@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,54 @@
|
|
|
1
|
+
import countries from "world-countries";
|
|
2
|
+
const countriesArray = countries;
|
|
3
|
+
// Function to convert country name to country code
|
|
4
|
+
export const getCountryCodeFromName = (countryName) => {
|
|
5
|
+
if (!countryName)
|
|
6
|
+
return "";
|
|
7
|
+
// Special case handling for common abbreviations and alternative names
|
|
8
|
+
const specialCases = {
|
|
9
|
+
uk: "GB",
|
|
10
|
+
"united kingdom": "GB",
|
|
11
|
+
england: "GB",
|
|
12
|
+
britain: "GB",
|
|
13
|
+
deutschland: "DE",
|
|
14
|
+
germany: "DE",
|
|
15
|
+
usa: "US",
|
|
16
|
+
"united states of america": "US",
|
|
17
|
+
america: "US",
|
|
18
|
+
};
|
|
19
|
+
const lowerCountryName = countryName.toLowerCase().trim();
|
|
20
|
+
// Check special cases first
|
|
21
|
+
if (specialCases[lowerCountryName]) {
|
|
22
|
+
return specialCases[lowerCountryName];
|
|
23
|
+
}
|
|
24
|
+
// Check if input is already a valid country code (2-letter code)
|
|
25
|
+
if (countryName.length === 2 && /^[A-Z]{2}$/.test(countryName)) {
|
|
26
|
+
const isValidCode = countriesArray.some((c) => c.cca2 === countryName);
|
|
27
|
+
if (isValidCode)
|
|
28
|
+
return countryName;
|
|
29
|
+
}
|
|
30
|
+
// Try exact match first (case-insensitive)
|
|
31
|
+
const exactMatch = countriesArray.find((c) => c.name.common.toLowerCase() === lowerCountryName);
|
|
32
|
+
if (exactMatch)
|
|
33
|
+
return exactMatch.cca2;
|
|
34
|
+
// Try official name match
|
|
35
|
+
const officialMatch = countriesArray.find((c) => c.name.official.toLowerCase() === lowerCountryName);
|
|
36
|
+
if (officialMatch)
|
|
37
|
+
return officialMatch.cca2;
|
|
38
|
+
// Try native name matches
|
|
39
|
+
const nativeMatch = countriesArray.find((c) => {
|
|
40
|
+
if (!c.name.native)
|
|
41
|
+
return false;
|
|
42
|
+
return Object.values(c.name.native).some((n) => n.common.toLowerCase() === lowerCountryName ||
|
|
43
|
+
n.official.toLowerCase() === lowerCountryName);
|
|
44
|
+
});
|
|
45
|
+
if (nativeMatch)
|
|
46
|
+
return nativeMatch.cca2;
|
|
47
|
+
// Try partial match if no exact match found
|
|
48
|
+
const partialMatch = countriesArray.find((c) => c.name.common.toLowerCase().includes(lowerCountryName) ||
|
|
49
|
+
lowerCountryName.includes(c.name.common.toLowerCase()));
|
|
50
|
+
if (partialMatch)
|
|
51
|
+
return partialMatch.cca2;
|
|
52
|
+
// If no match found, return original value
|
|
53
|
+
return countryName;
|
|
54
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Status } from "../../../document-models/invoice/index.js";
|
|
2
|
+
export type ValidationSeverity = 'error' | 'warning' | 'none';
|
|
3
|
+
export type ValidationResult = {
|
|
4
|
+
isValid: boolean;
|
|
5
|
+
message: string;
|
|
6
|
+
severity: ValidationSeverity;
|
|
7
|
+
};
|
|
8
|
+
export type ValidationRule = {
|
|
9
|
+
field: string;
|
|
10
|
+
validate: (value: any, context?: any) => ValidationResult;
|
|
11
|
+
appliesTo: {
|
|
12
|
+
currencies: Array<string | 'ALL'>;
|
|
13
|
+
statusTransitions: {
|
|
14
|
+
from: Status[];
|
|
15
|
+
to: Status[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type ValidationContext = {
|
|
20
|
+
currency: string;
|
|
21
|
+
currentStatus: Status;
|
|
22
|
+
targetStatus: Status;
|
|
23
|
+
};
|
|
24
|
+
export declare function validateField(field: string, value: any, context: ValidationContext): ValidationResult | null;
|
|
25
|
+
export declare function validateStatusTransition(fields: Record<string, any>, context: ValidationContext): Record<string, ValidationResult>;
|
|
26
|
+
export declare function addValidationRule(rule: ValidationRule): void;
|
|
27
|
+
export declare function removeValidationRule(field: string): void;
|
|
28
|
+
//# sourceMappingURL=validationManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validationManager.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/validation/validationManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAInE,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,kBAAkB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,gBAAgB,CAAC;IAC1D,SAAS,EAAE;QACP,UAAU,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;QAClC,iBAAiB,EAAE;YACf,IAAI,EAAE,MAAM,EAAE,CAAC;YACf,EAAE,EAAE,MAAM,EAAE,CAAC;SAChB,CAAC;KACL,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACxB,CAAC;AA8BF,wBAAgB,aAAa,CACzB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,GAAG,EACV,OAAO,EAAE,iBAAiB,GAC3B,gBAAgB,GAAG,IAAI,CAqBzB;AAGD,wBAAgB,wBAAwB,CACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,OAAO,EAAE,iBAAiB,GAC3B,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAalC;AAGD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAE5D;AAGD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAKxD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { accountNumberRule, bicNumberRule, bankNameRule, countryRule, currencyRule, ethereumAddressRule, invoiceNumberRule, issuerPostalCodeRule, issuerStreetAddressRule, issuerCityRule, payerEmailRule, lineItemRule } from "./validationRules.js";
|
|
2
|
+
// Validation rules registry
|
|
3
|
+
const validationRules = [];
|
|
4
|
+
// Register rules
|
|
5
|
+
validationRules.push(invoiceNumberRule);
|
|
6
|
+
validationRules.push(ethereumAddressRule);
|
|
7
|
+
validationRules.push(currencyRule);
|
|
8
|
+
validationRules.push(countryRule);
|
|
9
|
+
validationRules.push(accountNumberRule);
|
|
10
|
+
validationRules.push(bicNumberRule);
|
|
11
|
+
validationRules.push(bankNameRule);
|
|
12
|
+
validationRules.push(issuerStreetAddressRule);
|
|
13
|
+
validationRules.push(issuerCityRule);
|
|
14
|
+
validationRules.push(issuerPostalCodeRule);
|
|
15
|
+
validationRules.push(payerEmailRule);
|
|
16
|
+
validationRules.push(lineItemRule);
|
|
17
|
+
// Helper to check if a rule applies to the current context
|
|
18
|
+
function ruleAppliesToContext(rule, context) {
|
|
19
|
+
const { currencies, statusTransitions } = rule.appliesTo;
|
|
20
|
+
const currencyMatches = currencies.includes('ALL') || currencies.includes(context.currency);
|
|
21
|
+
const statusMatches = statusTransitions.from.includes(context.currentStatus) &&
|
|
22
|
+
statusTransitions.to.includes(context.targetStatus);
|
|
23
|
+
return currencyMatches && statusMatches;
|
|
24
|
+
}
|
|
25
|
+
// Main validation function
|
|
26
|
+
export function validateField(field, value, context) {
|
|
27
|
+
const applicableRules = validationRules.filter(rule => rule.field === field && ruleAppliesToContext(rule, context));
|
|
28
|
+
if (applicableRules.length === 0) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
// Run all applicable rules and return the first failure or the last success
|
|
32
|
+
let lastResult = null;
|
|
33
|
+
for (const rule of applicableRules) {
|
|
34
|
+
const result = rule.validate(value);
|
|
35
|
+
if (!result.isValid) {
|
|
36
|
+
return result; // Return first failure
|
|
37
|
+
}
|
|
38
|
+
lastResult = result;
|
|
39
|
+
}
|
|
40
|
+
return lastResult;
|
|
41
|
+
}
|
|
42
|
+
// Validate all fields for a status transition
|
|
43
|
+
export function validateStatusTransition(fields, context) {
|
|
44
|
+
const results = {};
|
|
45
|
+
validationRules.forEach(rule => {
|
|
46
|
+
if (ruleAppliesToContext(rule, context)) {
|
|
47
|
+
const result = rule.validate(fields[rule.field]);
|
|
48
|
+
if (!result.isValid) {
|
|
49
|
+
results[rule.field] = result;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return results;
|
|
54
|
+
}
|
|
55
|
+
// Add a new validation rule
|
|
56
|
+
export function addValidationRule(rule) {
|
|
57
|
+
validationRules.push(rule);
|
|
58
|
+
}
|
|
59
|
+
// Remove a validation rule
|
|
60
|
+
export function removeValidationRule(field) {
|
|
61
|
+
const index = validationRules.findIndex(rule => rule.field === field);
|
|
62
|
+
if (index !== -1) {
|
|
63
|
+
validationRules.splice(index, 1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ValidationRule } from "./validationManager.js";
|
|
2
|
+
export declare const invoiceNumberRule: ValidationRule;
|
|
3
|
+
export declare const ethereumAddressRule: ValidationRule;
|
|
4
|
+
export declare const currencyRule: ValidationRule;
|
|
5
|
+
export declare const countryRule: ValidationRule;
|
|
6
|
+
export declare const accountNumberRule: ValidationRule;
|
|
7
|
+
export declare const bicNumberRule: ValidationRule;
|
|
8
|
+
export declare const bankNameRule: ValidationRule;
|
|
9
|
+
export declare const issuerStreetAddressRule: ValidationRule;
|
|
10
|
+
export declare const issuerCityRule: ValidationRule;
|
|
11
|
+
export declare const issuerPostalCodeRule: ValidationRule;
|
|
12
|
+
export declare const payerEmailRule: ValidationRule;
|
|
13
|
+
export declare const lineItemRule: ValidationRule;
|
|
14
|
+
//# sourceMappingURL=validationRules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validationRules.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/validation/validationRules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAmBxD,eAAO,MAAM,iBAAiB,EAAE,cAuB/B,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAE,cA8BjC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAuB1B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,cAuBzB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cA8B/B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,cAkC3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAuB1B,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,cAuBrC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAuB5B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,cAuBlC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cA8B5B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAuB1B,CAAC"}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
// Helper function to validate Ethereum address
|
|
2
|
+
function isValidEthereumAddress(address) {
|
|
3
|
+
const ethereumAddressRegex = /^0x[a-fA-F0-9]{40}$/;
|
|
4
|
+
return ethereumAddressRegex.test(address);
|
|
5
|
+
}
|
|
6
|
+
function isValidIBAN(iban) {
|
|
7
|
+
const ibanRegex = /^([A-Z]{2}[0-9]{2})(?=(?:[A-Z0-9]){9,30}$)((?:[A-Z0-9]{3,5}){2,7})([A-Z0-9]{1,3})?$/;
|
|
8
|
+
return ibanRegex.test(iban);
|
|
9
|
+
}
|
|
10
|
+
function isValidEmail(email) {
|
|
11
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
12
|
+
return emailRegex.test(email);
|
|
13
|
+
}
|
|
14
|
+
// Invoice number validation rule
|
|
15
|
+
export const invoiceNumberRule = {
|
|
16
|
+
field: 'invoiceNo',
|
|
17
|
+
validate: (value) => {
|
|
18
|
+
if (!value || value.trim() === '') {
|
|
19
|
+
return {
|
|
20
|
+
isValid: false,
|
|
21
|
+
message: 'Invoice number is required',
|
|
22
|
+
severity: 'warning'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
isValid: true,
|
|
27
|
+
message: '',
|
|
28
|
+
severity: 'none'
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
appliesTo: {
|
|
32
|
+
currencies: ['ALL'],
|
|
33
|
+
statusTransitions: {
|
|
34
|
+
from: ['DRAFT'],
|
|
35
|
+
to: ['ISSUED']
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
// Ethereum address validation rule
|
|
40
|
+
export const ethereumAddressRule = {
|
|
41
|
+
field: 'address',
|
|
42
|
+
validate: (value) => {
|
|
43
|
+
if (!value || value.trim() === '') {
|
|
44
|
+
return {
|
|
45
|
+
isValid: false,
|
|
46
|
+
message: 'Wallet address is required',
|
|
47
|
+
severity: 'error'
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (!isValidEthereumAddress(value)) {
|
|
51
|
+
return {
|
|
52
|
+
isValid: false,
|
|
53
|
+
message: 'Invalid Ethereum address format',
|
|
54
|
+
severity: 'warning'
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
isValid: true,
|
|
59
|
+
message: '',
|
|
60
|
+
severity: 'none'
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
appliesTo: {
|
|
64
|
+
currencies: ['USDS', 'DAI'], // Only apply for crypto currencies
|
|
65
|
+
statusTransitions: {
|
|
66
|
+
from: ['DRAFT'],
|
|
67
|
+
to: ['ISSUED']
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
export const currencyRule = {
|
|
72
|
+
field: 'currency',
|
|
73
|
+
validate: (value) => {
|
|
74
|
+
if (!value || value.trim() === '') {
|
|
75
|
+
return {
|
|
76
|
+
isValid: false,
|
|
77
|
+
message: 'Currency is required',
|
|
78
|
+
severity: 'warning'
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
isValid: true,
|
|
83
|
+
message: '',
|
|
84
|
+
severity: 'none'
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
appliesTo: {
|
|
88
|
+
currencies: ['ALL'],
|
|
89
|
+
statusTransitions: {
|
|
90
|
+
from: ['DRAFT'],
|
|
91
|
+
to: ['ISSUED']
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
export const countryRule = {
|
|
96
|
+
field: 'country',
|
|
97
|
+
validate: (value) => {
|
|
98
|
+
if (!value || value.trim() === '') {
|
|
99
|
+
return {
|
|
100
|
+
isValid: false,
|
|
101
|
+
message: 'Country is required',
|
|
102
|
+
severity: 'warning'
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
isValid: true,
|
|
107
|
+
message: '',
|
|
108
|
+
severity: 'none'
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
appliesTo: {
|
|
112
|
+
currencies: ['USD', 'EUR', 'GBP', 'JPY', 'CNY', 'CHF'],
|
|
113
|
+
statusTransitions: {
|
|
114
|
+
from: ['DRAFT'],
|
|
115
|
+
to: ['ISSUED']
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
export const accountNumberRule = {
|
|
120
|
+
field: 'accountNum',
|
|
121
|
+
validate: (value) => {
|
|
122
|
+
if (!value || value.trim() === '') {
|
|
123
|
+
return {
|
|
124
|
+
isValid: false,
|
|
125
|
+
message: 'Account number is required',
|
|
126
|
+
severity: 'warning'
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (!isValidIBAN(value)) {
|
|
130
|
+
return {
|
|
131
|
+
isValid: false,
|
|
132
|
+
message: 'Invalid IBAN format - Remove spaces and/or dashes',
|
|
133
|
+
severity: 'warning'
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
isValid: true,
|
|
138
|
+
message: '',
|
|
139
|
+
severity: 'none'
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
appliesTo: {
|
|
143
|
+
currencies: ['EUR', 'GBP'],
|
|
144
|
+
statusTransitions: {
|
|
145
|
+
from: ['DRAFT'],
|
|
146
|
+
to: ['ISSUED']
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
export const bicNumberRule = {
|
|
151
|
+
field: 'bicNumber',
|
|
152
|
+
validate: (value) => {
|
|
153
|
+
if (!value || value.trim() === '') {
|
|
154
|
+
return {
|
|
155
|
+
isValid: false,
|
|
156
|
+
message: 'BIC number is required',
|
|
157
|
+
severity: 'warning'
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (value) {
|
|
161
|
+
const bicRegex = /^[a-zA-Z]{6}[a-zA-Z0-9]{2}([a-zA-Z0-9]{3})?$/i;
|
|
162
|
+
if (!bicRegex.test(value)) {
|
|
163
|
+
return {
|
|
164
|
+
isValid: false,
|
|
165
|
+
message: 'Invalid BIC number format',
|
|
166
|
+
severity: 'warning'
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
isValid: true,
|
|
172
|
+
message: '',
|
|
173
|
+
severity: 'none'
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
appliesTo: {
|
|
177
|
+
currencies: ['EUR', 'GBP'],
|
|
178
|
+
statusTransitions: {
|
|
179
|
+
from: ['DRAFT'],
|
|
180
|
+
to: ['ISSUED']
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
export const bankNameRule = {
|
|
185
|
+
field: 'bankName',
|
|
186
|
+
validate: (value) => {
|
|
187
|
+
if (!value || value.trim() === '') {
|
|
188
|
+
return {
|
|
189
|
+
isValid: false,
|
|
190
|
+
message: 'Bank name is required',
|
|
191
|
+
severity: 'warning'
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
isValid: true,
|
|
196
|
+
message: '',
|
|
197
|
+
severity: 'none'
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
appliesTo: {
|
|
201
|
+
currencies: ['USD', 'EUR', 'GBP', 'JPY', 'CNY', 'CHF'],
|
|
202
|
+
statusTransitions: {
|
|
203
|
+
from: ['DRAFT'],
|
|
204
|
+
to: ['ISSUED']
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
export const issuerStreetAddressRule = {
|
|
209
|
+
field: 'streetAddress',
|
|
210
|
+
validate: (value) => {
|
|
211
|
+
if (!value || value.trim() === '') {
|
|
212
|
+
return {
|
|
213
|
+
isValid: false,
|
|
214
|
+
message: 'Street address is required',
|
|
215
|
+
severity: 'warning'
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
isValid: true,
|
|
220
|
+
message: '',
|
|
221
|
+
severity: 'none'
|
|
222
|
+
};
|
|
223
|
+
},
|
|
224
|
+
appliesTo: {
|
|
225
|
+
currencies: ['USD', 'EUR', 'GBP', 'JPY', 'CNY', 'CHF'],
|
|
226
|
+
statusTransitions: {
|
|
227
|
+
from: ['DRAFT'],
|
|
228
|
+
to: ['ISSUED']
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
export const issuerCityRule = {
|
|
233
|
+
field: 'city',
|
|
234
|
+
validate: (value) => {
|
|
235
|
+
if (!value || value.trim() === '') {
|
|
236
|
+
return {
|
|
237
|
+
isValid: false,
|
|
238
|
+
message: 'City is required',
|
|
239
|
+
severity: 'warning'
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
isValid: true,
|
|
244
|
+
message: '',
|
|
245
|
+
severity: 'none'
|
|
246
|
+
};
|
|
247
|
+
},
|
|
248
|
+
appliesTo: {
|
|
249
|
+
currencies: ['USD', 'EUR', 'GBP', 'JPY', 'CNY', 'CHF'],
|
|
250
|
+
statusTransitions: {
|
|
251
|
+
from: ['DRAFT'],
|
|
252
|
+
to: ['ISSUED']
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
export const issuerPostalCodeRule = {
|
|
257
|
+
field: 'postalCode',
|
|
258
|
+
validate: (value) => {
|
|
259
|
+
if (!value || value.trim() === '') {
|
|
260
|
+
return {
|
|
261
|
+
isValid: false,
|
|
262
|
+
message: 'Postal code is required',
|
|
263
|
+
severity: 'warning'
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
isValid: true,
|
|
268
|
+
message: '',
|
|
269
|
+
severity: 'none'
|
|
270
|
+
};
|
|
271
|
+
},
|
|
272
|
+
appliesTo: {
|
|
273
|
+
currencies: ['USD', 'EUR', 'GBP', 'JPY', 'CNY', 'CHF'],
|
|
274
|
+
statusTransitions: {
|
|
275
|
+
from: ['DRAFT'],
|
|
276
|
+
to: ['ISSUED']
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
export const payerEmailRule = {
|
|
281
|
+
field: 'email',
|
|
282
|
+
validate: (value) => {
|
|
283
|
+
if (!value || value.trim() === '') {
|
|
284
|
+
return {
|
|
285
|
+
isValid: false,
|
|
286
|
+
message: 'Email is required',
|
|
287
|
+
severity: 'warning'
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
if (!isValidEmail(value)) {
|
|
291
|
+
return {
|
|
292
|
+
isValid: false,
|
|
293
|
+
message: 'Invalid email format',
|
|
294
|
+
severity: 'warning'
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
isValid: true,
|
|
299
|
+
message: '',
|
|
300
|
+
severity: 'none'
|
|
301
|
+
};
|
|
302
|
+
},
|
|
303
|
+
appliesTo: {
|
|
304
|
+
currencies: ['USD', 'EUR', 'GBP', 'JPY', 'CNY', 'CHF'],
|
|
305
|
+
statusTransitions: {
|
|
306
|
+
from: ['DRAFT'],
|
|
307
|
+
to: ['ISSUED']
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
export const lineItemRule = {
|
|
312
|
+
field: 'lineItem',
|
|
313
|
+
validate: (value) => {
|
|
314
|
+
if (value.length === 0) {
|
|
315
|
+
return {
|
|
316
|
+
isValid: false,
|
|
317
|
+
message: 'Line item is required - Add at least one line item',
|
|
318
|
+
severity: 'warning'
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
isValid: true,
|
|
323
|
+
message: '',
|
|
324
|
+
severity: 'none'
|
|
325
|
+
};
|
|
326
|
+
},
|
|
327
|
+
appliesTo: {
|
|
328
|
+
currencies: ['USD', 'EUR', 'GBP', 'JPY', 'CNY', 'CHF'],
|
|
329
|
+
statusTransitions: {
|
|
330
|
+
from: ['DRAFT'],
|
|
331
|
+
to: ['ISSUED']
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Manifest } from "document-model";
|
|
2
|
+
export declare const manifest: Manifest;
|
|
3
|
+
export declare const documentModels: import("document-model").DocumentModelModule<import("./document-models/invoice/index.js").InvoiceDocument>[];
|
|
4
|
+
export declare const editors: (import("document-model").EditorModule<import("./document-models/invoice/index.js").InvoiceDocument> | import("@powerhousedao/reactor-browser").DriveEditorModule<import("document-drive").DocumentDriveDocument>)[];
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK1C,eAAO,MAAM,QAAQ,EAAE,QAAuB,CAAC;AAC/C,eAAO,MAAM,cAAc,8GAAuC,CAAC;AACnE,eAAO,MAAM,OAAO,sNAAgC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import manifestJson from "./powerhouse.manifest.json" with { type: "json" };
|
|
2
|
+
import * as documentModelsExports from './document-models/index.js';
|
|
3
|
+
import * as editorsExports from './editors/index.js';
|
|
4
|
+
export const manifest = manifestJson;
|
|
5
|
+
export const documentModels = Object.values(documentModelsExports);
|
|
6
|
+
export const editors = Object.values(editorsExports);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Contributor Billing",
|
|
3
|
+
"description": "The invoice package offers contributors of decentralized and open organisations a way to get paid via their legal entity or governmental identity. ",
|
|
4
|
+
"category": "Workforce",
|
|
5
|
+
"publisher": {
|
|
6
|
+
"name": "Powerhouse",
|
|
7
|
+
"url": "https://www.powerhouse.inc/"
|
|
8
|
+
},
|
|
9
|
+
"documentModels": [
|
|
10
|
+
{
|
|
11
|
+
"id": "powerhouse/invoice",
|
|
12
|
+
"name": "Invoice"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"editors": [
|
|
16
|
+
{
|
|
17
|
+
"id": "powerhouse/invoice-editor",
|
|
18
|
+
"name": "Invoice",
|
|
19
|
+
"documentTypes": ["powerhouse/invoice"]
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"apps": [
|
|
23
|
+
{
|
|
24
|
+
"id": "contributor-billing",
|
|
25
|
+
"name": "Contributor Billing",
|
|
26
|
+
"driveEditor": "contributor-billing"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"subgraphs": [],
|
|
30
|
+
"importScripts": []
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../processors/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exampleBatchTxn.d.ts","sourceRoot":"","sources":["../../../scripts/invoice/exampleBatchTxn.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { executeTransferProposal } from './gnosisTransactionBuilder.js';
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
async function testBatchTransfer() {
|
|
5
|
+
try {
|
|
6
|
+
const payerWallet = {
|
|
7
|
+
rpc: 'https://mainnet.base.org', // Base mainnet RPC
|
|
8
|
+
chainName: 'Base',
|
|
9
|
+
chainId: '8453',
|
|
10
|
+
address: '0x1FB6bEF04230d67aF0e3455B997a28AFcCe1F45e',
|
|
11
|
+
};
|
|
12
|
+
const paymentDetails = [
|
|
13
|
+
{
|
|
14
|
+
payeeWallet: {
|
|
15
|
+
address: '0x48f208afD0Abeacd4e7C8839Ea19e3CcCF0433DE',
|
|
16
|
+
},
|
|
17
|
+
token: {
|
|
18
|
+
symbol: 'USDS',
|
|
19
|
+
evmAddress: '0x820C137fa70C8691f0e44Dc420a5e53c168921Dc',
|
|
20
|
+
decimals: 6,
|
|
21
|
+
},
|
|
22
|
+
amount: '10',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
payeeWallet: {
|
|
26
|
+
address: '0x48f208afD0Abeacd4e7C8839Ea19e3CcCF0433DE',
|
|
27
|
+
},
|
|
28
|
+
token: {
|
|
29
|
+
symbol: 'USDS',
|
|
30
|
+
evmAddress: '0x820C137fa70C8691f0e44Dc420a5e53c168921Dc',
|
|
31
|
+
decimals: 6,
|
|
32
|
+
},
|
|
33
|
+
amount: '15.5',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
const result = await executeTransferProposal(payerWallet, paymentDetails);
|
|
37
|
+
console.log('\n✅ Batch transaction proposed successfully:');
|
|
38
|
+
console.log(result);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
console.error('\n❌ Batch transaction test failed:', err);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
testBatchTransfer();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface PayerWallet {
|
|
2
|
+
rpc: string;
|
|
3
|
+
chainName: string;
|
|
4
|
+
chainId: string;
|
|
5
|
+
address: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PayeeWallet {
|
|
8
|
+
address: string;
|
|
9
|
+
}
|
|
10
|
+
export interface TokenInfo {
|
|
11
|
+
symbol: string;
|
|
12
|
+
evmAddress: string;
|
|
13
|
+
decimals: number;
|
|
14
|
+
}
|
|
15
|
+
export interface PaymentDetail {
|
|
16
|
+
payeeWallet: PayeeWallet;
|
|
17
|
+
token: TokenInfo;
|
|
18
|
+
amount: string | number;
|
|
19
|
+
}
|
|
20
|
+
export interface TransferResult {
|
|
21
|
+
success: true;
|
|
22
|
+
txHash: string;
|
|
23
|
+
safeAddress: string;
|
|
24
|
+
paymentDetails: PaymentDetail[];
|
|
25
|
+
}
|
|
26
|
+
declare function executeTransferProposal(payerWallet: PayerWallet, paymentDetailsInput: PaymentDetail | PaymentDetail[]): Promise<TransferResult>;
|
|
27
|
+
export { executeTransferProposal };
|
|
28
|
+
//# sourceMappingURL=gnosisTransactionBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gnosisTransactionBuilder.d.ts","sourceRoot":"","sources":["../../../scripts/invoice/gnosisTransactionBuilder.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,aAAa,EAAE,CAAC;CACjC;AAGD,iBAAe,uBAAuB,CACpC,WAAW,EAAE,WAAW,EACxB,mBAAmB,EAAE,aAAa,GAAG,aAAa,EAAE,GACnD,OAAO,CAAC,cAAc,CAAC,CAkFzB;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAA"}
|