@powerhousedao/contributor-billing 0.1.23 → 0.1.24
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/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.js +9 -3
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.js +38 -26
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderControls.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/HeaderControls.tsx"],"names":[],"mappings":"AAqBA,eAAO,MAAM,cAAc,GAAI,qSAgB5B;IACD,aAAa,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACnD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;IACpD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,qBAAqB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAC7B,qBAAqB,CAAC,EAAE,MAAM,OAAO,CAAC;IACtC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,gBAAgB,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAC9B,2BAA2B,CAAC,EAAE,MAAM,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACrC,4BAA4B,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,WAAW,EAAE,CAAC,QAAQ,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CAC5D,
|
|
1
|
+
{"version":3,"file":"HeaderControls.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/HeaderControls.tsx"],"names":[],"mappings":"AAqBA,eAAO,MAAM,cAAc,GAAI,qSAgB5B;IACD,aAAa,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACnD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;IACpD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,qBAAqB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAC7B,qBAAqB,CAAC,EAAE,MAAM,OAAO,CAAC;IACtC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,gBAAgB,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAC9B,2BAA2B,CAAC,EAAE,MAAM,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACrC,4BAA4B,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,WAAW,EAAE,CAAC,QAAQ,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CAC5D,4CAgTA,CAAC"}
|
|
@@ -36,7 +36,7 @@ export const HeaderControls = ({ statusOptions = [], onStatusChange, onSearchCha
|
|
|
36
36
|
const billingStatements = allDocuments?.filter((doc) => {
|
|
37
37
|
return doc.header.documentType === "powerhouse/billing-statement";
|
|
38
38
|
});
|
|
39
|
-
const handleBatchAction = (action) => {
|
|
39
|
+
const handleBatchAction = async (action) => {
|
|
40
40
|
if (action === "export-csv-expense-report") {
|
|
41
41
|
setShowExpenseReportCurrencyModal(true);
|
|
42
42
|
const updatedSelected = { ...selected };
|
|
@@ -103,10 +103,16 @@ export const HeaderControls = ({ statusOptions = [], onStatusChange, onSearchCha
|
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
105
|
// Create billing statements for invoices that don't have them yet
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
// Process sequentially to avoid race conditions
|
|
107
|
+
for (const id of invoicesToProcess) {
|
|
108
108
|
await handleCreateBillingStatement(id);
|
|
109
|
+
}
|
|
110
|
+
// Update all selected IDs at once after processing
|
|
111
|
+
const updatedSelected = { ...selected };
|
|
112
|
+
invoicesToProcess.forEach((id) => {
|
|
113
|
+
updatedSelected[id] = false;
|
|
109
114
|
});
|
|
115
|
+
setSelected(updatedSelected);
|
|
110
116
|
// Reset the select value after action is triggered
|
|
111
117
|
setTimeout(() => setSelectedBatchAction(undefined), 100);
|
|
112
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvoiceTable.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTable.tsx"],"names":[],"mappings":"AAaA,OAAO,EAKL,KAAK,wBAAwB,EAC9B,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"InvoiceTable.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTable.tsx"],"names":[],"mappings":"AAaA,OAAO,EAKL,KAAK,wBAAwB,EAC9B,MAAM,gCAAgC,CAAC;AAiBxC,KAAK,YAAY,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,UAAU,iBAAiB;IACzB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,QAAQ,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACpC,WAAW,EAAE,CACX,QAAQ,EACJ;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GACzB,CAAC,CAAC,IAAI,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,KAAK;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,KACjE,IAAI,CAAC;IACV,sBAAsB,EAAE,wBAAwB,EAAE,CAAC;IACnD,qBAAqB,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACjE,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,GAAG,CAAC;IACtC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;IACnD,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7E,qBAAqB,EAAE,MAAM,OAAO,CAAC;CACtC;AAED,eAAO,MAAM,YAAY,GAAI,oLAY1B,iBAAiB,4CA0qBnB,CAAC"}
|
|
@@ -10,6 +10,7 @@ import { exportExpenseReportCSV } from "../../../../scripts/contributor-billing/
|
|
|
10
10
|
import { toast } from "@powerhousedao/design-system/connect";
|
|
11
11
|
import { actions, } from "../../../../document-models/invoice/index.js";
|
|
12
12
|
import { addDocument, useSelectedDrive, dispatchActions, setSelectedNode, } from "@powerhousedao/reactor-browser";
|
|
13
|
+
import { useReactor } from "@powerhousedao/reactor-browser/connect";
|
|
13
14
|
import { actions as billingStatementActions } from "../../../../document-models/billing-statement/index.js";
|
|
14
15
|
const statusOptions = [
|
|
15
16
|
{ label: "Draft", value: "DRAFT" },
|
|
@@ -24,6 +25,7 @@ const statusOptions = [
|
|
|
24
25
|
];
|
|
25
26
|
export const InvoiceTable = ({ files, state, selected, setSelected, filteredDocumentModels, onSelectDocumentModel, getDocDispatcher, selectedStatuses, onStatusChange, onRowSelection, canExportSelectedRows, }) => {
|
|
26
27
|
const [selectedDrive] = useSelectedDrive();
|
|
28
|
+
const reactor = useReactor();
|
|
27
29
|
const billingDocStates = state
|
|
28
30
|
.filter((doc) => doc.header.documentType === "powerhouse/billing-statement")
|
|
29
31
|
.map((doc) => ({
|
|
@@ -94,10 +96,7 @@ export const InvoiceTable = ({ files, state, selected, setSelected, filteredDocu
|
|
|
94
96
|
console.error("Failed to create billing statement");
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
97
|
-
|
|
98
|
-
contributor: id,
|
|
99
|
-
}), createdNode.id);
|
|
100
|
-
// Prepare billing statement data with empty input handlers
|
|
99
|
+
// Prepare billing statement data
|
|
101
100
|
const billingStatementData = {
|
|
102
101
|
dateIssued: invoiceState.state.global.dateIssued &&
|
|
103
102
|
invoiceState.state.global.dateIssued.trim() !== ""
|
|
@@ -110,33 +109,46 @@ export const InvoiceTable = ({ files, state, selected, setSelected, filteredDocu
|
|
|
110
109
|
currency: invoiceState.state.global.currency || "",
|
|
111
110
|
notes: invoiceState.state.global.notes || "",
|
|
112
111
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
112
|
+
// Dispatch initial setup actions together
|
|
113
|
+
await dispatchActions([
|
|
114
|
+
billingStatementActions.editContributor({
|
|
115
|
+
contributor: id,
|
|
116
|
+
}),
|
|
117
|
+
billingStatementActions.editBillingStatement(billingStatementData),
|
|
118
|
+
], createdNode.id);
|
|
119
|
+
// Collect all line item actions
|
|
120
|
+
const lineItemActions = invoiceState.state.global.lineItems.map((lineItem) => billingStatementActions.addLineItem({
|
|
121
|
+
id: lineItem.id,
|
|
122
|
+
description: lineItem.description,
|
|
123
|
+
quantity: lineItem.quantity,
|
|
124
|
+
// Map invoice fields to billing statement fields
|
|
125
|
+
totalPriceCash: lineItem.totalPriceTaxIncl || 0,
|
|
126
|
+
totalPricePwt: 0, // Default to 0 since invoice doesn't have POWT pricing
|
|
127
|
+
unit: "UNIT", // Default to UNIT since invoice doesn't have unit field
|
|
128
|
+
unitPriceCash: lineItem.unitPriceTaxIncl || 0,
|
|
129
|
+
unitPricePwt: 0, // Default to 0 since invoice doesn't have POWT pricing
|
|
130
|
+
}));
|
|
131
|
+
// Dispatch all line items in one batch
|
|
132
|
+
if (lineItemActions.length > 0) {
|
|
133
|
+
await dispatchActions(lineItemActions, createdNode.id);
|
|
134
|
+
}
|
|
135
|
+
// Collect all tag actions
|
|
136
|
+
const tagActions = [];
|
|
137
|
+
for (const lineItem of invoiceState.state.global.lineItems) {
|
|
130
138
|
const lineItemTag = mapTags(lineItem.lineItemTag || []);
|
|
131
|
-
|
|
132
|
-
|
|
139
|
+
for (const tag of lineItemTag) {
|
|
140
|
+
tagActions.push(billingStatementActions.editLineItemTag({
|
|
133
141
|
lineItemId: lineItem.id,
|
|
134
142
|
dimension: tag.dimension,
|
|
135
143
|
value: tag.value,
|
|
136
144
|
label: tag.label,
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
}
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// Dispatch all tags in one batch
|
|
149
|
+
if (tagActions.length > 0) {
|
|
150
|
+
await dispatchActions(tagActions, createdNode.id);
|
|
151
|
+
}
|
|
140
152
|
};
|
|
141
153
|
const selectedInvoiceIds = Object.keys(selected).filter((id) => selected[id]);
|
|
142
154
|
const selectedInvoices = selectedInvoiceIds
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/contributor-billing",
|
|
3
3
|
"description": "Document models that help contributors of open organisations get paid anonymously for their work on a monthly basis.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.24",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|