mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-09 00:01:18 +00:00
fix: query (#18465)
This commit is contained in:
committed by
Nabin Hait
parent
55025d4dc9
commit
edb3cdbb59
@@ -613,13 +613,18 @@ def get_orders_to_be_billed(posting_date, party_type, party, party_account_curre
|
|||||||
|
|
||||||
orders = []
|
orders = []
|
||||||
if voucher_type:
|
if voucher_type:
|
||||||
ref_field = "base_grand_total" if party_account_currency == company_currency else "grand_total"
|
if party_account_currency == company_currency:
|
||||||
|
grand_total_field = "base_grand_total"
|
||||||
|
rounded_total_field = "base_rounded_total"
|
||||||
|
else:
|
||||||
|
grand_total_field = "grand_total"
|
||||||
|
rounded_total_field = "rounded_total"
|
||||||
|
|
||||||
orders = frappe.db.sql("""
|
orders = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
name as voucher_no,
|
name as voucher_no,
|
||||||
{ref_field} as invoice_amount,
|
if({rounded_total_field}, {rounded_total_field}, {grand_total_field}) as invoice_amount,
|
||||||
({ref_field} - advance_paid) as outstanding_amount,
|
(if({rounded_total_field}, {rounded_total_field}, {grand_total_field}) - advance_paid) as outstanding_amount,
|
||||||
transaction_date as posting_date
|
transaction_date as posting_date
|
||||||
from
|
from
|
||||||
`tab{voucher_type}`
|
`tab{voucher_type}`
|
||||||
@@ -627,17 +632,18 @@ def get_orders_to_be_billed(posting_date, party_type, party, party_account_curre
|
|||||||
{party_type} = %s
|
{party_type} = %s
|
||||||
and docstatus = 1
|
and docstatus = 1
|
||||||
and ifnull(status, "") != "Closed"
|
and ifnull(status, "") != "Closed"
|
||||||
and {ref_field} > advance_paid
|
and if({rounded_total_field}, {rounded_total_field}, {grand_total_field}) > advance_paid
|
||||||
and abs(100 - per_billed) > 0.01
|
and abs(100 - per_billed) > 0.01
|
||||||
{condition}
|
{condition}
|
||||||
order by
|
order by
|
||||||
transaction_date, name
|
transaction_date, name
|
||||||
""".format(**{
|
""".format(**{
|
||||||
"ref_field": ref_field,
|
"rounded_total_field": rounded_total_field,
|
||||||
|
"grand_total_field": grand_total_field,
|
||||||
"voucher_type": voucher_type,
|
"voucher_type": voucher_type,
|
||||||
"party_type": scrub(party_type),
|
"party_type": scrub(party_type),
|
||||||
"condition": condition
|
"condition": condition
|
||||||
}), party, as_dict=True)
|
}), (party), as_dict=True)
|
||||||
|
|
||||||
order_list = []
|
order_list = []
|
||||||
for d in orders:
|
for d in orders:
|
||||||
|
|||||||
Reference in New Issue
Block a user