test: Update test cases for discount accounting
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index d60f0a4..f0f5a58 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -235,39 +235,41 @@
discount_account = create_account(account_name="Discount Account",
parent_account="Indirect Expenses - _TC", company="_Test Company")
- pi = make_purchase_invoice(discount_account=discount_account, discount_amount=100)
+ pi = make_purchase_invoice(discount_account=discount_account, rate=45)
expected_gle = [
- ["_Test Account Cost for Goods Sold - _TC", 350.0, 0.0, nowdate()],
- ["Creditors - _TC", 0.0, 250.0, nowdate()],
- ["Discount Account - _TC", 0.0, 100.0, nowdate()]
+ ["_Test Account Cost for Goods Sold - _TC", 250.0, 0.0, nowdate()],
+ ["Creditors - _TC", 0.0, 225.0, nowdate()],
+ ["Discount Account - _TC", 0.0, 25.0, nowdate()]
]
check_gl_entries(self, pi.name, expected_gle, nowdate())
+ enable_discount_accounting(enable=0)
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", company="_Test Company")
- pi = make_purchase_invoice(qty=1, rate=100, do_not_save=1, parent_cost_center="Main - _TC")
+ pi = make_purchase_invoice(do_not_save=1, parent_cost_center="Main - _TC")
pi.apply_discount_on = "Grand Total"
pi.additional_discount_account = additional_discount_account
- pi.additional_discount_percentage = 20
+ pi.additional_discount_percentage = 10
+ pi.disable_rounded_total = 1
pi.append("taxes", {
- "charge_type": "Actual",
+ "charge_type": "On Net Total",
"account_head": "_Test Account VAT - _TC",
"cost_center": "Main - _TC",
"description": "Test",
- "tax_amount": 20
+ "rate": 10
})
pi.submit()
expected_gle = [
- ["_Test Account Cost for Goods Sold - _TC", 100.0, 0.0, nowdate()],
- ["_Test Account VAT - _TC", 20.0, 0.0, nowdate()],
- ["Creditors - _TC", 0.0, 96.0, nowdate()],
- ["Discount Account - _TC", 0.0, 24.0, nowdate()]
+ ["_Test Account Cost for Goods Sold - _TC", 250.0, 0.0, nowdate()],
+ ["_Test Account VAT - _TC", 25.0, 0.0, nowdate()],
+ ["Creditors - _TC", 0.0, 247.5, nowdate()],
+ ["Discount Account - _TC", 0.0, 27.5, nowdate()]
]
check_gl_entries(self, pi.name, expected_gle, nowdate())
@@ -1260,6 +1262,7 @@
"received_qty": args.received_qty or 0,
"rejected_qty": args.rejected_qty or 0,
"rate": args.rate or 50,
+ "price_list_rate": args.price_list_rate or 50,
"expense_account": args.expense_account or '_Test Account Cost for Goods Sold - _TC',
"discount_account": args.discount_account or None,
"discount_amount": args.discount_amount or 0,
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index af317db..12f03be 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -1993,15 +1993,16 @@
discount_account = create_account(account_name="Discount Account",
parent_account="Indirect Expenses - _TC", company="_Test Company")
- si = create_sales_invoice(discount_account=discount_account, discount_amount=100)
+ si = create_sales_invoice(discount_account=discount_account, discount_percentage=10, rate=90)
expected_gle = [
- ["Debtors - _TC", 100.0, 0.0, nowdate()],
- ["Discount Account - _TC", 100.0, 0.0, nowdate()],
- ["Sales - _TC", 0.0, 200.0, nowdate()]
+ ["Debtors - _TC", 90.0, 0.0, nowdate()],
+ ["Discount Account - _TC", 10.0, 0.0, nowdate()],
+ ["Sales - _TC", 0.0, 100.0, nowdate()]
]
check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1))
+ enable_discount_accounting(enable=0)
def test_additional_discount_for_sales_invoice_with_discount_accounting_enabled(self):
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import enable_discount_accounting
@@ -2010,28 +2011,28 @@
additional_discount_account = create_account(account_name="Discount Account",
parent_account="Indirect Expenses - _TC", company="_Test Company")
- si = create_sales_invoice(rate=100, parent_cost_center='Main - _TC', do_not_save=1)
+ si = create_sales_invoice(parent_cost_center='Main - _TC', do_not_save=1)
si.apply_discount_on = "Grand Total"
si.additional_discount_account = additional_discount_account
si.additional_discount_percentage = 20
si.append("taxes", {
- "charge_type": "Actual",
+ "charge_type": "On Net Total",
"account_head": "_Test Account VAT - _TC",
"cost_center": "Main - _TC",
"description": "Test",
- "rate": 0,
- "tax_amount": 20
+ "rate": 10
})
si.submit()
expected_gle = [
- ["_Test Account VAT - _TC", 0.0, 20.0, nowdate()],
- ["Debtors - _TC", 96.0, 0.0, nowdate()],
- ["Discount Account - _TC", 24.0, 0.0, nowdate()],
+ ["_Test Account VAT - _TC", 0.0, 10.0, nowdate()],
+ ["Debtors - _TC", 88, 0.0, nowdate()],
+ ["Discount Account - _TC", 22.0, 0.0, nowdate()],
["Sales - _TC", 0.0, 100.0, nowdate()]
]
check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1))
+ enable_discount_accounting(enable=0)
def get_sales_invoice_for_e_invoice():
si = make_sales_invoice_for_ewaybill()
@@ -2238,6 +2239,7 @@
"uom": args.uom or "Nos",
"stock_uom": args.uom or "Nos",
"rate": args.rate if args.get("rate") is not None else 100,
+ "price_list_rate": args.price_list_rate if args.get("price_list_rate") is not None else 100,
"income_account": args.income_account or "Sales - _TC",
"expense_account": args.expense_account or "Cost of Goods Sold - _TC",
"discount_account": args.discount_account or None,