fix: advance in seperate account

This commit is contained in:
Smit Vora 2023-08-21 15:12:11 +05:30
parent 450949cadd
commit c47adcfdd9
2 changed files with 8 additions and 4 deletions

View File

@ -1123,7 +1123,7 @@ class PaymentEntry(AccountsController):
if self.book_advance_payments_in_separate_party_account: if self.book_advance_payments_in_separate_party_account:
gl_entries = [] gl_entries = []
for d in self.get("references"): 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 ( if not (against_voucher_type and against_voucher) or (
d.reference_doctype == against_voucher_type and d.reference_name == against_voucher d.reference_doctype == against_voucher_type and d.reference_name == against_voucher
): ):
@ -1159,6 +1159,10 @@ class PaymentEntry(AccountsController):
"voucher_detail_no": invoice.name, "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" dr_or_cr = "credit" if invoice.reference_doctype == "Sales Invoice" else "debit"
args_dict["account"] = invoice.account args_dict["account"] = invoice.account
args_dict[dr_or_cr] = invoice.allocated_amount args_dict[dr_or_cr] = invoice.allocated_amount
@ -1167,6 +1171,7 @@ class PaymentEntry(AccountsController):
{ {
"against_voucher_type": invoice.reference_doctype, "against_voucher_type": invoice.reference_doctype,
"against_voucher": invoice.reference_name, "against_voucher": invoice.reference_name,
"posting_date": posting_date,
} }
) )
gle = self.get_gl_dict( gle = self.get_gl_dict(

View File

@ -489,14 +489,13 @@ def reconcile_against_document(args, skip_ref_details_update_for_pe=False): # n
gl_map = doc.build_gl_map() gl_map = doc.build_gl_map()
create_payment_ledger_entry(gl_map, update_outstanding="No", cancel=0, adv_adj=1) 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 # Only update outstanding for newly linked vouchers
for entry in entries: for entry in entries:
update_voucher_outstanding( update_voucher_outstanding(
entry.against_voucher_type, entry.against_voucher, entry.account, entry.party_type, entry.party 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 frappe.flags.ignore_party_validation = False