mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 12:49:10 +00:00
refactor(sales_invoice): replace sql with qb in get_discounting_status (#55378)
This commit is contained in:
@@ -2388,19 +2388,21 @@ def is_overdue(doc, total):
|
|||||||
def get_discounting_status(sales_invoice):
|
def get_discounting_status(sales_invoice):
|
||||||
status = None
|
status = None
|
||||||
|
|
||||||
invoice_discounting_list = frappe.db.sql(
|
InvoiceDiscounting = frappe.qb.DocType("Invoice Discounting")
|
||||||
"""
|
DiscountedInvoice = frappe.qb.DocType("Discounted Invoice")
|
||||||
select status
|
|
||||||
from `tabInvoice Discounting` id, `tabDiscounted Invoice` d
|
query = (
|
||||||
where
|
frappe.qb.from_(InvoiceDiscounting)
|
||||||
id.name = d.parent
|
.join(DiscountedInvoice)
|
||||||
and d.sales_invoice=%s
|
.on(InvoiceDiscounting.name == DiscountedInvoice.parent)
|
||||||
and id.docstatus=1
|
.select(InvoiceDiscounting.status)
|
||||||
and status in ('Disbursed', 'Settled')
|
.where(DiscountedInvoice.sales_invoice == sales_invoice)
|
||||||
""",
|
.where(InvoiceDiscounting.docstatus == 1)
|
||||||
sales_invoice,
|
.where(InvoiceDiscounting.status.isin(["Disbursed", "Settled"]))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
invoice_discounting_list = query.run()
|
||||||
|
|
||||||
for d in invoice_discounting_list:
|
for d in invoice_discounting_list:
|
||||||
status = d[0]
|
status = d[0]
|
||||||
if status == "Disbursed":
|
if status == "Disbursed":
|
||||||
|
|||||||
Reference in New Issue
Block a user