Filter cancelled and draft payments
This commit is contained in:
parent
67db77cfa8
commit
813485023b
@ -108,33 +108,33 @@ def get_conditions(filters):
|
|||||||
def get_pos_invoice_data(filters):
|
def get_pos_invoice_data(filters):
|
||||||
conditions = get_conditions(filters)
|
conditions = get_conditions(filters)
|
||||||
result = frappe.db.sql(''
|
result = frappe.db.sql(''
|
||||||
'SELECT '
|
'SELECT '
|
||||||
'posting_date, owner, sum(net_total) as "net_total", sum(total_taxes) as "total_taxes", '
|
'posting_date, owner, sum(net_total) as "net_total", sum(total_taxes) as "total_taxes", '
|
||||||
'sum(paid_amount) as "paid_amount", sum(outstanding_amount) as "outstanding_amount", '
|
'sum(paid_amount) as "paid_amount", sum(outstanding_amount) as "outstanding_amount", '
|
||||||
'mode_of_payment, warehouse, cost_center '
|
'mode_of_payment, warehouse, cost_center '
|
||||||
'FROM ('
|
'FROM ('
|
||||||
'SELECT '
|
'SELECT '
|
||||||
'parent, item_code, sum(amount) as "base_total", warehouse, cost_center '
|
'parent, item_code, sum(amount) as "base_total", warehouse, cost_center '
|
||||||
'from `tabSales Invoice Item` group by parent'
|
'from `tabSales Invoice Item` group by parent'
|
||||||
') t1 '
|
') t1 '
|
||||||
'left join '
|
'left join '
|
||||||
'(select parent, mode_of_payment from `tabSales Invoice Payment` group by parent) t3 '
|
'(select parent, mode_of_payment from `tabSales Invoice Payment` group by parent) t3 '
|
||||||
'on (t3.parent = t1.parent) '
|
'on (t3.parent = t1.parent) '
|
||||||
'JOIN ('
|
'JOIN ('
|
||||||
'SELECT '
|
'SELECT '
|
||||||
'docstatus, company, is_pos, name, posting_date, owner, sum(base_total) as "base_total", '
|
'docstatus, company, is_pos, name, posting_date, owner, sum(base_total) as "base_total", '
|
||||||
'sum(net_total) as "net_total", sum(total_taxes_and_charges) as "total_taxes", '
|
'sum(net_total) as "net_total", sum(total_taxes_and_charges) as "total_taxes", '
|
||||||
'sum(base_paid_amount) as "paid_amount", sum(outstanding_amount) as "outstanding_amount" '
|
'sum(base_paid_amount) as "paid_amount", sum(outstanding_amount) as "outstanding_amount" '
|
||||||
'FROM `tabSales Invoice` '
|
'FROM `tabSales Invoice` '
|
||||||
'GROUP BY name'
|
'GROUP BY name'
|
||||||
') a '
|
') a '
|
||||||
'ON ('
|
'ON ('
|
||||||
't1.parent = a.name and t1.base_total = a.base_total) '
|
't1.parent = a.name and t1.base_total = a.base_total) '
|
||||||
'WHERE a.docstatus = 1'
|
'WHERE a.docstatus = 1'
|
||||||
' AND {conditions} '
|
' AND {conditions} '
|
||||||
'GROUP BY '
|
'GROUP BY '
|
||||||
'owner, posting_date, warehouse'.format(conditions=conditions), filters, as_dict=1
|
'owner, posting_date, warehouse'.format(conditions=conditions), filters, as_dict=1
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@ -170,6 +170,7 @@ def get_mode_of_payments(filters):
|
|||||||
from `tabSales Invoice` a, `tabPayment Entry` b,`tabPayment Entry Reference` c
|
from `tabSales Invoice` a, `tabPayment Entry` b,`tabPayment Entry Reference` c
|
||||||
where a.name = c.reference_name
|
where a.name = c.reference_name
|
||||||
and b.name = c.parent
|
and b.name = c.parent
|
||||||
|
and b.docstatus = 1
|
||||||
and a.name in ({invoice_list_names})
|
and a.name in ({invoice_list_names})
|
||||||
union
|
union
|
||||||
select a.owner, a.posting_date,
|
select a.owner, a.posting_date,
|
||||||
@ -211,6 +212,7 @@ def get_mode_of_payment_details(filters):
|
|||||||
from `tabSales Invoice` a, `tabPayment Entry` b,`tabPayment Entry Reference` c
|
from `tabSales Invoice` a, `tabPayment Entry` b,`tabPayment Entry Reference` c
|
||||||
where a.name = c.reference_name
|
where a.name = c.reference_name
|
||||||
and b.name = c.parent
|
and b.name = c.parent
|
||||||
|
and b.docstatus = 1
|
||||||
and a.name in ({invoice_list_names})
|
and a.name in ({invoice_list_names})
|
||||||
group by a.owner, a.posting_date, mode_of_payment
|
group by a.owner, a.posting_date, mode_of_payment
|
||||||
union
|
union
|
||||||
|
Loading…
x
Reference in New Issue
Block a user