From 179e3772c0c331cb6752bbd0f4911928518e2bc2 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 5 Sep 2013 16:53:57 +0530 Subject: [PATCH] [fix] [minor] item wise taxes --- controllers/accounts_controller.py | 7 ++++++- public/js/transaction.js | 13 ++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py index a3dae8e2e8..4ee7e53e15 100644 --- a/controllers/accounts_controller.py +++ b/controllers/accounts_controller.py @@ -291,7 +291,12 @@ class AccountsController(TransactionBase): 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] + key = item.item_code or item.item_name + if tax.item_wise_tax_detail.get(key): + item_wise_tax_amount = tax.item_wise_tax_detail[key][1] + current_tax_amount + tax.item_wise_tax_detail[key] = [tax_rate, item_wise_tax_amount] + else: + tax.item_wise_tax_detail[key] = [tax_rate, current_tax_amount] return current_tax_amount diff --git a/public/js/transaction.js b/public/js/transaction.js index 1d06a9f487..0ff957a820 100644 --- a/public/js/transaction.js +++ b/public/js/transaction.js @@ -338,8 +338,19 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ var headings = $.map([wn._("Item Name")].concat($.map(tax_accounts, function(head) { return head[1]; })), function(head) { return '' + (head || "") + "" }).join("\n"); + + var distinct_item_names = []; + var distinct_items = []; + $.each(this.get_item_doclist(), function(i, item) { + if(distinct_item_names.indexOf(item.item_code || item.item_name)===-1) { + distinct_item_names.push(item.item_code || item.item_name); + distinct_items.push(item); + } + }); - var rows = $.map(this.get_item_doclist(), function(item) { + console.log(distinct_items); + + var rows = $.map(distinct_items, function(item) { var item_tax_record = item_tax[item.item_code || item.item_name]; if(!item_tax_record) { return null; } return repl("%(item_name)s%(taxes)s", {