Skip to content

Commit

Permalink
Merge pull request #2539 from resilient-tech/mergify/bp/version-15-ho…
Browse files Browse the repository at this point in the history
…tfix/pr-2511

fix: UX fixes for Taxes in Subcontracting Docs (backport #2511)
  • Loading branch information
mergify[bot] authored Aug 22, 2024
2 parents e3668a3 + 8eb7358 commit 9443952
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -116,6 +124,7 @@ def set_taxes(doc):
)


# Common Functions for Suncontracting Transactions
def get_dashboard_data(data):
doctype = (
"Subcontracting Receipt"
Expand Down
1 change: 1 addition & 0 deletions india_compliance/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
8 changes: 5 additions & 3 deletions india_compliance/public/js/taxes_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -82,7 +82,7 @@ india_compliance.taxes_controller = class TaxesController {
},
});
}
};
}

update_item_wise_tax_rates(tax_row) {
/**
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 9443952

Please sign in to comment.