mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 03:29:16 +00:00
Merge pull request #52630 from mendozal/fix-compute-tax-net-amount-in-js
fix(account): compute tax net_amount in JS controller
This commit is contained in:
@@ -191,6 +191,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
tax.item_wise_tax_detail = {};
|
tax.item_wise_tax_detail = {};
|
||||||
}
|
}
|
||||||
var tax_fields = [
|
var tax_fields = [
|
||||||
|
"net_amount",
|
||||||
"total",
|
"total",
|
||||||
"tax_amount_after_discount_amount",
|
"tax_amount_after_discount_amount",
|
||||||
"tax_amount_for_current_item",
|
"tax_amount_for_current_item",
|
||||||
@@ -400,9 +401,14 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
var item_tax_map = me._load_item_tax_rate(item.item_tax_rate);
|
var item_tax_map = me._load_item_tax_rate(item.item_tax_rate);
|
||||||
$.each(doc.taxes, function (i, tax) {
|
$.each(doc.taxes, function (i, tax) {
|
||||||
// tax_amount represents the amount of tax for the current step
|
// tax_amount represents the amount of tax for the current step
|
||||||
var current_tax_amount = me.get_current_tax_amount(item, tax, item_tax_map);
|
var [current_net_amount, current_tax_amount] = me.get_current_tax_amount(
|
||||||
|
item,
|
||||||
|
tax,
|
||||||
|
item_tax_map
|
||||||
|
);
|
||||||
if (frappe.flags.round_row_wise_tax) {
|
if (frappe.flags.round_row_wise_tax) {
|
||||||
current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax));
|
current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax));
|
||||||
|
current_net_amount = flt(current_net_amount, precision("net_amount", tax));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust divisional loss to the last item
|
// Adjust divisional loss to the last item
|
||||||
@@ -419,6 +425,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
!(me.discount_amount_applied && me.frm.doc.apply_discount_on == "Grand Total")
|
!(me.discount_amount_applied && me.frm.doc.apply_discount_on == "Grand Total")
|
||||||
) {
|
) {
|
||||||
tax.tax_amount += current_tax_amount;
|
tax.tax_amount += current_tax_amount;
|
||||||
|
tax.net_amount += current_net_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// store tax_amount for current item as it will be used for
|
// store tax_amount for current item as it will be used for
|
||||||
@@ -480,7 +487,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
|
|
||||||
for (const [i, tax] of doc.taxes.entries()) {
|
for (const [i, tax] of doc.taxes.entries()) {
|
||||||
me.round_off_totals(tax);
|
me.round_off_totals(tax);
|
||||||
me.set_in_company_currency(tax, ["tax_amount", "tax_amount_after_discount_amount"]);
|
me.set_in_company_currency(tax, ["tax_amount", "tax_amount_after_discount_amount", "net_amount"]);
|
||||||
|
|
||||||
me.round_off_base_values(tax);
|
me.round_off_base_values(tax);
|
||||||
|
|
||||||
@@ -555,7 +562,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
current_tax_amount = tax_rate * item.qty;
|
current_tax_amount = tax_rate * item.qty;
|
||||||
}
|
}
|
||||||
|
|
||||||
return current_tax_amount;
|
return [current_net_amount, current_tax_amount];
|
||||||
}
|
}
|
||||||
|
|
||||||
round_off_totals(tax) {
|
round_off_totals(tax) {
|
||||||
@@ -565,6 +572,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tax.tax_amount = flt(tax.tax_amount, precision("tax_amount", tax));
|
tax.tax_amount = flt(tax.tax_amount, precision("tax_amount", tax));
|
||||||
|
tax.net_amount = flt(tax.net_amount, precision("net_amount", tax));
|
||||||
tax.tax_amount_after_discount_amount = flt(
|
tax.tax_amount_after_discount_amount = flt(
|
||||||
tax.tax_amount_after_discount_amount,
|
tax.tax_amount_after_discount_amount,
|
||||||
precision("tax_amount", tax)
|
precision("tax_amount", tax)
|
||||||
|
|||||||
Reference in New Issue
Block a user