@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,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import { LegalEntityWalletSection } from "./walletSection.js";
|
|
4
|
+
import { LegalEntityBankSection } from "./bankSection.js";
|
|
5
|
+
import { CountryForm } from "../components/countryForm.js";
|
|
6
|
+
import { InputField } from "../components/inputField.js";
|
|
7
|
+
const FieldLabel = ({ children }) => (_jsx("label", { className: "block text-sm font-medium text-gray-700", children: children }));
|
|
8
|
+
export const LegalEntityMainSection = (props) => {
|
|
9
|
+
const { value, onChange, disabled, countryvalidation, streetaddressvalidation, cityvalidation, postalcodevalidation, payeremailvalidation, ...divProps } = props;
|
|
10
|
+
const handleInputChange = (field) => (e) => {
|
|
11
|
+
// No-op
|
|
12
|
+
};
|
|
13
|
+
const handleBlur = (field) => (e) => {
|
|
14
|
+
if (e.target.value !== value[field]) {
|
|
15
|
+
onChange({ [field]: e.target.value });
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const handleTextareaChange = (field) => (e) => {
|
|
19
|
+
// No-op
|
|
20
|
+
};
|
|
21
|
+
const handleTextareaBlur = (field) => (e) => {
|
|
22
|
+
if (e.target.value !== value[field]) {
|
|
23
|
+
onChange({ [field]: e.target.value });
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return (_jsxs("div", { ...divProps, className: twMerge("rounded-lg border border-gray-200 bg-white p-6 mb-2", props.className), children: [_jsx("h3", { className: "mb-4 text-lg font-semibold text-gray-900", children: "Basic Information" }), _jsxs("div", { className: "space-y-6", children: [_jsx("div", { className: "space-y-2", children: _jsx(InputField, { value: value.name ?? "", label: "Name", placeholder: "Legal Entity Name", onBlur: handleTextareaBlur("name"), handleInputChange: handleTextareaChange("name"), className: "h-10 w-full text-md mb-2" }) }), _jsx("div", { className: "space-y-2", children: _jsx(InputField, { value: value.id ?? "", label: "Tax ID / Corp. Reg", placeholder: "332...", onBlur: handleTextareaBlur("id"), handleInputChange: handleTextareaChange("id"), className: "h-10 w-full text-md mb-2" }) }), _jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "space-y-4", children: [_jsx(InputField, { value: value.streetAddress ?? "", label: "Address", placeholder: "Street Address", onBlur: handleTextareaBlur("streetAddress"), handleInputChange: handleTextareaChange("streetAddress"), className: "h-10 w-full text-md mb-2", validation: streetaddressvalidation }), _jsx(InputField, { value: value.extendedAddress ?? "", placeholder: "Extended Address", onBlur: handleTextareaBlur("extendedAddress"), handleInputChange: handleTextareaChange("extendedAddress"), className: "h-10 w-full text-md mb-2" })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsx("div", { className: "space-y-2", children: _jsx(InputField, { value: value.city ?? "", label: "City", placeholder: "City", onBlur: handleTextareaBlur("city"), handleInputChange: handleTextareaChange("city"), className: "h-10 w-full text-md mb-2", validation: cityvalidation }) }), _jsx("div", { className: "space-y-2", children: _jsx(InputField, { value: value.stateProvince ?? "", label: "State/Province", placeholder: "State/Province", onBlur: handleTextareaBlur("stateProvince"), handleInputChange: handleTextareaChange("stateProvince"), className: "h-10 w-full text-md mb-2" }) })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsx("div", { className: "space-y-2", children: _jsx(InputField, { value: value.postalCode ?? "", label: "Postal Code", placeholder: "Postal Code", onBlur: handleTextareaBlur("postalCode"), handleInputChange: handleTextareaChange("postalCode"), className: "h-10 w-full text-md mb-2", validation: postalcodevalidation }) }), _jsxs("div", { className: "space-y-2", children: [_jsx(FieldLabel, { children: "Country" }), _jsx(CountryForm, { country: value.country ?? "", handleInputChange: handleInputChange("country"), handleBlur: handleBlur("country"), className: "h-10 w-full text-md mb-2", validation: countryvalidation })] })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsx("div", { className: "space-y-2", children: _jsx(InputField, { value: value.email ?? "", label: "Email", placeholder: "Email", onBlur: handleTextareaBlur("email"), handleInputChange: handleTextareaChange("email"), className: "h-10 w-full text-md mb-2", validation: payeremailvalidation }) }), _jsx("div", { className: "space-y-2", children: _jsx(InputField, { value: value.tel ?? "", label: "Telephone", placeholder: "Telephone", onBlur: handleTextareaBlur("tel"), handleInputChange: handleTextareaChange("tel"), className: "h-10 w-full text-md mb-2" }) })] })] })] }));
|
|
27
|
+
};
|
|
28
|
+
// Helper to flatten LegalEntity to EditLegalEntityInput
|
|
29
|
+
function flattenLegalEntityToEditInput(legalEntity) {
|
|
30
|
+
let id = "";
|
|
31
|
+
if (typeof legalEntity.id === "string") {
|
|
32
|
+
id = legalEntity.id;
|
|
33
|
+
}
|
|
34
|
+
else if (legalEntity.id && typeof legalEntity.id === "object") {
|
|
35
|
+
if (legalEntity.id && typeof legalEntity.id === "object") {
|
|
36
|
+
id =
|
|
37
|
+
"taxId" in legalEntity.id
|
|
38
|
+
? legalEntity.id.taxId
|
|
39
|
+
: legalEntity.id.corpRegId;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
id,
|
|
44
|
+
name: legalEntity.name ?? "",
|
|
45
|
+
streetAddress: legalEntity.address?.streetAddress ?? "",
|
|
46
|
+
extendedAddress: legalEntity.address?.extendedAddress ?? "",
|
|
47
|
+
city: legalEntity.address?.city ?? "",
|
|
48
|
+
postalCode: legalEntity.address?.postalCode ?? "",
|
|
49
|
+
country: legalEntity.address?.country ?? "",
|
|
50
|
+
stateProvince: legalEntity.address?.stateProvince ?? "",
|
|
51
|
+
tel: legalEntity.contactInfo?.tel ?? "",
|
|
52
|
+
email: legalEntity.contactInfo?.email ?? "",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function LegalEntityForm({ legalEntity, onChangeInfo, onChangeBank, onChangeWallet, basicInfoDisabled, bankDisabled, walletDisabled, currency, status, walletvalidation, countryvalidation, ibanvalidation, bicvalidation, banknamevalidation, streetaddressvalidation, cityvalidation, postalcodevalidation, payeremailvalidation }) {
|
|
56
|
+
// Handler for main info section
|
|
57
|
+
const handleChangeInfo = (update) => {
|
|
58
|
+
if (!onChangeInfo)
|
|
59
|
+
return;
|
|
60
|
+
onChangeInfo(update);
|
|
61
|
+
};
|
|
62
|
+
return (_jsxs("div", { className: "space-y-8", children: [!basicInfoDisabled && !!onChangeInfo && (_jsx(LegalEntityMainSection, { onChange: handleChangeInfo, value: flattenLegalEntityToEditInput(legalEntity), countryvalidation: countryvalidation, streetaddressvalidation: streetaddressvalidation, cityvalidation: cityvalidation, postalcodevalidation: postalcodevalidation, payeremailvalidation: payeremailvalidation })), !walletDisabled && !!onChangeWallet && (_jsx(LegalEntityWalletSection, { onChange: onChangeWallet, value: legalEntity.paymentRouting?.wallet || {}, currency: currency, status: status, walletvalidation: walletvalidation })), !bankDisabled && !!onChangeBank && (_jsx(LegalEntityBankSection, { onChange: onChangeBank, value: legalEntity.paymentRouting?.bank || {}, countryvalidation: countryvalidation, ibanvalidation: ibanvalidation, bicvalidation: bicvalidation, banknamevalidation: banknamevalidation }))] }));
|
|
63
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { EditLegalEntityWalletInput } from "./legalEntity.js";
|
|
3
|
+
import { ValidationResult } from "../validation/validationManager.js";
|
|
4
|
+
export type LegalEntityWalletSectionProps = Omit<ComponentProps<"div">, "children" | "onChange"> & {
|
|
5
|
+
readonly value: EditLegalEntityWalletInput;
|
|
6
|
+
readonly onChange: (value: EditLegalEntityWalletInput) => void;
|
|
7
|
+
readonly disabled?: boolean;
|
|
8
|
+
readonly currency: string;
|
|
9
|
+
readonly status: string;
|
|
10
|
+
readonly walletvalidation?: ValidationResult | null;
|
|
11
|
+
};
|
|
12
|
+
export declare const LegalEntityWalletSection: (props: LegalEntityWalletSectionProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=walletSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletSection.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/legalEntity/walletSection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAC9C,cAAc,CAAC,KAAK,CAAC,EACrB,UAAU,GAAG,UAAU,CACxB,GAAG;IACF,QAAQ,CAAC,KAAK,EAAE,0BAA0B,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,0BAA0B,KAAK,IAAI,CAAC;IAC/D,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACrD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,OAAO,6BAA6B,4CA4GrC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { twMerge } from "tailwind-merge";
|
|
4
|
+
import { InputField } from "../components/inputField.js";
|
|
5
|
+
import { Select } from "@powerhousedao/document-engineering";
|
|
6
|
+
export const LegalEntityWalletSection = (props) => {
|
|
7
|
+
const { value, onChange, disabled, currency, status, walletvalidation, ...divProps } = props;
|
|
8
|
+
const [localState, setLocalState] = useState(value);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setLocalState(value);
|
|
11
|
+
}, [value]);
|
|
12
|
+
const handleInputChange = (field, event) => {
|
|
13
|
+
setLocalState(prev => ({
|
|
14
|
+
...prev,
|
|
15
|
+
[field]: event.target.value,
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
18
|
+
const handleBlur = (field, event) => {
|
|
19
|
+
const newValue = event.target.value;
|
|
20
|
+
onChange({
|
|
21
|
+
// ...localState,
|
|
22
|
+
[field]: newValue,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const CHAIN_PRESETS = [
|
|
26
|
+
{ chainName: "Base", chainId: "8453" },
|
|
27
|
+
{ chainName: "Ethereum", chainId: "1" },
|
|
28
|
+
{ chainName: "Arbitrum One", chainId: "42161" },
|
|
29
|
+
// { chainName: "Gnosis", chainId: "100" },
|
|
30
|
+
];
|
|
31
|
+
// Map CHAIN_PRESETS to Select options
|
|
32
|
+
const chainOptions = CHAIN_PRESETS.map((preset) => ({
|
|
33
|
+
label: preset.chainName,
|
|
34
|
+
value: preset.chainId,
|
|
35
|
+
}));
|
|
36
|
+
// Find the selected option by chainId
|
|
37
|
+
const selectedChain = chainOptions.find((opt) => opt.value === localState.chainId)?.value;
|
|
38
|
+
const handleChainChange = (value) => {
|
|
39
|
+
const chainId = Array.isArray(value) ? value[0] : value;
|
|
40
|
+
const preset = CHAIN_PRESETS.find((p) => p.chainId === chainId);
|
|
41
|
+
if (preset) {
|
|
42
|
+
setLocalState(prev => ({
|
|
43
|
+
...prev,
|
|
44
|
+
chainId: preset.chainId,
|
|
45
|
+
chainName: preset.chainName,
|
|
46
|
+
}));
|
|
47
|
+
onChange({
|
|
48
|
+
...localState,
|
|
49
|
+
chainId: preset.chainId,
|
|
50
|
+
chainName: preset.chainName,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return (_jsxs("div", { ...divProps, className: twMerge("rounded-lg border border-gray-200 bg-white p-6", props.className), children: [_jsxs("div", { className: "grid grid-cols-2 gap-4 items-center", children: [_jsx("h3", { className: "mb-4 text-lg font-semibold text-black-200", children: "Wallet Information" }), _jsx(Select, { style: { width: "100%" }, options: chainOptions, value: selectedChain || "", onChange: handleChainChange, placeholder: "Select Chain" })] }), _jsx("div", { className: "space-y-6", children: _jsx("div", { className: "space-y-4", children: _jsx(InputField, { value: localState.address ?? "", label: "Wallet Address", placeholder: "0x...", onBlur: (e) => handleBlur("address", e), handleInputChange: (e) => handleInputChange("address", e), validation: walletvalidation }) }) })] }));
|
|
55
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EditInvoiceInput, DeleteLineItemInput } from "../../document-models/invoice/index.js";
|
|
2
|
+
type LineItem = {
|
|
3
|
+
currency: string;
|
|
4
|
+
description: string;
|
|
5
|
+
id: string;
|
|
6
|
+
quantity: number;
|
|
7
|
+
taxPercent: number;
|
|
8
|
+
totalPriceTaxExcl: number;
|
|
9
|
+
totalPriceTaxIncl: number;
|
|
10
|
+
unitPriceTaxExcl: number;
|
|
11
|
+
unitPriceTaxIncl: number;
|
|
12
|
+
};
|
|
13
|
+
type LineItemsTableProps = {
|
|
14
|
+
readonly lineItems: LineItem[];
|
|
15
|
+
readonly currency: string;
|
|
16
|
+
readonly onAddItem: (item: LineItem) => void;
|
|
17
|
+
readonly onUpdateItem: (item: LineItem) => void;
|
|
18
|
+
readonly onDeleteItem: (input: DeleteLineItemInput) => void;
|
|
19
|
+
readonly onUpdateCurrency: (input: EditInvoiceInput) => void;
|
|
20
|
+
};
|
|
21
|
+
export declare function LineItemsTable({ lineItems, currency, onAddItem, onUpdateItem, onDeleteItem, onUpdateCurrency, }: LineItemsTableProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=lineItems.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineItems.d.ts","sourceRoot":"","sources":["../../../editors/invoice/lineItems.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AA+B/F,KAAK,QAAQ,GAAG;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAmNF,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC7C,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IAChD,QAAQ,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5D,QAAQ,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC9D,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,gBAAgB,GACjB,EAAE,mBAAmB,2CA+HrB"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable react/jsx-max-depth */
|
|
3
|
+
/* eslint-disable react/jsx-no-bind */
|
|
4
|
+
/* eslint-disable react/button-has-type */
|
|
5
|
+
import { RWAButton } from "@powerhousedao/design-system";
|
|
6
|
+
import { forwardRef, useState, useMemo } from "react";
|
|
7
|
+
import { v4 as uuidv4 } from "uuid";
|
|
8
|
+
import { NumberForm } from "./components/numberForm.js";
|
|
9
|
+
import { InputField } from "./components/inputField.js";
|
|
10
|
+
// Helper function to get precision based on currency
|
|
11
|
+
function getCurrencyPrecision(currency) {
|
|
12
|
+
return currency === "USDS" || currency === "DAI" ? 6 : 2;
|
|
13
|
+
}
|
|
14
|
+
// Helper function to format numbers with appropriate decimal places
|
|
15
|
+
function formatNumber(value) {
|
|
16
|
+
// Check if the value has decimal places
|
|
17
|
+
const hasDecimals = value % 1 !== 0;
|
|
18
|
+
// If no decimals or only trailing zeros after 2 decimal places, show 2 decimal places
|
|
19
|
+
if (!hasDecimals || value.toFixed(5).endsWith("000")) {
|
|
20
|
+
return value.toFixed(2);
|
|
21
|
+
}
|
|
22
|
+
// Otherwise, show atual decimal places up to 5
|
|
23
|
+
const stringValue = value.toString();
|
|
24
|
+
const decimalPart = stringValue.split(".")[1] || "";
|
|
25
|
+
// Determine how many decimal places to show (up to 5)
|
|
26
|
+
const decimalPlaces = Math.min(Math.max(2, decimalPart.length), 5);
|
|
27
|
+
return value.toFixed(decimalPlaces);
|
|
28
|
+
}
|
|
29
|
+
const EditableLineItem = forwardRef(function EditableLineItem(props, ref) {
|
|
30
|
+
const { item, onSave, onCancel, currency } = props;
|
|
31
|
+
const [editedItem, setEditedItem] = useState({
|
|
32
|
+
...item,
|
|
33
|
+
currency,
|
|
34
|
+
quantity: item.quantity ?? "",
|
|
35
|
+
taxPercent: item.taxPercent ?? "",
|
|
36
|
+
unitPriceTaxExcl: item.unitPriceTaxExcl ?? "",
|
|
37
|
+
});
|
|
38
|
+
const calculatedValues = useMemo(() => {
|
|
39
|
+
const quantity = typeof editedItem.quantity === "string"
|
|
40
|
+
? editedItem.quantity === ""
|
|
41
|
+
? 0
|
|
42
|
+
: Number(editedItem.quantity)
|
|
43
|
+
: (editedItem.quantity ?? 0);
|
|
44
|
+
const unitPriceTaxExcl = typeof editedItem.unitPriceTaxExcl === "string"
|
|
45
|
+
? editedItem.unitPriceTaxExcl === ""
|
|
46
|
+
? 0
|
|
47
|
+
: Number(editedItem.unitPriceTaxExcl)
|
|
48
|
+
: (editedItem.unitPriceTaxExcl ?? 0);
|
|
49
|
+
const taxPercent = typeof editedItem.taxPercent === "string"
|
|
50
|
+
? editedItem.taxPercent === ""
|
|
51
|
+
? 0
|
|
52
|
+
: Number(editedItem.taxPercent)
|
|
53
|
+
: (editedItem.taxPercent ?? 0);
|
|
54
|
+
const totalPriceTaxExcl = quantity * unitPriceTaxExcl;
|
|
55
|
+
const taxAmount = totalPriceTaxExcl * (taxPercent / 100);
|
|
56
|
+
const totalPriceTaxIncl = totalPriceTaxExcl + taxAmount;
|
|
57
|
+
const unitPriceTaxIncl = unitPriceTaxExcl * (1 + taxPercent / 100);
|
|
58
|
+
return {
|
|
59
|
+
totalPriceTaxExcl,
|
|
60
|
+
totalPriceTaxIncl,
|
|
61
|
+
unitPriceTaxIncl,
|
|
62
|
+
};
|
|
63
|
+
}, [editedItem.quantity, editedItem.unitPriceTaxExcl, editedItem.taxPercent]);
|
|
64
|
+
function handleInputChange(field) {
|
|
65
|
+
return function handleChange(event) {
|
|
66
|
+
const value = event.target.value;
|
|
67
|
+
if (field === "description") {
|
|
68
|
+
setEditedItem((prev) => ({ ...prev, [field]: value }));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// For numeric fields
|
|
72
|
+
if (value === "" || value === "0") {
|
|
73
|
+
setEditedItem((prev) => ({ ...prev, [field]: value }));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (field === "quantity") {
|
|
77
|
+
// Allow only integers for quantity
|
|
78
|
+
if (/^\d+$/.test(value)) {
|
|
79
|
+
setEditedItem((prev) => ({ ...prev, [field]: value }));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (field === "taxPercent") {
|
|
83
|
+
// Allow integers from 0-100 for tax percent, with more permissive validation
|
|
84
|
+
const numValue = parseInt(value, 10);
|
|
85
|
+
if (!isNaN(numValue) && numValue >= 0 && numValue <= 100) {
|
|
86
|
+
setEditedItem((prev) => ({ ...prev, [field]: value }));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (field === "unitPriceTaxExcl") {
|
|
90
|
+
// For unit price, allow up to dynamic decimal places based on currency
|
|
91
|
+
const maxDecimals = getCurrencyPrecision(currency);
|
|
92
|
+
const regex = new RegExp(`^-?\\d*\\.?\\d{0,${maxDecimals}}$`);
|
|
93
|
+
if (regex.test(value)) {
|
|
94
|
+
setEditedItem((prev) => ({ ...prev, [field]: value }));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// For other decimal fields
|
|
99
|
+
if (/^-?\d*\.?\d*$/.test(value)) {
|
|
100
|
+
setEditedItem((prev) => ({ ...prev, [field]: value }));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function handleSave() {
|
|
106
|
+
const quantity = typeof editedItem.quantity === "string"
|
|
107
|
+
? editedItem.quantity === ""
|
|
108
|
+
? 0
|
|
109
|
+
: Number(editedItem.quantity)
|
|
110
|
+
: (editedItem.quantity ?? 0);
|
|
111
|
+
const unitPriceTaxExcl = typeof editedItem.unitPriceTaxExcl === "string"
|
|
112
|
+
? editedItem.unitPriceTaxExcl === ""
|
|
113
|
+
? 0
|
|
114
|
+
: Number(editedItem.unitPriceTaxExcl)
|
|
115
|
+
: (editedItem.unitPriceTaxExcl ?? 0);
|
|
116
|
+
const taxPercent = typeof editedItem.taxPercent === "string"
|
|
117
|
+
? editedItem.taxPercent === ""
|
|
118
|
+
? 0
|
|
119
|
+
: Number(editedItem.taxPercent)
|
|
120
|
+
: (editedItem.taxPercent ?? 0);
|
|
121
|
+
const completeItem = {
|
|
122
|
+
id: editedItem.id ?? uuidv4(),
|
|
123
|
+
currency: editedItem.currency,
|
|
124
|
+
description: editedItem.description ?? "",
|
|
125
|
+
quantity: quantity,
|
|
126
|
+
taxPercent: taxPercent,
|
|
127
|
+
unitPriceTaxExcl: unitPriceTaxExcl,
|
|
128
|
+
unitPriceTaxIncl: calculatedValues.unitPriceTaxIncl,
|
|
129
|
+
totalPriceTaxExcl: calculatedValues.totalPriceTaxExcl,
|
|
130
|
+
totalPriceTaxIncl: calculatedValues.totalPriceTaxIncl,
|
|
131
|
+
};
|
|
132
|
+
onSave(completeItem);
|
|
133
|
+
}
|
|
134
|
+
return (_jsxs("tr", { ref: ref, className: "hover:bg-gray-50", children: [_jsx("td", { className: "border border-gray-200 p-3", children: _jsx(InputField, { onBlur: () => { }, handleInputChange: (e) => {
|
|
135
|
+
setEditedItem((prev) => ({ ...prev, description: e.target.value }));
|
|
136
|
+
}, value: editedItem.description ?? "", placeholder: "Description" }) }), _jsx("td", { className: "border border-gray-200 p-3", children: _jsx(NumberForm, { number: editedItem.quantity ?? "", precision: 0, handleInputChange: handleInputChange("quantity"), placeholder: "Quantity" }) }), _jsx("td", { className: "border border-gray-200 p-3", children: _jsx(NumberForm, { number: editedItem.unitPriceTaxExcl ?? "", precision: getCurrencyPrecision(currency), handleInputChange: handleInputChange("unitPriceTaxExcl"), placeholder: "Unit Price (excl. tax)" }) }), _jsx("td", { className: "border border-gray-200 p-3", children: _jsx(NumberForm, { number: editedItem.taxPercent ?? "", precision: 0, min: 0, max: 100, handleInputChange: handleInputChange("taxPercent"), placeholder: "Tax %" }) }), _jsx("td", { className: "border border-gray-200 p-3 text-right font-medium", children: formatNumber(calculatedValues.totalPriceTaxExcl) }), _jsx("td", { className: "border border-gray-200 p-3 text-right font-medium", children: formatNumber(calculatedValues.totalPriceTaxIncl) }), _jsx("td", { className: "border border-gray-200 p-3", children: _jsxs("div", { className: "flex space-x-2", children: [_jsx("button", { style: { backgroundColor: "blue" }, className: "rounded bg-blue-600 px-3 py-1 text-white hover:bg-blue-700", onClick: handleSave, children: "Save" }), _jsx("button", { className: "rounded bg-gray-500 px-3 py-1 text-white hover:bg-gray-600", onClick: onCancel, children: "Cancel" })] }) })] }));
|
|
137
|
+
});
|
|
138
|
+
export function LineItemsTable({ lineItems, currency, onAddItem, onUpdateItem, onDeleteItem, onUpdateCurrency, }) {
|
|
139
|
+
const [editingId, setEditingId] = useState(null);
|
|
140
|
+
const [isAddingNew, setIsAddingNew] = useState(false);
|
|
141
|
+
function handleAddClick() {
|
|
142
|
+
setIsAddingNew(true);
|
|
143
|
+
}
|
|
144
|
+
function handleSaveNewItem(item) {
|
|
145
|
+
onAddItem(item);
|
|
146
|
+
setIsAddingNew(false);
|
|
147
|
+
}
|
|
148
|
+
function handleCancelNewItem() {
|
|
149
|
+
setIsAddingNew(false);
|
|
150
|
+
}
|
|
151
|
+
return (_jsxs("div", { className: "mt-4", children: [_jsxs("div", { className: "mb-4 flex items-center justify-between", children: [_jsx("div", { className: "flex items-center gap-4", children: _jsx("h4", { className: "text-xl font-semibold text-gray-900", children: "Line Items" }) }), _jsx(RWAButton, { className: "mb-2", disabled: isAddingNew, onClick: handleAddClick, children: "Add Line Item" })] }), _jsx("div", { className: "overflow-x-auto rounded-lg border border-gray-200", children: _jsxs("table", { className: "w-full border-collapse bg-white", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "border-b border-gray-200 p-3 text-left", children: "Description" }), _jsx("th", { className: "border-b border-gray-200 p-3 text-right", children: "Quantity" }), _jsx("th", { className: "border-b border-gray-200 p-3 text-right", children: "Unit Price (excl. tax)" }), _jsx("th", { className: "border-b border-gray-200 p-3 text-right", children: "Tax %" }), _jsx("th", { className: "border-b border-gray-200 p-3 text-right", children: "Total (excl. tax)" }), _jsx("th", { className: "border-b border-gray-200 p-3 text-right", children: "Total (incl. tax)" }), _jsx("th", { className: "border-b border-gray-200 p-3 text-center", children: "Actions" })] }) }), _jsxs("tbody", { children: [lineItems.map((item) => editingId === item.id ? (_jsx(EditableLineItem, { currency: currency, item: item, onCancel: () => setEditingId(null), onSave: (updatedItem) => {
|
|
152
|
+
onUpdateItem(updatedItem);
|
|
153
|
+
setEditingId(null);
|
|
154
|
+
} }, item.id)) : (_jsxs("tr", { className: "hover:bg-gray-50", children: [_jsx("td", { className: "border-b border-gray-200 p-3", children: item.description }), _jsx("td", { className: "border-b border-gray-200 p-3 text-right", children: item.quantity }), _jsx("td", { className: "border-b border-gray-200 p-3 text-right", children: formatNumber(item.unitPriceTaxExcl) }), _jsxs("td", { className: "border-b border-gray-200 p-3 text-right", children: [typeof item.taxPercent === "number"
|
|
155
|
+
? Math.round(item.taxPercent)
|
|
156
|
+
: 0, "%"] }), _jsx("td", { className: "border-b border-gray-200 p-3 text-right font-medium", children: formatNumber(item.totalPriceTaxExcl) }), _jsx("td", { className: "border-b border-gray-200 p-3 text-right font-medium", children: formatNumber(item.totalPriceTaxIncl) }), _jsx("td", { className: "border-b border-gray-200 p-3", children: _jsxs("div", { className: "flex justify-center space-x-2", children: [_jsx("button", { style: { backgroundColor: "lightblue" }, className: "rounded bg-blue-600 px-3 py-1 text-white hover:bg-blue-700", onClick: () => setEditingId(item.id), children: "Edit" }), _jsx("button", { className: "rounded bg-red-600 px-3 py-1 text-white hover:bg-red-700", onClick: () => onDeleteItem({ id: item.id }), children: "Delete" })] }) })] }, item.id))), isAddingNew ? (_jsx(EditableLineItem, { currency: currency, item: {}, onCancel: handleCancelNewItem, onSave: handleSaveNewItem })) : null] })] }) })] }));
|
|
157
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestFinance.d.ts","sourceRoot":"","sources":["../../../editors/invoice/requestFinance.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAQxC,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,GAAG,CAAC;CACf;AAED,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA2MjD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
let GRAPHQL_URL = 'http://localhost:4001/graphql/invoice';
|
|
4
|
+
if (window.document.baseURI !== 'http://localhost:3000/') {
|
|
5
|
+
GRAPHQL_URL = 'https://switchboard-dev.powerhouse.xyz/graphql/invoice';
|
|
6
|
+
}
|
|
7
|
+
const RequestFinance = ({ docState }) => {
|
|
8
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
const [responseData, setResponseData] = useState(null);
|
|
11
|
+
const [invoiceLink, setInvoiceLink] = useState(null);
|
|
12
|
+
const [directPaymentStatus, setDirectPaymentStatus] = useState(null);
|
|
13
|
+
// Function to call the createDirectPayment mutation
|
|
14
|
+
const createDirectPayment = async (paymentData) => {
|
|
15
|
+
try {
|
|
16
|
+
// GraphQL mutation request
|
|
17
|
+
const response = await fetch(GRAPHQL_URL, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
},
|
|
22
|
+
body: JSON.stringify({
|
|
23
|
+
query: `
|
|
24
|
+
mutation Invoice_createRequestFinancePayment($paymentData: JSON!) {
|
|
25
|
+
Invoice_createRequestFinancePayment(paymentData: $paymentData) {
|
|
26
|
+
success
|
|
27
|
+
data
|
|
28
|
+
error
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`,
|
|
32
|
+
variables: {
|
|
33
|
+
paymentData,
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
const result = await response.json();
|
|
38
|
+
if (result.errors) {
|
|
39
|
+
throw new Error(result.errors[0].message);
|
|
40
|
+
}
|
|
41
|
+
if (result.data?.Invoice_createRequestFinancePayment?.success) {
|
|
42
|
+
setDirectPaymentStatus("Direct payment created successfully");
|
|
43
|
+
return result.data.Invoice_createRequestFinancePayment.data;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw new Error(result.data?.Invoice_createRequestFinancePayment?.error || "Unknown error");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
console.error("Error creating direct payment:", err);
|
|
51
|
+
setDirectPaymentStatus(`Error creating direct payment: ${err instanceof Error ? err.message : "Unknown error"}`);
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const handleRequestFinance = async () => {
|
|
56
|
+
console.log("state when request finance is clicked", docState);
|
|
57
|
+
setIsLoading(true);
|
|
58
|
+
setError(null);
|
|
59
|
+
setInvoiceLink(null);
|
|
60
|
+
setDirectPaymentStatus(null);
|
|
61
|
+
const bankDetails = {
|
|
62
|
+
currency: docState.currency,
|
|
63
|
+
accountNumber: docState.issuer.paymentRouting.bank.accountNum,
|
|
64
|
+
country: docState.issuer.paymentRouting.bank.address.country.toUpperCase(),
|
|
65
|
+
bankName: docState.issuer.paymentRouting.bank.name,
|
|
66
|
+
firstName: docState.issuer.paymentRouting.bank.beneficiary.split(" ")[0] ||
|
|
67
|
+
"Liberuum",
|
|
68
|
+
lastName: docState.issuer.paymentRouting.bank.beneficiary.split(" ")[1] ||
|
|
69
|
+
"Liberty",
|
|
70
|
+
bicSwift: docState.issuer.paymentRouting.bank.BIC,
|
|
71
|
+
};
|
|
72
|
+
try {
|
|
73
|
+
const invoiceData = {
|
|
74
|
+
meta: {
|
|
75
|
+
format: "rnf_generic",
|
|
76
|
+
version: "0.0.3",
|
|
77
|
+
},
|
|
78
|
+
creationDate: docState.dateIssued,
|
|
79
|
+
invoiceItems: docState.lineItems.map((item) => ({
|
|
80
|
+
currency: bankDetails.currency,
|
|
81
|
+
name: item.description,
|
|
82
|
+
quantity: item.quantity,
|
|
83
|
+
unitPrice: item.totalPriceTaxIncl * 100,
|
|
84
|
+
})),
|
|
85
|
+
invoiceNumber: docState.invoiceNo,
|
|
86
|
+
buyerInfo: {
|
|
87
|
+
email: docState.payer.contactInfo.email,
|
|
88
|
+
firstName: docState.payer.name,
|
|
89
|
+
// lastName: docState.payer.name.split(" ")[1] || "Liberty",
|
|
90
|
+
businessName: docState.payer.name,
|
|
91
|
+
address: {
|
|
92
|
+
country: docState.payer.address.country,
|
|
93
|
+
city: docState.payer.address.city,
|
|
94
|
+
streetAddress: docState.payer.address.streetAddress,
|
|
95
|
+
extendedAddress: docState.payer.address.extendedAddress,
|
|
96
|
+
postalCode: docState.payer.address.postalCode,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
sellerInfo: {
|
|
100
|
+
email: docState.issuer.contactInfo.email,
|
|
101
|
+
firstName: docState.issuer.name,
|
|
102
|
+
lastName: '',
|
|
103
|
+
address: {
|
|
104
|
+
country: docState.issuer.address.country,
|
|
105
|
+
city: docState.issuer.address.city,
|
|
106
|
+
streetAddress: docState.issuer.address.streetAddress,
|
|
107
|
+
extendedAddress: docState.issuer.address.extendedAddress,
|
|
108
|
+
postalCode: docState.issuer.address.postalCode,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
paymentOptions: [
|
|
112
|
+
{
|
|
113
|
+
type: "bank-account",
|
|
114
|
+
value: {
|
|
115
|
+
currency: bankDetails.currency,
|
|
116
|
+
paymentInformation: {
|
|
117
|
+
bankAccountDetails: {
|
|
118
|
+
accountNumber: bankDetails.accountNumber, // the IBAN
|
|
119
|
+
country: bankDetails.country,
|
|
120
|
+
currency: bankDetails.currency,
|
|
121
|
+
bankName: bankDetails.bankName,
|
|
122
|
+
firstName: bankDetails.firstName,
|
|
123
|
+
lastName: bankDetails.lastName,
|
|
124
|
+
bicSwift: bankDetails.bicSwift,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
// Instead of calling the API endpoint directly, use the createDirectPayment function
|
|
132
|
+
const directPaymentResult = await createDirectPayment(invoiceData);
|
|
133
|
+
console.log("Direct payment created:", directPaymentResult);
|
|
134
|
+
// Process the response
|
|
135
|
+
if (directPaymentResult?.response?.invoiceLinks?.pay) {
|
|
136
|
+
setInvoiceLink(directPaymentResult.response.invoiceLinks.pay);
|
|
137
|
+
}
|
|
138
|
+
setResponseData(directPaymentResult);
|
|
139
|
+
setDirectPaymentStatus("Direct payment created successfully");
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
// Handle error with proper typing
|
|
143
|
+
let errorMessage = "An error occurred";
|
|
144
|
+
if (err instanceof Error) {
|
|
145
|
+
errorMessage = err.message;
|
|
146
|
+
}
|
|
147
|
+
setError(errorMessage);
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
setIsLoading(false);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
return (_jsxs("div", { children: [_jsx("button", { className: "bg-blue-500 text-black px-4 py-2 rounded-md", onClick: handleRequestFinance, disabled: isLoading, children: isLoading ? "Processing..." : "Send Payment to Request Finance >" }), error && (_jsx("div", { className: "error-message", style: { color: "red" }, children: error })), invoiceLink && (_jsxs("div", { children: [_jsx("div", { className: "direct-payment-status", children: _jsx("p", { children: directPaymentStatus }) }), _jsx("div", { className: "invoice-link", children: _jsx("a", { style: { color: "blue" }, href: invoiceLink, target: "_blank", rel: "noopener noreferrer", className: "view-invoice-button", children: "View Invoice" }) })] }))] }));
|
|
154
|
+
};
|
|
155
|
+
export default RequestFinance;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility function to upload a PDF file in chunks
|
|
3
|
+
* @param pdfData Base64 encoded PDF data
|
|
4
|
+
* @param endpoint GraphQL endpoint
|
|
5
|
+
* @param chunkSize Size of each chunk in bytes (default: 500KB)
|
|
6
|
+
* @param onProgress Callback for upload progress
|
|
7
|
+
*/
|
|
8
|
+
export declare function uploadPdfChunked(pdfData: string, endpoint?: string, chunkSize?: number, // 500KB chunks
|
|
9
|
+
onProgress?: (progress: number) => void): Promise<any>;
|
|
10
|
+
//# sourceMappingURL=uploadPdfChunked.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadPdfChunked.d.ts","sourceRoot":"","sources":["../../../editors/invoice/uploadPdfChunked.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,MAAoB,EAC9B,SAAS,GAAE,MAAmB,EAAE,eAAe;AAC/C,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GACtC,OAAO,CAAC,GAAG,CAAC,CA6Ed"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility function to upload a PDF file in chunks
|
|
3
|
+
* @param pdfData Base64 encoded PDF data
|
|
4
|
+
* @param endpoint GraphQL endpoint
|
|
5
|
+
* @param chunkSize Size of each chunk in bytes (default: 500KB)
|
|
6
|
+
* @param onProgress Callback for upload progress
|
|
7
|
+
*/
|
|
8
|
+
let GRAPHQL_URL = 'http://localhost:4001/graphql/invoice';
|
|
9
|
+
if (window.document.baseURI !== 'http://localhost:3000/') {
|
|
10
|
+
GRAPHQL_URL = 'https://switchboard-dev.powerhouse.xyz/graphql/invoice';
|
|
11
|
+
}
|
|
12
|
+
export async function uploadPdfChunked(pdfData, endpoint = GRAPHQL_URL, chunkSize = 500 * 1024, // 500KB chunks
|
|
13
|
+
onProgress) {
|
|
14
|
+
// Generate a unique session ID for this upload
|
|
15
|
+
const sessionId = `upload_${Date.now()}_${Math.random().toString(36).substring(2, 10)}`;
|
|
16
|
+
const fileName = `invoice_${Date.now()}.pdf`;
|
|
17
|
+
// Calculate total chunks
|
|
18
|
+
const totalChunks = Math.ceil(pdfData.length / chunkSize);
|
|
19
|
+
console.log(`Splitting file into ${totalChunks} chunks of ${chunkSize} bytes each`);
|
|
20
|
+
// Upload each chunk
|
|
21
|
+
const results = [];
|
|
22
|
+
for (let i = 0; i < totalChunks; i++) {
|
|
23
|
+
const start = i * chunkSize;
|
|
24
|
+
const end = Math.min(start + chunkSize, pdfData.length);
|
|
25
|
+
const chunk = pdfData.substring(start, end);
|
|
26
|
+
const response = await fetch(endpoint, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: {
|
|
29
|
+
"Content-Type": "application/json",
|
|
30
|
+
},
|
|
31
|
+
body: JSON.stringify({
|
|
32
|
+
query: `
|
|
33
|
+
mutation Invoice_uploadInvoicePdfChunk(
|
|
34
|
+
$chunk: String!
|
|
35
|
+
$chunkIndex: Int!
|
|
36
|
+
$totalChunks: Int!
|
|
37
|
+
$fileName: String!
|
|
38
|
+
$sessionId: String!
|
|
39
|
+
) {
|
|
40
|
+
Invoice_uploadInvoicePdfChunk(
|
|
41
|
+
chunk: $chunk
|
|
42
|
+
chunkIndex: $chunkIndex
|
|
43
|
+
totalChunks: $totalChunks
|
|
44
|
+
fileName: $fileName
|
|
45
|
+
sessionId: $sessionId
|
|
46
|
+
) {
|
|
47
|
+
success
|
|
48
|
+
data
|
|
49
|
+
error
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`,
|
|
53
|
+
variables: {
|
|
54
|
+
chunk,
|
|
55
|
+
chunkIndex: i,
|
|
56
|
+
totalChunks,
|
|
57
|
+
fileName,
|
|
58
|
+
sessionId,
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
const result = await response.json();
|
|
63
|
+
results.push(result);
|
|
64
|
+
// Call progress callback if provided
|
|
65
|
+
if (onProgress) {
|
|
66
|
+
onProgress(((i + 1) / totalChunks) * 100);
|
|
67
|
+
}
|
|
68
|
+
// If this is the last chunk and it was successful, return the final result
|
|
69
|
+
if (i === totalChunks - 1 && result.data?.Invoice_uploadInvoicePdfChunk?.success) {
|
|
70
|
+
return result.data.Invoice_uploadInvoicePdfChunk;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// If we get here, something went wrong
|
|
74
|
+
const lastResult = results[results.length - 1];
|
|
75
|
+
return (lastResult?.data?.Invoice_uploadInvoicePdfChunk || {
|
|
76
|
+
success: false,
|
|
77
|
+
error: "Failed to upload all chunks",
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/utils/utils.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,GACjC,aAAa,MAAM,GAAG,SAAS,GAAG,IAAI,KACrC,MA8DF,CAAC"}
|