From 13092bcc2dbb312ef5367ca74f6bfe90e72950b2 Mon Sep 17 00:00:00 2001 From: rahib-hassan Date: Wed, 20 Apr 2022 16:46:29 +0530 Subject: [PATCH] fix: enable discount roll_back --- .../doctype/purchase_invoice/test_purchase_invoice.py | 8 ++++++++ .../accounts/doctype/sales_invoice/test_sales_invoice.py | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 30d26acf3a..e894252f5d 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -354,6 +354,7 @@ class TestPurchaseInvoice(unittest.TestCase): ] check_gl_entries(self, pi.name, expected_gle, nowdate()) + enable_discount_accounting(enable=0) @change_settings("Buying Settings", {"enable_discount_accounting": 1}) def test_additional_discount_for_purchase_invoice_with_discount_accounting_enabled(self): @@ -389,6 +390,7 @@ class TestPurchaseInvoice(unittest.TestCase): ] check_gl_entries(self, pi.name, expected_gle, nowdate()) + enable_discount_accounting(enable=0) def test_purchase_invoice_change_naming_series(self): pi = frappe.copy_doc(test_records[1]) @@ -1530,6 +1532,12 @@ class TestPurchaseInvoice(unittest.TestCase): company.save() +def enable_discount_accounting(enable=1): + buying_settings = frappe.get_doc("Buying Settings") + buying_settings.enable_discount_accounting = enable + buying_settings.save() + + def check_gl_entries(doc, voucher_no, expected_gle, posting_date): gl_entries = frappe.db.sql( """select account, debit, credit, posting_date diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 98a5755f71..e4df20f6b7 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -2702,6 +2702,7 @@ class TestSalesInvoice(unittest.TestCase): ] check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1)) + enable_discount_accounting(enable=0) @change_settings("Selling Settings", {"enable_discount_accounting": 1}) def test_additional_discount_for_sales_invoice_with_discount_accounting_enabled(self): @@ -2736,6 +2737,7 @@ class TestSalesInvoice(unittest.TestCase): ] check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1)) + enable_discount_accounting(enable=0) def test_asset_depreciation_on_sale_with_pro_rata(self): """ @@ -3173,6 +3175,12 @@ class TestSalesInvoice(unittest.TestCase): ) +def enable_discount_accounting(enable=1): + selling_settings = frappe.get_doc("Selling Settings") + selling_settings.enable_discount_accounting = enable + selling_settings.save() + + def get_sales_invoice_for_e_invoice(): si = make_sales_invoice_for_ewaybill() si.naming_series = "INV-2020-.#####"