Skip to content

Commit

Permalink
refactor: post to GL and Payment Ledger on advance as liability
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Nov 6, 2023
1 parent 20eacd4 commit 5f462e4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ def reconcile_against_document(args, skip_ref_details_update_for_pe=False): # n
frappe.flags.ignore_party_validation = True
_delete_pl_entries(voucher_type, voucher_no)

if voucher_type == "Payment Entry" and doc.book_advance_payments_in_separate_party_account:
_delete_gl_entries(voucher_type, voucher_no)

for entry in entries:
check_if_advance_entry_modified(entry)
validate_allocated_amount(entry)
Expand All @@ -488,16 +491,19 @@ def reconcile_against_document(args, skip_ref_details_update_for_pe=False): # n
doc.save(ignore_permissions=True)
# re-submit advance entry
doc = frappe.get_doc(entry.voucher_type, entry.voucher_no)
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" and doc.book_advance_payments_in_separate_party_account:
# both ledgers must be posted to for `Advance as Liability`
doc.make_gl_entries()
else:
gl_map = doc.build_gl_map()
create_payment_ledger_entry(gl_map, update_outstanding="No", cancel=0, adv_adj=1)

# 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

Expand Down

0 comments on commit 5f462e4

Please sign in to comment.