From 5e9821dce24fdbca59a11f9763b8b96df2b0d3bd Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Mon, 12 Jun 2023 18:00:15 +0530 Subject: [PATCH] test: modify test to check posting date --- .../doctype/payment_entry/payment_entry.py | 19 ++++++++++++++++--- .../purchase_invoice/test_purchase_invoice.py | 11 ++++++++--- .../sales_invoice/test_sales_invoice.py | 14 +++++++++++--- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 7012eacb61e..7a31dc58858 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -909,6 +909,7 @@ class PaymentEntry(AccountsController): item=self, ) for d in self.get("references"): + gle = party_dict.copy() book_advance_payments_as_liability = frappe.get_value( "Company", {"company_name": self.company}, "book_advance_payments_as_liability" ) @@ -917,17 +918,27 @@ class PaymentEntry(AccountsController): and book_advance_payments_as_liability ): self.make_invoice_liability_entry(gl_entries, d) + gle.update( + { + "against_voucher_type": "Payment Entry", + "against_voucher": self.name, + } + ) allocated_amount_in_company_currency = self.calculate_base_allocated_amount_for_reference(d) - gle = party_dict.copy() gle.update( { dr_or_cr: allocated_amount_in_company_currency, dr_or_cr + "_in_account_currency": d.allocated_amount, - "against_voucher_type": "Payment Entry", - "against_voucher": self.name, } ) + if not gle.get("against_voucher_type"): + gle.update( + { + "against_voucher_type": d.reference_doctype, + "against_voucher": d.reference_name, + } + ) gl_entries.append(gle) @@ -940,6 +951,8 @@ class PaymentEntry(AccountsController): { dr_or_cr + "_in_account_currency": self.unallocated_amount, dr_or_cr: base_unallocated_amount, + "against_voucher_type": "Payment Entry", + "against_voucher": self.name, } ) diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index c15692b751b..1ac231bc19f 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -1694,13 +1694,18 @@ class TestPurchaseInvoice(unittest.TestCase, StockTestMixin): pi.save() pi.submit() expected_gle = [ - ["Creditors - _TC", 50, 100], - ["Debtors - _TC", 0.0, 50], - ["Stock Received But Not Billed - _TC", 100, 0.0], + ["Creditors - _TC", 50, 100, nowdate()], + ["Debtors - _TC", 0.0, 50, nowdate()], + ["Stock Received But Not Billed - _TC", 100, 0.0, nowdate()], ] check_gl_entries(self, pi.name, expected_gle, nowdate()) self.assertEqual(pi.outstanding_amount, 200) + frappe.db.set_value( + "Company", + "_Test Company", + {"book_advance_payments_as_liability": 0, "default_advance_paid_account": ""}, + ) def check_gl_entries(doc, voucher_no, expected_gle, posting_date): diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 54c8b8472e2..8ab7fd7cd0c 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -3348,13 +3348,21 @@ class TestSalesInvoice(unittest.TestCase): si.save() si.submit() expected_gle = [ - ["Creditors - _TC", 50, 0.0], - ["Debtors - _TC", 100, 50], - ["Sales - _TC", 0.0, 100], + ["Creditors - _TC", 50, 0.0, nowdate()], + ["Debtors - _TC", 100, 50, nowdate()], + ["Sales - _TC", 0.0, 100, nowdate()], ] check_gl_entries(self, si.name, expected_gle, nowdate()) self.assertEqual(si.outstanding_amount, 50) + frappe.db.set_value( + "Company", + "_Test Company", + { + "book_advance_payments_as_liability": 0, + "default_advance_received_account": "", + }, + ) def get_sales_invoice_for_e_invoice():