Skip to content

Commit

Permalink
refactor(test): use @change_settings in sales invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Oct 2, 2023
1 parent 63a74ad commit 1c4f4ef
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ def setUp(self):
create_items(["_Test Internal Transfer Item"], uoms=[{"uom": "Box", "conversion_factor": 10}])
create_internal_parties()
setup_accounts()
self.remove_accounts_frozen_date()

def tearDown(self):
frappe.db.rollback()

def remove_accounts_frozen_date(self):
frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", None)

def make(self):
w = frappe.copy_doc(test_records[0])
w.is_pos = 0
Expand Down Expand Up @@ -3079,8 +3075,8 @@ def test_sales_commission(self):
si.commission_rate = commission_rate
self.assertRaises(frappe.ValidationError, si.save)

@change_settings("Accounts Settings", {"acc_frozen_upto": add_days(getdate(), 1)})
def test_sales_invoice_submission_post_account_freezing_date(self):
frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", add_days(getdate(), 1))
si = create_sales_invoice(do_not_save=True)
si.posting_date = add_days(getdate(), 1)
si.save()
Expand All @@ -3089,8 +3085,6 @@ def test_sales_invoice_submission_post_account_freezing_date(self):
si.posting_date = getdate()
si.submit()

frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", None)

def test_over_billing_case_against_delivery_note(self):
"""
Test a case where duplicating the item with qty = 1 in the invoice
Expand Down Expand Up @@ -3119,6 +3113,7 @@ def test_over_billing_case_against_delivery_note(self):

frappe.db.set_single_value("Accounts Settings", "over_billing_allowance", over_billing_allowance)

@change_settings("Accounts Settings", {"acc_frozen_upto": getdate("2019-01-31")})
def test_multi_currency_deferred_revenue_via_journal_entry(self):
deferred_account = create_account(
account_name="Deferred Revenue",
Expand Down Expand Up @@ -3156,8 +3151,6 @@ def test_multi_currency_deferred_revenue_via_journal_entry(self):
si.save()
si.submit()

frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", getdate("2019-01-31"))

pda1 = frappe.get_doc(
dict(
doctype="Process Deferred Accounting",
Expand Down Expand Up @@ -3201,8 +3194,6 @@ def test_multi_currency_deferred_revenue_via_journal_entry(self):
acc_settings.submit_journal_entries = 0
acc_settings.save()

frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", None)

def test_standalone_serial_no_return(self):
si = create_sales_invoice(
item_code="_Test Serialized Item With Series", update_stock=True, is_return=True, qty=-1
Expand Down

0 comments on commit 1c4f4ef

Please sign in to comment.