Close review gaps: gate fixes, cylinder register, roll tracking, costing, Uganda setup #1

Merged
denis_ireri merged 8 commits from feat/review-backlog-fixes into develop 2026-10-10 10:02:47 +00:00
Contributor

This PR addresses the blocker and major findings from the pre-implementation review against Makap Uganda ERP Review PRD v1.1. It does not change any data on the live site; bench migrate adds fields, roles and permissions, and the company setup runs only by hand.

Fixes to existing gates

  • Permission bypass (B6). evaluate_work_order_readiness, evaluate_material_availability, apply_quality_disposition and the closure recompute saved with ignore_permissions, so any desk user could mark a Work Order Ready or put a QI on Hold. They now require the right role plus write permission.
  • Work Order specification gate never fired (M1). The spec is now copied from the Sales Order Item, walking back through the Production Plan for sub-assembly orders. Release blockers are re-derived on submit, not read from a stored select.
  • Tooling never enforced (M2). Tooling readiness is derived from the new cylinder register and blocks release.
  • Dispatch Gate too loose (M3). Controlled lines need a batch, and each batch needs its own released final/outgoing inspection. "Reserved" mode needs stock reservation switched on.
  • Returns read a field Delivery Note Item doesn't have. Partial credit notes were wrongly blocked (m5). Billing recompute loaded every invoice (m6). Supply Close used an item-code proxy; it now follows SO → Production Plan → MR → PO.

New capability

  • Print Cylinder DocType: a register of each cylinder or plate (spec, colour station, dimensions, ownership, location, condition, impressions).
  • Roll details on Batch: stage, width, length, micron, net and gross kg, supplier lot, machine, Work Order.
  • Job Card output and waste: rolls, metres, kg, set-up and running waste with a required reason, and a derived waste %.
  • Quotation cost estimate: material (with expected waste) + BOM operating cost + set-up + cylinder charge, shown with the margin against the quoted rate.
  • Reports: Roll Genealogy (backward and forward traceability) and Work Order Cost Variance (planned vs actual).
  • Role profiles for the 10 PRD roles, new Machine Operator and Prepress roles, and quality decisions locked to QA (permlevel 1).
  • Form layout: about 120 custom fields move from the bottom of each form into a "Makap" tab with labelled sections (m1).
  • setup_uganda.run: a dry-run-first script for a UGX company, VAT 18% templates, stage WIP, Quarantine and Returns Hold warehouses, and manufacturing settings. It never deletes; the Kenya company stays until someone removes it by hand.

Rollout

  1. Merge into develop and deploy to a staging site first.
  2. Run bench migrate, then bench --site <site> run-tests --app makap_backend.
  3. Run setup_uganda.run as a dry run, review the plan, then run it with confirm=1.
  4. Check the forms (Work Order, QI, Delivery Note, Job Card, Batch) on a tablet.

Testing

  • test_gates.py (11 cases, database reads mocked) passes locally against Frappe v15 source.
  • test_print_cylinder.py needs a test site with ERPNext. Not run yet, because there was no bench to run it on.
  • setup_uganda.py, the two reports and the migrate-time field moves are not yet run against a database. Staging is the first real check.

Decisions Makap still owns

Roll identity (one batch per roll), cylinder ownership, consumption costing method, company name and fiscal year, and the EFRIS route. The current defaults are listed in the README.

This PR addresses the blocker and major findings from the pre-implementation review against *Makap Uganda ERP Review PRD v1.1*. It does not change any data on the live site; `bench migrate` adds fields, roles and permissions, and the company setup runs only by hand. ## Fixes to existing gates - **Permission bypass (B6).** `evaluate_work_order_readiness`, `evaluate_material_availability`, `apply_quality_disposition` and the closure `recompute` saved with `ignore_permissions`, so any desk user could mark a Work Order Ready or put a QI on Hold. They now require the right role plus write permission. - **Work Order specification gate never fired (M1).** The spec is now copied from the Sales Order Item, walking back through the Production Plan for sub-assembly orders. Release blockers are re-derived on submit, not read from a stored select. - **Tooling never enforced (M2).** Tooling readiness is derived from the new cylinder register and blocks release. - **Dispatch Gate too loose (M3).** Controlled lines need a batch, and each batch needs its own released final/outgoing inspection. "Reserved" mode needs stock reservation switched on. - **Returns** read a field Delivery Note Item doesn't have. **Partial credit notes** were wrongly blocked (m5). **Billing recompute** loaded every invoice (m6). **Supply Close** used an item-code proxy; it now follows SO → Production Plan → MR → PO. ## New capability - **Print Cylinder** DocType: a register of each cylinder or plate (spec, colour station, dimensions, ownership, location, condition, impressions). - **Roll details on Batch:** stage, width, length, micron, net and gross kg, supplier lot, machine, Work Order. - **Job Card output and waste:** rolls, metres, kg, set-up and running waste with a required reason, and a derived waste %. - **Quotation cost estimate:** material (with expected waste) + BOM operating cost + set-up + cylinder charge, shown with the margin against the quoted rate. - **Reports:** Roll Genealogy (backward and forward traceability) and Work Order Cost Variance (planned vs actual). - **Role profiles** for the 10 PRD roles, new Machine Operator and Prepress roles, and quality decisions locked to QA (permlevel 1). - **Form layout:** about 120 custom fields move from the bottom of each form into a "Makap" tab with labelled sections (m1). - **`setup_uganda.run`**: a dry-run-first script for a UGX company, VAT 18% templates, stage WIP, Quarantine and Returns Hold warehouses, and manufacturing settings. It never deletes; the Kenya company stays until someone removes it by hand. ## Rollout 1. Merge into `develop` and deploy to a **staging** site first. 2. Run `bench migrate`, then `bench --site <site> run-tests --app makap_backend`. 3. Run `setup_uganda.run` as a dry run, review the plan, then run it with `confirm=1`. 4. Check the forms (Work Order, QI, Delivery Note, Job Card, Batch) on a tablet. ## Testing - `test_gates.py` (11 cases, database reads mocked) passes locally against Frappe v15 source. - `test_print_cylinder.py` needs a test site with ERPNext. **Not run yet**, because there was no bench to run it on. - `setup_uganda.py`, the two reports and the migrate-time field moves are **not yet run** against a database. Staging is the first real check. ## Decisions Makap still owns Roll identity (one batch per roll), cylinder ownership, consumption costing method, company name and fiscal year, and the EFRIS route. The current defaults are listed in the README.
denis_ireri added 8 commits 2026-10-09 07:46:41 +00:00
- Work Order: copy the Packaging Specification from the Sales Order Item
  (walking back through the Production Plan for sub-assembly orders), and
  re-derive release blockers on submit instead of trusting a stored status.
  Tooling readiness is now derived and enforced (B6/M1/M2).
- Whitelisted operations no longer save with ignore_permissions: callers
  need the right role and write permission on the document (B6).
- Dispatch Gate matches final/outgoing inspections by exact batch and needs
  a batch on every controlled line; Reserved mode needs stock reservation (M3).
- Returns check read a field Delivery Note Item doesn't have.
- Drop the credit-note rule that blocked legitimate partial credits; ERPNext
  already caps cumulative returned qty (m5).
- Billing recompute and Supply Close query only this order's documents (m6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tooling was free text on the specification and a manual select on the Work
Order. The register records each cylinder/plate with its specification,
colour station, dimensions, ownership, location, condition and impressions.
Work Order release now reads it: a job needing print tooling is blocked until
every registered cylinder for its specification is Ready.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Batch gets roll details (stage, width, length, micron, net/gross kg,
  supplier lot, machine, Work Order) so each roll is a traceable batch (B3).
- Job Card gets operator output and waste capture on its first tab, with a
  derived waste % and a required reason whenever waste is entered.
- Quotation Item can cost a line from an estimating BOM: material grossed up
  for expected waste, BOM operating cost, set-up and cylinder charge, with
  the resulting margin shown against the quoted rate (M4).
- About 120 fields used to stack after amended_from with no sections. They
  now sit in a "Makap" tab per form (a section on child rows) with labelled
  sub-sections, and positions are updated on migrate (m1).
- Tooling Readiness is read-only: it is derived from the cylinder register.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Roll Genealogy traces a batch backward (what went into it) or forward
  (where it was used) through submitted Manufacture entries, showing roll
  dimensions and the latest inspection disposition at each step (B3).
- Work Order Cost Variance compares BOM-planned material, operating cost and
  scrap with actual consumption and Job Card time, plus recorded waste kg (M5).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Ten "Makap - ..." role profiles map the PRD Section 3 roles (sales,
  prepress, planner, procurement, warehouse, operator, supervisor, QC/QA,
  finance, management) onto standard and Makap roles. Created only if
  missing, so desk edits survive migrate (M6).
- New Machine Operator and Prepress roles. Operators can run Job Cards,
  label rolls and raise in-process inspections, but cannot plan or release.
- Quality eligibility, disposition and concession fields move to permlevel 1:
  only Quality Manager / Concession Authority can set them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The live company was created as Kenya/KES. setup_uganda.run creates a UGX
company on the Standard chart with a July-June fiscal year, VAT Output/Input
accounts with 18% sales and purchase templates, stage WIP, Quarantine,
Returns Hold and Rejected warehouses, and sets Manufacturing Settings to
backflush on transferred material with enforced time logs (B1, M7, M8).

It only creates, never deletes, and does nothing without confirm=1. It is
deliberately not an after_migrate hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_gates.py patches database reads, so each rule is tested on its own
(11 cases: dispatch by batch, reservation mode, waste capture, quotation
cost build-up, specification lookup through the Production Plan, release
blockers). test_print_cylinder.py uses real records for cylinder readiness
and checks that operators can't call the readiness or disposition endpoints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
denis_ireri requested review from JosephNjuki 2026-10-09 07:46:41 +00:00
denis_ireri removed review request for JosephNjuki 2026-10-10 10:01:11 +00:00
denis_ireri requested review from JosephNjuki 2026-10-10 10:01:53 +00:00
denis_ireri marked the pull request as ready for review 2026-10-10 10:02:06 +00:00
denis_ireri merged commit 7fb0fa378a into develop 2026-10-10 10:02:47 +00:00
denis_ireri deleted branch feat/review-backlog-fixes 2026-10-10 10:03:01 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JosephNjuki/Makap#1