From 95ff2d4fed05d7128dcefb3a7299f388eaa73f6e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Mar 2015 16:02:03 +0530 Subject: [PATCH] discount loss adjustment in base currency --- .../sales_taxes_and_charges.json | 28 +++++++++++-------- erpnext/controllers/taxes_and_totals.py | 10 +++++-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json index 67f7ab4893..701f1aceba 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json +++ b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json @@ -48,16 +48,6 @@ "options": "Cost Center", "permlevel": 0 }, - { - "fieldname": "rate", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "rate", - "oldfieldtype": "Currency", - "permlevel": 0, - "reqd": 0 - }, { "fieldname": "col_break_1", "fieldtype": "Column Break", @@ -89,6 +79,22 @@ "report_hide": 1, "width": "150px" }, + { + "fieldname": "section_break_8", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "rate", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 0 + }, { "fieldname": "section_break_9", "fieldtype": "Section Break", @@ -186,7 +192,7 @@ "hide_heading": 1, "idx": 1, "istable": 1, - "modified": "2015-02-25 02:50:44.152307", + "modified": "2015-03-04 15:16:30.732876", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Taxes and Charges", diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 9637f39f50..a4be3f9ef5 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -226,11 +226,13 @@ class calculate_taxes_and_totals(object): # set precision in the last item iteration if n == len(self.doc.get("items")) - 1: self.round_off_totals(tax) - + # adjust Discount Amount loss in last tax iteration if i == (len(self.doc.get("taxes")) - 1) and self.discount_amount_applied \ and self.doc.discount_amount: self.adjust_discount_amount_loss(tax) + + def get_current_tax_amount(self, item, tax, item_tax_map): tax_rate = self._get_tax_rate(tax, item_tax_map) @@ -275,8 +277,10 @@ class calculate_taxes_and_totals(object): def adjust_discount_amount_loss(self, tax): discount_amount_loss = self.doc.grand_total - flt(self.doc.discount_amount) - tax.total tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount + - discount_amount_loss, self.doc.precision("tax_amount", tax)) - tax.total = flt(tax.total + discount_amount_loss, self.doc.precision("total", tax)) + discount_amount_loss, tax.precision("tax_amount")) + tax.total = flt(tax.total + discount_amount_loss, tax.precision("total")) + + self._set_in_company_currency(tax, ["total", "tax_amount_after_discount_amount"]) def calculate_totals(self): self.doc.grand_total = flt(self.doc.get("taxes")[-1].total