diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py index d7c9441e8c..b3007fe55a 100644 --- a/controllers/accounts_controller.py +++ b/controllers/accounts_controller.py @@ -190,9 +190,6 @@ class AccountsController(TransactionBase): # accumulate tax amount into tax.tax_amount tax.tax_amount += current_tax_amount - # store tax breakup for each item - tax.item_wise_tax_detail[item.item_code] = current_tax_amount - if tax.category: # if just for valuation, do not add the tax amount in total # hence, setting it as 0 for further steps @@ -233,8 +230,13 @@ class AccountsController(TransactionBase): elif tax.charge_type == "On Previous Row Total": current_tax_amount = (tax_rate / 100.0) * \ self.tax_doclist[cint(tax.row_id) - 1].grand_total_for_current_item + + current_tax_amount = flt(current_tax_amount, self.precision("tax_amount", tax)) + + # store tax breakup for each item + tax.item_wise_tax_detail[item.item_code or item.item_name] = [tax_rate, current_tax_amount] - return flt(current_tax_amount, self.precision("tax_amount", tax)) + return current_tax_amount def _load_item_tax_rate(self, item_tax_rate): return json.loads(item_tax_rate) if item_tax_rate else {} diff --git a/public/js/transaction.js b/public/js/transaction.js index 78f792d018..9004a999d0 100644 --- a/public/js/transaction.js +++ b/public/js/transaction.js @@ -259,10 +259,18 @@ erpnext.TransactionController = wn.ui.form.Controller.extend({ $.each(this.get_tax_doclist(), function(i, tax) { var tax_amount_precision = precision("tax_amount", tax); + var tax_rate_precision = precision("rate", tax); $.each(JSON.parse(tax.item_wise_tax_detail || '{}'), - function(item_code, tax_amount) { + function(item_code, tax_data) { if(!item_tax[item_code]) item_tax[item_code] = {}; - item_tax[item_code][tax.account_head] = flt(tax_amount, tax_amount_precision); + if($.isArray(tax_data)) { + var tax_rate = tax_data[0] == null ? "" : (flt(tax_data[0], tax_rate_precision) + "%"), + tax_amount = format_currency(flt(tax_data[1], tax_amount_precision), company_currency); + + item_tax[item_code][tax.account_head] = [tax_rate, tax_amount]; + } else { + item_tax[item_code][tax.account_head] = [flt(tax_data, tax_rate_precision) + "%", ""]; + } }); tax_accounts.push(tax.account_head); }); @@ -272,14 +280,16 @@ erpnext.TransactionController = wn.ui.form.Controller.extend({ var rows = $.map(this.get_item_doclist(), function(item) { var item_tax_record = item_tax[item.item_code || item.item_name]; + if(!item_tax_record) { return null; } return repl("