@powerhousedao/contributor-billing 0.1.29 → 0.1.31

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 (390) hide show
  1. package/README.md +165 -8
  2. package/dist/document-models/billing-statement/actions.d.ts +1 -0
  3. package/dist/document-models/billing-statement/actions.d.ts.map +1 -1
  4. package/dist/document-models/billing-statement/gen/document-model.d.ts.map +1 -1
  5. package/dist/document-models/billing-statement/gen/document-model.js +58 -47
  6. package/dist/document-models/billing-statement/gen/document-schema.d.ts +38 -38
  7. package/dist/document-models/billing-statement/gen/document-schema.d.ts.map +1 -1
  8. package/dist/document-models/billing-statement/gen/line-items/actions.d.ts +6 -2
  9. package/dist/document-models/billing-statement/gen/line-items/actions.d.ts.map +1 -1
  10. package/dist/document-models/billing-statement/gen/line-items/creators.d.ts +3 -2
  11. package/dist/document-models/billing-statement/gen/line-items/creators.d.ts.map +1 -1
  12. package/dist/document-models/billing-statement/gen/line-items/creators.js +2 -1
  13. package/dist/document-models/billing-statement/gen/line-items/operations.d.ts +2 -1
  14. package/dist/document-models/billing-statement/gen/line-items/operations.d.ts.map +1 -1
  15. package/dist/document-models/billing-statement/gen/ph-factories.js +1 -1
  16. package/dist/document-models/billing-statement/gen/reducer.d.ts.map +1 -1
  17. package/dist/document-models/billing-statement/gen/reducer.js +5 -1
  18. package/dist/document-models/billing-statement/gen/schema/types.d.ts +3 -0
  19. package/dist/document-models/billing-statement/gen/schema/types.d.ts.map +1 -1
  20. package/dist/document-models/billing-statement/gen/schema/zod.d.ts +2 -1
  21. package/dist/document-models/billing-statement/gen/schema/zod.d.ts.map +1 -1
  22. package/dist/document-models/billing-statement/gen/schema/zod.js +5 -0
  23. package/dist/document-models/billing-statement/gen/utils.js +2 -2
  24. package/dist/document-models/billing-statement/src/reducers/general.d.ts.map +1 -1
  25. package/dist/document-models/billing-statement/src/reducers/general.js +5 -4
  26. package/dist/document-models/billing-statement/src/reducers/line-items.d.ts.map +1 -1
  27. package/dist/document-models/billing-statement/src/reducers/line-items.js +7 -2
  28. package/dist/document-models/billing-statement/src/reducers/tags.d.ts.map +1 -1
  29. package/dist/document-models/billing-statement/src/reducers/tags.js +1 -1
  30. package/dist/document-models/billing-statement/src/tests/document-model.test.d.ts +4 -0
  31. package/dist/document-models/billing-statement/src/tests/document-model.test.d.ts.map +1 -1
  32. package/dist/document-models/billing-statement/src/tests/document-model.test.js +94 -7
  33. package/dist/document-models/billing-statement/src/tests/general.test.d.ts +2 -1
  34. package/dist/document-models/billing-statement/src/tests/general.test.d.ts.map +1 -1
  35. package/dist/document-models/billing-statement/src/tests/general.test.js +33 -88
  36. package/dist/document-models/billing-statement/src/tests/line-items.test.js +22 -125
  37. package/dist/document-models/billing-statement/src/tests/tags.test.js +13 -47
  38. package/dist/document-models/document-models.js +2 -2
  39. package/dist/document-models/expense-report/gen/document-model.d.ts.map +1 -1
  40. package/dist/document-models/expense-report/gen/document-model.js +48 -48
  41. package/dist/document-models/expense-report/gen/document-schema.d.ts +6 -6
  42. package/dist/document-models/expense-report/gen/utils.js +1 -1
  43. package/dist/document-models/expense-report/src/tests/document-model.test.d.ts +4 -0
  44. package/dist/document-models/expense-report/src/tests/document-model.test.d.ts.map +1 -1
  45. package/dist/document-models/expense-report/src/tests/document-model.test.js +94 -8
  46. package/dist/document-models/expense-report/src/tests/wallet.test.js +145 -10
  47. package/dist/document-models/index.d.ts +2 -6
  48. package/dist/document-models/index.d.ts.map +1 -1
  49. package/dist/document-models/index.js +2 -6
  50. package/dist/document-models/integrations/gen/document-model.js +33 -33
  51. package/dist/document-models/integrations/gen/document-schema.d.ts +6 -6
  52. package/dist/document-models/integrations/gen/utils.js +1 -1
  53. package/dist/document-models/integrations/src/reducers/integrations.d.ts.map +1 -1
  54. package/dist/document-models/integrations/src/reducers/integrations.js +9 -32
  55. package/dist/document-models/integrations/src/tests/document-model.test.d.ts +4 -0
  56. package/dist/document-models/integrations/src/tests/document-model.test.d.ts.map +1 -1
  57. package/dist/document-models/integrations/src/tests/document-model.test.js +91 -5
  58. package/dist/document-models/integrations/src/tests/integrations.test.js +21 -46
  59. package/dist/document-models/invoice/gen/document-model.js +147 -147
  60. package/dist/document-models/invoice/gen/document-schema.d.ts +127 -127
  61. package/dist/document-models/invoice/gen/document-schema.d.ts.map +1 -1
  62. package/dist/document-models/invoice/gen/ph-factories.d.ts.map +1 -1
  63. package/dist/document-models/invoice/gen/ph-factories.js +16 -122
  64. package/dist/document-models/invoice/gen/schema/types.d.ts +4 -4
  65. package/dist/document-models/invoice/gen/schema/types.d.ts.map +1 -1
  66. package/dist/document-models/invoice/gen/schema/zod.d.ts.map +1 -1
  67. package/dist/document-models/invoice/gen/schema/zod.js +4 -4
  68. package/dist/document-models/invoice/gen/utils.d.ts.map +1 -1
  69. package/dist/document-models/invoice/gen/utils.js +17 -123
  70. package/dist/document-models/invoice/src/reducers/general.d.ts.map +1 -1
  71. package/dist/document-models/invoice/src/reducers/general.js +34 -10
  72. package/dist/document-models/invoice/src/reducers/items.d.ts.map +1 -1
  73. package/dist/document-models/invoice/src/reducers/items.js +7 -7
  74. package/dist/document-models/invoice/src/reducers/parties.d.ts.map +1 -1
  75. package/dist/document-models/invoice/src/reducers/parties.js +96 -50
  76. package/dist/document-models/invoice/src/reducers/transitions.d.ts.map +1 -1
  77. package/dist/document-models/invoice/src/reducers/transitions.js +69 -53
  78. package/dist/document-models/invoice/src/tests/document-model.test.d.ts +4 -0
  79. package/dist/document-models/invoice/src/tests/document-model.test.d.ts.map +1 -1
  80. package/dist/document-models/invoice/src/tests/document-model.test.js +91 -4
  81. package/dist/document-models/invoice/src/tests/general.test.js +24 -26
  82. package/dist/document-models/invoice/src/tests/items.test.js +37 -17
  83. package/dist/document-models/invoice/src/tests/parties.test.js +32 -26
  84. package/dist/document-models/invoice/src/tests/transitions.test.js +52 -500
  85. package/dist/document-models/invoice/utils/statusTransitions.d.ts.map +1 -1
  86. package/dist/document-models/invoice/utils/statusTransitions.js +10 -10
  87. package/dist/editors/billing-statement/components/lineItemsTable.d.ts.map +1 -1
  88. package/dist/editors/billing-statement/components/lineItemsTable.js +32 -23
  89. package/dist/editors/billing-statement/components/objectSetTable.d.ts.map +1 -1
  90. package/dist/editors/billing-statement/components/objectSetTable.js +1 -2
  91. package/dist/editors/billing-statement/editor.d.ts +4 -0
  92. package/dist/editors/billing-statement/editor.d.ts.map +1 -1
  93. package/dist/editors/billing-statement/editor.js +34 -16
  94. package/dist/editors/billing-statement/lineItemTags/lineItemTags.d.ts.map +1 -1
  95. package/dist/editors/billing-statement/lineItemTags/lineItemTags.js +36 -37
  96. package/dist/editors/billing-statement/lineItemTags/tagMapping.d.ts.map +1 -1
  97. package/dist/editors/billing-statement/lineItemTags/tagMapping.js +28 -10
  98. package/dist/editors/clean-new-editor/components/CreateDocument.d.ts +6 -0
  99. package/dist/editors/clean-new-editor/components/CreateDocument.d.ts.map +1 -0
  100. package/dist/editors/clean-new-editor/components/CreateDocument.js +18 -0
  101. package/dist/editors/clean-new-editor/components/DriveContents.d.ts +3 -0
  102. package/dist/editors/clean-new-editor/components/DriveContents.d.ts.map +1 -0
  103. package/dist/editors/clean-new-editor/components/DriveContents.js +10 -0
  104. package/dist/editors/clean-new-editor/components/DriveExplorer.d.ts +7 -0
  105. package/dist/editors/clean-new-editor/components/DriveExplorer.d.ts.map +1 -0
  106. package/dist/editors/clean-new-editor/components/DriveExplorer.js +16 -0
  107. package/dist/editors/clean-new-editor/components/EmptyState.d.ts +3 -0
  108. package/dist/editors/clean-new-editor/components/EmptyState.d.ts.map +1 -0
  109. package/dist/editors/clean-new-editor/components/EmptyState.js +10 -0
  110. package/dist/editors/clean-new-editor/components/Files.d.ts +3 -0
  111. package/dist/editors/clean-new-editor/components/Files.d.ts.map +1 -0
  112. package/dist/editors/clean-new-editor/components/Files.js +12 -0
  113. package/dist/editors/clean-new-editor/components/FolderTree.d.ts +6 -0
  114. package/dist/editors/clean-new-editor/components/FolderTree.d.ts.map +1 -0
  115. package/dist/editors/clean-new-editor/components/FolderTree.js +65 -0
  116. package/dist/editors/clean-new-editor/components/Folders.d.ts +3 -0
  117. package/dist/editors/clean-new-editor/components/Folders.d.ts.map +1 -0
  118. package/dist/editors/clean-new-editor/components/Folders.js +12 -0
  119. package/dist/editors/clean-new-editor/components/NavigationBreadcrumbs.d.ts +3 -0
  120. package/dist/editors/clean-new-editor/components/NavigationBreadcrumbs.d.ts.map +1 -0
  121. package/dist/editors/clean-new-editor/components/NavigationBreadcrumbs.js +6 -0
  122. package/dist/editors/clean-new-editor/config.d.ts +4 -0
  123. package/dist/editors/clean-new-editor/config.d.ts.map +1 -0
  124. package/dist/editors/clean-new-editor/config.js +5 -0
  125. package/dist/editors/clean-new-editor/editor.d.ts +4 -0
  126. package/dist/editors/clean-new-editor/editor.d.ts.map +1 -0
  127. package/dist/editors/clean-new-editor/editor.js +11 -0
  128. package/dist/editors/clean-new-editor/module.d.ts +3 -0
  129. package/dist/editors/clean-new-editor/module.d.ts.map +1 -0
  130. package/dist/editors/clean-new-editor/module.js +10 -0
  131. package/dist/editors/contributor-billing/components/ConfirmationModal.d.ts +14 -0
  132. package/dist/editors/contributor-billing/components/ConfirmationModal.d.ts.map +1 -0
  133. package/dist/editors/contributor-billing/components/ConfirmationModal.js +6 -0
  134. package/dist/editors/contributor-billing/components/CreateDocument.d.ts +6 -0
  135. package/dist/editors/contributor-billing/components/CreateDocument.d.ts.map +1 -0
  136. package/dist/editors/contributor-billing/components/CreateDocument.js +18 -0
  137. package/dist/editors/contributor-billing/components/DriveContents.d.ts +3 -0
  138. package/dist/editors/contributor-billing/components/DriveContents.d.ts.map +1 -0
  139. package/dist/editors/contributor-billing/components/DriveContents.js +10 -0
  140. package/dist/editors/contributor-billing/components/DriveExplorer.d.ts +3 -3
  141. package/dist/editors/contributor-billing/components/DriveExplorer.d.ts.map +1 -1
  142. package/dist/editors/contributor-billing/components/DriveExplorer.js +13 -180
  143. package/dist/editors/contributor-billing/components/EmptyState.d.ts +3 -0
  144. package/dist/editors/contributor-billing/components/EmptyState.d.ts.map +1 -0
  145. package/dist/editors/contributor-billing/components/EmptyState.js +10 -0
  146. package/dist/editors/contributor-billing/components/Files.d.ts +3 -0
  147. package/dist/editors/contributor-billing/components/Files.d.ts.map +1 -0
  148. package/dist/editors/contributor-billing/components/Files.js +12 -0
  149. package/dist/editors/contributor-billing/components/FolderTree.d.ts +6 -0
  150. package/dist/editors/contributor-billing/components/FolderTree.d.ts.map +1 -0
  151. package/dist/editors/contributor-billing/components/FolderTree.js +65 -0
  152. package/dist/editors/contributor-billing/components/Folders.d.ts +3 -0
  153. package/dist/editors/contributor-billing/components/Folders.d.ts.map +1 -0
  154. package/dist/editors/contributor-billing/components/Folders.js +12 -0
  155. package/dist/editors/contributor-billing/components/HeaderControls.d.ts +38 -0
  156. package/dist/editors/contributor-billing/components/HeaderControls.d.ts.map +1 -0
  157. package/dist/editors/contributor-billing/components/HeaderControls.js +124 -0
  158. package/dist/editors/contributor-billing/components/HeaderStats.d.ts.map +1 -0
  159. package/dist/editors/contributor-billing/components/{InvoiceTable/HeaderStats.js → HeaderStats.js} +1 -1
  160. package/dist/editors/contributor-billing/components/InvoiceTable.d.ts +22 -0
  161. package/dist/editors/contributor-billing/components/InvoiceTable.d.ts.map +1 -0
  162. package/dist/editors/contributor-billing/components/InvoiceTable.js +399 -0
  163. package/dist/editors/contributor-billing/components/InvoiceTableContainer.d.ts +6 -0
  164. package/dist/editors/contributor-billing/components/InvoiceTableContainer.d.ts.map +1 -0
  165. package/dist/editors/contributor-billing/components/InvoiceTableContainer.js +111 -0
  166. package/dist/editors/contributor-billing/components/InvoiceTableRow.d.ts +32 -0
  167. package/dist/editors/contributor-billing/components/InvoiceTableRow.d.ts.map +1 -0
  168. package/dist/editors/contributor-billing/components/InvoiceTableRow.js +55 -0
  169. package/dist/editors/contributor-billing/components/InvoiceTableSection.d.ts +13 -0
  170. package/dist/editors/contributor-billing/components/InvoiceTableSection.d.ts.map +1 -0
  171. package/dist/editors/contributor-billing/components/InvoiceTableSection.js +16 -0
  172. package/dist/editors/contributor-billing/components/NavigationBreadcrumbs.d.ts +3 -0
  173. package/dist/editors/contributor-billing/components/NavigationBreadcrumbs.d.ts.map +1 -0
  174. package/dist/editors/contributor-billing/components/NavigationBreadcrumbs.js +6 -0
  175. package/dist/editors/contributor-billing/config.d.ts +1 -0
  176. package/dist/editors/contributor-billing/config.d.ts.map +1 -1
  177. package/dist/editors/contributor-billing/config.js +4 -1
  178. package/dist/editors/contributor-billing/editor.d.ts +1 -0
  179. package/dist/editors/contributor-billing/editor.d.ts.map +1 -1
  180. package/dist/editors/contributor-billing/editor.js +4 -1
  181. package/dist/editors/contributor-billing/module.d.ts +1 -1
  182. package/dist/editors/contributor-billing/module.d.ts.map +1 -1
  183. package/dist/editors/contributor-billing/module.js +3 -2
  184. package/dist/editors/contributor-billing/utils/exchangeRate.d.ts +15 -0
  185. package/dist/editors/contributor-billing/utils/exchangeRate.d.ts.map +1 -0
  186. package/dist/editors/contributor-billing/utils/exchangeRate.js +122 -0
  187. package/dist/editors/editors.js +2 -2
  188. package/dist/editors/expense-report/components/AddBillingStatementModal.d.ts.map +1 -1
  189. package/dist/editors/expense-report/editor.js +8 -8
  190. package/dist/editors/index.d.ts +2 -2
  191. package/dist/editors/index.d.ts.map +1 -1
  192. package/dist/editors/index.js +2 -2
  193. package/dist/editors/integrations/components/EditName.d.ts +3 -0
  194. package/dist/editors/integrations/components/EditName.d.ts.map +1 -0
  195. package/dist/editors/integrations/components/EditName.js +31 -0
  196. package/dist/editors/integrations/editor.d.ts +2 -4
  197. package/dist/editors/integrations/editor.d.ts.map +1 -1
  198. package/dist/editors/integrations/editor.js +5 -132
  199. package/dist/editors/integrations/module.d.ts +1 -0
  200. package/dist/editors/integrations/module.d.ts.map +1 -1
  201. package/dist/editors/integrations/module.js +3 -2
  202. package/dist/editors/invoice/components/confirmationModal.js +1 -1
  203. package/dist/editors/invoice/components/countryForm.d.ts.map +1 -1
  204. package/dist/editors/invoice/components/countryForm.js +1 -1
  205. package/dist/editors/invoice/components/currencyForm.d.ts.map +1 -1
  206. package/dist/editors/invoice/components/currencyForm.js +1 -1
  207. package/dist/editors/invoice/components/datePicker.d.ts +1 -1
  208. package/dist/editors/invoice/components/datePicker.d.ts.map +1 -1
  209. package/dist/editors/invoice/components/datePicker.js +1 -1
  210. package/dist/editors/invoice/components/inputField.d.ts.map +1 -1
  211. package/dist/editors/invoice/components/inputField.js +3 -2
  212. package/dist/editors/invoice/components/lineItemMobileModal.d.ts.map +1 -1
  213. package/dist/editors/invoice/components/lineItemMobileModal.js +1 -1
  214. package/dist/editors/invoice/components/numberForm.d.ts.map +1 -1
  215. package/dist/editors/invoice/components/selectField.js +7 -7
  216. package/dist/editors/invoice/components/statusModalComponents.d.ts.map +1 -1
  217. package/dist/editors/invoice/components/statusModalComponents.js +27 -3
  218. package/dist/editors/invoice/editor.d.ts +1 -4
  219. package/dist/editors/invoice/editor.d.ts.map +1 -1
  220. package/dist/editors/invoice/editor.js +102 -40
  221. package/dist/editors/invoice/exportUBL.d.ts.map +1 -1
  222. package/dist/editors/invoice/exportUBL.js +35 -18
  223. package/dist/editors/invoice/ingestPDF.d.ts.map +1 -1
  224. package/dist/editors/invoice/ingestPDF.js +15 -9
  225. package/dist/editors/invoice/invoiceToGnosis.js +2 -2
  226. package/dist/editors/invoice/legalEntity/bankSection.d.ts.map +1 -1
  227. package/dist/editors/invoice/legalEntity/legalEntity.d.ts.map +1 -1
  228. package/dist/editors/invoice/legalEntity/walletSection.d.ts.map +1 -1
  229. package/dist/editors/invoice/legalEntity/walletSection.js +3 -3
  230. package/dist/editors/invoice/lineItemTags/lineItemTags.d.ts.map +1 -1
  231. package/dist/editors/invoice/lineItemTags/lineItemTags.js +1 -1
  232. package/dist/editors/invoice/lineItemTags/tagMobileModal.d.ts.map +1 -1
  233. package/dist/editors/invoice/lineItemTags/tagMobileModal.js +4 -3
  234. package/dist/editors/invoice/lineItems.d.ts.map +1 -1
  235. package/dist/editors/invoice/module.d.ts +1 -0
  236. package/dist/editors/invoice/module.d.ts.map +1 -1
  237. package/dist/editors/invoice/module.js +2 -1
  238. package/dist/editors/invoice/requestFinance.js +3 -3
  239. package/dist/editors/invoice/uploadPdfChunked.d.ts.map +1 -1
  240. package/dist/editors/invoice/uploadPdfChunked.js +4 -3
  241. package/dist/editors/invoice/utils/utils.d.ts.map +1 -1
  242. package/dist/editors/invoice/utils/utils.js +5 -4
  243. package/dist/editors/invoice/validation/validationHandler.d.ts.map +1 -1
  244. package/dist/editors/invoice/validation/validationHandler.js +11 -5
  245. package/dist/editors/invoice/validation/validationManager.d.ts +2 -2
  246. package/dist/editors/invoice/validation/validationManager.d.ts.map +1 -1
  247. package/dist/editors/invoice/validation/validationManager.js +5 -5
  248. package/dist/editors/invoice/validation/validationRules.d.ts.map +1 -1
  249. package/dist/editors/invoice/validation/validationRules.js +178 -178
  250. package/dist/index.d.ts +2 -2
  251. package/dist/index.d.ts.map +1 -1
  252. package/dist/index.js +4 -2
  253. package/dist/old-contributor-billing/components/DriveExplorer.d.ts +7 -0
  254. package/dist/old-contributor-billing/components/DriveExplorer.d.ts.map +1 -0
  255. package/dist/old-contributor-billing/components/DriveExplorer.js +184 -0
  256. package/dist/old-contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -0
  257. package/dist/old-contributor-billing/components/InvoiceTable/HeaderStats.d.ts +2 -0
  258. package/dist/old-contributor-billing/components/InvoiceTable/HeaderStats.d.ts.map +1 -0
  259. package/dist/old-contributor-billing/components/InvoiceTable/HeaderStats.js +73 -0
  260. package/dist/old-contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -0
  261. package/dist/old-contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts.map +1 -0
  262. package/dist/old-contributor-billing/components/InvoiceTable/InvoiceTableSection.d.ts.map +1 -0
  263. package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/InvoiceTableSection.js +1 -1
  264. package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/RowActionMenu.d.ts +1 -1
  265. package/dist/old-contributor-billing/components/InvoiceTable/RowActionMenu.d.ts.map +1 -0
  266. package/dist/old-contributor-billing/components/InvoiceTable/RowActionMenu.js +2 -0
  267. package/dist/old-contributor-billing/config.d.ts +3 -0
  268. package/dist/old-contributor-billing/config.d.ts.map +1 -0
  269. package/dist/old-contributor-billing/config.js +4 -0
  270. package/dist/old-contributor-billing/editor.d.ts +3 -0
  271. package/dist/old-contributor-billing/editor.d.ts.map +1 -0
  272. package/dist/old-contributor-billing/editor.js +8 -0
  273. package/dist/old-contributor-billing/module.d.ts +3 -0
  274. package/dist/old-contributor-billing/module.d.ts.map +1 -0
  275. package/dist/old-contributor-billing/module.js +9 -0
  276. package/dist/old-contributor-billing/util.d.ts.map +1 -0
  277. package/dist/{editors/contributor-billing → old-contributor-billing}/util.js +11 -9
  278. package/dist/powerhouse.manifest.json +6 -41
  279. package/dist/processors/index.d.ts +1 -6
  280. package/dist/processors/index.d.ts.map +1 -1
  281. package/dist/processors/index.js +1 -18
  282. package/dist/scripts/contributor-billing/createExpenseReportCsv.d.ts.map +1 -1
  283. package/dist/scripts/contributor-billing/createExpenseReportCsv.js +24 -24
  284. package/dist/scripts/contributor-billing/createXeroCsv.d.ts.map +1 -1
  285. package/dist/scripts/contributor-billing/createXeroCsv.js +52 -46
  286. package/dist/scripts/invoice/autoTagging.d.ts +1 -1
  287. package/dist/scripts/invoice/autoTagging.d.ts.map +1 -1
  288. package/dist/scripts/invoice/autoTagging.js +168 -138
  289. package/dist/scripts/invoice/exampleBatchTxn.js +16 -16
  290. package/dist/scripts/invoice/gnosisTransactionBuilder.d.ts.map +1 -1
  291. package/dist/scripts/invoice/gnosisTransactionBuilder.js +32 -25
  292. package/dist/scripts/invoice/pdfToClaudeAI.d.ts.map +1 -1
  293. package/dist/scripts/invoice/pdfToClaudeAI.js +36 -30
  294. package/dist/scripts/invoice/requestFinance.d.ts.map +1 -1
  295. package/dist/scripts/invoice/requestFinance.js +13 -13
  296. package/dist/style.css +407 -13659
  297. package/dist/subgraphs/billing-statement/resolvers.d.ts +1 -1
  298. package/dist/subgraphs/billing-statement/resolvers.d.ts.map +1 -1
  299. package/dist/subgraphs/billing-statement/resolvers.js +16 -5
  300. package/dist/subgraphs/billing-statement/schema.d.ts.map +1 -1
  301. package/dist/subgraphs/billing-statement/schema.js +12 -67
  302. package/dist/subgraphs/expense-report/resolvers.d.ts +1 -1
  303. package/dist/subgraphs/expense-report/resolvers.d.ts.map +1 -1
  304. package/dist/subgraphs/expense-report/resolvers.js +4 -5
  305. package/dist/subgraphs/expense-report/schema.d.ts.map +1 -1
  306. package/dist/subgraphs/expense-report/schema.js +5 -48
  307. package/dist/subgraphs/index.d.ts +1 -0
  308. package/dist/subgraphs/index.d.ts.map +1 -1
  309. package/dist/subgraphs/index.js +1 -0
  310. package/dist/subgraphs/integrations/resolvers.d.ts +1 -1
  311. package/dist/subgraphs/integrations/resolvers.d.ts.map +1 -1
  312. package/dist/subgraphs/integrations/resolvers.js +4 -5
  313. package/dist/subgraphs/integrations/schema.d.ts.map +1 -1
  314. package/dist/subgraphs/integrations/schema.js +3 -43
  315. package/dist/subgraphs/invoice/index.d.ts.map +1 -1
  316. package/dist/subgraphs/invoice/index.js +1 -20
  317. package/dist/subgraphs/invoice/resolvers.d.ts +1 -1
  318. package/dist/subgraphs/invoice/resolvers.d.ts.map +1 -1
  319. package/dist/subgraphs/invoice/resolvers.js +4 -9
  320. package/dist/subgraphs/invoice/schema.d.ts.map +1 -1
  321. package/dist/subgraphs/invoice/schema.js +14 -232
  322. package/dist/subgraphs/{invoice → invoice-addon}/customResolvers.d.ts +1 -1
  323. package/dist/subgraphs/invoice-addon/customResolvers.d.ts.map +1 -0
  324. package/dist/subgraphs/{invoice → invoice-addon}/customResolvers.js +38 -34
  325. package/dist/subgraphs/invoice-addon/index.d.ts +11 -0
  326. package/dist/subgraphs/invoice-addon/index.d.ts.map +1 -0
  327. package/dist/subgraphs/invoice-addon/index.js +11 -0
  328. package/dist/subgraphs/invoice-addon/resolvers.d.ts +3 -0
  329. package/dist/subgraphs/invoice-addon/resolvers.d.ts.map +1 -0
  330. package/dist/subgraphs/invoice-addon/resolvers.js +12 -0
  331. package/dist/subgraphs/invoice-addon/schema.d.ts +3 -0
  332. package/dist/subgraphs/invoice-addon/schema.d.ts.map +1 -0
  333. package/dist/subgraphs/invoice-addon/schema.js +52 -0
  334. package/package.json +9 -21
  335. package/dist/document-models/expense-report/gen/expense-report/actions.d.ts +0 -8
  336. package/dist/document-models/expense-report/gen/expense-report/actions.d.ts.map +0 -1
  337. package/dist/document-models/expense-report/gen/expense-report/actions.js +0 -1
  338. package/dist/document-models/expense-report/gen/expense-report/creators.d.ts +0 -4
  339. package/dist/document-models/expense-report/gen/expense-report/creators.d.ts.map +0 -1
  340. package/dist/document-models/expense-report/gen/expense-report/creators.js +0 -3
  341. package/dist/document-models/expense-report/gen/expense-report/error.d.ts +0 -2
  342. package/dist/document-models/expense-report/gen/expense-report/error.d.ts.map +0 -1
  343. package/dist/document-models/expense-report/gen/expense-report/error.js +0 -1
  344. package/dist/document-models/expense-report/gen/expense-report/operations.d.ts +0 -7
  345. package/dist/document-models/expense-report/gen/expense-report/operations.d.ts.map +0 -1
  346. package/dist/document-models/expense-report/gen/expense-report/operations.js +0 -3
  347. package/dist/document-models/expense-report/src/tests/expense-report.test.d.ts +0 -6
  348. package/dist/document-models/expense-report/src/tests/expense-report.test.d.ts.map +0 -1
  349. package/dist/document-models/expense-report/src/tests/expense-report.test.js +0 -24
  350. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +0 -1
  351. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderStats.d.ts.map +0 -1
  352. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +0 -1
  353. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts.map +0 -1
  354. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableSection.d.ts.map +0 -1
  355. package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.d.ts.map +0 -1
  356. package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.js +0 -2
  357. package/dist/editors/contributor-billing/util.d.ts.map +0 -1
  358. package/dist/editors/hooks/useBillingStatementDocument.d.ts +0 -4
  359. package/dist/editors/hooks/useBillingStatementDocument.d.ts.map +0 -1
  360. package/dist/editors/hooks/useBillingStatementDocument.js +0 -8
  361. package/dist/editors/hooks/useExpenseReportDocument.d.ts +0 -4
  362. package/dist/editors/hooks/useExpenseReportDocument.d.ts.map +0 -1
  363. package/dist/editors/hooks/useExpenseReportDocument.js +0 -8
  364. package/dist/editors/hooks/useIntegrationsDocument.d.ts +0 -4
  365. package/dist/editors/hooks/useIntegrationsDocument.d.ts.map +0 -1
  366. package/dist/editors/hooks/useIntegrationsDocument.js +0 -8
  367. package/dist/editors/hooks/useInvoiceDocument.d.ts +0 -4
  368. package/dist/editors/hooks/useInvoiceDocument.d.ts.map +0 -1
  369. package/dist/editors/hooks/useInvoiceDocument.js +0 -8
  370. package/dist/editors/integrations/config.d.ts +0 -3
  371. package/dist/editors/integrations/config.d.ts.map +0 -1
  372. package/dist/editors/integrations/config.js +0 -3
  373. package/dist/editors/invoice/exportSAFTPT.d.ts +0 -184
  374. package/dist/editors/invoice/exportSAFTPT.d.ts.map +0 -1
  375. package/dist/editors/invoice/exportSAFTPT.js +0 -548
  376. package/dist/processors/line-item-processor/index.d.ts +0 -11
  377. package/dist/processors/line-item-processor/index.d.ts.map +0 -1
  378. package/dist/processors/line-item-processor/index.js +0 -36
  379. package/dist/subgraphs/invoice/customResolvers.d.ts.map +0 -1
  380. package/editors/invoice/assets/custom.d.ts +0 -4
  381. package/editors/invoice/assets/powerhouseLogo.png +0 -0
  382. /package/dist/editors/contributor-billing/components/{InvoiceTable/HeaderStats.d.ts → HeaderStats.d.ts} +0 -0
  383. /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/HeaderControls.d.ts +0 -0
  384. /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/HeaderControls.js +0 -0
  385. /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/InvoiceTable.d.ts +0 -0
  386. /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/InvoiceTable.js +0 -0
  387. /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/InvoiceTableRow.d.ts +0 -0
  388. /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/InvoiceTableRow.js +0 -0
  389. /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/InvoiceTableSection.d.ts +0 -0
  390. /package/dist/{editors/contributor-billing → old-contributor-billing}/util.d.ts +0 -0
@@ -2,42 +2,65 @@ function getStateValue(input, currentValue) {
2
2
  return input === undefined ? currentValue : input;
3
3
  }
4
4
  export const invoicePartiesOperations = {
5
- editIssuerOperation(state, action, dispatch) {
6
- if ('address' in state.issuer && ('city' in action.input ||
7
- 'country' in action.input ||
8
- 'extendedAddress' in action.input ||
9
- 'postalCode' in action.input ||
10
- 'stateProvince' in action.input ||
11
- 'streetAddress' in action.input)) {
5
+ editIssuerOperation(state, action) {
6
+ if ("address" in state.issuer &&
7
+ ("city" in action.input ||
8
+ "country" in action.input ||
9
+ "extendedAddress" in action.input ||
10
+ "postalCode" in action.input ||
11
+ "stateProvince" in action.input ||
12
+ "streetAddress" in action.input)) {
12
13
  state.issuer.address = {
13
14
  ...state.issuer.address,
14
- city: action.input.city !== undefined ? action.input.city : state.issuer.address?.city ?? null,
15
- country: action.input.country !== undefined ? action.input.country : state.issuer.address?.country ?? null,
16
- extendedAddress: action.input.extendedAddress !== undefined ? action.input.extendedAddress : state.issuer.address?.extendedAddress ?? null,
17
- postalCode: action.input.postalCode !== undefined ? action.input.postalCode : state.issuer.address?.postalCode ?? null,
18
- stateProvince: action.input.stateProvince !== undefined ? action.input.stateProvince : state.issuer.address?.stateProvince ?? null,
19
- streetAddress: action.input.streetAddress !== undefined ? action.input.streetAddress : state.issuer.address?.streetAddress ?? null,
15
+ city: action.input.city !== undefined
16
+ ? action.input.city
17
+ : (state.issuer.address?.city ?? null),
18
+ country: action.input.country !== undefined
19
+ ? action.input.country
20
+ : (state.issuer.address?.country ?? null),
21
+ extendedAddress: action.input.extendedAddress !== undefined
22
+ ? action.input.extendedAddress
23
+ : (state.issuer.address?.extendedAddress ?? null),
24
+ postalCode: action.input.postalCode !== undefined
25
+ ? action.input.postalCode
26
+ : (state.issuer.address?.postalCode ?? null),
27
+ stateProvince: action.input.stateProvince !== undefined
28
+ ? action.input.stateProvince
29
+ : (state.issuer.address?.stateProvince ?? null),
30
+ streetAddress: action.input.streetAddress !== undefined
31
+ ? action.input.streetAddress
32
+ : (state.issuer.address?.streetAddress ?? null),
20
33
  };
21
34
  }
22
- if ('contactInfo' in state.issuer && ('tel' in action.input ||
23
- 'email' in action.input)) {
35
+ if ("contactInfo" in state.issuer &&
36
+ ("tel" in action.input || "email" in action.input)) {
24
37
  state.issuer.contactInfo = {
25
38
  ...state.issuer.contactInfo,
26
- tel: action.input.tel !== undefined ? action.input.tel : state.issuer.contactInfo?.tel ?? null,
27
- email: action.input.email !== undefined ? action.input.email : state.issuer.contactInfo?.email ?? null,
39
+ tel: action.input.tel !== undefined
40
+ ? action.input.tel
41
+ : (state.issuer.contactInfo?.tel ?? null),
42
+ email: action.input.email !== undefined
43
+ ? action.input.email
44
+ : (state.issuer.contactInfo?.email ?? null),
28
45
  };
29
46
  }
30
- if ('country' in action.input) {
31
- state.issuer.country = action.input.country !== undefined ? action.input.country : state.issuer.country ?? null;
47
+ if ("country" in action.input) {
48
+ state.issuer.country =
49
+ action.input.country !== undefined
50
+ ? action.input.country
51
+ : (state.issuer.country ?? null);
32
52
  }
33
- if ('id' in action.input) {
53
+ if ("id" in action.input) {
34
54
  state.issuer.id = action.input.id ? { taxId: action.input.id } : null;
35
55
  }
36
- if ('name' in action.input) {
37
- state.issuer.name = action.input.name !== undefined ? action.input.name : state.issuer.name ?? null;
56
+ if ("name" in action.input) {
57
+ state.issuer.name =
58
+ action.input.name !== undefined
59
+ ? action.input.name
60
+ : (state.issuer.name ?? null);
38
61
  }
39
62
  },
40
- editIssuerBankOperation(state, action, dispatch) {
63
+ editIssuerBankOperation(state, action) {
41
64
  if (!state.issuer.paymentRouting) {
42
65
  state.issuer.paymentRouting = {
43
66
  bank: null,
@@ -73,8 +96,8 @@ export const invoicePartiesOperations = {
73
96
  accountType: getStateValue(action.input.accountTypeIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.accountType ??
74
97
  null),
75
98
  address: {
76
- city: getStateValue(action.input.cityIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.address
77
- .city ?? null),
99
+ city: getStateValue(action.input.cityIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.address.city ??
100
+ null),
78
101
  country: getStateValue(action.input.countryIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.address
79
102
  .country ?? null),
80
103
  extendedAddress: getStateValue(action.input.extendedAddressIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.address
@@ -95,7 +118,7 @@ export const invoicePartiesOperations = {
95
118
  },
96
119
  };
97
120
  },
98
- editIssuerWalletOperation(state, action, dispatch) {
121
+ editIssuerWalletOperation(state, action) {
99
122
  if (!state.issuer.paymentRouting) {
100
123
  state.issuer.paymentRouting = {
101
124
  bank: null,
@@ -115,42 +138,65 @@ export const invoicePartiesOperations = {
115
138
  rpc: action.input.rpc ?? state.issuer.paymentRouting.wallet?.rpc ?? null,
116
139
  };
117
140
  },
118
- editPayerOperation(state, action, dispatch) {
119
- if ('address' in state.payer && ('city' in action.input ||
120
- 'country' in action.input ||
121
- 'extendedAddress' in action.input ||
122
- 'postalCode' in action.input ||
123
- 'stateProvince' in action.input ||
124
- 'streetAddress' in action.input)) {
141
+ editPayerOperation(state, action) {
142
+ if ("address" in state.payer &&
143
+ ("city" in action.input ||
144
+ "country" in action.input ||
145
+ "extendedAddress" in action.input ||
146
+ "postalCode" in action.input ||
147
+ "stateProvince" in action.input ||
148
+ "streetAddress" in action.input)) {
125
149
  state.payer.address = {
126
150
  ...state.payer.address,
127
- city: action.input.city !== undefined ? action.input.city : state.payer.address?.city ?? null,
128
- country: action.input.country !== undefined ? action.input.country : state.payer.address?.country ?? null,
129
- extendedAddress: action.input.extendedAddress !== undefined ? action.input.extendedAddress : state.payer.address?.extendedAddress ?? null,
130
- postalCode: action.input.postalCode !== undefined ? action.input.postalCode : state.payer.address?.postalCode ?? null,
131
- stateProvince: action.input.stateProvince !== undefined ? action.input.stateProvince : state.payer.address?.stateProvince ?? null,
132
- streetAddress: action.input.streetAddress !== undefined ? action.input.streetAddress : state.payer.address?.streetAddress ?? null,
151
+ city: action.input.city !== undefined
152
+ ? action.input.city
153
+ : (state.payer.address?.city ?? null),
154
+ country: action.input.country !== undefined
155
+ ? action.input.country
156
+ : (state.payer.address?.country ?? null),
157
+ extendedAddress: action.input.extendedAddress !== undefined
158
+ ? action.input.extendedAddress
159
+ : (state.payer.address?.extendedAddress ?? null),
160
+ postalCode: action.input.postalCode !== undefined
161
+ ? action.input.postalCode
162
+ : (state.payer.address?.postalCode ?? null),
163
+ stateProvince: action.input.stateProvince !== undefined
164
+ ? action.input.stateProvince
165
+ : (state.payer.address?.stateProvince ?? null),
166
+ streetAddress: action.input.streetAddress !== undefined
167
+ ? action.input.streetAddress
168
+ : (state.payer.address?.streetAddress ?? null),
133
169
  };
134
170
  }
135
- if ('contactInfo' in state.payer && ('tel' in action.input ||
136
- 'email' in action.input)) {
171
+ if ("contactInfo" in state.payer &&
172
+ ("tel" in action.input || "email" in action.input)) {
137
173
  state.payer.contactInfo = {
138
174
  ...state.payer.contactInfo,
139
- tel: action.input.tel !== undefined ? action.input.tel : state.payer.contactInfo?.tel ?? null,
140
- email: action.input.email !== undefined ? action.input.email : state.payer.contactInfo?.email ?? null,
175
+ tel: action.input.tel !== undefined
176
+ ? action.input.tel
177
+ : (state.payer.contactInfo?.tel ?? null),
178
+ email: action.input.email !== undefined
179
+ ? action.input.email
180
+ : (state.payer.contactInfo?.email ?? null),
141
181
  };
142
182
  }
143
- if ('country' in action.input) {
144
- state.payer.country = action.input.country !== undefined ? action.input.country : state.payer.country ?? null;
183
+ if ("country" in action.input) {
184
+ state.payer.country =
185
+ action.input.country !== undefined
186
+ ? action.input.country
187
+ : (state.payer.country ?? null);
145
188
  }
146
- if ('id' in action.input) {
189
+ if ("id" in action.input) {
147
190
  state.payer.id = action.input.id ? { taxId: action.input.id } : null;
148
191
  }
149
- if ('name' in action.input) {
150
- state.payer.name = action.input.name !== undefined ? action.input.name : state.payer.name ?? null;
192
+ if ("name" in action.input) {
193
+ state.payer.name =
194
+ action.input.name !== undefined
195
+ ? action.input.name
196
+ : (state.payer.name ?? null);
151
197
  }
152
198
  },
153
- editPayerBankOperation(state, action, dispatch) {
199
+ editPayerBankOperation(state, action) {
154
200
  if (!state.payer.paymentRouting) {
155
201
  state.payer.paymentRouting = {
156
202
  bank: null,
@@ -208,7 +254,7 @@ export const invoicePartiesOperations = {
208
254
  },
209
255
  };
210
256
  },
211
- editPayerWalletOperation(state, action, dispatch) {
257
+ editPayerWalletOperation(state, action) {
212
258
  if (!state.payer.paymentRouting) {
213
259
  state.payer.paymentRouting = {
214
260
  bank: null,
@@ -1 +1 @@
1
- {"version":3,"file":"transitions.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/reducers/transitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAC;AAE/G,eAAO,MAAM,4BAA4B,EAAE,4BA4I1C,CAAC"}
1
+ {"version":3,"file":"transitions.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/reducers/transitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAC;AAgB/G,eAAO,MAAM,4BAA4B,EAAE,4BA+J1C,CAAC"}
@@ -4,42 +4,58 @@
4
4
  * - delete the file and run the code generator again to have it reset
5
5
  */
6
6
  import { permittedTransitions } from "../../utils/statusTransitions.js";
7
+ /**
8
+ * Converts a date string to ISO datetime format if it's not already in that format
9
+ * Handles both date-only (YYYY-MM-DD) and datetime (YYYY-MM-DDTHH:mm:ss.sssZ) strings
10
+ */
11
+ function ensureDatetimeFormat(dateStr) {
12
+ if (!dateStr || dateStr.trim() === "")
13
+ return null;
14
+ // If it's already a datetime string, return as is
15
+ if (dateStr.includes("T"))
16
+ return dateStr;
17
+ // Convert date-only to datetime at midnight UTC
18
+ return `${dateStr}T00:00:00.000Z`;
19
+ }
7
20
  export const invoiceTransitionsOperations = {
8
- cancelOperation(state, action, dispatch) {
9
- if (permittedTransitions[state.status].includes('CANCELLED')) {
10
- state.status = 'CANCELLED';
21
+ cancelOperation(state, action) {
22
+ if (permittedTransitions[state.status].includes("CANCELLED")) {
23
+ state.status = "CANCELLED";
11
24
  }
12
25
  else {
13
26
  throw new Error(`Invalid transition from ${state.status} to CANCELLED`);
14
27
  }
15
28
  },
16
- issueOperation(state, action, dispatch) {
29
+ issueOperation(state, action) {
17
30
  if (!action.input.invoiceNo || !action.input.dateIssued) {
18
- throw new Error('Invoice number and date issued are required');
31
+ throw new Error("Invoice number and date issued are required");
19
32
  }
20
- if (permittedTransitions[state.status].includes('ISSUED')) {
21
- state.status = 'ISSUED';
33
+ if (permittedTransitions[state.status].includes("ISSUED")) {
34
+ state.status = "ISSUED";
22
35
  state.invoiceNo = action.input.invoiceNo;
23
- state.dateIssued = action.input.dateIssued;
36
+ // Convert date string to datetime format to match Zod schema requirements
37
+ state.dateIssued =
38
+ ensureDatetimeFormat(action.input.dateIssued) ||
39
+ action.input.dateIssued;
24
40
  }
25
41
  else {
26
42
  throw new Error(`Invalid transition from ${state.status} to ISSUED`);
27
43
  }
28
44
  },
29
- resetOperation(state, action, dispatch) {
30
- if (permittedTransitions[state.status].includes('DRAFT')) {
31
- state.status = 'DRAFT';
45
+ resetOperation(state, action) {
46
+ if (permittedTransitions[state.status].includes("DRAFT")) {
47
+ state.status = "DRAFT";
32
48
  }
33
49
  else {
34
50
  throw new Error(`Invalid transition from ${state.status} to DRAFT`);
35
51
  }
36
52
  },
37
- rejectOperation(state, action, dispatch) {
53
+ rejectOperation(state, action) {
38
54
  if (!action.input.id || !action.input.reason) {
39
- throw new Error('Reason, ID and final are required');
55
+ throw new Error("Reason, ID and final are required");
40
56
  }
41
- if (permittedTransitions[state.status].includes('REJECTED')) {
42
- state.status = 'REJECTED';
57
+ if (permittedTransitions[state.status].includes("REJECTED")) {
58
+ state.status = "REJECTED";
43
59
  const rejection = {
44
60
  id: action.input.id,
45
61
  reason: action.input.reason,
@@ -51,40 +67,40 @@ export const invoiceTransitionsOperations = {
51
67
  throw new Error(`Invalid transition from ${state.status} to REJECTED`);
52
68
  }
53
69
  },
54
- acceptOperation(state, action, dispatch) {
70
+ acceptOperation(state, action) {
55
71
  if (!action.input.payAfter) {
56
- throw new Error('Pay after is required');
72
+ throw new Error("Pay after is required");
57
73
  }
58
- if (permittedTransitions[state.status].includes('ACCEPTED')) {
59
- state.status = 'ACCEPTED';
74
+ if (permittedTransitions[state.status].includes("ACCEPTED")) {
75
+ state.status = "ACCEPTED";
60
76
  state.payAfter = action.input.payAfter;
61
77
  }
62
78
  else {
63
79
  throw new Error(`Invalid transition from ${state.status} to ACCEPTED`);
64
80
  }
65
81
  },
66
- reinstateOperation(state, action, dispatch) {
67
- const finalRejection = state.rejections.find(rejection => rejection.final === true);
82
+ reinstateOperation(state, action) {
83
+ const finalRejection = state.rejections.find((rejection) => rejection.final === true);
68
84
  if (finalRejection) {
69
- throw new Error('Cannot reinstate an invoice that has been rejected');
85
+ throw new Error("Cannot reinstate an invoice that has been rejected");
70
86
  }
71
- if (permittedTransitions[state.status].includes('ISSUED')) {
72
- state.status = 'ISSUED';
87
+ if (permittedTransitions[state.status].includes("ISSUED")) {
88
+ state.status = "ISSUED";
73
89
  }
74
90
  else {
75
91
  throw new Error(`Invalid transition from ${state.status} to ISSUED`);
76
92
  }
77
93
  },
78
- schedulePaymentOperation(state, action, dispatch) {
94
+ schedulePaymentOperation(state, action) {
79
95
  if (!action.input.id || !action.input.processorRef) {
80
- throw new Error('ID and processorRef are required');
96
+ throw new Error("ID and processorRef are required");
81
97
  }
82
- if (permittedTransitions[state.status].includes('PAYMENTSCHEDULED')) {
83
- state.status = 'PAYMENTSCHEDULED';
98
+ if (permittedTransitions[state.status].includes("PAYMENTSCHEDULED")) {
99
+ state.status = "PAYMENTSCHEDULED";
84
100
  state.payments.push({
85
101
  id: action.input.id,
86
102
  processorRef: action.input.processorRef,
87
- paymentDate: '',
103
+ paymentDate: new Date().toISOString(),
88
104
  txnRef: "",
89
105
  confirmed: false,
90
106
  issue: "",
@@ -95,20 +111,20 @@ export const invoiceTransitionsOperations = {
95
111
  throw new Error(`Invalid transition from ${state.status} to PAYMENTSCHEDULED`);
96
112
  }
97
113
  },
98
- reapprovePaymentOperation(state, action, dispatch) {
99
- if (permittedTransitions[state.status].includes('ACCEPTED')) {
100
- state.status = 'ACCEPTED';
114
+ reapprovePaymentOperation(state, action) {
115
+ if (permittedTransitions[state.status].includes("ACCEPTED")) {
116
+ state.status = "ACCEPTED";
101
117
  }
102
118
  else {
103
119
  throw new Error(`Invalid transition from ${state.status} to ACCEPTED`);
104
120
  }
105
121
  },
106
- registerPaymentTxOperation(state, action, dispatch) {
107
- if (permittedTransitions[state.status].includes('PAYMENTSENT')) {
108
- state.status = 'PAYMENTSENT';
109
- const payment = state.payments.find(payment => payment.id === action.input.id);
122
+ registerPaymentTxOperation(state, action) {
123
+ if (permittedTransitions[state.status].includes("PAYMENTSENT")) {
124
+ state.status = "PAYMENTSENT";
125
+ const payment = state.payments.find((payment) => payment.id === action.input.id);
110
126
  if (!payment)
111
- throw new Error('Payment not found');
127
+ throw new Error("Payment not found");
112
128
  payment.txnRef = action.input.txRef;
113
129
  payment.paymentDate = action.input.timestamp;
114
130
  }
@@ -116,30 +132,30 @@ export const invoiceTransitionsOperations = {
116
132
  throw new Error(`Invalid transition from ${state.status} to PAYMENTSENT`);
117
133
  }
118
134
  },
119
- reportPaymentIssueOperation(state, action, dispatch) {
135
+ reportPaymentIssueOperation(state, action) {
120
136
  if (!action.input.id || !action.input.issue) {
121
- throw new Error('ID and issue are required');
137
+ throw new Error("ID and issue are required");
122
138
  }
123
- if (permittedTransitions[state.status].includes('PAYMENTISSUE')) {
124
- state.status = 'PAYMENTISSUE';
125
- const payment = state.payments.find(payment => payment.id === action.input.id);
139
+ if (permittedTransitions[state.status].includes("PAYMENTISSUE")) {
140
+ state.status = "PAYMENTISSUE";
141
+ const payment = state.payments.find((payment) => payment.id === action.input.id);
126
142
  if (!payment)
127
- throw new Error('Payment not found');
143
+ throw new Error("Payment not found");
128
144
  payment.issue = action.input.issue;
129
145
  }
130
146
  else {
131
147
  throw new Error(`Invalid transition from ${state.status} to PAYMENTISSUE`);
132
148
  }
133
149
  },
134
- confirmPaymentOperation(state, action, dispatch) {
150
+ confirmPaymentOperation(state, action) {
135
151
  if (!action.input.id || !action.input.amount) {
136
- throw new Error('ID and amount are required');
152
+ throw new Error("ID and amount are required");
137
153
  }
138
- if (permittedTransitions[state.status].includes('PAYMENTRECEIVED')) {
139
- state.status = 'PAYMENTRECEIVED';
140
- const payment = state.payments.find(payment => payment.id === action.input.id);
154
+ if (permittedTransitions[state.status].includes("PAYMENTRECEIVED")) {
155
+ state.status = "PAYMENTRECEIVED";
156
+ const payment = state.payments.find((payment) => payment.id === action.input.id);
141
157
  if (!payment)
142
- throw new Error('Payment not found');
158
+ throw new Error("Payment not found");
143
159
  payment.confirmed = true;
144
160
  payment.amount = action.input.amount;
145
161
  }
@@ -147,12 +163,12 @@ export const invoiceTransitionsOperations = {
147
163
  throw new Error(`Invalid transition from ${state.status} to PAYMENTRECEIVED`);
148
164
  }
149
165
  },
150
- closePaymentOperation(state, action, dispatch) {
166
+ closePaymentOperation(state, action) {
151
167
  if (!action.input.closureReason) {
152
- throw new Error('Closure reason is required');
168
+ throw new Error("Closure reason is required");
153
169
  }
154
- if (permittedTransitions[state.status].includes('PAYMENTCLOSED')) {
155
- state.status = 'PAYMENTCLOSED';
170
+ if (permittedTransitions[state.status].includes("PAYMENTCLOSED")) {
171
+ state.status = "PAYMENTCLOSED";
156
172
  state.closureReason = action.input.closureReason;
157
173
  }
158
174
  else {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
1
5
  /**
2
6
  * This is a scaffold file meant for customization:
3
7
  * - change it by adding new tests or modifying the existing ones
@@ -1 +1 @@
1
- {"version":3,"file":"document-model.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/tests/document-model.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
1
+ {"version":3,"file":"document-model.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/tests/document-model.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;;GAGG"}
@@ -2,16 +2,103 @@
2
2
  * This is a scaffold file meant for customization:
3
3
  * - change it by adding new tests or modifying the existing ones
4
4
  */
5
- import { initialGlobalState, initialLocalState, createDocument, } from "../../gen/utils.js";
5
+ /**
6
+ * This is a scaffold file meant for customization:
7
+ * - change it by adding new tests or modifying the existing ones
8
+ */
9
+ import { describe, it, expect } from "vitest";
10
+ import { utils, initialGlobalState, initialLocalState, invoiceDocumentType, isInvoiceDocument, assertIsInvoiceDocument, isInvoiceState, assertIsInvoiceState, } from "@powerhousedao/contributor-billing/document-models/invoice";
11
+ import { ZodError } from "zod";
6
12
  describe("Invoice Document Model", () => {
7
13
  it("should create a new Invoice document", () => {
8
- const document = createDocument();
14
+ const document = utils.createDocument();
9
15
  expect(document).toBeDefined();
10
- expect(document.header?.documentType).toBe("powerhouse/invoice");
16
+ expect(document.header.documentType).toBe(invoiceDocumentType);
11
17
  });
12
18
  it("should create a new Invoice document with a valid initial state", () => {
13
- const document = createDocument();
19
+ const document = utils.createDocument();
14
20
  expect(document.state.global).toStrictEqual(initialGlobalState);
15
21
  expect(document.state.local).toStrictEqual(initialLocalState);
22
+ expect(isInvoiceDocument(document)).toBe(true);
23
+ expect(isInvoiceState(document.state)).toBe(true);
24
+ });
25
+ it("should reject a document that is not a Invoice document", () => {
26
+ const wrongDocumentType = utils.createDocument();
27
+ wrongDocumentType.header.documentType = "the-wrong-thing-1234";
28
+ try {
29
+ expect(assertIsInvoiceDocument(wrongDocumentType)).toThrow();
30
+ expect(isInvoiceDocument(wrongDocumentType)).toBe(false);
31
+ }
32
+ catch (error) {
33
+ expect(error).toBeInstanceOf(ZodError);
34
+ }
16
35
  });
36
+ const wrongState = utils.createDocument();
37
+ // @ts-expect-error - we are testing the error case
38
+ wrongState.state.global = {
39
+ ...{ notWhat: "you want" },
40
+ };
41
+ try {
42
+ expect(isInvoiceState(wrongState.state)).toBe(false);
43
+ expect(assertIsInvoiceState(wrongState.state)).toThrow();
44
+ expect(isInvoiceDocument(wrongState)).toBe(false);
45
+ expect(assertIsInvoiceDocument(wrongState)).toThrow();
46
+ }
47
+ catch (error) {
48
+ expect(error).toBeInstanceOf(ZodError);
49
+ }
50
+ const wrongInitialState = utils.createDocument();
51
+ // @ts-expect-error - we are testing the error case
52
+ wrongInitialState.initialState.global = {
53
+ ...{ notWhat: "you want" },
54
+ };
55
+ try {
56
+ expect(isInvoiceState(wrongInitialState.state)).toBe(false);
57
+ expect(assertIsInvoiceState(wrongInitialState.state)).toThrow();
58
+ expect(isInvoiceDocument(wrongInitialState)).toBe(false);
59
+ expect(assertIsInvoiceDocument(wrongInitialState)).toThrow();
60
+ }
61
+ catch (error) {
62
+ expect(error).toBeInstanceOf(ZodError);
63
+ }
64
+ const missingIdInHeader = utils.createDocument();
65
+ // @ts-expect-error - we are testing the error case
66
+ delete missingIdInHeader.header.id;
67
+ try {
68
+ expect(isInvoiceDocument(missingIdInHeader)).toBe(false);
69
+ expect(assertIsInvoiceDocument(missingIdInHeader)).toThrow();
70
+ }
71
+ catch (error) {
72
+ expect(error).toBeInstanceOf(ZodError);
73
+ }
74
+ const missingNameInHeader = utils.createDocument();
75
+ // @ts-expect-error - we are testing the error case
76
+ delete missingNameInHeader.header.name;
77
+ try {
78
+ expect(isInvoiceDocument(missingNameInHeader)).toBe(false);
79
+ expect(assertIsInvoiceDocument(missingNameInHeader)).toThrow();
80
+ }
81
+ catch (error) {
82
+ expect(error).toBeInstanceOf(ZodError);
83
+ }
84
+ const missingCreatedAtUtcIsoInHeader = utils.createDocument();
85
+ // @ts-expect-error - we are testing the error case
86
+ delete missingCreatedAtUtcIsoInHeader.header.createdAtUtcIso;
87
+ try {
88
+ expect(isInvoiceDocument(missingCreatedAtUtcIsoInHeader)).toBe(false);
89
+ expect(assertIsInvoiceDocument(missingCreatedAtUtcIsoInHeader)).toThrow();
90
+ }
91
+ catch (error) {
92
+ expect(error).toBeInstanceOf(ZodError);
93
+ }
94
+ const missingLastModifiedAtUtcIsoInHeader = utils.createDocument();
95
+ // @ts-expect-error - we are testing the error case
96
+ delete missingLastModifiedAtUtcIsoInHeader.header.lastModifiedAtUtcIso;
97
+ try {
98
+ expect(isInvoiceDocument(missingLastModifiedAtUtcIsoInHeader)).toBe(false);
99
+ expect(assertIsInvoiceDocument(missingLastModifiedAtUtcIsoInHeader)).toThrow();
100
+ }
101
+ catch (error) {
102
+ expect(error).toBeInstanceOf(ZodError);
103
+ }
17
104
  });
@@ -2,50 +2,48 @@
2
2
  * This is a scaffold file meant for customization:
3
3
  * - change it by adding new tests or modifying the existing ones
4
4
  */
5
+ import { describe, it, expect } from "vitest";
5
6
  import { generateMock } from "@powerhousedao/codegen";
6
- import * as utils from "../../gen/utils.js";
7
- import { EditInvoiceInputSchema, EditStatusInputSchema, } from "../../gen/schema/index.js";
8
- import { reducer } from "../../gen/reducer.js";
9
- import * as creators from "../../gen/general/creators.js";
7
+ import { reducer, utils, isInvoiceDocument, editInvoice, EditInvoiceInputSchema, editStatus, EditStatusInputSchema, editPaymentData, EditPaymentDataInputSchema, setExportedData, SetExportedDataInputSchema, } from "@powerhousedao/contributor-billing/document-models/invoice";
10
8
  describe("General Operations", () => {
11
- let document;
12
- beforeEach(() => {
13
- document = utils.createDocument();
14
- });
15
9
  it("should handle editInvoice operation", () => {
10
+ const document = utils.createDocument();
16
11
  const input = generateMock(EditInvoiceInputSchema());
17
- const updatedDocument = reducer(document, creators.editInvoice(input));
12
+ const updatedDocument = reducer(document, editInvoice(input));
13
+ expect(isInvoiceDocument(updatedDocument)).toBe(true);
18
14
  expect(updatedDocument.operations.global).toHaveLength(1);
19
- expect(updatedDocument.operations.global[0].type).toBe("EDIT_INVOICE");
20
- expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
15
+ expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_INVOICE");
16
+ expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
21
17
  expect(updatedDocument.operations.global[0].index).toEqual(0);
22
18
  });
23
19
  it("should handle editStatus operation", () => {
20
+ const document = utils.createDocument();
24
21
  const input = generateMock(EditStatusInputSchema());
25
- const updatedDocument = reducer(document, creators.editStatus(input));
22
+ const updatedDocument = reducer(document, editStatus(input));
23
+ expect(isInvoiceDocument(updatedDocument)).toBe(true);
26
24
  expect(updatedDocument.operations.global).toHaveLength(1);
27
- expect(updatedDocument.operations.global[0].type).toBe("EDIT_STATUS");
28
- expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
25
+ expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_STATUS");
26
+ expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
29
27
  expect(updatedDocument.operations.global[0].index).toEqual(0);
30
28
  });
31
29
  it("should handle editPaymentData operation", () => {
32
- const invoice = utils.createDocument();
33
- const paymentDate = new Date().toISOString();
34
- const updatedDocument = reducer(invoice, creators.editPaymentData({ paymentDate: paymentDate, txnRef: "0x123", confirmed: true, id: "123" }));
30
+ const document = utils.createDocument();
31
+ const input = generateMock(EditPaymentDataInputSchema());
32
+ const updatedDocument = reducer(document, editPaymentData(input));
33
+ expect(isInvoiceDocument(updatedDocument)).toBe(true);
35
34
  expect(updatedDocument.operations.global).toHaveLength(1);
36
- expect(updatedDocument.operations.global[0].type).toBe("EDIT_PAYMENT_DATA");
37
- expect(updatedDocument.operations.global[0].input).toEqual({ paymentDate: paymentDate, txnRef: "0x123", confirmed: true, id: "123" });
35
+ expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_PAYMENT_DATA");
36
+ expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
38
37
  expect(updatedDocument.operations.global[0].index).toEqual(0);
39
38
  });
40
39
  it("should handle setExportedData operation", () => {
41
- const input = {
42
- timestamp: '2025-01-01T00:00:00Z',
43
- exportedLineItems: [['1', '2', '3'], ['4', '5', '6']]
44
- };
45
- const updatedDocument = reducer(document, creators.setExportedData(input));
40
+ const document = utils.createDocument();
41
+ const input = generateMock(SetExportedDataInputSchema());
42
+ const updatedDocument = reducer(document, setExportedData(input));
43
+ expect(isInvoiceDocument(updatedDocument)).toBe(true);
46
44
  expect(updatedDocument.operations.global).toHaveLength(1);
47
- expect(updatedDocument.operations.global[0].type).toBe("SET_EXPORTED_DATA");
48
- expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
45
+ expect(updatedDocument.operations.global[0].action.type).toBe("SET_EXPORTED_DATA");
46
+ expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
49
47
  expect(updatedDocument.operations.global[0].index).toEqual(0);
50
48
  });
51
49
  });