@powerhousedao/contributor-billing 0.0.34 → 0.0.36

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":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/components/DriveExplorer.tsx"],"names":[],"mappings":"AAUA,OAAO,EAGL,mBAAmB,EAEnB,KAAK,qBAAqB,EAE1B,KAAK,IAAI,EACV,MAAM,gBAAgB,CAAC;AASxB,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,KAAK,kBAAkB,EAMxB,MAAM,gCAAgC,CAAC;AAKxC,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5E,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,qBAAqB,CAAC;IAChC,QAAQ,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC;CAC/C;AAED,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,KAAK,EACL,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE,kBAAkB,2CAyQpB"}
1
+ {"version":3,"file":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/components/DriveExplorer.tsx"],"names":[],"mappings":"AAUA,OAAO,EAGL,mBAAmB,EAEnB,KAAK,qBAAqB,EAE1B,KAAK,IAAI,EACV,MAAM,gBAAgB,CAAC;AASxB,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,KAAK,kBAAkB,EAMxB,MAAM,gCAAgC,CAAC;AAMxC,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5E,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,qBAAqB,CAAC;IAChC,QAAQ,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC;CAC/C;AAED,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,KAAK,EACL,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE,kBAAkB,2CAsRpB"}
@@ -11,6 +11,7 @@ import { useDriveActionsWithUiNodes, useDriveContext, } from "@powerhousedao/rea
11
11
  import { InvoiceTable } from "./InvoiceTable/InvoiceTable.js";
12
12
  import { actions } from "../../../document-models/invoice/index.js";
13
13
  import { useDrop } from "../hooks/useDrop.js";
14
+ import { ToastContainer } from '@powerhousedao/design-system';
14
15
  export function DriveExplorer({ driveId, nodes, onDeleteNode, renameNode, onAddFolder, onCopyNode, context, document, dispatch, }) {
15
16
  const [selectedNodeId, setSelectedNodeId] = useState();
16
17
  const [activeDocumentId, setActiveDocumentId] = useState();
@@ -105,5 +106,5 @@ export function DriveExplorer({ driveId, nodes, onDeleteNode, renameNode, onAddF
105
106
  const editorModule = activeDocument
106
107
  ? context.getEditor(activeDocument.documentType)
107
108
  : null;
108
- return (_jsxs("div", { className: "flex h-full", children: [nodes.map((node) => (_jsx(DocumentDispatch, { documentId: node.id, driveId: driveId, documentModelModule: documentModels, context: context, onDispatchReady: (dispatch) => handleDispatchReady(node.id, dispatch) }, node.id))), _jsx("div", { className: "flex-1 p-4 overflow-y-auto", children: activeDocument && documentModelModule && editorModule ? (_jsx(EditorContainer, { context: context, documentId: activeDocumentId, documentType: activeDocument.documentType, driveId: driveId, onClose: handleEditorClose, title: activeDocument.name, documentModelModule: documentModelModule, editorModule: editorModule })) : (_jsx("div", { ...dropProps, className: twMerge("editor-container rounded-md border-2 border-transparent ", isDropTarget && "border-dashed border-blue-100"), children: _jsx(InvoiceTable, { setActiveDocumentId: setActiveDocumentId, files: files, state: state, getDispatch: () => dispatchMap[activeDocumentId || ""], selected: selected, setSelected: setSelected, onBatchAction: handleBatchAction, onDeleteNode: onDeleteNode, renameNode: renameNode, filteredDocumentModels: filteredDocumentModels, onSelectDocumentModel: onSelectDocumentModel, dispatchMap: dispatchMap }) })) }), _jsx(CreateDocumentModal, { onContinue: onCreateDocument, onOpenChange: (open) => setOpenModal(open), open: openModal })] }));
109
+ return (_jsxs("div", { className: "flex h-full", children: [_jsx(ToastContainer, { position: "bottom-right", autoClose: 5000, hideProgressBar: false, newestOnTop: false, closeOnClick: false, rtl: false, pauseOnFocusLoss: true, draggable: true, pauseOnHover: true, theme: "light" }), nodes.map((node) => (_jsx(DocumentDispatch, { documentId: node.id, driveId: driveId, documentModelModule: documentModels, context: context, onDispatchReady: (dispatch) => handleDispatchReady(node.id, dispatch) }, node.id))), _jsx("div", { className: "flex-1 p-4 overflow-y-auto", children: activeDocument && documentModelModule && editorModule ? (_jsx(EditorContainer, { context: context, documentId: activeDocumentId, documentType: activeDocument.documentType, driveId: driveId, onClose: handleEditorClose, title: activeDocument.name, documentModelModule: documentModelModule, editorModule: editorModule })) : (_jsx("div", { ...dropProps, className: twMerge("editor-container rounded-md border-2 border-transparent ", isDropTarget && "border-dashed border-blue-100"), children: _jsx(InvoiceTable, { setActiveDocumentId: setActiveDocumentId, files: files, state: state, getDispatch: () => dispatchMap[activeDocumentId || ""], selected: selected, setSelected: setSelected, onBatchAction: handleBatchAction, onDeleteNode: onDeleteNode, renameNode: renameNode, filteredDocumentModels: filteredDocumentModels, onSelectDocumentModel: onSelectDocumentModel, dispatchMap: dispatchMap, driveId: driveId }) })) }), _jsx(CreateDocumentModal, { onContinue: onCreateDocument, onOpenChange: (open) => setOpenModal(open), open: openModal })] }));
109
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderControls.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/HeaderControls.tsx"],"names":[],"mappings":"AAYA,eAAO,MAAM,cAAc,GAAI,wIAS5B;IACD,kBAAkB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACxD,aAAa,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACnD,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;IACzD,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,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B,4CA2GA,CAAC"}
1
+ {"version":3,"file":"HeaderControls.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/HeaderControls.tsx"],"names":[],"mappings":"AAYA,eAAO,MAAM,cAAc,GAAI,wIAS5B;IACD,kBAAkB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACxD,aAAa,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACnD,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;IACzD,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,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B,4CAyFA,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
3
  import { Select } from "@powerhousedao/document-engineering";
4
+ import ConfirmationModal from "../../../invoice/components/confirmationModal.js";
4
5
  const currencyOptions = [
5
6
  { label: "CHF", value: "CHF" },
6
7
  { label: "USD", value: "USD" },
@@ -32,8 +33,8 @@ export const HeaderControls = ({ contributorOptions = [], statusOptions = [], on
32
33
  }, options: batchOptions, onChange: (value) => onBatchAction?.(value), placeholder: "Batch Action", selectionIcon: "checkmark" })] })] }), _jsxs("div", { className: "flex gap-2 items-center", children: [_jsx(Select, { style: {
33
34
  width: "200px",
34
35
  height: "30px",
35
- }, options: statusOptions, onChange: onStatusChange, placeholder: "Status", selectionIcon: "checkmark", multiple: true }), _jsx("input", { type: "text", className: "border rounded px-2 py-1 text-sm", placeholder: "Search", onChange: (e) => onSearchChange?.(e.target.value) })] }), showCurrencyModal && (_jsx("div", { className: "fixed inset-0", children: _jsxs("div", { className: "absolute left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2 bg-white rounded shadow-lg p-6 min-w-[300px] flex flex-col items-center", children: [_jsx("h3", { className: "text-lg font-semibold mb-4", children: "Select Base Currency" }), _jsx("select", { className: "border border-gray-300 rounded px-2 py-1 mb-4", value: selectedCurrency, onChange: (e) => setSelectedCurrency(e.target.value), children: currencyOptions.map((opt) => (_jsx("option", { value: opt.value, children: opt.label }, opt.value))) }), _jsxs("div", { className: "flex gap-2", children: [_jsx("button", { className: "bg-blue-600 text-white px-4 py-1 rounded hover:bg-blue-700", onClick: () => {
36
- setShowCurrencyModal(false);
37
- onExport?.(selectedCurrency);
38
- }, children: "Export" }), _jsx("button", { className: "bg-gray-200 px-4 py-1 rounded hover:bg-gray-300", onClick: () => setShowCurrencyModal(false), children: "Cancel" })] })] }) }))] }));
36
+ }, options: statusOptions, onChange: onStatusChange, placeholder: "Status", selectionIcon: "checkmark", multiple: true }), _jsx("input", { type: "text", className: "border rounded px-2 py-1 text-sm", placeholder: "Search", onChange: (e) => onSearchChange?.(e.target.value) })] }), _jsx(ConfirmationModal, { open: showCurrencyModal, onCancel: () => setShowCurrencyModal(false), onContinue: () => {
37
+ setShowCurrencyModal(false);
38
+ onExport?.(selectedCurrency);
39
+ }, header: "Select Base Currency", continueLabel: "Export", cancelLabel: "Cancel", children: _jsx(Select, { options: currencyOptions, onChange: (value) => setSelectedCurrency(value), placeholder: "Select Base Currency" }) })] }));
39
40
  };
@@ -1,7 +1,6 @@
1
1
  import { type UiFileNode } from "@powerhousedao/design-system";
2
- import { EditorDispatch } from "document-model";
3
2
  import { DocumentModelModule } from "document-model";
4
- import { DocumentDriveAction } from "document-drive";
3
+ import { type InvoiceAction } from "../../../../document-models/invoice/index.js";
5
4
  interface InvoiceTableProps {
6
5
  files: UiFileNode[];
7
6
  state: Record<string, any>;
@@ -22,8 +21,9 @@ interface InvoiceTableProps {
22
21
  renameNode: (nodeId: string, name: string) => void;
23
22
  filteredDocumentModels: DocumentModelModule[];
24
23
  onSelectDocumentModel: (model: DocumentModelModule) => void;
25
- dispatchMap: Record<string, EditorDispatch<DocumentDriveAction>>;
24
+ dispatchMap: Record<string, (action: InvoiceAction) => void>;
25
+ driveId: string;
26
26
  }
27
- export declare const InvoiceTable: ({ files, state, setActiveDocumentId, getDispatch, selected, setSelected, onBatchAction, onDeleteNode, renameNode, filteredDocumentModels, onSelectDocumentModel, dispatchMap, }: InvoiceTableProps) => import("react/jsx-runtime").JSX.Element;
27
+ export declare const InvoiceTable: ({ files, state, setActiveDocumentId, getDispatch, selected, setSelected, onBatchAction, onDeleteNode, renameNode, filteredDocumentModels, onSelectDocumentModel, dispatchMap, driveId, }: InvoiceTableProps) => import("react/jsx-runtime").JSX.Element;
28
28
  export {};
29
29
  //# sourceMappingURL=InvoiceTable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InvoiceTable.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTable.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAM/D,OAAO,EAAE,cAAc,EAA0B,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAuBrD,UAAU,iBAAiB;IACzB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,eAAe,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAChE,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,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,sBAAsB,EAAE,mBAAmB,EAAE,CAAC;IAC9C,qBAAqB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5D,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC;CAClE;AAED,eAAO,MAAM,YAAY,GAAI,iLAa1B,iBAAiB,4CA+enB,CAAC"}
1
+ {"version":3,"file":"InvoiceTable.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTable.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAU/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAIrD,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,8CAA8C,CAAC;AAwBtD,UAAU,iBAAiB;IACzB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,eAAe,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAChE,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,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,sBAAsB,EAAE,mBAAmB,EAAE,CAAC;IAC9C,qBAAqB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5D,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC,CAAC;IAC7D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,YAAY,GAAI,0LAc1B,iBAAiB,4CA4rBnB,CAAC"}
@@ -1,5 +1,6 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from "react";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import { useState, useMemo } from "react";
3
4
  import { HeaderControls } from "./HeaderControls.js";
4
5
  import { InvoiceTableSection } from "./InvoiceTableSection.js";
5
6
  import { InvoiceTableRow } from "./InvoiceTableRow.js";
@@ -7,17 +8,21 @@ import { useDriveContext, } from "@powerhousedao/reactor-browser";
7
8
  import { generateId } from "document-model";
8
9
  import { mapTags } from "../../../billing-statement/lineItemTags/tagMapping.js";
9
10
  import { exportInvoicesToXeroCSV } from "../../../../scripts/contributor-billing/createXeroCsv.js";
11
+ import { toast } from "@powerhousedao/design-system";
10
12
  const statusOptions = [
11
13
  { label: "Draft", value: "DRAFT" },
12
- { label: "Awaiting Approval", value: "AWAITINGAPPROVAL" },
13
- { label: "Awaiting Payment", value: "AWAITINGPAYMENT" },
14
- { label: "Payment Received", value: "PAYMENTRECEIVED" },
14
+ { label: "Issued", value: "ISSUED" },
15
+ { label: "Accepted", value: "ACCEPTED" },
16
+ { label: "Payment Scheduled", value: "PAYMENTSCHEDULED" },
17
+ { label: "Payment Sent", value: "PAYMENTSENT" },
18
+ { label: "Payment Issue", value: "PAYMENTISSUE" },
19
+ { label: "Payment Closed", value: "PAYMENTCLOSED" },
15
20
  { label: "Rejected", value: "REJECTED" },
16
21
  { label: "Other", value: "OTHER" },
17
22
  ];
18
- export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, selected, setSelected, onBatchAction, onDeleteNode, renameNode, filteredDocumentModels, onSelectDocumentModel, dispatchMap, }) => {
23
+ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, selected, setSelected, onBatchAction, onDeleteNode, renameNode, filteredDocumentModels, onSelectDocumentModel, dispatchMap, driveId, }) => {
19
24
  const [selectedStatuses, setSelectedStatuses] = useState([]);
20
- const { addDocument, addFile, documentModels, useDriveDocumentStates, selectedNode, } = useDriveContext();
25
+ const { addDocument, addFile, documentModels, useDriveDocumentStates, selectedNode, useDocumentEditorProps, } = useDriveContext();
21
26
  const billingDocStates = Object.entries(state)
22
27
  .filter(([_, doc]) => doc.documentType === "powerhouse/billing-statement")
23
28
  .map(([id, doc]) => ({
@@ -58,9 +63,11 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
58
63
  .filter(([_, doc]) => doc.documentType === "powerhouse/invoice" &&
59
64
  doc.global.status !== "DRAFT" &&
60
65
  doc.global.status !== "ISSUED" &&
61
- doc.global.status !== "AWAITINGAPPROVAL" &&
66
+ doc.global.status !== "ACCEPTED" &&
62
67
  doc.global.status !== "PAYMENTSCHEDULED" &&
63
- doc.global.status !== "PAYMENTRECEIVED" &&
68
+ doc.global.status !== "PAYMENTSENT" &&
69
+ doc.global.status !== "PAYMENTISSUE" &&
70
+ doc.global.status !== "PAYMENTCLOSED" &&
64
71
  doc.global.status !== "REJECTED")
65
72
  .map(([id, doc]) => ({
66
73
  id,
@@ -76,9 +83,12 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
76
83
  }));
77
84
  };
78
85
  const draft = getInvoicesByStatus("DRAFT");
79
- const awaitingApproval = getInvoicesByStatus("ISSUED");
80
- const awaitingPayment = getInvoicesByStatus("PAYMENTSCHEDULED");
81
- const paid = getInvoicesByStatus("PAYMENTRECEIVED");
86
+ const issued = getInvoicesByStatus("ISSUED");
87
+ const accepted = getInvoicesByStatus("ACCEPTED");
88
+ const paymentScheduled = getInvoicesByStatus("PAYMENTSCHEDULED");
89
+ const paymentSent = getInvoicesByStatus("PAYMENTSENT");
90
+ const paymentIssue = getInvoicesByStatus("PAYMENTISSUE");
91
+ const paymentClosed = getInvoicesByStatus("PAYMENTCLOSED");
82
92
  const rejected = getInvoicesByStatus("REJECTED");
83
93
  const otherInvoices = getOtherInvoices();
84
94
  const handleDelete = (id) => {
@@ -116,7 +126,7 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
116
126
  id: item.id,
117
127
  description: item.description,
118
128
  quantity: item.quantity,
119
- unit: 'UNIT',
129
+ unit: "UNIT",
120
130
  unitPricePwt: 0,
121
131
  unitPriceCash: item.unitPriceTaxIncl,
122
132
  totalPricePwt: 0,
@@ -161,7 +171,7 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
161
171
  id: item.id,
162
172
  description: item.description,
163
173
  quantity: item.quantity,
164
- unit: 'UNIT',
174
+ unit: "UNIT",
165
175
  unitPricePwt: 0,
166
176
  unitPriceCash: item.unitPriceTaxIncl,
167
177
  totalPricePwt: 0,
@@ -181,29 +191,81 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
181
191
  clipboard: [],
182
192
  });
183
193
  };
184
- const selectedInvoiceIds = Object.keys(selected).filter(id => selected[id]);
185
- const selectedInvoices = selectedInvoiceIds.map(id => state[id]);
186
- const selectedInvoiceStatuses = selectedInvoices.map(inv => inv?.global?.status || inv?.status);
187
- const handleCSVExport = (baseCurrency) => {
188
- console.log('Exporting selected invoices:', selectedInvoiceIds.map((id, idx) => ({
194
+ const selectedInvoiceIds = Object.keys(selected).filter((id) => selected[id]);
195
+ const selectedInvoices = selectedInvoiceIds.map((id) => ({
196
+ ...state[id],
197
+ id,
198
+ }));
199
+ const selectedInvoiceStatuses = selectedInvoices.map((inv) => inv?.global?.status || inv?.status);
200
+ // Create dispatch map for selected invoices using the existing dispatchMap prop
201
+ const selectedInvoiceDispatchMap = useMemo(() => {
202
+ const map = {};
203
+ selectedInvoiceIds.forEach((invoiceId) => {
204
+ if (dispatchMap[invoiceId]) {
205
+ map[invoiceId] = dispatchMap[invoiceId];
206
+ }
207
+ });
208
+ return map;
209
+ }, [selectedInvoiceIds, dispatchMap]);
210
+ const handleCSVExport = async (baseCurrency) => {
211
+ console.log("Exporting selected invoices:", selectedInvoiceIds.map((id, idx) => ({
189
212
  id,
190
213
  state: selectedInvoices[idx],
191
214
  })));
192
- exportInvoicesToXeroCSV(selectedInvoices, baseCurrency);
215
+ try {
216
+ const exportedInvoices = await exportInvoicesToXeroCSV(selectedInvoices, baseCurrency);
217
+ // Object.entries(exportedInvoices).forEach(
218
+ // ([invoiceId, invoiceData]: [string, any]) => {
219
+ // const dispatch = selectedInvoiceDispatchMap[invoiceId];
220
+ // if (dispatch) {
221
+ // dispatch(
222
+ // actions.setExportedData({
223
+ // timestamp: invoiceData.exportTimestamp as string,
224
+ // exportedLineItems: invoiceData.exportedLines as string[][],
225
+ // })
226
+ // );
227
+ // } else {
228
+ // console.warn(`No dispatch function found for invoice ${invoiceId}`);
229
+ // }
230
+ // }
231
+ // );
232
+ toast("Invoices exported successfully", {
233
+ type: "success",
234
+ });
235
+ }
236
+ catch (error) {
237
+ console.error("Error exporting invoices:", error);
238
+ const missingExpenseTagInvoices = error.missingExpenseTagInvoices || [];
239
+ const missingExpenseTagInvoicesList = missingExpenseTagInvoices.map((invoiceId) => {
240
+ const invoice = files.find((file) => file.id === invoiceId);
241
+ return invoice?.name || invoiceId;
242
+ });
243
+ console.log("missingExpenseTagInvoicesList", missingExpenseTagInvoicesList);
244
+ toast(_jsxs(_Fragment, { children: ["Invoice Line Item Tags need to be set for:", _jsx("br", {}), missingExpenseTagInvoicesList.map((name, idx) => (_jsxs(React.Fragment, { children: ["- ", name, _jsx("br", {})] }, name)))] }), { type: "error" });
245
+ }
193
246
  };
194
247
  return (_jsxs("div", { className: "w-full h-full bg-white rounded-lg p-4 border border-gray-200 shadow-md mt-4 overflow-x-auto", children: [_jsx(HeaderControls, { statusOptions: statusOptions, onStatusChange: handleStatusChange, onBatchAction: onBatchAction, onExport: handleCSVExport, selectedStatuses: selectedInvoiceStatuses }), shouldShowSection("DRAFT") && (_jsx(InvoiceTableSection, { title: "Draft", count: draft.length, onSelectDocumentModel: onSelectDocumentModel, filteredDocumentModels: filteredDocumentModels, children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Invoice" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2", children: "Exported" })] }) }), _jsx("tbody", { children: draft.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
195
248
  ...prev,
196
249
  [row.id]: checked,
197
- })), menuOptions: getMenuOptions(), onMenuAction: (action) => { }, setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode }, row.id))) })] }) })), shouldShowSection("AWAITINGAPPROVAL") && (_jsx(InvoiceTableSection, { title: "Awaiting Approval", count: awaitingApproval.length, children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Billing Statement" }), _jsx("th", { className: "px-2 py-2", children: "Exported" })] }) }), _jsx("tbody", { children: awaitingApproval.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
250
+ })), menuOptions: getMenuOptions(), onMenuAction: (action) => { }, setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode }, row.id))) })] }) })), shouldShowSection("ISSUED") && (_jsx(InvoiceTableSection, { title: "Issued", count: issued.length, children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Billing Statement" }), _jsx("th", { className: "px-2 py-2", children: "Exported" })] }) }), _jsx("tbody", { children: issued.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
251
+ ...prev,
252
+ [row.id]: checked,
253
+ })), menuOptions: getMenuOptions(), onMenuAction: (action) => { }, setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode, onCreateBillingStatement: handleCreateBillingStatement, billingDocStates: billingDocStates }, row.id))) })] }) })), shouldShowSection("ACCEPTED") && (_jsx(InvoiceTableSection, { title: "Accepted", count: accepted.length, color: "bg-green-100 text-green-600", children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-centert", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2", children: "Exported" })] }) }), _jsx("tbody", { children: accepted.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
254
+ ...prev,
255
+ [row.id]: checked,
256
+ })), menuOptions: getMenuOptions(), onMenuAction: (action) => { }, setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode, onCreateBillingStatement: handleCreateBillingStatement, billingDocStates: billingDocStates }, row.id))) })] }) })), shouldShowSection("PAYMENTSCHEDULED") && (_jsx(InvoiceTableSection, { title: "Payment Scheduled", count: paymentScheduled.length, color: "bg-green-100 text-green-600", children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-centert", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2", children: "Exported" })] }) }), _jsx("tbody", { children: paymentScheduled.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
257
+ ...prev,
258
+ [row.id]: checked,
259
+ })), menuOptions: getMenuOptions(), onMenuAction: (action) => { }, setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode, onCreateBillingStatement: handleCreateBillingStatement, billingDocStates: billingDocStates }, row.id))) })] }) })), shouldShowSection("PAYMENTSENT") && (_jsx(InvoiceTableSection, { title: "Payment Sent", count: paymentSent.length, color: "bg-green-100 text-green-600", children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-centert", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2", children: "Exported" })] }) }), _jsx("tbody", { children: paymentSent.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
198
260
  ...prev,
199
261
  [row.id]: checked,
200
- })), menuOptions: getMenuOptions(), onMenuAction: (action) => { }, setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode, onCreateBillingStatement: handleCreateBillingStatement, billingDocStates: billingDocStates }, row.id))) })] }) })), shouldShowSection("AWAITINGPAYMENT") && (_jsx(InvoiceTableSection, { title: "Awaiting Payment", count: awaitingPayment.length, color: "bg-yellow-100 text-yellow-600", children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Billing Statement" }), _jsx("th", { className: "px-2 py-2", children: "Exported" })] }) }), _jsx("tbody", { children: awaitingPayment.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
262
+ })), menuOptions: getMenuOptions(), onMenuAction: (action) => { }, setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode, onCreateBillingStatement: handleCreateBillingStatement, billingDocStates: billingDocStates }, row.id))) })] }) })), shouldShowSection("PAYMENTISSUE") && (_jsx(InvoiceTableSection, { title: "Payment Issue", count: paymentIssue.length, color: "bg-yellow-100 text-yellow-600", children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-centert", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2", children: "Exported" })] }) }), _jsx("tbody", { children: paymentIssue.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
201
263
  ...prev,
202
264
  [row.id]: checked,
203
- })), menuOptions: getMenuOptions(), onMenuAction: (action) => { }, setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode, onCreateBillingStatement: handleCreateBillingStatement, billingDocStates: billingDocStates }, row.id))) })] }) })), shouldShowSection("PAYMENTRECEIVED") && (_jsx(InvoiceTableSection, { title: "Payment Received", count: paid.length, color: "bg-green-100 text-green-600", children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Billing Statement" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Exported" })] }) }), _jsx("tbody", { children: paid.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
265
+ })), menuOptions: getMenuOptions(), onMenuAction: (action) => { }, setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode, onCreateBillingStatement: handleCreateBillingStatement, billingDocStates: billingDocStates }, row.id))) })] }) })), shouldShowSection("PAYMENTCLOSED") && (_jsx(InvoiceTableSection, { title: "Payment Closed", count: paymentClosed.length, color: "bg-red-500 text-black-600", children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-centert", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2", children: "Exported" })] }) }), _jsx("tbody", { children: paymentClosed.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
204
266
  ...prev,
205
267
  [row.id]: checked,
206
- })), menuOptions: getMenuOptions(), onMenuAction: (action) => { }, setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode, onCreateBillingStatement: handleCreateBillingStatement, billingDocStates: billingDocStates }, row.id))) })] }) })), shouldShowSection("REJECTED") && (_jsx(InvoiceTableSection, { title: "Rejected", count: rejected.length, color: "bg-red-500 text-black-600", children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-centert", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2", children: "Exported" })] }) }), _jsx("tbody", { children: rejected.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
268
+ })), menuOptions: getMenuOptions(), onMenuAction: (action) => { }, setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode }, row.id))) })] }) })), shouldShowSection("REJECTED") && (_jsx(InvoiceTableSection, { title: "Rejected", count: rejected.length, color: "bg-red-500 text-black-600", children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-centert", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2", children: "Exported" })] }) }), _jsx("tbody", { children: rejected.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
207
269
  ...prev,
208
270
  [row.id]: checked,
209
271
  })), menuOptions: getMenuOptions(), onMenuAction: (action) => { }, setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode }, row.id))) })] }) })), shouldShowSection("OTHER") && (_jsx(InvoiceTableSection, { title: "Other", count: otherInvoices.length, children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Exported" })] }) }), _jsx("tbody", { children: otherInvoices.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
@@ -7,5 +7,5 @@ export const InvoiceTableRow = ({ files, row, isSelected, onSelect, menuOptions,
7
7
  const billingDoc = billingDocStates?.find((doc) => doc.contributor === row.id);
8
8
  const billingFile = files?.find((file) => file.id === billingDoc?.id);
9
9
  const file = files?.find((file) => file.id === row.id);
10
- return (_jsxs("tr", { className: "hover:bg-gray-50", children: [_jsx("td", { className: "px-2 py-2", children: _jsx("input", { type: "checkbox", checked: isSelected, onChange: (e) => onSelect(e.target.checked), className: "size-4 rounded border-gray-300 text-blue-600 focus:ring-2 focus:ring-blue-500" }) }), _jsx("td", { className: "py-1 w-10", children: file && (_jsx(FileItem, { uiNode: file, onSelectNode: () => setActiveDocumentId(row.id), onRenameNode: (name) => renameNode(row.id, name), onDuplicateNode: () => { }, onDeleteNode: () => onDeleteNode(row.id), isAllowedToCreateDocuments: true, className: "h-10" }, row.id)) }), _jsx("td", { className: "px-2 py-2 text-center", children: row.invoiceNo }), _jsx("td", { className: "px-2 py-2 text-center", children: row.issueDate }), _jsx("td", { className: "px-2 py-2 text-center", children: row.dueDate }), _jsx("td", { className: "px-2 py-2 text-center", children: row.currency }), _jsx("td", { className: "px-2 py-2 text-center", children: row.amount }), (row.status === "ISSUED" || row.status === "PAYMENTSCHEDULED" || row.status === "PAYMENTRECEIVED") && !billingFile && (_jsx("td", { className: "px-2 py-2 text-center", children: _jsx("button", { className: "bg-white border border-gray-300 rounded px-3 py-1 text-sm hover:bg-gray-100 col-span-1 justify-self-end", onClick: () => onCreateBillingStatement?.(row.id), children: "Generate Billing Statement" }) })), billingFile && (_jsx("td", { className: "px-2 py-2 text-center", children: _jsx(FileItem, { uiNode: billingFile, onSelectNode: () => setActiveDocumentId(billingDoc?.id), onRenameNode: (name) => renameNode(billingDoc?.id, name), onDuplicateNode: () => { }, onDeleteNode: () => onDeleteNode(billingDoc?.id), isAllowedToCreateDocuments: true, className: "h-10" }, billingDoc?.id) })), _jsx("td", { className: "px-2 py-2 text-center", children: row.exported ? _jsx("span", { className: "text-green-500", children: "Yes" }) : _jsx("span", { className: "text-red-500", children: "No" }) })] }));
10
+ return (_jsxs("tr", { className: "hover:bg-gray-50", children: [_jsx("td", { className: "px-2 py-2", children: _jsx("input", { type: "checkbox", checked: isSelected, onChange: (e) => onSelect(e.target.checked), className: "size-4 rounded border-gray-300 text-blue-600 focus:ring-2 focus:ring-blue-500" }) }), _jsx("td", { className: "py-1 w-10", children: file && (_jsx(FileItem, { uiNode: file, onSelectNode: () => setActiveDocumentId(row.id), onRenameNode: (name) => renameNode(row.id, name), onDuplicateNode: () => { }, onDeleteNode: () => onDeleteNode(row.id), isAllowedToCreateDocuments: true, className: "h-10" }, row.id)) }), _jsx("td", { className: "px-2 py-2 text-center", children: row.invoiceNo }), _jsx("td", { className: "px-2 py-2 text-center", children: row.issueDate }), _jsx("td", { className: "px-2 py-2 text-center", children: row.dueDate }), _jsx("td", { className: "px-2 py-2 text-center", children: row.currency }), _jsx("td", { className: "px-2 py-2 text-center", children: row.amount }), (row.status === "ISSUED" || row.status === "PAYMENTSCHEDULED" || row.status === "PAYMENTRECEIVED") && !billingFile && (_jsx("td", { className: "px-2 py-2 text-center", children: _jsx("button", { className: "bg-white border border-gray-300 rounded px-3 py-1 text-sm hover:bg-gray-100 col-span-1 justify-self-end", onClick: () => onCreateBillingStatement?.(row.id), children: "Generate Billing Statement" }) })), billingFile && (_jsx("td", { className: "px-2 py-2 text-center", children: _jsx(FileItem, { uiNode: billingFile, onSelectNode: () => setActiveDocumentId(billingDoc?.id), onRenameNode: (name) => renameNode(billingDoc?.id, name), onDuplicateNode: () => { }, onDeleteNode: () => onDeleteNode(billingDoc?.id), isAllowedToCreateDocuments: true, className: "h-10" }, billingDoc?.id) })), _jsx("td", { className: "px-2 py-2 text-center", children: row.exported.timestamp ? _jsx("span", { className: "text-green-500", children: "Yes" }) : _jsx("span", { className: "text-red-500", children: "No" }) })] }));
11
11
  };
@@ -406,5 +406,5 @@ export default function Editor(props) {
406
406
  }));
407
407
  }
408
408
  setActiveModal(null);
409
- }, continueLabel: modalContinueLabels[activeModal], continueDisabled: modalWarning, children: modalContentMap[activeModal] })), (state.status === "ACCEPTED" || state.status === "PAYMENTSCHEDULED") && (_jsx("div", { className: "mt-8", children: !isFiatCurrency(state.currency) ? (_jsx(InvoiceToGnosis, { docState: state, dispatch: dispatch })) : (_jsx(RequestFinance, { docState: state })) }))] }));
409
+ }, continueLabel: modalContinueLabels[activeModal], continueDisabled: modalWarning, children: modalContentMap[activeModal] })), (state.status === "ACCEPTED" || state.status === "PAYMENTSCHEDULED") && (_jsx("div", { className: "mt-8", children: !isFiatCurrency(state.currency) ? (_jsx(InvoiceToGnosis, { docState: state, dispatch: dispatch })) : (_jsx(RequestFinance, { docState: state, dispatch: dispatch })) }))] }));
410
410
  }
@@ -6,7 +6,7 @@ import { uploadPdfChunked } from "./uploadPdfChunked.js";
6
6
  import { getCountryCodeFromName } from "./utils/utils.js";
7
7
  let GRAPHQL_URL = 'http://localhost:4001/graphql/invoice';
8
8
  if (!window.document.baseURI.includes('localhost')) {
9
- GRAPHQL_URL = 'https://switchboard-dev.powerhouse.xyz/graphql/invoice';
9
+ GRAPHQL_URL = 'https://switchboard-staging.powerhouse.xyz/graphql/invoice';
10
10
  }
11
11
  export async function loadPDFFile({ file, dispatch, }) {
12
12
  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);
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  interface RequestFinanceProps {
3
3
  docState: any;
4
+ dispatch: any;
4
5
  }
5
6
  declare const RequestFinance: React.FC<RequestFinanceProps>;
6
7
  export default RequestFinance;
@@ -1 +1 @@
1
- {"version":3,"file":"requestFinance.d.ts","sourceRoot":"","sources":["../../../editors/invoice/requestFinance.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAQxC,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,GAAG,CAAC;CACf;AAED,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA2MjD,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"requestFinance.d.ts","sourceRoot":"","sources":["../../../editors/invoice/requestFinance.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAYxC,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,GAAG,CAAC;CACf;AAED,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAgNjD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,10 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
+ import { actions, } from "../../document-models/invoice/index.js";
4
+ import { generateId } from "document-model";
3
5
  let GRAPHQL_URL = 'http://localhost:4001/graphql/invoice';
4
6
  if (!window.document.baseURI.includes('localhost')) {
5
- GRAPHQL_URL = 'https://switchboard-dev.powerhouse.xyz/graphql/invoice';
7
+ GRAPHQL_URL = 'https://switchboard-staging.powerhouse.xyz/graphql/invoice';
6
8
  }
7
- const RequestFinance = ({ docState }) => {
9
+ const RequestFinance = ({ docState, dispatch }) => {
8
10
  const [isLoading, setIsLoading] = useState(false);
9
11
  const [error, setError] = useState(null);
10
12
  const [responseData, setResponseData] = useState(null);
@@ -84,7 +86,8 @@ const RequestFinance = ({ docState }) => {
84
86
  })),
85
87
  invoiceNumber: docState.invoiceNo,
86
88
  buyerInfo: {
87
- email: docState.payer.contactInfo.email,
89
+ // email: docState.payer.contactInfo.email,
90
+ email: 'prometheus@powerhouse.inc',
88
91
  firstName: docState.payer.name,
89
92
  // lastName: docState.payer.name.split(" ")[1] || "Liberty",
90
93
  businessName: docState.payer.name,
@@ -134,6 +137,10 @@ const RequestFinance = ({ docState }) => {
134
137
  // Process the response
135
138
  if (directPaymentResult?.response?.invoiceLinks?.pay) {
136
139
  setInvoiceLink(directPaymentResult.response.invoiceLinks.pay);
140
+ dispatch(actions.schedulePayment({
141
+ id: generateId(),
142
+ processorRef: directPaymentResult.response.invoiceLinks.pay,
143
+ }));
137
144
  }
138
145
  setResponseData(directPaymentResult);
139
146
  setDirectPaymentStatus("Direct payment created successfully");
@@ -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) {
@@ -4,5 +4,5 @@
4
4
  * See: https://frankfurter.dev/
5
5
  */
6
6
  export declare function getExchangeRate(date: string, from: string, to: string): Promise<number>;
7
- export declare function exportInvoicesToXeroCSV(invoiceStates: any[], baseCurrency: string): Promise<void>;
7
+ export declare function exportInvoicesToXeroCSV(invoiceStates: any[], baseCurrency: string): Promise<any>;
8
8
  //# sourceMappingURL=createXeroCsv.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createXeroCsv.d.ts","sourceRoot":"","sources":["../../../scripts/contributor-billing/createXeroCsv.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkC7F;AAED,wBAAsB,uBAAuB,CAAC,aAAa,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+LvG"}
1
+ {"version":3,"file":"createXeroCsv.d.ts","sourceRoot":"","sources":["../../../scripts/contributor-billing/createXeroCsv.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkC7F;AAED,wBAAsB,uBAAuB,CAAC,aAAa,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CA+LtG"}
@@ -58,9 +58,9 @@ export async function exportInvoicesToXeroCSV(invoiceStates, baseCurrency) {
58
58
  const exportDataByInvoice = {};
59
59
  const exportTimestamp = new Date().toISOString();
60
60
  const missingExpenseTagInvoices = [];
61
- for (let state of invoiceStates) {
62
- state = state.global;
63
- const invoiceId = state.id || Math.random().toString(36).slice(2); // fallback if no id
61
+ for (let invoiceState of invoiceStates) {
62
+ const state = invoiceState.global;
63
+ const invoiceId = invoiceState.id;
64
64
  const invoiceName = state.name || invoiceId;
65
65
  const items = state.lineItems || [];
66
66
  const dateIssued = state.dateIssued || '';
@@ -183,7 +183,10 @@ export async function exportInvoicesToXeroCSV(invoiceStates, baseCurrency) {
183
183
  }
184
184
  // If any invoices are missing expense tags, throw an error
185
185
  if (missingExpenseTagInvoices.length > 0) {
186
- throw new Error(`The following invoices have line items missing a 'xero-expense-account' tag: ${[...new Set(missingExpenseTagInvoices)].join(', ')}`);
186
+ throw {
187
+ message: `The following invoices have line items missing a 'xero-expense-account' tag: ${[...new Set(missingExpenseTagInvoices)].join(', ')}`,
188
+ missingExpenseTagInvoices: missingExpenseTagInvoices
189
+ };
187
190
  }
188
191
  // Download CSV for all invoices
189
192
  const csvLines = [headers.join(',')].concat(allRows.map(row => row.map(value => `"${value}"`).join(',')));
@@ -199,8 +202,8 @@ export async function exportInvoicesToXeroCSV(invoiceStates, baseCurrency) {
199
202
  link.click();
200
203
  document.body.removeChild(link);
201
204
  // This is the data to be added to ExportData in the state of each invoice
202
- console.log(exportDataByInvoice);
205
+ // console.log(exportDataByInvoice)
203
206
  // Return or assign exportDataByInvoice as needed
204
207
  // For example, return it if you want to use it elsewhere:
205
- // return exportDataByInvoice;
208
+ return exportDataByInvoice;
206
209
  }
package/dist/style.css CHANGED
@@ -285,9 +285,6 @@
285
285
  .right-2 {
286
286
  right: calc(var(--spacing) * 2);
287
287
  }
288
- .left-1\/2 {
289
- left: calc(1/2 * 100%);
290
- }
291
288
  .z-10 {
292
289
  z-index: 10;
293
290
  }
@@ -472,9 +469,6 @@
472
469
  .min-w-\[142px\] {
473
470
  min-width: 142px;
474
471
  }
475
- .min-w-\[300px\] {
476
- min-width: 300px;
477
- }
478
472
  .min-w-\[900px\] {
479
473
  min-width: 900px;
480
474
  }
@@ -495,10 +489,6 @@
495
489
  --tw-border-spacing-y: calc(var(--spacing) * 0);
496
490
  border-spacing: var(--tw-border-spacing-x) var(--tw-border-spacing-y);
497
491
  }
498
- .-translate-x-1\/2 {
499
- --tw-translate-x: calc(calc(1/2 * 100%) * -1);
500
- translate: var(--tw-translate-x) var(--tw-translate-y);
501
- }
502
492
  .-translate-y-1\/2 {
503
493
  --tw-translate-y: calc(calc(1/2 * 100%) * -1);
504
494
  translate: var(--tw-translate-x) var(--tw-translate-y);
@@ -1008,13 +998,6 @@
1008
998
  }
1009
999
  }
1010
1000
  }
1011
- .hover\:bg-gray-300 {
1012
- &:hover {
1013
- @media (hover: hover) {
1014
- background-color: var(--color-gray-300);
1015
- }
1016
- }
1017
- }
1018
1001
  .hover\:bg-gray-600 {
1019
1002
  &:hover {
1020
1003
  @media (hover: hover) {
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.0.34",
4
+ "version": "0.0.36",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
7
7
  "files": [