Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

1.7 KB
Raw Blame

Consume First: whole assemblies only

Customer feedback on the partial-stock split: a unit that needs 2 of a part must get two of the SAME part. Old stock is used in whole multiples of the per-assembly quantity; the odd part stays on the shelf. Units in a batch may differ from one another; a single unit never mixes old and new.

Tasks

    1. Shared helper consumableInWholeAssemblies(onHand, perAssembly) in lib/supersession-pick.ts (+ RoundingMode.Down in precision.ts), Deno tests.
    1. get-method: settle pass after insert handles BOTH directions with the per-assembly threshold — pull a successor line back when the predecessor covers ≥ 1 assembly; push a predecessor line to the successor when it covers none.
    1. generatePickingList: split at whole assemblies; predecessor "in stock" for Consume First means ≥ 1 assembly of the running balance.
    1. SQL get_picking_schedule: Consume First predecessor stock test ≥ per-assembly quantity (new migration); openJobMaterialLines gains quantityPerParent.
    1. Job materials note + Order Status netting round the same way.
    1. Item planning list split rounds per line.
    1. MRP post-explode Consume First pass nets per contributor in whole assemblies.
    1. Pick line notes (ERP + MES) and the materials note say how many assemblies.
    1. Rule doc, lessons, types regenerated, tests, typecheck, lint.

Verification

  • deno test packages/database/supabase/functions/lib/supersession-pick.test.ts
  • pnpm --filter ./apps/erp exec vitest run app/modules/inventory/supersession-pick.test.ts
  • pnpm exec turbo run typecheck --filter=erp --filter=mes --filter=@carbon/ee
  • pnpm run lint