From 42ef95759d75a572465b26a6aab9a5f9de7a3bbb Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 3 May 2024 17:04:37 +0530 Subject: [PATCH] test: Update failing tests --- .../doctype/payment_entry/payment_entry.py | 32 +++++++++---------- .../purchase_order/test_purchase_order.py | 23 +------------ 2 files changed, 17 insertions(+), 38 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index f271daa8567..4569fbeedf5 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1269,27 +1269,27 @@ class PaymentEntry(AccountsController): ) gl_entries.append(gle) - if self.unallocated_amount: - dr_or_cr = "credit" if self.payment_type == "Receive" else "debit" - exchange_rate = self.get_exchange_rate() - base_unallocated_amount = self.unallocated_amount * exchange_rate + if self.unallocated_amount: + dr_or_cr = "credit" if self.payment_type == "Receive" else "debit" + exchange_rate = self.get_exchange_rate() + base_unallocated_amount = self.unallocated_amount * exchange_rate - gle = party_gl_dict.copy() + gle = party_gl_dict.copy() + gle.update( + { + dr_or_cr + "_in_account_currency": self.unallocated_amount, + dr_or_cr: base_unallocated_amount, + } + ) + + if self.book_advance_payments_in_separate_party_account: gle.update( { - dr_or_cr + "_in_account_currency": self.unallocated_amount, - dr_or_cr: base_unallocated_amount, + "against_voucher_type": "Payment Entry", + "against_voucher": self.name, } ) - - if self.book_advance_payments_in_separate_party_account: - gle.update( - { - "against_voucher_type": "Payment Entry", - "against_voucher": self.name, - } - ) - gl_entries.append(gle) + gl_entries.append(gle) def make_advance_gl_entries( self, entry: object | dict = None, cancel: bool = 0, update_outstanding: str = "Yes" diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py index 15b7fa1143a..c7e79fec4c0 100644 --- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py @@ -772,12 +772,7 @@ class TestPurchaseOrder(FrappeTestCase): } ).insert() else: - account = frappe.db.get_value( - "Account", - filters={"account_name": account_name, "company": company}, - fieldname="name", - pluck=True, - ) + account = frappe.get_doc("Account", {"account_name": account_name, "company": company}) return account @@ -808,22 +803,6 @@ class TestPurchaseOrder(FrappeTestCase): from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_invoice - pi = make_purchase_invoice(po_doc.name) - pi.append( - "advances", - { - "reference_type": pe.doctype, - "reference_name": pe.name, - "reference_row": pe.references[0].name, - "advance_amount": 5000, - "allocated_amount": 5000, - }, - ) - pi.save().submit() - pe.reload() - po_doc.reload() - self.assertEqual(po_doc.advance_paid, 0) - company_doc.book_advance_payments_in_separate_party_account = False company_doc.save()