@tailor-platform/erp-kit 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cli.mjs +103 -23
  3. package/package.json +1 -1
  4. package/skills/erp-kit-app-5-impl-backend/SKILL.md +7 -4
  5. package/skills/erp-kit-app-7-impl-review/SKILL.md +1 -1
  6. package/skills/erp-kit-module-6-impl-review/SKILL.md +39 -17
  7. package/src/commands/generate-doc.ts +1 -1
  8. package/src/commands/lib/discovery.test.ts +13 -3
  9. package/src/commands/lib/discovery.ts +10 -2
  10. package/src/commands/lib/paths.ts +4 -2
  11. package/src/commands/lib/sync-check-tests.test.ts +84 -6
  12. package/src/commands/lib/sync-check-tests.ts +63 -3
  13. package/src/commands/sync-check.ts +7 -3
  14. package/src/generator/generate-app-code.ts +51 -16
  15. package/src/generator/generate-stubs.ts +4 -0
  16. package/src/generator/stub-templates.test.ts +11 -0
  17. package/src/generator/stub-templates.ts +22 -1
  18. package/src/modules/inventory/docs/features/inventory-adjustment.md +2 -1
  19. package/src/modules/inventory/docs/features/scrap-management.md +39 -1
  20. package/src/modules/manufacturing/README.md +63 -0
  21. package/src/modules/manufacturing/command/.gitkeep +0 -0
  22. package/src/modules/manufacturing/command/activateBillOfMaterial.generated.ts +6 -0
  23. package/src/modules/manufacturing/command/activateBillOfMaterial.test.ts +166 -0
  24. package/src/modules/manufacturing/command/activateBillOfMaterial.ts +173 -0
  25. package/src/modules/manufacturing/command/activateRouting.generated.ts +6 -0
  26. package/src/modules/manufacturing/command/activateRouting.test.ts +152 -0
  27. package/src/modules/manufacturing/command/activateRouting.ts +92 -0
  28. package/src/modules/manufacturing/command/activateWorkCenter.generated.ts +6 -0
  29. package/src/modules/manufacturing/command/activateWorkCenter.test.ts +135 -0
  30. package/src/modules/manufacturing/command/activateWorkCenter.ts +91 -0
  31. package/src/modules/manufacturing/command/cancelProductionOrder.generated.ts +6 -0
  32. package/src/modules/manufacturing/command/cancelProductionOrder.test.ts +151 -0
  33. package/src/modules/manufacturing/command/cancelProductionOrder.ts +114 -0
  34. package/src/modules/manufacturing/command/closeProductionOrder.generated.ts +6 -0
  35. package/src/modules/manufacturing/command/closeProductionOrder.test.ts +126 -0
  36. package/src/modules/manufacturing/command/closeProductionOrder.ts +87 -0
  37. package/src/modules/manufacturing/command/completeProductionOrder.generated.ts +6 -0
  38. package/src/modules/manufacturing/command/completeProductionOrder.test.ts +132 -0
  39. package/src/modules/manufacturing/command/completeProductionOrder.ts +97 -0
  40. package/src/modules/manufacturing/command/completeWorkOrder.generated.ts +6 -0
  41. package/src/modules/manufacturing/command/completeWorkOrder.test.ts +369 -0
  42. package/src/modules/manufacturing/command/completeWorkOrder.ts +212 -0
  43. package/src/modules/manufacturing/command/createBillOfMaterial.generated.ts +6 -0
  44. package/src/modules/manufacturing/command/createBillOfMaterial.test.ts +210 -0
  45. package/src/modules/manufacturing/command/createBillOfMaterial.ts +176 -0
  46. package/src/modules/manufacturing/command/createProductionOrder.generated.ts +6 -0
  47. package/src/modules/manufacturing/command/createProductionOrder.test.ts +160 -0
  48. package/src/modules/manufacturing/command/createProductionOrder.ts +129 -0
  49. package/src/modules/manufacturing/command/createRouting.generated.ts +6 -0
  50. package/src/modules/manufacturing/command/createRouting.test.ts +168 -0
  51. package/src/modules/manufacturing/command/createRouting.ts +128 -0
  52. package/src/modules/manufacturing/command/createWorkCenter.generated.ts +6 -0
  53. package/src/modules/manufacturing/command/createWorkCenter.test.ts +148 -0
  54. package/src/modules/manufacturing/command/createWorkCenter.ts +131 -0
  55. package/src/modules/manufacturing/command/deactivateBillOfMaterial.generated.ts +6 -0
  56. package/src/modules/manufacturing/command/deactivateBillOfMaterial.test.ts +103 -0
  57. package/src/modules/manufacturing/command/deactivateBillOfMaterial.ts +78 -0
  58. package/src/modules/manufacturing/command/deactivateRouting.generated.ts +6 -0
  59. package/src/modules/manufacturing/command/deactivateRouting.test.ts +112 -0
  60. package/src/modules/manufacturing/command/deactivateRouting.ts +76 -0
  61. package/src/modules/manufacturing/command/deactivateWorkCenter.generated.ts +6 -0
  62. package/src/modules/manufacturing/command/deactivateWorkCenter.test.ts +113 -0
  63. package/src/modules/manufacturing/command/deactivateWorkCenter.ts +85 -0
  64. package/src/modules/manufacturing/command/pauseWorkOrder.generated.ts +6 -0
  65. package/src/modules/manufacturing/command/pauseWorkOrder.test.ts +118 -0
  66. package/src/modules/manufacturing/command/pauseWorkOrder.ts +82 -0
  67. package/src/modules/manufacturing/command/recordInventoryIssueOutcome.generated.ts +6 -0
  68. package/src/modules/manufacturing/command/recordInventoryIssueOutcome.test.ts +183 -0
  69. package/src/modules/manufacturing/command/recordInventoryIssueOutcome.ts +139 -0
  70. package/src/modules/manufacturing/command/recordManufacturingCostSettlementAcknowledgment.generated.ts +6 -0
  71. package/src/modules/manufacturing/command/recordManufacturingCostSettlementAcknowledgment.test.ts +120 -0
  72. package/src/modules/manufacturing/command/recordManufacturingCostSettlementAcknowledgment.ts +110 -0
  73. package/src/modules/manufacturing/command/releaseProductionOrder.generated.ts +6 -0
  74. package/src/modules/manufacturing/command/releaseProductionOrder.test.ts +220 -0
  75. package/src/modules/manufacturing/command/releaseProductionOrder.ts +450 -0
  76. package/src/modules/manufacturing/command/reopenProductionOrder.generated.ts +6 -0
  77. package/src/modules/manufacturing/command/reopenProductionOrder.test.ts +196 -0
  78. package/src/modules/manufacturing/command/reopenProductionOrder.ts +98 -0
  79. package/src/modules/manufacturing/command/reportWorkOrderProgress.generated.ts +6 -0
  80. package/src/modules/manufacturing/command/reportWorkOrderProgress.test.ts +204 -0
  81. package/src/modules/manufacturing/command/reportWorkOrderProgress.ts +129 -0
  82. package/src/modules/manufacturing/command/rescheduleProductionOrder.generated.ts +6 -0
  83. package/src/modules/manufacturing/command/rescheduleProductionOrder.test.ts +185 -0
  84. package/src/modules/manufacturing/command/rescheduleProductionOrder.ts +95 -0
  85. package/src/modules/manufacturing/command/resumeWorkOrder.generated.ts +6 -0
  86. package/src/modules/manufacturing/command/resumeWorkOrder.test.ts +122 -0
  87. package/src/modules/manufacturing/command/resumeWorkOrder.ts +94 -0
  88. package/src/modules/manufacturing/command/reviewManufacturingCostSummary.generated.ts +6 -0
  89. package/src/modules/manufacturing/command/reviewManufacturingCostSummary.test.ts +231 -0
  90. package/src/modules/manufacturing/command/reviewManufacturingCostSummary.ts +137 -0
  91. package/src/modules/manufacturing/command/startWorkOrder.generated.ts +6 -0
  92. package/src/modules/manufacturing/command/startWorkOrder.test.ts +118 -0
  93. package/src/modules/manufacturing/command/startWorkOrder.ts +126 -0
  94. package/src/modules/manufacturing/command/technicallyCompleteProductionOrder.generated.ts +6 -0
  95. package/src/modules/manufacturing/command/technicallyCompleteProductionOrder.test.ts +153 -0
  96. package/src/modules/manufacturing/command/technicallyCompleteProductionOrder.ts +106 -0
  97. package/src/modules/manufacturing/command/unreleaseProductionOrder.generated.ts +6 -0
  98. package/src/modules/manufacturing/command/unreleaseProductionOrder.test.ts +140 -0
  99. package/src/modules/manufacturing/command/unreleaseProductionOrder.ts +131 -0
  100. package/src/modules/manufacturing/command/updateBillOfMaterial.generated.ts +6 -0
  101. package/src/modules/manufacturing/command/updateBillOfMaterial.test.ts +149 -0
  102. package/src/modules/manufacturing/command/updateBillOfMaterial.ts +174 -0
  103. package/src/modules/manufacturing/command/updateProductionOrder.generated.ts +6 -0
  104. package/src/modules/manufacturing/command/updateProductionOrder.test.ts +112 -0
  105. package/src/modules/manufacturing/command/updateProductionOrder.ts +145 -0
  106. package/src/modules/manufacturing/command/updateRouting.generated.ts +6 -0
  107. package/src/modules/manufacturing/command/updateRouting.test.ts +211 -0
  108. package/src/modules/manufacturing/command/updateRouting.ts +124 -0
  109. package/src/modules/manufacturing/command/updateWorkCenter.generated.ts +6 -0
  110. package/src/modules/manufacturing/command/updateWorkCenter.test.ts +152 -0
  111. package/src/modules/manufacturing/command/updateWorkCenter.ts +137 -0
  112. package/src/modules/manufacturing/db/.gitkeep +0 -0
  113. package/src/modules/manufacturing/db/billOfMaterial.ts +70 -0
  114. package/src/modules/manufacturing/db/billOfMaterialLine.ts +49 -0
  115. package/src/modules/manufacturing/db/costVarianceLine.ts +53 -0
  116. package/src/modules/manufacturing/db/manufacturingCostLine.ts +35 -0
  117. package/src/modules/manufacturing/db/manufacturingCostSettlementRecord.ts +39 -0
  118. package/src/modules/manufacturing/db/manufacturingCostSummary.ts +59 -0
  119. package/src/modules/manufacturing/db/productionOrder.ts +83 -0
  120. package/src/modules/manufacturing/db/productionOrderBomSnapshot.ts +44 -0
  121. package/src/modules/manufacturing/db/productionOrderCostBaseline.ts +44 -0
  122. package/src/modules/manufacturing/db/productionOrderMaterialRequirement.ts +57 -0
  123. package/src/modules/manufacturing/db/productionOrderRoutingSnapshot.ts +43 -0
  124. package/src/modules/manufacturing/db/routing.ts +63 -0
  125. package/src/modules/manufacturing/db/routingOperation.ts +57 -0
  126. package/src/modules/manufacturing/db/workCenter.ts +87 -0
  127. package/src/modules/manufacturing/db/workOrder.ts +65 -0
  128. package/src/modules/manufacturing/db/workOrderExecutionEvent.ts +54 -0
  129. package/src/modules/manufacturing/docs/commands/ActivateBillOfMaterial.md +50 -0
  130. package/src/modules/manufacturing/docs/commands/ActivateRouting.md +48 -0
  131. package/src/modules/manufacturing/docs/commands/ActivateWorkCenter.md +49 -0
  132. package/src/modules/manufacturing/docs/commands/CancelProductionOrder.md +48 -0
  133. package/src/modules/manufacturing/docs/commands/CloseProductionOrder.md +46 -0
  134. package/src/modules/manufacturing/docs/commands/CompleteProductionOrder.md +48 -0
  135. package/src/modules/manufacturing/docs/commands/CompleteWorkOrder.md +66 -0
  136. package/src/modules/manufacturing/docs/commands/CreateBillOfMaterial.md +54 -0
  137. package/src/modules/manufacturing/docs/commands/CreateProductionOrder.md +49 -0
  138. package/src/modules/manufacturing/docs/commands/CreateRouting.md +50 -0
  139. package/src/modules/manufacturing/docs/commands/CreateWorkCenter.md +51 -0
  140. package/src/modules/manufacturing/docs/commands/DeactivateBillOfMaterial.md +45 -0
  141. package/src/modules/manufacturing/docs/commands/DeactivateRouting.md +45 -0
  142. package/src/modules/manufacturing/docs/commands/DeactivateWorkCenter.md +45 -0
  143. package/src/modules/manufacturing/docs/commands/PauseWorkOrder.md +44 -0
  144. package/src/modules/manufacturing/docs/commands/RecordInventoryIssueOutcome.md +59 -0
  145. package/src/modules/manufacturing/docs/commands/RecordManufacturingCostSettlementAcknowledgment.md +49 -0
  146. package/src/modules/manufacturing/docs/commands/ReleaseProductionOrder.md +57 -0
  147. package/src/modules/manufacturing/docs/commands/ReopenProductionOrder.md +54 -0
  148. package/src/modules/manufacturing/docs/commands/ReportWorkOrderProgress.md +53 -0
  149. package/src/modules/manufacturing/docs/commands/RescheduleProductionOrder.md +45 -0
  150. package/src/modules/manufacturing/docs/commands/ResumeWorkOrder.md +44 -0
  151. package/src/modules/manufacturing/docs/commands/ReviewManufacturingCostSummary.md +52 -0
  152. package/src/modules/manufacturing/docs/commands/StartWorkOrder.md +46 -0
  153. package/src/modules/manufacturing/docs/commands/TechnicallyCompleteProductionOrder.md +51 -0
  154. package/src/modules/manufacturing/docs/commands/UnreleaseProductionOrder.md +46 -0
  155. package/src/modules/manufacturing/docs/commands/UpdateBillOfMaterial.md +48 -0
  156. package/src/modules/manufacturing/docs/commands/UpdateProductionOrder.md +48 -0
  157. package/src/modules/manufacturing/docs/commands/UpdateRouting.md +52 -0
  158. package/src/modules/manufacturing/docs/commands/UpdateWorkCenter.md +48 -0
  159. package/src/modules/manufacturing/docs/features/bill-of-material-management.md +83 -0
  160. package/src/modules/manufacturing/docs/features/manufacturing-cost-and-variance.md +191 -0
  161. package/src/modules/manufacturing/docs/features/production-order-lifecycle.md +103 -0
  162. package/src/modules/manufacturing/docs/features/routing-and-work-center-definition.md +63 -0
  163. package/src/modules/manufacturing/docs/features/work-order-execution.md +115 -0
  164. package/src/modules/manufacturing/docs/models/BillOfMaterial.md +60 -0
  165. package/src/modules/manufacturing/docs/models/ManufacturingCostSummary.md +66 -0
  166. package/src/modules/manufacturing/docs/models/ProductionOrder.md +76 -0
  167. package/src/modules/manufacturing/docs/models/Routing.md +58 -0
  168. package/src/modules/manufacturing/docs/models/WorkCenter.md +56 -0
  169. package/src/modules/manufacturing/docs/models/WorkOrder.md +63 -0
  170. package/src/modules/manufacturing/docs/queries/DetectBillOfMaterialCircularReference.md +39 -0
  171. package/src/modules/manufacturing/docs/queries/ExplodeBillOfMaterial.md +56 -0
  172. package/src/modules/manufacturing/docs/queries/GetBillOfMaterial.md +37 -0
  173. package/src/modules/manufacturing/docs/queries/GetManufacturingCostSummary.md +39 -0
  174. package/src/modules/manufacturing/docs/queries/GetProductionOrder.md +37 -0
  175. package/src/modules/manufacturing/docs/queries/GetRouting.md +39 -0
  176. package/src/modules/manufacturing/docs/queries/GetWorkCenter.md +35 -0
  177. package/src/modules/manufacturing/docs/queries/GetWorkOrder.md +38 -0
  178. package/src/modules/manufacturing/docs/queries/ListBillOfMaterialsByItem.md +42 -0
  179. package/src/modules/manufacturing/docs/queries/ListManufacturingCostSummariesByStatus.md +41 -0
  180. package/src/modules/manufacturing/docs/queries/ListProductionOrdersByStatus.md +41 -0
  181. package/src/modules/manufacturing/docs/queries/ListRoutingsByItem.md +42 -0
  182. package/src/modules/manufacturing/docs/queries/ListWorkCentersBySite.md +38 -0
  183. package/src/modules/manufacturing/docs/queries/ListWorkOrdersByProductionOrder.md +39 -0
  184. package/src/modules/manufacturing/docs/queries/ListWorkOrdersByWorkCenter.md +43 -0
  185. package/src/modules/manufacturing/executor/.gitkeep +0 -0
  186. package/src/modules/manufacturing/generated/enums.ts +113 -0
  187. package/src/modules/manufacturing/generated/kysely-tailordb.ts +247 -0
  188. package/src/modules/manufacturing/index.ts +2 -0
  189. package/src/modules/manufacturing/lib/_db_deps.ts +22 -0
  190. package/src/modules/manufacturing/lib/errors.generated.ts +592 -0
  191. package/src/modules/manufacturing/lib/permissions.generated.ts +35 -0
  192. package/src/modules/manufacturing/lib/types.ts +111 -0
  193. package/src/modules/manufacturing/module.ts +226 -0
  194. package/src/modules/manufacturing/permissions.ts +3 -0
  195. package/src/modules/manufacturing/query/.gitkeep +0 -0
  196. package/src/modules/manufacturing/query/detectBillOfMaterialCircularReference.generated.ts +5 -0
  197. package/src/modules/manufacturing/query/detectBillOfMaterialCircularReference.test.ts +115 -0
  198. package/src/modules/manufacturing/query/detectBillOfMaterialCircularReference.ts +79 -0
  199. package/src/modules/manufacturing/query/explodeBillOfMaterial.generated.ts +5 -0
  200. package/src/modules/manufacturing/query/explodeBillOfMaterial.test.ts +445 -0
  201. package/src/modules/manufacturing/query/explodeBillOfMaterial.ts +306 -0
  202. package/src/modules/manufacturing/query/getBillOfMaterial.generated.ts +5 -0
  203. package/src/modules/manufacturing/query/getBillOfMaterial.test.ts +64 -0
  204. package/src/modules/manufacturing/query/getBillOfMaterial.ts +27 -0
  205. package/src/modules/manufacturing/query/getManufacturingCostSummary.generated.ts +5 -0
  206. package/src/modules/manufacturing/query/getManufacturingCostSummary.test.ts +147 -0
  207. package/src/modules/manufacturing/query/getManufacturingCostSummary.ts +46 -0
  208. package/src/modules/manufacturing/query/getProductionOrder.generated.ts +5 -0
  209. package/src/modules/manufacturing/query/getProductionOrder.test.ts +139 -0
  210. package/src/modules/manufacturing/query/getProductionOrder.ts +84 -0
  211. package/src/modules/manufacturing/query/getRouting.generated.ts +5 -0
  212. package/src/modules/manufacturing/query/getRouting.test.ts +71 -0
  213. package/src/modules/manufacturing/query/getRouting.ts +34 -0
  214. package/src/modules/manufacturing/query/getWorkCenter.generated.ts +5 -0
  215. package/src/modules/manufacturing/query/getWorkCenter.test.ts +37 -0
  216. package/src/modules/manufacturing/query/getWorkCenter.ts +21 -0
  217. package/src/modules/manufacturing/query/getWorkOrder.generated.ts +5 -0
  218. package/src/modules/manufacturing/query/getWorkOrder.test.ts +73 -0
  219. package/src/modules/manufacturing/query/getWorkOrder.ts +28 -0
  220. package/src/modules/manufacturing/query/listBillOfMaterialsByItem.generated.ts +5 -0
  221. package/src/modules/manufacturing/query/listBillOfMaterialsByItem.test.ts +107 -0
  222. package/src/modules/manufacturing/query/listBillOfMaterialsByItem.ts +58 -0
  223. package/src/modules/manufacturing/query/listManufacturingCostSummariesByStatus.generated.ts +5 -0
  224. package/src/modules/manufacturing/query/listManufacturingCostSummariesByStatus.test.ts +96 -0
  225. package/src/modules/manufacturing/query/listManufacturingCostSummariesByStatus.ts +77 -0
  226. package/src/modules/manufacturing/query/listProductionOrdersByStatus.generated.ts +5 -0
  227. package/src/modules/manufacturing/query/listProductionOrdersByStatus.test.ts +121 -0
  228. package/src/modules/manufacturing/query/listProductionOrdersByStatus.ts +83 -0
  229. package/src/modules/manufacturing/query/listRoutingsByItem.generated.ts +5 -0
  230. package/src/modules/manufacturing/query/listRoutingsByItem.test.ts +110 -0
  231. package/src/modules/manufacturing/query/listRoutingsByItem.ts +54 -0
  232. package/src/modules/manufacturing/query/listWorkCentersBySite.generated.ts +5 -0
  233. package/src/modules/manufacturing/query/listWorkCentersBySite.test.ts +81 -0
  234. package/src/modules/manufacturing/query/listWorkCentersBySite.ts +70 -0
  235. package/src/modules/manufacturing/query/listWorkOrdersByProductionOrder.generated.ts +5 -0
  236. package/src/modules/manufacturing/query/listWorkOrdersByProductionOrder.test.ts +102 -0
  237. package/src/modules/manufacturing/query/listWorkOrdersByProductionOrder.ts +53 -0
  238. package/src/modules/manufacturing/query/listWorkOrdersByWorkCenter.generated.ts +5 -0
  239. package/src/modules/manufacturing/query/listWorkOrdersByWorkCenter.test.ts +143 -0
  240. package/src/modules/manufacturing/query/listWorkOrdersByWorkCenter.ts +56 -0
  241. package/src/modules/manufacturing/seed/index.ts +19 -0
  242. package/src/modules/manufacturing/tailor.config.ts +13 -0
  243. package/src/modules/manufacturing/tailor.d.ts +13 -0
  244. package/src/modules/manufacturing/testing/commandTestUtils.ts +29 -0
  245. package/src/modules/manufacturing/testing/fixtures.ts +402 -0
  246. package/templates/scaffold/app/backend/package.json +9 -2
  247. package/templates/scaffold/app/backend/src/tests/utils/graphql-client.ts +66 -0
  248. package/templates/scaffold/app/backend/src/tests/utils/setup.ts +21 -0
  249. package/templates/scaffold/app/backend/tsconfig.json +9 -2
  250. package/templates/scaffold/app/backend/vitest.config.ts +35 -0
  251. package/templates/scaffold/app/frontend/package.json +2 -2
@@ -0,0 +1,45 @@
1
+ # DeactivateWorkCenter
2
+
3
+ ## Overview
4
+
5
+ DeactivateWorkCenter removes a work center from future routing and release selection. The command preserves historical work-order and cost records while blocking new execution use.
6
+
7
+ ## Business Rules
8
+
9
+ - Target work center must exist.
10
+ - Only `ACTIVE` work centers can be deactivated.
11
+ - Deactivation may be blocked when future active routings or open released work still require the work center.
12
+ - Historical work orders and cost baselines remain intact after deactivation.
13
+
14
+ ## Process Flow
15
+
16
+ ```mermaid
17
+ flowchart TD
18
+ A[Receive deactivate request] --> B{Work center exists?}
19
+ B -->|No| C[Return WORK_CENTER_NOT_FOUND]
20
+ B -->|Yes| D{Status is ACTIVE?}
21
+ D -->|No| E[Return WORK_CENTER_NOT_DEACTIVATABLE]
22
+ D -->|Yes| F{Open dependency check passes?}
23
+ F -->|No| G[Return WORK_CENTER_IN_USE]
24
+ F -->|Yes| H[Set status to INACTIVE]
25
+ H --> I[Return inactive work center]
26
+ ```
27
+
28
+ ## External Dependencies
29
+
30
+ - [Routing](../models/Routing.md) - Future active routings may block deactivation.
31
+
32
+ ## Error Scenarios
33
+
34
+ - **WORK_CENTER_NOT_FOUND**: Target work center does not exist.
35
+ - **WORK_CENTER_NOT_DEACTIVATABLE**: The work center is not in `ACTIVE`.
36
+ - **WORK_CENTER_IN_USE**: Future routings or open released work still require the work center.
37
+
38
+ ## Test Cases
39
+
40
+ - deactivates an active work center with no blocking dependencies
41
+ - returns error when the work center does not exist
42
+ - returns error when the work center is not active
43
+ - returns error when open routing or released-work dependencies block deactivation
44
+ - returns error when open work orders block deactivation
45
+ - preserves historical work-order and cost data after deactivation
@@ -0,0 +1,44 @@
1
+ # PauseWorkOrder
2
+
3
+ ## Overview
4
+
5
+ PauseWorkOrder temporarily halts an in-progress operation and records the reason for the interruption. The command preserves accumulated execution history so the work order can later resume.
6
+
7
+ ## Business Rules
8
+
9
+ - Target work order must exist.
10
+ - Work order must be in `IN_PROGRESS`.
11
+ - Pause reason is required.
12
+ - Pausing preserves previously reported quantity, scrap, and time.
13
+
14
+ ## Process Flow
15
+
16
+ ```mermaid
17
+ flowchart TD
18
+ A[Receive pause request] --> B{Work order exists?}
19
+ B -->|No| C[Return WORK_ORDER_NOT_FOUND]
20
+ B -->|Yes| D{Status is IN_PROGRESS?}
21
+ D -->|No| E[Return WORK_ORDER_NOT_PAUSABLE]
22
+ D -->|Yes| F{Pause reason provided?}
23
+ F -->|No| G[Return PAUSE_REASON_REQUIRED]
24
+ F -->|Yes| H[Record pause event and set PAUSED]
25
+ H --> I[Return paused work order]
26
+ ```
27
+
28
+ ## External Dependencies
29
+
30
+ - None
31
+
32
+ ## Error Scenarios
33
+
34
+ - **WORK_ORDER_NOT_FOUND**: Target work order does not exist.
35
+ - **WORK_ORDER_NOT_PAUSABLE**: Work order is not in `IN_PROGRESS`.
36
+ - **PAUSE_REASON_REQUIRED**: No pause reason was provided.
37
+
38
+ ## Test Cases
39
+
40
+ - pauses an in-progress work order
41
+ - returns error when the work order does not exist
42
+ - returns error when the work order is not in progress
43
+ - returns error when no pause reason is provided
44
+ - preserves prior execution quantities and time after pause
@@ -0,0 +1,59 @@
1
+ # RecordInventoryIssueOutcome
2
+
3
+ ## Overview
4
+
5
+ RecordInventoryIssueOutcome applies one inventory-owned valuation outcome to the manufacturing cost summary for a production order. It is the only valid path for actual material cost to enter manufacturing.
6
+
7
+ ## Business Rules
8
+
9
+ - Referenced production order and cost summary must exist.
10
+ - Cost summary must be in `COLLECTING`.
11
+ - Inventory outcome payload must include `productionOrderReference`, `inventoryIssueReference`, `itemReference`, `issuedQuantity`, `unitOfMeasure`, `actualUnitCost`, `actualExtendedCost`, `currency`, `valuationMethod`, `postingDate`, and `siteReference`.
12
+ - Inventory issue outcome must already be final-valued by inventory.
13
+ - The event must not be double-applied to the same summary.
14
+ - Actual material cost is recorded using the payload values rather than manufacturing-side recalculation.
15
+
16
+ ## Process Flow
17
+
18
+ ```mermaid
19
+ flowchart TD
20
+ A[Receive inventory issue outcome] --> B[Resolve production order and cost summary]
21
+ B --> C[Validate required payload fields]
22
+ C --> D{Summary collecting?}
23
+ D -->|No| E[Return COST_SUMMARY_NOT_COLLECTING]
24
+ D -->|Yes| F{Inventory valuation final?}
25
+ F -->|No| G[Return ISSUE_OUTCOME_NOT_FINAL]
26
+ F -->|Yes| H{Already applied?}
27
+ H -->|Yes| I[Return DUPLICATE_ISSUE_OUTCOME]
28
+ H -->|No| J[Apply actual material cost to summary]
29
+ J --> K[Return updated summary]
30
+ ```
31
+
32
+ ## External Dependencies
33
+
34
+ - [ManufacturingCostSummary](../models/ManufacturingCostSummary.md) - Actual material issue outcomes accumulate on the linked summary.
35
+
36
+ ## Error Scenarios
37
+
38
+ - **PRODUCTION_ORDER_NOT_FOUND**: Referenced production order does not exist.
39
+ - **COST_SUMMARY_NOT_FOUND**: Linked cost summary does not exist.
40
+ - **COST_SUMMARY_NOT_COLLECTING**: Summary is not in `COLLECTING`.
41
+ - **MISSING_INVENTORY_ISSUE_REFERENCE**: `inventoryIssueReference` was not provided in the outcome payload.
42
+ - **MISSING_ACTUAL_UNIT_COST**: `actualUnitCost` was not provided in the outcome payload.
43
+ - **MISSING_ACTUAL_EXTENDED_COST**: `actualExtendedCost` was not provided in the outcome payload.
44
+ - **MISSING_POSTING_DATE**: `postingDate` was not provided in the outcome payload.
45
+ - **ISSUE_OUTCOME_NOT_FINAL**: Inventory valuation is not yet final.
46
+ - **DUPLICATE_ISSUE_OUTCOME**: The same inventory issue outcome was already applied.
47
+
48
+ ## Test Cases
49
+
50
+ - applies a final-valued inventory issue outcome to a collecting summary
51
+ - returns error when the production order does not exist
52
+ - returns error when the linked cost summary does not exist
53
+ - returns error when the summary is not collecting
54
+ - returns error when `inventoryIssueReference` is missing from the outcome payload
55
+ - returns error when `actualUnitCost` is missing from the outcome payload
56
+ - returns error when `actualExtendedCost` is missing from the outcome payload
57
+ - returns error when `postingDate` is missing from the outcome payload
58
+ - returns error when the inventory issue outcome is not yet final
59
+ - returns error when the same issue outcome is applied twice
@@ -0,0 +1,49 @@
1
+ # RecordManufacturingCostSettlementAcknowledgment
2
+
3
+ ## Overview
4
+
5
+ RecordManufacturingCostSettlementAcknowledgment persists the downstream accounting acknowledgment that a reviewed manufacturing cost handoff has been consumed by settlement processing. It is the only path that moves a reviewed summary to `SETTLED`.
6
+
7
+ ## Business Rules
8
+
9
+ - Target cost summary must exist and be in `VARIANCE_REVIEWED`.
10
+ - Acknowledgment payload must match the reviewed summary's production order, summary reference, and settlement currency.
11
+ - Downstream accounting owns the acknowledgment payload; manufacturing may record it but must not fabricate it.
12
+ - An acknowledgment that is rejected, reversed, or superseded by downstream accounting must not settle the summary and requires a valid replacement acknowledgment before settlement can proceed.
13
+ - Successful recording sets the summary status to `SETTLED`.
14
+
15
+ ## Process Flow
16
+
17
+ ```mermaid
18
+ flowchart TD
19
+ A[Receive settlement acknowledgment] --> B{Summary exists and is reviewed?}
20
+ B -->|No| C[Return COST_SUMMARY_NOT_SETTLABLE]
21
+ B -->|Yes| D[Validate payload identity and currency]
22
+ D --> E{Payload valid?}
23
+ E -->|No| F[Return ACKNOWLEDGMENT_MISMATCH]
24
+ E -->|Yes| G{Downstream accepted and not superseded?}
25
+ G -->|No| H[Return ACKNOWLEDGMENT_REJECTED_OR_SUPERSEDED]
26
+ G -->|Yes| I[Persist acknowledgment and set SETTLED]
27
+ I --> J[Return settled summary]
28
+ ```
29
+
30
+ ## External Dependencies
31
+
32
+ - None
33
+
34
+ ## Error Scenarios
35
+
36
+ - **COST_SUMMARY_NOT_FOUND**: Target cost summary does not exist.
37
+ - **COST_SUMMARY_NOT_SETTLABLE**: Summary is not in `VARIANCE_REVIEWED`.
38
+ - **ACKNOWLEDGMENT_MISMATCH**: Order, summary reference, or currency does not match the reviewed handoff.
39
+ - **ACKNOWLEDGMENT_REJECTED_OR_SUPERSEDED**: Downstream accounting rejected, reversed, or superseded the reviewed handoff, so the summary must remain in `VARIANCE_REVIEWED`.
40
+ - **ACKNOWLEDGMENT_SOURCE_INVALID**: Payload was not produced by the downstream settlement process.
41
+
42
+ ## Test Cases
43
+
44
+ - records a valid downstream settlement acknowledgment and settles the summary
45
+ - returns error when the summary does not exist
46
+ - returns error when the summary is not variance reviewed
47
+ - returns error when the payload does not match the reviewed handoff
48
+ - returns error when downstream accounting rejects, reverses, or supersedes the reviewed handoff
49
+ - returns error when the acknowledgment source is invalid
@@ -0,0 +1,57 @@
1
+ # ReleaseProductionOrder
2
+
3
+ ## Overview
4
+
5
+ ReleaseProductionOrder turns a draft plan into executable work by resolving active BOM and routing content, freezing snapshots, creating work orders and material requirements, and opening manufacturing cost collection.
6
+
7
+ ## Business Rules
8
+
9
+ - Target order must exist and be in `DRAFT`.
10
+ - An active BOM and active routing must be explicitly selected or resolvable by default.
11
+ - BOM and routing must belong to the same company as the order, and any site-scoped master must match the order site exactly.
12
+ - Planned material unit cost for every required component must be resolved from inventory-owned valuation data at release time.
13
+ - Release snapshots BOM lines, routing operations, work-center rates, overhead policy, and planned material valuation.
14
+ - Release creates work orders, material requirements, and one manufacturing cost summary in `COLLECTING`.
15
+
16
+ ## Process Flow
17
+
18
+ ```mermaid
19
+ flowchart TD
20
+ A[Receive release request] --> B{Order exists and is DRAFT?}
21
+ B -->|No| C[Return PRODUCTION_ORDER_NOT_RELEASABLE]
22
+ B -->|Yes| D[Resolve active BOM and routing]
23
+ D --> E[Validate company and site scope of resolved masters]
24
+ E --> F[Query inventory valuation for planned material cost]
25
+ F --> G[Snapshot BOM, routing, and cost baseline]
26
+ G --> H[Create work orders and material requirements]
27
+ H --> I[Set order status to RELEASED]
28
+ I --> J[Return released order]
29
+ ```
30
+
31
+ ## External Dependencies
32
+
33
+ - [BillOfMaterial](../models/BillOfMaterial.md) - One active BOM version must be selected or resolved.
34
+ - [Routing](../models/Routing.md) - One active routing revision must be selected or resolved.
35
+ - [ManufacturingCostSummary](../models/ManufacturingCostSummary.md) - Release opens cost collection and freezes the baseline.
36
+
37
+ ## Error Scenarios
38
+
39
+ - **PRODUCTION_ORDER_NOT_FOUND**: Target order does not exist.
40
+ - **PRODUCTION_ORDER_NOT_RELEASABLE**: The order is not in `DRAFT`.
41
+ - **BOM_NOT_RESOLVED**: No valid active BOM could be selected for the order scope.
42
+ - **ROUTING_NOT_RESOLVED**: No valid active routing could be selected for the order scope.
43
+ - **CROSS_COMPANY_MASTER_REFERENCE**: Selected BOM or routing belongs to another company.
44
+ - **CROSS_SITE_MASTER_REFERENCE**: Selected BOM or routing belongs to another site than the production order, even if the company matches.
45
+ - **PLANNED_MATERIAL_COST_UNAVAILABLE**: Inventory could not resolve planned component cost for release.
46
+
47
+ ## Test Cases
48
+
49
+ - releases a draft order with valid BOM and routing snapshots
50
+ - returns error when the order does not exist
51
+ - returns error when the order is not in `DRAFT`
52
+ - returns error when no active BOM can be resolved
53
+ - returns error when no active routing can be resolved
54
+ - returns error when BOM or routing belongs to another company
55
+ - returns error when BOM or routing belongs to another site in the same company
56
+ - returns error when inventory valuation for a required component is unavailable
57
+ - creates work orders and a collecting cost summary at release
@@ -0,0 +1,54 @@
1
+ # ReopenProductionOrder
2
+
3
+ ## Overview
4
+
5
+ ReopenProductionOrder re-enables execution after a technically complete order needs more shop-floor work. It reverses the execution freeze and returns the linked cost summary to active collection.
6
+
7
+ ## Business Rules
8
+
9
+ - Target order must exist and be in `TECHNICALLY_COMPLETE`.
10
+ - A documented reopen reason is required.
11
+ - Reopening is not allowed after the order has been administratively closed.
12
+ - Reopening returns the linked manufacturing cost summary from either `PENDING_VARIANCE_REVIEW` or `VARIANCE_REVIEWED` back to `COLLECTING`.
13
+ - A linked summary already in `SETTLED` is not reopenable through this workflow.
14
+ - Once reopened, execution resumes under the existing released snapshots rather than creating a new release.
15
+
16
+ ## Process Flow
17
+
18
+ ```mermaid
19
+ flowchart TD
20
+ A[Receive reopen request] --> B{Order exists and is TECHNICALLY_COMPLETE?}
21
+ B -->|No| C[Return PRODUCTION_ORDER_NOT_REOPENABLE]
22
+ B -->|Yes| D{Reopen reason provided?}
23
+ D -->|No| E[Return REOPEN_REASON_REQUIRED]
24
+ D -->|Yes| F[Resolve linked cost summary state]
25
+ F --> G{Summary pending review or variance reviewed?}
26
+ G -->|No| H[Return COST_SUMMARY_NOT_REOPENABLE]
27
+ G -->|Yes| I[Return cost summary to COLLECTING]
28
+ I --> J[Set order status to IN_PROGRESS]
29
+ J --> K[Return reopened order]
30
+ ```
31
+
32
+ ## External Dependencies
33
+
34
+ - [ManufacturingCostSummary](../models/ManufacturingCostSummary.md) - Review state is reversed so additional execution can be costed.
35
+
36
+ ## Error Scenarios
37
+
38
+ - **PRODUCTION_ORDER_NOT_FOUND**: Target order does not exist.
39
+ - **PRODUCTION_ORDER_NOT_REOPENABLE**: The order is not in `TECHNICALLY_COMPLETE`.
40
+ - **REOPEN_REASON_REQUIRED**: No reopen reason was provided.
41
+ - **COST_SUMMARY_NOT_REOPENABLE**: The linked cost summary is not in `PENDING_VARIANCE_REVIEW` or `VARIANCE_REVIEWED`.
42
+ - **ORDER_ALREADY_CLOSED**: Administratively closed orders cannot be reopened through this workflow.
43
+
44
+ ## Test Cases
45
+
46
+ - reopens a technically complete order for additional execution
47
+ - returns error when the order does not exist
48
+ - returns error when the order is not technically complete
49
+ - returns error when no reopen reason is provided
50
+ - reopens an order when the linked cost summary is `PENDING_VARIANCE_REVIEW`
51
+ - reopens an order when the linked cost summary is `VARIANCE_REVIEWED`
52
+ - returns error when the linked cost summary is already `SETTLED` or otherwise not reopenable
53
+ - returns error when the order is already closed
54
+ - returns the linked cost summary to collecting on reopen
@@ -0,0 +1,53 @@
1
+ # ReportWorkOrderProgress
2
+
3
+ ## Overview
4
+
5
+ ReportWorkOrderProgress records partial execution evidence such as completed quantity, scrap quantity, actual time, and exception notes. It also emits any required manufacturing scrap handoff when the report contains scrapped quantity.
6
+
7
+ ## Business Rules
8
+
9
+ - Target work order must exist and be in `IN_PROGRESS`.
10
+ - Reported completed quantity and scrap quantity must be zero or greater.
11
+ - At least one of completed quantity, scrap quantity, or actual time must be positive.
12
+ - Scrap reporting emits `ManufacturingScrapHandoff` exactly once per submitted scrap transaction.
13
+ - Manufacturing-originated stock loss with a resolvable production or work-order reference must not bypass the manufacturing scrap handoff path.
14
+ - Progress reporting updates parent production-order rollup.
15
+
16
+ ## Process Flow
17
+
18
+ ```mermaid
19
+ flowchart TD
20
+ A[Receive progress report] --> B{Work order exists and is IN_PROGRESS?}
21
+ B -->|No| C[Return WORK_ORDER_NOT_REPORTABLE]
22
+ B -->|Yes| D[Validate quantities and time]
23
+ D --> E{Positive scrap reported?}
24
+ E -->|Yes| F[Emit ManufacturingScrapHandoff]
25
+ E -->|No| G[Skip scrap handoff]
26
+ F --> H[Persist execution event]
27
+ G --> H
28
+ H --> I[Roll up parent order progress]
29
+ I --> J[Return updated work order]
30
+ ```
31
+
32
+ ## External Dependencies
33
+
34
+ - [ProductionOrder](../models/ProductionOrder.md) - Progress rolls up into parent order execution state.
35
+
36
+ ## Error Scenarios
37
+
38
+ - **WORK_ORDER_NOT_FOUND**: Target work order does not exist.
39
+ - **WORK_ORDER_NOT_REPORTABLE**: Work order is not in `IN_PROGRESS`.
40
+ - **INVALID_REPORTED_QUANTITY**: Reported completed or scrap quantity is negative.
41
+ - **EMPTY_PROGRESS_TRANSACTION**: No positive quantity or time was reported.
42
+ - **SCRAP_HANDOFF_REQUIRED**: Positive scrap was reported but required scrap-handoff data is incomplete.
43
+
44
+ ## Test Cases
45
+
46
+ - records partial completed quantity and time on an in-progress work order
47
+ - returns error when the work order does not exist
48
+ - returns error when the work order is not in progress
49
+ - returns error when completed or scrap quantity is negative
50
+ - returns error when no positive quantity or time is provided
51
+ - emits manufacturing scrap handoff when positive scrap is reported
52
+ - returns error when positive scrap is reported without scrap handoff data
53
+ - rolls up execution progress to the parent order
@@ -0,0 +1,45 @@
1
+ # RescheduleProductionOrder
2
+
3
+ ## Overview
4
+
5
+ RescheduleProductionOrder changes the planned execution dates on a released order before execution starts. The command preserves the released snapshots and keeps the change auditable.
6
+
7
+ ## Business Rules
8
+
9
+ - Target order must exist and be in `RELEASED`.
10
+ - No work order may have started or received execution evidence.
11
+ - Revised planned dates must be chronologically valid.
12
+ - Rescheduling changes scheduling fields only; BOM, routing, and cost snapshots remain unchanged.
13
+
14
+ ## Process Flow
15
+
16
+ ```mermaid
17
+ flowchart TD
18
+ A[Receive reschedule request] --> B{Order exists and is RELEASED?}
19
+ B -->|No| C[Return PRODUCTION_ORDER_NOT_RESCHEDULABLE]
20
+ B -->|Yes| D{Execution already started?}
21
+ D -->|Yes| E[Return EXECUTION_ALREADY_STARTED]
22
+ D -->|No| F[Validate revised dates]
23
+ F --> G[Persist scheduling update]
24
+ G --> H[Return rescheduled order]
25
+ ```
26
+
27
+ ## External Dependencies
28
+
29
+ - None
30
+
31
+ ## Error Scenarios
32
+
33
+ - **PRODUCTION_ORDER_NOT_FOUND**: Target order does not exist.
34
+ - **PRODUCTION_ORDER_NOT_RESCHEDULABLE**: The order is not in `RELEASED`.
35
+ - **EXECUTION_ALREADY_STARTED**: Work-order execution has already begun.
36
+ - **INVALID_DATE_RANGE**: Planned dates are missing or chronologically invalid.
37
+
38
+ ## Test Cases
39
+
40
+ - reschedules a released order before execution starts
41
+ - returns error when the order does not exist
42
+ - returns error when the order is not in `RELEASED`
43
+ - returns error when execution has already started
44
+ - returns error when planned dates are invalid
45
+ - preserves release snapshots after rescheduling
@@ -0,0 +1,44 @@
1
+ # ResumeWorkOrder
2
+
3
+ ## Overview
4
+
5
+ ResumeWorkOrder restarts a paused operation without losing the accumulated execution history recorded before the interruption.
6
+
7
+ ## Business Rules
8
+
9
+ - Target work order must exist.
10
+ - Work order must be in `PAUSED`.
11
+ - Parent production order must still be execution-capable.
12
+ - Resuming preserves previously reported quantity, scrap, and time.
13
+
14
+ ## Process Flow
15
+
16
+ ```mermaid
17
+ flowchart TD
18
+ A[Receive resume request] --> B{Work order exists?}
19
+ B -->|No| C[Return WORK_ORDER_NOT_FOUND]
20
+ B -->|Yes| D{Status is PAUSED?}
21
+ D -->|No| E[Return WORK_ORDER_NOT_RESUMABLE]
22
+ D -->|Yes| F{Parent order executable?}
23
+ F -->|No| G[Return PARENT_ORDER_NOT_EXECUTABLE]
24
+ F -->|Yes| H[Record resume event and set IN_PROGRESS]
25
+ H --> I[Return resumed work order]
26
+ ```
27
+
28
+ ## External Dependencies
29
+
30
+ - [ProductionOrder](../models/ProductionOrder.md) - Parent production order must still allow execution.
31
+
32
+ ## Error Scenarios
33
+
34
+ - **WORK_ORDER_NOT_FOUND**: Target work order does not exist.
35
+ - **WORK_ORDER_NOT_RESUMABLE**: Work order is not in `PAUSED`.
36
+ - **PARENT_ORDER_NOT_EXECUTABLE**: Parent production order does not allow execution.
37
+
38
+ ## Test Cases
39
+
40
+ - resumes a paused work order
41
+ - returns error when the work order does not exist
42
+ - returns error when the work order is not paused
43
+ - returns error when the parent production order no longer allows execution
44
+ - preserves prior execution history after resume
@@ -0,0 +1,52 @@
1
+ # ReviewManufacturingCostSummary
2
+
3
+ ## Overview
4
+
5
+ ReviewManufacturingCostSummary recalculates the final planned-versus-actual result for a technically complete order and freezes the variance classification through an explicit reviewer approval step.
6
+
7
+ ## Business Rules
8
+
9
+ - Target cost summary must exist and be in `PENDING_VARIANCE_REVIEW`.
10
+ - Parent production order must already be `TECHNICALLY_COMPLETE`.
11
+ - Final variance must be recalculated against the frozen release baseline.
12
+ - Review must preserve the named variance taxonomy: `MATERIAL_PRICE`, `MATERIAL_USAGE`, `LABOR_RATE`, `LABOR_EFFICIENCY`, `MACHINE_RATE`, `MACHINE_EFFICIENCY`, `SCRAP`, and `YIELD`.
13
+ - Reviewer identity is required.
14
+ - Approved review freezes the variance breakdown until the order is reopened.
15
+
16
+ ## Process Flow
17
+
18
+ ```mermaid
19
+ flowchart TD
20
+ A[Receive review request] --> B{Summary exists and is pending review?}
21
+ B -->|No| C[Return COST_SUMMARY_NOT_REVIEWABLE]
22
+ B -->|Yes| D[Recalculate final variances across the named taxonomy]
23
+ D --> E{All required categories supported?}
24
+ E -->|No| F[Return INCOMPLETE_VARIANCE_BREAKDOWN]
25
+ E -->|Yes| G{Reviewer provided?}
26
+ G -->|No| H[Return REVIEWER_REQUIRED]
27
+ G -->|Yes| I[Freeze variance lines and set VARIANCE_REVIEWED]
28
+ I --> J[Return reviewed summary]
29
+ ```
30
+
31
+ ## External Dependencies
32
+
33
+ - [ProductionOrder](../models/ProductionOrder.md) - Parent order must already be technically complete before review.
34
+
35
+ ## Error Scenarios
36
+
37
+ - **COST_SUMMARY_NOT_FOUND**: Target cost summary does not exist.
38
+ - **COST_SUMMARY_NOT_REVIEWABLE**: Summary is not in `PENDING_VARIANCE_REVIEW`.
39
+ - **PARENT_ORDER_NOT_TECHNICALLY_COMPLETE**: Parent production order is not ready for review.
40
+ - **INCOMPLETE_VARIANCE_BREAKDOWN**: The review result cannot represent the full named variance taxonomy required by the feature.
41
+ - **REVIEWER_REQUIRED**: Reviewer identity was not provided.
42
+ - **VARIANCE_CALCULATION_FAILED**: Final variance could not be recalculated consistently.
43
+
44
+ ## Test Cases
45
+
46
+ - reviews a pending cost summary and freezes the variance breakdown
47
+ - returns error when the summary does not exist
48
+ - returns error when the summary is not pending review
49
+ - returns error when the parent order is not technically complete
50
+ - returns error when the review result cannot represent all required variance types
51
+ - returns error when reviewer identity is missing
52
+ - keeps all required variance types distinct during review
@@ -0,0 +1,46 @@
1
+ # StartWorkOrder
2
+
3
+ ## Overview
4
+
5
+ StartWorkOrder begins execution on one released operation. It records the actual start signal and moves the work order into `IN_PROGRESS` so later reporting can accumulate quantities and time.
6
+
7
+ ## Business Rules
8
+
9
+ - Target work order must exist.
10
+ - Work order must be in `PENDING`.
11
+ - Parent production order must be in an execution-capable state.
12
+ - Required predecessor operations must already satisfy sequencing policy.
13
+ - Starting the work order records the actual start timestamp.
14
+
15
+ ## Process Flow
16
+
17
+ ```mermaid
18
+ flowchart TD
19
+ A[Receive start request] --> B{Work order exists?}
20
+ B -->|No| C[Return WORK_ORDER_NOT_FOUND]
21
+ B -->|Yes| D{Status is PENDING?}
22
+ D -->|No| E[Return WORK_ORDER_NOT_STARTABLE]
23
+ D -->|Yes| F{Parent order and sequence ready?}
24
+ F -->|No| G[Return OPERATION_SEQUENCE_BLOCKED]
25
+ F -->|Yes| H[Record actual start and set IN_PROGRESS]
26
+ H --> I[Return started work order]
27
+ ```
28
+
29
+ ## External Dependencies
30
+
31
+ - [ProductionOrder](../models/ProductionOrder.md) - Parent production order must still allow execution.
32
+
33
+ ## Error Scenarios
34
+
35
+ - **WORK_ORDER_NOT_FOUND**: Target work order does not exist.
36
+ - **WORK_ORDER_NOT_STARTABLE**: Work order is not in `PENDING`.
37
+ - **PARENT_ORDER_NOT_EXECUTABLE**: Parent production order does not allow execution.
38
+ - **OPERATION_SEQUENCE_BLOCKED**: Required predecessor work is not yet complete.
39
+
40
+ ## Test Cases
41
+
42
+ - starts a pending work order
43
+ - returns error when the work order does not exist
44
+ - returns error when the work order is not pending
45
+ - returns error when the parent production order is not executable
46
+ - returns error when required predecessor work is incomplete
@@ -0,0 +1,51 @@
1
+ # TechnicallyCompleteProductionOrder
2
+
3
+ ## Overview
4
+
5
+ TechnicallyCompleteProductionOrder freezes the production order after physical completion and moves the linked manufacturing cost summary into variance review. It marks the point where no more normal execution or rescheduling is expected.
6
+
7
+ ## Business Rules
8
+
9
+ - Target order must exist and be in `COMPLETED`.
10
+ - No additional execution, rescheduling, or material issue may still be expected.
11
+ - Open execution exceptions must be resolved before technical completion.
12
+ - Pending material issue requests or unresolved backflush issue intents must be cleared before technical completion.
13
+ - Technical completion moves the linked manufacturing cost summary to `PENDING_VARIANCE_REVIEW`.
14
+ - Further shop-floor reporting is blocked until a controlled reopen occurs.
15
+
16
+ ## Process Flow
17
+
18
+ ```mermaid
19
+ flowchart TD
20
+ A[Receive technical-complete request] --> B{Order exists and is COMPLETED?}
21
+ B -->|No| C[Return PRODUCTION_ORDER_NOT_TECHNICALLY_COMPLETABLE]
22
+ B -->|Yes| D{Open execution exceptions remain?}
23
+ D -->|Yes| E[Return EXECUTION_EXCEPTION_REMAINS]
24
+ D -->|No| F{Pending material issue requests remain?}
25
+ F -->|Yes| G[Return PENDING_MATERIAL_ISSUE_REQUESTS]
26
+ F -->|No| H[Move cost summary to PENDING_VARIANCE_REVIEW]
27
+ H --> I[Set order status to TECHNICALLY_COMPLETE]
28
+ I --> J[Return technically complete order]
29
+ ```
30
+
31
+ ## External Dependencies
32
+
33
+ - [ManufacturingCostSummary](../models/ManufacturingCostSummary.md) - Technical completion opens variance review on the linked summary.
34
+
35
+ ## Error Scenarios
36
+
37
+ - **PRODUCTION_ORDER_NOT_FOUND**: Target order does not exist.
38
+ - **PRODUCTION_ORDER_NOT_TECHNICALLY_COMPLETABLE**: The order is not in `COMPLETED`.
39
+ - **EXECUTION_EXCEPTION_REMAINS**: Unresolved execution exceptions still exist.
40
+ - **PENDING_MATERIAL_ISSUE_REQUESTS**: Material issue requests or backflush intents are still unresolved for the order.
41
+ - **COST_SUMMARY_NOT_READY**: The linked cost summary cannot move to review.
42
+
43
+ ## Test Cases
44
+
45
+ - technically completes a completed order and opens variance review
46
+ - returns error when the order does not exist
47
+ - returns error when the order is not in `COMPLETED`
48
+ - returns error when unresolved execution exceptions remain
49
+ - returns error when pending material issue requests or unresolved backflush intents remain
50
+ - returns error when the linked cost summary is not ready for review
51
+ - blocks further shop-floor reporting after technical completion
@@ -0,0 +1,46 @@
1
+ # UnreleaseProductionOrder
2
+
3
+ ## Overview
4
+
5
+ UnreleaseProductionOrder returns a released order to `DRAFT` when execution has not meaningfully started. It removes the executable release artifacts so the planner can safely revise the order.
6
+
7
+ ## Business Rules
8
+
9
+ - Target order must exist and be in `RELEASED`.
10
+ - No work order may have started or received execution evidence.
11
+ - No irreversible inventory handoff may exist for the order.
12
+ - Unrelease removes or supersedes work orders, material requirements, and the unrevised release snapshot.
13
+ - Orders with actual material or execution evidence must use controlled reopening instead of unrelease.
14
+
15
+ ## Process Flow
16
+
17
+ ```mermaid
18
+ flowchart TD
19
+ A[Receive unrelease request] --> B{Order exists and is RELEASED?}
20
+ B -->|No| C[Return PRODUCTION_ORDER_NOT_UNRELEASABLE]
21
+ B -->|Yes| D{Any execution or inventory evidence?}
22
+ D -->|Yes| E[Return EXECUTION_ALREADY_STARTED]
23
+ D -->|No| F[Remove release artifacts]
24
+ F --> G[Set status to DRAFT]
25
+ G --> H[Return draft order]
26
+ ```
27
+
28
+ ## External Dependencies
29
+
30
+ - [WorkOrder](../models/WorkOrder.md) - Unrelease is blocked once execution evidence exists on any child work order.
31
+
32
+ ## Error Scenarios
33
+
34
+ - **PRODUCTION_ORDER_NOT_FOUND**: Target order does not exist.
35
+ - **PRODUCTION_ORDER_NOT_UNRELEASABLE**: The order is not in `RELEASED`.
36
+ - **EXECUTION_ALREADY_STARTED**: A work order already has execution evidence.
37
+ - **INVENTORY_HANDOFF_EXISTS**: Inventory-facing material or receipt evidence already exists.
38
+
39
+ ## Test Cases
40
+
41
+ - unreleases a released order with no execution evidence
42
+ - returns error when the order does not exist
43
+ - returns error when the order is not in `RELEASED`
44
+ - returns error when a work order has already started
45
+ - returns error when inventory handoff evidence already exists
46
+ - removes work orders and material requirements when unrelease succeeds