From c47adcfdd9c63b4e99adb775dbb6d1a85cf0c151 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Mon, 21 Aug 2023 15:12:11 +0530 Subject: [PATCH] fix: advance in seperate account --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 7 ++++++- erpnext/accounts/utils.py | 5 ++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index ac31e8a1db..1f5fba52a6 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1123,7 +1123,7 @@ class PaymentEntry(AccountsController): if self.book_advance_payments_in_separate_party_account: gl_entries = [] for d in self.get("references"): - if d.reference_doctype in ("Sales Invoice", "Purchase Invoice"): + if d.reference_doctype in ("Sales Invoice", "Purchase Invoice", "Journal Entry"): if not (against_voucher_type and against_voucher) or ( d.reference_doctype == against_voucher_type and d.reference_name == against_voucher ): @@ -1159,6 +1159,10 @@ class PaymentEntry(AccountsController): "voucher_detail_no": invoice.name, } + posting_date = frappe.db.get_value( + invoice.reference_doctype, invoice.reference_name, "posting_date" + ) + dr_or_cr = "credit" if invoice.reference_doctype == "Sales Invoice" else "debit" args_dict["account"] = invoice.account args_dict[dr_or_cr] = invoice.allocated_amount @@ -1167,6 +1171,7 @@ class PaymentEntry(AccountsController): { "against_voucher_type": invoice.reference_doctype, "against_voucher": invoice.reference_name, + "posting_date": posting_date, } ) gle = self.get_gl_dict( diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index bccf6f10b6..5c3c486deb 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -489,14 +489,13 @@ def reconcile_against_document(args, skip_ref_details_update_for_pe=False): # n gl_map = doc.build_gl_map() create_payment_ledger_entry(gl_map, update_outstanding="No", cancel=0, adv_adj=1) - if voucher_type == "Payment Entry": - doc.make_advance_gl_entries() - # Only update outstanding for newly linked vouchers for entry in entries: update_voucher_outstanding( entry.against_voucher_type, entry.against_voucher, entry.account, entry.party_type, entry.party ) + if voucher_type == "Payment Entry": + doc.make_advance_gl_entries(entry.against_voucher_type, entry.against_voucher) frappe.flags.ignore_party_validation = False