@powerhousedao/contributor-billing 0.0.99 → 0.1.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.
- package/dist/document-models/billing-statement/src/reducers/general.d.ts.map +1 -1
- package/dist/document-models/billing-statement/src/reducers/general.js +8 -26
- package/dist/document-models/billing-statement/src/reducers/line-items.d.ts.map +1 -1
- package/dist/document-models/billing-statement/src/reducers/line-items.js +19 -29
- package/dist/document-models/billing-statement/src/reducers/tags.d.ts.map +1 -1
- package/dist/document-models/billing-statement/src/reducers/tags.js +20 -25
- package/dist/document-models/integrations/src/reducers/integrations.d.ts.map +1 -1
- package/dist/document-models/integrations/src/reducers/integrations.js +29 -44
- package/dist/document-models/invoice/src/reducers/general.d.ts.map +1 -1
- package/dist/document-models/invoice/src/reducers/general.js +31 -56
- package/dist/document-models/invoice/src/reducers/items.d.ts.map +1 -1
- package/dist/document-models/invoice/src/reducers/items.js +63 -88
- package/dist/document-models/invoice/src/reducers/parties.d.ts.map +1 -1
- package/dist/document-models/invoice/src/reducers/parties.js +199 -229
- package/dist/editors/billing-statement/components/lineItemsTable.d.ts +3 -2
- package/dist/editors/billing-statement/components/lineItemsTable.d.ts.map +1 -1
- package/dist/editors/billing-statement/components/lineItemsTable.js +12 -8
- package/dist/editors/billing-statement/components/objectSetTable.d.ts +3 -2
- package/dist/editors/billing-statement/components/objectSetTable.d.ts.map +1 -1
- package/dist/editors/billing-statement/editor.d.ts +3 -1
- package/dist/editors/billing-statement/editor.d.ts.map +1 -1
- package/dist/editors/billing-statement/editor.js +2 -2
- package/dist/editors/billing-statement/lineItemTags/lineItemTags.d.ts +2 -2
- package/dist/editors/billing-statement/lineItemTags/lineItemTags.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/DriveExplorer.d.ts +8 -1
- package/dist/editors/contributor-billing/components/DriveExplorer.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/DriveExplorer.js +18 -64
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts +2 -8
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.js +21 -7
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts +8 -10
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.js +27 -24
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts +6 -8
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.js +8 -17
- package/dist/editors/contributor-billing/editor.d.ts +1 -10
- package/dist/editors/contributor-billing/editor.d.ts.map +1 -1
- package/dist/editors/contributor-billing/editor.js +2 -23
- package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts +2 -1
- package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts.map +1 -1
- package/dist/editors/contributor-billing/index.js +1 -1
- package/dist/editors/hooks/useBillingStatementDocument.d.ts +4 -0
- package/dist/editors/hooks/useBillingStatementDocument.d.ts.map +1 -0
- package/dist/editors/hooks/useBillingStatementDocument.js +8 -0
- package/dist/editors/hooks/useIntegrationsDocument.d.ts +4 -0
- package/dist/editors/hooks/useIntegrationsDocument.d.ts.map +1 -0
- package/dist/editors/hooks/useIntegrationsDocument.js +8 -0
- package/dist/editors/hooks/useInvoiceDocument.d.ts +4 -0
- package/dist/editors/hooks/useInvoiceDocument.d.ts.map +1 -0
- package/dist/editors/hooks/useInvoiceDocument.js +8 -0
- package/dist/editors/integrations/editor.d.ts +4 -1
- package/dist/editors/integrations/editor.d.ts.map +1 -1
- package/dist/editors/integrations/editor.js +7 -12
- package/dist/editors/invoice/editor.d.ts +4 -1
- package/dist/editors/invoice/editor.d.ts.map +1 -1
- package/dist/editors/invoice/editor.js +5 -4
- package/dist/editors/invoice/ingestPDF.d.ts.map +1 -1
- package/dist/editors/invoice/ingestPDF.js +3 -3
- package/dist/editors/invoice/invoiceToGnosis.d.ts +3 -2
- package/dist/editors/invoice/invoiceToGnosis.d.ts.map +1 -1
- package/dist/editors/invoice/invoiceToGnosis.js +11 -11
- package/dist/editors/invoice/legalEntity/bankSection.d.ts +1 -0
- package/dist/editors/invoice/legalEntity/bankSection.d.ts.map +1 -1
- package/dist/editors/invoice/legalEntity/bankSection.js +36 -12
- package/dist/editors/invoice/legalEntity/legalEntity.d.ts +2 -1
- package/dist/editors/invoice/legalEntity/legalEntity.d.ts.map +1 -1
- package/dist/editors/invoice/legalEntity/legalEntity.js +2 -2
- package/dist/editors/invoice/lineItemTags/lineItemTags.d.ts.map +1 -1
- package/dist/editors/invoice/lineItems.d.ts.map +1 -1
- package/dist/editors/invoice/lineItems.js +8 -6
- package/dist/editors/invoice/requestFinance.js +2 -2
- package/dist/editors/invoice/uploadPdfChunked.js +1 -1
- package/dist/editors/invoice/validation/validationHandler.d.ts +1 -1
- package/dist/editors/invoice/validation/validationHandler.d.ts.map +1 -1
- package/dist/editors/invoice/validation/validationHandler.js +25 -9
- package/dist/editors/invoice/validation/validationManager.d.ts.map +1 -1
- package/dist/editors/invoice/validation/validationManager.js +3 -2
- package/dist/editors/invoice/validation/validationRules.d.ts +2 -0
- package/dist/editors/invoice/validation/validationRules.d.ts.map +1 -1
- package/dist/editors/invoice/validation/validationRules.js +37 -7
- package/dist/scripts/contributor-billing/createExpenseReportCsv.d.ts +5 -0
- package/dist/scripts/contributor-billing/createExpenseReportCsv.d.ts.map +1 -0
- package/dist/scripts/contributor-billing/createExpenseReportCsv.js +122 -0
- package/dist/style.css +9 -6
- package/package.json +12 -12
- package/dist/reducers/general.d.ts +0 -8
- package/dist/reducers/general.d.ts.map +0 -1
- package/dist/reducers/general.js +0 -73
- package/dist/reducers/items.d.ts +0 -8
- package/dist/reducers/items.d.ts.map +0 -1
- package/dist/reducers/items.js +0 -195
- package/dist/reducers/parties.d.ts +0 -8
- package/dist/reducers/parties.d.ts.map +0 -1
- package/dist/reducers/parties.js +0 -266
- package/dist/reducers/transitions.d.ts +0 -8
- package/dist/reducers/transitions.d.ts.map +0 -1
- 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,
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
31
|
-
|
|
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,
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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,
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
33
|
-
|
|
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,
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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,
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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,
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
48
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
81
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
107
|
-
|
|
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,
|
|
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"}
|