@powerhousedao/contributor-billing 0.0.98 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/document-models/billing-statement/src/reducers/general.d.ts.map +1 -1
  2. package/dist/document-models/billing-statement/src/reducers/general.js +8 -26
  3. package/dist/document-models/billing-statement/src/reducers/line-items.d.ts.map +1 -1
  4. package/dist/document-models/billing-statement/src/reducers/line-items.js +19 -29
  5. package/dist/document-models/billing-statement/src/reducers/tags.d.ts.map +1 -1
  6. package/dist/document-models/billing-statement/src/reducers/tags.js +20 -25
  7. package/dist/document-models/integrations/src/reducers/integrations.d.ts.map +1 -1
  8. package/dist/document-models/integrations/src/reducers/integrations.js +29 -44
  9. package/dist/document-models/invoice/src/reducers/general.d.ts.map +1 -1
  10. package/dist/document-models/invoice/src/reducers/general.js +31 -56
  11. package/dist/document-models/invoice/src/reducers/items.d.ts.map +1 -1
  12. package/dist/document-models/invoice/src/reducers/items.js +63 -88
  13. package/dist/document-models/invoice/src/reducers/parties.d.ts.map +1 -1
  14. package/dist/document-models/invoice/src/reducers/parties.js +199 -229
  15. package/dist/editors/billing-statement/components/lineItemsTable.d.ts +3 -2
  16. package/dist/editors/billing-statement/components/lineItemsTable.d.ts.map +1 -1
  17. package/dist/editors/billing-statement/components/lineItemsTable.js +12 -8
  18. package/dist/editors/billing-statement/components/objectSetTable.d.ts +3 -2
  19. package/dist/editors/billing-statement/components/objectSetTable.d.ts.map +1 -1
  20. package/dist/editors/billing-statement/editor.d.ts +3 -1
  21. package/dist/editors/billing-statement/editor.d.ts.map +1 -1
  22. package/dist/editors/billing-statement/editor.js +2 -2
  23. package/dist/editors/billing-statement/lineItemTags/lineItemTags.d.ts +2 -2
  24. package/dist/editors/billing-statement/lineItemTags/lineItemTags.d.ts.map +1 -1
  25. package/dist/editors/contributor-billing/components/DriveExplorer.d.ts +8 -1
  26. package/dist/editors/contributor-billing/components/DriveExplorer.d.ts.map +1 -1
  27. package/dist/editors/contributor-billing/components/DriveExplorer.js +18 -64
  28. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts +2 -8
  29. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -1
  30. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.js +21 -7
  31. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts +8 -10
  32. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -1
  33. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.js +27 -24
  34. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts +6 -8
  35. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts.map +1 -1
  36. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.js +8 -17
  37. package/dist/editors/contributor-billing/editor.d.ts +1 -10
  38. package/dist/editors/contributor-billing/editor.d.ts.map +1 -1
  39. package/dist/editors/contributor-billing/editor.js +2 -23
  40. package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts +2 -1
  41. package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts.map +1 -1
  42. package/dist/editors/contributor-billing/index.js +1 -1
  43. package/dist/editors/hooks/useBillingStatementDocument.d.ts +4 -0
  44. package/dist/editors/hooks/useBillingStatementDocument.d.ts.map +1 -0
  45. package/dist/editors/hooks/useBillingStatementDocument.js +8 -0
  46. package/dist/editors/hooks/useIntegrationsDocument.d.ts +4 -0
  47. package/dist/editors/hooks/useIntegrationsDocument.d.ts.map +1 -0
  48. package/dist/editors/hooks/useIntegrationsDocument.js +8 -0
  49. package/dist/editors/hooks/useInvoiceDocument.d.ts +4 -0
  50. package/dist/editors/hooks/useInvoiceDocument.d.ts.map +1 -0
  51. package/dist/editors/hooks/useInvoiceDocument.js +8 -0
  52. package/dist/editors/integrations/editor.d.ts +4 -1
  53. package/dist/editors/integrations/editor.d.ts.map +1 -1
  54. package/dist/editors/integrations/editor.js +7 -12
  55. package/dist/editors/invoice/components/lineItemCard.d.ts +21 -0
  56. package/dist/editors/invoice/components/lineItemCard.d.ts.map +1 -0
  57. package/dist/editors/invoice/components/lineItemCard.js +23 -0
  58. package/dist/editors/invoice/components/lineItemMobileModal.d.ts +33 -0
  59. package/dist/editors/invoice/components/lineItemMobileModal.d.ts.map +1 -0
  60. package/dist/editors/invoice/components/lineItemMobileModal.js +73 -0
  61. package/dist/editors/invoice/components/lineItemsEmptyState.d.ts +6 -0
  62. package/dist/editors/invoice/components/lineItemsEmptyState.d.ts.map +1 -0
  63. package/dist/editors/invoice/components/lineItemsEmptyState.js +5 -0
  64. package/dist/editors/invoice/editor.d.ts +4 -1
  65. package/dist/editors/invoice/editor.d.ts.map +1 -1
  66. package/dist/editors/invoice/editor.js +41 -22
  67. package/dist/editors/invoice/ingestPDF.js +1 -1
  68. package/dist/editors/invoice/invoiceToGnosis.d.ts +3 -2
  69. package/dist/editors/invoice/invoiceToGnosis.d.ts.map +1 -1
  70. package/dist/editors/invoice/invoiceToGnosis.js +11 -11
  71. package/dist/editors/invoice/legalEntity/bankSection.d.ts +1 -0
  72. package/dist/editors/invoice/legalEntity/bankSection.d.ts.map +1 -1
  73. package/dist/editors/invoice/legalEntity/bankSection.js +36 -12
  74. package/dist/editors/invoice/legalEntity/legalEntity.d.ts +2 -1
  75. package/dist/editors/invoice/legalEntity/legalEntity.d.ts.map +1 -1
  76. package/dist/editors/invoice/legalEntity/legalEntity.js +2 -2
  77. package/dist/editors/invoice/lineItemTags/lineItemTags.d.ts.map +1 -1
  78. package/dist/editors/invoice/lineItemTags/lineItemTags.js +25 -3
  79. package/dist/editors/invoice/lineItemTags/tagCard.d.ts +15 -0
  80. package/dist/editors/invoice/lineItemTags/tagCard.d.ts.map +1 -0
  81. package/dist/editors/invoice/lineItemTags/tagCard.js +13 -0
  82. package/dist/editors/invoice/lineItemTags/tagMobileModal.d.ts +18 -0
  83. package/dist/editors/invoice/lineItemTags/tagMobileModal.d.ts.map +1 -0
  84. package/dist/editors/invoice/lineItemTags/tagMobileModal.js +71 -0
  85. package/dist/editors/invoice/lineItems.d.ts.map +1 -1
  86. package/dist/editors/invoice/lineItems.js +76 -38
  87. package/dist/editors/invoice/requestFinance.js +2 -2
  88. package/dist/editors/invoice/uploadPdfChunked.js +1 -1
  89. package/dist/editors/invoice/validation/validationHandler.d.ts +1 -1
  90. package/dist/editors/invoice/validation/validationHandler.d.ts.map +1 -1
  91. package/dist/editors/invoice/validation/validationHandler.js +25 -9
  92. package/dist/editors/invoice/validation/validationManager.d.ts.map +1 -1
  93. package/dist/editors/invoice/validation/validationManager.js +3 -2
  94. package/dist/editors/invoice/validation/validationRules.d.ts +2 -0
  95. package/dist/editors/invoice/validation/validationRules.d.ts.map +1 -1
  96. package/dist/editors/invoice/validation/validationRules.js +37 -7
  97. package/dist/scripts/contributor-billing/createExpenseReportCsv.d.ts +5 -0
  98. package/dist/scripts/contributor-billing/createExpenseReportCsv.d.ts.map +1 -0
  99. package/dist/scripts/contributor-billing/createExpenseReportCsv.js +122 -0
  100. package/dist/style.css +180 -12
  101. package/dist/tailwind.config.js +1 -0
  102. package/package.json +13 -12
  103. package/dist/reducers/general.d.ts +0 -8
  104. package/dist/reducers/general.d.ts.map +0 -1
  105. package/dist/reducers/general.js +0 -73
  106. package/dist/reducers/items.d.ts +0 -8
  107. package/dist/reducers/items.d.ts.map +0 -1
  108. package/dist/reducers/items.js +0 -195
  109. package/dist/reducers/parties.d.ts +0 -8
  110. package/dist/reducers/parties.d.ts.map +0 -1
  111. package/dist/reducers/parties.js +0 -266
  112. package/dist/reducers/transitions.d.ts +0 -8
  113. package/dist/reducers/transitions.d.ts.map +0 -1
  114. package/dist/reducers/transitions.js +0 -162
@@ -1 +1 @@
1
- {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../../../document-models/billing-statement/src/reducers/general.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,iCAAiC,CAAC;AAGzF,eAAO,MAAM,OAAO,EAAE,iCAiCrB,CAAC"}
1
+ {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../../../document-models/billing-statement/src/reducers/general.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,iCAAiC,CAAC;AAGzF,eAAO,MAAM,OAAO,EAAE,iCAqBrB,CAAC"}
@@ -6,36 +6,18 @@
6
6
  import { BillingStatementStatusInputSchema } from "../../gen/schema/zod.js";
7
7
  export const reducer = {
8
8
  editBillingStatementOperation(state, action, dispatch) {
9
- try {
10
- state.dateIssued = action.input.dateIssued ?? state.dateIssued;
11
- state.dateDue = action.input.dateDue ?? state.dateDue;
12
- state.currency = action.input.currency ?? state.currency;
13
- state.notes = action.input.notes ?? state.notes;
14
- }
15
- catch (error) {
16
- console.error("Failed to edit billing statement:", error);
17
- return state;
18
- }
9
+ state.dateIssued = action.input.dateIssued ?? state.dateIssued;
10
+ state.dateDue = action.input.dateDue ?? state.dateDue;
11
+ state.currency = action.input.currency ?? state.currency;
12
+ state.notes = action.input.notes ?? state.notes;
19
13
  },
20
14
  editContributorOperation(state, action, dispatch) {
21
- try {
22
- state.contributor = action.input.contributor ?? state.contributor;
23
- }
24
- catch (error) {
25
- console.error("Failed to edit contributor:", error);
26
- return state;
27
- }
15
+ state.contributor = action.input.contributor ?? state.contributor;
28
16
  },
29
17
  editStatusOperation(state, action, dispatch) {
30
- try {
31
- if (!BillingStatementStatusInputSchema.safeParse(action.input.status).success) {
32
- throw new Error("Invalid status value");
33
- }
34
- state.status = action.input.status ?? state.status;
35
- }
36
- catch (error) {
37
- console.error("Failed to edit status:", error);
38
- return state;
18
+ if (!BillingStatementStatusInputSchema.safeParse(action.input.status).success) {
19
+ throw new Error("Invalid status value");
39
20
  }
21
+ state.status = action.input.status ?? state.status;
40
22
  },
41
23
  };
@@ -1 +1 @@
1
- {"version":3,"file":"line-items.d.ts","sourceRoot":"","sources":["../../../../../document-models/billing-statement/src/reducers/line-items.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oCAAoC,CAAC;AAG9F,eAAO,MAAM,OAAO,EAAE,mCAuCrB,CAAC"}
1
+ {"version":3,"file":"line-items.d.ts","sourceRoot":"","sources":["../../../../../document-models/billing-statement/src/reducers/line-items.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oCAAoC,CAAC;AAG9F,eAAO,MAAM,OAAO,EAAE,mCAiCrB,CAAC"}
@@ -5,38 +5,28 @@
5
5
  */
6
6
  export const reducer = {
7
7
  addLineItemOperation(state, action, dispatch) {
8
- try {
9
- const newLineItem = {
10
- ...action.input,
11
- lineItemTag: [],
12
- };
13
- // Check for duplicate ID
14
- if (state.lineItems.find((x) => x.id === newLineItem.id)) {
15
- throw new Error("Duplicate line item ID");
16
- }
17
- state.lineItems.push(newLineItem);
18
- updateTotals(state);
19
- }
20
- catch (error) {
21
- console.error("Failed to add line item:", error);
8
+ const newLineItem = {
9
+ ...action.input,
10
+ lineItemTag: [],
11
+ };
12
+ // Check for duplicate ID
13
+ if (state.lineItems.find((x) => x.id === newLineItem.id)) {
14
+ throw new Error("Duplicate line item ID");
22
15
  }
16
+ state.lineItems.push(newLineItem);
17
+ updateTotals(state);
23
18
  },
24
19
  editLineItemOperation(state, action, dispatch) {
25
- try {
26
- const stateItem = state.lineItems.find((x) => x.id === action.input.id);
27
- if (!stateItem)
28
- throw new Error("Item matching input.id not found");
29
- const sanitizedInput = Object.fromEntries(Object.entries(action.input).filter(([, value]) => value !== null));
30
- const nextItem = {
31
- ...stateItem,
32
- ...sanitizedInput,
33
- };
34
- Object.assign(stateItem, nextItem);
35
- updateTotals(state);
36
- }
37
- catch (error) {
38
- console.error("Failed to edit line item:", error);
39
- }
20
+ const stateItem = state.lineItems.find((x) => x.id === action.input.id);
21
+ if (!stateItem)
22
+ throw new Error("Item matching input.id not found");
23
+ const sanitizedInput = Object.fromEntries(Object.entries(action.input).filter(([, value]) => value !== null));
24
+ const nextItem = {
25
+ ...stateItem,
26
+ ...sanitizedInput,
27
+ };
28
+ Object.assign(stateItem, nextItem);
29
+ updateTotals(state);
40
30
  },
41
31
  };
42
32
  const updateTotals = (state) => {
@@ -1 +1 @@
1
- {"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../../../../document-models/billing-statement/src/reducers/tags.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAEnF,eAAO,MAAM,OAAO,EAAE,8BA8BrB,CAAC"}
1
+ {"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../../../../document-models/billing-statement/src/reducers/tags.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAEnF,eAAO,MAAM,OAAO,EAAE,8BA2BrB,CAAC"}
@@ -5,32 +5,27 @@
5
5
  */
6
6
  export const reducer = {
7
7
  editLineItemTagOperation(state, action, dispatch) {
8
- try {
9
- const stateItem = state.lineItems.find((x) => x.id === action.input.lineItemId);
10
- if (!stateItem)
11
- throw new Error("Item matching input.lineItemId not found");
12
- // if tag already exists with the same dimension, update the value and label
13
- const existingTag = stateItem.lineItemTag?.find((tag) => tag.dimension === action.input.dimension);
14
- if (existingTag) {
15
- existingTag.value = action.input.value;
16
- existingTag.label = action.input.label || null;
17
- }
18
- else {
19
- // if tag does not exist, add it
20
- const newTag = {
21
- dimension: action.input.dimension,
22
- value: action.input.value,
23
- label: action.input.label || null,
24
- };
25
- if (!stateItem.lineItemTag) {
26
- stateItem.lineItemTag = [];
27
- }
28
- // Add the new tag
29
- stateItem.lineItemTag?.push(newTag);
30
- }
8
+ const stateItem = state.lineItems.find((x) => x.id === action.input.lineItemId);
9
+ if (!stateItem)
10
+ throw new Error("Item matching input.lineItemId not found");
11
+ // if tag already exists with the same dimension, update the value and label
12
+ const existingTag = stateItem.lineItemTag?.find((tag) => tag.dimension === action.input.dimension);
13
+ if (existingTag) {
14
+ existingTag.value = action.input.value;
15
+ existingTag.label = action.input.label || null;
31
16
  }
32
- catch (error) {
33
- console.error("Failed to edit line item tag:", error);
17
+ else {
18
+ // if tag does not exist, add it
19
+ const newTag = {
20
+ dimension: action.input.dimension,
21
+ value: action.input.value,
22
+ label: action.input.label || null,
23
+ };
24
+ if (!stateItem.lineItemTag) {
25
+ stateItem.lineItemTag = [];
26
+ }
27
+ // Add the new tag
28
+ stateItem.lineItemTag?.push(newTag);
34
29
  }
35
30
  },
36
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../../../../document-models/integrations/src/reducers/integrations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAE/F,eAAO,MAAM,OAAO,EAAE,kCAoDrB,CAAC"}
1
+ {"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../../../../document-models/integrations/src/reducers/integrations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAE/F,eAAO,MAAM,OAAO,EAAE,kCA2CrB,CAAC"}
@@ -5,53 +5,38 @@
5
5
  */
6
6
  export const reducer = {
7
7
  setRequestFinanceOperation(state, action, dispatch) {
8
- try {
9
- const requestFinance = {
10
- apiKey: action.input.apiKey || '',
11
- email: action.input.email || '',
12
- };
13
- state.requestFinance = requestFinance;
14
- }
15
- catch (error) {
16
- console.error(error);
17
- }
8
+ const requestFinance = {
9
+ apiKey: action.input.apiKey || '',
10
+ email: action.input.email || '',
11
+ };
12
+ state.requestFinance = requestFinance;
18
13
  },
19
14
  setGnosisSafeOperation(state, action, dispatch) {
20
- try {
21
- const gnosisSafe = {
22
- safeAddress: action.input.safeAddress || '',
23
- signerPrivateKey: action.input.signerPrivateKey || '',
24
- };
25
- state.gnosisSafe = gnosisSafe;
26
- }
27
- catch (error) {
28
- console.error(error);
29
- }
15
+ const gnosisSafe = {
16
+ safeAddress: action.input.safeAddress || '',
17
+ signerPrivateKey: action.input.signerPrivateKey || '',
18
+ };
19
+ state.gnosisSafe = gnosisSafe;
30
20
  },
31
21
  setGoogleCloudOperation(state, action, dispatch) {
32
- try {
33
- const googleCloud = {
34
- projectId: action.input.projectId || '',
35
- location: action.input.location || '',
36
- processorId: action.input.processorId || '',
37
- keyFile: {
38
- type: action.input.keyFile?.type || '',
39
- project_id: action.input.keyFile?.project_id || '',
40
- private_key_id: action.input.keyFile?.private_key_id || '',
41
- private_key: action.input.keyFile?.private_key || '',
42
- client_email: action.input.keyFile?.client_email || '',
43
- client_id: action.input.keyFile?.client_id || '',
44
- auth_uri: action.input.keyFile?.auth_uri || '',
45
- token_uri: action.input.keyFile?.token_uri || '',
46
- auth_provider_x509_cert_url: action.input.keyFile?.auth_provider_x509_cert_url || '',
47
- client_x509_cert_url: action.input.keyFile?.client_x509_cert_url || '',
48
- universe_domain: action.input.keyFile?.universe_domain || '',
49
- },
50
- };
51
- state.googleCloud = googleCloud;
52
- }
53
- catch (error) {
54
- console.error(error);
55
- }
22
+ const googleCloud = {
23
+ projectId: action.input.projectId || '',
24
+ location: action.input.location || '',
25
+ processorId: action.input.processorId || '',
26
+ keyFile: {
27
+ type: action.input.keyFile?.type || '',
28
+ project_id: action.input.keyFile?.project_id || '',
29
+ private_key_id: action.input.keyFile?.private_key_id || '',
30
+ private_key: action.input.keyFile?.private_key || '',
31
+ client_email: action.input.keyFile?.client_email || '',
32
+ client_id: action.input.keyFile?.client_id || '',
33
+ auth_uri: action.input.keyFile?.auth_uri || '',
34
+ token_uri: action.input.keyFile?.token_uri || '',
35
+ auth_provider_x509_cert_url: action.input.keyFile?.auth_provider_x509_cert_url || '',
36
+ client_x509_cert_url: action.input.keyFile?.client_x509_cert_url || '',
37
+ universe_domain: action.input.keyFile?.universe_domain || '',
38
+ },
39
+ };
40
+ state.googleCloud = googleCloud;
56
41
  },
57
42
  };
@@ -1 +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,wBAmErB,CAAC"}
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,wBAmDrB,CAAC"}
@@ -5,70 +5,45 @@
5
5
  */
6
6
  export const reducer = {
7
7
  editInvoiceOperation(state, action, dispatch) {
8
- try {
9
- const newState = { ...state };
10
- newState.currency = action.input.currency ?? state.currency;
11
- newState.dateDue = action.input.dateDue ?? state.dateDue;
12
- newState.dateIssued = action.input.dateIssued ?? state.dateIssued;
13
- newState.dateDelivered = action.input.dateDelivered ?? state.dateDelivered;
14
- newState.invoiceNo = action.input.invoiceNo ?? state.invoiceNo;
15
- newState.notes = action.input.notes ?? state.notes;
16
- state = Object.assign(state, newState);
17
- }
18
- catch (e) {
19
- console.error(e);
20
- }
8
+ const newState = { ...state };
9
+ newState.currency = action.input.currency ?? state.currency;
10
+ newState.dateDue = action.input.dateDue ?? state.dateDue;
11
+ newState.dateIssued = action.input.dateIssued ?? state.dateIssued;
12
+ newState.dateDelivered = action.input.dateDelivered ?? state.dateDelivered;
13
+ newState.invoiceNo = action.input.invoiceNo ?? state.invoiceNo;
14
+ newState.notes = action.input.notes ?? state.notes;
15
+ state = Object.assign(state, newState);
21
16
  },
22
17
  editStatusOperation(state, action, dispatch) {
23
- try {
24
- state.status = action.input.status;
25
- }
26
- catch (e) {
27
- console.error(e);
28
- }
18
+ state.status = action.input.status;
29
19
  },
30
20
  editPaymentDataOperation(state, action, dispatch) {
31
- try {
32
- const payment = state.payments.find((payment) => payment.id === action.input.id);
33
- if (payment) {
34
- payment.processorRef = action.input.processorRef ?? payment.processorRef;
35
- payment.paymentDate = action.input.paymentDate ?? payment.paymentDate;
36
- payment.txnRef = action.input.txnRef ?? payment.txnRef;
37
- payment.confirmed = action.input.confirmed ?? payment.confirmed;
38
- payment.issue = action.input.issue ?? payment.issue;
39
- }
40
- }
41
- catch (e) {
42
- console.error(e);
21
+ const payment = state.payments.find((payment) => payment.id === action.input.id);
22
+ if (payment) {
23
+ payment.processorRef = action.input.processorRef ?? payment.processorRef;
24
+ payment.paymentDate = action.input.paymentDate ?? payment.paymentDate;
25
+ payment.txnRef = action.input.txnRef ?? payment.txnRef;
26
+ payment.confirmed = action.input.confirmed ?? payment.confirmed;
27
+ payment.issue = action.input.issue ?? payment.issue;
43
28
  }
44
29
  },
45
30
  addPaymentOperation(state, action, dispatch) {
46
- try {
47
- const payment = {
48
- id: action.input.id,
49
- processorRef: action.input.processorRef ?? "",
50
- paymentDate: action.input.paymentDate ?? "",
51
- txnRef: action.input.txnRef ?? "",
52
- confirmed: action.input.confirmed ?? false,
53
- issue: action.input.issue ?? "",
54
- amount: 0,
55
- };
56
- state.payments.push(payment);
57
- }
58
- catch (e) {
59
- console.error(e);
60
- }
31
+ const payment = {
32
+ id: action.input.id,
33
+ processorRef: action.input.processorRef ?? "",
34
+ paymentDate: action.input.paymentDate ?? "",
35
+ txnRef: action.input.txnRef ?? "",
36
+ confirmed: action.input.confirmed ?? false,
37
+ issue: action.input.issue ?? "",
38
+ amount: 0,
39
+ };
40
+ state.payments.push(payment);
61
41
  },
62
42
  setExportedDataOperation(state, action, dispatch) {
63
- try {
64
- const exportedData = {
65
- timestamp: action.input.timestamp,
66
- exportedLineItems: action.input.exportedLineItems,
67
- };
68
- state.exported = exportedData;
69
- }
70
- catch (e) {
71
- console.error(e);
72
- }
43
+ const exportedData = {
44
+ timestamp: action.input.timestamp,
45
+ exportedLineItems: action.input.exportedLineItems,
46
+ };
47
+ state.exported = exportedData;
73
48
  }
74
49
  };
@@ -1 +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,sBA6GrB,CAAC"}
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,sBA+FrB,CAAC"}
@@ -5,106 +5,81 @@
5
5
  */
6
6
  export const reducer = {
7
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
- }
8
+ const item = {
9
+ ...action.input,
10
+ lineItemTag: [],
11
+ };
12
+ if (state.lineItems.find((x) => x.id === item.id))
13
+ throw new Error("Duplicate input.id");
14
+ validatePrices(item);
15
+ state.lineItems.push(item);
16
+ updateTotals(state);
22
17
  },
23
18
  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
- applyInvariants(state, nextItem);
39
- Object.assign(stateItem, nextItem);
40
- updateTotals(state);
41
- }
42
- catch (e) {
43
- console.error(e);
19
+ const stateItem = state.lineItems.find((x) => x.id === action.input.id);
20
+ if (!stateItem)
21
+ throw new Error("Item matching input.id not found");
22
+ const sanitizedInput = Object.fromEntries(Object.entries(action.input).filter(([, value]) => value !== null));
23
+ // Ensure lineItemTag is always an array if provided
24
+ if ('lineItemTag' in action.input) {
25
+ sanitizedInput.lineItemTag = (action.input.lineItemTag ?? []);
44
26
  }
27
+ const nextItem = {
28
+ ...stateItem,
29
+ ...sanitizedInput,
30
+ };
31
+ validatePrices(nextItem);
32
+ applyInvariants(state, nextItem);
33
+ Object.assign(stateItem, nextItem);
34
+ updateTotals(state);
45
35
  },
46
36
  deleteLineItemOperation(state, action, dispatch) {
47
- try {
48
- state.lineItems = state.lineItems.filter((x) => x.id !== action.input.id);
49
- updateTotals(state);
50
- }
51
- catch (e) {
52
- console.error(e);
53
- }
37
+ state.lineItems = state.lineItems.filter((x) => x.id !== action.input.id);
38
+ updateTotals(state);
54
39
  },
55
40
  setLineItemTagOperation(state, action, dispatch) {
56
- try {
57
- const stateItem = state.lineItems.find((x) => x.id === action.input.lineItemId);
58
- if (!stateItem)
59
- throw new Error("Item matching input.id not found");
60
- // if tag already exists with the same dimension, update the value and label
61
- const existingTag = stateItem.lineItemTag?.find((tag) => tag.dimension === action.input.dimension);
62
- if (existingTag) {
63
- existingTag.value = action.input.value;
64
- existingTag.label = action.input.label || null;
65
- }
66
- else {
67
- // if tag does not exist, add it
68
- const newTag = {
69
- dimension: action.input.dimension,
70
- value: action.input.value,
71
- label: action.input.label || null,
72
- };
73
- if (!stateItem.lineItemTag) {
74
- stateItem.lineItemTag = [];
75
- }
76
- // Add the new tag
77
- stateItem.lineItemTag?.push(newTag);
78
- }
41
+ const stateItem = state.lineItems.find((x) => x.id === action.input.lineItemId);
42
+ if (!stateItem)
43
+ throw new Error("Item matching input.id not found");
44
+ // if tag already exists with the same dimension, update the value and label
45
+ const existingTag = stateItem.lineItemTag?.find((tag) => tag.dimension === action.input.dimension);
46
+ if (existingTag) {
47
+ existingTag.value = action.input.value;
48
+ existingTag.label = action.input.label || null;
79
49
  }
80
- catch (e) {
81
- console.error(e);
50
+ else {
51
+ // if tag does not exist, add it
52
+ const newTag = {
53
+ dimension: action.input.dimension,
54
+ value: action.input.value,
55
+ label: action.input.label || null,
56
+ };
57
+ if (!stateItem.lineItemTag) {
58
+ stateItem.lineItemTag = [];
59
+ }
60
+ // Add the new tag
61
+ stateItem.lineItemTag?.push(newTag);
82
62
  }
83
63
  },
84
64
  setInvoiceTagOperation(state, action, dispatch) {
85
- try {
86
- // if tag already exists with the same dimension, update the value and label
87
- const existingTag = state.invoiceTags?.find((tag) => tag.dimension === action.input.dimension);
88
- if (existingTag) {
89
- existingTag.value = action.input.value;
90
- existingTag.label = action.input.label || null;
91
- }
92
- else {
93
- // if tag does not exist, add it
94
- const newTag = {
95
- dimension: action.input.dimension,
96
- value: action.input.value,
97
- label: action.input.label || null,
98
- };
99
- if (!state.invoiceTags) {
100
- state.invoiceTags = [];
101
- }
102
- // Add the new tag
103
- state.invoiceTags.push(newTag);
104
- }
65
+ // if tag already exists with the same dimension, update the value and label
66
+ const existingTag = state.invoiceTags?.find((tag) => tag.dimension === action.input.dimension);
67
+ if (existingTag) {
68
+ existingTag.value = action.input.value;
69
+ existingTag.label = action.input.label || null;
105
70
  }
106
- catch (e) {
107
- console.error(e);
71
+ else {
72
+ // if tag does not exist, add it
73
+ const newTag = {
74
+ dimension: action.input.dimension,
75
+ value: action.input.value,
76
+ label: action.input.label || null,
77
+ };
78
+ if (!state.invoiceTags) {
79
+ state.invoiceTags = [];
80
+ }
81
+ // Add the new tag
82
+ state.invoiceTags.push(newTag);
108
83
  }
109
84
  },
110
85
  };
@@ -1 +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"}
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,wBAsZrB,CAAC"}