mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 13:09:17 +00:00
refactor: calculate advance from advance ledger
(cherry picked from commit 2b2360bf7b)
# Conflicts:
# erpnext/controllers/accounts_controller.py
This commit is contained in:
@@ -1935,22 +1935,33 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
return stock_items
|
return stock_items
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
def set_total_advance_paid(self):
|
def set_total_advance_paid(self):
|
||||||
ple = frappe.qb.DocType("Payment Ledger Entry")
|
ple = frappe.qb.DocType("Payment Ledger Entry")
|
||||||
party = self.customer if self.doctype == "Sales Order" else self.supplier
|
party = self.customer if self.doctype == "Sales Order" else self.supplier
|
||||||
|
=======
|
||||||
|
def calculate_total_advance_from_ledger(self):
|
||||||
|
adv = frappe.qb.DocType("Advance Payment Ledger Entry")
|
||||||
|
>>>>>>> 2b2360bf7b (refactor: calculate advance from advance ledger)
|
||||||
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
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
def set_total_advance_paid(self):
|
||||||
|
advance = self.calculate_total_advance_from_ledger()
|
||||||
|
advance_paid, order_total = None, None
|
||||||
|
|
||||||
|
>>>>>>> 2b2360bf7b (refactor: calculate advance from advance ledger)
|
||||||
if advance:
|
if advance:
|
||||||
advance = advance[0]
|
advance = advance[0]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user