mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-28 02:58:30 +00:00
fix: incorrect advance paid in Sales/Purchase Order
(cherry picked from commit 9d9b83362a)
This commit is contained in:
@@ -1185,7 +1185,13 @@ class PaymentEntry(AccountsController):
|
|||||||
references = [x for x in self.get("references") if x.name == entry.name]
|
references = [x for x in self.get("references") if x.name == entry.name]
|
||||||
|
|
||||||
for ref in references:
|
for ref in references:
|
||||||
if ref.reference_doctype in ("Sales Invoice", "Purchase Invoice", "Journal Entry"):
|
if ref.reference_doctype in (
|
||||||
|
"Sales Invoice",
|
||||||
|
"Purchase Invoice",
|
||||||
|
"Journal Entry",
|
||||||
|
"Sales Order",
|
||||||
|
"Purchase Order",
|
||||||
|
):
|
||||||
self.add_advance_gl_for_reference(gl_entries, ref)
|
self.add_advance_gl_for_reference(gl_entries, ref)
|
||||||
|
|
||||||
def add_advance_gl_for_reference(self, gl_entries, invoice):
|
def add_advance_gl_for_reference(self, gl_entries, invoice):
|
||||||
@@ -1199,9 +1205,10 @@ class PaymentEntry(AccountsController):
|
|||||||
"voucher_detail_no": invoice.name,
|
"voucher_detail_no": invoice.name,
|
||||||
}
|
}
|
||||||
|
|
||||||
posting_date = frappe.db.get_value(
|
date_field = "posting_date"
|
||||||
invoice.reference_doctype, invoice.reference_name, "posting_date"
|
if invoice.reference_doctype in ["Sales Order", "Purchase Order"]:
|
||||||
)
|
date_field = "transaction_date"
|
||||||
|
posting_date = frappe.db.get_value(invoice.reference_doctype, invoice.reference_name, date_field)
|
||||||
|
|
||||||
if getdate(posting_date) < getdate(self.posting_date):
|
if getdate(posting_date) < getdate(self.posting_date):
|
||||||
posting_date = self.posting_date
|
posting_date = self.posting_date
|
||||||
@@ -2108,6 +2115,11 @@ def get_reference_details(reference_doctype, reference_name, party_account_curre
|
|||||||
else:
|
else:
|
||||||
outstanding_amount = flt(total_amount) - flt(ref_doc.get("advance_paid"))
|
outstanding_amount = flt(total_amount) - flt(ref_doc.get("advance_paid"))
|
||||||
|
|
||||||
|
if reference_doctype in ["Sales Order", "Purchase Order"]:
|
||||||
|
party_type = "Customer" if reference_doctype == "Sales Order" else "Supplier"
|
||||||
|
party_field = "customer" if reference_doctype == "Sales Order" else "supplier"
|
||||||
|
party = ref_doc.get(party_field)
|
||||||
|
account = get_party_account(party_type, party, ref_doc.company)
|
||||||
else:
|
else:
|
||||||
# Get the exchange rate based on the posting date of the ref doc.
|
# Get the exchange rate based on the posting date of the ref doc.
|
||||||
exchange_rate = get_exchange_rate(party_account_currency, company_currency, ref_doc.posting_date)
|
exchange_rate = get_exchange_rate(party_account_currency, company_currency, ref_doc.posting_date)
|
||||||
|
|||||||
@@ -522,7 +522,8 @@ def reconcile_against_document(
|
|||||||
|
|
||||||
if voucher_type == "Payment Entry" and doc.book_advance_payments_in_separate_party_account:
|
if voucher_type == "Payment Entry" and doc.book_advance_payments_in_separate_party_account:
|
||||||
# both ledgers must be posted to for `Advance` in separate account feature
|
# both ledgers must be posted to for `Advance` in separate account feature
|
||||||
doc.make_advance_gl_entries(referenced_row, update_outstanding="No")
|
doc.make_advance_gl_entries(cancel=1)
|
||||||
|
doc.make_advance_gl_entries()
|
||||||
else:
|
else:
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user