fix: report sales payments summary (#30264)
This commit is contained in:
parent
9376d8d308
commit
01fd3adedf
@ -199,31 +199,39 @@ def get_mode_of_payment_details(filters):
|
|||||||
invoice_list = get_invoices(filters)
|
invoice_list = get_invoices(filters)
|
||||||
invoice_list_names = ",".join('"' + invoice['name'] + '"' for invoice in invoice_list)
|
invoice_list_names = ",".join('"' + invoice['name'] + '"' for invoice in invoice_list)
|
||||||
if invoice_list:
|
if invoice_list:
|
||||||
inv_mop_detail = frappe.db.sql("""select a.owner, a.posting_date,
|
inv_mop_detail = frappe.db.sql("""
|
||||||
ifnull(b.mode_of_payment, '') as mode_of_payment, sum(b.base_amount) as paid_amount
|
select t.owner,
|
||||||
from `tabSales Invoice` a, `tabSales Invoice Payment` b
|
t.posting_date,
|
||||||
where a.name = b.parent
|
t.mode_of_payment,
|
||||||
and a.docstatus = 1
|
sum(t.paid_amount) as paid_amount
|
||||||
and a.name in ({invoice_list_names})
|
from (
|
||||||
group by a.owner, a.posting_date, mode_of_payment
|
select a.owner, a.posting_date,
|
||||||
union
|
ifnull(b.mode_of_payment, '') as mode_of_payment, sum(b.base_amount) as paid_amount
|
||||||
select a.owner,a.posting_date,
|
from `tabSales Invoice` a, `tabSales Invoice Payment` b
|
||||||
ifnull(b.mode_of_payment, '') as mode_of_payment, sum(b.base_paid_amount) as paid_amount
|
where a.name = b.parent
|
||||||
from `tabSales Invoice` a, `tabPayment Entry` b,`tabPayment Entry Reference` c
|
and a.docstatus = 1
|
||||||
where a.name = c.reference_name
|
and a.name in ({invoice_list_names})
|
||||||
and b.name = c.parent
|
group by a.owner, a.posting_date, mode_of_payment
|
||||||
and b.docstatus = 1
|
union
|
||||||
and a.name in ({invoice_list_names})
|
select a.owner,a.posting_date,
|
||||||
group by a.owner, a.posting_date, mode_of_payment
|
ifnull(b.mode_of_payment, '') as mode_of_payment, sum(c.allocated_amount) as paid_amount
|
||||||
union
|
from `tabSales Invoice` a, `tabPayment Entry` b,`tabPayment Entry Reference` c
|
||||||
select a.owner, a.posting_date,
|
where a.name = c.reference_name
|
||||||
ifnull(a.voucher_type,'') as mode_of_payment, sum(b.credit)
|
and b.name = c.parent
|
||||||
from `tabJournal Entry` a, `tabJournal Entry Account` b
|
and b.docstatus = 1
|
||||||
where a.name = b.parent
|
and a.name in ({invoice_list_names})
|
||||||
and a.docstatus = 1
|
group by a.owner, a.posting_date, mode_of_payment
|
||||||
and b.reference_type = "Sales Invoice"
|
union
|
||||||
and b.reference_name in ({invoice_list_names})
|
select a.owner, a.posting_date,
|
||||||
group by a.owner, a.posting_date, mode_of_payment
|
ifnull(a.voucher_type,'') as mode_of_payment, sum(b.credit)
|
||||||
|
from `tabJournal Entry` a, `tabJournal Entry Account` b
|
||||||
|
where a.name = b.parent
|
||||||
|
and a.docstatus = 1
|
||||||
|
and b.reference_type = "Sales Invoice"
|
||||||
|
and b.reference_name in ({invoice_list_names})
|
||||||
|
group by a.owner, a.posting_date, mode_of_payment
|
||||||
|
) t
|
||||||
|
group by t.owner, t.posting_date, t.mode_of_payment
|
||||||
""".format(invoice_list_names=invoice_list_names), as_dict=1)
|
""".format(invoice_list_names=invoice_list_names), as_dict=1)
|
||||||
|
|
||||||
inv_change_amount = frappe.db.sql("""select a.owner, a.posting_date,
|
inv_change_amount = frappe.db.sql("""select a.owner, a.posting_date,
|
||||||
@ -231,7 +239,7 @@ def get_mode_of_payment_details(filters):
|
|||||||
from `tabSales Invoice` a, `tabSales Invoice Payment` b
|
from `tabSales Invoice` a, `tabSales Invoice Payment` b
|
||||||
where a.name = b.parent
|
where a.name = b.parent
|
||||||
and a.name in ({invoice_list_names})
|
and a.name in ({invoice_list_names})
|
||||||
and b.mode_of_payment = 'Cash'
|
and b.type = 'Cash'
|
||||||
and a.base_change_amount > 0
|
and a.base_change_amount > 0
|
||||||
group by a.owner, a.posting_date, mode_of_payment""".format(invoice_list_names=invoice_list_names), as_dict=1)
|
group by a.owner, a.posting_date, mode_of_payment""".format(invoice_list_names=invoice_list_names), as_dict=1)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user