@powerhousedao/contributor-billing 0.0.85 → 0.0.86
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/DriveExplorer.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/DriveExplorer.js +26 -1
- package/dist/editors/contributor-billing/components/EditorContainer.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/EditorContainer.js +13 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts +2 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.js +3 -12
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts +3 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.js +56 -112
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.js +19 -9
- package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts +1 -2
- package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts.map +1 -1
- package/dist/editors/invoice/requestFinance.d.ts.map +1 -1
- package/dist/editors/invoice/requestFinance.js +2 -0
- package/dist/reducers/general.d.ts +8 -0
- package/dist/reducers/general.d.ts.map +1 -0
- package/dist/reducers/general.js +73 -0
- package/dist/reducers/items.d.ts +8 -0
- package/dist/reducers/items.d.ts.map +1 -0
- package/dist/reducers/items.js +195 -0
- package/dist/reducers/parties.d.ts +8 -0
- package/dist/reducers/parties.d.ts.map +1 -0
- package/dist/reducers/parties.js +266 -0
- package/dist/reducers/transitions.d.ts +8 -0
- package/dist/reducers/transitions.d.ts.map +1 -0
- package/dist/reducers/transitions.js +162 -0
- package/dist/style.css +167 -20
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/components/DriveExplorer.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,gBAAgB,EAUtB,MAAM,gCAAgC,CAAC;AAUxC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"DriveExplorer.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/components/DriveExplorer.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,gBAAgB,EAUtB,MAAM,gCAAgC,CAAC;AAUxC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,2CAuWpD"}
|
|
@@ -46,6 +46,31 @@ export function DriveExplorer(props) {
|
|
|
46
46
|
// All document states
|
|
47
47
|
const allDocuments = useSelectedDriveDocuments();
|
|
48
48
|
const state = allDocuments;
|
|
49
|
+
// Handler for row selection (does not affect status filter display)
|
|
50
|
+
const handleRowSelection = useCallback((rowId, checked, rowStatus) => {
|
|
51
|
+
setSelected((prev) => ({
|
|
52
|
+
...prev,
|
|
53
|
+
[rowId]: checked,
|
|
54
|
+
}));
|
|
55
|
+
}, []);
|
|
56
|
+
// Determine if CSV export should be enabled based on selected rows
|
|
57
|
+
const canExportSelectedRows = useCallback(() => {
|
|
58
|
+
const allowedStatuses = [
|
|
59
|
+
"ACCEPTED",
|
|
60
|
+
"AWAITINGPAYMENT",
|
|
61
|
+
"PAYMENTSCHEDULED",
|
|
62
|
+
"PAYMENTSENT",
|
|
63
|
+
"PAYMENTRECEIVED",
|
|
64
|
+
"PAYMENTCLOSED",
|
|
65
|
+
];
|
|
66
|
+
// Get all selected row IDs
|
|
67
|
+
const selectedRowIds = Object.keys(selected).filter(id => selected[id]);
|
|
68
|
+
if (selectedRowIds.length === 0)
|
|
69
|
+
return false;
|
|
70
|
+
// Check if all selected rows have allowed statuses
|
|
71
|
+
const selectedRows = state?.filter(doc => selectedRowIds.includes(doc.header.id)) || [];
|
|
72
|
+
return selectedRows.every(row => allowedStatuses.includes(row.state.global.status));
|
|
73
|
+
}, [selected, state]);
|
|
49
74
|
// Create a stable dispatcher map using useRef only (no useState to avoid re-renders)
|
|
50
75
|
const dispatchersRef = useRef(new Map());
|
|
51
76
|
// Create a working dispatch function that uses the existing reactor system
|
|
@@ -203,5 +228,5 @@ export function DriveExplorer(props) {
|
|
|
203
228
|
// console.log("dropProps", dropProps);
|
|
204
229
|
return (_jsx("div", { className: "flex h-full editor-container", children: _jsxs("div", { ...dropProps, className: twMerge("rounded-md border-2 border-transparent ", isDropTarget && "border-dashed border-blue-100"), children: [_jsx(ToastContainer, { position: "bottom-right", autoClose: 5000, hideProgressBar: false, newestOnTop: false, closeOnClick: false, rtl: false, pauseOnFocusLoss: true, draggable: true, pauseOnHover: true, theme: "light" }), _jsx("div", { className: "flex-1 p-4", children: activeDocument && documentModelModule && editorModule ? (
|
|
205
230
|
// Document editor view
|
|
206
|
-
_jsx(EditorContainer, { handleClose: () => setActiveDocumentId(undefined), activeDocumentId: activeDocumentId || "" })) : (_jsxs(_Fragment, { children: [_jsx(HeaderStats, {}), _jsx(InvoiceTable, { setActiveDocumentId: setActiveDocumentId, files: fileChildren, state: state || [], selected: selected, setSelected: setSelected, onBatchAction: () => { }, onDeleteNode: () => { }, renameNode: () => { }, filteredDocumentModels: documentModelModules, onSelectDocumentModel: onSelectDocumentModel, getDocDispatcher: getDocDispatcher, selectedStatuses: selectedStatuses, onStatusChange: handleStatusChange })] })) }), _jsx(CreateDocumentModal, { onContinue: onCreateDocument, onOpenChange: (open) => setOpenModal(open), open: openModal })] }) }));
|
|
231
|
+
_jsx(EditorContainer, { handleClose: () => setActiveDocumentId(undefined), activeDocumentId: activeDocumentId || "" })) : (_jsxs(_Fragment, { children: [_jsx(HeaderStats, {}), _jsx(InvoiceTable, { setActiveDocumentId: setActiveDocumentId, files: fileChildren, state: state || [], selected: selected, setSelected: setSelected, onBatchAction: () => { }, onDeleteNode: () => { }, renameNode: () => { }, filteredDocumentModels: documentModelModules, onSelectDocumentModel: onSelectDocumentModel, getDocDispatcher: getDocDispatcher, selectedStatuses: selectedStatuses, onStatusChange: handleStatusChange, onRowSelection: handleRowSelection, canExportSelectedRows: canExportSelectedRows })] })) }), _jsx(CreateDocumentModal, { onContinue: onCreateDocument, onOpenChange: (open) => setOpenModal(open), open: openModal })] }) }));
|
|
207
232
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/components/EditorContainer.tsx"],"names":[],"mappings":"AAiBA;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO;IACrC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,
|
|
1
|
+
{"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/components/EditorContainer.tsx"],"names":[],"mappings":"AAiBA;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO;IACrC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,4CAmGA,CAAC"}
|
|
@@ -17,7 +17,19 @@ export const EditorContainer = (props) => {
|
|
|
17
17
|
const [selectedDrive] = useSelectedDrive();
|
|
18
18
|
// Timeline data for revision history
|
|
19
19
|
const timelineItems = useTimelineItems(selectedDocument?.header.id, selectedDocument?.header.createdAtUtcIso, selectedDrive?.header.id);
|
|
20
|
-
|
|
20
|
+
// Determine the correct editor based on document type
|
|
21
|
+
const getEditorForDocumentType = (documentType) => {
|
|
22
|
+
switch (documentType) {
|
|
23
|
+
case "powerhouse/billing-statement":
|
|
24
|
+
return "powerhouse-billing-statement-editor";
|
|
25
|
+
case "powerhouse/invoice":
|
|
26
|
+
return "powerhouse-invoice-editor";
|
|
27
|
+
default:
|
|
28
|
+
return "powerhouse-invoice-editor";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const preferredEditor = selectedDocument?.header.meta?.preferredEditor ??
|
|
32
|
+
getEditorForDocumentType(selectedDocument?.header.documentType || "");
|
|
21
33
|
const editorModule = useEditorModuleById(preferredEditor);
|
|
22
34
|
// Document export functionality - customize export behavior here
|
|
23
35
|
const onExport = useCallback(async () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const HeaderControls: ({ contributorOptions, statusOptions, onContributorChange, onStatusChange, onSearchChange, onExport, onBatchAction, selectedStatuses, createIntegrationsDocument, integrationsDoc, setActiveDocumentId }: {
|
|
1
|
+
export declare const HeaderControls: ({ contributorOptions, statusOptions, onContributorChange, onStatusChange, onSearchChange, onExport, onBatchAction, selectedStatuses, createIntegrationsDocument, integrationsDoc, setActiveDocumentId, canExportSelectedRows }: {
|
|
2
2
|
contributorOptions?: {
|
|
3
3
|
label: string;
|
|
4
4
|
value: string;
|
|
@@ -16,5 +16,6 @@ export declare const HeaderControls: ({ contributorOptions, statusOptions, onCon
|
|
|
16
16
|
createIntegrationsDocument?: () => void;
|
|
17
17
|
integrationsDoc?: any | null;
|
|
18
18
|
setActiveDocumentId?: (id: string) => void;
|
|
19
|
+
canExportSelectedRows?: () => boolean;
|
|
19
20
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
20
21
|
//# sourceMappingURL=HeaderControls.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderControls.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/HeaderControls.tsx"],"names":[],"mappings":"AAcA,eAAO,MAAM,cAAc,GAAI,
|
|
1
|
+
{"version":3,"file":"HeaderControls.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/HeaderControls.tsx"],"names":[],"mappings":"AAcA,eAAO,MAAM,cAAc,GAAI,gOAa5B;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;IAC5B,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAC7B,mBAAmB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,qBAAqB,CAAC,EAAE,MAAM,OAAO,CAAC;CACvC,4CAuJA,CAAC"}
|
|
@@ -10,23 +10,14 @@ const currencyOptions = [
|
|
|
10
10
|
{ label: "GBP", value: "GBP" },
|
|
11
11
|
{ label: "JPY", value: "JPY" },
|
|
12
12
|
];
|
|
13
|
-
export const HeaderControls = ({ contributorOptions = [], statusOptions = [], onContributorChange, onStatusChange, onSearchChange, onExport, onBatchAction, selectedStatuses = [], createIntegrationsDocument, integrationsDoc, setActiveDocumentId }) => {
|
|
13
|
+
export const HeaderControls = ({ contributorOptions = [], statusOptions = [], onContributorChange, onStatusChange, onSearchChange, onExport, onBatchAction, selectedStatuses = [], createIntegrationsDocument, integrationsDoc, setActiveDocumentId, canExportSelectedRows }) => {
|
|
14
14
|
const batchOptions = [
|
|
15
15
|
{ label: "$ Pay Selected", value: "pay" },
|
|
16
16
|
{ label: "Approve Selected", value: "approve" },
|
|
17
17
|
{ label: "Reject Selected", value: "reject" },
|
|
18
18
|
];
|
|
19
|
-
//
|
|
20
|
-
const
|
|
21
|
-
"ACCEPTED",
|
|
22
|
-
"AWAITINGPAYMENT",
|
|
23
|
-
"PAYMENTSCHEDULED",
|
|
24
|
-
"PAYMENTSENT",
|
|
25
|
-
"PAYMENTRECEIVED",
|
|
26
|
-
"PAYMENTCLOSED",
|
|
27
|
-
];
|
|
28
|
-
const canExport = selectedStatuses.length > 0 &&
|
|
29
|
-
selectedStatuses.every((status) => allowedStatuses.includes(status));
|
|
19
|
+
// Use the function to determine if export should be enabled based on selected rows
|
|
20
|
+
const canExport = canExportSelectedRows ? canExportSelectedRows() : false;
|
|
30
21
|
const [showCurrencyModal, setShowCurrencyModal] = useState(false);
|
|
31
22
|
const [selectedCurrency, setSelectedCurrency] = useState("CHF");
|
|
32
23
|
return (_jsxs("div", { className: "flex flex-col gap-4 mb-4", children: [_jsxs("div", { className: "flex justify-between items-center", children: [_jsxs("div", { className: "flex gap-2 items-center", children: [_jsx(Select, { style: {
|
|
@@ -21,7 +21,9 @@ interface InvoiceTableProps {
|
|
|
21
21
|
getDocDispatcher: (id: string) => any;
|
|
22
22
|
selectedStatuses: string[];
|
|
23
23
|
onStatusChange: (value: string | string[]) => void;
|
|
24
|
+
onRowSelection: (rowId: string, checked: boolean, rowStatus: string) => void;
|
|
25
|
+
canExportSelectedRows: () => boolean;
|
|
24
26
|
}
|
|
25
|
-
export declare const InvoiceTable: ({ files, state, setActiveDocumentId, selected, setSelected, onBatchAction, onDeleteNode, renameNode, filteredDocumentModels, onSelectDocumentModel, getDocDispatcher, selectedStatuses, onStatusChange, }: InvoiceTableProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare const InvoiceTable: ({ files, state, setActiveDocumentId, selected, setSelected, onBatchAction, onDeleteNode, renameNode, filteredDocumentModels, onSelectDocumentModel, getDocDispatcher, selectedStatuses, onStatusChange, onRowSelection, canExportSelectedRows, }: InvoiceTableProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
28
|
export {};
|
|
27
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":"
|
|
1
|
+
{"version":3,"file":"InvoiceTable.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTable.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AA2B1D,UAAU,iBAAiB;IACzB,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAC7B,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,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,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,kPAgB1B,iBAAiB,4CA0nBnB,CAAC"}
|
|
@@ -3,12 +3,12 @@ import React from "react";
|
|
|
3
3
|
import { HeaderControls } from "./HeaderControls.js";
|
|
4
4
|
import { InvoiceTableSection } from "./InvoiceTableSection.js";
|
|
5
5
|
import { InvoiceTableRow } from "./InvoiceTableRow.js";
|
|
6
|
-
import { createPresignedHeader } from "document-model";
|
|
7
6
|
import { mapTags } from "../../../billing-statement/lineItemTags/tagMapping.js";
|
|
8
7
|
import { exportInvoicesToXeroCSV } from "../../../../scripts/contributor-billing/createXeroCsv.js";
|
|
9
8
|
import { toast } from "@powerhousedao/design-system";
|
|
10
9
|
import { actions, } from "../../../../document-models/invoice/index.js";
|
|
11
|
-
import { addDocument, useSelectedDrive } from "@powerhousedao/reactor-browser";
|
|
10
|
+
import { addDocument, useSelectedDrive, dispatchActions, } from "@powerhousedao/reactor-browser";
|
|
11
|
+
import { actions as billingStatementActions } from "../../../../document-models/billing-statement/index.js";
|
|
12
12
|
const statusOptions = [
|
|
13
13
|
{ label: "Draft", value: "DRAFT" },
|
|
14
14
|
{ label: "Issued", value: "ISSUED" },
|
|
@@ -20,7 +20,7 @@ const statusOptions = [
|
|
|
20
20
|
{ label: "Rejected", value: "REJECTED" },
|
|
21
21
|
{ label: "Other", value: "OTHER" },
|
|
22
22
|
];
|
|
23
|
-
export const InvoiceTable = ({ files, state, setActiveDocumentId, selected, setSelected, onBatchAction, onDeleteNode, renameNode, filteredDocumentModels, onSelectDocumentModel, getDocDispatcher, selectedStatuses, onStatusChange, }) => {
|
|
23
|
+
export const InvoiceTable = ({ files, state, setActiveDocumentId, selected, setSelected, onBatchAction, onDeleteNode, renameNode, filteredDocumentModels, onSelectDocumentModel, getDocDispatcher, selectedStatuses, onStatusChange, onRowSelection, canExportSelectedRows, }) => {
|
|
24
24
|
const [selectedDrive] = useSelectedDrive();
|
|
25
25
|
const billingDocStates = state
|
|
26
26
|
.filter((doc) => doc.header.documentType === "powerhouse/billing-statement")
|
|
@@ -105,87 +105,58 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, selected, setS
|
|
|
105
105
|
if (!invoiceState) {
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
|
-
await addDocument(selectedDrive?.header.id || "", `bill-${invoiceFile?.name}`, "powerhouse/billing-statement", undefined,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
global: {
|
|
161
|
-
contributor: id,
|
|
162
|
-
dateIssued: invoiceState.state.global.dateIssued,
|
|
163
|
-
dateDue: invoiceState.state.global.dateDue,
|
|
164
|
-
lineItems: invoiceState.state.global.lineItems.map((item) => {
|
|
165
|
-
return {
|
|
166
|
-
id: item.id,
|
|
167
|
-
description: item.description,
|
|
168
|
-
quantity: item.quantity,
|
|
169
|
-
unit: "UNIT",
|
|
170
|
-
unitPricePwt: 0,
|
|
171
|
-
unitPriceCash: item.unitPriceTaxIncl,
|
|
172
|
-
totalPricePwt: 0,
|
|
173
|
-
totalPriceCash: item.totalPriceTaxIncl,
|
|
174
|
-
lineItemTag: mapTags(item.lineItemTag || []),
|
|
175
|
-
};
|
|
176
|
-
}),
|
|
177
|
-
status: invoiceState.state.global.status,
|
|
178
|
-
currency: invoiceState.state.global.currency,
|
|
179
|
-
totalCash: invoiceState.state.global.lineItems.reduce((acc, item) => acc + item.totalPriceTaxIncl, 0),
|
|
180
|
-
totalPowt: 0,
|
|
181
|
-
notes: invoiceState.state.global.notes,
|
|
182
|
-
},
|
|
183
|
-
local: {},
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
clipboard: [],
|
|
188
|
-
}, undefined, "powerhouse-billing-statement-editor");
|
|
108
|
+
const createdNode = await addDocument(selectedDrive?.header.id || "", `bill-${invoiceFile?.name}`, "powerhouse/billing-statement", undefined, undefined, undefined, "powerhouse-billing-statement-editor");
|
|
109
|
+
console.log("created billing statement doc", createdNode);
|
|
110
|
+
if (!createdNode?.id) {
|
|
111
|
+
console.error("Failed to create billing statement");
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
await dispatchActions(billingStatementActions.editContributor({
|
|
115
|
+
contributor: id,
|
|
116
|
+
}), createdNode.id);
|
|
117
|
+
// Prepare billing statement data with empty input handlers
|
|
118
|
+
const billingStatementData = {
|
|
119
|
+
dateIssued: invoiceState.state.global.dateIssued &&
|
|
120
|
+
invoiceState.state.global.dateIssued.trim() !== ""
|
|
121
|
+
? new Date(invoiceState.state.global.dateIssued).toISOString()
|
|
122
|
+
: null,
|
|
123
|
+
dateDue: invoiceState.state.global.dateDue &&
|
|
124
|
+
invoiceState.state.global.dateDue.trim() !== ""
|
|
125
|
+
? new Date(invoiceState.state.global.dateDue).toISOString()
|
|
126
|
+
: null,
|
|
127
|
+
currency: invoiceState.state.global.currency || "",
|
|
128
|
+
notes: invoiceState.state.global.notes || "",
|
|
129
|
+
};
|
|
130
|
+
await dispatchActions(billingStatementActions.editBillingStatement(billingStatementData), createdNode.id);
|
|
131
|
+
await dispatchActions(billingStatementActions.editStatus({
|
|
132
|
+
status: invoiceState.state.global.status,
|
|
133
|
+
}), createdNode.id);
|
|
134
|
+
// add line items from invoiceState to billing statement
|
|
135
|
+
invoiceState.state.global.lineItems.forEach(async (lineItem) => {
|
|
136
|
+
await dispatchActions(billingStatementActions.addLineItem({
|
|
137
|
+
id: lineItem.id,
|
|
138
|
+
description: lineItem.description,
|
|
139
|
+
quantity: lineItem.quantity,
|
|
140
|
+
// Map invoice fields to billing statement fields
|
|
141
|
+
totalPriceCash: lineItem.totalPriceTaxIncl || 0,
|
|
142
|
+
totalPricePwt: 0, // Default to 0 since invoice doesn't have POWT pricing
|
|
143
|
+
unit: "UNIT", // Default to UNIT since invoice doesn't have unit field
|
|
144
|
+
unitPriceCash: lineItem.unitPriceTaxIncl || 0,
|
|
145
|
+
unitPricePwt: 0, // Default to 0 since invoice doesn't have POWT pricing
|
|
146
|
+
}), createdNode.id);
|
|
147
|
+
});
|
|
148
|
+
// add tags from each invoice line item to billing statement line item
|
|
149
|
+
invoiceState.state.global.lineItems.forEach(async (lineItem) => {
|
|
150
|
+
const lineItemTag = mapTags(lineItem.lineItemTag || []);
|
|
151
|
+
lineItemTag.forEach(async (tag) => {
|
|
152
|
+
await dispatchActions(billingStatementActions.editLineItemTag({
|
|
153
|
+
lineItemId: lineItem.id,
|
|
154
|
+
dimension: tag.dimension,
|
|
155
|
+
value: tag.value,
|
|
156
|
+
label: tag.label,
|
|
157
|
+
}), createdNode.id);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
189
160
|
};
|
|
190
161
|
const selectedInvoiceIds = Object.keys(selected).filter((id) => selected[id]);
|
|
191
162
|
const selectedInvoices = selectedInvoiceIds
|
|
@@ -237,32 +208,5 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, selected, setS
|
|
|
237
208
|
onSelectDocumentModel(integrationsDocument);
|
|
238
209
|
}
|
|
239
210
|
};
|
|
240
|
-
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: onStatusChange, onBatchAction: onBatchAction, onExport: handleCSVExport, selectedStatuses: selectedStatuses, createIntegrationsDocument: createIntegrationsDocument, integrationsDoc: integrationsDoc, setActiveDocumentId: setActiveDocumentId }), 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) => ({
|
|
241
|
-
...prev,
|
|
242
|
-
[row.id]: checked,
|
|
243
|
-
})), 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) => ({
|
|
244
|
-
...prev,
|
|
245
|
-
[row.id]: checked,
|
|
246
|
-
})), 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-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: accepted.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
|
|
247
|
-
...prev,
|
|
248
|
-
[row.id]: checked,
|
|
249
|
-
})), 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-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: paymentScheduled.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
|
|
250
|
-
...prev,
|
|
251
|
-
[row.id]: checked,
|
|
252
|
-
})), 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-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: paymentSent.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
|
|
253
|
-
...prev,
|
|
254
|
-
[row.id]: checked,
|
|
255
|
-
})), 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-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: paymentIssue.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
|
|
256
|
-
...prev,
|
|
257
|
-
[row.id]: checked,
|
|
258
|
-
})), 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-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: paymentClosed.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
|
|
259
|
-
...prev,
|
|
260
|
-
[row.id]: checked,
|
|
261
|
-
})), 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-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: rejected.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
|
|
262
|
-
...prev,
|
|
263
|
-
[row.id]: checked,
|
|
264
|
-
})), 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) => ({
|
|
265
|
-
...prev,
|
|
266
|
-
[row.id]: checked,
|
|
267
|
-
})), setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode }, row.id))) })] }) }))] }, `${state.length}`));
|
|
211
|
+
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: onStatusChange, onBatchAction: onBatchAction, onExport: handleCSVExport, selectedStatuses: selectedStatuses, createIntegrationsDocument: createIntegrationsDocument, integrationsDoc: integrationsDoc, setActiveDocumentId: setActiveDocumentId, canExportSelectedRows: canExportSelectedRows }), 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) => onRowSelection(row.id, checked, row.status), 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) => onRowSelection(row.id, checked, row.status), 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-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: accepted.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => onRowSelection(row.id, checked, row.status), 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-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: paymentScheduled.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => onRowSelection(row.id, checked, row.status), 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-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: paymentSent.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => onRowSelection(row.id, checked, row.status), 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-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: paymentIssue.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => onRowSelection(row.id, checked, row.status), 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-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: paymentClosed.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => onRowSelection(row.id, checked, row.status), 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-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: rejected.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => onRowSelection(row.id, checked, row.status), 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) => onRowSelection(row.id, checked, row.status), setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode }, row.id))) })] }) }))] }, `${state.length}`));
|
|
268
212
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvoiceTableRow.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,eAAe,GAAI,kIAU7B;IACD,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;IACd,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,wBAAwB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,gBAAgB,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC1D,
|
|
1
|
+
{"version":3,"file":"InvoiceTableRow.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,eAAe,GAAI,kIAU7B;IACD,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;IACd,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,wBAAwB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,gBAAgB,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC1D,4CAgLA,CAAC"}
|
|
@@ -7,25 +7,35 @@ export const InvoiceTableRow = ({ files, row, isSelected, onSelect, setActiveDoc
|
|
|
7
7
|
const menuRef = useRef(null);
|
|
8
8
|
const formatTimestamp = (timestamp) => {
|
|
9
9
|
const date = new Date(timestamp);
|
|
10
|
-
const day = date.getDate().toString().padStart(2,
|
|
10
|
+
const day = date.getDate().toString().padStart(2, "0");
|
|
11
11
|
// Use ISO short month names (Jan, Feb, etc.)
|
|
12
12
|
const monthNames = [
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
"Jan",
|
|
14
|
+
"Feb",
|
|
15
|
+
"Mar",
|
|
16
|
+
"Apr",
|
|
17
|
+
"May",
|
|
18
|
+
"Jun",
|
|
19
|
+
"Jul",
|
|
20
|
+
"Aug",
|
|
21
|
+
"Sep",
|
|
22
|
+
"Oct",
|
|
23
|
+
"Nov",
|
|
24
|
+
"Dec",
|
|
15
25
|
];
|
|
16
26
|
const month = monthNames[date.getMonth()];
|
|
17
27
|
const year = date.getFullYear();
|
|
18
|
-
const hours = date.getHours().toString().padStart(2,
|
|
19
|
-
const minutes = date.getMinutes().toString().padStart(2,
|
|
28
|
+
const hours = date.getHours().toString().padStart(2, "0");
|
|
29
|
+
const minutes = date.getMinutes().toString().padStart(2, "0");
|
|
20
30
|
return `${day}-${month}-${year} ${hours}:${minutes}`;
|
|
21
31
|
};
|
|
22
32
|
const formatAmount = (amount) => {
|
|
23
|
-
const numAmount = typeof amount ===
|
|
33
|
+
const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
|
|
24
34
|
if (isNaN(numAmount))
|
|
25
|
-
return
|
|
26
|
-
return numAmount.toLocaleString(
|
|
35
|
+
return "0.00";
|
|
36
|
+
return numAmount.toLocaleString("en-US", {
|
|
27
37
|
minimumFractionDigits: 2,
|
|
28
|
-
maximumFractionDigits: 2
|
|
38
|
+
maximumFractionDigits: 2,
|
|
29
39
|
});
|
|
30
40
|
};
|
|
31
41
|
const billingDoc = billingDocStates?.find((doc) => doc.contributor === row.id);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { Node } from "document-drive";
|
|
2
|
-
|
|
3
|
-
export declare function useTransformedNodes(nodes: Node[], driveId: string): (UiFileNode | UiFolderNode)[];
|
|
2
|
+
export declare function useTransformedNodes(nodes: Node[], driveId: string): any[];
|
|
4
3
|
//# sourceMappingURL=useTransformedNodes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransformedNodes.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/hooks/useTransformedNodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"useTransformedNodes.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/hooks/useTransformedNodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,gBAAgB,CAAC;AAGrD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,SA8BjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestFinance.d.ts","sourceRoot":"","sources":["../../../editors/invoice/requestFinance.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAUxC,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,GAAG,CAAC;CACf;AAED,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"requestFinance.d.ts","sourceRoot":"","sources":["../../../editors/invoice/requestFinance.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAUxC,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,GAAG,CAAC;CACf;AAED,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAuRjD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -118,6 +118,7 @@ const RequestFinance = ({ docState, dispatch, }) => {
|
|
|
118
118
|
streetAddress: docState.payer.address.streetAddress,
|
|
119
119
|
extendedAddress: docState.payer.address.extendedAddress,
|
|
120
120
|
postalCode: docState.payer.address.postalCode,
|
|
121
|
+
region: docState.payer.address.stateProvince || "",
|
|
121
122
|
},
|
|
122
123
|
},
|
|
123
124
|
sellerInfo: {
|
|
@@ -130,6 +131,7 @@ const RequestFinance = ({ docState, dispatch, }) => {
|
|
|
130
131
|
streetAddress: docState.issuer.address.streetAddress,
|
|
131
132
|
extendedAddress: docState.issuer.address.extendedAddress,
|
|
132
133
|
postalCode: docState.issuer.address.postalCode,
|
|
134
|
+
region: docState.issuer.address.stateProvince || "",
|
|
133
135
|
},
|
|
134
136
|
},
|
|
135
137
|
paymentOptions: [
|
|
@@ -0,0 +1,8 @@
|
|
|
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 type { InvoiceGeneralOperations } from "../../gen/general/operations.js";
|
|
7
|
+
export declare const reducer: InvoiceGeneralOperations;
|
|
8
|
+
//# sourceMappingURL=general.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../reducers/general.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAEhF,eAAO,MAAM,OAAO,EAAE,wBAkErB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
export const reducer = {
|
|
7
|
+
editInvoiceOperation(state, action, dispatch) {
|
|
8
|
+
try {
|
|
9
|
+
const newState = { ...state };
|
|
10
|
+
newState.currency = action.input.currency ?? state.currency;
|
|
11
|
+
newState.dateDue = action.input.dateDue ?? state.dateDue;
|
|
12
|
+
newState.dateIssued = action.input.dateIssued ?? state.dateIssued;
|
|
13
|
+
newState.invoiceNo = action.input.invoiceNo ?? state.invoiceNo;
|
|
14
|
+
newState.notes = action.input.notes ?? state.notes;
|
|
15
|
+
state = Object.assign(state, newState);
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
console.error(e);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
editStatusOperation(state, action, dispatch) {
|
|
22
|
+
try {
|
|
23
|
+
state.status = action.input.status;
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
console.error(e);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
editPaymentDataOperation(state, action, dispatch) {
|
|
30
|
+
try {
|
|
31
|
+
const payment = state.payments.find((payment) => payment.id === action.input.id);
|
|
32
|
+
if (payment) {
|
|
33
|
+
payment.processorRef = action.input.processorRef ?? payment.processorRef;
|
|
34
|
+
payment.paymentDate = action.input.paymentDate ?? payment.paymentDate;
|
|
35
|
+
payment.txnRef = action.input.txnRef ?? payment.txnRef;
|
|
36
|
+
payment.confirmed = action.input.confirmed ?? payment.confirmed;
|
|
37
|
+
payment.issue = action.input.issue ?? payment.issue;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
console.error(e);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
addPaymentOperation(state, action, dispatch) {
|
|
45
|
+
try {
|
|
46
|
+
const payment = {
|
|
47
|
+
id: action.input.id,
|
|
48
|
+
processorRef: action.input.processorRef ?? "",
|
|
49
|
+
paymentDate: action.input.paymentDate ?? "",
|
|
50
|
+
txnRef: action.input.txnRef ?? "",
|
|
51
|
+
confirmed: action.input.confirmed ?? false,
|
|
52
|
+
issue: action.input.issue ?? "",
|
|
53
|
+
amount: 0,
|
|
54
|
+
};
|
|
55
|
+
state.payments.push(payment);
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
console.error(e);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
setExportedDataOperation(state, action, dispatch) {
|
|
62
|
+
try {
|
|
63
|
+
const exportedData = {
|
|
64
|
+
timestamp: action.input.timestamp,
|
|
65
|
+
exportedLineItems: action.input.exportedLineItems,
|
|
66
|
+
};
|
|
67
|
+
state.exported = exportedData;
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
console.error(e);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
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 type { InvoiceItemsOperations } from "../../gen/items/operations.js";
|
|
7
|
+
export declare const reducer: InvoiceItemsOperations;
|
|
8
|
+
//# sourceMappingURL=items.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../reducers/items.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAG5E,eAAO,MAAM,OAAO,EAAE,sBA6GrB,CAAC"}
|