diff --git a/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.js b/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.js index 5495dba1e..171184287 100644 --- a/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.js +++ b/india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.js @@ -372,7 +372,12 @@ class TaxesController { const item_wise_tax_rates = JSON.parse(tax_row.item_wise_tax_rates || "{}"); return this.frm.doc.items.reduce((total, item) => { - return total + (item.taxable_value * item_wise_tax_rates[item.name]) / 100; + return ( + total + + (item.taxable_value * + (item_wise_tax_rates[item.name] || tax_row.rate)) / + 100 + ); }, 0); } @@ -386,7 +391,7 @@ class TaxesController { const item_wise_tax_rates = JSON.parse(tax_row.item_wise_tax_rates || "{}"); return this.frm.doc.items.reduce((total, item) => { - return total + (item.qty * item_wise_tax_rates[item.name]); + return total + item.qty * (item_wise_tax_rates[item.name] || tax_row.rate); }, 0); } } diff --git a/india_compliance/gst_india/overrides/subcontracting_transaction.py b/india_compliance/gst_india/overrides/subcontracting_transaction.py index b3a02aced..75e003bd6 100644 --- a/india_compliance/gst_india/overrides/subcontracting_transaction.py +++ b/india_compliance/gst_india/overrides/subcontracting_transaction.py @@ -34,6 +34,7 @@ SUBCONTRACTING_ORDER_RECEIPT_FIELD_MAP = {"total_taxable_value": "total"} +# Functions to perform operations before and after mapping of transactions def after_mapping_subcontracting_order(doc, method, source_doc): if source_doc.doctype != "Purchase Order": return @@ -74,6 +75,13 @@ def after_mapping_stock_entry(doc, method, source_doc): doc.taxes = [] +def before_mapping_subcontracting_receipt(doc, method, source_doc, table_maps): + table_maps["India Compliance Taxes and Charges"] = { + "doctype": "India Compliance Taxes and Charges", + "add_if_empty": True, + } + + def set_taxes(doc): accounts = get_gst_accounts_by_type(doc.company, "Output", throw=False) if not accounts: @@ -116,6 +124,7 @@ def set_taxes(doc): ) +# Common Functions for Suncontracting Transactions def get_dashboard_data(data): doctype = ( "Subcontracting Receipt" diff --git a/india_compliance/hooks.py b/india_compliance/hooks.py index 8301a6df5..28d273e00 100644 --- a/india_compliance/hooks.py +++ b/india_compliance/hooks.py @@ -243,6 +243,7 @@ "Subcontracting Receipt": { "onload": "india_compliance.gst_india.overrides.subcontracting_transaction.onload", "validate": "india_compliance.gst_india.overrides.subcontracting_transaction.validate", + "before_mapping": "india_compliance.gst_india.overrides.subcontracting_transaction.before_mapping_subcontracting_receipt", }, "Supplier": { "validate": [ diff --git a/india_compliance/public/js/taxes_controller.js b/india_compliance/public/js/taxes_controller.js index cb17cbdd9..6c6717ed0 100644 --- a/india_compliance/public/js/taxes_controller.js +++ b/india_compliance/public/js/taxes_controller.js @@ -73,7 +73,7 @@ india_compliance.taxes_controller = class TaxesController { ).options, master_name: this.frm.doc.taxes_and_charges, }, - callback: async (r) => { + callback: async r => { if (!r.exc) { this.frm.set_value("taxes", r.message); await this.set_item_wise_tax_rates(); @@ -82,7 +82,7 @@ india_compliance.taxes_controller = class TaxesController { }, }); } - }; + } update_item_wise_tax_rates(tax_row) { /** @@ -190,7 +190,9 @@ india_compliance.taxes_controller = class TaxesController { item.charge_type === "On Item Quantity" ? item.qty : item.taxable_value / 100; - return total + multiplier * item_wise_tax_rates[item.name]; + return ( + total + multiplier * (item_wise_tax_rates[item.name] || tax_row.rate) + ); }, 0); }