frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.87k stars 7.33k forks source link

Inconsistent calculation of operational cost from BOM to Work Order #40862

Open JeanWLC opened 7 months ago

JeanWLC commented 7 months ago

Information about bug

When the cost of an operation is calculated for a Work Order, it doesn't correspond to (is not what is expected) when taking into account what is calculated on the Costing tab of the BOM

The problem seems to lie with how the operational cost is calculated for the BOM using the quantity set on the Production Items tab.

Assume the following values are set on the BOM (to manufacture 5 items):

image

When the Costing tab is viewed, operating cost will be 34.00. This seems to be calculated as follows:

Hour rate (Operation time / 60) Quantity / Batch size = Total Operating Cost 68 (60 / 60) 5 / 10 = 34

image

This is as expected

When creating a new Work Order for a quantity of 20, operating cost seems to be calculated as follows:

Hour rate (Operation time / 60) / Quantity / Batch size Work Order qty to manufacture = Operating Cost 68 (60 / 60) / 5 / 10 20 = 27.2

image

This is not what is expected taking into account the operational cost per unit on the BOM Costing tab: Operation cost per unit according to BOM: Hour rate (Operation time / 60) / Batch size = Operating Cost per unit 68 (60 / 60) / 10 = 6.8

Thus the operation cost on a Work Order for 20 should be: 6.8 * 20 = 136

While the BOM Costing tab times cost per unit with quantity set on the BOM, the Work Order divides by that quantity and multiplies with quantity set for the Work Order

So it seems that the Work Order calculation assumes that the operation time set on the BOM is the time it takes to manufacture the quantity set on the Production Item tab, but the BOM Costing tab use the production time as time per unit to manufacture. This is supported by looking at the production time calculated on the Word Order too: the production time is lower than expected by a factor = to BOM quantity

Module

manufacturing

Version

ERPNext: v14.27.12 Frappe Framework: v14.40.0

Installation method

docker

Relevant log output / Stack trace / Full Error Message.

No response

JeanWLC commented 7 months ago

As a workaround, I'm setting the quantity of the BOM on the Production Item tab to 1, and the quantity of the raw materials to correspond to that

schmutzfuss42 commented 7 months ago

I answer here, coz my bug is mentioned as duplicated to this one (I'm focussed on time issue from BOM->WO->JC):

The workaround is only possible as long as the quantity is smaller or similar to the batch size, if it's bigger, the system will create jobcards which have fulltime for every jobcard, instead a divided time Quantity in BOM 1, time one minute, batch size 200 -> create a work order for 401 pcs -> getting three job cards, every job card has 40,1 Minutes (instead of the whole jobcards together should have 401 Minutes, JC1: 200, JC2: 200, JC3: 1)

Our current workarond: .../frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/work_order/work_order.py

Line 858: OLD: d.time_in_mins = flt(d.time_in_mins) (flt(self.qty) / flt(d.batch_size)) NEW: d.time_in_mins = flt(d.time_in_mins) flt(self.qty)

at least until the max batch size it works for us, waiting for a professional developer here ... to find the correct solution for that :-)

JeanWLC commented 7 months ago

I answer here, coz my bug is mentioned as duplicated to this one (I'm focussed on time issue from BOM->WO->JC):

The workaround is only possible as long as the quantity is smaller or similar to the batch size, if it's bigger, the system will create jobcards which have fulltime for every jobcard, instead a divided time Quantity in BOM 1, time one minute, batch size 200 -> create a work order for 401 pcs -> getting three job cards, every job card has 40,1 Minutes (instead of the whole jobcards together should have 401 Minutes, JC1: 200, JC2: 200, JC3: 1)

Our current workarond: .../frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/work_order/work_order.py

Line 858: OLD: d.time_in_mins = flt(d.time_in_mins) (flt(self.qty) / flt(d.batch_size)) NEW: d.time_in_mins = flt(d.time_in_mins) flt(self.qty)

at least until the max batch size it works for us, waiting for a professional developer here ... to find the correct solution for that :-)

@schmutzfuss42 It seems we may have two separate, but related, issues. I tried replicating your findings, but always got a single job card. Can you please share your exact BOM settings and work order through screenshots so I can confirm whether we do indeed have the exact same issue?

JeanWLC commented 7 months ago

I answer here, coz my bug is mentioned as duplicated to this one (I'm focussed on time issue from BOM->WO->JC): The workaround is only possible as long as the quantity is smaller or similar to the batch size, if it's bigger, the system will create jobcards which have fulltime for every jobcard, instead a divided time Quantity in BOM 1, time one minute, batch size 200 -> create a work order for 401 pcs -> getting three job cards, every job card has 40,1 Minutes (instead of the whole jobcards together should have 401 Minutes, JC1: 200, JC2: 200, JC3: 1) Our current workarond: .../frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/work_order/work_order.py Line 858: OLD: d.time_in_mins = flt(d.time_in_mins) (flt(self.qty) / flt(d.batch_size)) NEW: d.time_in_mins = flt(d.time_in_mins) flt(self.qty) at least until the max batch size it works for us, waiting for a professional developer here ... to find the correct solution for that :-)

@schmutzfuss42 It seems we may have two separate, but related, issues. I tried replicating your findings, but always got a single job card. Can you please share your exact BOM settings and work order through screenshots so I can confirm whether we do indeed have the exact same issue?

@schmutzfuss42 Ignore my previous comment. Just realized my operation wasn't set with "Create Job Card based on Batch Size" enabled. @Nihantra-Patel I was able to replicate @schmutzfuss42 findings that operation times are not divided up correctly between job cards

schmutzfuss42 commented 7 months ago

I answer here, coz my bug is mentioned as duplicated to this one (I'm focussed on time issue from BOM->WO->JC): The workaround is only possible as long as the quantity is smaller or similar to the batch size, if it's bigger, the system will create jobcards which have fulltime for every jobcard, instead a divided time Quantity in BOM 1, time one minute, batch size 200 -> create a work order for 401 pcs -> getting three job cards, every job card has 40,1 Minutes (instead of the whole jobcards together should have 401 Minutes, JC1: 200, JC2: 200, JC3: 1) Our current workarond: .../frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/work_order/work_order.py Line 858: OLD: d.time_in_mins = flt(d.time_in_mins) (flt(self.qty) / flt(d.batch_size)) NEW: d.time_in_mins = flt(d.time_in_mins) flt(self.qty) at least until the max batch size it works for us, waiting for a professional developer here ... to find the correct solution for that :-)

@schmutzfuss42 It seems we may have two separate, but related, issues. I tried replicating your findings, but always got a single job card. Can you please share your exact BOM settings and work order through screenshots so I can confirm whether we do indeed have the exact same issue?

@schmutzfuss42 Ignore my previous comment. Just realized my operation wasn't set with "Create Job Card based on Batch Size" enabled. @nihantra I was able to replicate @schmutzfuss42 findings that operation times are not divided up correctly between job cards

https://github.com/frappe/erpnext/assets/150498137/0e66ab24-97f6-4959-b449-ba06b49c890b

Should'nt be one minute in the work order, should'nt be two times one minute in the jobcard. Should be 100 Minute in the work order, should be two times 50 minutes in the jobcard (together 100 minutes)

JeanWLC commented 7 months ago

@Nihantra-Patel what's the difference between batch size set for an operation in the BOM settings image

and batch size set on the operation itself outside the BOM image

Which would take precedence? Doesn't seem like the second is being used.

JeanWLC commented 7 months ago

I answer here, coz my bug is mentioned as duplicated to this one (I'm focussed on time issue from BOM->WO->JC): The workaround is only possible as long as the quantity is smaller or similar to the batch size, if it's bigger, the system will create jobcards which have fulltime for every jobcard, instead a divided time Quantity in BOM 1, time one minute, batch size 200 -> create a work order for 401 pcs -> getting three job cards, every job card has 40,1 Minutes (instead of the whole jobcards together should have 401 Minutes, JC1: 200, JC2: 200, JC3: 1) Our current workarond: .../frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/work_order/work_order.py Line 858: OLD: d.time_in_mins = flt(d.time_in_mins) (flt(self.qty) / flt(d.batch_size)) NEW: d.time_in_mins = flt(d.time_in_mins) flt(self.qty) at least until the max batch size it works for us, waiting for a professional developer here ... to find the correct solution for that :-)

@schmutzfuss42 It seems we may have two separate, but related, issues. I tried replicating your findings, but always got a single job card. Can you please share your exact BOM settings and work order through screenshots so I can confirm whether we do indeed have the exact same issue?

@schmutzfuss42 Ignore my previous comment. Just realized my operation wasn't set with "Create Job Card based on Batch Size" enabled. @nihantra I was able to replicate @schmutzfuss42 findings that operation times are not divided up correctly between job cards

BOM-WorkOrder-JobCard_withoutPatch.mp4 Should'nt be one minute in the work order, should'nt be two times one minute in the jobcard. Should be 100 Minute in the work order, should be two times 50 minutes in the jobcard (together 100 minutes)

This is definitely the the sam issue as I described when I opened this issue. Using the calculations there explains why the operation time is one minute, but the distributions of operating times of the work order to job cards being incorrect I didn't notice before, because I didn't create job cards per batch size. I was able to replicate this issue too.

JeanWLC commented 5 months ago

@schmutzfuss42 Can you please confirm whether this is considered a bug or not, or if you need more info to clarify something?