@powerhousedao/contributor-billing 0.1.23 → 0.1.25

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.
@@ -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,4CAySA,CAAC"}
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
- invoicesToProcess.forEach(async (id) => {
107
- setSelected({ ...selected, [id]: false });
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;AAexC,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,4CAiqBnB,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
- await dispatchActions(billingStatementActions.editContributor({
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
- await dispatchActions(billingStatementActions.editBillingStatement(billingStatementData), createdNode.id);
114
- // add line items from invoiceState to billing statement
115
- invoiceState.state.global.lineItems.forEach(async (lineItem) => {
116
- await dispatchActions(billingStatementActions.addLineItem({
117
- id: lineItem.id,
118
- description: lineItem.description,
119
- quantity: lineItem.quantity,
120
- // Map invoice fields to billing statement fields
121
- totalPriceCash: lineItem.totalPriceTaxIncl || 0,
122
- totalPricePwt: 0, // Default to 0 since invoice doesn't have POWT pricing
123
- unit: "UNIT", // Default to UNIT since invoice doesn't have unit field
124
- unitPriceCash: lineItem.unitPriceTaxIncl || 0,
125
- unitPricePwt: 0, // Default to 0 since invoice doesn't have POWT pricing
126
- }), createdNode.id);
127
- });
128
- // add tags from each invoice line item to billing statement line item
129
- invoiceState.state.global.lineItems.forEach(async (lineItem) => {
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
- lineItemTag.forEach(async (tag) => {
132
- await dispatchActions(billingStatementActions.editLineItemTag({
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
- }), createdNode.id);
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
@@ -7,7 +7,7 @@ import { getCountryCodeFromName, mapChainNameToConfig } from "./utils/utils.js";
7
7
  import { LoaderCircle } from "lucide-react";
8
8
  let GRAPHQL_URL = "http://localhost:4001/graphql/invoice";
9
9
  if (!window.document.baseURI.includes("localhost")) {
10
- GRAPHQL_URL = "https://switchboard-dev.powerhouse.xyz/graphql/invoice";
10
+ GRAPHQL_URL = "https://switchboard-staging.powerhouse.xyz/graphql/invoice";
11
11
  }
12
12
  export async function loadPDFFile({ file, dispatch, }) {
13
13
  if (!file)
@@ -4,7 +4,7 @@ import { actions } from "../../document-models/invoice/index.js";
4
4
  import { generateId } from "document-model";
5
5
  let GRAPHQL_URL = "http://localhost:4001/graphql/invoice";
6
6
  if (!window.document.baseURI.includes('localhost')) {
7
- GRAPHQL_URL = 'https://switchboard-dev.powerhouse.xyz/graphql/invoice';
7
+ GRAPHQL_URL = 'https://switchboard-staging.powerhouse.xyz/graphql/invoice';
8
8
  }
9
9
  const InvoiceToGnosis = ({ docState, dispatch, }) => {
10
10
  const [isLoading, setIsLoading] = useState(false);
@@ -4,7 +4,7 @@ import { actions } from "../../document-models/invoice/index.js";
4
4
  import { generateId } from "document-model";
5
5
  let GRAPHQL_URL = "http://localhost:4001/graphql/invoice";
6
6
  if (!window.document.baseURI.includes('localhost')) {
7
- GRAPHQL_URL = 'https://switchboard-dev.powerhouse.xyz/graphql/invoice';
7
+ GRAPHQL_URL = 'https://switchboard-staging.powerhouse.xyz/graphql/invoice';
8
8
  }
9
9
  const RequestFinance = ({ docState, dispatch, }) => {
10
10
  const [isLoading, setIsLoading] = useState(false);
@@ -7,7 +7,7 @@
7
7
  */
8
8
  let GRAPHQL_URL = 'http://localhost:4001/graphql/invoice';
9
9
  if (!window.document.baseURI.includes('localhost')) {
10
- GRAPHQL_URL = 'https://switchboard-dev.powerhouse.xyz/graphql/invoice';
10
+ GRAPHQL_URL = 'https://switchboard-staging.powerhouse.xyz/graphql/invoice';
11
11
  }
12
12
  export async function uploadPdfChunked(pdfData, endpoint = GRAPHQL_URL, chunkSize = 500 * 1024, // 500KB chunks
13
13
  onProgress) {
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.23",
4
+ "version": "0.1.25",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
7
7
  "files": [