Skip to content

feat: a BOM cost update should re-calculate operating costs off a workstation vs using cached hour_rate field #183

Description

@HKuz

This issue came up working on a client feature that depends on the Workstation Operating Cost feature. Currently, Inventory Tools will update the hour_rate field on Workstation in before_save, grabbing the appropriate current-date-based costs from the Workstation Operating Cost table and setting the field, with a fallback to ERPNext's calc to use the component fields (labor + electricity + etc).

The client's use-case is they will add new Workstation Operating Cost rows with valid_from dates happening in the future, evaluate costing, then trigger a 'rollover' (happens on the from_date), which also updates BOM costs. This bypasses the before_save hook, and ERPNext's BOM cost calcs grab a cached value from the hour_rate field on Workstation, which will be the stale rates.

Proposed fix:

  • Create an InventoryToolsBOM class
  • Create override in UI for when a row is added to the BOM Operation table, the row's hour_rate should check the Workstation Op Cost table dates against current date (or if no Workstation Op Cost rows, uses fallback to sum of static field values for labor/electricity/etc)
  • Create override on InventoryToolsBOM class for update_rate_and_time when costs are updated
  • If the rate changed in either case, should set the Workstation's hour_rate field to the new value in the DB

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions