test: Update test cases for discount accounting
This commit is contained in:
parent
b73bb3e501
commit
428ccebad9
@ -235,39 +235,41 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
discount_account = create_account(account_name="Discount Account",
|
discount_account = create_account(account_name="Discount Account",
|
||||||
parent_account="Indirect Expenses - _TC", company="_Test Company")
|
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 = [
|
expected_gle = [
|
||||||
["_Test Account Cost for Goods Sold - _TC", 350.0, 0.0, nowdate()],
|
["_Test Account Cost for Goods Sold - _TC", 250.0, 0.0, nowdate()],
|
||||||
["Creditors - _TC", 0.0, 250.0, nowdate()],
|
["Creditors - _TC", 0.0, 225.0, nowdate()],
|
||||||
["Discount Account - _TC", 0.0, 100.0, nowdate()]
|
["Discount Account - _TC", 0.0, 25.0, nowdate()]
|
||||||
]
|
]
|
||||||
|
|
||||||
check_gl_entries(self, pi.name, expected_gle, 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):
|
def test_additional_discount_for_purchase_invoice_with_discount_accounting_enabled(self):
|
||||||
enable_discount_accounting()
|
enable_discount_accounting()
|
||||||
additional_discount_account = create_account(account_name="Discount Account",
|
additional_discount_account = create_account(account_name="Discount Account",
|
||||||
parent_account="Indirect Expenses - _TC", company="_Test Company")
|
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.apply_discount_on = "Grand Total"
|
||||||
pi.additional_discount_account = additional_discount_account
|
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", {
|
pi.append("taxes", {
|
||||||
"charge_type": "Actual",
|
"charge_type": "On Net Total",
|
||||||
"account_head": "_Test Account VAT - _TC",
|
"account_head": "_Test Account VAT - _TC",
|
||||||
"cost_center": "Main - _TC",
|
"cost_center": "Main - _TC",
|
||||||
"description": "Test",
|
"description": "Test",
|
||||||
"tax_amount": 20
|
"rate": 10
|
||||||
})
|
})
|
||||||
pi.submit()
|
pi.submit()
|
||||||
|
|
||||||
expected_gle = [
|
expected_gle = [
|
||||||
["_Test Account Cost for Goods Sold - _TC", 100.0, 0.0, nowdate()],
|
["_Test Account Cost for Goods Sold - _TC", 250.0, 0.0, nowdate()],
|
||||||
["_Test Account VAT - _TC", 20.0, 0.0, nowdate()],
|
["_Test Account VAT - _TC", 25.0, 0.0, nowdate()],
|
||||||
["Creditors - _TC", 0.0, 96.0, nowdate()],
|
["Creditors - _TC", 0.0, 247.5, nowdate()],
|
||||||
["Discount Account - _TC", 0.0, 24.0, nowdate()]
|
["Discount Account - _TC", 0.0, 27.5, nowdate()]
|
||||||
]
|
]
|
||||||
|
|
||||||
check_gl_entries(self, pi.name, expected_gle, nowdate())
|
check_gl_entries(self, pi.name, expected_gle, nowdate())
|
||||||
@ -1260,6 +1262,7 @@ def make_purchase_invoice(**args):
|
|||||||
"received_qty": args.received_qty or 0,
|
"received_qty": args.received_qty or 0,
|
||||||
"rejected_qty": args.rejected_qty or 0,
|
"rejected_qty": args.rejected_qty or 0,
|
||||||
"rate": args.rate or 50,
|
"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',
|
"expense_account": args.expense_account or '_Test Account Cost for Goods Sold - _TC',
|
||||||
"discount_account": args.discount_account or None,
|
"discount_account": args.discount_account or None,
|
||||||
"discount_amount": args.discount_amount or 0,
|
"discount_amount": args.discount_amount or 0,
|
||||||
|
|||||||
@ -1993,15 +1993,16 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
discount_account = create_account(account_name="Discount Account",
|
discount_account = create_account(account_name="Discount Account",
|
||||||
parent_account="Indirect Expenses - _TC", company="_Test Company")
|
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 = [
|
expected_gle = [
|
||||||
["Debtors - _TC", 100.0, 0.0, nowdate()],
|
["Debtors - _TC", 90.0, 0.0, nowdate()],
|
||||||
["Discount Account - _TC", 100.0, 0.0, nowdate()],
|
["Discount Account - _TC", 10.0, 0.0, nowdate()],
|
||||||
["Sales - _TC", 0.0, 200.0, nowdate()]
|
["Sales - _TC", 0.0, 100.0, nowdate()]
|
||||||
]
|
]
|
||||||
|
|
||||||
check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1))
|
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):
|
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
|
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import enable_discount_accounting
|
||||||
@ -2010,28 +2011,28 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
additional_discount_account = create_account(account_name="Discount Account",
|
additional_discount_account = create_account(account_name="Discount Account",
|
||||||
parent_account="Indirect Expenses - _TC", company="_Test Company")
|
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.apply_discount_on = "Grand Total"
|
||||||
si.additional_discount_account = additional_discount_account
|
si.additional_discount_account = additional_discount_account
|
||||||
si.additional_discount_percentage = 20
|
si.additional_discount_percentage = 20
|
||||||
si.append("taxes", {
|
si.append("taxes", {
|
||||||
"charge_type": "Actual",
|
"charge_type": "On Net Total",
|
||||||
"account_head": "_Test Account VAT - _TC",
|
"account_head": "_Test Account VAT - _TC",
|
||||||
"cost_center": "Main - _TC",
|
"cost_center": "Main - _TC",
|
||||||
"description": "Test",
|
"description": "Test",
|
||||||
"rate": 0,
|
"rate": 10
|
||||||
"tax_amount": 20
|
|
||||||
})
|
})
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
expected_gle = [
|
expected_gle = [
|
||||||
["_Test Account VAT - _TC", 0.0, 20.0, nowdate()],
|
["_Test Account VAT - _TC", 0.0, 10.0, nowdate()],
|
||||||
["Debtors - _TC", 96.0, 0.0, nowdate()],
|
["Debtors - _TC", 88, 0.0, nowdate()],
|
||||||
["Discount Account - _TC", 24.0, 0.0, nowdate()],
|
["Discount Account - _TC", 22.0, 0.0, nowdate()],
|
||||||
["Sales - _TC", 0.0, 100.0, nowdate()]
|
["Sales - _TC", 0.0, 100.0, nowdate()]
|
||||||
]
|
]
|
||||||
|
|
||||||
check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1))
|
check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1))
|
||||||
|
enable_discount_accounting(enable=0)
|
||||||
|
|
||||||
def get_sales_invoice_for_e_invoice():
|
def get_sales_invoice_for_e_invoice():
|
||||||
si = make_sales_invoice_for_ewaybill()
|
si = make_sales_invoice_for_ewaybill()
|
||||||
@ -2238,6 +2239,7 @@ def create_sales_invoice(**args):
|
|||||||
"uom": args.uom or "Nos",
|
"uom": args.uom or "Nos",
|
||||||
"stock_uom": args.uom or "Nos",
|
"stock_uom": args.uom or "Nos",
|
||||||
"rate": args.rate if args.get("rate") is not None else 100,
|
"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",
|
"income_account": args.income_account or "Sales - _TC",
|
||||||
"expense_account": args.expense_account or "Cost of Goods Sold - _TC",
|
"expense_account": args.expense_account or "Cost of Goods Sold - _TC",
|
||||||
"discount_account": args.discount_account or None,
|
"discount_account": args.discount_account or None,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user