mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-12 17:23:38 +00:00
fix(manufacturing): validate delivered qty in production plan
This commit is contained in:
@@ -385,6 +385,15 @@ class ProductionPlan(Document):
|
||||
|
||||
pi = frappe.qb.DocType("Packed Item")
|
||||
|
||||
pending_qty = (
|
||||
frappe.qb.terms.Case()
|
||||
.when(
|
||||
(so_item.work_order_qty > so_item.delivered_qty),
|
||||
(((so_item.qty - so_item.work_order_qty) * pi.qty) / so_item.qty),
|
||||
)
|
||||
.else_(((so_item.qty - so_item.delivered_qty) * pi.qty) / so_item.qty)
|
||||
)
|
||||
|
||||
packed_items_query = (
|
||||
frappe.qb.from_(so_item)
|
||||
.from_(pi)
|
||||
@@ -392,7 +401,7 @@ class ProductionPlan(Document):
|
||||
pi.parent,
|
||||
pi.item_code,
|
||||
pi.warehouse.as_("warehouse"),
|
||||
(((so_item.qty - so_item.work_order_qty) * pi.qty) / so_item.qty).as_("pending_qty"),
|
||||
pending_qty.as_("pending_qty"),
|
||||
pi.parent_item,
|
||||
pi.description,
|
||||
so_item.name,
|
||||
@@ -403,7 +412,16 @@ class ProductionPlan(Document):
|
||||
& (so_item.docstatus == 1)
|
||||
& (pi.parent_item == so_item.item_code)
|
||||
& (so_item.parent.isin(so_list))
|
||||
& (so_item.qty > so_item.work_order_qty)
|
||||
& (
|
||||
(
|
||||
(so_item.work_order_qty > so_item.delivered_qty)
|
||||
& (so_item.qty > so_item.work_order_qty)
|
||||
)
|
||||
| (
|
||||
(so_item.work_order_qty <= so_item.delivered_qty)
|
||||
& (so_item.qty > so_item.delivered_qty)
|
||||
)
|
||||
)
|
||||
& (
|
||||
ExistsCriterion(
|
||||
frappe.qb.from_(bom)
|
||||
|
||||
Reference in New Issue
Block a user