Merge pull request #36092 from HarryPaulo/fix-paid-amount-payment-method-group
fix: paid_amount when the group is mode of payment
This commit is contained in:
commit
fff83bc847
@ -50,20 +50,20 @@ def get_pos_entries(filters, group_by_field):
|
|||||||
order_by = "p.posting_date"
|
order_by = "p.posting_date"
|
||||||
select_mop_field, from_sales_invoice_payment, group_by_mop_condition = "", "", ""
|
select_mop_field, from_sales_invoice_payment, group_by_mop_condition = "", "", ""
|
||||||
if group_by_field == "mode_of_payment":
|
if group_by_field == "mode_of_payment":
|
||||||
select_mop_field = ", sip.mode_of_payment"
|
select_mop_field = ", sip.mode_of_payment, sip.base_amount - IF(sip.type='Cash', p.change_amount, 0) as paid_amount"
|
||||||
from_sales_invoice_payment = ", `tabSales Invoice Payment` sip"
|
from_sales_invoice_payment = ", `tabSales Invoice Payment` sip"
|
||||||
group_by_mop_condition = "sip.parent = p.name AND ifnull(sip.base_amount, 0) != 0 AND"
|
group_by_mop_condition = "sip.parent = p.name AND ifnull(sip.base_amount - IF(sip.type='Cash', p.change_amount, 0), 0) != 0 AND"
|
||||||
order_by += ", sip.mode_of_payment"
|
order_by += ", sip.mode_of_payment"
|
||||||
|
|
||||||
elif group_by_field:
|
elif group_by_field:
|
||||||
order_by += ", p.{}".format(group_by_field)
|
order_by += ", p.{}".format(group_by_field)
|
||||||
|
select_mop_field = ", p.base_paid_amount - p.change_amount as paid_amount "
|
||||||
|
|
||||||
return frappe.db.sql(
|
return frappe.db.sql(
|
||||||
"""
|
"""
|
||||||
SELECT
|
SELECT
|
||||||
p.posting_date, p.name as pos_invoice, p.pos_profile,
|
p.posting_date, p.name as pos_invoice, p.pos_profile,
|
||||||
p.owner, p.base_grand_total as grand_total, p.base_paid_amount - p.change_amount as paid_amount,
|
p.owner, p.customer, p.is_return, p.base_grand_total as grand_total {select_mop_field}
|
||||||
p.customer, p.is_return {select_mop_field}
|
|
||||||
FROM
|
FROM
|
||||||
`tabPOS Invoice` p {from_sales_invoice_payment}
|
`tabPOS Invoice` p {from_sales_invoice_payment}
|
||||||
WHERE
|
WHERE
|
||||||
|
Loading…
Reference in New Issue
Block a user