fix: use @change_settings to enable_discount_account
This commit is contained in:
parent
f3fa6ac4c2
commit
1e143e7479
@ -5,6 +5,7 @@
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
from frappe.tests.utils import change_settings
|
||||
from frappe.utils import add_days, cint, flt, getdate, nowdate, today
|
||||
|
||||
import erpnext
|
||||
@ -336,8 +337,8 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
|
||||
self.assertEqual(discrepancy_caused_by_exchange_rate_diff, amount)
|
||||
|
||||
@change_settings("Buying Settings", {"enable_discount_accounting": 1})
|
||||
def test_purchase_invoice_with_discount_accounting_enabled(self):
|
||||
enable_discount_accounting()
|
||||
|
||||
discount_account = create_account(
|
||||
account_name="Discount Account",
|
||||
@ -353,10 +354,10 @@ 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):
|
||||
enable_discount_accounting()
|
||||
|
||||
additional_discount_account = create_account(
|
||||
account_name="Discount Account",
|
||||
parent_account="Indirect Expenses - _TC",
|
||||
@ -1588,12 +1589,6 @@ def unlink_payment_on_cancel_of_invoice(enable=1):
|
||||
accounts_settings.save()
|
||||
|
||||
|
||||
def enable_discount_accounting(enable=1):
|
||||
buying_settings = frappe.get_doc("Buying Settings")
|
||||
buying_settings.enable_discount_accounting = enable
|
||||
buying_settings.save()
|
||||
|
||||
|
||||
def make_purchase_invoice(**args):
|
||||
pi = frappe.new_doc("Purchase Invoice")
|
||||
args = frappe._dict(args)
|
||||
|
@ -7,6 +7,7 @@ import unittest
|
||||
import frappe
|
||||
from frappe.model.dynamic_links import get_dynamic_link_map
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe.tests.utils import change_settings
|
||||
from frappe.utils import add_days, flt, getdate, nowdate
|
||||
|
||||
import erpnext
|
||||
@ -2684,10 +2685,9 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC"
|
||||
)
|
||||
|
||||
@change_settings("Selling Settings", {"enable_discount_accounting": 1})
|
||||
def test_sales_invoice_with_discount_accounting_enabled(self):
|
||||
|
||||
enable_discount_accounting()
|
||||
|
||||
discount_account = create_account(
|
||||
account_name="Discount Account",
|
||||
parent_account="Indirect Expenses - _TC",
|
||||
@ -2702,11 +2702,10 @@ 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):
|
||||
|
||||
enable_discount_accounting()
|
||||
additional_discount_account = create_account(
|
||||
account_name="Discount Account",
|
||||
parent_account="Indirect Expenses - _TC",
|
||||
@ -2737,7 +2736,6 @@ 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):
|
||||
"""
|
||||
@ -3175,12 +3173,6 @@ 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-.#####"
|
||||
|
Loading…
Reference in New Issue
Block a user