refactor: calculate advance from advance ledger
This commit is contained in:
@@ -1927,25 +1927,22 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
return stock_items
|
return stock_items
|
||||||
|
|
||||||
def set_total_advance_paid(self):
|
def calculate_total_advance_from_ledger(self):
|
||||||
ple = frappe.qb.DocType("Payment Ledger Entry")
|
adv = frappe.qb.DocType("Advance Payment Ledger Entry")
|
||||||
if self.doctype in frappe.get_hooks("advance_payment_receivable_doctypes"):
|
|
||||||
party = self.customer
|
|
||||||
if self.doctype in frappe.get_hooks("advance_payment_payable_doctypes"):
|
|
||||||
party = self.supplier
|
|
||||||
advance = (
|
advance = (
|
||||||
frappe.qb.from_(ple)
|
frappe.qb.from_(adv)
|
||||||
.select(ple.account_currency, Abs(Sum(ple.amount_in_account_currency)).as_("amount"))
|
.select(adv.currency, Abs(Sum(adv.amount)).as_("amount"))
|
||||||
.where(
|
.where(
|
||||||
(ple.against_voucher_type == self.doctype)
|
(adv.against_voucher_type == self.doctype)
|
||||||
& (ple.against_voucher_no == self.name)
|
& (adv.against_voucher_no == self.name)
|
||||||
& (ple.party == party)
|
& (adv.company == self.company)
|
||||||
& (ple.delinked == 0)
|
|
||||||
& (ple.company == self.company)
|
|
||||||
)
|
)
|
||||||
.run(as_dict=True)
|
.run(as_dict=True)
|
||||||
)
|
)
|
||||||
|
return advance
|
||||||
|
|
||||||
|
def set_total_advance_paid(self):
|
||||||
|
advance = self.calculate_total_advance_from_ledger()
|
||||||
advance_paid, order_total = None, None
|
advance_paid, order_total = None, None
|
||||||
|
|
||||||
if advance:
|
if advance:
|
||||||
|
|||||||
Reference in New Issue
Block a user