Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion rohit_common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@

from rohit_common.overrides.file import get_permission_query_conditions,has_permission
frappe.frappe.core.doctype.file.file.has_permission=has_permission
frappe.frappe.core.doctype.file.file.get_permission_query_conditions=get_permission_query_conditions
frappe.frappe.core.doctype.file.file.get_permission_query_conditions=get_permission_query_conditions

# Override for EInvoiceData.get_data
# from india_compliance.gst_india.utils.e_invoice import EInvoiceData
# from rohit_common.overrides.india_compliance_einvoice import custom_get_data
# EInvoiceData.get_data = custom_get_data
72 changes: 72 additions & 0 deletions rohit_common/fixtures/custom_docperm.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
[
{
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"docstatus": 0,
"doctype": "Custom DocPerm",
"email": 1,
"export": 1,
"if_owner": 0,
"import": 1,
"modified": "2025-09-24 15:08:40.557587",
"name": "m7hut3b1u5",
"parent": "e-Invoice Log",
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"select": 1,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"cancel": 0,
Expand Down Expand Up @@ -46,5 +70,53 @@
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 1,
"docstatus": 0,
"doctype": "Custom DocPerm",
"email": 1,
"export": 1,
"if_owner": 0,
"import": 0,
"modified": "2025-09-24 15:08:32.029829",
"name": "m7goptn66e",
"parent": "e-Invoice Log",
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts Manager",
"select": 0,
"share": 1,
"submit": 0,
"write": 0
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 1,
"docstatus": 0,
"doctype": "Custom DocPerm",
"email": 1,
"export": 1,
"if_owner": 0,
"import": 0,
"modified": "2025-09-24 15:08:32.127716",
"name": "m7hfu12j3g",
"parent": "e-Invoice Log",
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts User",
"select": 0,
"share": 1,
"submit": 0,
"write": 0
}
]
3 changes: 2 additions & 1 deletion rohit_common/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"parent",
"in",
[
"File"
"File",
"e-Invoice Log"
],
]
],
Expand Down
47 changes: 47 additions & 0 deletions rohit_common/overrides/india_compliance_einvoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import frappe
from collections import defaultdict
from india_compliance.gst_india.utils.e_invoice import EInvoiceData

original_get_data = EInvoiceData.get_data

def custom_get_data(self):
frappe.log_error("Custom get_data called", "EInvoice Patch")
data = original_get_data(self)

# Summarize ItemList by HSN
summarized = defaultdict(lambda: {
"HsnCd": "",
"IsServc": "N",
"GstRt": 0,
"AssAmt": 0.0,
"CgstAmt": 0.0,
"SgstAmt": 0.0,
"IgstAmt": 0.0,
"CesAmt": 0.0,
"TotItemVal": 0.0
})

for item in data.get("ItemList", []):
hsn = item.get("HsnCd")
s = summarized[hsn]

if not s["HsnCd"]:
s["HsnCd"] = hsn
s["IsServc"] = item.get("IsServc", "N")
s["GstRt"] = item.get("GstRt", 0)

for k in ["AssAmt","CgstAmt","SgstAmt","IgstAmt","CesAmt","TotItemVal"]:
s[k] += item.get(k, 0.0)

new_items = []
for i, (hsn, vals) in enumerate(summarized.items(), 1):
vals["SlNo"] = str(i)
vals["PrdDesc"] = f"Goods with HSN {hsn}"
vals["Qty"] = 1.0
vals["Unit"] = "OTH"
vals["UnitPrice"] = vals["AssAmt"]
vals["TotAmt"] = vals["AssAmt"]
new_items.append(vals)

data["ItemList"] = new_items
return data
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"absolute_value": 0,
"align_labels_right": 0,
"creation": "2025-09-24 14:40:27.316661",
"custom_format": 1,
"default_print_language": "en",
"disabled": 0,
"doc_type": "e-Invoice Log",
"docstatus": 0,
"doctype": "Print Format",
"font_size": 14,
"html": "<style>\n {% include \"india_compliance/gst_india/print_format/e_invoice/e_invoice.css\" %}\n</style>\n\n{%- from \"templates/print_formats/standard_macros.html\" import add_header, render_field, print_value -%}\n\n{% if not doc.irn %}\n<div class=\"text-center no-preview-available\">\n Please generate an e-Invoice to preview it.\n</div>\n\n{% else %}\n{% set e_invoice_log = frappe.db.get_value(\n \"e-Invoice Log\", doc.irn, (\"invoice_data\", \"signed_qr_code\"), as_dict=True\n) %}\n\n{% if not e_invoice_log %}\n<div class=\"text-center no-preview-available\">\n The e-Invoice Log linked to this Sales Invoice could not be found.\n</div>\n\n{% else %}\n{% if not e_invoice_log.invoice_data %}\n<div class=\"text-center no-preview-available\">\n Invoice Data is not available in the e-Invoice Log linked to this invoice.\n</div>\n\n{% else %}\n{%- set invoice_data = _dict(json.loads(e_invoice_log.invoice_data)) -%}\n\n{% macro get_address_html(address) %}\n{% for field in (\"Gstin\", \"LglNm\", \"Nm\", \"Addr1\", \"Addr2\", \"Loc\") %}\n{% if address.get(field) %}\n<p>{{ address[field] }}</p>\n{% endif %}\n{% endfor %}\n<p>{{ get_state(address[\"Stcd\"]) }} - {{ address[\"Pin\"] }}</p>\n{%- endmacro %}\n\n<div {% if print_settings.repeat_header_footer %} id=\"header-html\" class=\"hidden-pdf\" {% endif %}>\n {% if letter_head and not no_letterhead %}\n <div class=\"letter-head\">{{ letter_head }}</div>\n {% endif %}\n <div class=\"print-heading text-right\">\n <h2>e-Invoice<br></h2>\n <span class=\"docname\">{{ doc.name }}</span>\n </div>\n</div>\n\n{% if print_settings.repeat_header_footer %}\n<div id=\"footer-html\" class=\"visible-pdf\">\n {% if not no_letterhead and footer %}\n <div class=\"letter-head-footer\">\n {{ footer }}\n </div>\n {% endif %}\n <p class=\"text-center small page-number visible-pdf\">\n {{ _(\"Page {0} of {1}\").format('<span class=\"page\"></span>', '<span class=\"topage\"></span>') }}\n </p>\n</div>\n{% endif %}\n\n<h5 class=\"section-heading\">1. Transaction Details</h5>\n<div class=\"row section-break info-section\">\n <div class=\"col-xs-8 column-break\">\n {%\n set transaction_details = {\n \"IRN\": invoice_data.Irn,\n \"Category\": invoice_data.TranDtls.SupTyp,\n \"Document Type\": invoice_data.DocDtls.Typ,\n \"Document No.\": invoice_data.DocDtls.No,\n \"e-Waybill No.\": doc.ewaybill,\n }\n %}\n {% for key, value in transaction_details.items() %}\n {% if value %}\n <div class=\"row data-field\">\n <div class=\"col-xs-4\"><label>{{ key }}</label></div>\n <div class=\"col-xs-8 value\">{{ value }}</div>\n </div>\n {% endif %}\n {% endfor %}\n </div>\n <!-- QR Code removed -->\n</div>\n\n<h5 class=\"section-heading\">2. Party Details</h5>\n<div class=\"row section-break info-section\">\n <div class=\"col-xs-6 column-break\">\n <h6 class=\"address-heading\">\n {% if invoice_data.DispDtls %}\n Seller Details\n {% else %}\n Seller and Dispatch Details\n {% endif %}\n </h6>\n {{ get_address_html(invoice_data.SellerDtls) }}\n\n {%- if invoice_data.DispDtls -%}\n <h6 class=\"address-heading\">Dispatched From</h6>\n {{ get_address_html(invoice_data.DispDtls) }}\n {% endif %}\n </div>\n <div class=\"col-xs-6 column-break\">\n <h6 class=\"address-heading\">\n {% if invoice_data.ShipDtls %}\n Buyer Details\n {% else %}\n Buyer and Shipping Details\n {% endif %}\n </h6>\n {{ get_address_html(invoice_data.BuyerDtls) }}\n\n {%- if invoice_data.ShipDtls -%}\n <h6 class=\"address-heading\">Shipped To</h6>\n {{ get_address_html(invoice_data.ShipDtls) }}\n {% endif %}\n </div>\n</div>\n\n{% set items = invoice_data.ItemList %}\n{% set item_fields = get_e_invoice_item_fields(items) %}\n<h5 class=\"section-heading\">3. Item Details</h5>\n<div class=\"row section-break info-section item-details\">\n<div class=\"col-xs-12 column-break\">\n <table class=\"table table-bordered e-invoice-table\">\n <thead>\n <tr>\n {% for field, label in item_fields.items() %}\n <th\n {% if field not in (\"HsnCd\", \"PrdDesc\", \"Unit\") -%}\n class=\"text-right\"\n {%- endif -%}\n >{{ label }}</th>\n {% endfor %}\n </tr>\n </thead>\n <tbody>\n {% for item in items %}\n <tr>\n {% for field in item_fields %}\n {% set value = item[field] %}\n <!-- Currency -->\n {% if field.endswith((\"Val\", \"Amt\", \"Price\")) or field == \"Discount\" %}\n <td class=\"text-right text-nowrap\">\n {{ frappe.utils.fmt_money(value, currency=\"INR\") }}\n </td>\n {% elif field.endswith(\"Rt\") %}\n <td class=\"text-right text-nowrap\">\n {% if value % 1 == 0 %}\n {{ \"{}%\".format(frappe.utils.cint(value)) }}\n {% elif value % 0.1 == 0 %}\n {{ \"{}%\".format(frappe.utils.flt(value, 1)) }}\n {% else %}\n {{ \"{}%\".format(frappe.utils.flt(value, 2)) }}\n {% endif %}\n </td>\n {% elif value is not string or field == \"SlNo\" %}\n <td class=\"text-right\">{{ value }}</td>\n {% else %}\n <td class=\"text-left\">{{ value }}</td>\n {% endif %}\n {% endfor %}\n </tr>\n {% endfor %}\n </tbody>\n </table>\n</div>\n</div>\n\n{%- set amounts = invoice_data.ValDtls -%}\n{% set amount_fields = get_e_invoice_amount_fields(amounts, doc) %}\n<h5 class=\"section-heading\">4. Value Details</h5>\n<div class=\"row section-break\">\n<div class=\"col-xs-12 column-break\">\n <table class=\"table table-bordered e-invoice-table\">\n <thead>\n <tr>\n {% for field, label in amount_fields.items() %}\n <th class=\"text-right\">{{ label }}</th>\n {% endfor %}\n </tr>\n </thead>\n <tbody>\n <tr>\n {% for field in amount_fields %}\n <td class=\"text-right text-nowrap\">\n {{ frappe.utils.fmt_money(amounts[field], currency=\"INR\")}}\n </td>\n {% endfor %}\n </tr>\n </tbody>\n </table>\n</div>\n</div>\n\n{% endif %}\n{% endif %}\n{% endif %}",
"idx": 0,
"line_breaks": 0,
"margin_bottom": 15.0,
"margin_left": 15.0,
"margin_right": 15.0,
"margin_top": 15.0,
"modified": "2025-09-24 14:40:37.321167",
"modified_by": "Administrator",
"module": "rohit_common",
"name": "RIGPL IC e-Invoice",
"owner": "Administrator",
"page_number": "Hide",
"pdf_generator": "wkhtmltopdf",
"print_format_builder": 0,
"print_format_builder_beta": 0,
"print_format_for": "DocType",
"print_format_type": "Jinja",
"raw_printing": 0,
"show_section_headings": 0,
"standard": "Yes"
}