refactor: create invoices list without if else
This commit is contained in:
parent
85ed0fb8d6
commit
a4b8d67323
@ -157,25 +157,20 @@ def set_payment_terms_statuses(sales_orders, invoices, filters):
|
|||||||
|
|
||||||
for so in sales_orders:
|
for so in sales_orders:
|
||||||
so.currency = frappe.get_cached_value('Company', filters.get('company'), 'default_currency')
|
so.currency = frappe.get_cached_value('Company', filters.get('company'), 'default_currency')
|
||||||
|
so.invoices = ""
|
||||||
for inv in [x for x in invoices if x.sales_order == so.name and x.invoice_amount > 0]:
|
for inv in [x for x in invoices if x.sales_order == so.name and x.invoice_amount > 0]:
|
||||||
if so.base_payment_amount - so.paid_amount > 0:
|
if so.base_payment_amount - so.paid_amount > 0:
|
||||||
amount = so.base_payment_amount - so.paid_amount
|
amount = so.base_payment_amount - so.paid_amount
|
||||||
if inv.invoice_amount >= amount:
|
if inv.invoice_amount >= amount:
|
||||||
inv.invoice_amount -= amount
|
inv.invoice_amount -= amount
|
||||||
so.paid_amount += amount
|
so.paid_amount += amount
|
||||||
if so.invoices:
|
so.invoices += "," + inv.invoice
|
||||||
so.invoices = so.invoices + "," + inv.invoice
|
|
||||||
else:
|
|
||||||
so.invoices = inv.invoice
|
|
||||||
so.status = "Completed"
|
so.status = "Completed"
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
so.paid_amount += inv.invoice_amount
|
so.paid_amount += inv.invoice_amount
|
||||||
inv.invoice_amount = 0
|
inv.invoice_amount = 0
|
||||||
if so.invoices:
|
so.invoices += "," + inv.invoice
|
||||||
so.invoices = so.invoices + "," + inv.invoice
|
|
||||||
else:
|
|
||||||
so.invoices = inv.invoice
|
|
||||||
so.status = "Partly Paid"
|
so.status = "Partly Paid"
|
||||||
|
|
||||||
return sales_orders, invoices
|
return sales_orders, invoices
|
||||||
|
Loading…
Reference in New Issue
Block a user