mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-17 00:25:01 +00:00
fix: incorrect logic for "Reserved Qty for Production" (#28880)
* fix: reservation for production incorrect
The query uses case to decide what fields to compute reservation on,
this case is outermost case hence the very first Work order's "Skip
transfer" is considered for ALL work orders.
Solution: move the case inside Sum.
Steps to reproduce:
1. Make work order for more than 1 qty (with | without skip transfer)
2. Create manufacture and transfer entries.
3. Keep checking reserved quantities during this process.
* test: use default warehouse for testing reservation
(cherry picked from commit 80f1a8c645)
This commit is contained in:
committed by
Ankush Menat
parent
25fd11e24f
commit
bdd43274b2
@@ -91,7 +91,7 @@ class TestWorkOrder(ERPNextTestCase):
|
||||
|
||||
def test_reserved_qty_for_partial_completion(self):
|
||||
item = "_Test Item"
|
||||
warehouse = create_warehouse("Test Warehouse for reserved_qty - _TC")
|
||||
warehouse = "_Test Warehouse - _TC"
|
||||
|
||||
bin1_at_start = get_bin(item, warehouse)
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@ class Bin(Document):
|
||||
in open work orders'''
|
||||
self.reserved_qty_for_production = frappe.db.sql('''
|
||||
SELECT
|
||||
CASE WHEN ifnull(skip_transfer, 0) = 0 THEN
|
||||
SUM(item.required_qty - item.transferred_qty)
|
||||
SUM(CASE WHEN ifnull(skip_transfer, 0) = 0 THEN
|
||||
item.required_qty - item.transferred_qty
|
||||
ELSE
|
||||
SUM(item.required_qty - item.consumed_qty)
|
||||
item.required_qty - item.consumed_qty END)
|
||||
END
|
||||
FROM `tabWork Order` pro, `tabWork Order Item` item
|
||||
WHERE
|
||||
|
||||
Reference in New Issue
Block a user