mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-09 15:29:30 +00:00
This commit is contained in:
@@ -304,6 +304,9 @@ def get_payment_entries(filters, args):
|
|||||||
pe.mode_of_payment,
|
pe.mode_of_payment,
|
||||||
pe.project,
|
pe.project,
|
||||||
pe.cost_center,
|
pe.cost_center,
|
||||||
|
pe.payment_type,
|
||||||
|
pe.source_exchange_rate,
|
||||||
|
pe.target_exchange_rate,
|
||||||
)
|
)
|
||||||
.where(
|
.where(
|
||||||
(pe.docstatus == 1)
|
(pe.docstatus == 1)
|
||||||
@@ -314,6 +317,22 @@ def get_payment_entries(filters, args):
|
|||||||
)
|
)
|
||||||
query = apply_common_conditions(filters, query, doctype="Payment Entry", payments=True)
|
query = apply_common_conditions(filters, query, doctype="Payment Entry", payments=True)
|
||||||
payment_entries = query.run(as_dict=True)
|
payment_entries = query.run(as_dict=True)
|
||||||
|
|
||||||
|
if payment_entries:
|
||||||
|
ded = frappe.qb.DocType("Payment Entry Deduction")
|
||||||
|
deduction_totals = frappe._dict(
|
||||||
|
frappe.qb.from_(ded)
|
||||||
|
.select(ded.parent, Sum(ded.amount))
|
||||||
|
.where(ded.parent.isin([d.name for d in payment_entries]) & (ded.is_exchange_gain_loss == 0))
|
||||||
|
.groupby(ded.parent)
|
||||||
|
.run()
|
||||||
|
)
|
||||||
|
for d in payment_entries:
|
||||||
|
exchange_rate = (
|
||||||
|
d.source_exchange_rate if d.payment_type == "Receive" else d.target_exchange_rate
|
||||||
|
) or 1
|
||||||
|
d.base_grand_total = flt(d.base_grand_total) + flt(deduction_totals.get(d.name)) / exchange_rate
|
||||||
|
|
||||||
return payment_entries
|
return payment_entries
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user