@tailor-platform/erp-kit 0.5.1 → 0.7.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 (525) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +10 -10
  3. package/dist/cli.mjs +499 -81
  4. package/package.json +1 -1
  5. package/skills/erp-kit-app-1-requirements/SKILL.md +33 -17
  6. package/skills/erp-kit-app-2-requirements-review/SKILL.md +12 -0
  7. package/skills/erp-kit-app-3-plan/SKILL.md +18 -4
  8. package/skills/erp-kit-app-3-plan/references/resolver-extraction.md +1 -1
  9. package/skills/erp-kit-app-3-plan/references/screen-extraction.md +1 -1
  10. package/skills/erp-kit-app-4-plan-review/SKILL.md +12 -0
  11. package/skills/erp-kit-app-5-impl-backend/SKILL.md +19 -4
  12. package/skills/erp-kit-app-6-impl-frontend/SKILL.md +12 -0
  13. package/skills/erp-kit-app-7-impl-review/SKILL.md +14 -2
  14. package/skills/erp-kit-app-shared/references/progress-protocol.md +77 -0
  15. package/skills/erp-kit-mock-scenario/SKILL.md +1 -1
  16. package/skills/erp-kit-module-1-requirements/SKILL.md +1 -1
  17. package/skills/erp-kit-module-3-plan/SKILL.md +3 -3
  18. package/skills/erp-kit-module-3-update-plan/SKILL.md +3 -3
  19. package/skills/erp-kit-module-5-impl/SKILL.md +1 -1
  20. package/skills/erp-kit-module-6-impl-review/SKILL.md +39 -17
  21. package/src/commands/app/index.ts +2 -0
  22. package/src/commands/app/progress/git-context.ts +16 -0
  23. package/src/commands/app/progress/index.ts +45 -0
  24. package/src/commands/app/progress/log.ts +49 -0
  25. package/src/commands/app/progress/progress.test.ts +128 -0
  26. package/src/commands/app/progress/schema-cmd.ts +10 -0
  27. package/src/commands/check.test.ts +4 -4
  28. package/src/commands/generate-doc.ts +1 -1
  29. package/src/commands/lib/discovery.test.ts +18 -10
  30. package/src/commands/lib/discovery.ts +17 -9
  31. package/src/commands/lib/paths.ts +4 -2
  32. package/src/commands/lib/sync-check-source.test.ts +1 -1
  33. package/src/commands/lib/sync-check-source.ts +6 -1
  34. package/src/commands/lib/sync-check-tests.test.ts +127 -6
  35. package/src/commands/lib/sync-check-tests.ts +82 -4
  36. package/src/commands/sync-check.ts +10 -3
  37. package/src/generator/generate-app-code.test.ts +0 -6
  38. package/src/generator/generate-app-code.ts +47 -22
  39. package/src/generator/generate-code.test.ts +10 -40
  40. package/src/generator/generate-code.ts +6 -12
  41. package/src/generator/stub-templates.test.ts +9 -5
  42. package/src/generator/stub-templates.ts +16 -9
  43. package/src/modules/finance-ledger/README.md +50 -0
  44. package/src/modules/finance-ledger/command/.gitkeep +0 -0
  45. package/src/modules/finance-ledger/command/addJournalLine.generated.ts +6 -0
  46. package/src/modules/finance-ledger/command/addJournalLine.test.ts +438 -0
  47. package/src/modules/finance-ledger/command/addJournalLine.ts +122 -0
  48. package/src/modules/finance-ledger/command/approveAndLockPeriod.generated.ts +6 -0
  49. package/src/modules/finance-ledger/command/approveAndLockPeriod.test.ts +107 -0
  50. package/src/modules/finance-ledger/command/approveAndLockPeriod.ts +72 -0
  51. package/src/modules/finance-ledger/command/beginClose.generated.ts +6 -0
  52. package/src/modules/finance-ledger/command/beginClose.test.ts +106 -0
  53. package/src/modules/finance-ledger/command/beginClose.ts +58 -0
  54. package/src/modules/finance-ledger/command/closePeriod.generated.ts +6 -0
  55. package/src/modules/finance-ledger/command/closePeriod.test.ts +87 -0
  56. package/src/modules/finance-ledger/command/closePeriod.ts +44 -0
  57. package/src/modules/finance-ledger/command/createAccountingPeriod.generated.ts +6 -0
  58. package/src/modules/finance-ledger/command/createAccountingPeriod.test.ts +425 -0
  59. package/src/modules/finance-ledger/command/createAccountingPeriod.ts +133 -0
  60. package/src/modules/finance-ledger/command/createFiscalYear.generated.ts +6 -0
  61. package/src/modules/finance-ledger/command/createFiscalYear.test.ts +197 -0
  62. package/src/modules/finance-ledger/command/createFiscalYear.ts +70 -0
  63. package/src/modules/finance-ledger/command/createJournalEntry.generated.ts +6 -0
  64. package/src/modules/finance-ledger/command/createJournalEntry.test.ts +261 -0
  65. package/src/modules/finance-ledger/command/createJournalEntry.ts +121 -0
  66. package/src/modules/finance-ledger/command/deleteAccountingPeriod.generated.ts +6 -0
  67. package/src/modules/finance-ledger/command/deleteAccountingPeriod.test.ts +71 -0
  68. package/src/modules/finance-ledger/command/deleteAccountingPeriod.ts +55 -0
  69. package/src/modules/finance-ledger/command/deleteFiscalYear.generated.ts +6 -0
  70. package/src/modules/finance-ledger/command/deleteFiscalYear.test.ts +38 -0
  71. package/src/modules/finance-ledger/command/deleteFiscalYear.ts +34 -0
  72. package/src/modules/finance-ledger/command/deleteJournalEntry.generated.ts +6 -0
  73. package/src/modules/finance-ledger/command/deleteJournalEntry.test.ts +58 -0
  74. package/src/modules/finance-ledger/command/deleteJournalEntry.ts +43 -0
  75. package/src/modules/finance-ledger/command/executeYearEndClose.generated.ts +6 -0
  76. package/src/modules/finance-ledger/command/executeYearEndClose.test.ts +239 -0
  77. package/src/modules/finance-ledger/command/executeYearEndClose.ts +415 -0
  78. package/src/modules/finance-ledger/command/finalCloseAndLockPeriod.generated.ts +6 -0
  79. package/src/modules/finance-ledger/command/finalCloseAndLockPeriod.test.ts +102 -0
  80. package/src/modules/finance-ledger/command/finalCloseAndLockPeriod.ts +76 -0
  81. package/src/modules/finance-ledger/command/finalizeFinancialStatement.generated.ts +6 -0
  82. package/src/modules/finance-ledger/command/finalizeFinancialStatement.test.ts +73 -0
  83. package/src/modules/finance-ledger/command/finalizeFinancialStatement.ts +73 -0
  84. package/src/modules/finance-ledger/command/generateFinancialStatement.generated.ts +6 -0
  85. package/src/modules/finance-ledger/command/generateFinancialStatement.test.ts +311 -0
  86. package/src/modules/finance-ledger/command/generateFinancialStatement.ts +275 -0
  87. package/src/modules/finance-ledger/command/generatePreliminaryStatements.generated.ts +6 -0
  88. package/src/modules/finance-ledger/command/generatePreliminaryStatements.test.ts +152 -0
  89. package/src/modules/finance-ledger/command/generatePreliminaryStatements.ts +140 -0
  90. package/src/modules/finance-ledger/command/generateTrialBalance.generated.ts +6 -0
  91. package/src/modules/finance-ledger/command/generateTrialBalance.test.ts +439 -0
  92. package/src/modules/finance-ledger/command/generateTrialBalance.ts +268 -0
  93. package/src/modules/finance-ledger/command/initiatePeriodClose.generated.ts +6 -0
  94. package/src/modules/finance-ledger/command/initiatePeriodClose.test.ts +153 -0
  95. package/src/modules/finance-ledger/command/initiatePeriodClose.ts +84 -0
  96. package/src/modules/finance-ledger/command/openForAdvanceEntry.generated.ts +6 -0
  97. package/src/modules/finance-ledger/command/openForAdvanceEntry.test.ts +87 -0
  98. package/src/modules/finance-ledger/command/openForAdvanceEntry.ts +44 -0
  99. package/src/modules/finance-ledger/command/openPeriod.generated.ts +6 -0
  100. package/src/modules/finance-ledger/command/openPeriod.test.ts +90 -0
  101. package/src/modules/finance-ledger/command/openPeriod.ts +44 -0
  102. package/src/modules/finance-ledger/command/permanentlyClosePeriod.generated.ts +6 -0
  103. package/src/modules/finance-ledger/command/permanentlyClosePeriod.test.ts +87 -0
  104. package/src/modules/finance-ledger/command/permanentlyClosePeriod.ts +48 -0
  105. package/src/modules/finance-ledger/command/postAdjustingEntries.generated.ts +6 -0
  106. package/src/modules/finance-ledger/command/postAdjustingEntries.test.ts +392 -0
  107. package/src/modules/finance-ledger/command/postAdjustingEntries.ts +156 -0
  108. package/src/modules/finance-ledger/command/postJournalEntry.generated.ts +6 -0
  109. package/src/modules/finance-ledger/command/postJournalEntry.test.ts +346 -0
  110. package/src/modules/finance-ledger/command/postJournalEntry.ts +160 -0
  111. package/src/modules/finance-ledger/command/processInventoryHandoff.generated.ts +6 -0
  112. package/src/modules/finance-ledger/command/processInventoryHandoff.test.ts +211 -0
  113. package/src/modules/finance-ledger/command/processInventoryHandoff.ts +133 -0
  114. package/src/modules/finance-ledger/command/processManufacturingHandoff.generated.ts +6 -0
  115. package/src/modules/finance-ledger/command/processManufacturingHandoff.test.ts +221 -0
  116. package/src/modules/finance-ledger/command/processManufacturingHandoff.ts +133 -0
  117. package/src/modules/finance-ledger/command/processPurchaseHandoff.generated.ts +6 -0
  118. package/src/modules/finance-ledger/command/processPurchaseHandoff.test.ts +222 -0
  119. package/src/modules/finance-ledger/command/processPurchaseHandoff.ts +133 -0
  120. package/src/modules/finance-ledger/command/processSalesHandoff.generated.ts +6 -0
  121. package/src/modules/finance-ledger/command/processSalesHandoff.test.ts +257 -0
  122. package/src/modules/finance-ledger/command/processSalesHandoff.ts +135 -0
  123. package/src/modules/finance-ledger/command/regenerateFinancialStatement.generated.ts +6 -0
  124. package/src/modules/finance-ledger/command/regenerateFinancialStatement.test.ts +129 -0
  125. package/src/modules/finance-ledger/command/regenerateFinancialStatement.ts +186 -0
  126. package/src/modules/finance-ledger/command/removeJournalLine.generated.ts +6 -0
  127. package/src/modules/finance-ledger/command/removeJournalLine.test.ts +65 -0
  128. package/src/modules/finance-ledger/command/removeJournalLine.ts +39 -0
  129. package/src/modules/finance-ledger/command/reopenPeriod.generated.ts +6 -0
  130. package/src/modules/finance-ledger/command/reopenPeriod.test.ts +87 -0
  131. package/src/modules/finance-ledger/command/reopenPeriod.ts +44 -0
  132. package/src/modules/finance-ledger/command/reverseJournalEntry.generated.ts +6 -0
  133. package/src/modules/finance-ledger/command/reverseJournalEntry.test.ts +337 -0
  134. package/src/modules/finance-ledger/command/reverseJournalEntry.ts +140 -0
  135. package/src/modules/finance-ledger/command/revertSoftLock.generated.ts +6 -0
  136. package/src/modules/finance-ledger/command/revertSoftLock.test.ts +96 -0
  137. package/src/modules/finance-ledger/command/revertSoftLock.ts +67 -0
  138. package/src/modules/finance-ledger/command/updateFiscalYear.generated.ts +6 -0
  139. package/src/modules/finance-ledger/command/updateFiscalYear.test.ts +138 -0
  140. package/src/modules/finance-ledger/command/updateFiscalYear.ts +85 -0
  141. package/src/modules/finance-ledger/command/updateJournalEntry.generated.ts +6 -0
  142. package/src/modules/finance-ledger/command/updateJournalEntry.test.ts +195 -0
  143. package/src/modules/finance-ledger/command/updateJournalEntry.ts +86 -0
  144. package/src/modules/finance-ledger/command/updateJournalLine.generated.ts +6 -0
  145. package/src/modules/finance-ledger/command/updateJournalLine.test.ts +385 -0
  146. package/src/modules/finance-ledger/command/updateJournalLine.ts +155 -0
  147. package/src/modules/finance-ledger/command/verifySubledgerTransfers.generated.ts +6 -0
  148. package/src/modules/finance-ledger/command/verifySubledgerTransfers.test.ts +201 -0
  149. package/src/modules/finance-ledger/command/verifySubledgerTransfers.ts +113 -0
  150. package/src/modules/finance-ledger/command/verifyTrialBalance.generated.ts +6 -0
  151. package/src/modules/finance-ledger/command/verifyTrialBalance.test.ts +136 -0
  152. package/src/modules/finance-ledger/command/verifyTrialBalance.ts +97 -0
  153. package/src/modules/finance-ledger/db/.gitkeep +0 -0
  154. package/src/modules/finance-ledger/db/accountingPeriod.ts +58 -0
  155. package/src/modules/finance-ledger/db/financialStatement.ts +92 -0
  156. package/src/modules/finance-ledger/db/financialStatementLineItem.ts +76 -0
  157. package/src/modules/finance-ledger/db/fiscalYear.ts +41 -0
  158. package/src/modules/finance-ledger/db/journalEntry.ts +101 -0
  159. package/src/modules/finance-ledger/db/journalLine.ts +64 -0
  160. package/src/modules/finance-ledger/db/periodClose.ts +97 -0
  161. package/src/modules/finance-ledger/db/trialBalance.ts +63 -0
  162. package/src/modules/finance-ledger/db/trialBalanceLine.ts +63 -0
  163. package/src/modules/finance-ledger/docs/commands/AddJournalLine.md +74 -0
  164. package/src/modules/finance-ledger/docs/commands/ApproveAndLockPeriod.md +53 -0
  165. package/src/modules/finance-ledger/docs/commands/BeginClose.md +47 -0
  166. package/src/modules/finance-ledger/docs/commands/ClosePeriod.md +45 -0
  167. package/src/modules/finance-ledger/docs/commands/CreateAccountingPeriod.md +69 -0
  168. package/src/modules/finance-ledger/docs/commands/CreateFiscalYear.md +56 -0
  169. package/src/modules/finance-ledger/docs/commands/CreateJournalEntry.md +63 -0
  170. package/src/modules/finance-ledger/docs/commands/DeleteAccountingPeriod.md +46 -0
  171. package/src/modules/finance-ledger/docs/commands/DeleteFiscalYear.md +40 -0
  172. package/src/modules/finance-ledger/docs/commands/DeleteJournalEntry.md +44 -0
  173. package/src/modules/finance-ledger/docs/commands/ExecuteYearEndClose.md +81 -0
  174. package/src/modules/finance-ledger/docs/commands/FinalCloseAndLockPeriod.md +49 -0
  175. package/src/modules/finance-ledger/docs/commands/FinalizeFinancialStatement.md +43 -0
  176. package/src/modules/finance-ledger/docs/commands/GenerateFinancialStatement.md +86 -0
  177. package/src/modules/finance-ledger/docs/commands/GeneratePreliminaryStatements.md +53 -0
  178. package/src/modules/finance-ledger/docs/commands/GenerateTrialBalance.md +75 -0
  179. package/src/modules/finance-ledger/docs/commands/InitiatePeriodClose.md +58 -0
  180. package/src/modules/finance-ledger/docs/commands/OpenForAdvanceEntry.md +44 -0
  181. package/src/modules/finance-ledger/docs/commands/OpenPeriod.md +45 -0
  182. package/src/modules/finance-ledger/docs/commands/PermanentlyClosePeriod.md +45 -0
  183. package/src/modules/finance-ledger/docs/commands/PostAdjustingEntries.md +61 -0
  184. package/src/modules/finance-ledger/docs/commands/PostJournalEntry.md +81 -0
  185. package/src/modules/finance-ledger/docs/commands/ProcessInventoryHandoff.md +72 -0
  186. package/src/modules/finance-ledger/docs/commands/ProcessManufacturingHandoff.md +68 -0
  187. package/src/modules/finance-ledger/docs/commands/ProcessPurchaseHandoff.md +68 -0
  188. package/src/modules/finance-ledger/docs/commands/ProcessSalesHandoff.md +71 -0
  189. package/src/modules/finance-ledger/docs/commands/RegenerateFinancialStatement.md +60 -0
  190. package/src/modules/finance-ledger/docs/commands/RemoveJournalLine.md +42 -0
  191. package/src/modules/finance-ledger/docs/commands/ReopenPeriod.md +45 -0
  192. package/src/modules/finance-ledger/docs/commands/ReverseJournalEntry.md +62 -0
  193. package/src/modules/finance-ledger/docs/commands/RevertSoftLock.md +49 -0
  194. package/src/modules/finance-ledger/docs/commands/UpdateFiscalYear.md +60 -0
  195. package/src/modules/finance-ledger/docs/commands/UpdateJournalEntry.md +50 -0
  196. package/src/modules/finance-ledger/docs/commands/UpdateJournalLine.md +61 -0
  197. package/src/modules/finance-ledger/docs/commands/VerifySubledgerTransfers.md +59 -0
  198. package/src/modules/finance-ledger/docs/commands/VerifyTrialBalance.md +53 -0
  199. package/src/modules/finance-ledger/docs/features/accounting-period-management.md +110 -0
  200. package/src/modules/finance-ledger/docs/features/financial-statement-generation.md +115 -0
  201. package/src/modules/finance-ledger/docs/features/journal-entry-management.md +138 -0
  202. package/src/modules/finance-ledger/docs/features/period-end-close.md +102 -0
  203. package/src/modules/finance-ledger/docs/features/subledger-integration.md +141 -0
  204. package/src/modules/finance-ledger/docs/features/trial-balance.md +99 -0
  205. package/src/modules/finance-ledger/docs/features/year-end-close.md +84 -0
  206. package/src/modules/finance-ledger/docs/models/AccountingPeriod.md +71 -0
  207. package/src/modules/finance-ledger/docs/models/FinancialStatement.md +76 -0
  208. package/src/modules/finance-ledger/docs/models/FinancialStatementLineItem.md +41 -0
  209. package/src/modules/finance-ledger/docs/models/FiscalYear.md +41 -0
  210. package/src/modules/finance-ledger/docs/models/JournalEntry.md +80 -0
  211. package/src/modules/finance-ledger/docs/models/JournalLine.md +47 -0
  212. package/src/modules/finance-ledger/docs/models/PeriodClose.md +83 -0
  213. package/src/modules/finance-ledger/docs/models/TrialBalance.md +56 -0
  214. package/src/modules/finance-ledger/docs/models/TrialBalanceLine.md +37 -0
  215. package/src/modules/finance-ledger/docs/queries/GetAccountingPeriod.md +35 -0
  216. package/src/modules/finance-ledger/docs/queries/GetFinancialStatement.md +38 -0
  217. package/src/modules/finance-ledger/docs/queries/GetFiscalYear.md +35 -0
  218. package/src/modules/finance-ledger/docs/queries/GetJournalEntry.md +37 -0
  219. package/src/modules/finance-ledger/docs/queries/GetPeriodByDate.md +38 -0
  220. package/src/modules/finance-ledger/docs/queries/GetPeriodClose.md +36 -0
  221. package/src/modules/finance-ledger/docs/queries/GetSubledgerTransferStatus.md +45 -0
  222. package/src/modules/finance-ledger/docs/queries/GetTrialBalance.md +38 -0
  223. package/src/modules/finance-ledger/docs/queries/ListAccountingPeriods.md +46 -0
  224. package/src/modules/finance-ledger/docs/queries/ListFinancialStatements.md +46 -0
  225. package/src/modules/finance-ledger/docs/queries/ListFiscalYears.md +42 -0
  226. package/src/modules/finance-ledger/docs/queries/ListJournalEntries.md +48 -0
  227. package/src/modules/finance-ledger/docs/queries/ListPeriodCloses.md +46 -0
  228. package/src/modules/finance-ledger/docs/queries/ListTrialBalances.md +51 -0
  229. package/src/modules/finance-ledger/executor/.gitkeep +0 -0
  230. package/src/modules/finance-ledger/generated/enums.ts +109 -0
  231. package/src/modules/finance-ledger/generated/kysely-tailordb.ts +202 -0
  232. package/src/modules/finance-ledger/index.ts +2 -0
  233. package/src/modules/finance-ledger/lib/_db_deps.ts +56 -0
  234. package/src/modules/finance-ledger/lib/errors.generated.ts +332 -0
  235. package/src/modules/finance-ledger/lib/permissions.generated.ts +41 -0
  236. package/src/modules/finance-ledger/lib/types.ts +66 -0
  237. package/src/modules/finance-ledger/module.ts +262 -0
  238. package/src/modules/finance-ledger/package.json +26 -0
  239. package/src/modules/finance-ledger/permissions.ts +3 -0
  240. package/src/modules/finance-ledger/query/.gitkeep +0 -0
  241. package/src/modules/finance-ledger/query/getAccountingPeriod.generated.ts +5 -0
  242. package/src/modules/finance-ledger/query/getAccountingPeriod.test.ts +31 -0
  243. package/src/modules/finance-ledger/query/getAccountingPeriod.ts +21 -0
  244. package/src/modules/finance-ledger/query/getFinancialStatement.generated.ts +5 -0
  245. package/src/modules/finance-ledger/query/getFinancialStatement.test.ts +35 -0
  246. package/src/modules/finance-ledger/query/getFinancialStatement.ts +29 -0
  247. package/src/modules/finance-ledger/query/getFiscalYear.generated.ts +5 -0
  248. package/src/modules/finance-ledger/query/getFiscalYear.test.ts +31 -0
  249. package/src/modules/finance-ledger/query/getFiscalYear.ts +21 -0
  250. package/src/modules/finance-ledger/query/getJournalEntry.generated.ts +5 -0
  251. package/src/modules/finance-ledger/query/getJournalEntry.test.ts +35 -0
  252. package/src/modules/finance-ledger/query/getJournalEntry.ts +29 -0
  253. package/src/modules/finance-ledger/query/getPeriodByDate.generated.ts +5 -0
  254. package/src/modules/finance-ledger/query/getPeriodByDate.test.ts +53 -0
  255. package/src/modules/finance-ledger/query/getPeriodByDate.ts +27 -0
  256. package/src/modules/finance-ledger/query/getPeriodClose.generated.ts +5 -0
  257. package/src/modules/finance-ledger/query/getPeriodClose.test.ts +31 -0
  258. package/src/modules/finance-ledger/query/getPeriodClose.ts +21 -0
  259. package/src/modules/finance-ledger/query/getSubledgerTransferStatus.generated.ts +5 -0
  260. package/src/modules/finance-ledger/query/getSubledgerTransferStatus.test.ts +101 -0
  261. package/src/modules/finance-ledger/query/getSubledgerTransferStatus.ts +68 -0
  262. package/src/modules/finance-ledger/query/getTrialBalance.generated.ts +5 -0
  263. package/src/modules/finance-ledger/query/getTrialBalance.test.ts +33 -0
  264. package/src/modules/finance-ledger/query/getTrialBalance.ts +30 -0
  265. package/src/modules/finance-ledger/query/listAccountingPeriods.generated.ts +5 -0
  266. package/src/modules/finance-ledger/query/listAccountingPeriods.test.ts +81 -0
  267. package/src/modules/finance-ledger/query/listAccountingPeriods.ts +61 -0
  268. package/src/modules/finance-ledger/query/listFinancialStatements.generated.ts +5 -0
  269. package/src/modules/finance-ledger/query/listFinancialStatements.test.ts +76 -0
  270. package/src/modules/finance-ledger/query/listFinancialStatements.ts +62 -0
  271. package/src/modules/finance-ledger/query/listFiscalYears.generated.ts +5 -0
  272. package/src/modules/finance-ledger/query/listFiscalYears.test.ts +63 -0
  273. package/src/modules/finance-ledger/query/listFiscalYears.ts +45 -0
  274. package/src/modules/finance-ledger/query/listJournalEntries.generated.ts +5 -0
  275. package/src/modules/finance-ledger/query/listJournalEntries.test.ts +91 -0
  276. package/src/modules/finance-ledger/query/listJournalEntries.ts +64 -0
  277. package/src/modules/finance-ledger/query/listPeriodCloses.generated.ts +5 -0
  278. package/src/modules/finance-ledger/query/listPeriodCloses.test.ts +63 -0
  279. package/src/modules/finance-ledger/query/listPeriodCloses.ts +64 -0
  280. package/src/modules/finance-ledger/query/listTrialBalances.generated.ts +5 -0
  281. package/src/modules/finance-ledger/query/listTrialBalances.test.ts +78 -0
  282. package/src/modules/finance-ledger/query/listTrialBalances.ts +56 -0
  283. package/src/modules/finance-ledger/seed/index.ts +19 -0
  284. package/src/modules/finance-ledger/tailor.config.ts +13 -0
  285. package/src/modules/finance-ledger/tailor.d.ts +13 -0
  286. package/src/modules/finance-ledger/testing/commandTestUtils.ts +35 -0
  287. package/src/modules/finance-ledger/testing/fixtures.ts +382 -0
  288. package/src/modules/finance-ledger/tsconfig.json +16 -0
  289. package/src/modules/inventory/docs/features/inventory-adjustment.md +2 -1
  290. package/src/modules/inventory/docs/features/scrap-management.md +39 -1
  291. package/src/modules/manufacturing/README.md +63 -0
  292. package/src/modules/manufacturing/command/.gitkeep +0 -0
  293. package/src/modules/manufacturing/command/activateBillOfMaterial.generated.ts +6 -0
  294. package/src/modules/manufacturing/command/activateBillOfMaterial.test.ts +166 -0
  295. package/src/modules/manufacturing/command/activateBillOfMaterial.ts +173 -0
  296. package/src/modules/manufacturing/command/activateRouting.generated.ts +6 -0
  297. package/src/modules/manufacturing/command/activateRouting.test.ts +152 -0
  298. package/src/modules/manufacturing/command/activateRouting.ts +92 -0
  299. package/src/modules/manufacturing/command/activateWorkCenter.generated.ts +6 -0
  300. package/src/modules/manufacturing/command/activateWorkCenter.test.ts +135 -0
  301. package/src/modules/manufacturing/command/activateWorkCenter.ts +91 -0
  302. package/src/modules/manufacturing/command/cancelProductionOrder.generated.ts +6 -0
  303. package/src/modules/manufacturing/command/cancelProductionOrder.test.ts +151 -0
  304. package/src/modules/manufacturing/command/cancelProductionOrder.ts +114 -0
  305. package/src/modules/manufacturing/command/closeProductionOrder.generated.ts +6 -0
  306. package/src/modules/manufacturing/command/closeProductionOrder.test.ts +126 -0
  307. package/src/modules/manufacturing/command/closeProductionOrder.ts +87 -0
  308. package/src/modules/manufacturing/command/completeProductionOrder.generated.ts +6 -0
  309. package/src/modules/manufacturing/command/completeProductionOrder.test.ts +132 -0
  310. package/src/modules/manufacturing/command/completeProductionOrder.ts +97 -0
  311. package/src/modules/manufacturing/command/completeWorkOrder.generated.ts +6 -0
  312. package/src/modules/manufacturing/command/completeWorkOrder.test.ts +369 -0
  313. package/src/modules/manufacturing/command/completeWorkOrder.ts +212 -0
  314. package/src/modules/manufacturing/command/createBillOfMaterial.generated.ts +6 -0
  315. package/src/modules/manufacturing/command/createBillOfMaterial.test.ts +210 -0
  316. package/src/modules/manufacturing/command/createBillOfMaterial.ts +176 -0
  317. package/src/modules/manufacturing/command/createProductionOrder.generated.ts +6 -0
  318. package/src/modules/manufacturing/command/createProductionOrder.test.ts +160 -0
  319. package/src/modules/manufacturing/command/createProductionOrder.ts +129 -0
  320. package/src/modules/manufacturing/command/createRouting.generated.ts +6 -0
  321. package/src/modules/manufacturing/command/createRouting.test.ts +168 -0
  322. package/src/modules/manufacturing/command/createRouting.ts +128 -0
  323. package/src/modules/manufacturing/command/createWorkCenter.generated.ts +6 -0
  324. package/src/modules/manufacturing/command/createWorkCenter.test.ts +148 -0
  325. package/src/modules/manufacturing/command/createWorkCenter.ts +131 -0
  326. package/src/modules/manufacturing/command/deactivateBillOfMaterial.generated.ts +6 -0
  327. package/src/modules/manufacturing/command/deactivateBillOfMaterial.test.ts +103 -0
  328. package/src/modules/manufacturing/command/deactivateBillOfMaterial.ts +78 -0
  329. package/src/modules/manufacturing/command/deactivateRouting.generated.ts +6 -0
  330. package/src/modules/manufacturing/command/deactivateRouting.test.ts +112 -0
  331. package/src/modules/manufacturing/command/deactivateRouting.ts +76 -0
  332. package/src/modules/manufacturing/command/deactivateWorkCenter.generated.ts +6 -0
  333. package/src/modules/manufacturing/command/deactivateWorkCenter.test.ts +113 -0
  334. package/src/modules/manufacturing/command/deactivateWorkCenter.ts +85 -0
  335. package/src/modules/manufacturing/command/pauseWorkOrder.generated.ts +6 -0
  336. package/src/modules/manufacturing/command/pauseWorkOrder.test.ts +118 -0
  337. package/src/modules/manufacturing/command/pauseWorkOrder.ts +82 -0
  338. package/src/modules/manufacturing/command/recordInventoryIssueOutcome.generated.ts +6 -0
  339. package/src/modules/manufacturing/command/recordInventoryIssueOutcome.test.ts +183 -0
  340. package/src/modules/manufacturing/command/recordInventoryIssueOutcome.ts +139 -0
  341. package/src/modules/manufacturing/command/recordManufacturingCostSettlementAcknowledgment.generated.ts +6 -0
  342. package/src/modules/manufacturing/command/recordManufacturingCostSettlementAcknowledgment.test.ts +120 -0
  343. package/src/modules/manufacturing/command/recordManufacturingCostSettlementAcknowledgment.ts +110 -0
  344. package/src/modules/manufacturing/command/releaseProductionOrder.generated.ts +6 -0
  345. package/src/modules/manufacturing/command/releaseProductionOrder.test.ts +220 -0
  346. package/src/modules/manufacturing/command/releaseProductionOrder.ts +450 -0
  347. package/src/modules/manufacturing/command/reopenProductionOrder.generated.ts +6 -0
  348. package/src/modules/manufacturing/command/reopenProductionOrder.test.ts +196 -0
  349. package/src/modules/manufacturing/command/reopenProductionOrder.ts +98 -0
  350. package/src/modules/manufacturing/command/reportWorkOrderProgress.generated.ts +6 -0
  351. package/src/modules/manufacturing/command/reportWorkOrderProgress.test.ts +204 -0
  352. package/src/modules/manufacturing/command/reportWorkOrderProgress.ts +129 -0
  353. package/src/modules/manufacturing/command/rescheduleProductionOrder.generated.ts +6 -0
  354. package/src/modules/manufacturing/command/rescheduleProductionOrder.test.ts +185 -0
  355. package/src/modules/manufacturing/command/rescheduleProductionOrder.ts +95 -0
  356. package/src/modules/manufacturing/command/resumeWorkOrder.generated.ts +6 -0
  357. package/src/modules/manufacturing/command/resumeWorkOrder.test.ts +122 -0
  358. package/src/modules/manufacturing/command/resumeWorkOrder.ts +94 -0
  359. package/src/modules/manufacturing/command/reviewManufacturingCostSummary.generated.ts +6 -0
  360. package/src/modules/manufacturing/command/reviewManufacturingCostSummary.test.ts +231 -0
  361. package/src/modules/manufacturing/command/reviewManufacturingCostSummary.ts +137 -0
  362. package/src/modules/manufacturing/command/startWorkOrder.generated.ts +6 -0
  363. package/src/modules/manufacturing/command/startWorkOrder.test.ts +118 -0
  364. package/src/modules/manufacturing/command/startWorkOrder.ts +126 -0
  365. package/src/modules/manufacturing/command/technicallyCompleteProductionOrder.generated.ts +6 -0
  366. package/src/modules/manufacturing/command/technicallyCompleteProductionOrder.test.ts +153 -0
  367. package/src/modules/manufacturing/command/technicallyCompleteProductionOrder.ts +106 -0
  368. package/src/modules/manufacturing/command/unreleaseProductionOrder.generated.ts +6 -0
  369. package/src/modules/manufacturing/command/unreleaseProductionOrder.test.ts +140 -0
  370. package/src/modules/manufacturing/command/unreleaseProductionOrder.ts +131 -0
  371. package/src/modules/manufacturing/command/updateBillOfMaterial.generated.ts +6 -0
  372. package/src/modules/manufacturing/command/updateBillOfMaterial.test.ts +149 -0
  373. package/src/modules/manufacturing/command/updateBillOfMaterial.ts +174 -0
  374. package/src/modules/manufacturing/command/updateProductionOrder.generated.ts +6 -0
  375. package/src/modules/manufacturing/command/updateProductionOrder.test.ts +112 -0
  376. package/src/modules/manufacturing/command/updateProductionOrder.ts +145 -0
  377. package/src/modules/manufacturing/command/updateRouting.generated.ts +6 -0
  378. package/src/modules/manufacturing/command/updateRouting.test.ts +211 -0
  379. package/src/modules/manufacturing/command/updateRouting.ts +124 -0
  380. package/src/modules/manufacturing/command/updateWorkCenter.generated.ts +6 -0
  381. package/src/modules/manufacturing/command/updateWorkCenter.test.ts +152 -0
  382. package/src/modules/manufacturing/command/updateWorkCenter.ts +137 -0
  383. package/src/modules/manufacturing/db/.gitkeep +0 -0
  384. package/src/modules/manufacturing/db/billOfMaterial.ts +70 -0
  385. package/src/modules/manufacturing/db/billOfMaterialLine.ts +49 -0
  386. package/src/modules/manufacturing/db/costVarianceLine.ts +53 -0
  387. package/src/modules/manufacturing/db/manufacturingCostLine.ts +35 -0
  388. package/src/modules/manufacturing/db/manufacturingCostSettlementRecord.ts +39 -0
  389. package/src/modules/manufacturing/db/manufacturingCostSummary.ts +59 -0
  390. package/src/modules/manufacturing/db/productionOrder.ts +83 -0
  391. package/src/modules/manufacturing/db/productionOrderBomSnapshot.ts +44 -0
  392. package/src/modules/manufacturing/db/productionOrderCostBaseline.ts +44 -0
  393. package/src/modules/manufacturing/db/productionOrderMaterialRequirement.ts +57 -0
  394. package/src/modules/manufacturing/db/productionOrderRoutingSnapshot.ts +43 -0
  395. package/src/modules/manufacturing/db/routing.ts +63 -0
  396. package/src/modules/manufacturing/db/routingOperation.ts +57 -0
  397. package/src/modules/manufacturing/db/workCenter.ts +87 -0
  398. package/src/modules/manufacturing/db/workOrder.ts +65 -0
  399. package/src/modules/manufacturing/db/workOrderExecutionEvent.ts +54 -0
  400. package/src/modules/manufacturing/docs/commands/ActivateBillOfMaterial.md +50 -0
  401. package/src/modules/manufacturing/docs/commands/ActivateRouting.md +48 -0
  402. package/src/modules/manufacturing/docs/commands/ActivateWorkCenter.md +49 -0
  403. package/src/modules/manufacturing/docs/commands/CancelProductionOrder.md +48 -0
  404. package/src/modules/manufacturing/docs/commands/CloseProductionOrder.md +46 -0
  405. package/src/modules/manufacturing/docs/commands/CompleteProductionOrder.md +48 -0
  406. package/src/modules/manufacturing/docs/commands/CompleteWorkOrder.md +66 -0
  407. package/src/modules/manufacturing/docs/commands/CreateBillOfMaterial.md +54 -0
  408. package/src/modules/manufacturing/docs/commands/CreateProductionOrder.md +49 -0
  409. package/src/modules/manufacturing/docs/commands/CreateRouting.md +50 -0
  410. package/src/modules/manufacturing/docs/commands/CreateWorkCenter.md +51 -0
  411. package/src/modules/manufacturing/docs/commands/DeactivateBillOfMaterial.md +45 -0
  412. package/src/modules/manufacturing/docs/commands/DeactivateRouting.md +45 -0
  413. package/src/modules/manufacturing/docs/commands/DeactivateWorkCenter.md +45 -0
  414. package/src/modules/manufacturing/docs/commands/PauseWorkOrder.md +44 -0
  415. package/src/modules/manufacturing/docs/commands/RecordInventoryIssueOutcome.md +59 -0
  416. package/src/modules/manufacturing/docs/commands/RecordManufacturingCostSettlementAcknowledgment.md +49 -0
  417. package/src/modules/manufacturing/docs/commands/ReleaseProductionOrder.md +57 -0
  418. package/src/modules/manufacturing/docs/commands/ReopenProductionOrder.md +54 -0
  419. package/src/modules/manufacturing/docs/commands/ReportWorkOrderProgress.md +53 -0
  420. package/src/modules/manufacturing/docs/commands/RescheduleProductionOrder.md +45 -0
  421. package/src/modules/manufacturing/docs/commands/ResumeWorkOrder.md +44 -0
  422. package/src/modules/manufacturing/docs/commands/ReviewManufacturingCostSummary.md +52 -0
  423. package/src/modules/manufacturing/docs/commands/StartWorkOrder.md +46 -0
  424. package/src/modules/manufacturing/docs/commands/TechnicallyCompleteProductionOrder.md +51 -0
  425. package/src/modules/manufacturing/docs/commands/UnreleaseProductionOrder.md +46 -0
  426. package/src/modules/manufacturing/docs/commands/UpdateBillOfMaterial.md +48 -0
  427. package/src/modules/manufacturing/docs/commands/UpdateProductionOrder.md +48 -0
  428. package/src/modules/manufacturing/docs/commands/UpdateRouting.md +52 -0
  429. package/src/modules/manufacturing/docs/commands/UpdateWorkCenter.md +48 -0
  430. package/src/modules/manufacturing/docs/features/bill-of-material-management.md +83 -0
  431. package/src/modules/manufacturing/docs/features/manufacturing-cost-and-variance.md +191 -0
  432. package/src/modules/manufacturing/docs/features/production-order-lifecycle.md +103 -0
  433. package/src/modules/manufacturing/docs/features/routing-and-work-center-definition.md +63 -0
  434. package/src/modules/manufacturing/docs/features/work-order-execution.md +115 -0
  435. package/src/modules/manufacturing/docs/models/BillOfMaterial.md +60 -0
  436. package/src/modules/manufacturing/docs/models/ManufacturingCostSummary.md +66 -0
  437. package/src/modules/manufacturing/docs/models/ProductionOrder.md +76 -0
  438. package/src/modules/manufacturing/docs/models/Routing.md +58 -0
  439. package/src/modules/manufacturing/docs/models/WorkCenter.md +56 -0
  440. package/src/modules/manufacturing/docs/models/WorkOrder.md +63 -0
  441. package/src/modules/manufacturing/docs/queries/DetectBillOfMaterialCircularReference.md +39 -0
  442. package/src/modules/manufacturing/docs/queries/ExplodeBillOfMaterial.md +56 -0
  443. package/src/modules/manufacturing/docs/queries/GetBillOfMaterial.md +37 -0
  444. package/src/modules/manufacturing/docs/queries/GetManufacturingCostSummary.md +39 -0
  445. package/src/modules/manufacturing/docs/queries/GetProductionOrder.md +37 -0
  446. package/src/modules/manufacturing/docs/queries/GetRouting.md +39 -0
  447. package/src/modules/manufacturing/docs/queries/GetWorkCenter.md +35 -0
  448. package/src/modules/manufacturing/docs/queries/GetWorkOrder.md +38 -0
  449. package/src/modules/manufacturing/docs/queries/ListBillOfMaterialsByItem.md +42 -0
  450. package/src/modules/manufacturing/docs/queries/ListManufacturingCostSummariesByStatus.md +41 -0
  451. package/src/modules/manufacturing/docs/queries/ListProductionOrdersByStatus.md +41 -0
  452. package/src/modules/manufacturing/docs/queries/ListRoutingsByItem.md +42 -0
  453. package/src/modules/manufacturing/docs/queries/ListWorkCentersBySite.md +38 -0
  454. package/src/modules/manufacturing/docs/queries/ListWorkOrdersByProductionOrder.md +39 -0
  455. package/src/modules/manufacturing/docs/queries/ListWorkOrdersByWorkCenter.md +43 -0
  456. package/src/modules/manufacturing/executor/.gitkeep +0 -0
  457. package/src/modules/manufacturing/generated/enums.ts +113 -0
  458. package/src/modules/manufacturing/generated/kysely-tailordb.ts +247 -0
  459. package/src/modules/manufacturing/index.ts +2 -0
  460. package/src/modules/manufacturing/lib/_db_deps.ts +22 -0
  461. package/src/modules/manufacturing/lib/errors.generated.ts +592 -0
  462. package/src/modules/manufacturing/lib/permissions.generated.ts +35 -0
  463. package/src/modules/manufacturing/lib/types.ts +111 -0
  464. package/src/modules/manufacturing/module.ts +226 -0
  465. package/src/modules/manufacturing/permissions.ts +3 -0
  466. package/src/modules/manufacturing/query/.gitkeep +0 -0
  467. package/src/modules/manufacturing/query/detectBillOfMaterialCircularReference.generated.ts +5 -0
  468. package/src/modules/manufacturing/query/detectBillOfMaterialCircularReference.test.ts +115 -0
  469. package/src/modules/manufacturing/query/detectBillOfMaterialCircularReference.ts +79 -0
  470. package/src/modules/manufacturing/query/explodeBillOfMaterial.generated.ts +5 -0
  471. package/src/modules/manufacturing/query/explodeBillOfMaterial.test.ts +445 -0
  472. package/src/modules/manufacturing/query/explodeBillOfMaterial.ts +306 -0
  473. package/src/modules/manufacturing/query/getBillOfMaterial.generated.ts +5 -0
  474. package/src/modules/manufacturing/query/getBillOfMaterial.test.ts +64 -0
  475. package/src/modules/manufacturing/query/getBillOfMaterial.ts +27 -0
  476. package/src/modules/manufacturing/query/getManufacturingCostSummary.generated.ts +5 -0
  477. package/src/modules/manufacturing/query/getManufacturingCostSummary.test.ts +147 -0
  478. package/src/modules/manufacturing/query/getManufacturingCostSummary.ts +46 -0
  479. package/src/modules/manufacturing/query/getProductionOrder.generated.ts +5 -0
  480. package/src/modules/manufacturing/query/getProductionOrder.test.ts +139 -0
  481. package/src/modules/manufacturing/query/getProductionOrder.ts +84 -0
  482. package/src/modules/manufacturing/query/getRouting.generated.ts +5 -0
  483. package/src/modules/manufacturing/query/getRouting.test.ts +71 -0
  484. package/src/modules/manufacturing/query/getRouting.ts +34 -0
  485. package/src/modules/manufacturing/query/getWorkCenter.generated.ts +5 -0
  486. package/src/modules/manufacturing/query/getWorkCenter.test.ts +37 -0
  487. package/src/modules/manufacturing/query/getWorkCenter.ts +21 -0
  488. package/src/modules/manufacturing/query/getWorkOrder.generated.ts +5 -0
  489. package/src/modules/manufacturing/query/getWorkOrder.test.ts +73 -0
  490. package/src/modules/manufacturing/query/getWorkOrder.ts +28 -0
  491. package/src/modules/manufacturing/query/listBillOfMaterialsByItem.generated.ts +5 -0
  492. package/src/modules/manufacturing/query/listBillOfMaterialsByItem.test.ts +107 -0
  493. package/src/modules/manufacturing/query/listBillOfMaterialsByItem.ts +58 -0
  494. package/src/modules/manufacturing/query/listManufacturingCostSummariesByStatus.generated.ts +5 -0
  495. package/src/modules/manufacturing/query/listManufacturingCostSummariesByStatus.test.ts +96 -0
  496. package/src/modules/manufacturing/query/listManufacturingCostSummariesByStatus.ts +77 -0
  497. package/src/modules/manufacturing/query/listProductionOrdersByStatus.generated.ts +5 -0
  498. package/src/modules/manufacturing/query/listProductionOrdersByStatus.test.ts +121 -0
  499. package/src/modules/manufacturing/query/listProductionOrdersByStatus.ts +83 -0
  500. package/src/modules/manufacturing/query/listRoutingsByItem.generated.ts +5 -0
  501. package/src/modules/manufacturing/query/listRoutingsByItem.test.ts +110 -0
  502. package/src/modules/manufacturing/query/listRoutingsByItem.ts +54 -0
  503. package/src/modules/manufacturing/query/listWorkCentersBySite.generated.ts +5 -0
  504. package/src/modules/manufacturing/query/listWorkCentersBySite.test.ts +81 -0
  505. package/src/modules/manufacturing/query/listWorkCentersBySite.ts +70 -0
  506. package/src/modules/manufacturing/query/listWorkOrdersByProductionOrder.generated.ts +5 -0
  507. package/src/modules/manufacturing/query/listWorkOrdersByProductionOrder.test.ts +102 -0
  508. package/src/modules/manufacturing/query/listWorkOrdersByProductionOrder.ts +53 -0
  509. package/src/modules/manufacturing/query/listWorkOrdersByWorkCenter.generated.ts +5 -0
  510. package/src/modules/manufacturing/query/listWorkOrdersByWorkCenter.test.ts +143 -0
  511. package/src/modules/manufacturing/query/listWorkOrdersByWorkCenter.ts +56 -0
  512. package/src/modules/manufacturing/seed/index.ts +19 -0
  513. package/src/modules/manufacturing/tailor.config.ts +13 -0
  514. package/src/modules/manufacturing/tailor.d.ts +13 -0
  515. package/src/modules/manufacturing/testing/commandTestUtils.ts +29 -0
  516. package/src/modules/manufacturing/testing/fixtures.ts +402 -0
  517. package/src/progress/schema.test.ts +161 -0
  518. package/src/progress/schema.ts +316 -0
  519. package/templates/scaffold/app/backend/package.json +7 -2
  520. package/templates/scaffold/app/backend/src/tests/utils/graphql-client.ts +66 -0
  521. package/templates/scaffold/app/backend/src/tests/utils/setup.ts +21 -0
  522. package/templates/scaffold/app/backend/tsconfig.json +9 -2
  523. package/templates/scaffold/app/backend/vitest.config.ts +18 -0
  524. package/templates/scaffold/app/frontend/package.json +2 -2
  525. package/src/generator/generate-stubs.ts +0 -31
@@ -0,0 +1,83 @@
1
+ # Bill of Material Management
2
+
3
+ ## Overview
4
+
5
+ Bill of Material Management defines the production recipe for a finished good or subassembly. A `BillOfMaterial` specifies which component items are required, in what quantities and units, under which version or effectivity window, with which expected scrap assumptions, and with which `bomType` explosion behavior. The feature supports multi-level manufacturing by allowing a component line to reference another manufactured item that has its own BOM.
6
+
7
+ The BOM is manufacturing-owned master data, distinct from product templates and item identity. Product-management may describe the commercial definition of a product, and item-management owns the SKU that transactions reference, but manufacturing owns the recipe used to turn component stock into finished output. Production orders resolve and snapshot a BOM version at release time so future engineering changes do not silently alter in-flight work.
8
+
9
+ Each `BillOfMaterial` must declare `bomType` as one of `MANUFACTURE`, `PHANTOM`, or `KIT`:
10
+
11
+ - `MANUFACTURE`: The parent item is produced through the normal manufacturing path. BOM explosion preserves the parent as a make item, and released production orders may create lower-level production demand for manufactured child components according to planning policy.
12
+ - `PHANTOM`: The parent item is a logical subassembly used for engineering structure, but manufacturing does not create a separate production order, WIP bucket, or finished-stock receipt for the phantom itself. BOM explosion flattens the phantom's child lines directly into the nearest released parent production order.
13
+ - `KIT`: The parent item is an issue or packaging structure, not a shop-floor build recipe. BOM explosion produces component demand and picking or issue requirements only; it does not create routing-based work orders or a standalone manufacturing execution path for the kit parent.
14
+
15
+ ## Business Purpose
16
+
17
+ - Provide a single manufacturing-owned source of truth for how a finished good or subassembly is built
18
+ - Support multi-level production by reusing subassembly BOMs inside higher-level BOMs
19
+ - Classify BOMs by explosion behavior so the same structural master data can support make, phantom, and kit scenarios without redesign
20
+ - Preserve engineering change control through versions and effectivity windows rather than destructive edits
21
+ - Enable material requirement explosion for production-order planning and inventory handoff
22
+ - Capture expected scrap or yield assumptions used for planning and variance comparison
23
+ - Prevent inactive, circular, or invalid component structures from entering production execution
24
+
25
+ ## Process Flow
26
+
27
+ ```mermaid
28
+ flowchart TD
29
+ A[Create BillOfMaterial] --> B[Select finished item and company or site scope]
30
+ B --> C[Set bomType: MANUFACTURE, PHANTOM, or KIT]
31
+ C --> D[Add component lines with quantity, UoM, and scrap factor]
32
+ D --> E{Subassembly component?}
33
+ E -->|Yes| F[Reference manufactured child item BOM]
34
+ E -->|No| G[Use purchased or stocked component]
35
+ F --> H[Validate structure, effectivity, and circular references]
36
+ G --> H
37
+ H --> I{Valid?}
38
+ I -->|No| J[Correct line or version data]
39
+ J --> D
40
+ I -->|Yes| K[Activate BOM version]
41
+ K --> L[Production order or issue flow selects BOM]
42
+ L --> M{bomType?}
43
+ M -->|MANUFACTURE| N[Keep parent make item and snapshot recipe]
44
+ M -->|PHANTOM| O[Flatten child components into nearest parent order]
45
+ M -->|KIT| P[Explode to component issue list without work orders]
46
+ ```
47
+
48
+ ## Scenario Patterns
49
+
50
+ - **Standard assembly recipe**: A planner defines the component list and quantities for a finished good that is assembled repeatedly using the same standard recipe
51
+ - **Multi-level subassembly reuse**: A manufactured subassembly is defined once and referenced by several parent BOMs so planning can explode common lower-level demand consistently
52
+ - **Phantom subassembly flattening**: A logical intermediate assembly is maintained for engineering readability, but its children are exploded directly into the parent production order without generating a separate shop-floor order
53
+ - **Kit structure definition**: A bundled item keeps a BOM-owned component list for issue or packaging purposes while explicitly bypassing routing-based manufacturing execution
54
+ - **Engineering revision cutover**: A new BOM version becomes effective on a future date while the previous version remains valid for already released production orders
55
+ - **Site-specific recipe difference**: The same finished item has different default component mix or yield assumptions at two sites due to local equipment or supplier differences
56
+ - **Scrap-aware planning**: A BOM line includes expected process loss so planned component requirements better match real production behavior
57
+ - **Change freeze at release**: A production order snapshots the active BOM at release time so later BOM edits do not mutate in-flight manufacturing instructions
58
+
59
+ The `bomType` classification is part of the released BOM snapshot. A released order must preserve not only the selected component structure, but also the explosion semantics that were in force when the order was released. Later edits to convert a BOM from `PHANTOM` to `MANUFACTURE`, or from `KIT` to `MANUFACTURE`, must not retroactively rewire previously released orders.
60
+
61
+ ## Test Cases
62
+
63
+ - Creating a BOM for an ACTIVE finished item with at least one ACTIVE component line should succeed
64
+ - A BOM must require `bomType` to be one of `MANUFACTURE`, `PHANTOM`, or `KIT`
65
+ - A BOM line must require a positive component quantity and a unit of measure compatible with the component item definition
66
+ - A BOM must reject direct or indirect circular references between parent and child manufactured items
67
+ - Overlapping active BOM effectivity windows for the same finished item and scope should be rejected unless one version is explicitly non-default
68
+ - Inactive items must not be added as new BOM components
69
+ - A BOM can reference both stocked raw materials and manufactured subassemblies
70
+ - Releasing a `MANUFACTURE` BOM should preserve the parent item as a producible order output rather than flattening it away
71
+ - Releasing a `PHANTOM` BOM should flatten its child requirements into the nearest non-phantom parent order and must not create a separate production-order requirement for the phantom parent
72
+ - Selecting a `KIT` BOM should explode component demand without generating routing-based work orders for the kit parent
73
+ - Editing a BOM that is already snapshotted by a released production order must not change the snapshotted order recipe
74
+ - Editing `bomType` on an active BOM after release must not mutate the type semantics already snapshotted onto open production orders
75
+ - Deactivating a BOM version used by open production orders may prevent new selection but must not invalidate existing snapshots
76
+ - BOM explosion for a multi-level structure should produce the correct lower-level component requirements
77
+ - Only authorized manufacturing users should be able to create, revise, activate, or deactivate BOM versions
78
+
79
+ ## Reference Links
80
+
81
+ - [Odoo Manufacturing BOM configuration](https://www.odoo.com/documentation/19.0/applications/inventory_and_mrp/manufacturing/basic_setup/bill_configuration.html)
82
+ - [Oracle Manufacturing work definitions overview](https://docs.oracle.com/en/cloud/saas/supply-chain-and-manufacturing/25c/faumf/how-you-create-work-definitions.html)
83
+ - [Rootstock manufacturing ERP overview](https://www.rootstock.com/manufacturing-erp-software/)
@@ -0,0 +1,191 @@
1
+ # Manufacturing Cost and Variance
2
+
3
+ ## Overview
4
+
5
+ Manufacturing Cost and Variance captures the planned and actual cost footprint of a production order without taking ownership of accounting postings. At release time, the module snapshots expected component, labor, machine, and overhead assumptions based on the selected BOM, routing, work-center rates, and inventory-owned planned material cost resolution. During execution, it accumulates actual material consumption values sourced from the named `InventoryIssueOutcomeEvent` contract plus actual time and quantity data from work orders.
6
+
7
+ The feature compares actual results against the plan and classifies manufacturing variance so downstream accounting can decide how to post it. Manufacturing owns cost visibility at the order and operation level, including WIP-oriented progress context, but it does not create journal entries, settle balances, or close accounting periods. Those responsibilities remain outside the module. Manufacturing does, however, own the operational review lifecycle that blocks order close until variance review is complete and downstream accounting has acknowledged the settlement handoff.
8
+
9
+ Planned overhead is not entered ad hoc per production order. It is derived from the overhead absorption policy configured on each referenced `WorkCenter`, then snapshotted onto the production order at release alongside labor and machine assumptions. This keeps overhead calculation deterministic and aligned to the capacity resource that drives the cost.
10
+
11
+ Planned material cost is also not maintained as an editable manufacturing-owned field on BOM component lines in the initial scope. Manufacturing resolves the planned unit cost for each component from inventory-owned valuation data at release time, snapshots the resolved amount onto the production order cost baseline, and preserves that baseline even if valuation settings later change.
12
+
13
+ ## Business Purpose
14
+
15
+ - Give planners and supervisors visibility into whether production is running to expected cost
16
+ - Preserve the standard or planned cost assumptions that were in force when work was released
17
+ - Distinguish price, usage, rate, efficiency, scrap, and yield-related variances at a level that downstream accounting can map to separate review or posting treatment
18
+ - Support WIP-style progress visibility without forcing manufacturing to own general-ledger behavior
19
+ - Provide a downstream accounting handoff contract backed by operational evidence rather than manual spreadsheet reconciliation
20
+ - Make post-order review and continuous improvement possible through cost and variance history
21
+ - Use an explicit overhead absorption rule so planned and actual overhead can be reproduced consistently during review
22
+
23
+ ## Process Flow
24
+
25
+ ```mermaid
26
+ flowchart TD
27
+ A[Release Production Order] --> B[Snapshot planned material, labor, machine, and overhead cost]
28
+ B --> C[Execute material issues through inventory]
29
+ C --> D[Inventory emits InventoryIssueOutcomeEvent when issue valuation is final]
30
+ D --> E[Collect actual time and quantity from work orders]
31
+ E --> F[Accumulate actual cost by production order]
32
+ F --> G{Order completed?}
33
+ G -->|No| H[Show in-progress WIP-style cost view]
34
+ G -->|Yes| I[Order becomes TECHNICALLY_COMPLETE]
35
+ I --> J[PENDING_VARIANCE_REVIEW]
36
+ J --> K[Compare planned vs actual]
37
+ K --> L[Classify price, usage, rate, efficiency, scrap, and yield variance]
38
+ L --> M[VARIANCE_REVIEWED]
39
+ M --> N[Publish reviewed manufacturing cost summary for downstream accounting]
40
+ N --> O[SETTLED after downstream settlement acknowledgment]
41
+ ```
42
+
43
+ Each production order owns one manufacturing cost summary that moves through a named lifecycle after execution is frozen. The initial scope uses these states:
44
+
45
+ - `COLLECTING`: Planned baseline is snapshotted and actual material, labor, machine, and overhead evidence is still accumulating while the order is `RELEASED`, `IN_PROGRESS`, or `COMPLETED`
46
+ - `PENDING_VARIANCE_REVIEW`: The production order has reached `TECHNICALLY_COMPLETE`, final variance can be calculated, and review is required before administrative close
47
+ - `VARIANCE_REVIEWED`: An authorized reviewer has approved the final planned-versus-actual comparison, variance classification, and downstream handoff payload
48
+ - `SETTLED`: Downstream accounting or financial close processing has acknowledged the reviewed handoff and the order is now eligible for final administrative close
49
+
50
+ The allowed transitions are:
51
+
52
+ - `COLLECTING -> PENDING_VARIANCE_REVIEW`
53
+ - `PENDING_VARIANCE_REVIEW -> VARIANCE_REVIEWED`
54
+ - `VARIANCE_REVIEWED -> SETTLED`
55
+
56
+ The following enforcement rules apply:
57
+
58
+ - A production order entering `TECHNICALLY_COMPLETE` must move its linked cost summary to `PENDING_VARIANCE_REVIEW`
59
+ - `VARIANCE_REVIEWED` requires final variance recalculation against the frozen order baseline and an explicit reviewer action by a manufacturing or finance-review role
60
+ - `SETTLED` requires a named downstream acknowledgment that the reviewed variance or WIP handoff was consumed by the accounting-owned settlement process; manufacturing records the acknowledgment but does not post the settlement itself
61
+ - A production order must not transition from `TECHNICALLY_COMPLETE` to `CLOSED` until the linked cost summary is `SETTLED`
62
+ - If execution must resume after review begins, the production order must be reopened and the cost summary must return to `COLLECTING` or a superseded draft state through a controlled workflow
63
+
64
+ ## Scenario Patterns
65
+
66
+ - **Standard-cost comparison**: A production order is released using standard component and work-center assumptions, then reviewed against actual execution cost after completion
67
+ - **Labor rate change**: Actual labor is booked at a different rate than the snapped standard, and the delta is isolated from pure time-overrun effects
68
+ - **Labor or machine overrun**: An operation takes materially longer than its standard time, and the excess resource consumption is exposed as an efficiency variance instead of being mixed into a rate variance
69
+ - **Material price change**: Inventory issues the same planned quantity at a different actual unit valuation than the snapped standard, and the delta is tracked separately from quantity over-consumption
70
+ - **Material loss variance**: Actual issued component quantity exceeds the BOM expectation because of setup loss, damage, or poor yield, and the excess is tracked as usage rather than price variance
71
+ - **Scrap-heavy production run**: Scrap reported during execution inflates actual cost per good unit and is classified separately from normal usage
72
+ - **In-progress cost visibility**: Supervisors review cost accumulation on an order that has started but not yet completed to see whether it is trending off plan
73
+ - **Accounting handoff after review**: Manufacturing finishes variance review, publishes summarized planned-versus-actual results for downstream accounting, and waits for settlement acknowledgment before the order can close
74
+ - **Work-center overhead absorption**: Each work center may define one active overhead absorption rule, and released orders snapshot that rule so planned and actual overhead remain reproducible even if work-center master data changes later
75
+
76
+ Manufacturing resolves each component's planned material cost through inventory-owned valuation contracts at release time. The required source rules are:
77
+
78
+ - Manufacturing must query inventory for the component item's active valuation context at the production order's site or company scope
79
+ - If the item's `ValuationPolicy.costingMethod` is `STANDARD_COST`, the planned unit cost must come from inventory's `ValuationPolicy.standardCostRate`
80
+ - If the item's costing method is `AVCO` or `FIFO`, the planned unit cost baseline must come from inventory's current `GetItemValuation.costPerUnit` at release time
81
+ - Manufacturing must snapshot the returned unit cost, currency, valuation method, and source valuation reference onto the released production order and must not recompute the baseline from later inventory changes
82
+ - If inventory cannot resolve planned material cost for a required component, production-order release must be rejected rather than allowing manufacturing to invent a fallback cost
83
+
84
+ This makes inventory the source of truth for planned material valuation while allowing manufacturing to own the frozen release-time baseline used for later variance comparison.
85
+
86
+ Manufacturing consumes actual material cost only through the named `InventoryIssueOutcomeEvent` contract emitted by inventory after a goods issue or backflush movement reaches its inventory-owned final valuation state. The minimum payload is:
87
+
88
+ - `productionOrderReference`
89
+ - `workOrderReference`: optional for issue transactions recorded at order level rather than operation level
90
+ - `inventoryIssueReference`
91
+ - `itemReference`
92
+ - `issuedQuantity`
93
+ - `unitOfMeasure`
94
+ - `actualUnitCost`
95
+ - `actualExtendedCost`
96
+ - `currency`
97
+ - `valuationMethod`
98
+ - `postingDate`
99
+ - `siteReference`
100
+
101
+ Optional and conditional fields:
102
+
103
+ - `inventoryLotReference`: optional unless the issued quantity is lot-specific and manufacturing needs lot-cost traceability
104
+ - `costLayerReferences`: optional list of cost-layer identifiers when valuation methods such as FIFO require traceability to multiple inventory layers
105
+ - `issueMode`: optional classification such as `MANUAL_ISSUE` or `BACKFLUSH` for cost analysis without changing the financial result
106
+
107
+ Inventory emits `InventoryIssueOutcomeEvent` only after the issue transaction is accepted, executed, and valued by inventory-owned logic. Manufacturing must not infer actual material cost from the issue request itself, from open stock movements, or from duplicated valuation formulas. If inventory rejects or has not yet valued the issue, manufacturing keeps the material cost pending rather than manufacturing its own fallback amount.
108
+
109
+ When a cost summary reaches `VARIANCE_REVIEWED`, manufacturing publishes the reviewed settlement handoff to downstream accounting and waits for the named `ManufacturingCostSettlementAcknowledgment` contract before allowing the summary to move to `SETTLED`. The acknowledgment contract is owned and emitted by the downstream accounting or financial-close module or service, not by manufacturing. Manufacturing may persist the received acknowledgment for auditability, but it must not fabricate, edit, or mark the acknowledgment as received through a manufacturing-only toggle.
110
+
111
+ The minimum `ManufacturingCostSettlementAcknowledgment` payload is:
112
+
113
+ - `productionOrderReference`
114
+ - `costSummaryReference`
115
+ - `settledByReference`
116
+ - `settlementDate`
117
+ - `currency`
118
+
119
+ Optional and conditional fields:
120
+
121
+ - `settlementReference`: optional downstream settlement batch, journal, or close-run identifier used to trace the accounting-side action
122
+ - `settledAmount`: optional when accounting settles an explicit amount and required if downstream policy allows partial or currency-translated settlement evidence
123
+ - `companyReference`: optional when company scope is derivable from the production order and required otherwise
124
+ - `siteReference`: optional when the settlement applies at company scope rather than site scope
125
+ - `variancePostingReference`: optional identifier for the downstream posting or variance document created from the reviewed handoff
126
+
127
+ The following contract rules apply:
128
+
129
+ - `ManufacturingCostSettlementAcknowledgment` must reference a cost summary already in `VARIANCE_REVIEWED`; an acknowledgment for any earlier lifecycle state is invalid
130
+ - The payload must match the reviewed handoff's `productionOrderReference`, `costSummaryReference`, and settlement currency before manufacturing can transition the cost summary to `SETTLED`
131
+ - If downstream accounting rejects, reverses, or supersedes the reviewed handoff, the cost summary must remain `VARIANCE_REVIEWED` until a valid replacement acknowledgment is received
132
+ - `TECHNICALLY_COMPLETE -> CLOSED` remains blocked until manufacturing records a valid `ManufacturingCostSettlementAcknowledgment` for the linked cost summary
133
+
134
+ The `CostVariance` taxonomy must be granular enough to avoid mixing price deltas with usage or efficiency deltas. The initial scope replaces the coarse `material` and `labor_machine` buckets with the following categories:
135
+
136
+ - `MATERIAL_PRICE`: Actual material unit valuation differs from the snapped planned unit cost for the consumed quantity
137
+ - `MATERIAL_USAGE`: Actual material quantity consumed differs from the BOM-based planned quantity after normalizing to the snapped planned unit cost
138
+ - `LABOR_RATE`: Actual labor cost-per-hour differs from the snapped labor rate for the reported hours
139
+ - `LABOR_EFFICIENCY`: Actual labor hours differ from the snapped standard hours after normalizing to the snapped labor rate
140
+ - `MACHINE_RATE`: Actual machine rate differs from the snapped machine cost rate for the reported machine hours
141
+ - `MACHINE_EFFICIENCY`: Actual machine hours differ from the snapped standard machine hours after normalizing to the snapped machine rate
142
+ - `SCRAP`: Cost attributable to reported scrap transactions that should remain visible separately from normal material usage
143
+ - `YIELD`: Cost impact caused by producing fewer good units than planned after material and resource consumption are applied
144
+
145
+ Each variance category must support a distinct downstream variance-account reference from `coa-management`. Manufacturing owns the classification and reference data needed for handoff, while downstream accounting decides whether to post, aggregate, or settle those balances.
146
+
147
+ Manufacturing supports a single active overhead absorption rule per `WorkCenter`. The policy is owned by manufacturing as part of `WorkCenter` master data because the rate follows the resource or line used to perform work, not the warehouse or accounting module. A work center may define:
148
+
149
+ - `overheadAbsorptionMethod`: one of `PERCENT_OF_LABOR_COST`, `PERCENT_OF_MACHINE_COST`, or `FIXED_AMOUNT_PER_GOOD_UNIT`
150
+ - `overheadAbsorptionRate`: the numeric rate or amount interpreted by the selected method
151
+ - `overheadAbsorptionCurrency`: required when the method is `FIXED_AMOUNT_PER_GOOD_UNIT`
152
+
153
+ The initial scope uses these rules:
154
+
155
+ - `PERCENT_OF_LABOR_COST`: planned or actual overhead equals labor cost multiplied by the configured percentage
156
+ - `PERCENT_OF_MACHINE_COST`: planned or actual overhead equals machine cost multiplied by the configured percentage
157
+ - `FIXED_AMOUNT_PER_GOOD_UNIT`: planned or actual overhead equals good quantity reported multiplied by the configured amount per unit
158
+
159
+ When a production order is released, manufacturing snapshots the resolved work-center overhead method, rate, and currency onto the order or operation cost baseline. Later edits to the work center must not mutate released orders. During execution, actual overhead uses the same snapped method with actual reported labor cost, machine cost, or completed good quantity as the driver. Work centers without an overhead absorption rule contribute zero planned and zero actual overhead.
160
+
161
+ ## Test Cases
162
+
163
+ - Releasing a production order must snapshot the planned material and routing-based cost assumptions used for later variance comparison
164
+ - Releasing a production order must resolve each component's planned unit cost from inventory-owned valuation data rather than from a manufacturing-edited BOM cost field
165
+ - A STANDARD_COST component must snapshot inventory `ValuationPolicy.standardCostRate` as its planned unit cost at release
166
+ - An AVCO or FIFO component must snapshot the release-time `GetItemValuation.costPerUnit` returned by inventory as its planned unit cost baseline
167
+ - Production-order release must be rejected when inventory cannot resolve planned material cost for a required component
168
+ - Actual material cost used by manufacturing must come from `InventoryIssueOutcomeEvent` rather than duplicated manufacturing-owned valuation logic
169
+ - `InventoryIssueOutcomeEvent` must not be accepted as actual material cost input until the referenced inventory issue has completed inventory-owned valuation
170
+ - Actual labor or machine cost should derive from reported time and the applicable work-center rates in force for the order snapshot
171
+ - Moving a cost summary to `PENDING_VARIANCE_REVIEW` should require that the parent production order is `TECHNICALLY_COMPLETE`
172
+ - Moving a cost summary to `VARIANCE_REVIEWED` should require an explicit reviewer approval and freeze the reviewed variance breakdown unless the order is reopened
173
+ - Moving a cost summary to `SETTLED` should require a valid `ManufacturingCostSettlementAcknowledgment` rather than a manufacturing-only toggle
174
+ - Planned overhead must derive from the released work center's snapped `overheadAbsorptionMethod` and `overheadAbsorptionRate`
175
+ - Editing a work center's overhead absorption rule after release must not change the planned overhead baseline of an already released production order
176
+ - Actual overhead must use the same snapped absorption method as the plan, substituting actual labor cost, machine cost, or completed good quantity as the driver
177
+ - Planned and actual cost must be tracked independently per production order and company
178
+ - Completing additional work after an order is marked closed should be rejected or require a controlled reopening workflow
179
+ - Variance calculation should separate at minimum `MATERIAL_PRICE`, `MATERIAL_USAGE`, `LABOR_RATE`, `LABOR_EFFICIENCY`, and distinct scrap or yield-related causes rather than combining them into a single material or labor bucket
180
+ - Variance handoff data must retain the variance category and its mapped variance-account reference for every published variance line
181
+ - An in-progress production order should expose accumulated actual cost even before full completion
182
+ - Manufacturing must not create journal entries or mutate GL balances directly as part of variance calculation
183
+ - Downstream accounting handoff data should retain references to the production order, site, finished item, completed quantity, and variance breakdown
184
+ - Manufacturing must not transition a reviewed cost summary to `SETTLED` until `ManufacturingCostSettlementAcknowledgment` is received from the accounting-owned settlement process with matching order and cost-summary references
185
+ - Only authorized manufacturing or finance-review users should be able to finalize cost review, mark the summary `VARIANCE_REVIEWED`, and advance the order toward administrative close
186
+
187
+ ## Reference Links
188
+
189
+ - [Oracle work orders overview](https://docs.oracle.com/en/cloud/saas/supply-chain-and-manufacturing/25d/faumf/overview-of-work-orders.html)
190
+ - [MRPeasy manufacturing scheduling and costing overview](https://www.mrpeasy.com/manufacturing-scheduling-software/)
191
+ - [Rootstock manufacturing ERP overview](https://www.rootstock.com/manufacturing-erp-software/)
@@ -0,0 +1,103 @@
1
+ # Production Order Lifecycle
2
+
3
+ ## Overview
4
+
5
+ Production Order Lifecycle governs how a manufacturing request is created, planned, released, executed, and closed. A `ProductionOrder` records what item should be produced, at what quantity, for which company and site, against which BOM and routing definition, and on which planned dates. It is the manufacturing control document that turns a planning decision into executable shop-floor work.
6
+
7
+ The production order tracks both control state and execution progress. Release freezes the selected BOM and routing into an order snapshot, generates operation-level work orders, and prepares material requirements for inventory coordination. Subsequent work-order reporting, material issue, scrap, and completion update production progress until the order is physically completed, marked `TECHNICALLY_COMPLETE` for cost and administrative review, and then formally closed.
8
+
9
+ ## Business Purpose
10
+
11
+ - Turn manual planner intent or upstream demand signals into a controlled manufacturing commitment
12
+ - Freeze recipe and process assumptions at release time so execution stays auditable
13
+ - Provide a single source of truth for planned quantity, completed quantity, scrap quantity, and remaining open work
14
+ - Coordinate material readiness, work-order generation, and production scheduling around one document
15
+ - Support make-to-stock and make-to-order scenarios without moving sales or purchasing ownership into manufacturing
16
+ - Prevent incomplete, invalid, or unauthorized production requests from reaching execution
17
+
18
+ ## Process Flow
19
+
20
+ ```mermaid
21
+ flowchart TD
22
+ A[Create Production Order] --> B[DRAFT]
23
+ B --> C[Select item, quantity, site, BOM, routing, and dates]
24
+ C --> D{Ready to release?}
25
+ D -->|No| C
26
+ D -->|Yes| E[RELEASED]
27
+ E --> F[Snapshot BOM and routing]
28
+ F --> G[Generate work orders and material requirements]
29
+ G --> H{Execution started?}
30
+ H -->|No| I[Remain RELEASED or reschedule]
31
+ H -->|Yes| J[IN_PROGRESS]
32
+ J --> K{Completed quantity and final receipt posted?}
33
+ K -->|No| J
34
+ K -->|Yes| L[COMPLETED]
35
+ L --> M[Freeze execution and mark TECHNICALLY_COMPLETE]
36
+ M --> N[Review variances and administrative exceptions]
37
+ N --> O{Cost review settled?}
38
+ O -->|No| N
39
+ O -->|Yes| P[CLOSED]
40
+ B --> Q[CANCELLED]
41
+ E --> Q
42
+ ```
43
+
44
+ The `ProductionOrder.status` lifecycle in the initial scope is:
45
+
46
+ - `DRAFT`: Planner can create, edit, or delete the order before any execution commitment exists
47
+ - `RELEASED`: BOM and routing are snapshotted, work orders are generated, and the order is ready for shop-floor execution
48
+ - `IN_PROGRESS`: At least one work order has started or execution evidence exists against the order
49
+ - `COMPLETED`: Physical production is complete because required work orders, final output reporting, and finished-goods receipt handoff have been submitted
50
+ - `TECHNICALLY_COMPLETE`: The order is execution-frozen and no additional production activity is expected, but cost review, variance approval, and downstream accounting handoff are still pending
51
+ - `CLOSED`: Administrative close is finished after the linked manufacturing cost summary reaches its required settled state
52
+ - `CANCELLED`: The order is abandoned before meaningful execution and cannot accept further execution updates
53
+
54
+ The allowed transitions are:
55
+
56
+ - `DRAFT -> RELEASED`
57
+ - `DRAFT -> CANCELLED`
58
+ - `RELEASED -> IN_PROGRESS`
59
+ - `RELEASED -> CANCELLED`
60
+ - `RELEASED -> DRAFT` only through an explicit controlled unrelease or replan workflow if no execution evidence exists
61
+ - `IN_PROGRESS -> COMPLETED`
62
+ - `COMPLETED -> TECHNICALLY_COMPLETE`
63
+ - `TECHNICALLY_COMPLETE -> CLOSED`
64
+
65
+ The following gating rules apply:
66
+
67
+ - `COMPLETED` requires all mandatory work orders complete plus the final output reporting and receipt handoff required by policy
68
+ - `TECHNICALLY_COMPLETE` requires that no additional execution, rescheduling, or material issue is still expected on the order
69
+ - `CLOSED` requires the linked manufacturing cost summary to finish variance review and reach its settled lifecycle state through a recorded `ManufacturingCostSettlementAcknowledgment`
70
+ - Any attempt to resume execution after `TECHNICALLY_COMPLETE` must use a controlled reopen workflow rather than direct shop-floor updates
71
+
72
+ ## Scenario Patterns
73
+
74
+ - **Make-to-stock replenishment**: A planner creates a production order to rebuild finished-goods inventory to target levels without linking ownership to a specific sales order
75
+ - **Demand-driven production**: A production order is created in response to prioritized downstream demand while remaining a manufacturing-owned document
76
+ - **Release after shortage review**: A planner keeps the order in draft until material availability and work-center timing are acceptable, then releases it for execution
77
+ - **Reschedule before execution**: A released order is moved to a later date because a bottleneck work center or inbound material is not ready yet
78
+ - **Partial completion**: A production order reports some finished quantity and scrap before the remaining balance is completed later
79
+ - **Cancellation before execution**: A production order is cancelled because demand disappears and no meaningful execution or inventory posting has occurred yet
80
+ - **Technical completion before close**: The order finishes physical production, then enters `TECHNICALLY_COMPLETE` so cost review and downstream settlement can occur without reopening shop-floor execution
81
+ - **Close after review**: The order is closed only after variance review, `ManufacturingCostSettlementAcknowledgment`, and administrative checks are finished
82
+
83
+ ## Test Cases
84
+
85
+ - Creating a production order for an ACTIVE manufactured item with positive quantity and valid company or site scope should succeed
86
+ - A production order must not be released without an ACTIVE BOM and ACTIVE routing selection or resolvable default
87
+ - Releasing a production order must snapshot the chosen BOM and routing definitions onto the order
88
+ - Releasing a production order must create the expected work-order structure based on the snapshotted routing operations
89
+ - A cancelled production order must not accept new execution updates
90
+ - Rescheduling a production order should be allowed before execution starts and must remain auditable after release
91
+ - Execution progress on work orders must roll up to production-order started, partial, or completed state correctly
92
+ - Completing a production order should require final output reporting and the finished-goods receipt handoff required by policy
93
+ - Marking a production order `TECHNICALLY_COMPLETE` should require that all planned execution is done and should block further shop-floor reporting unless the order is formally reopened
94
+ - Closing a production order should be blocked while open work orders or unresolved execution exceptions remain
95
+ - Closing a production order should be blocked until the linked manufacturing cost summary reaches `SETTLED` through a valid `ManufacturingCostSettlementAcknowledgment`
96
+ - Production-order data must be isolated by company and must not reference BOMs, routings, or work centers from another company
97
+ - Only authorized manufacturing users should be able to release, cancel, complete, technically complete, or close production orders
98
+
99
+ ## Reference Links
100
+
101
+ - [Oracle work orders overview](https://docs.oracle.com/en/cloud/saas/supply-chain-and-manufacturing/25d/faumf/overview-of-work-orders.html)
102
+ - [Odoo manufacturing features](https://www.odoo.com/app/manufacturing-features)
103
+ - [SAP S/4HANA Cloud manufacturing overview](https://help.sap.com/docs/SAP_S4HANA_CLOUD/2bba750d1e124e1ea2a039bb1cd9b6c5/03659e8e0c9d4f37afb3c5f3b37cabc3.html)
@@ -0,0 +1,63 @@
1
+ # Routing and Work Center Definition
2
+
3
+ ## Overview
4
+
5
+ Routing and Work Center Definition captures how manufacturing work is performed and where capacity exists to perform it. A `Routing` defines the ordered set of operations required to produce an item, including sequence, standard setup or run times, instructions, and the work center expected to execute each step. A `WorkCenter` represents the machine, line, cell, or labor pool where operations are scheduled and reported.
6
+
7
+ This feature establishes the execution structure used by production orders and work orders. Routing and work-center data drive planned lead time, operation sequencing, standard labor or machine cost, optional overhead absorption policy, and the work-order breakdown created when a production order is released. The initial scope supports deterministic step sequencing and capacity context, while deferring advanced optimization, parallel routing logic, and outsourced operations.
8
+
9
+ ## Business Purpose
10
+
11
+ - Define a repeatable manufacturing process for each produced item or family of items
12
+ - Associate each operation with the capacity and cost context required for planning and execution
13
+ - Support realistic planned duration and standard-cost estimation before work begins
14
+ - Provide operators and supervisors with step-level instructions and expected execution order
15
+ - Create the basis for work-order generation and progress tracking at operation level
16
+ - Prevent production from being released against incomplete or inactive process definitions
17
+
18
+ ## Process Flow
19
+
20
+ ```mermaid
21
+ flowchart TD
22
+ A[Create WorkCenter] --> B[Set company or site scope, calendar, capacity, and rates]
23
+ B --> C[Activate WorkCenter]
24
+ C --> D[Create Routing]
25
+ D --> E[Add ordered operations with standard times and instructions]
26
+ E --> F[Assign each operation to a WorkCenter]
27
+ F --> G{Valid sequence and active centers?}
28
+ G -->|No| H[Correct routing or work-center data]
29
+ H --> E
30
+ G -->|Yes| I[Activate Routing]
31
+ I --> J[Production order selects routing]
32
+ J --> K[Release creates work orders by operation]
33
+ ```
34
+
35
+ ## Scenario Patterns
36
+
37
+ - **Single-line assembly flow**: A finished item uses a simple routing with cut, assemble, inspect, and pack operations assigned to distinct work centers
38
+ - **Shared bottleneck center**: Several routings reference the same constrained work center, allowing planners to see where capacity pressure will accumulate
39
+ - **Site-specific process**: The same manufactured item uses different routings at different sites because local equipment or labor specialization differs
40
+ - **Instruction-driven operation**: An operation stores setup notes, drawings, or SOP-style instructions so execution users know the expected method
41
+ - **Standard-time planning**: Standard setup and run time on routing operations provide the planned duration used for release and variance comparison
42
+ - **Resource-based overhead policy**: A work center defines the overhead absorption method and rate used by manufacturing cost snapshots for orders executed on that resource
43
+ - **Controlled process revision**: A routing is revised for future orders while open production orders continue using the snapshotted process they were released with
44
+
45
+ ## Test Cases
46
+
47
+ - Creating a work center with a unique code within its company or site scope should succeed
48
+ - A work center must require positive capacity assumptions and must not be activated while missing required calendar or status data
49
+ - Creating a routing with at least one operation assigned to an ACTIVE work center should succeed
50
+ - Routing operation sequence numbers must be unique within the routing
51
+ - An ACTIVE routing must reject references to inactive or cross-company work centers
52
+ - Standard setup and run times on an operation must be zero or greater
53
+ - A work center may define one overhead absorption method and rate, which released production orders snapshot for later cost comparison
54
+ - Releasing a production order should snapshot the selected routing and operation definitions onto generated work orders
55
+ - Editing a routing after a production order is released must not mutate the released order's operation plan
56
+ - Deactivating a work center that is referenced by future routings or open released work should be blocked or require controlled replacement
57
+ - Only authorized manufacturing users should be able to activate, revise, or deactivate work centers and routings
58
+
59
+ ## Reference Links
60
+
61
+ - [Odoo work centers and operations](https://www.odoo.com/documentation/19.0/applications/inventory_and_mrp/manufacturing/advanced_configuration/using_work_centers.html)
62
+ - [Oracle Manufacturing work definitions](https://docs.oracle.com/en/cloud/saas/supply-chain-and-manufacturing/25c/faumf/how-you-create-work-definitions.html)
63
+ - [SAP Digital Manufacturing routing documentation](https://help.sap.com/docs/sap-digital-manufacturing/execution/routing)
@@ -0,0 +1,115 @@
1
+ # Work Order Execution
2
+
3
+ ## Overview
4
+
5
+ Work Order Execution tracks the operation-level progress of manufacturing work after a production order is released. A `WorkOrder` represents one executable routing step with assigned work-center context, planned quantity, status, actual start or finish data, and the execution evidence needed to move the parent production order forward. Work orders provide the operational unit for supervisors and operators to start, pause, report, and complete shop-floor activity.
6
+
7
+ This feature also defines how manufacturing coordinates with inventory during execution. Material issue may occur explicitly before work starts or implicitly through backflush on completion, while final or intermediate output completion triggers receipt handoff to inventory. Scrap reported during execution can also trigger an inventory scrap handoff. Manufacturing owns the operational intent and recorded progress; inventory owns stock movement persistence, lot or serial state, and valuation consequences.
8
+
9
+ ## Business Purpose
10
+
11
+ - Break a released production order into operation-level executable steps with clear status and ownership
12
+ - Provide auditable tracking of actual start, stop, completion, quantity, time, and scrap at each operation
13
+ - Support both manual material issue and backflush-style material consumption
14
+ - Coordinate finished-goods or intermediate receipt with inventory without embedding warehouse ownership in manufacturing
15
+ - Expose operation-level exceptions that explain why production is late, paused, or under-yielding
16
+ - Roll execution progress into parent production-order status and cost collection
17
+
18
+ ## Process Flow
19
+
20
+ ```mermaid
21
+ flowchart TD
22
+ A[Production Order Released] --> B[Open Work Orders by Operation]
23
+ B --> C[Start Work Order]
24
+ C --> D{Manual issue required?}
25
+ D -->|Yes| E[Send material issue request to inventory]
26
+ D -->|No| F[Continue execution]
27
+ E --> F
28
+ F --> G[Report time, completed qty, and scrap]
29
+ G --> H{Backflush at completion?}
30
+ H -->|Yes| I[Send backflush issue request to inventory]
31
+ H -->|No| J[Keep manual issue basis]
32
+ I --> J
33
+ J --> K{Final or intermediate output complete?}
34
+ K -->|Yes| L[Send production receipt handoff to inventory]
35
+ K -->|No| M[Move to next operation]
36
+ L --> M
37
+ M --> N{All required operations complete?}
38
+ N -->|No| C
39
+ N -->|Yes| O[Parent Production Order progresses toward completion]
40
+ ```
41
+
42
+ ## Scenario Patterns
43
+
44
+ - **Pre-issued materials**: Components are issued to the line before the first operation starts, and the work order records execution without backflushing those same quantities again
45
+ - **Backflush assembly**: Standard components are consumed automatically when an operation or order reports completion, reducing operator transaction burden
46
+ - **Partial operation reporting**: An operator reports some completed quantity and some scrap, leaving the work order open for the remaining balance
47
+ - **Paused bottleneck operation**: A work order is started, paused due to machine or staffing constraints, and later resumed with the pause history preserved
48
+ - **Intermediate output step**: A routing produces an intermediate quantity at one operation that must be receipted before the next step continues
49
+ - **Final receipt handoff**: The final operation completes and sends finished-goods receipt intent to inventory while keeping manufacturing as the owner of execution evidence
50
+ - **Manufacturing scrap handoff**: A work order reports nonrecoverable scrap and sends a named scrap contract to inventory so stock and valuation can be reduced through the inventory-owned adjustment flow
51
+ - **Exception note capture**: A supervisor records an exception reason on a delayed or abnormal work order to explain variance and schedule slippage
52
+
53
+ Manufacturing uses two named handoff contracts during execution. `ManufacturingReceiptHandoff` is sent when a work order reports intermediate or finished output that must be receipted into inventory. The minimum payload is:
54
+
55
+ - `productionOrderReference`
56
+ - `workOrderReference`
57
+ - `itemReference`
58
+ - `quantity`
59
+ - `unitOfMeasure`
60
+ - `siteReference`
61
+ - `postingDate`
62
+
63
+ Optional and conditional fields:
64
+
65
+ - `finishedGoodLotReference`: optional for non-lot-tracked items and required when the receipted item is lot-tracked
66
+ - `storageLocationReference`: optional when inventory can derive the receiving location from site or production policy; otherwise required
67
+ - `serialReferences`: required when the receipted item is serial-tracked and serial numbers are assigned before inventory confirmation
68
+
69
+ Inventory owns final lot, serial, and storage persistence. Manufacturing owns only the execution evidence and the handoff intent. The same receipt handoff contract is used for both intermediate and final receipts.
70
+
71
+ `ManufacturingScrapHandoff` is sent when a work order reports scrap that must reduce usable stock in inventory. The minimum payload is:
72
+
73
+ - `productionOrderReference`
74
+ - `workOrderReference`
75
+ - `itemReference`
76
+ - `scrapQuantity`
77
+ - `unitOfMeasure`
78
+ - `scrapReasonCode`
79
+ - `siteReference`
80
+ - `postingDate`
81
+
82
+ Optional and conditional fields:
83
+
84
+ - `sourceStorageLocationReference`: optional when inventory can derive the source location from prior issue or backflush context, or from a site-level manufacturing scrap policy; otherwise required
85
+ - `inventoryLotReference`: required when the scrapped item is lot-tracked
86
+ - `serialReferences`: required when the scrapped item is serial-tracked
87
+ - `scrapDispositionCode`: optional classification used by downstream inventory or accounting policies
88
+
89
+ Manufacturing creates the handoff once per submitted scrap transaction. Inventory is responsible for translating the handoff into an inventory-owned `InventoryAdjustment` approval flow and for rejecting the handoff if location, lot, or serial resolution is incomplete.
90
+
91
+ For any stock-loss event that originates from manufacturing execution and can be traced to a `productionOrderReference` or `workOrderReference`, `ManufacturingScrapHandoff` is the only valid inventory path in the initial scope. A direct inventory `InventoryAdjustment` with reason code `Production Variance` is reserved for fallback situations where the manufacturing module is not deployed or the discrepancy is discovered after the fact with no resolvable manufacturing source document. This rule prevents the same physical production loss from being posted through two asymmetric flows and preserves work-order traceability.
92
+
93
+ ## Test Cases
94
+
95
+ - Starting a work order should succeed only when its parent production order is in a releasable execution state
96
+ - A work order must not be completed before it is started unless an explicit bypass policy exists
97
+ - Reported completed quantity and scrap quantity must be zero or greater, and at least one must be positive for a completion transaction
98
+ - Completing a work order must update parent production-order progress correctly
99
+ - Material issue requested manually from manufacturing must call the downstream inventory contract exactly once per submitted issue transaction
100
+ - Backflush consumption must not duplicate quantities already issued manually
101
+ - Final or intermediate receipt handoff payloads must include production-order reference, work-order reference, item reference, quantity, unit of measure, site, and posting date at minimum
102
+ - Receipt handoff must include `finishedGoodLotReference` whenever the receipted item is lot-tracked
103
+ - Reporting positive scrap quantity must emit `ManufacturingScrapHandoff` exactly once per submitted scrap transaction
104
+ - Scrap handoff payloads must include production-order reference, work-order reference, item reference, scrap quantity, unit of measure, scrap reason code, site, and posting date at minimum
105
+ - Manufacturing-originated stock loss with a resolvable production-order or work-order reference must not bypass `ManufacturingScrapHandoff` through a direct inventory adjustment
106
+ - A paused work order must be resumable without losing prior execution history
107
+ - Completing a later sequential operation before a required earlier operation should be rejected unless the routing policy explicitly allows it
108
+ - Work-order execution must remain isolated by company and site context
109
+ - Only authorized manufacturing users should be able to start, pause, resume, report, or complete work orders
110
+
111
+ ## Reference Links
112
+
113
+ - [Oracle work orders overview](https://docs.oracle.com/en/cloud/saas/supply-chain-and-manufacturing/25d/faumf/overview-of-work-orders.html)
114
+ - [Odoo work centers and manufacturing execution concepts](https://www.odoo.com/documentation/19.0/applications/inventory_and_mrp/manufacturing/advanced_configuration/using_work_centers.html)
115
+ - [SAP Digital Manufacturing execution routing](https://help.sap.com/docs/sap-digital-manufacturing/execution/routing)
@@ -0,0 +1,60 @@
1
+ # BillOfMaterial
2
+
3
+ ## Description
4
+
5
+ BillOfMaterial stores the manufacturing-owned recipe used to build one finished item or subassembly at company or site scope. It owns version identity, effectivity, `bomType`, default-selection behavior, and the component-line structure that production orders later snapshot at release time.
6
+
7
+ ## Domain Model Definitions
8
+
9
+ ### Model type
10
+
11
+ Stateful
12
+
13
+ #### State Transitions
14
+
15
+ ```mermaid
16
+ stateDiagram-v2
17
+ [*] --> Draft: createBillOfMaterial
18
+ Draft --> Draft: updateBillOfMaterial
19
+ Draft --> Active: activateBillOfMaterial
20
+ Active --> Inactive: deactivateBillOfMaterial
21
+ ```
22
+
23
+ ### Command Definitions
24
+
25
+ - [createBillOfMaterial](../commands/CreateBillOfMaterial.md) - Create a draft BOM version for one manufactured parent item.
26
+ - [updateBillOfMaterial](../commands/UpdateBillOfMaterial.md) - Revise mutable draft metadata, effectivity, and component lines.
27
+ - [activateBillOfMaterial](../commands/ActivateBillOfMaterial.md) - Validate the draft structure and make the version selectable for release.
28
+ - [deactivateBillOfMaterial](../commands/DeactivateBillOfMaterial.md) - Prevent future selection while preserving existing production-order snapshots.
29
+
30
+ ### Query Definitions
31
+
32
+ - [getBillOfMaterial](../queries/GetBillOfMaterial.md) - Retrieve one BOM version with component lines and effectivity details.
33
+ - [explodeBillOfMaterial](../queries/ExplodeBillOfMaterial.md) - Expand one BOM version into multi-level component requirements on a specific effectivity date.
34
+ - [listBillOfMaterialsByItem](../queries/ListBillOfMaterialsByItem.md) - List BOM versions for one parent item and scope.
35
+ - [detectBillOfMaterialCircularReference](../queries/DetectBillOfMaterialCircularReference.md) - Detect direct or indirect loops across manufactured child items.
36
+
37
+ ### Models
38
+
39
+ - BillOfMaterial
40
+ - BillOfMaterialLine
41
+
42
+ ### Invariants
43
+
44
+ - Every BOM version belongs to exactly one manufactured parent item and one company, with optional site-specific scope.
45
+ - The parent item must be ACTIVE and manufacturable when the BOM is created or activated.
46
+ - `bomType` must always be one of `MANUFACTURE`, `PHANTOM`, or `KIT`.
47
+ - A draft or active BOM contains at least one component line with positive required quantity.
48
+ - Component lines may reference stocked items or manufactured subassemblies, but inactive items cannot appear as newly added components.
49
+ - Active BOM versions may only reference ACTIVE component items.
50
+ - An active BOM must not introduce a direct or indirect circular manufactured-item reference.
51
+ - Overlapping active effectivity windows for the same parent item and scope are allowed only when default-selection rules keep the active version unambiguous.
52
+ - Production-order release snapshots the selected BOM version, lines, and `bomType` semantics so later BOM edits never mutate released work.
53
+
54
+ ### Relationships
55
+
56
+ - **References Item (cross-module)**: `parentItemId` and component `itemId` point to [Item](../../../item-management/docs/models/Item.md).
57
+ - **Belongs To Company and optional Site**: scope is constrained by [Company](../../../organization/docs/models/Company.md) and optionally [Site](../../../organization/docs/models/Site.md).
58
+ - **Has Many BillOfMaterialLines**: component structure, scrap assumptions, and subassembly references live under the parent BOM version.
59
+ - **Referenced By ProductionOrder**: [ProductionOrder](./ProductionOrder.md) resolves and snapshots one active BOM version at release.
60
+ - **Depends On primitives**: component and parent quantities use primitives-owned unit-of-measure compatibility.