Merge pull request #36780 from rtdany10/rounded-row-wise-tax
feat: item(row) wise tax amount rounding
This commit is contained in:
commit
10a9a7c52a
@ -32,6 +32,7 @@
|
|||||||
"column_break_19",
|
"column_break_19",
|
||||||
"add_taxes_from_item_tax_template",
|
"add_taxes_from_item_tax_template",
|
||||||
"book_tax_discount_loss",
|
"book_tax_discount_loss",
|
||||||
|
"round_row_wise_tax",
|
||||||
"print_settings",
|
"print_settings",
|
||||||
"show_inclusive_tax_in_print",
|
"show_inclusive_tax_in_print",
|
||||||
"show_taxes_as_table_in_print",
|
"show_taxes_as_table_in_print",
|
||||||
@ -414,6 +415,13 @@
|
|||||||
"fieldname": "ignore_account_closing_balance",
|
"fieldname": "ignore_account_closing_balance",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Ignore Account Closing Balance"
|
"label": "Ignore Account Closing Balance"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"description": "Tax Amount will be rounded on a row(items) level",
|
||||||
|
"fieldname": "round_row_wise_tax",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Round Tax Amount Row-wise"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-cog",
|
"icon": "icon-cog",
|
||||||
@ -421,7 +429,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-07-27 15:05:34.000264",
|
"modified": "2023-08-28 00:12:02.740633",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Accounts Settings",
|
"name": "Accounts Settings",
|
||||||
|
@ -25,6 +25,9 @@ class calculate_taxes_and_totals(object):
|
|||||||
def __init__(self, doc: Document):
|
def __init__(self, doc: Document):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
frappe.flags.round_off_applicable_accounts = []
|
frappe.flags.round_off_applicable_accounts = []
|
||||||
|
frappe.flags.round_row_wise_tax = frappe.db.get_single_value(
|
||||||
|
"Accounts Settings", "round_row_wise_tax"
|
||||||
|
)
|
||||||
|
|
||||||
self._items = self.filter_rows() if self.doc.doctype == "Quotation" else self.doc.get("items")
|
self._items = self.filter_rows() if self.doc.doctype == "Quotation" else self.doc.get("items")
|
||||||
|
|
||||||
@ -370,6 +373,8 @@ class calculate_taxes_and_totals(object):
|
|||||||
for i, tax in enumerate(self.doc.get("taxes")):
|
for i, tax in enumerate(self.doc.get("taxes")):
|
||||||
# tax_amount represents the amount of tax for the current step
|
# tax_amount represents the amount of tax for the current step
|
||||||
current_tax_amount = self.get_current_tax_amount(item, tax, item_tax_map)
|
current_tax_amount = self.get_current_tax_amount(item, tax, item_tax_map)
|
||||||
|
if frappe.flags.round_row_wise_tax:
|
||||||
|
current_tax_amount = flt(current_tax_amount, tax.precision("tax_amount"))
|
||||||
|
|
||||||
# Adjust divisional loss to the last item
|
# Adjust divisional loss to the last item
|
||||||
if tax.charge_type == "Actual":
|
if tax.charge_type == "Actual":
|
||||||
@ -480,6 +485,15 @@ class calculate_taxes_and_totals(object):
|
|||||||
# store tax breakup for each item
|
# store tax breakup for each item
|
||||||
key = item.item_code or item.item_name
|
key = item.item_code or item.item_name
|
||||||
item_wise_tax_amount = current_tax_amount * self.doc.conversion_rate
|
item_wise_tax_amount = current_tax_amount * self.doc.conversion_rate
|
||||||
|
if frappe.flags.round_row_wise_tax:
|
||||||
|
item_wise_tax_amount = flt(item_wise_tax_amount, tax.precision("tax_amount"))
|
||||||
|
if tax.item_wise_tax_detail.get(key):
|
||||||
|
item_wise_tax_amount += flt(tax.item_wise_tax_detail[key][1], tax.precision("tax_amount"))
|
||||||
|
tax.item_wise_tax_detail[key] = [
|
||||||
|
tax_rate,
|
||||||
|
flt(item_wise_tax_amount, tax.precision("tax_amount")),
|
||||||
|
]
|
||||||
|
else:
|
||||||
if tax.item_wise_tax_detail.get(key):
|
if tax.item_wise_tax_detail.get(key):
|
||||||
item_wise_tax_amount += tax.item_wise_tax_detail[key][1]
|
item_wise_tax_amount += tax.item_wise_tax_detail[key][1]
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
frappe.flags.round_off_applicable_accounts = [];
|
frappe.flags.round_off_applicable_accounts = [];
|
||||||
|
|
||||||
if (me.frm.doc.company) {
|
if (me.frm.doc.company) {
|
||||||
return frappe.call({
|
frappe.call({
|
||||||
"method": "erpnext.controllers.taxes_and_totals.get_round_off_applicable_accounts",
|
"method": "erpnext.controllers.taxes_and_totals.get_round_off_applicable_accounts",
|
||||||
"args": {
|
"args": {
|
||||||
"company": me.frm.doc.company,
|
"company": me.frm.doc.company,
|
||||||
@ -206,6 +206,11 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frappe.db.get_single_value("Accounts Settings", "round_row_wise_tax")
|
||||||
|
.then((round_row_wise_tax) => {
|
||||||
|
frappe.flags.round_row_wise_tax = round_row_wise_tax;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
determine_exclusive_rate() {
|
determine_exclusive_rate() {
|
||||||
@ -346,6 +351,9 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
$.each(me.frm.doc["taxes"] || [], function(i, tax) {
|
$.each(me.frm.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_tax_amount = me.get_current_tax_amount(item, tax, item_tax_map);
|
||||||
|
if (frappe.flags.round_row_wise_tax) {
|
||||||
|
current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax));
|
||||||
|
}
|
||||||
|
|
||||||
// Adjust divisional loss to the last item
|
// Adjust divisional loss to the last item
|
||||||
if (tax.charge_type == "Actual") {
|
if (tax.charge_type == "Actual") {
|
||||||
@ -480,8 +488,15 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let item_wise_tax_amount = current_tax_amount * this.frm.doc.conversion_rate;
|
let item_wise_tax_amount = current_tax_amount * this.frm.doc.conversion_rate;
|
||||||
|
if (frappe.flags.round_row_wise_tax) {
|
||||||
|
item_wise_tax_amount = flt(item_wise_tax_amount, precision("tax_amount", tax));
|
||||||
|
if (tax_detail && tax_detail[key]) {
|
||||||
|
item_wise_tax_amount += flt(tax_detail[key][1], precision("tax_amount", tax));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (tax_detail && tax_detail[key])
|
if (tax_detail && tax_detail[key])
|
||||||
item_wise_tax_amount += tax_detail[key][1];
|
item_wise_tax_amount += tax_detail[key][1];
|
||||||
|
}
|
||||||
|
|
||||||
tax_detail[key] = [tax_rate, flt(item_wise_tax_amount, precision("base_tax_amount", tax))];
|
tax_detail[key] = [tax_rate, flt(item_wise_tax_amount, precision("base_tax_amount", tax))];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user