diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 5e27b3a69a9..4e4e507cae6 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -14,7 +14,7 @@ from erpnext.controllers.stock_controller import StockController class BuyingController(StockController): def __setup__(self): - if hasattr(self, "items"): + if hasattr(self, "taxes"): self.print_templates = { "taxes": "templates/print_formats/includes/taxes.html" } diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index e6ec2af3859..9cee5832b41 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -12,7 +12,7 @@ from erpnext.controllers.stock_controller import StockController class SellingController(StockController): def __setup__(self): - if hasattr(self, "items"): + if hasattr(self, "taxes"): self.print_templates = { "taxes": "templates/print_formats/includes/taxes.html" } diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 640bcea4a54..1b1527b7eb0 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -76,8 +76,9 @@ class calculate_taxes_and_totals(object): "tax_amount_for_current_item", "grand_total_for_current_item", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"] - if tax.charge_type != "Actual" and not self.discount_amount_applied: - tax_fields.append("tax_amount") + if tax.charge_type != "Actual" and \ + not (self.discount_amount_applied and self.doc.apply_discount_on=="Grand Total"): + tax_fields.append("tax_amount") for fieldname in tax_fields: tax.set(fieldname, 0.0) @@ -215,8 +216,9 @@ class calculate_taxes_and_totals(object): current_tax_amount += actual_tax_dict[tax.idx] # accumulate tax amount into tax.tax_amount - if tax.charge_type != "Actual" and not self.discount_amount_applied: - tax.tax_amount += current_tax_amount + if tax.charge_type != "Actual" and \ + not (self.discount_amount_applied and self.doc.apply_discount_on=="Grand Total"): + tax.tax_amount += current_tax_amount # store tax_amount for current item as it will be used for # charge type = 'On Previous Row Amount' @@ -250,8 +252,9 @@ class calculate_taxes_and_totals(object): 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: - self.adjust_discount_amount_loss(tax) + if i == (len(self.doc.get("taxes")) - 1) and self.discount_amount_applied \ + and self.doc.apply_discount_on == "Grand Total": + 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) @@ -291,7 +294,7 @@ class calculate_taxes_and_totals(object): tax.tax_amount = flt(tax.tax_amount, tax.precision("tax_amount")) tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, tax.precision("tax_amount")) - self._set_in_company_currency(tax, ["total", "tax_amount", "tax_amount_after_discount_amount"]); + self._set_in_company_currency(tax, ["total", "tax_amount", "tax_amount_after_discount_amount"]) def adjust_discount_amount_loss(self, tax): discount_amount_loss = self.doc.grand_total - flt(self.doc.discount_amount) - tax.total @@ -360,8 +363,8 @@ class calculate_taxes_and_totals(object): self.doc.base_discount_amount = 0 def get_total_for_discount_amount(self): - if self.doc.apply_discount_on == "Print Total": - return self.net_total + if self.doc.apply_discount_on == "Net Total": + return self.doc.net_total else: actual_taxes_dict = {} diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 652350ac801..21ad71fc5d0 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -93,11 +93,11 @@ cur_frm.pformat.in_words = function(doc) { return ''; } cur_frm.pformat.taxes= function(doc){ //function to make row of table - var make_row = function(title, val, bold){ + var make_row = function(title, val, bold, is_negative) { var bstart = ''; var bend = ''; return '