fix: Create ledger entries for discount applied on taxes in make_tax_gl_entries
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index 78d1ee9..006f5bb 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -888,6 +888,11 @@
"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 15fae84..ee9b59e 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -902,6 +902,11 @@
}, 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 8fc4023..f4593c2 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -852,9 +852,6 @@
"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"):