Merge pull request #21641 from frappe/mergify/bp/develop/pr-21635

fix: Job Card submitted qty (bp #21635)
This commit is contained in:
rohitwaghchaure 2020-05-08 10:28:19 +05:30 committed by GitHub
commit 6a9c84b5f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -421,6 +421,9 @@ class WorkOrder(Document):
return holidays[holiday_list]
def update_operation_status(self):
allowance_percentage = flt(frappe.db.get_single_value("Manufacturing Settings", "overproduction_percentage_for_work_order"))
max_allowed_qty_for_wo = flt(self.qty) + (allowance_percentage/100 * flt(self.qty))
for d in self.get("operations"):
if not d.completed_qty:
d.status = "Pending"
@ -428,6 +431,8 @@ class WorkOrder(Document):
d.status = "Work in Progress"
elif flt(d.completed_qty) == flt(self.qty):
d.status = "Completed"
elif flt(d.completed_qty) <= max_allowed_qty_for_wo:
d.status = "Completed"
else:
frappe.throw(_("Completed Qty can not be greater than 'Qty to Manufacture'"))