mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 04:59:18 +00:00
refactor(Sales Invoice): convert to guard clause
This commit is contained in:
@@ -591,43 +591,48 @@ class SalesInvoice(SellingController):
|
|||||||
self.delete_auto_created_batches()
|
self.delete_auto_created_batches()
|
||||||
|
|
||||||
def update_status_updater_args(self):
|
def update_status_updater_args(self):
|
||||||
if cint(self.update_stock):
|
if not cint(self.update_stock):
|
||||||
self.status_updater.append(
|
return
|
||||||
{
|
|
||||||
"source_dt": "Sales Invoice Item",
|
self.status_updater.append(
|
||||||
"target_dt": "Sales Order Item",
|
{
|
||||||
"target_parent_dt": "Sales Order",
|
"source_dt": "Sales Invoice Item",
|
||||||
"target_parent_field": "per_delivered",
|
"target_dt": "Sales Order Item",
|
||||||
"target_field": "delivered_qty",
|
"target_parent_dt": "Sales Order",
|
||||||
"target_ref_field": "qty",
|
"target_parent_field": "per_delivered",
|
||||||
"source_field": "qty",
|
"target_field": "delivered_qty",
|
||||||
"join_field": "so_detail",
|
"target_ref_field": "qty",
|
||||||
"percent_join_field": "sales_order",
|
"source_field": "qty",
|
||||||
"status_field": "delivery_status",
|
"join_field": "so_detail",
|
||||||
"keyword": "Delivered",
|
"percent_join_field": "sales_order",
|
||||||
"second_source_dt": "Delivery Note Item",
|
"status_field": "delivery_status",
|
||||||
"second_source_field": "qty",
|
"keyword": "Delivered",
|
||||||
"second_join_field": "so_detail",
|
"second_source_dt": "Delivery Note Item",
|
||||||
"overflow_type": "delivery",
|
"second_source_field": "qty",
|
||||||
"extra_cond": """ and exists(select name from `tabSales Invoice`
|
"second_join_field": "so_detail",
|
||||||
where name=`tabSales Invoice Item`.parent and update_stock = 1)""",
|
"overflow_type": "delivery",
|
||||||
}
|
"extra_cond": """ and exists(select name from `tabSales Invoice`
|
||||||
)
|
where name=`tabSales Invoice Item`.parent and update_stock = 1)""",
|
||||||
if cint(self.is_return):
|
}
|
||||||
self.status_updater.append(
|
)
|
||||||
{
|
|
||||||
"source_dt": "Sales Invoice Item",
|
if not cint(self.is_return):
|
||||||
"target_dt": "Sales Order Item",
|
return
|
||||||
"join_field": "so_detail",
|
|
||||||
"target_field": "returned_qty",
|
self.status_updater.append(
|
||||||
"target_parent_dt": "Sales Order",
|
{
|
||||||
"source_field": "-1 * qty",
|
"source_dt": "Sales Invoice Item",
|
||||||
"second_source_dt": "Delivery Note Item",
|
"target_dt": "Sales Order Item",
|
||||||
"second_source_field": "-1 * qty",
|
"join_field": "so_detail",
|
||||||
"second_join_field": "so_detail",
|
"target_field": "returned_qty",
|
||||||
"extra_cond": """ and exists (select name from `tabSales Invoice` where name=`tabSales Invoice Item`.parent and update_stock=1 and is_return=1)""",
|
"target_parent_dt": "Sales Order",
|
||||||
}
|
"source_field": "-1 * qty",
|
||||||
)
|
"second_source_dt": "Delivery Note Item",
|
||||||
|
"second_source_field": "-1 * qty",
|
||||||
|
"second_join_field": "so_detail",
|
||||||
|
"extra_cond": """ and exists (select name from `tabSales Invoice` where name=`tabSales Invoice Item`.parent and update_stock=1 and is_return=1)""",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def check_credit_limit(self):
|
def check_credit_limit(self):
|
||||||
from erpnext.selling.doctype.customer.customer import check_credit_limit
|
from erpnext.selling.doctype.customer.customer import check_credit_limit
|
||||||
|
|||||||
Reference in New Issue
Block a user