diff --git a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py index 355aa46ea05..f6c240c0714 100644 --- a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py @@ -1045,6 +1045,7 @@ class TestPaymentEntry(IntegrationTestCase): ) 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( 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.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): ple = frappe.qb.DocType("Payment Ledger Entry") pl_entries = ( diff --git a/erpnext/stock/doctype/item_price/test_records.json b/erpnext/stock/doctype/item_price/test_records.json deleted file mode 100644 index afe5ad65b75..00000000000 --- a/erpnext/stock/doctype/item_price/test_records.json +++ /dev/null @@ -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" - } -]