mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-24 17:18:30 +00:00
* fix: incorrect Material Transferred for Manufacturing qty (#44823)
(cherry picked from commit fe0036e707)
# Conflicts:
# erpnext/manufacturing/doctype/job_card/job_card.py
* chore: fix conflicts
---------
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -944,8 +944,9 @@ class JobCard(Document):
|
|||||||
if doc.transfer_material_against == "Job Card" and not doc.skip_transfer:
|
if doc.transfer_material_against == "Job Card" and not doc.skip_transfer:
|
||||||
min_qty = []
|
min_qty = []
|
||||||
for d in doc.operations:
|
for d in doc.operations:
|
||||||
if d.completed_qty:
|
completed_qty = flt(d.completed_qty) + flt(d.process_loss_qty)
|
||||||
min_qty.append(d.completed_qty)
|
if completed_qty:
|
||||||
|
min_qty.append(completed_qty)
|
||||||
else:
|
else:
|
||||||
min_qty = []
|
min_qty = []
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from frappe.tests.utils import FrappeTestCase, change_settings, timeout
|
|||||||
from frappe.utils import add_days, add_months, add_to_date, cint, flt, now, today
|
from frappe.utils import add_days, add_months, add_to_date, cint, flt, now, today
|
||||||
|
|
||||||
from erpnext.manufacturing.doctype.job_card.job_card import JobCardCancelError
|
from erpnext.manufacturing.doctype.job_card.job_card import JobCardCancelError
|
||||||
|
from erpnext.manufacturing.doctype.job_card.job_card import make_stock_entry as make_stock_entry_from_jc
|
||||||
from erpnext.manufacturing.doctype.production_plan.test_production_plan import make_bom
|
from erpnext.manufacturing.doctype.production_plan.test_production_plan import make_bom
|
||||||
from erpnext.manufacturing.doctype.work_order.work_order import (
|
from erpnext.manufacturing.doctype.work_order.work_order import (
|
||||||
CapacityError,
|
CapacityError,
|
||||||
@@ -505,6 +506,60 @@ class TestWorkOrder(FrappeTestCase):
|
|||||||
for stock_entry in stock_entries:
|
for stock_entry in stock_entries:
|
||||||
stock_entry.cancel()
|
stock_entry.cancel()
|
||||||
|
|
||||||
|
def test_work_order_material_transferred_qty_with_process_loss(self):
|
||||||
|
stock_entries = []
|
||||||
|
bom = frappe.get_doc("BOM", {"docstatus": 1, "with_operations": 1, "company": "_Test Company"})
|
||||||
|
|
||||||
|
work_order = make_wo_order_test_record(
|
||||||
|
item=bom.item,
|
||||||
|
qty=2,
|
||||||
|
bom_no=bom.name,
|
||||||
|
source_warehouse="_Test Warehouse - _TC",
|
||||||
|
transfer_material_against="Job Card",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(work_order.qty, 2)
|
||||||
|
|
||||||
|
for row in work_order.required_items:
|
||||||
|
stock_entry_doc = test_stock_entry.make_stock_entry(
|
||||||
|
item_code=row.item_code, target="_Test Warehouse - _TC", qty=row.required_qty, basic_rate=100
|
||||||
|
)
|
||||||
|
stock_entries.append(stock_entry_doc)
|
||||||
|
|
||||||
|
job_cards = frappe.get_all(
|
||||||
|
"Job Card", filters={"work_order": work_order.name}, order_by="creation asc"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in job_cards:
|
||||||
|
transfer_entry_1 = make_stock_entry_from_jc(row.name)
|
||||||
|
transfer_entry_1.submit()
|
||||||
|
|
||||||
|
doc = frappe.get_doc("Job Card", row.name)
|
||||||
|
for row in doc.scheduled_time_logs:
|
||||||
|
doc.append(
|
||||||
|
"time_logs",
|
||||||
|
{
|
||||||
|
"from_time": row.from_time,
|
||||||
|
"to_time": row.to_time,
|
||||||
|
"time_in_mins": row.time_in_mins,
|
||||||
|
"completed_qty": 1,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
doc.save()
|
||||||
|
doc.submit()
|
||||||
|
|
||||||
|
self.assertEqual(doc.total_completed_qty, 1)
|
||||||
|
self.assertEqual(doc.process_loss_qty, 1)
|
||||||
|
|
||||||
|
work_order.reload()
|
||||||
|
|
||||||
|
self.assertEqual(work_order.material_transferred_for_manufacturing, 2)
|
||||||
|
|
||||||
|
for row in work_order.operations:
|
||||||
|
self.assertEqual(row.completed_qty, 1)
|
||||||
|
self.assertEqual(row.process_loss_qty, 1)
|
||||||
|
|
||||||
def test_capcity_planning(self):
|
def test_capcity_planning(self):
|
||||||
frappe.db.set_single_value(
|
frappe.db.set_single_value(
|
||||||
"Manufacturing Settings", {"disable_capacity_planning": 0, "capacity_planning_for_days": 1}
|
"Manufacturing Settings", {"disable_capacity_planning": 0, "capacity_planning_for_days": 1}
|
||||||
|
|||||||
Reference in New Issue
Block a user