mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-04 05:58:27 +00:00
refactor: handle currency on advance payment ledger
(cherry picked from commit ae6a81cd07)
This commit is contained in:
@@ -1958,7 +1958,7 @@ class AccountsController(TransactionBase):
|
||||
>>>>>>> 2b2360bf7b (refactor: calculate advance from advance ledger)
|
||||
advance = (
|
||||
frappe.qb.from_(adv)
|
||||
.select(adv.currency, Abs(Sum(adv.amount)).as_("amount"))
|
||||
.select(adv.currency.as_("account_currency"), Abs(Sum(adv.amount)).as_("amount"))
|
||||
.where(
|
||||
(adv.against_voucher_type == self.doctype)
|
||||
& (adv.against_voucher_no == self.name)
|
||||
@@ -2602,6 +2602,11 @@ class AccountsController(TransactionBase):
|
||||
advance_doctype_references = [
|
||||
x for x in self.references if x.reference_doctype in advance_payment_doctypes
|
||||
]
|
||||
currency = (
|
||||
self.paid_from_account_currency
|
||||
if self.payment_type == "Receive"
|
||||
else self.paid_to_account_currency
|
||||
)
|
||||
for x in advance_doctype_references:
|
||||
doc = frappe.new_doc("Advance Payment Ledger Entry")
|
||||
doc.company = self.company
|
||||
@@ -2610,6 +2615,7 @@ class AccountsController(TransactionBase):
|
||||
doc.against_voucher_type = x.reference_doctype
|
||||
doc.against_voucher_no = x.reference_name
|
||||
doc.amount = x.allocated_amount if self.docstatus == 1 else -1 * x.allocated_amount
|
||||
doc.currency = currency
|
||||
doc.event = "Submit" if self.docstatus == 1 else "Cancel"
|
||||
doc.save()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user