mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 04:39:11 +00:00
test: add tests for merging GL entries based on Accounts Settings
This commit is contained in:
@@ -1045,6 +1045,7 @@ class TestPaymentEntry(IntegrationTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_gl_of_multi_currency_payment_with_taxes(self):
|
def test_gl_of_multi_currency_payment_with_taxes(self):
|
||||||
|
frappe.db.set_single_value("Accounts Settings", "merge_similar_account_heads", 1)
|
||||||
payment_entry = create_payment_entry(
|
payment_entry = create_payment_entry(
|
||||||
party="_Test Supplier USD", paid_to="_Test Payable USD - _TC", save=True
|
party="_Test Supplier USD", paid_to="_Test Payable USD - _TC", save=True
|
||||||
)
|
)
|
||||||
@@ -1606,6 +1607,96 @@ class TestPaymentEntry(IntegrationTestCase):
|
|||||||
self.voucher_no = pe.name
|
self.voucher_no = pe.name
|
||||||
self.check_gl_entries()
|
self.check_gl_entries()
|
||||||
|
|
||||||
|
def test_payment_entry_merges_gl_entries_with_same_account_head(self):
|
||||||
|
"""
|
||||||
|
Test that Payment Entry merges GL entries with same account head
|
||||||
|
when 'Merge Similar Account Heads' setting is enabled.
|
||||||
|
"""
|
||||||
|
frappe.db.set_single_value("Accounts Settings", "merge_similar_account_heads", 1)
|
||||||
|
|
||||||
|
pe = create_payment_entry(
|
||||||
|
party_type="Supplier",
|
||||||
|
party="_Test Supplier",
|
||||||
|
paid_from="_Test Bank - _TC",
|
||||||
|
paid_to="Creditors - _TC",
|
||||||
|
)
|
||||||
|
|
||||||
|
pe.append(
|
||||||
|
"deductions",
|
||||||
|
{
|
||||||
|
"account": "Write Off - _TC",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"amount": 50,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
pe.append(
|
||||||
|
"deductions",
|
||||||
|
{
|
||||||
|
"account": "Write Off - _TC",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"amount": 30,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
pe.save()
|
||||||
|
pe.submit()
|
||||||
|
|
||||||
|
gl_entries = frappe.db.get_all(
|
||||||
|
"GL Entry",
|
||||||
|
filters={"voucher_no": pe.name, "account": "Write Off - _TC", "is_cancelled": 0},
|
||||||
|
fields=["debit", "credit"],
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(len(gl_entries), 1)
|
||||||
|
self.assertEqual(gl_entries[0].debit, 80)
|
||||||
|
|
||||||
|
def test_payment_entry_does_not_merge_gl_entries_when_setting_disabled(self):
|
||||||
|
"""
|
||||||
|
Test that Payment Entry does NOT merge GL entries
|
||||||
|
when 'Merge Similar Account Heads' is disabled.
|
||||||
|
"""
|
||||||
|
|
||||||
|
frappe.db.set_single_value("Accounts Settings", "merge_similar_account_heads", 0)
|
||||||
|
|
||||||
|
pe = create_payment_entry(
|
||||||
|
party_type="Supplier",
|
||||||
|
party="_Test Supplier",
|
||||||
|
paid_from="_Test Bank - _TC",
|
||||||
|
paid_to="Creditors - _TC",
|
||||||
|
)
|
||||||
|
|
||||||
|
pe.append(
|
||||||
|
"deductions",
|
||||||
|
{
|
||||||
|
"account": "Write Off - _TC",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"amount": 50,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
pe.append(
|
||||||
|
"deductions",
|
||||||
|
{
|
||||||
|
"account": "Write Off - _TC",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"amount": 30,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
pe.save()
|
||||||
|
pe.submit()
|
||||||
|
|
||||||
|
gl_entries = frappe.db.get_all(
|
||||||
|
"GL Entry",
|
||||||
|
filters={"voucher_no": pe.name, "account": "Write Off - _TC", "is_cancelled": 0},
|
||||||
|
fields=["debit", "credit"],
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(len(gl_entries), 2)
|
||||||
|
|
||||||
|
frappe.db.set_single_value("Accounts Settings", "merge_similar_account_heads", 1)
|
||||||
|
|
||||||
def check_pl_entries(self):
|
def check_pl_entries(self):
|
||||||
ple = frappe.qb.DocType("Payment Ledger Entry")
|
ple = frappe.qb.DocType("Payment Ledger Entry")
|
||||||
pl_entries = (
|
pl_entries = (
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"doctype": "Item Price",
|
|
||||||
"item_code": "_Test Item",
|
|
||||||
"price_list": "_Test Price List",
|
|
||||||
"price_list_rate": 100,
|
|
||||||
"valid_from": "2017-04-18",
|
|
||||||
"valid_upto": "2017-04-26"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Item Price",
|
|
||||||
"item_code": "_Test Item",
|
|
||||||
"price_list": "_Test Price List Rest of the World",
|
|
||||||
"price_list_rate": 10
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Item Price",
|
|
||||||
"item_code": "_Test Item 2",
|
|
||||||
"price_list": "_Test Price List Rest of the World",
|
|
||||||
"price_list_rate": 20,
|
|
||||||
"valid_from": "2017-04-18",
|
|
||||||
"valid_upto": "2017-04-26",
|
|
||||||
"customer": "_Test Customer",
|
|
||||||
"uom": "_Test UOM"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Item Price",
|
|
||||||
"item_code": "_Test Item Home Desktop 100",
|
|
||||||
"price_list": "_Test Price List",
|
|
||||||
"price_list_rate": 1000,
|
|
||||||
"valid_from": "2017-04-10",
|
|
||||||
"valid_upto": "2017-04-17"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Item Price",
|
|
||||||
"item_code": "_Test Item Home Desktop Manufactured",
|
|
||||||
"price_list": "_Test Price List",
|
|
||||||
"price_list_rate": 1000,
|
|
||||||
"valid_from": "2017-04-10",
|
|
||||||
"valid_upto": "2017-04-17"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Item Price",
|
|
||||||
"item_code": "_Test Item",
|
|
||||||
"price_list": "_Test Buying Price List",
|
|
||||||
"price_list_rate": 100,
|
|
||||||
"supplier": "_Test Supplier"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Item Price",
|
|
||||||
"item_code": "_Test Item",
|
|
||||||
"price_list": "_Test Selling Price List",
|
|
||||||
"price_list_rate": 200,
|
|
||||||
"customer": "_Test Customer"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
Reference in New Issue
Block a user