@powerhousedao/contributor-billing 0.0.1

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 (282) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +22 -0
  3. package/dist/document-models/index.d.ts +2 -0
  4. package/dist/document-models/index.d.ts.map +1 -0
  5. package/dist/document-models/index.js +1 -0
  6. package/dist/document-models/invoice/gen/actions.d.ts +8 -0
  7. package/dist/document-models/invoice/gen/actions.d.ts.map +1 -0
  8. package/dist/document-models/invoice/gen/actions.js +3 -0
  9. package/dist/document-models/invoice/gen/creators.d.ts +4 -0
  10. package/dist/document-models/invoice/gen/creators.d.ts.map +1 -0
  11. package/dist/document-models/invoice/gen/creators.js +3 -0
  12. package/dist/document-models/invoice/gen/document-model.d.ts +3 -0
  13. package/dist/document-models/invoice/gen/document-model.d.ts.map +1 -0
  14. package/dist/document-models/invoice/gen/document-model.js +227 -0
  15. package/dist/document-models/invoice/gen/general/actions.d.ts +10 -0
  16. package/dist/document-models/invoice/gen/general/actions.d.ts.map +1 -0
  17. package/dist/document-models/invoice/gen/general/actions.js +1 -0
  18. package/dist/document-models/invoice/gen/general/creators.d.ts +9 -0
  19. package/dist/document-models/invoice/gen/general/creators.d.ts.map +1 -0
  20. package/dist/document-models/invoice/gen/general/creators.js +8 -0
  21. package/dist/document-models/invoice/gen/general/error.d.ts +2 -0
  22. package/dist/document-models/invoice/gen/general/error.d.ts.map +1 -0
  23. package/dist/document-models/invoice/gen/general/error.js +1 -0
  24. package/dist/document-models/invoice/gen/general/object.d.ts +12 -0
  25. package/dist/document-models/invoice/gen/general/object.d.ts.map +1 -0
  26. package/dist/document-models/invoice/gen/general/object.js +22 -0
  27. package/dist/document-models/invoice/gen/general/operations.d.ts +12 -0
  28. package/dist/document-models/invoice/gen/general/operations.d.ts.map +1 -0
  29. package/dist/document-models/invoice/gen/general/operations.js +1 -0
  30. package/dist/document-models/invoice/gen/index.d.ts +6 -0
  31. package/dist/document-models/invoice/gen/index.d.ts.map +1 -0
  32. package/dist/document-models/invoice/gen/index.js +5 -0
  33. package/dist/document-models/invoice/gen/items/actions.d.ts +8 -0
  34. package/dist/document-models/invoice/gen/items/actions.d.ts.map +1 -0
  35. package/dist/document-models/invoice/gen/items/actions.js +1 -0
  36. package/dist/document-models/invoice/gen/items/creators.d.ts +7 -0
  37. package/dist/document-models/invoice/gen/items/creators.d.ts.map +1 -0
  38. package/dist/document-models/invoice/gen/items/creators.js +6 -0
  39. package/dist/document-models/invoice/gen/items/error.d.ts +2 -0
  40. package/dist/document-models/invoice/gen/items/error.d.ts.map +1 -0
  41. package/dist/document-models/invoice/gen/items/error.js +1 -0
  42. package/dist/document-models/invoice/gen/items/object.d.ts +10 -0
  43. package/dist/document-models/invoice/gen/items/object.d.ts.map +1 -0
  44. package/dist/document-models/invoice/gen/items/object.js +16 -0
  45. package/dist/document-models/invoice/gen/items/operations.d.ts +10 -0
  46. package/dist/document-models/invoice/gen/items/operations.d.ts.map +1 -0
  47. package/dist/document-models/invoice/gen/items/operations.js +1 -0
  48. package/dist/document-models/invoice/gen/object.d.ts +20 -0
  49. package/dist/document-models/invoice/gen/object.d.ts.map +1 -0
  50. package/dist/document-models/invoice/gen/object.js +29 -0
  51. package/dist/document-models/invoice/gen/parties/actions.d.ts +10 -0
  52. package/dist/document-models/invoice/gen/parties/actions.d.ts.map +1 -0
  53. package/dist/document-models/invoice/gen/parties/actions.js +1 -0
  54. package/dist/document-models/invoice/gen/parties/creators.d.ts +9 -0
  55. package/dist/document-models/invoice/gen/parties/creators.d.ts.map +1 -0
  56. package/dist/document-models/invoice/gen/parties/creators.js +8 -0
  57. package/dist/document-models/invoice/gen/parties/error.d.ts +2 -0
  58. package/dist/document-models/invoice/gen/parties/error.d.ts.map +1 -0
  59. package/dist/document-models/invoice/gen/parties/error.js +1 -0
  60. package/dist/document-models/invoice/gen/parties/object.d.ts +12 -0
  61. package/dist/document-models/invoice/gen/parties/object.d.ts.map +1 -0
  62. package/dist/document-models/invoice/gen/parties/object.js +22 -0
  63. package/dist/document-models/invoice/gen/parties/operations.d.ts +12 -0
  64. package/dist/document-models/invoice/gen/parties/operations.d.ts.map +1 -0
  65. package/dist/document-models/invoice/gen/parties/operations.js +1 -0
  66. package/dist/document-models/invoice/gen/reducer.d.ts +3 -0
  67. package/dist/document-models/invoice/gen/reducer.d.ts.map +1 -0
  68. package/dist/document-models/invoice/gen/reducer.js +79 -0
  69. package/dist/document-models/invoice/gen/schema/index.d.ts +3 -0
  70. package/dist/document-models/invoice/gen/schema/index.d.ts.map +1 -0
  71. package/dist/document-models/invoice/gen/schema/index.js +2 -0
  72. package/dist/document-models/invoice/gen/schema/types.d.ts +390 -0
  73. package/dist/document-models/invoice/gen/schema/types.d.ts.map +1 -0
  74. package/dist/document-models/invoice/gen/schema/types.js +1 -0
  75. package/dist/document-models/invoice/gen/schema/zod.d.ts +56 -0
  76. package/dist/document-models/invoice/gen/schema/zod.d.ts.map +1 -0
  77. package/dist/document-models/invoice/gen/schema/zod.js +362 -0
  78. package/dist/document-models/invoice/gen/types.d.ts +10 -0
  79. package/dist/document-models/invoice/gen/types.d.ts.map +1 -0
  80. package/dist/document-models/invoice/gen/types.js +1 -0
  81. package/dist/document-models/invoice/gen/utils.d.ts +7 -0
  82. package/dist/document-models/invoice/gen/utils.d.ts.map +1 -0
  83. package/dist/document-models/invoice/gen/utils.js +166 -0
  84. package/dist/document-models/invoice/index.d.ts +41 -0
  85. package/dist/document-models/invoice/index.d.ts.map +1 -0
  86. package/dist/document-models/invoice/index.js +21 -0
  87. package/dist/document-models/invoice/src/reducers/general.d.ts +8 -0
  88. package/dist/document-models/invoice/src/reducers/general.d.ts.map +1 -0
  89. package/dist/document-models/invoice/src/reducers/general.js +79 -0
  90. package/dist/document-models/invoice/src/reducers/items.d.ts +8 -0
  91. package/dist/document-models/invoice/src/reducers/items.d.ts.map +1 -0
  92. package/dist/document-models/invoice/src/reducers/items.js +108 -0
  93. package/dist/document-models/invoice/src/reducers/parties.d.ts +8 -0
  94. package/dist/document-models/invoice/src/reducers/parties.d.ts.map +1 -0
  95. package/dist/document-models/invoice/src/reducers/parties.js +266 -0
  96. package/dist/document-models/invoice/src/tests/document-model.test.d.ts +6 -0
  97. package/dist/document-models/invoice/src/tests/document-model.test.d.ts.map +1 -0
  98. package/dist/document-models/invoice/src/tests/document-model.test.js +17 -0
  99. package/dist/document-models/invoice/src/tests/general.test.d.ts +6 -0
  100. package/dist/document-models/invoice/src/tests/general.test.d.ts.map +1 -0
  101. package/dist/document-models/invoice/src/tests/general.test.js +75 -0
  102. package/dist/document-models/invoice/src/tests/items.test.d.ts +6 -0
  103. package/dist/document-models/invoice/src/tests/items.test.d.ts.map +1 -0
  104. package/dist/document-models/invoice/src/tests/items.test.js +45 -0
  105. package/dist/document-models/invoice/src/tests/parties.test.d.ts +6 -0
  106. package/dist/document-models/invoice/src/tests/parties.test.d.ts.map +1 -0
  107. package/dist/document-models/invoice/src/tests/parties.test.js +75 -0
  108. package/dist/document-models/invoice/src/utils.d.ts +2 -0
  109. package/dist/document-models/invoice/src/utils.d.ts.map +1 -0
  110. package/dist/document-models/invoice/src/utils.js +1 -0
  111. package/dist/editors/contributor-billing/components/CreateDocument.d.ts +8 -0
  112. package/dist/editors/contributor-billing/components/CreateDocument.d.ts.map +1 -0
  113. package/dist/editors/contributor-billing/components/CreateDocument.js +14 -0
  114. package/dist/editors/contributor-billing/components/DocumentDispatch.d.ts +12 -0
  115. package/dist/editors/contributor-billing/components/DocumentDispatch.d.ts.map +1 -0
  116. package/dist/editors/contributor-billing/components/DocumentDispatch.js +20 -0
  117. package/dist/editors/contributor-billing/components/DriveExplorer.d.ts +17 -0
  118. package/dist/editors/contributor-billing/components/DriveExplorer.d.ts.map +1 -0
  119. package/dist/editors/contributor-billing/components/DriveExplorer.js +112 -0
  120. package/dist/editors/contributor-billing/components/EditorContainer.d.ts +14 -0
  121. package/dist/editors/contributor-billing/components/EditorContainer.d.ts.map +1 -0
  122. package/dist/editors/contributor-billing/components/EditorContainer.js +28 -0
  123. package/dist/editors/contributor-billing/components/FileItemsGrid.d.ts +12 -0
  124. package/dist/editors/contributor-billing/components/FileItemsGrid.d.ts.map +1 -0
  125. package/dist/editors/contributor-billing/components/FileItemsGrid.js +7 -0
  126. package/dist/editors/contributor-billing/components/FolderItemsGrid.d.ts +17 -0
  127. package/dist/editors/contributor-billing/components/FolderItemsGrid.d.ts.map +1 -0
  128. package/dist/editors/contributor-billing/components/FolderItemsGrid.js +14 -0
  129. package/dist/editors/contributor-billing/components/FolderTree.d.ts +9 -0
  130. package/dist/editors/contributor-billing/components/FolderTree.d.ts.map +1 -0
  131. package/dist/editors/contributor-billing/components/FolderTree.js +31 -0
  132. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts +16 -0
  133. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -0
  134. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.js +16 -0
  135. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts +21 -0
  136. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -0
  137. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.js +45 -0
  138. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts +12 -0
  139. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts.map +1 -0
  140. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.js +12 -0
  141. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableSection.d.ts +7 -0
  142. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableSection.d.ts.map +1 -0
  143. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableSection.js +7 -0
  144. package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.d.ts +8 -0
  145. package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.d.ts.map +1 -0
  146. package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.js +2 -0
  147. package/dist/editors/contributor-billing/editor.d.ts +6 -0
  148. package/dist/editors/contributor-billing/editor.d.ts.map +1 -0
  149. package/dist/editors/contributor-billing/editor.js +48 -0
  150. package/dist/editors/contributor-billing/hooks/useDispatchMap.d.ts +9 -0
  151. package/dist/editors/contributor-billing/hooks/useDispatchMap.d.ts.map +1 -0
  152. package/dist/editors/contributor-billing/hooks/useDispatchMap.js +21 -0
  153. package/dist/editors/contributor-billing/hooks/useDrop.d.ts +22 -0
  154. package/dist/editors/contributor-billing/hooks/useDrop.d.ts.map +1 -0
  155. package/dist/editors/contributor-billing/hooks/useDrop.js +57 -0
  156. package/dist/editors/contributor-billing/hooks/useSelectedFolderChildren.d.ts +8 -0
  157. package/dist/editors/contributor-billing/hooks/useSelectedFolderChildren.d.ts.map +1 -0
  158. package/dist/editors/contributor-billing/hooks/useSelectedFolderChildren.js +19 -0
  159. package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts +4 -0
  160. package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts.map +1 -0
  161. package/dist/editors/contributor-billing/hooks/useTransformedNodes.js +32 -0
  162. package/dist/editors/contributor-billing/index.d.ts +5 -0
  163. package/dist/editors/contributor-billing/index.d.ts.map +1 -0
  164. package/dist/editors/contributor-billing/index.js +12 -0
  165. package/dist/editors/index.d.ts +3 -0
  166. package/dist/editors/index.d.ts.map +1 -0
  167. package/dist/editors/index.js +2 -0
  168. package/dist/editors/invoice/InvoicePDF.d.ts +8 -0
  169. package/dist/editors/invoice/InvoicePDF.d.ts.map +1 -0
  170. package/dist/editors/invoice/InvoicePDF.js +359 -0
  171. package/dist/editors/invoice/assets/custom.d.ts +4 -0
  172. package/dist/editors/invoice/assets/powerhouseLogo.png +0 -0
  173. package/dist/editors/invoice/components/countryForm.d.ts +12 -0
  174. package/dist/editors/invoice/components/countryForm.d.ts.map +1 -0
  175. package/dist/editors/invoice/components/countryForm.js +28 -0
  176. package/dist/editors/invoice/components/currencyForm.d.ts +13 -0
  177. package/dist/editors/invoice/components/currencyForm.d.ts.map +1 -0
  178. package/dist/editors/invoice/components/currencyForm.js +26 -0
  179. package/dist/editors/invoice/components/datePicker.d.ts +11 -0
  180. package/dist/editors/invoice/components/datePicker.d.ts.map +1 -0
  181. package/dist/editors/invoice/components/datePicker.js +8 -0
  182. package/dist/editors/invoice/components/inputField.d.ts +14 -0
  183. package/dist/editors/invoice/components/inputField.d.ts.map +1 -0
  184. package/dist/editors/invoice/components/inputField.js +25 -0
  185. package/dist/editors/invoice/components/numberForm.d.ts +11 -0
  186. package/dist/editors/invoice/components/numberForm.d.ts.map +1 -0
  187. package/dist/editors/invoice/components/numberForm.js +7 -0
  188. package/dist/editors/invoice/components/selectField.d.ts +8 -0
  189. package/dist/editors/invoice/components/selectField.d.ts.map +1 -0
  190. package/dist/editors/invoice/components/selectField.js +323 -0
  191. package/dist/editors/invoice/editor.d.ts +5 -0
  192. package/dist/editors/invoice/editor.d.ts.map +1 -0
  193. package/dist/editors/invoice/editor.js +377 -0
  194. package/dist/editors/invoice/exportUBL.d.ts +85 -0
  195. package/dist/editors/invoice/exportUBL.d.ts.map +1 -0
  196. package/dist/editors/invoice/exportUBL.js +382 -0
  197. package/dist/editors/invoice/index.d.ts +5 -0
  198. package/dist/editors/invoice/index.d.ts.map +1 -0
  199. package/dist/editors/invoice/index.js +12 -0
  200. package/dist/editors/invoice/ingestPDF.d.ts +12 -0
  201. package/dist/editors/invoice/ingestPDF.d.ts.map +1 -0
  202. package/dist/editors/invoice/ingestPDF.js +193 -0
  203. package/dist/editors/invoice/ingestUBL.d.ts +21 -0
  204. package/dist/editors/invoice/ingestUBL.d.ts.map +1 -0
  205. package/dist/editors/invoice/ingestUBL.js +169 -0
  206. package/dist/editors/invoice/invoiceToGnosis.d.ts +7 -0
  207. package/dist/editors/invoice/invoiceToGnosis.d.ts.map +1 -0
  208. package/dist/editors/invoice/invoiceToGnosis.js +139 -0
  209. package/dist/editors/invoice/legalEntity/bankSection.d.ts +14 -0
  210. package/dist/editors/invoice/legalEntity/bankSection.d.ts.map +1 -0
  211. package/dist/editors/invoice/legalEntity/bankSection.js +156 -0
  212. package/dist/editors/invoice/legalEntity/common.d.ts +6 -0
  213. package/dist/editors/invoice/legalEntity/common.d.ts.map +1 -0
  214. package/dist/editors/invoice/legalEntity/common.js +6 -0
  215. package/dist/editors/invoice/legalEntity/legalEntity.d.ts +40 -0
  216. package/dist/editors/invoice/legalEntity/legalEntity.d.ts.map +1 -0
  217. package/dist/editors/invoice/legalEntity/legalEntity.js +63 -0
  218. package/dist/editors/invoice/legalEntity/walletSection.d.ts +13 -0
  219. package/dist/editors/invoice/legalEntity/walletSection.d.ts.map +1 -0
  220. package/dist/editors/invoice/legalEntity/walletSection.js +55 -0
  221. package/dist/editors/invoice/lineItems.d.ts +23 -0
  222. package/dist/editors/invoice/lineItems.d.ts.map +1 -0
  223. package/dist/editors/invoice/lineItems.js +157 -0
  224. package/dist/editors/invoice/requestFinance.d.ts +7 -0
  225. package/dist/editors/invoice/requestFinance.d.ts.map +1 -0
  226. package/dist/editors/invoice/requestFinance.js +155 -0
  227. package/dist/editors/invoice/uploadPdfChunked.d.ts +10 -0
  228. package/dist/editors/invoice/uploadPdfChunked.d.ts.map +1 -0
  229. package/dist/editors/invoice/uploadPdfChunked.js +79 -0
  230. package/dist/editors/invoice/utils/utils.d.ts +2 -0
  231. package/dist/editors/invoice/utils/utils.d.ts.map +1 -0
  232. package/dist/editors/invoice/utils/utils.js +54 -0
  233. package/dist/editors/invoice/validation/validationManager.d.ts +28 -0
  234. package/dist/editors/invoice/validation/validationManager.d.ts.map +1 -0
  235. package/dist/editors/invoice/validation/validationManager.js +65 -0
  236. package/dist/editors/invoice/validation/validationRules.d.ts +14 -0
  237. package/dist/editors/invoice/validation/validationRules.d.ts.map +1 -0
  238. package/dist/editors/invoice/validation/validationRules.js +334 -0
  239. package/dist/index.d.ts +5 -0
  240. package/dist/index.d.ts.map +1 -0
  241. package/dist/index.js +6 -0
  242. package/dist/powerhouse.manifest.json +31 -0
  243. package/dist/processors/index.d.ts +2 -0
  244. package/dist/processors/index.d.ts.map +1 -0
  245. package/dist/processors/index.js +1 -0
  246. package/dist/scripts/invoice/exampleBatchTxn.d.ts +2 -0
  247. package/dist/scripts/invoice/exampleBatchTxn.d.ts.map +1 -0
  248. package/dist/scripts/invoice/exampleBatchTxn.js +44 -0
  249. package/dist/scripts/invoice/gnosisTransactionBuilder.d.ts +28 -0
  250. package/dist/scripts/invoice/gnosisTransactionBuilder.d.ts.map +1 -0
  251. package/dist/scripts/invoice/gnosisTransactionBuilder.js +74 -0
  252. package/dist/scripts/invoice/pdfToDocumentAi.d.ts +5 -0
  253. package/dist/scripts/invoice/pdfToDocumentAi.d.ts.map +1 -0
  254. package/dist/scripts/invoice/pdfToDocumentAi.js +659 -0
  255. package/dist/scripts/invoice/requestFinance.d.ts +2 -0
  256. package/dist/scripts/invoice/requestFinance.d.ts.map +1 -0
  257. package/dist/scripts/invoice/requestFinance.js +38 -0
  258. package/dist/style.css +6463 -0
  259. package/dist/subgraphs/index.d.ts +2 -0
  260. package/dist/subgraphs/index.d.ts.map +1 -0
  261. package/dist/subgraphs/index.js +1 -0
  262. package/dist/subgraphs/invoice/customResolvers.d.ts +50 -0
  263. package/dist/subgraphs/invoice/customResolvers.d.ts.map +1 -0
  264. package/dist/subgraphs/invoice/customResolvers.js +327 -0
  265. package/dist/subgraphs/invoice/index.d.ts +10 -0
  266. package/dist/subgraphs/invoice/index.d.ts.map +1 -0
  267. package/dist/subgraphs/invoice/index.js +30 -0
  268. package/dist/subgraphs/invoice/resolvers.d.ts +3 -0
  269. package/dist/subgraphs/invoice/resolvers.d.ts.map +1 -0
  270. package/dist/subgraphs/invoice/resolvers.js +184 -0
  271. package/dist/subgraphs/invoice/schema.d.ts +3 -0
  272. package/dist/subgraphs/invoice/schema.d.ts.map +1 -0
  273. package/dist/subgraphs/invoice/schema.js +460 -0
  274. package/dist/tailwind.config.d.ts +13 -0
  275. package/dist/tailwind.config.d.ts.map +1 -0
  276. package/dist/tailwind.config.js +15 -0
  277. package/dist/vitest.config.d.ts +3 -0
  278. package/dist/vitest.config.d.ts.map +1 -0
  279. package/dist/vitest.config.js +8 -0
  280. package/editors/invoice/assets/custom.d.ts +4 -0
  281. package/editors/invoice/assets/powerhouseLogo.png +0 -0
  282. package/package.json +117 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * This is a scaffold file meant for customization.
3
+ * Delete the file and run the code generator again to have it reset
4
+ */
5
+ import { actions as BaseActions, } from "document-model";
6
+ import { actions as InvoiceActions } from "./gen/index.js";
7
+ import { reducer } from "./gen/reducer.js";
8
+ import { documentModel } from "./gen/document-model.js";
9
+ import genUtils from "./gen/utils.js";
10
+ import * as customUtils from "./src/utils.js";
11
+ const utils = { ...genUtils, ...customUtils };
12
+ const actions = { ...BaseActions, ...InvoiceActions };
13
+ export const module = {
14
+ reducer,
15
+ actions,
16
+ utils,
17
+ documentModel,
18
+ };
19
+ export { reducer, actions, utils, documentModel };
20
+ export * from "./gen/types.js";
21
+ export * from "./src/utils.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - modify it by implementing the reducer functions
4
+ * - delete the file and run the code generator again to have it reset
5
+ */
6
+ import type { InvoiceGeneralOperations } from "../../gen/general/operations.js";
7
+ export declare const reducer: InvoiceGeneralOperations;
8
+ //# sourceMappingURL=general.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/reducers/general.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAEhF,eAAO,MAAM,OAAO,EAAE,wBA+DrB,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - modify it by implementing the reducer functions
4
+ * - delete the file and run the code generator again to have it reset
5
+ */
6
+ export const reducer = {
7
+ editInvoiceOperation(state, action, dispatch) {
8
+ try {
9
+ const newState = { ...state };
10
+ newState.currency = action.input.currency ?? state.currency;
11
+ newState.dateDelivered =
12
+ action.input.dateDelivered ?? state.dateDelivered;
13
+ newState.dateDue = action.input.dateDue ?? state.dateDue;
14
+ newState.dateIssued = action.input.dateIssued ?? state.dateIssued;
15
+ newState.invoiceNo = action.input.invoiceNo ?? state.invoiceNo;
16
+ state = Object.assign(state, newState);
17
+ }
18
+ catch (e) {
19
+ console.error(e);
20
+ }
21
+ },
22
+ editStatusOperation(state, action, dispatch) {
23
+ try {
24
+ state.status = action.input.status;
25
+ }
26
+ catch (e) {
27
+ console.error(e);
28
+ }
29
+ },
30
+ addRefOperation(state, action, dispatch) {
31
+ try {
32
+ if (!action.input.id)
33
+ throw new Error("No input.id");
34
+ if (!action.input.value)
35
+ throw new Error("No input.value");
36
+ if (state.refs.find((r) => r.id == action.input.id))
37
+ throw new Error("Ref already exists with provided input.id");
38
+ state.refs.push(action.input);
39
+ }
40
+ catch (e) {
41
+ console.error(e);
42
+ }
43
+ },
44
+ editRefOperation(state, action, dispatch) {
45
+ try {
46
+ if (!action.input.id)
47
+ throw new Error("No input.id");
48
+ if (!action.input.value)
49
+ throw new Error("No input.value");
50
+ let ref = state.refs.find((r) => r.id == action.input.id);
51
+ if (!ref)
52
+ throw new Error("Ref not found with provided input.id");
53
+ ref = action.input;
54
+ }
55
+ catch (e) {
56
+ console.error(e);
57
+ }
58
+ },
59
+ deleteRefOperation(state, action, dispatch) {
60
+ try {
61
+ if (!action.input.id)
62
+ throw new Error("No input.id");
63
+ state.refs = state.refs.filter((r) => r.id !== action.input.id);
64
+ }
65
+ catch (e) {
66
+ console.error(e);
67
+ }
68
+ },
69
+ setPaymentAccountOperation(state, action, dispatch) {
70
+ try {
71
+ if (!action.input.paymentAccount)
72
+ throw new Error("No input.paymentAccount");
73
+ state.paymentAccount = action.input.paymentAccount;
74
+ }
75
+ catch (e) {
76
+ console.error(e);
77
+ }
78
+ },
79
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - modify it by implementing the reducer functions
4
+ * - delete the file and run the code generator again to have it reset
5
+ */
6
+ import type { InvoiceItemsOperations } from "../../gen/items/operations.js";
7
+ export declare const reducer: InvoiceItemsOperations;
8
+ //# sourceMappingURL=items.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/reducers/items.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAG5E,eAAO,MAAM,OAAO,EAAE,sBA6ErB,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - modify it by implementing the reducer functions
4
+ * - delete the file and run the code generator again to have it reset
5
+ */
6
+ export const reducer = {
7
+ addLineItemOperation(state, action, dispatch) {
8
+ try {
9
+ const item = {
10
+ ...action.input,
11
+ lineItemTag: [],
12
+ };
13
+ if (state.lineItems.find((x) => x.id === item.id))
14
+ throw new Error("Duplicate input.id");
15
+ validatePrices(item);
16
+ state.lineItems.push(item);
17
+ updateTotals(state);
18
+ }
19
+ catch (e) {
20
+ console.error(e);
21
+ }
22
+ },
23
+ editLineItemOperation(state, action, dispatch) {
24
+ try {
25
+ const stateItem = state.lineItems.find((x) => x.id === action.input.id);
26
+ if (!stateItem)
27
+ throw new Error("Item matching input.id not found");
28
+ const sanitizedInput = Object.fromEntries(Object.entries(action.input).filter(([, value]) => value !== null));
29
+ // Ensure lineItemTag is always an array if provided
30
+ if ('lineItemTag' in action.input) {
31
+ sanitizedInput.lineItemTag = (action.input.lineItemTag ?? []);
32
+ }
33
+ const nextItem = {
34
+ ...stateItem,
35
+ ...sanitizedInput,
36
+ };
37
+ validatePrices(nextItem);
38
+ Object.assign(stateItem, nextItem);
39
+ updateTotals(state);
40
+ }
41
+ catch (e) {
42
+ console.error(e);
43
+ }
44
+ },
45
+ deleteLineItemOperation(state, action, dispatch) {
46
+ try {
47
+ state.lineItems = state.lineItems.filter((x) => x.id !== action.input.id);
48
+ updateTotals(state);
49
+ }
50
+ catch (e) {
51
+ console.error(e);
52
+ }
53
+ },
54
+ setLineItemTagOperation(state, action, dispatch) {
55
+ try {
56
+ const stateItem = state.lineItems.find((x) => x.id === action.input.id);
57
+ if (!stateItem)
58
+ throw new Error("Item matching input.id not found");
59
+ const newTag = {
60
+ dimension: action.input.dimension,
61
+ value: action.input.value,
62
+ label: action.input.label || null,
63
+ };
64
+ // Remove existing tag with same dimension if it exists
65
+ stateItem.lineItemTag = stateItem.lineItemTag.filter((tag) => tag.dimension !== action.input.dimension);
66
+ // Add the new tag
67
+ stateItem.lineItemTag.push(newTag);
68
+ }
69
+ catch (e) {
70
+ console.error(e);
71
+ }
72
+ },
73
+ };
74
+ function updateTotals(state) {
75
+ state.totalPriceTaxExcl = state.lineItems.reduce((total, lineItem) => {
76
+ return total + lineItem.quantity * lineItem.unitPriceTaxExcl;
77
+ }, 0.0);
78
+ state.totalPriceTaxIncl = state.lineItems.reduce((total, lineItem) => {
79
+ return total + lineItem.quantity * lineItem.unitPriceTaxIncl;
80
+ }, 0.0);
81
+ }
82
+ function validatePrices(item) {
83
+ const EPSILON = 0.00001; // Small value for floating point comparisons
84
+ // Calculate total prices from unit prices and quantity
85
+ const calcPriceIncl = item.quantity * item.unitPriceTaxIncl;
86
+ const calcPriceExcl = item.quantity * item.unitPriceTaxExcl;
87
+ // Convert tax percentage to decimal rate
88
+ const taxRate = item.taxPercent / 100;
89
+ // Helper function to compare floating point numbers
90
+ const isClose = (a, b) => Math.abs(a - b) < EPSILON;
91
+ // Validate unit prices (tax-exclusive should equal tax-inclusive / (1 + taxRate))
92
+ const expectedUnitPriceExcl = item.unitPriceTaxIncl / (1 + taxRate);
93
+ if (!isClose(item.unitPriceTaxExcl, expectedUnitPriceExcl)) {
94
+ throw new Error("Tax inclusive/exclusive unit prices failed comparison.");
95
+ }
96
+ // Validate total prices
97
+ if (!isClose(calcPriceIncl, item.totalPriceTaxIncl)) {
98
+ throw new Error("Calculated unitPriceTaxIncl does not match input total");
99
+ }
100
+ if (!isClose(calcPriceExcl, item.totalPriceTaxExcl)) {
101
+ throw new Error("Calculated unitPriceTaxExcl does not match input total");
102
+ }
103
+ // Validate total prices using the tax rate
104
+ const expectedTotalPriceExcl = calcPriceIncl / (1 + taxRate);
105
+ if (!isClose(calcPriceExcl, expectedTotalPriceExcl)) {
106
+ throw new Error("Tax inclusive/exclusive totals failed comparison.");
107
+ }
108
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - modify it by implementing the reducer functions
4
+ * - delete the file and run the code generator again to have it reset
5
+ */
6
+ import type { InvoicePartiesOperations } from "../../gen/parties/operations.js";
7
+ export declare const reducer: InvoicePartiesOperations;
8
+ //# sourceMappingURL=parties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parties.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/reducers/parties.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAShF,eAAO,MAAM,OAAO,EAAE,wBAwarB,CAAC"}
@@ -0,0 +1,266 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - modify it by implementing the reducer functions
4
+ * - delete the file and run the code generator again to have it reset
5
+ */
6
+ function getStateValue(input, currentValue) {
7
+ return input === undefined ? currentValue : input;
8
+ }
9
+ export const reducer = {
10
+ editIssuerOperation(state, action, dispatch) {
11
+ try {
12
+ if ('address' in state.issuer && ('city' in action.input ||
13
+ 'country' in action.input ||
14
+ 'extendedAddress' in action.input ||
15
+ 'postalCode' in action.input ||
16
+ 'stateProvince' in action.input ||
17
+ 'streetAddress' in action.input)) {
18
+ state.issuer.address = {
19
+ ...state.issuer.address,
20
+ city: action.input.city !== undefined ? action.input.city : state.issuer.address?.city ?? null,
21
+ country: action.input.country !== undefined ? action.input.country : state.issuer.address?.country ?? null,
22
+ extendedAddress: action.input.extendedAddress !== undefined ? action.input.extendedAddress : state.issuer.address?.extendedAddress ?? null,
23
+ postalCode: action.input.postalCode !== undefined ? action.input.postalCode : state.issuer.address?.postalCode ?? null,
24
+ stateProvince: action.input.stateProvince !== undefined ? action.input.stateProvince : state.issuer.address?.stateProvince ?? null,
25
+ streetAddress: action.input.streetAddress !== undefined ? action.input.streetAddress : state.issuer.address?.streetAddress ?? null,
26
+ };
27
+ }
28
+ if ('contactInfo' in state.issuer && ('tel' in action.input ||
29
+ 'email' in action.input)) {
30
+ state.issuer.contactInfo = {
31
+ ...state.issuer.contactInfo,
32
+ tel: action.input.tel !== undefined ? action.input.tel : state.issuer.contactInfo?.tel ?? null,
33
+ email: action.input.email !== undefined ? action.input.email : state.issuer.contactInfo?.email ?? null,
34
+ };
35
+ }
36
+ if ('country' in action.input) {
37
+ state.issuer.country = action.input.country !== undefined ? action.input.country : state.issuer.country ?? null;
38
+ }
39
+ if ('id' in action.input) {
40
+ state.issuer.id = action.input.id ? { taxId: action.input.id } : null;
41
+ }
42
+ if ('name' in action.input) {
43
+ state.issuer.name = action.input.name !== undefined ? action.input.name : state.issuer.name ?? null;
44
+ }
45
+ }
46
+ catch (e) {
47
+ console.error(e);
48
+ }
49
+ },
50
+ editIssuerBankOperation(state, action, dispatch) {
51
+ try {
52
+ if (!state.issuer.paymentRouting) {
53
+ state.issuer.paymentRouting = {
54
+ bank: null,
55
+ wallet: null,
56
+ };
57
+ }
58
+ state.issuer.paymentRouting.bank = {
59
+ ABA: getStateValue(action.input.ABA, state.issuer.paymentRouting.bank?.ABA ?? null),
60
+ BIC: getStateValue(action.input.BIC, state.issuer.paymentRouting.bank?.BIC ?? null),
61
+ SWIFT: getStateValue(action.input.SWIFT, state.issuer.paymentRouting.bank?.SWIFT ?? null),
62
+ accountNum: action.input.accountNum ??
63
+ state.issuer.paymentRouting.bank?.accountNum ??
64
+ "",
65
+ accountType: getStateValue(action.input.accountType, state.issuer.paymentRouting.bank?.accountType ?? null),
66
+ address: {
67
+ city: getStateValue(action.input.city, state.issuer.paymentRouting.bank?.address.city ?? null),
68
+ country: getStateValue(action.input.country, state.issuer.paymentRouting.bank?.address.country ?? null),
69
+ extendedAddress: getStateValue(action.input.extendedAddress, state.issuer.paymentRouting.bank?.address.extendedAddress ?? null),
70
+ postalCode: getStateValue(action.input.postalCode, state.issuer.paymentRouting.bank?.address.postalCode ?? null),
71
+ stateProvince: getStateValue(action.input.stateProvince, state.issuer.paymentRouting.bank?.address.stateProvince ?? null),
72
+ streetAddress: getStateValue(action.input.streetAddress, state.issuer.paymentRouting.bank?.address.streetAddress ?? null),
73
+ },
74
+ beneficiary: getStateValue(action.input.beneficiary, state.issuer.paymentRouting.bank?.beneficiary ?? null),
75
+ name: action.input.name ?? state.issuer.paymentRouting.bank?.name ?? "",
76
+ memo: getStateValue(action.input.memo, state.issuer.paymentRouting.bank?.memo ?? null),
77
+ intermediaryBank: {
78
+ ABA: getStateValue(action.input.ABAIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.ABA ?? null),
79
+ BIC: getStateValue(action.input.BICIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.BIC ?? null),
80
+ SWIFT: getStateValue(action.input.SWIFTIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.SWIFT ?? null),
81
+ accountNum: action.input.accountNumIntermediary ??
82
+ state.issuer.paymentRouting.bank?.intermediaryBank?.accountNum ??
83
+ "",
84
+ accountType: getStateValue(action.input.accountTypeIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.accountType ??
85
+ null),
86
+ address: {
87
+ city: getStateValue(action.input.cityIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.address
88
+ .city ?? null),
89
+ country: getStateValue(action.input.countryIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.address
90
+ .country ?? null),
91
+ extendedAddress: getStateValue(action.input.extendedAddressIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.address
92
+ .extendedAddress ?? null),
93
+ postalCode: getStateValue(action.input.postalCodeIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.address
94
+ .postalCode ?? null),
95
+ stateProvince: getStateValue(action.input.stateProvinceIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.address
96
+ .stateProvince ?? null),
97
+ streetAddress: getStateValue(action.input.streetAddressIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.address
98
+ .streetAddress ?? null),
99
+ },
100
+ beneficiary: getStateValue(action.input.beneficiaryIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.beneficiary ??
101
+ null),
102
+ name: action.input.nameIntermediary ??
103
+ state.issuer.paymentRouting.bank?.intermediaryBank?.name ??
104
+ "",
105
+ memo: getStateValue(action.input.memoIntermediary, state.issuer.paymentRouting.bank?.intermediaryBank?.memo ?? null),
106
+ },
107
+ };
108
+ }
109
+ catch (e) {
110
+ console.error(e);
111
+ }
112
+ },
113
+ editIssuerWalletOperation(state, action, dispatch) {
114
+ try {
115
+ if (!state.issuer.paymentRouting) {
116
+ state.issuer.paymentRouting = {
117
+ bank: null,
118
+ wallet: null,
119
+ };
120
+ }
121
+ state.issuer.paymentRouting.wallet = {
122
+ address: action.input.address ??
123
+ state.issuer.paymentRouting.wallet?.address ??
124
+ null,
125
+ chainId: action.input.chainId ??
126
+ state.issuer.paymentRouting.wallet?.chainId ??
127
+ null,
128
+ chainName: action.input.chainName ??
129
+ state.issuer.paymentRouting.wallet?.chainName ??
130
+ null,
131
+ rpc: action.input.rpc ?? state.issuer.paymentRouting.wallet?.rpc ?? null,
132
+ };
133
+ }
134
+ catch (e) {
135
+ console.error(e);
136
+ }
137
+ },
138
+ editPayerOperation(state, action, dispatch) {
139
+ try {
140
+ if ('address' in state.payer && ('city' in action.input ||
141
+ 'country' in action.input ||
142
+ 'extendedAddress' in action.input ||
143
+ 'postalCode' in action.input ||
144
+ 'stateProvince' in action.input ||
145
+ 'streetAddress' in action.input)) {
146
+ state.payer.address = {
147
+ ...state.payer.address,
148
+ city: action.input.city !== undefined ? action.input.city : state.payer.address?.city ?? null,
149
+ country: action.input.country !== undefined ? action.input.country : state.payer.address?.country ?? null,
150
+ extendedAddress: action.input.extendedAddress !== undefined ? action.input.extendedAddress : state.payer.address?.extendedAddress ?? null,
151
+ postalCode: action.input.postalCode !== undefined ? action.input.postalCode : state.payer.address?.postalCode ?? null,
152
+ stateProvince: action.input.stateProvince !== undefined ? action.input.stateProvince : state.payer.address?.stateProvince ?? null,
153
+ streetAddress: action.input.streetAddress !== undefined ? action.input.streetAddress : state.payer.address?.streetAddress ?? null,
154
+ };
155
+ }
156
+ if ('contactInfo' in state.payer && ('tel' in action.input ||
157
+ 'email' in action.input)) {
158
+ state.payer.contactInfo = {
159
+ ...state.payer.contactInfo,
160
+ tel: action.input.tel !== undefined ? action.input.tel : state.payer.contactInfo?.tel ?? null,
161
+ email: action.input.email !== undefined ? action.input.email : state.payer.contactInfo?.email ?? null,
162
+ };
163
+ }
164
+ if ('country' in action.input) {
165
+ state.payer.country = action.input.country !== undefined ? action.input.country : state.payer.country ?? null;
166
+ }
167
+ if ('id' in action.input) {
168
+ state.payer.id = action.input.id ? { taxId: action.input.id } : null;
169
+ }
170
+ if ('name' in action.input) {
171
+ state.payer.name = action.input.name !== undefined ? action.input.name : state.payer.name ?? null;
172
+ }
173
+ }
174
+ catch (e) {
175
+ console.error(e);
176
+ }
177
+ },
178
+ editPayerBankOperation(state, action, dispatch) {
179
+ try {
180
+ if (!state.payer.paymentRouting) {
181
+ state.payer.paymentRouting = {
182
+ bank: null,
183
+ wallet: null,
184
+ };
185
+ }
186
+ state.payer.paymentRouting.bank = {
187
+ ABA: getStateValue(action.input.ABA, state.payer.paymentRouting.bank?.ABA ?? null),
188
+ BIC: getStateValue(action.input.BIC, state.payer.paymentRouting.bank?.BIC ?? null),
189
+ SWIFT: getStateValue(action.input.SWIFT, state.payer.paymentRouting.bank?.SWIFT ?? null),
190
+ accountNum: action.input.accountNum ??
191
+ state.payer.paymentRouting.bank?.accountNum ??
192
+ "",
193
+ accountType: getStateValue(action.input.accountType, state.payer.paymentRouting.bank?.accountType ?? null),
194
+ address: {
195
+ city: getStateValue(action.input.city, state.payer.paymentRouting.bank?.address.city ?? null),
196
+ country: getStateValue(action.input.country, state.payer.paymentRouting.bank?.address.country ?? null),
197
+ extendedAddress: getStateValue(action.input.extendedAddress, state.payer.paymentRouting.bank?.address.extendedAddress ?? null),
198
+ postalCode: getStateValue(action.input.postalCode, state.payer.paymentRouting.bank?.address.postalCode ?? null),
199
+ stateProvince: getStateValue(action.input.stateProvince, state.payer.paymentRouting.bank?.address.stateProvince ?? null),
200
+ streetAddress: getStateValue(action.input.streetAddress, state.payer.paymentRouting.bank?.address.streetAddress ?? null),
201
+ },
202
+ beneficiary: getStateValue(action.input.beneficiary, state.payer.paymentRouting.bank?.beneficiary ?? null),
203
+ name: action.input.name ?? state.payer.paymentRouting.bank?.name ?? "",
204
+ memo: getStateValue(action.input.memo, state.payer.paymentRouting.bank?.memo ?? null),
205
+ intermediaryBank: {
206
+ ABA: getStateValue(action.input.ABAIntermediary, state.payer.paymentRouting.bank?.intermediaryBank?.ABA ?? null),
207
+ BIC: getStateValue(action.input.BICIntermediary, state.payer.paymentRouting.bank?.intermediaryBank?.BIC ?? null),
208
+ SWIFT: getStateValue(action.input.SWIFTIntermediary, state.payer.paymentRouting.bank?.intermediaryBank?.SWIFT ?? null),
209
+ accountNum: action.input.accountNumIntermediary ??
210
+ state.payer.paymentRouting.bank?.intermediaryBank?.accountNum ??
211
+ "",
212
+ accountType: getStateValue(action.input.accountTypeIntermediary, state.payer.paymentRouting.bank?.intermediaryBank?.accountType ??
213
+ null),
214
+ address: {
215
+ city: getStateValue(action.input.cityIntermediary, state.payer.paymentRouting.bank?.intermediaryBank?.address.city ??
216
+ null),
217
+ country: getStateValue(action.input.countryIntermediary, state.payer.paymentRouting.bank?.intermediaryBank?.address
218
+ .country ?? null),
219
+ extendedAddress: getStateValue(action.input.extendedAddressIntermediary, state.payer.paymentRouting.bank?.intermediaryBank?.address
220
+ .extendedAddress ?? null),
221
+ postalCode: getStateValue(action.input.postalCodeIntermediary, state.payer.paymentRouting.bank?.intermediaryBank?.address
222
+ .postalCode ?? null),
223
+ stateProvince: getStateValue(action.input.stateProvinceIntermediary, state.payer.paymentRouting.bank?.intermediaryBank?.address
224
+ .stateProvince ?? null),
225
+ streetAddress: getStateValue(action.input.streetAddressIntermediary, state.payer.paymentRouting.bank?.intermediaryBank?.address
226
+ .streetAddress ?? null),
227
+ },
228
+ beneficiary: getStateValue(action.input.beneficiaryIntermediary, state.payer.paymentRouting.bank?.intermediaryBank?.beneficiary ??
229
+ null),
230
+ name: action.input.nameIntermediary ??
231
+ state.payer.paymentRouting.bank?.intermediaryBank?.name ??
232
+ "",
233
+ memo: getStateValue(action.input.memoIntermediary, state.payer.paymentRouting.bank?.intermediaryBank?.memo ?? null),
234
+ },
235
+ };
236
+ }
237
+ catch (e) {
238
+ console.error(e);
239
+ }
240
+ },
241
+ editPayerWalletOperation(state, action, dispatch) {
242
+ try {
243
+ if (!state.payer.paymentRouting) {
244
+ state.payer.paymentRouting = {
245
+ bank: null,
246
+ wallet: null,
247
+ };
248
+ }
249
+ state.payer.paymentRouting.wallet = {
250
+ address: action.input.address ??
251
+ state.payer.paymentRouting.wallet?.address ??
252
+ null,
253
+ chainId: action.input.chainId ??
254
+ state.payer.paymentRouting.wallet?.chainId ??
255
+ null,
256
+ chainName: action.input.chainName ??
257
+ state.payer.paymentRouting.wallet?.chainName ??
258
+ null,
259
+ rpc: action.input.rpc ?? state.payer.paymentRouting.wallet?.rpc ?? null,
260
+ };
261
+ }
262
+ catch (e) {
263
+ console.error(e);
264
+ }
265
+ },
266
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=document-model.test.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
5
+ import utils, { initialGlobalState, initialLocalState, } from "../../gen/utils.js";
6
+ describe("Invoice Document Model", () => {
7
+ it("should create a new Invoice document", () => {
8
+ const document = utils.createDocument();
9
+ expect(document).toBeDefined();
10
+ expect(document.documentType).toBe("powerhouse/invoice");
11
+ });
12
+ it("should create a new Invoice document with a valid initial state", () => {
13
+ const document = utils.createDocument();
14
+ expect(document.state.global).toStrictEqual(initialGlobalState);
15
+ expect(document.state.local).toStrictEqual(initialLocalState);
16
+ });
17
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=general.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"general.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/tests/general.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
5
+ import { generateMock } from "@powerhousedao/codegen";
6
+ import utils from "../../gen/utils.js";
7
+ import { z, } from "../../gen/schema/index.js";
8
+ import { reducer } from "../../gen/reducer.js";
9
+ import * as creators from "../../gen/general/creators.js";
10
+ describe("General Operations", () => {
11
+ let document;
12
+ beforeEach(() => {
13
+ document = utils.createDocument();
14
+ });
15
+ it("should handle editInvoice operation", () => {
16
+ // generate a random id
17
+ // const id = documentModelUtils.hashKey();
18
+ const input = generateMock(z.EditInvoiceInputSchema());
19
+ const updatedDocument = reducer(document, creators.editInvoice(input));
20
+ expect(updatedDocument.operations.global).toHaveLength(1);
21
+ expect(updatedDocument.operations.global[0].type).toBe("EDIT_INVOICE");
22
+ expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
23
+ expect(updatedDocument.operations.global[0].index).toEqual(0);
24
+ });
25
+ it("should handle editStatus operation", () => {
26
+ // generate a random id
27
+ // const id = documentModelUtils.hashKey();
28
+ const input = generateMock(z.EditStatusInputSchema());
29
+ const updatedDocument = reducer(document, creators.editStatus(input));
30
+ expect(updatedDocument.operations.global).toHaveLength(1);
31
+ expect(updatedDocument.operations.global[0].type).toBe("EDIT_STATUS");
32
+ expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
33
+ expect(updatedDocument.operations.global[0].index).toEqual(0);
34
+ });
35
+ it("should handle addRef operation", () => {
36
+ // generate a random id
37
+ // const id = documentModelUtils.hashKey();
38
+ const input = generateMock(z.AddRefInputSchema());
39
+ const updatedDocument = reducer(document, creators.addRef(input));
40
+ expect(updatedDocument.operations.global).toHaveLength(1);
41
+ expect(updatedDocument.operations.global[0].type).toBe("ADD_REF");
42
+ expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
43
+ expect(updatedDocument.operations.global[0].index).toEqual(0);
44
+ });
45
+ it("should handle editRef operation", () => {
46
+ // generate a random id
47
+ // const id = documentModelUtils.hashKey();
48
+ const input = generateMock(z.EditRefInputSchema());
49
+ const updatedDocument = reducer(document, creators.editRef(input));
50
+ expect(updatedDocument.operations.global).toHaveLength(1);
51
+ expect(updatedDocument.operations.global[0].type).toBe("EDIT_REF");
52
+ expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
53
+ expect(updatedDocument.operations.global[0].index).toEqual(0);
54
+ });
55
+ it("should handle deleteRef operation", () => {
56
+ // generate a random id
57
+ // const id = documentModelUtils.hashKey();
58
+ const input = generateMock(z.DeleteRefInputSchema());
59
+ const updatedDocument = reducer(document, creators.deleteRef(input));
60
+ expect(updatedDocument.operations.global).toHaveLength(1);
61
+ expect(updatedDocument.operations.global[0].type).toBe("DELETE_REF");
62
+ expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
63
+ expect(updatedDocument.operations.global[0].index).toEqual(0);
64
+ });
65
+ it("should handle setPaymentAccount operation", () => {
66
+ // generate a random id
67
+ // const id = documentModelUtils.hashKey();
68
+ const input = generateMock(z.SetPaymentAccountInputSchema());
69
+ const updatedDocument = reducer(document, creators.setPaymentAccount(input));
70
+ expect(updatedDocument.operations.global).toHaveLength(1);
71
+ expect(updatedDocument.operations.global[0].type).toBe("SET_PAYMENT_ACCOUNT");
72
+ expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
73
+ expect(updatedDocument.operations.global[0].index).toEqual(0);
74
+ });
75
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=items.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"items.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/tests/items.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}