@powerhousedao/contributor-billing 0.0.1
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/LICENSE +661 -0
- package/README.md +22 -0
- package/dist/document-models/index.d.ts +2 -0
- package/dist/document-models/index.d.ts.map +1 -0
- package/dist/document-models/index.js +1 -0
- package/dist/document-models/invoice/gen/actions.d.ts +8 -0
- package/dist/document-models/invoice/gen/actions.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/actions.js +3 -0
- package/dist/document-models/invoice/gen/creators.d.ts +4 -0
- package/dist/document-models/invoice/gen/creators.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/creators.js +3 -0
- package/dist/document-models/invoice/gen/document-model.d.ts +3 -0
- package/dist/document-models/invoice/gen/document-model.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/document-model.js +227 -0
- package/dist/document-models/invoice/gen/general/actions.d.ts +10 -0
- package/dist/document-models/invoice/gen/general/actions.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/general/actions.js +1 -0
- package/dist/document-models/invoice/gen/general/creators.d.ts +9 -0
- package/dist/document-models/invoice/gen/general/creators.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/general/creators.js +8 -0
- package/dist/document-models/invoice/gen/general/error.d.ts +2 -0
- package/dist/document-models/invoice/gen/general/error.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/general/error.js +1 -0
- package/dist/document-models/invoice/gen/general/object.d.ts +12 -0
- package/dist/document-models/invoice/gen/general/object.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/general/object.js +22 -0
- package/dist/document-models/invoice/gen/general/operations.d.ts +12 -0
- package/dist/document-models/invoice/gen/general/operations.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/general/operations.js +1 -0
- package/dist/document-models/invoice/gen/index.d.ts +6 -0
- package/dist/document-models/invoice/gen/index.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/index.js +5 -0
- package/dist/document-models/invoice/gen/items/actions.d.ts +8 -0
- package/dist/document-models/invoice/gen/items/actions.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/items/actions.js +1 -0
- package/dist/document-models/invoice/gen/items/creators.d.ts +7 -0
- package/dist/document-models/invoice/gen/items/creators.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/items/creators.js +6 -0
- package/dist/document-models/invoice/gen/items/error.d.ts +2 -0
- package/dist/document-models/invoice/gen/items/error.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/items/error.js +1 -0
- package/dist/document-models/invoice/gen/items/object.d.ts +10 -0
- package/dist/document-models/invoice/gen/items/object.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/items/object.js +16 -0
- package/dist/document-models/invoice/gen/items/operations.d.ts +10 -0
- package/dist/document-models/invoice/gen/items/operations.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/items/operations.js +1 -0
- package/dist/document-models/invoice/gen/object.d.ts +20 -0
- package/dist/document-models/invoice/gen/object.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/object.js +29 -0
- package/dist/document-models/invoice/gen/parties/actions.d.ts +10 -0
- package/dist/document-models/invoice/gen/parties/actions.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/parties/actions.js +1 -0
- package/dist/document-models/invoice/gen/parties/creators.d.ts +9 -0
- package/dist/document-models/invoice/gen/parties/creators.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/parties/creators.js +8 -0
- package/dist/document-models/invoice/gen/parties/error.d.ts +2 -0
- package/dist/document-models/invoice/gen/parties/error.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/parties/error.js +1 -0
- package/dist/document-models/invoice/gen/parties/object.d.ts +12 -0
- package/dist/document-models/invoice/gen/parties/object.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/parties/object.js +22 -0
- package/dist/document-models/invoice/gen/parties/operations.d.ts +12 -0
- package/dist/document-models/invoice/gen/parties/operations.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/parties/operations.js +1 -0
- package/dist/document-models/invoice/gen/reducer.d.ts +3 -0
- package/dist/document-models/invoice/gen/reducer.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/reducer.js +79 -0
- package/dist/document-models/invoice/gen/schema/index.d.ts +3 -0
- package/dist/document-models/invoice/gen/schema/index.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/schema/index.js +2 -0
- package/dist/document-models/invoice/gen/schema/types.d.ts +390 -0
- package/dist/document-models/invoice/gen/schema/types.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/schema/types.js +1 -0
- package/dist/document-models/invoice/gen/schema/zod.d.ts +56 -0
- package/dist/document-models/invoice/gen/schema/zod.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/schema/zod.js +362 -0
- package/dist/document-models/invoice/gen/types.d.ts +10 -0
- package/dist/document-models/invoice/gen/types.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/types.js +1 -0
- package/dist/document-models/invoice/gen/utils.d.ts +7 -0
- package/dist/document-models/invoice/gen/utils.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/utils.js +166 -0
- package/dist/document-models/invoice/index.d.ts +41 -0
- package/dist/document-models/invoice/index.d.ts.map +1 -0
- package/dist/document-models/invoice/index.js +21 -0
- package/dist/document-models/invoice/src/reducers/general.d.ts +8 -0
- package/dist/document-models/invoice/src/reducers/general.d.ts.map +1 -0
- package/dist/document-models/invoice/src/reducers/general.js +79 -0
- package/dist/document-models/invoice/src/reducers/items.d.ts +8 -0
- package/dist/document-models/invoice/src/reducers/items.d.ts.map +1 -0
- package/dist/document-models/invoice/src/reducers/items.js +108 -0
- package/dist/document-models/invoice/src/reducers/parties.d.ts +8 -0
- package/dist/document-models/invoice/src/reducers/parties.d.ts.map +1 -0
- package/dist/document-models/invoice/src/reducers/parties.js +266 -0
- package/dist/document-models/invoice/src/tests/document-model.test.d.ts +6 -0
- package/dist/document-models/invoice/src/tests/document-model.test.d.ts.map +1 -0
- package/dist/document-models/invoice/src/tests/document-model.test.js +17 -0
- package/dist/document-models/invoice/src/tests/general.test.d.ts +6 -0
- package/dist/document-models/invoice/src/tests/general.test.d.ts.map +1 -0
- package/dist/document-models/invoice/src/tests/general.test.js +75 -0
- package/dist/document-models/invoice/src/tests/items.test.d.ts +6 -0
- package/dist/document-models/invoice/src/tests/items.test.d.ts.map +1 -0
- package/dist/document-models/invoice/src/tests/items.test.js +45 -0
- package/dist/document-models/invoice/src/tests/parties.test.d.ts +6 -0
- package/dist/document-models/invoice/src/tests/parties.test.d.ts.map +1 -0
- package/dist/document-models/invoice/src/tests/parties.test.js +75 -0
- package/dist/document-models/invoice/src/utils.d.ts +2 -0
- package/dist/document-models/invoice/src/utils.d.ts.map +1 -0
- package/dist/document-models/invoice/src/utils.js +1 -0
- package/dist/editors/contributor-billing/components/CreateDocument.d.ts +8 -0
- package/dist/editors/contributor-billing/components/CreateDocument.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/CreateDocument.js +14 -0
- package/dist/editors/contributor-billing/components/DocumentDispatch.d.ts +12 -0
- package/dist/editors/contributor-billing/components/DocumentDispatch.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/DocumentDispatch.js +20 -0
- package/dist/editors/contributor-billing/components/DriveExplorer.d.ts +17 -0
- package/dist/editors/contributor-billing/components/DriveExplorer.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/DriveExplorer.js +112 -0
- package/dist/editors/contributor-billing/components/EditorContainer.d.ts +14 -0
- package/dist/editors/contributor-billing/components/EditorContainer.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/EditorContainer.js +28 -0
- package/dist/editors/contributor-billing/components/FileItemsGrid.d.ts +12 -0
- package/dist/editors/contributor-billing/components/FileItemsGrid.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/FileItemsGrid.js +7 -0
- package/dist/editors/contributor-billing/components/FolderItemsGrid.d.ts +17 -0
- package/dist/editors/contributor-billing/components/FolderItemsGrid.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/FolderItemsGrid.js +14 -0
- package/dist/editors/contributor-billing/components/FolderTree.d.ts +9 -0
- package/dist/editors/contributor-billing/components/FolderTree.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/FolderTree.js +31 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts +16 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.js +16 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts +21 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.js +45 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts +12 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.js +12 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableSection.d.ts +7 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableSection.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableSection.js +7 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.d.ts +8 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.js +2 -0
- package/dist/editors/contributor-billing/editor.d.ts +6 -0
- package/dist/editors/contributor-billing/editor.d.ts.map +1 -0
- package/dist/editors/contributor-billing/editor.js +48 -0
- package/dist/editors/contributor-billing/hooks/useDispatchMap.d.ts +9 -0
- package/dist/editors/contributor-billing/hooks/useDispatchMap.d.ts.map +1 -0
- package/dist/editors/contributor-billing/hooks/useDispatchMap.js +21 -0
- package/dist/editors/contributor-billing/hooks/useDrop.d.ts +22 -0
- package/dist/editors/contributor-billing/hooks/useDrop.d.ts.map +1 -0
- package/dist/editors/contributor-billing/hooks/useDrop.js +57 -0
- package/dist/editors/contributor-billing/hooks/useSelectedFolderChildren.d.ts +8 -0
- package/dist/editors/contributor-billing/hooks/useSelectedFolderChildren.d.ts.map +1 -0
- package/dist/editors/contributor-billing/hooks/useSelectedFolderChildren.js +19 -0
- package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts +4 -0
- package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts.map +1 -0
- package/dist/editors/contributor-billing/hooks/useTransformedNodes.js +32 -0
- package/dist/editors/contributor-billing/index.d.ts +5 -0
- package/dist/editors/contributor-billing/index.d.ts.map +1 -0
- package/dist/editors/contributor-billing/index.js +12 -0
- package/dist/editors/index.d.ts +3 -0
- package/dist/editors/index.d.ts.map +1 -0
- package/dist/editors/index.js +2 -0
- package/dist/editors/invoice/InvoicePDF.d.ts +8 -0
- package/dist/editors/invoice/InvoicePDF.d.ts.map +1 -0
- package/dist/editors/invoice/InvoicePDF.js +359 -0
- package/dist/editors/invoice/assets/custom.d.ts +4 -0
- package/dist/editors/invoice/assets/powerhouseLogo.png +0 -0
- package/dist/editors/invoice/components/countryForm.d.ts +12 -0
- package/dist/editors/invoice/components/countryForm.d.ts.map +1 -0
- package/dist/editors/invoice/components/countryForm.js +28 -0
- package/dist/editors/invoice/components/currencyForm.d.ts +13 -0
- package/dist/editors/invoice/components/currencyForm.d.ts.map +1 -0
- package/dist/editors/invoice/components/currencyForm.js +26 -0
- package/dist/editors/invoice/components/datePicker.d.ts +11 -0
- package/dist/editors/invoice/components/datePicker.d.ts.map +1 -0
- package/dist/editors/invoice/components/datePicker.js +8 -0
- package/dist/editors/invoice/components/inputField.d.ts +14 -0
- package/dist/editors/invoice/components/inputField.d.ts.map +1 -0
- package/dist/editors/invoice/components/inputField.js +25 -0
- package/dist/editors/invoice/components/numberForm.d.ts +11 -0
- package/dist/editors/invoice/components/numberForm.d.ts.map +1 -0
- package/dist/editors/invoice/components/numberForm.js +7 -0
- package/dist/editors/invoice/components/selectField.d.ts +8 -0
- package/dist/editors/invoice/components/selectField.d.ts.map +1 -0
- package/dist/editors/invoice/components/selectField.js +323 -0
- package/dist/editors/invoice/editor.d.ts +5 -0
- package/dist/editors/invoice/editor.d.ts.map +1 -0
- package/dist/editors/invoice/editor.js +377 -0
- package/dist/editors/invoice/exportUBL.d.ts +85 -0
- package/dist/editors/invoice/exportUBL.d.ts.map +1 -0
- package/dist/editors/invoice/exportUBL.js +382 -0
- package/dist/editors/invoice/index.d.ts +5 -0
- package/dist/editors/invoice/index.d.ts.map +1 -0
- package/dist/editors/invoice/index.js +12 -0
- package/dist/editors/invoice/ingestPDF.d.ts +12 -0
- package/dist/editors/invoice/ingestPDF.d.ts.map +1 -0
- package/dist/editors/invoice/ingestPDF.js +193 -0
- package/dist/editors/invoice/ingestUBL.d.ts +21 -0
- package/dist/editors/invoice/ingestUBL.d.ts.map +1 -0
- package/dist/editors/invoice/ingestUBL.js +169 -0
- package/dist/editors/invoice/invoiceToGnosis.d.ts +7 -0
- package/dist/editors/invoice/invoiceToGnosis.d.ts.map +1 -0
- package/dist/editors/invoice/invoiceToGnosis.js +139 -0
- package/dist/editors/invoice/legalEntity/bankSection.d.ts +14 -0
- package/dist/editors/invoice/legalEntity/bankSection.d.ts.map +1 -0
- package/dist/editors/invoice/legalEntity/bankSection.js +156 -0
- package/dist/editors/invoice/legalEntity/common.d.ts +6 -0
- package/dist/editors/invoice/legalEntity/common.d.ts.map +1 -0
- package/dist/editors/invoice/legalEntity/common.js +6 -0
- package/dist/editors/invoice/legalEntity/legalEntity.d.ts +40 -0
- package/dist/editors/invoice/legalEntity/legalEntity.d.ts.map +1 -0
- package/dist/editors/invoice/legalEntity/legalEntity.js +63 -0
- package/dist/editors/invoice/legalEntity/walletSection.d.ts +13 -0
- package/dist/editors/invoice/legalEntity/walletSection.d.ts.map +1 -0
- package/dist/editors/invoice/legalEntity/walletSection.js +55 -0
- package/dist/editors/invoice/lineItems.d.ts +23 -0
- package/dist/editors/invoice/lineItems.d.ts.map +1 -0
- package/dist/editors/invoice/lineItems.js +157 -0
- package/dist/editors/invoice/requestFinance.d.ts +7 -0
- package/dist/editors/invoice/requestFinance.d.ts.map +1 -0
- package/dist/editors/invoice/requestFinance.js +155 -0
- package/dist/editors/invoice/uploadPdfChunked.d.ts +10 -0
- package/dist/editors/invoice/uploadPdfChunked.d.ts.map +1 -0
- package/dist/editors/invoice/uploadPdfChunked.js +79 -0
- package/dist/editors/invoice/utils/utils.d.ts +2 -0
- package/dist/editors/invoice/utils/utils.d.ts.map +1 -0
- package/dist/editors/invoice/utils/utils.js +54 -0
- package/dist/editors/invoice/validation/validationManager.d.ts +28 -0
- package/dist/editors/invoice/validation/validationManager.d.ts.map +1 -0
- package/dist/editors/invoice/validation/validationManager.js +65 -0
- package/dist/editors/invoice/validation/validationRules.d.ts +14 -0
- package/dist/editors/invoice/validation/validationRules.d.ts.map +1 -0
- package/dist/editors/invoice/validation/validationRules.js +334 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/powerhouse.manifest.json +31 -0
- package/dist/processors/index.d.ts +2 -0
- package/dist/processors/index.d.ts.map +1 -0
- package/dist/processors/index.js +1 -0
- package/dist/scripts/invoice/exampleBatchTxn.d.ts +2 -0
- package/dist/scripts/invoice/exampleBatchTxn.d.ts.map +1 -0
- package/dist/scripts/invoice/exampleBatchTxn.js +44 -0
- package/dist/scripts/invoice/gnosisTransactionBuilder.d.ts +28 -0
- package/dist/scripts/invoice/gnosisTransactionBuilder.d.ts.map +1 -0
- package/dist/scripts/invoice/gnosisTransactionBuilder.js +74 -0
- package/dist/scripts/invoice/pdfToDocumentAi.d.ts +5 -0
- package/dist/scripts/invoice/pdfToDocumentAi.d.ts.map +1 -0
- package/dist/scripts/invoice/pdfToDocumentAi.js +659 -0
- package/dist/scripts/invoice/requestFinance.d.ts +2 -0
- package/dist/scripts/invoice/requestFinance.d.ts.map +1 -0
- package/dist/scripts/invoice/requestFinance.js +38 -0
- package/dist/style.css +6463 -0
- package/dist/subgraphs/index.d.ts +2 -0
- package/dist/subgraphs/index.d.ts.map +1 -0
- package/dist/subgraphs/index.js +1 -0
- package/dist/subgraphs/invoice/customResolvers.d.ts +50 -0
- package/dist/subgraphs/invoice/customResolvers.d.ts.map +1 -0
- package/dist/subgraphs/invoice/customResolvers.js +327 -0
- package/dist/subgraphs/invoice/index.d.ts +10 -0
- package/dist/subgraphs/invoice/index.d.ts.map +1 -0
- package/dist/subgraphs/invoice/index.js +30 -0
- package/dist/subgraphs/invoice/resolvers.d.ts +3 -0
- package/dist/subgraphs/invoice/resolvers.d.ts.map +1 -0
- package/dist/subgraphs/invoice/resolvers.js +184 -0
- package/dist/subgraphs/invoice/schema.d.ts +3 -0
- package/dist/subgraphs/invoice/schema.d.ts.map +1 -0
- package/dist/subgraphs/invoice/schema.js +460 -0
- package/dist/tailwind.config.d.ts +13 -0
- package/dist/tailwind.config.d.ts.map +1 -0
- package/dist/tailwind.config.js +15 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/vitest.config.js +8 -0
- package/editors/invoice/assets/custom.d.ts +4 -0
- package/editors/invoice/assets/powerhouseLogo.png +0 -0
- package/package.json +117 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { actions, } from "../../document-models/invoice/index.js";
|
|
4
|
+
import { LegalEntityForm } from "./legalEntity/legalEntity.js";
|
|
5
|
+
import { LineItemsTable } from "./lineItems.js";
|
|
6
|
+
import { loadUBLFile } from "./ingestUBL.js";
|
|
7
|
+
import PDFUploader from "./ingestPDF.js";
|
|
8
|
+
import RequestFinance from "./requestFinance.js";
|
|
9
|
+
import InvoiceToGnosis from "./invoiceToGnosis.js";
|
|
10
|
+
import { toast, ToastContainer } from "@powerhousedao/design-system";
|
|
11
|
+
import { PDFDownloadLink } from "@react-pdf/renderer";
|
|
12
|
+
import { InvoicePDF } from "./InvoicePDF.js";
|
|
13
|
+
import { createRoot } from "react-dom/client";
|
|
14
|
+
import { downloadUBL } from "./exportUBL.js";
|
|
15
|
+
import { CurrencyForm, currencyList } from "./components/currencyForm.js";
|
|
16
|
+
import { InputField } from "./components/inputField.js";
|
|
17
|
+
import { validateField, } from "./validation/validationManager.js";
|
|
18
|
+
import { DatePicker } from "./components/datePicker.js";
|
|
19
|
+
import { SelectField } from "./components/selectField.js";
|
|
20
|
+
// Helper function to format numbers with appropriate decimal places
|
|
21
|
+
function formatNumber(value) {
|
|
22
|
+
// Check if the value has decimal places
|
|
23
|
+
const hasDecimals = value % 1 !== 0;
|
|
24
|
+
// If no decimals or only trailing zeros after 2 decimal places, show 2 decimal places
|
|
25
|
+
if (!hasDecimals || value.toFixed(5).endsWith("000")) {
|
|
26
|
+
return value.toFixed(2);
|
|
27
|
+
}
|
|
28
|
+
// Otherwise, show actual decimal places up to 5
|
|
29
|
+
const stringValue = value.toString();
|
|
30
|
+
const decimalPart = stringValue.split(".")[1] || "";
|
|
31
|
+
// Determine how many decimal places to show (up to 5)
|
|
32
|
+
const decimalPlaces = Math.min(Math.max(2, decimalPart.length), 5);
|
|
33
|
+
return value.toFixed(decimalPlaces);
|
|
34
|
+
}
|
|
35
|
+
function isFiatCurrency(currency) {
|
|
36
|
+
return currencyList.find((c) => c.ticker === currency)?.crypto === false;
|
|
37
|
+
}
|
|
38
|
+
export default function Editor(props) {
|
|
39
|
+
const { document: doc, dispatch } = props;
|
|
40
|
+
const state = doc.state.global;
|
|
41
|
+
const [fiatMode, setFiatMode] = useState(isFiatCurrency(state.currency));
|
|
42
|
+
const [uploadDropdownOpen, setUploadDropdownOpen] = useState(false);
|
|
43
|
+
const [exportDropdownOpen, setExportDropdownOpen] = useState(false);
|
|
44
|
+
const [invoiceNoInput, setInvoiceNoInput] = useState(state.invoiceNo || "");
|
|
45
|
+
const uploadDropdownRef = useRef(null);
|
|
46
|
+
const exportDropdownRef = useRef(null);
|
|
47
|
+
const [isPdfLoading, setIsPdfLoading] = useState(false);
|
|
48
|
+
// Validation state
|
|
49
|
+
const [invoiceValidation, setInvoiceValidation] = useState(null);
|
|
50
|
+
const [walletValidation, setWalletValidation] = useState(null);
|
|
51
|
+
const [currencyValidation, setCurrencyValidation] = useState(null);
|
|
52
|
+
const [countryValidation, setCountryValidation] = useState(null);
|
|
53
|
+
const [ibanValidation, setIbanValidation] = useState(null);
|
|
54
|
+
const [bicValidation, setBicValidation] = useState(null);
|
|
55
|
+
const [bankNameValidation, setBankNameValidation] = useState(null);
|
|
56
|
+
const [streetAddressValidation, setStreetAddressValidation] = useState(null);
|
|
57
|
+
const [cityValidation, setCityValidation] = useState(null);
|
|
58
|
+
const [postalCodeValidation, setPostalCodeValidation] = useState(null);
|
|
59
|
+
const [payerEmailValidation, setPayerEmailValidation] = useState(null);
|
|
60
|
+
const [lineItemValidation, setLineItemValidation] = useState(null);
|
|
61
|
+
const prevStatus = useRef(state.status);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
setFiatMode(isFiatCurrency(state.currency));
|
|
64
|
+
}, [state.currency, state]);
|
|
65
|
+
// Add click outside listener to close dropdowns
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
function handleClickOutside(event) {
|
|
68
|
+
if (uploadDropdownRef.current &&
|
|
69
|
+
!uploadDropdownRef.current.contains(event.target)) {
|
|
70
|
+
setUploadDropdownOpen(false);
|
|
71
|
+
}
|
|
72
|
+
if (exportDropdownRef.current &&
|
|
73
|
+
!exportDropdownRef.current.contains(event.target)) {
|
|
74
|
+
setExportDropdownOpen(false);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
78
|
+
return () => {
|
|
79
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
80
|
+
};
|
|
81
|
+
}, []);
|
|
82
|
+
const itemsTotalTaxExcl = useMemo(() => {
|
|
83
|
+
return state.lineItems.reduce((total, lineItem) => {
|
|
84
|
+
return total + lineItem.quantity * lineItem.unitPriceTaxExcl;
|
|
85
|
+
}, 0.0);
|
|
86
|
+
}, [state.lineItems]);
|
|
87
|
+
const itemsTotalTaxIncl = useMemo(() => {
|
|
88
|
+
return state.lineItems.reduce((total, lineItem) => {
|
|
89
|
+
return total + lineItem.quantity * lineItem.unitPriceTaxIncl;
|
|
90
|
+
}, 0.0);
|
|
91
|
+
}, [state.lineItems]);
|
|
92
|
+
const STATUS_OPTIONS = [
|
|
93
|
+
"DRAFT",
|
|
94
|
+
"ISSUED",
|
|
95
|
+
"CANCELLED",
|
|
96
|
+
"ACCEPTED",
|
|
97
|
+
"REJECTED",
|
|
98
|
+
"AWAITINGPAYMENT",
|
|
99
|
+
"PAYMENTSCHEDULED",
|
|
100
|
+
"PAYMENTSENT",
|
|
101
|
+
"PAYMENTISSUE",
|
|
102
|
+
"PAYMENTRECEIVED",
|
|
103
|
+
];
|
|
104
|
+
const handleFileUpload = async (event) => {
|
|
105
|
+
const file = event.target.files?.[0];
|
|
106
|
+
if (!file)
|
|
107
|
+
return;
|
|
108
|
+
try {
|
|
109
|
+
await loadUBLFile({ file, dispatch });
|
|
110
|
+
toast("UBL file uploaded successfully", {
|
|
111
|
+
type: "success",
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
// Handle error presentation to user
|
|
116
|
+
console.error("Failed to load UBL file:", error);
|
|
117
|
+
toast("Failed to load UBL file", {
|
|
118
|
+
type: "error",
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const handleExportPDF = () => {
|
|
123
|
+
// Create a temporary container for the PDFDownloadLink
|
|
124
|
+
const container = window.document.createElement("div");
|
|
125
|
+
container.style.display = "none";
|
|
126
|
+
window.document.body.appendChild(container);
|
|
127
|
+
// Create root for React 18
|
|
128
|
+
const root = createRoot(container);
|
|
129
|
+
// Render the PDFDownloadLink
|
|
130
|
+
const cleanup = () => {
|
|
131
|
+
root.unmount();
|
|
132
|
+
window.document.body.removeChild(container);
|
|
133
|
+
};
|
|
134
|
+
try {
|
|
135
|
+
root.render(_jsx(PDFDownloadLink, { document: _jsx(InvoicePDF, { invoice: state, fiatMode: fiatMode }), fileName: `invoice-${state.invoiceNo || "export"}.pdf`, className: "hidden", children: ({ blob, url, loading, error }) => {
|
|
136
|
+
if (loading) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
if (error) {
|
|
140
|
+
cleanup();
|
|
141
|
+
toast("Failed to export PDF", { type: "error" });
|
|
142
|
+
console.error("PDF generation error:", error);
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
if (url && blob) {
|
|
146
|
+
// Create a direct download link
|
|
147
|
+
const downloadLink = window.document.createElement("a");
|
|
148
|
+
downloadLink.href = url;
|
|
149
|
+
downloadLink.download = `invoice-${state.invoiceNo || "export"}.pdf`;
|
|
150
|
+
window.document.body.appendChild(downloadLink);
|
|
151
|
+
downloadLink.click();
|
|
152
|
+
window.document.body.removeChild(downloadLink);
|
|
153
|
+
// Cleanup after ensuring download has started
|
|
154
|
+
setTimeout(cleanup, 100);
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
} }));
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
console.error("Error exporting PDF:", error);
|
|
161
|
+
cleanup();
|
|
162
|
+
toast("Failed to export PDF", { type: "error" });
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
async function handleExportUBL() {
|
|
166
|
+
try {
|
|
167
|
+
// Generate a PDF blob first
|
|
168
|
+
const pdfBlob = await generatePDFBlob();
|
|
169
|
+
// Generate filename based on invoice number
|
|
170
|
+
const filename = `invoice_${state.invoiceNo || "export"}.xml`;
|
|
171
|
+
return await downloadUBL({
|
|
172
|
+
invoice: state,
|
|
173
|
+
filename,
|
|
174
|
+
pdfBlob, // Pass the PDF blob to be embedded in the UBL file
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
console.error("Error exporting to UBL:", error);
|
|
179
|
+
toast("Failed to export UBL", { type: "error" });
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// New function to generate a PDF blob using the existing PDF generation logic
|
|
184
|
+
async function generatePDFBlob() {
|
|
185
|
+
return new Promise((resolve, reject) => {
|
|
186
|
+
// Create a temporary container for the PDFDownloadLink
|
|
187
|
+
const container = window.document.createElement("div");
|
|
188
|
+
container.style.display = "none";
|
|
189
|
+
window.document.body.appendChild(container);
|
|
190
|
+
// Create root for React 18
|
|
191
|
+
const root = createRoot(container);
|
|
192
|
+
// Cleanup function
|
|
193
|
+
const cleanup = () => {
|
|
194
|
+
root.unmount();
|
|
195
|
+
window.document.body.removeChild(container);
|
|
196
|
+
};
|
|
197
|
+
try {
|
|
198
|
+
root.render(_jsx(PDFDownloadLink, { document: _jsx(InvoicePDF, { invoice: state, fiatMode: fiatMode }), fileName: `invoice-${state.invoiceNo || "export"}.pdf`, className: "hidden", children: ({ blob, url, loading, error }) => {
|
|
199
|
+
if (loading) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
if (error) {
|
|
203
|
+
cleanup();
|
|
204
|
+
reject(error);
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
if (blob) {
|
|
208
|
+
// We have the blob, resolve it
|
|
209
|
+
resolve(blob);
|
|
210
|
+
// Cleanup after getting the blob
|
|
211
|
+
setTimeout(cleanup, 100);
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
} }));
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
console.error("Error generating PDF blob:", error);
|
|
218
|
+
cleanup();
|
|
219
|
+
reject(error);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
// Add validation check when status changes
|
|
224
|
+
const handleStatusChange = (newStatus) => {
|
|
225
|
+
if (newStatus === "PAYMENTSCHEDULED" || newStatus === "ISSUED") {
|
|
226
|
+
const context = {
|
|
227
|
+
currency: state.currency,
|
|
228
|
+
currentStatus: state.status,
|
|
229
|
+
targetStatus: newStatus === "PAYMENTSCHEDULED" ? "ISSUED" : "ISSUED",
|
|
230
|
+
};
|
|
231
|
+
// Collect all validation errors
|
|
232
|
+
const validationErrors = [];
|
|
233
|
+
// Validate invoice number
|
|
234
|
+
const invoiceValidation = validateField("invoiceNo", state.invoiceNo, context);
|
|
235
|
+
setInvoiceValidation(invoiceValidation);
|
|
236
|
+
if (invoiceValidation && !invoiceValidation.isValid) {
|
|
237
|
+
validationErrors.push(invoiceValidation);
|
|
238
|
+
}
|
|
239
|
+
// Validate wallet address if currency is crypto
|
|
240
|
+
if (!isFiatCurrency(state.currency)) {
|
|
241
|
+
const walletValidation = validateField("address", state.issuer.paymentRouting?.wallet?.address ?? "", context);
|
|
242
|
+
setWalletValidation(walletValidation);
|
|
243
|
+
if (walletValidation && !walletValidation.isValid) {
|
|
244
|
+
validationErrors.push(walletValidation);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// Validate currency
|
|
248
|
+
const currencyValidation = validateField("currency", state.currency, context);
|
|
249
|
+
setCurrencyValidation(currencyValidation);
|
|
250
|
+
if (currencyValidation && !currencyValidation.isValid) {
|
|
251
|
+
validationErrors.push(currencyValidation);
|
|
252
|
+
}
|
|
253
|
+
// Validate country
|
|
254
|
+
const country = state.issuer.paymentRouting?.bank?.address?.country &&
|
|
255
|
+
state.issuer.country
|
|
256
|
+
? state.issuer.paymentRouting?.bank?.address?.country
|
|
257
|
+
: "";
|
|
258
|
+
const countryValidation = validateField("country", country, context);
|
|
259
|
+
setCountryValidation(countryValidation);
|
|
260
|
+
if (countryValidation && !countryValidation.isValid) {
|
|
261
|
+
validationErrors.push(countryValidation);
|
|
262
|
+
}
|
|
263
|
+
// Validate EUR&GBP IBAN account number
|
|
264
|
+
const ibanValidation = validateField("accountNum", state.issuer.paymentRouting?.bank?.accountNum, context);
|
|
265
|
+
setIbanValidation(ibanValidation);
|
|
266
|
+
if (ibanValidation && !ibanValidation.isValid) {
|
|
267
|
+
validationErrors.push(ibanValidation);
|
|
268
|
+
}
|
|
269
|
+
// Validate BIC number
|
|
270
|
+
const bicValidation = validateField("bicNumber", state.issuer.paymentRouting?.bank?.BIC, context);
|
|
271
|
+
setBicValidation(bicValidation);
|
|
272
|
+
if (bicValidation && !bicValidation.isValid) {
|
|
273
|
+
validationErrors.push(bicValidation);
|
|
274
|
+
}
|
|
275
|
+
// Validate bank name
|
|
276
|
+
const bankNameValidation = validateField("bankName", state.issuer.paymentRouting?.bank?.name, context);
|
|
277
|
+
setBankNameValidation(bankNameValidation);
|
|
278
|
+
if (bankNameValidation && !bankNameValidation.isValid) {
|
|
279
|
+
validationErrors.push(bankNameValidation);
|
|
280
|
+
}
|
|
281
|
+
// Validate street address
|
|
282
|
+
const streetAddressValidation = validateField("streetAddress", state.issuer.address?.streetAddress, context);
|
|
283
|
+
setStreetAddressValidation(streetAddressValidation);
|
|
284
|
+
if (streetAddressValidation && !streetAddressValidation.isValid) {
|
|
285
|
+
validationErrors.push(streetAddressValidation);
|
|
286
|
+
}
|
|
287
|
+
// Validate city
|
|
288
|
+
const cityValidation = validateField("city", state.issuer.address?.city, context);
|
|
289
|
+
setCityValidation(cityValidation);
|
|
290
|
+
if (cityValidation && !cityValidation.isValid) {
|
|
291
|
+
validationErrors.push(cityValidation);
|
|
292
|
+
}
|
|
293
|
+
// Validate postal code
|
|
294
|
+
const postalCodeValidation = validateField("postalCode", state.issuer.address?.postalCode, context);
|
|
295
|
+
setPostalCodeValidation(postalCodeValidation);
|
|
296
|
+
if (postalCodeValidation && !postalCodeValidation.isValid) {
|
|
297
|
+
validationErrors.push(postalCodeValidation);
|
|
298
|
+
}
|
|
299
|
+
// Validate payer email
|
|
300
|
+
const payerEmailValidation = validateField("email", state.payer.contactInfo?.email, context);
|
|
301
|
+
setPayerEmailValidation(payerEmailValidation);
|
|
302
|
+
if (payerEmailValidation && !payerEmailValidation.isValid) {
|
|
303
|
+
validationErrors.push(payerEmailValidation);
|
|
304
|
+
}
|
|
305
|
+
// Validate line items
|
|
306
|
+
const lineItemValidation = validateField("lineItem", state.lineItems, context);
|
|
307
|
+
setLineItemValidation(lineItemValidation);
|
|
308
|
+
if (lineItemValidation && !lineItemValidation.isValid) {
|
|
309
|
+
validationErrors.push(lineItemValidation);
|
|
310
|
+
}
|
|
311
|
+
if (newStatus === "PAYMENTSCHEDULED" &&
|
|
312
|
+
!isFiatCurrency(state.currency) &&
|
|
313
|
+
state.issuer.paymentRouting?.wallet?.chainName === "") {
|
|
314
|
+
validationErrors.push({
|
|
315
|
+
message: "Select currency and chain before accepting invoice",
|
|
316
|
+
severity: "warning",
|
|
317
|
+
isValid: false,
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
// If there are any validation errors, show them and return
|
|
321
|
+
if (validationErrors.length > 0) {
|
|
322
|
+
validationErrors.forEach((error) => {
|
|
323
|
+
toast(error.message, {
|
|
324
|
+
type: error.severity === "error" ? "error" : "warning",
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
dispatch(actions.editStatus({ status: newStatus }));
|
|
331
|
+
};
|
|
332
|
+
const handleCurrencyChange = (currency) => {
|
|
333
|
+
if ((prevStatus.current === "PAYMENTSCHEDULED" || prevStatus.current === "DRAFT") &&
|
|
334
|
+
!isFiatCurrency(currency) &&
|
|
335
|
+
state.issuer.paymentRouting?.wallet?.chainName === "") {
|
|
336
|
+
dispatch(actions.editStatus({ status: "DRAFT" }));
|
|
337
|
+
toast("Select currency and chain before accepting invoice", {
|
|
338
|
+
type: "warning",
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
dispatch(actions.editInvoice({ currency }));
|
|
342
|
+
};
|
|
343
|
+
return (_jsxs("div", { className: "container mx-auto p-6 max-w-7xl", children: [_jsx(ToastContainer, { position: "bottom-right", autoClose: 5000, hideProgressBar: false, newestOnTop: false, closeOnClick: false, rtl: false, pauseOnFocusLoss: true, draggable: true, pauseOnHover: true, theme: "light" }), _jsxs("div", { className: "flex items-center justify-between gap-4 mb-6", children: [_jsxs("div", { className: "flex items-center gap-4 flex-nowrap", children: [_jsx("h1", { className: "text-3xl font-bold whitespace-nowrap", children: "Invoice" }), _jsx(InputField, { placeholder: "Add invoice number", value: invoiceNoInput, handleInputChange: (e) => setInvoiceNoInput(e.target.value), onBlur: (e) => {
|
|
344
|
+
const newValue = e.target.value;
|
|
345
|
+
if (newValue !== state.invoiceNo) {
|
|
346
|
+
dispatch(actions.editInvoice({ invoiceNo: newValue }));
|
|
347
|
+
}
|
|
348
|
+
}, input: invoiceNoInput, validation: invoiceValidation }), _jsxs("div", { className: "relative", ref: uploadDropdownRef, children: [_jsxs("button", { onClick: () => setUploadDropdownOpen(!uploadDropdownOpen), className: "inline-flex items-center h-10 px-4 rounded bg-blue-500 hover:bg-blue-600 text-white font-medium transition-colors whitespace-nowrap cursor-pointer", disabled: isPdfLoading, children: [isPdfLoading ? "Processing..." : "Upload File", _jsx("svg", { className: "w-4 h-4 ml-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M19 9l-7 7-7-7" }) })] }), uploadDropdownOpen && !isPdfLoading && (_jsx("div", { className: "absolute z-10 mt-1 w-48 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5", children: _jsxs("div", { className: "py-1", role: "menu", "aria-orientation": "vertical", children: [_jsxs("label", { className: "block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 cursor-pointer", children: ["Upload UBL", _jsx("input", { accept: ".xml", className: "hidden", onChange: (e) => {
|
|
349
|
+
handleFileUpload(e);
|
|
350
|
+
setUploadDropdownOpen(false);
|
|
351
|
+
}, type: "file" })] }), _jsx(PDFUploader, { dispatch: dispatch, changeDropdownOpen: setUploadDropdownOpen })] }) }))] }), _jsxs("div", { className: "relative", ref: exportDropdownRef, children: [_jsxs("button", { onClick: () => setExportDropdownOpen(!exportDropdownOpen), className: "inline-flex items-center h-10 px-4 rounded bg-black hover:bg-gray-800 text-white font-medium transition-colors whitespace-nowrap cursor-pointer", children: ["Export File", _jsx("svg", { className: "w-4 h-4 ml-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M19 9l-7 7-7-7" }) })] }), exportDropdownOpen && (_jsx("div", { className: "absolute z-10 mt-1 w-48 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5", children: _jsxs("div", { className: "py-1", role: "menu", "aria-orientation": "vertical", children: [_jsx("button", { onClick: () => {
|
|
352
|
+
handleExportUBL();
|
|
353
|
+
setExportDropdownOpen(false);
|
|
354
|
+
}, className: "block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 cursor-pointer", children: "Export UBL" }), _jsx("button", { onClick: () => {
|
|
355
|
+
handleExportPDF();
|
|
356
|
+
setExportDropdownOpen(false);
|
|
357
|
+
}, className: "block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 cursor-pointer", children: "Export PDF" })] }) }))] })] }), _jsx("div", { className: "flex items-center gap-2", children: _jsx(CurrencyForm, { currency: state.currency, handleInputChange: (e) => {
|
|
358
|
+
handleCurrencyChange(e.target.value);
|
|
359
|
+
}, validation: currencyValidation }) }), _jsx(SelectField, { options: STATUS_OPTIONS, value: state.status, onChange: (value) => handleStatusChange(value) })] }), _jsxs("div", { className: "grid grid-cols-2 gap-8", children: [_jsxs("div", { className: "border border-gray-200 rounded-lg p-6", children: [_jsx("h3", { className: "text-lg font-semibold mb-4", children: "Issuer" }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "mb-2", children: [_jsx("label", { className: "block mb-1 text-sm", children: "Issue Date:" }), _jsx(DatePicker, { name: "issueDate", className: "w-full", onChange: (e) => {
|
|
360
|
+
const newDate = e.target.value.split("T")[0];
|
|
361
|
+
dispatch(actions.editInvoice({
|
|
362
|
+
dateIssued: newDate,
|
|
363
|
+
}));
|
|
364
|
+
}, value: state.dateIssued })] }), _jsxs("div", { className: "mb-2", children: [_jsx("label", { className: "block mb-1 text-sm", children: "Delivery Date:" }), _jsx(DatePicker, { name: "deliveryDate", className: "w-full", onChange: (e) => {
|
|
365
|
+
const newValue = e.target.value.split("T")[0];
|
|
366
|
+
if (newValue !== state.dateDelivered) {
|
|
367
|
+
dispatch(actions.editInvoice({
|
|
368
|
+
dateDelivered: newValue,
|
|
369
|
+
}));
|
|
370
|
+
}
|
|
371
|
+
}, value: state.dateDelivered || "" })] })] }), _jsx(LegalEntityForm, { legalEntity: state.issuer, onChangeBank: (input) => dispatch(actions.editIssuerBank(input)), onChangeInfo: (input) => dispatch(actions.editIssuer(input)), onChangeWallet: (input) => dispatch(actions.editIssuerWallet(input)), bankDisabled: !fiatMode, walletDisabled: fiatMode, currency: state.currency, status: state.status, walletvalidation: walletValidation, countryvalidation: countryValidation, ibanvalidation: ibanValidation, bicvalidation: bicValidation, banknamevalidation: bankNameValidation, streetaddressvalidation: streetAddressValidation, cityvalidation: cityValidation, postalcodevalidation: postalCodeValidation })] }), _jsxs("div", { className: "border border-gray-200 rounded-lg p-6", children: [_jsx("h3", { className: "text-lg font-semibold mb-4", children: "Payer" }), _jsxs("div", { className: "mb-2", children: [_jsx("label", { className: "block mb-1 text-sm", children: "Due Date:" }), _jsx(DatePicker, { name: "dateDue", className: "w-full", onChange: (e) => dispatch(actions.editInvoice({
|
|
372
|
+
dateDue: e.target.value.split("T")[0],
|
|
373
|
+
})), value: state.dateDue })] }), _jsx(LegalEntityForm, { bankDisabled: true, legalEntity: state.payer, onChangeInfo: (input) => dispatch(actions.editPayer(input)), currency: state.currency, status: state.status, payeremailvalidation: payerEmailValidation })] })] }), _jsx("div", { className: "mb-8", children: _jsx(LineItemsTable, { currency: state.currency, lineItems: state.lineItems, onAddItem: (item) => dispatch(actions.addLineItem(item)), onDeleteItem: (input) => dispatch(actions.deleteLineItem(input)), onUpdateCurrency: (input) => {
|
|
374
|
+
setFiatMode(input.currency !== "USDS");
|
|
375
|
+
dispatch(actions.editInvoice(input));
|
|
376
|
+
}, onUpdateItem: (item) => dispatch(actions.editLineItem(item)) }) }), _jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: _jsx("div", { className: "md:col-start-2", children: _jsx("div", { className: "rounded-lg border border-gray-200 bg-gray-50 p-6 shadow-sm", children: _jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "flex justify-between text-gray-700", children: [_jsx("span", { className: "font-medium", children: "Subtotal (excl. tax):" }), _jsxs("span", { children: [formatNumber(itemsTotalTaxExcl), " ", state.currency] })] }), _jsxs("div", { className: "flex justify-between border-t border-gray-200 pt-4 text-lg font-bold text-gray-900", children: [_jsx("span", { children: "Total (incl. tax):" }), _jsxs("span", { children: [formatNumber(itemsTotalTaxIncl), " ", state.currency] })] })] }) }) }) }), state.status === "PAYMENTSCHEDULED" && (_jsx("div", { className: "mt-8", children: !isFiatCurrency(state.currency) ? (_jsx(InvoiceToGnosis, { docState: state })) : (_jsx(RequestFinance, { docState: state })) }))] }));
|
|
377
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { InvoiceState } from "../../document-models/invoice/index.js";
|
|
2
|
+
interface ExportUBLOptions {
|
|
3
|
+
invoice: InvoiceState;
|
|
4
|
+
filename?: string;
|
|
5
|
+
pdfBlob?: Blob;
|
|
6
|
+
}
|
|
7
|
+
export declare class UBLExporter {
|
|
8
|
+
private invoice;
|
|
9
|
+
private pdfBlob?;
|
|
10
|
+
constructor(invoice: InvoiceState, pdfBlob?: Blob);
|
|
11
|
+
/**
|
|
12
|
+
* Convert the invoice state to UBL XML format
|
|
13
|
+
* @returns UBL XML string
|
|
14
|
+
*/
|
|
15
|
+
convertInvoiceToUBL(): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Export the invoice to a UBL file
|
|
18
|
+
* @param options Export options
|
|
19
|
+
* @returns Promise resolving to the generated file
|
|
20
|
+
*/
|
|
21
|
+
exportToFile({ filename, }?: {
|
|
22
|
+
filename?: string;
|
|
23
|
+
}): Promise<File>;
|
|
24
|
+
/**
|
|
25
|
+
* Trigger download of the UBL file in the browser
|
|
26
|
+
*/
|
|
27
|
+
downloadUBL(filename?: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Format date as YYYY-MM-DD for UBL format
|
|
30
|
+
*/
|
|
31
|
+
private formatDate;
|
|
32
|
+
/**
|
|
33
|
+
* Escape special XML characters
|
|
34
|
+
*/
|
|
35
|
+
private escapeXml;
|
|
36
|
+
/**
|
|
37
|
+
* Generate the AccountingSupplierParty section
|
|
38
|
+
*/
|
|
39
|
+
private generateSupplierParty;
|
|
40
|
+
/**
|
|
41
|
+
* Generate the AccountingCustomerParty section
|
|
42
|
+
*/
|
|
43
|
+
private generateCustomerParty;
|
|
44
|
+
/**
|
|
45
|
+
* Generate payment terms section
|
|
46
|
+
*/
|
|
47
|
+
private generatePaymentTerms;
|
|
48
|
+
/**
|
|
49
|
+
* Generate the PaymentMeans section with bank details
|
|
50
|
+
*/
|
|
51
|
+
private generatePaymentMeans;
|
|
52
|
+
/**
|
|
53
|
+
* Generate tax summary section
|
|
54
|
+
*/
|
|
55
|
+
private generateTaxSummary;
|
|
56
|
+
/**
|
|
57
|
+
* Generate the LegalMonetaryTotal section
|
|
58
|
+
*/
|
|
59
|
+
private generateLegalMonetaryTotal;
|
|
60
|
+
/**
|
|
61
|
+
* Generate InvoiceLine sections for each line item
|
|
62
|
+
*/
|
|
63
|
+
private generateInvoiceLines;
|
|
64
|
+
/**
|
|
65
|
+
* Generate PDF attachment section if a PDF blob is available
|
|
66
|
+
*/
|
|
67
|
+
private generatePDFAttachment;
|
|
68
|
+
/**
|
|
69
|
+
* Convert a Blob to base64 string
|
|
70
|
+
*/
|
|
71
|
+
private blobToBase64;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Export an invoice to UBL format
|
|
75
|
+
* @param options Export options
|
|
76
|
+
* @returns Promise resolving to the generated file
|
|
77
|
+
*/
|
|
78
|
+
export declare function exportToUBL({ invoice, filename, pdfBlob, }: ExportUBLOptions): Promise<File>;
|
|
79
|
+
/**
|
|
80
|
+
* Export and download an invoice as UBL
|
|
81
|
+
* @param options Export options
|
|
82
|
+
*/
|
|
83
|
+
export declare function downloadUBL({ invoice, filename, pdfBlob, }: ExportUBLOptions): Promise<void>;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=exportUBL.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exportUBL.d.ts","sourceRoot":"","sources":["../../../editors/invoice/exportUBL.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAKb,MAAM,wCAAwC,CAAC;AAEhD,UAAU,gBAAgB;IACxB,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB;AAqBD,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,OAAO,CAAC,CAAO;gBAEX,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,IAAI;IAKjD;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAkC5C;;;;OAIG;IACG,YAAY,CAAC,EACjB,QAAwB,GACzB,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7C;;OAEG;IACG,WAAW,CAAC,QAAQ,SAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAa1D;;OAEG;IACH,OAAO,CAAC,UAAU;IAalB;;OAEG;IACH,OAAO,CAAC,SAAS;IASjB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAsC7B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAyB7B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAe5B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAuB5B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAuE1B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IA2BlC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA+B5B;;OAEG;YACW,qBAAqB;IAuBnC;;OAEG;IACH,OAAO,CAAC,YAAY;CAarB;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,EAChC,OAAO,EACP,QAAwB,EACxB,OAAO,GACR,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlC;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,EAChC,OAAO,EACP,QAAwB,EACxB,OAAO,GACR,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlC"}
|