@powerhousedao/contributor-billing 0.0.33 → 0.0.35
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/invoice/gen/actions.d.ts +3 -1
- package/dist/document-models/invoice/gen/actions.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/actions.js +1 -0
- package/dist/document-models/invoice/gen/creators.d.ts +1 -0
- package/dist/document-models/invoice/gen/creators.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/creators.js +1 -0
- package/dist/document-models/invoice/gen/document-model.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/document-model.js +167 -50
- package/dist/document-models/invoice/gen/general/actions.d.ts +4 -6
- package/dist/document-models/invoice/gen/general/actions.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/general/creators.d.ts +4 -6
- package/dist/document-models/invoice/gen/general/creators.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/general/creators.js +2 -4
- package/dist/document-models/invoice/gen/general/object.d.ts +3 -5
- package/dist/document-models/invoice/gen/general/object.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/general/object.js +6 -12
- package/dist/document-models/invoice/gen/general/operations.d.ts +3 -5
- package/dist/document-models/invoice/gen/general/operations.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/object.d.ts +3 -1
- package/dist/document-models/invoice/gen/object.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/object.js +8 -1
- package/dist/document-models/invoice/gen/reducer.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/reducer.js +56 -15
- package/dist/document-models/invoice/gen/schema/types.d.ts +89 -23
- package/dist/document-models/invoice/gen/schema/types.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/schema/zod.d.ts +21 -7
- package/dist/document-models/invoice/gen/schema/zod.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/schema/zod.js +124 -28
- package/dist/document-models/invoice/gen/transitions/actions.d.ts +16 -0
- package/dist/document-models/invoice/gen/transitions/actions.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/transitions/actions.js +1 -0
- package/dist/document-models/invoice/gen/transitions/creators.d.ts +15 -0
- package/dist/document-models/invoice/gen/transitions/creators.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/transitions/creators.js +14 -0
- package/dist/document-models/invoice/gen/transitions/error.d.ts +2 -0
- package/dist/document-models/invoice/gen/transitions/error.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/transitions/error.js +1 -0
- package/dist/document-models/invoice/gen/transitions/object.d.ts +18 -0
- package/dist/document-models/invoice/gen/transitions/object.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/transitions/object.js +40 -0
- package/dist/document-models/invoice/gen/transitions/operations.d.ts +18 -0
- package/dist/document-models/invoice/gen/transitions/operations.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/transitions/operations.js +1 -0
- package/dist/document-models/invoice/gen/utils.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/utils.js +10 -6
- package/dist/document-models/invoice/index.d.ts +14 -4
- package/dist/document-models/invoice/index.d.ts.map +1 -1
- package/dist/document-models/invoice/src/reducers/general.d.ts.map +1 -1
- package/dist/document-models/invoice/src/reducers/general.js +26 -42
- package/dist/document-models/invoice/src/reducers/transitions.d.ts +8 -0
- package/dist/document-models/invoice/src/reducers/transitions.d.ts.map +1 -0
- package/dist/document-models/invoice/src/reducers/transitions.js +162 -0
- package/dist/document-models/invoice/src/tests/general.test.js +10 -31
- package/dist/document-models/invoice/src/tests/transitions.test.d.ts +6 -0
- package/dist/document-models/invoice/src/tests/transitions.test.d.ts.map +1 -0
- package/dist/document-models/invoice/src/tests/transitions.test.js +506 -0
- package/dist/document-models/invoice/utils/statusTransitions.d.ts +13 -0
- package/dist/document-models/invoice/utils/statusTransitions.d.ts.map +1 -0
- package/dist/document-models/invoice/utils/statusTransitions.js +13 -0
- package/dist/editors/billing-statement/lineItemTags/tagMapping.js +64 -64
- package/dist/editors/contributor-billing/components/DriveExplorer.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/DriveExplorer.js +3 -2
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts +3 -2
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.js +27 -3
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts +4 -4
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.js +91 -21
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.js +1 -1
- package/dist/editors/invoice/components/confirmationModal.d.ts +14 -0
- package/dist/editors/invoice/components/confirmationModal.d.ts.map +1 -0
- package/dist/editors/invoice/components/confirmationModal.js +7 -0
- package/dist/editors/invoice/components/selectField.d.ts.map +1 -1
- package/dist/editors/invoice/components/selectField.js +109 -112
- package/dist/editors/invoice/components/statusModalComponents.d.ts +52 -0
- package/dist/editors/invoice/components/statusModalComponents.d.ts.map +1 -0
- package/dist/editors/invoice/components/statusModalComponents.js +78 -0
- package/dist/editors/invoice/editor.d.ts +1 -1
- package/dist/editors/invoice/editor.d.ts.map +1 -1
- package/dist/editors/invoice/editor.js +153 -158
- package/dist/editors/invoice/ingestUBL.d.ts.map +1 -1
- package/dist/editors/invoice/ingestUBL.js +0 -3
- package/dist/editors/invoice/invoiceToGnosis.d.ts.map +1 -1
- package/dist/editors/invoice/invoiceToGnosis.js +4 -3
- package/dist/editors/invoice/lineItemTags/tagMapping.d.ts.map +1 -1
- package/dist/editors/invoice/lineItemTags/tagMapping.js +65 -64
- package/dist/editors/invoice/requestFinance.d.ts +1 -0
- package/dist/editors/invoice/requestFinance.d.ts.map +1 -1
- package/dist/editors/invoice/requestFinance.js +9 -2
- package/dist/editors/invoice/validation/validationHandler.d.ts +4 -0
- package/dist/editors/invoice/validation/validationHandler.d.ts.map +1 -0
- package/dist/editors/invoice/validation/validationHandler.js +117 -0
- package/dist/scripts/contributor-billing/createXeroCsv.d.ts +8 -0
- package/dist/scripts/contributor-billing/createXeroCsv.d.ts.map +1 -0
- package/dist/scripts/contributor-billing/createXeroCsv.js +209 -0
- package/dist/style.css +164 -18
- package/dist/subgraphs/invoice/resolvers.d.ts.map +1 -1
- package/dist/subgraphs/invoice/resolvers.js +92 -22
- package/dist/subgraphs/invoice/schema.d.ts.map +1 -1
- package/dist/subgraphs/invoice/schema.js +181 -57
- package/package.json +1 -1
|
@@ -0,0 +1,162 @@
|
|
|
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 { permittedTransitions } from "../../utils/statusTransitions.js";
|
|
7
|
+
export const reducer = {
|
|
8
|
+
cancelOperation(state, action, dispatch) {
|
|
9
|
+
if (permittedTransitions[state.status].includes('CANCELLED')) {
|
|
10
|
+
state.status = 'CANCELLED';
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
throw new Error(`Invalid transition from ${state.status} to CANCELLED`);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
issueOperation(state, action, dispatch) {
|
|
17
|
+
if (!action.input.invoiceNo || !action.input.dateIssued) {
|
|
18
|
+
throw new Error('Invoice number and date issued are required');
|
|
19
|
+
}
|
|
20
|
+
if (permittedTransitions[state.status].includes('ISSUED')) {
|
|
21
|
+
state.status = 'ISSUED';
|
|
22
|
+
state.invoiceNo = action.input.invoiceNo;
|
|
23
|
+
state.dateIssued = action.input.dateIssued;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw new Error(`Invalid transition from ${state.status} to ISSUED`);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
resetOperation(state, action, dispatch) {
|
|
30
|
+
if (permittedTransitions[state.status].includes('DRAFT')) {
|
|
31
|
+
state.status = 'DRAFT';
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
throw new Error(`Invalid transition from ${state.status} to DRAFT`);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
rejectOperation(state, action, dispatch) {
|
|
38
|
+
if (!action.input.id || !action.input.reason) {
|
|
39
|
+
throw new Error('Reason, ID and final are required');
|
|
40
|
+
}
|
|
41
|
+
if (permittedTransitions[state.status].includes('REJECTED')) {
|
|
42
|
+
state.status = 'REJECTED';
|
|
43
|
+
const rejection = {
|
|
44
|
+
id: action.input.id,
|
|
45
|
+
reason: action.input.reason,
|
|
46
|
+
final: action.input.final,
|
|
47
|
+
};
|
|
48
|
+
state.rejections.push(rejection);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
throw new Error(`Invalid transition from ${state.status} to REJECTED`);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
acceptOperation(state, action, dispatch) {
|
|
55
|
+
if (!action.input.payAfter) {
|
|
56
|
+
throw new Error('Pay after is required');
|
|
57
|
+
}
|
|
58
|
+
if (permittedTransitions[state.status].includes('ACCEPTED')) {
|
|
59
|
+
state.status = 'ACCEPTED';
|
|
60
|
+
state.payAfter = action.input.payAfter;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error(`Invalid transition from ${state.status} to ACCEPTED`);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
reinstateOperation(state, action, dispatch) {
|
|
67
|
+
const finalRejection = state.rejections.find(rejection => rejection.final === true);
|
|
68
|
+
if (finalRejection) {
|
|
69
|
+
throw new Error('Cannot reinstate an invoice that has been rejected');
|
|
70
|
+
}
|
|
71
|
+
if (permittedTransitions[state.status].includes('ISSUED')) {
|
|
72
|
+
state.status = 'ISSUED';
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
throw new Error(`Invalid transition from ${state.status} to ISSUED`);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
schedulePaymentOperation(state, action, dispatch) {
|
|
79
|
+
if (!action.input.id || !action.input.processorRef) {
|
|
80
|
+
throw new Error('ID and processorRef are required');
|
|
81
|
+
}
|
|
82
|
+
if (permittedTransitions[state.status].includes('PAYMENTSCHEDULED')) {
|
|
83
|
+
state.status = 'PAYMENTSCHEDULED';
|
|
84
|
+
state.payments.push({
|
|
85
|
+
id: action.input.id,
|
|
86
|
+
processorRef: action.input.processorRef,
|
|
87
|
+
paymentDate: '',
|
|
88
|
+
txnRef: "",
|
|
89
|
+
confirmed: false,
|
|
90
|
+
issue: "",
|
|
91
|
+
amount: 0,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
throw new Error(`Invalid transition from ${state.status} to PAYMENTSCHEDULED`);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
reapprovePaymentOperation(state, action, dispatch) {
|
|
99
|
+
if (permittedTransitions[state.status].includes('ACCEPTED')) {
|
|
100
|
+
state.status = 'ACCEPTED';
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
throw new Error(`Invalid transition from ${state.status} to ACCEPTED`);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
registerPaymentTxOperation(state, action, dispatch) {
|
|
107
|
+
if (permittedTransitions[state.status].includes('PAYMENTSENT')) {
|
|
108
|
+
state.status = 'PAYMENTSENT';
|
|
109
|
+
const payment = state.payments.find(payment => payment.id === action.input.id);
|
|
110
|
+
if (!payment)
|
|
111
|
+
throw new Error('Payment not found');
|
|
112
|
+
payment.txnRef = action.input.txRef;
|
|
113
|
+
payment.paymentDate = action.input.timestamp;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
throw new Error(`Invalid transition from ${state.status} to PAYMENTSENT`);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
reportPaymentIssueOperation(state, action, dispatch) {
|
|
120
|
+
if (!action.input.id || !action.input.issue) {
|
|
121
|
+
throw new Error('ID and issue are required');
|
|
122
|
+
}
|
|
123
|
+
if (permittedTransitions[state.status].includes('PAYMENTISSUE')) {
|
|
124
|
+
state.status = 'PAYMENTISSUE';
|
|
125
|
+
const payment = state.payments.find(payment => payment.id === action.input.id);
|
|
126
|
+
if (!payment)
|
|
127
|
+
throw new Error('Payment not found');
|
|
128
|
+
payment.issue = action.input.issue;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
throw new Error(`Invalid transition from ${state.status} to PAYMENTISSUE`);
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
confirmPaymentOperation(state, action, dispatch) {
|
|
135
|
+
if (!action.input.id || !action.input.amount) {
|
|
136
|
+
throw new Error('ID and amount are required');
|
|
137
|
+
}
|
|
138
|
+
if (permittedTransitions[state.status].includes('PAYMENTRECEIVED')) {
|
|
139
|
+
state.status = 'PAYMENTRECEIVED';
|
|
140
|
+
const payment = state.payments.find(payment => payment.id === action.input.id);
|
|
141
|
+
if (!payment)
|
|
142
|
+
throw new Error('Payment not found');
|
|
143
|
+
payment.confirmed = true;
|
|
144
|
+
payment.amount = action.input.amount;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
throw new Error(`Invalid transition from ${state.status} to PAYMENTRECEIVED`);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
closePaymentOperation(state, action, dispatch) {
|
|
151
|
+
if (!action.input.closureReason) {
|
|
152
|
+
throw new Error('Closure reason is required');
|
|
153
|
+
}
|
|
154
|
+
if (permittedTransitions[state.status].includes('PAYMENTCLOSED')) {
|
|
155
|
+
state.status = 'PAYMENTCLOSED';
|
|
156
|
+
state.closureReason = action.input.closureReason;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
throw new Error(`Invalid transition from ${state.status} to PAYMENTCLOSED`);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
};
|
|
@@ -28,45 +28,24 @@ describe("General Operations", () => {
|
|
|
28
28
|
expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
|
|
29
29
|
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
30
30
|
});
|
|
31
|
-
it("should handle addRef operation", () => {
|
|
32
|
-
const input = generateMock(z.AddRefInputSchema());
|
|
33
|
-
const updatedDocument = reducer(document, creators.addRef(input));
|
|
34
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
35
|
-
expect(updatedDocument.operations.global[0].type).toBe("ADD_REF");
|
|
36
|
-
expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
|
|
37
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
38
|
-
});
|
|
39
|
-
it("should handle editRef operation", () => {
|
|
40
|
-
const input = generateMock(z.EditRefInputSchema());
|
|
41
|
-
const updatedDocument = reducer(document, creators.editRef(input));
|
|
42
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
43
|
-
expect(updatedDocument.operations.global[0].type).toBe("EDIT_REF");
|
|
44
|
-
expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
|
|
45
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
46
|
-
});
|
|
47
|
-
it("should handle deleteRef operation", () => {
|
|
48
|
-
const input = generateMock(z.DeleteRefInputSchema());
|
|
49
|
-
const updatedDocument = reducer(document, creators.deleteRef(input));
|
|
50
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
51
|
-
expect(updatedDocument.operations.global[0].type).toBe("DELETE_REF");
|
|
52
|
-
expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
|
|
53
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
54
|
-
});
|
|
55
31
|
it("should handle editPaymentData operation", () => {
|
|
56
32
|
const invoice = utils.createDocument();
|
|
57
33
|
const paymentDate = new Date().toISOString();
|
|
58
|
-
const updatedDocument = reducer(invoice, creators.editPaymentData({ paymentDate: paymentDate,
|
|
34
|
+
const updatedDocument = reducer(invoice, creators.editPaymentData({ paymentDate: paymentDate, txnRef: "0x123", confirmed: true, id: "123" }));
|
|
59
35
|
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
60
36
|
expect(updatedDocument.operations.global[0].type).toBe("EDIT_PAYMENT_DATA");
|
|
61
|
-
expect(updatedDocument.operations.global[0].input).
|
|
37
|
+
expect(updatedDocument.operations.global[0].input).toEqual({ paymentDate: paymentDate, txnRef: "0x123", confirmed: true, id: "123" });
|
|
62
38
|
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
63
39
|
});
|
|
64
|
-
it("should handle
|
|
65
|
-
const
|
|
66
|
-
|
|
40
|
+
it("should handle setExportedData operation", () => {
|
|
41
|
+
const input = {
|
|
42
|
+
timestamp: '2025-01-01T00:00:00Z',
|
|
43
|
+
exportedLineItems: [['1', '2', '3'], ['4', '5', '6']]
|
|
44
|
+
};
|
|
45
|
+
const updatedDocument = reducer(document, creators.setExportedData(input));
|
|
67
46
|
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
68
|
-
expect(updatedDocument.operations.global[0].type).toBe("
|
|
69
|
-
expect(updatedDocument.operations.global[0].input).toStrictEqual(
|
|
47
|
+
expect(updatedDocument.operations.global[0].type).toBe("SET_EXPORTED_DATA");
|
|
48
|
+
expect(updatedDocument.operations.global[0].input).toStrictEqual(input);
|
|
70
49
|
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
71
50
|
});
|
|
72
51
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transitions.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/tests/transitions.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|