From 9dd2a9e8973fe4e5c70dc4aa65683870281e4091 Mon Sep 17 00:00:00 2001 From: GangaManoj Date: Sat, 17 Jul 2021 17:42:36 +0530 Subject: [PATCH] fix: Create ledger entries for discount applied on taxes in make_tax_gl_entries --- .../accounts/doctype/purchase_invoice/purchase_invoice.py | 5 +++++ erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 5 +++++ erpnext/controllers/accounts_controller.py | 3 --- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 78d1ee972f..006f5bb0e8 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -888,6 +888,11 @@ class PurchaseInvoice(BuyingController): "remarks": self.remarks or "Accounting Entry for Stock" }, item=tax)) + enable_discount_accounting = cint(frappe.db.get_single_value('Accounts Settings', 'enable_discount_accounting')) + + if enable_discount_accounting and self.get('discount_amount') and self.get('additional_discount_account'): + self.make_gle_for_additional_discount_applied_on_taxes(gl_entries) + def make_internal_transfer_gl_entries(self, gl_entries): if self.is_internal_transfer() and flt(self.base_total_taxes_and_charges): account_currency = get_account_currency(self.unrealized_profit_loss_account) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 15fae84b79..ee9b59e769 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -902,6 +902,11 @@ class SalesInvoice(SellingController): }, account_currency, item=tax) ) + enable_discount_accounting = cint(frappe.db.get_single_value('Accounts Settings', 'enable_discount_accounting')) + + if enable_discount_accounting and self.get('discount_amount') and self.get('additional_discount_account'): + self.make_gle_for_additional_discount_applied_on_taxes(gl_entries) + def make_internal_transfer_gl_entries(self, gl_entries): if self.is_internal_transfer() and flt(self.base_total_taxes_and_charges): account_currency = get_account_currency(self.unrealized_profit_loss_account) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 8fc4023f2e..f4593c2a76 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -852,9 +852,6 @@ class AccountsController(TransactionBase): "project": item.project or self.project }, account_currency, item=item) ) - - if self.get('discount_amount') and self.get('additional_discount_account'): - self.make_gle_for_additional_discount_applied_on_taxes(gl_entries) def make_gle_for_additional_discount_applied_on_taxes(self, gl_entries): for tax in self.get("taxes"):