@powerhousedao/contributor-billing 0.1.29 → 0.1.30
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/README.md +165 -8
- package/dist/document-models/billing-statement/actions.d.ts +1 -0
- package/dist/document-models/billing-statement/actions.d.ts.map +1 -1
- package/dist/document-models/billing-statement/gen/document-model.d.ts.map +1 -1
- package/dist/document-models/billing-statement/gen/document-model.js +58 -47
- package/dist/document-models/billing-statement/gen/document-schema.d.ts +38 -38
- package/dist/document-models/billing-statement/gen/document-schema.d.ts.map +1 -1
- package/dist/document-models/billing-statement/gen/line-items/actions.d.ts +6 -2
- package/dist/document-models/billing-statement/gen/line-items/actions.d.ts.map +1 -1
- package/dist/document-models/billing-statement/gen/line-items/creators.d.ts +3 -2
- package/dist/document-models/billing-statement/gen/line-items/creators.d.ts.map +1 -1
- package/dist/document-models/billing-statement/gen/line-items/creators.js +2 -1
- package/dist/document-models/billing-statement/gen/line-items/operations.d.ts +2 -1
- package/dist/document-models/billing-statement/gen/line-items/operations.d.ts.map +1 -1
- package/dist/document-models/billing-statement/gen/ph-factories.js +1 -1
- package/dist/document-models/billing-statement/gen/reducer.d.ts.map +1 -1
- package/dist/document-models/billing-statement/gen/reducer.js +5 -1
- package/dist/document-models/billing-statement/gen/schema/types.d.ts +3 -0
- package/dist/document-models/billing-statement/gen/schema/types.d.ts.map +1 -1
- package/dist/document-models/billing-statement/gen/schema/zod.d.ts +2 -1
- package/dist/document-models/billing-statement/gen/schema/zod.d.ts.map +1 -1
- package/dist/document-models/billing-statement/gen/schema/zod.js +5 -0
- package/dist/document-models/billing-statement/gen/utils.js +2 -2
- package/dist/document-models/billing-statement/src/reducers/general.d.ts.map +1 -1
- package/dist/document-models/billing-statement/src/reducers/general.js +5 -4
- package/dist/document-models/billing-statement/src/reducers/line-items.d.ts.map +1 -1
- package/dist/document-models/billing-statement/src/reducers/line-items.js +7 -2
- package/dist/document-models/billing-statement/src/reducers/tags.d.ts.map +1 -1
- package/dist/document-models/billing-statement/src/reducers/tags.js +1 -1
- package/dist/document-models/billing-statement/src/tests/document-model.test.d.ts +4 -0
- package/dist/document-models/billing-statement/src/tests/document-model.test.d.ts.map +1 -1
- package/dist/document-models/billing-statement/src/tests/document-model.test.js +94 -7
- package/dist/document-models/billing-statement/src/tests/general.test.d.ts +2 -1
- package/dist/document-models/billing-statement/src/tests/general.test.d.ts.map +1 -1
- package/dist/document-models/billing-statement/src/tests/general.test.js +33 -88
- package/dist/document-models/billing-statement/src/tests/line-items.test.js +22 -125
- package/dist/document-models/billing-statement/src/tests/tags.test.js +13 -47
- package/dist/document-models/document-models.js +2 -2
- package/dist/document-models/expense-report/gen/document-model.d.ts.map +1 -1
- package/dist/document-models/expense-report/gen/document-model.js +48 -48
- package/dist/document-models/expense-report/gen/document-schema.d.ts +6 -6
- package/dist/document-models/expense-report/gen/utils.js +1 -1
- package/dist/document-models/expense-report/src/tests/document-model.test.d.ts +4 -0
- package/dist/document-models/expense-report/src/tests/document-model.test.d.ts.map +1 -1
- package/dist/document-models/expense-report/src/tests/document-model.test.js +94 -8
- package/dist/document-models/expense-report/src/tests/wallet.test.js +145 -10
- package/dist/document-models/index.d.ts +2 -6
- package/dist/document-models/index.d.ts.map +1 -1
- package/dist/document-models/index.js +2 -6
- package/dist/document-models/integrations/gen/document-model.js +33 -33
- package/dist/document-models/integrations/gen/document-schema.d.ts +6 -6
- package/dist/document-models/integrations/gen/utils.js +1 -1
- package/dist/document-models/integrations/src/reducers/integrations.d.ts.map +1 -1
- package/dist/document-models/integrations/src/reducers/integrations.js +9 -32
- package/dist/document-models/integrations/src/tests/document-model.test.d.ts +4 -0
- package/dist/document-models/integrations/src/tests/document-model.test.d.ts.map +1 -1
- package/dist/document-models/integrations/src/tests/document-model.test.js +91 -5
- package/dist/document-models/integrations/src/tests/integrations.test.js +21 -46
- package/dist/document-models/invoice/gen/document-model.js +147 -147
- package/dist/document-models/invoice/gen/document-schema.d.ts +127 -127
- package/dist/document-models/invoice/gen/document-schema.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/ph-factories.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/ph-factories.js +16 -122
- package/dist/document-models/invoice/gen/schema/types.d.ts +4 -4
- package/dist/document-models/invoice/gen/schema/types.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/schema/zod.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/schema/zod.js +4 -4
- package/dist/document-models/invoice/gen/utils.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/utils.js +17 -123
- package/dist/document-models/invoice/src/reducers/general.d.ts.map +1 -1
- package/dist/document-models/invoice/src/reducers/general.js +34 -10
- package/dist/document-models/invoice/src/reducers/items.d.ts.map +1 -1
- package/dist/document-models/invoice/src/reducers/items.js +7 -7
- package/dist/document-models/invoice/src/reducers/parties.d.ts.map +1 -1
- package/dist/document-models/invoice/src/reducers/parties.js +96 -50
- package/dist/document-models/invoice/src/reducers/transitions.d.ts.map +1 -1
- package/dist/document-models/invoice/src/reducers/transitions.js +69 -53
- package/dist/document-models/invoice/src/tests/document-model.test.d.ts +4 -0
- package/dist/document-models/invoice/src/tests/document-model.test.d.ts.map +1 -1
- package/dist/document-models/invoice/src/tests/document-model.test.js +91 -4
- package/dist/document-models/invoice/src/tests/general.test.js +24 -26
- package/dist/document-models/invoice/src/tests/items.test.js +37 -17
- package/dist/document-models/invoice/src/tests/parties.test.js +32 -26
- package/dist/document-models/invoice/src/tests/transitions.test.js +52 -500
- package/dist/document-models/invoice/utils/statusTransitions.d.ts.map +1 -1
- package/dist/document-models/invoice/utils/statusTransitions.js +10 -10
- package/dist/editors/billing-statement/components/lineItemsTable.d.ts.map +1 -1
- package/dist/editors/billing-statement/components/lineItemsTable.js +32 -23
- package/dist/editors/billing-statement/components/objectSetTable.d.ts.map +1 -1
- package/dist/editors/billing-statement/components/objectSetTable.js +1 -2
- package/dist/editors/billing-statement/editor.d.ts +4 -0
- package/dist/editors/billing-statement/editor.d.ts.map +1 -1
- package/dist/editors/billing-statement/editor.js +34 -16
- package/dist/editors/billing-statement/lineItemTags/lineItemTags.d.ts.map +1 -1
- package/dist/editors/billing-statement/lineItemTags/lineItemTags.js +36 -37
- package/dist/editors/billing-statement/lineItemTags/tagMapping.d.ts.map +1 -1
- package/dist/editors/billing-statement/lineItemTags/tagMapping.js +28 -10
- package/dist/editors/clean-new-editor/components/CreateDocument.d.ts +6 -0
- package/dist/editors/clean-new-editor/components/CreateDocument.d.ts.map +1 -0
- package/dist/editors/clean-new-editor/components/CreateDocument.js +18 -0
- package/dist/editors/clean-new-editor/components/DriveContents.d.ts +3 -0
- package/dist/editors/clean-new-editor/components/DriveContents.d.ts.map +1 -0
- package/dist/editors/clean-new-editor/components/DriveContents.js +10 -0
- package/dist/editors/clean-new-editor/components/DriveExplorer.d.ts +7 -0
- package/dist/editors/clean-new-editor/components/DriveExplorer.d.ts.map +1 -0
- package/dist/editors/clean-new-editor/components/DriveExplorer.js +16 -0
- package/dist/editors/clean-new-editor/components/EmptyState.d.ts +3 -0
- package/dist/editors/clean-new-editor/components/EmptyState.d.ts.map +1 -0
- package/dist/editors/clean-new-editor/components/EmptyState.js +10 -0
- package/dist/editors/clean-new-editor/components/Files.d.ts +3 -0
- package/dist/editors/clean-new-editor/components/Files.d.ts.map +1 -0
- package/dist/editors/clean-new-editor/components/Files.js +12 -0
- package/dist/editors/clean-new-editor/components/FolderTree.d.ts +6 -0
- package/dist/editors/clean-new-editor/components/FolderTree.d.ts.map +1 -0
- package/dist/editors/clean-new-editor/components/FolderTree.js +65 -0
- package/dist/editors/clean-new-editor/components/Folders.d.ts +3 -0
- package/dist/editors/clean-new-editor/components/Folders.d.ts.map +1 -0
- package/dist/editors/clean-new-editor/components/Folders.js +12 -0
- package/dist/editors/clean-new-editor/components/NavigationBreadcrumbs.d.ts +3 -0
- package/dist/editors/clean-new-editor/components/NavigationBreadcrumbs.d.ts.map +1 -0
- package/dist/editors/clean-new-editor/components/NavigationBreadcrumbs.js +6 -0
- package/dist/editors/clean-new-editor/config.d.ts +4 -0
- package/dist/editors/clean-new-editor/config.d.ts.map +1 -0
- package/dist/editors/clean-new-editor/config.js +5 -0
- package/dist/editors/clean-new-editor/editor.d.ts +4 -0
- package/dist/editors/clean-new-editor/editor.d.ts.map +1 -0
- package/dist/editors/clean-new-editor/editor.js +11 -0
- package/dist/editors/clean-new-editor/module.d.ts +3 -0
- package/dist/editors/clean-new-editor/module.d.ts.map +1 -0
- package/dist/editors/clean-new-editor/module.js +10 -0
- package/dist/editors/contributor-billing/components/ConfirmationModal.d.ts +14 -0
- package/dist/editors/contributor-billing/components/ConfirmationModal.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/ConfirmationModal.js +6 -0
- package/dist/editors/contributor-billing/components/CreateDocument.d.ts +6 -0
- package/dist/editors/contributor-billing/components/CreateDocument.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/CreateDocument.js +18 -0
- package/dist/editors/contributor-billing/components/DriveContents.d.ts +3 -0
- package/dist/editors/contributor-billing/components/DriveContents.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/DriveContents.js +10 -0
- package/dist/editors/contributor-billing/components/DriveExplorer.d.ts +3 -3
- package/dist/editors/contributor-billing/components/DriveExplorer.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/DriveExplorer.js +13 -180
- package/dist/editors/contributor-billing/components/EmptyState.d.ts +3 -0
- package/dist/editors/contributor-billing/components/EmptyState.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/EmptyState.js +10 -0
- package/dist/editors/contributor-billing/components/Files.d.ts +3 -0
- package/dist/editors/contributor-billing/components/Files.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/Files.js +12 -0
- package/dist/editors/contributor-billing/components/FolderTree.d.ts +6 -0
- package/dist/editors/contributor-billing/components/FolderTree.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/FolderTree.js +65 -0
- package/dist/editors/contributor-billing/components/Folders.d.ts +3 -0
- package/dist/editors/contributor-billing/components/Folders.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/Folders.js +12 -0
- package/dist/editors/contributor-billing/components/HeaderControls.d.ts +38 -0
- package/dist/editors/contributor-billing/components/HeaderControls.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/HeaderControls.js +124 -0
- package/dist/editors/contributor-billing/components/HeaderStats.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/{InvoiceTable/HeaderStats.js → HeaderStats.js} +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable.d.ts +22 -0
- package/dist/editors/contributor-billing/components/InvoiceTable.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTable.js +399 -0
- package/dist/editors/contributor-billing/components/InvoiceTableContainer.d.ts +6 -0
- package/dist/editors/contributor-billing/components/InvoiceTableContainer.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTableContainer.js +111 -0
- package/dist/editors/contributor-billing/components/InvoiceTableRow.d.ts +32 -0
- package/dist/editors/contributor-billing/components/InvoiceTableRow.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTableRow.js +55 -0
- package/dist/editors/contributor-billing/components/InvoiceTableSection.d.ts +13 -0
- package/dist/editors/contributor-billing/components/InvoiceTableSection.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTableSection.js +16 -0
- package/dist/editors/contributor-billing/components/NavigationBreadcrumbs.d.ts +3 -0
- package/dist/editors/contributor-billing/components/NavigationBreadcrumbs.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/NavigationBreadcrumbs.js +6 -0
- package/dist/editors/contributor-billing/config.d.ts +1 -0
- package/dist/editors/contributor-billing/config.d.ts.map +1 -1
- package/dist/editors/contributor-billing/config.js +4 -1
- package/dist/editors/contributor-billing/editor.d.ts +1 -0
- package/dist/editors/contributor-billing/editor.d.ts.map +1 -1
- package/dist/editors/contributor-billing/editor.js +4 -1
- package/dist/editors/contributor-billing/module.d.ts +1 -1
- package/dist/editors/contributor-billing/module.d.ts.map +1 -1
- package/dist/editors/contributor-billing/module.js +3 -2
- package/dist/editors/contributor-billing/utils/exchangeRate.d.ts +15 -0
- package/dist/editors/contributor-billing/utils/exchangeRate.d.ts.map +1 -0
- package/dist/editors/contributor-billing/utils/exchangeRate.js +122 -0
- package/dist/editors/editors.js +2 -2
- package/dist/editors/expense-report/components/AddBillingStatementModal.d.ts.map +1 -1
- package/dist/editors/expense-report/editor.js +8 -8
- package/dist/editors/index.d.ts +2 -2
- package/dist/editors/index.d.ts.map +1 -1
- package/dist/editors/index.js +2 -2
- package/dist/editors/integrations/components/EditName.d.ts +3 -0
- package/dist/editors/integrations/components/EditName.d.ts.map +1 -0
- package/dist/editors/integrations/components/EditName.js +31 -0
- package/dist/editors/integrations/editor.d.ts +2 -4
- package/dist/editors/integrations/editor.d.ts.map +1 -1
- package/dist/editors/integrations/editor.js +5 -132
- package/dist/editors/integrations/module.d.ts +1 -0
- package/dist/editors/integrations/module.d.ts.map +1 -1
- package/dist/editors/integrations/module.js +3 -2
- package/dist/editors/invoice/components/confirmationModal.js +1 -1
- package/dist/editors/invoice/components/countryForm.d.ts.map +1 -1
- package/dist/editors/invoice/components/countryForm.js +1 -1
- package/dist/editors/invoice/components/currencyForm.d.ts.map +1 -1
- package/dist/editors/invoice/components/currencyForm.js +1 -1
- package/dist/editors/invoice/components/datePicker.d.ts +1 -1
- package/dist/editors/invoice/components/datePicker.d.ts.map +1 -1
- package/dist/editors/invoice/components/datePicker.js +1 -1
- package/dist/editors/invoice/components/inputField.d.ts.map +1 -1
- package/dist/editors/invoice/components/inputField.js +3 -2
- package/dist/editors/invoice/components/lineItemMobileModal.d.ts.map +1 -1
- package/dist/editors/invoice/components/lineItemMobileModal.js +1 -1
- package/dist/editors/invoice/components/numberForm.d.ts.map +1 -1
- package/dist/editors/invoice/components/selectField.js +7 -7
- package/dist/editors/invoice/components/statusModalComponents.d.ts.map +1 -1
- package/dist/editors/invoice/components/statusModalComponents.js +27 -3
- package/dist/editors/invoice/editor.d.ts +1 -4
- package/dist/editors/invoice/editor.d.ts.map +1 -1
- package/dist/editors/invoice/editor.js +102 -40
- package/dist/editors/invoice/exportUBL.d.ts.map +1 -1
- package/dist/editors/invoice/exportUBL.js +35 -18
- package/dist/editors/invoice/ingestPDF.d.ts.map +1 -1
- package/dist/editors/invoice/ingestPDF.js +15 -9
- package/dist/editors/invoice/invoiceToGnosis.js +3 -3
- package/dist/editors/invoice/legalEntity/bankSection.d.ts.map +1 -1
- package/dist/editors/invoice/legalEntity/legalEntity.d.ts.map +1 -1
- package/dist/editors/invoice/legalEntity/walletSection.d.ts.map +1 -1
- package/dist/editors/invoice/legalEntity/walletSection.js +3 -3
- package/dist/editors/invoice/lineItemTags/lineItemTags.d.ts.map +1 -1
- package/dist/editors/invoice/lineItemTags/lineItemTags.js +1 -1
- package/dist/editors/invoice/lineItemTags/tagMobileModal.d.ts.map +1 -1
- package/dist/editors/invoice/lineItemTags/tagMobileModal.js +4 -3
- package/dist/editors/invoice/lineItems.d.ts.map +1 -1
- package/dist/editors/invoice/module.d.ts +1 -0
- package/dist/editors/invoice/module.d.ts.map +1 -1
- package/dist/editors/invoice/module.js +2 -1
- package/dist/editors/invoice/requestFinance.js +4 -4
- package/dist/editors/invoice/uploadPdfChunked.d.ts.map +1 -1
- package/dist/editors/invoice/uploadPdfChunked.js +5 -4
- package/dist/editors/invoice/utils/utils.d.ts.map +1 -1
- package/dist/editors/invoice/utils/utils.js +5 -4
- package/dist/editors/invoice/validation/validationHandler.d.ts.map +1 -1
- package/dist/editors/invoice/validation/validationHandler.js +11 -5
- package/dist/editors/invoice/validation/validationManager.d.ts +2 -2
- package/dist/editors/invoice/validation/validationManager.d.ts.map +1 -1
- package/dist/editors/invoice/validation/validationManager.js +5 -5
- package/dist/editors/invoice/validation/validationRules.d.ts.map +1 -1
- package/dist/editors/invoice/validation/validationRules.js +178 -178
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/old-contributor-billing/components/DriveExplorer.d.ts +7 -0
- package/dist/old-contributor-billing/components/DriveExplorer.d.ts.map +1 -0
- package/dist/old-contributor-billing/components/DriveExplorer.js +184 -0
- package/dist/old-contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -0
- package/dist/old-contributor-billing/components/InvoiceTable/HeaderStats.d.ts +2 -0
- package/dist/old-contributor-billing/components/InvoiceTable/HeaderStats.d.ts.map +1 -0
- package/dist/old-contributor-billing/components/InvoiceTable/HeaderStats.js +73 -0
- package/dist/old-contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -0
- package/dist/old-contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts.map +1 -0
- package/dist/old-contributor-billing/components/InvoiceTable/InvoiceTableSection.d.ts.map +1 -0
- package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/InvoiceTableSection.js +1 -1
- package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/RowActionMenu.d.ts +1 -1
- package/dist/old-contributor-billing/components/InvoiceTable/RowActionMenu.d.ts.map +1 -0
- package/dist/old-contributor-billing/components/InvoiceTable/RowActionMenu.js +2 -0
- package/dist/old-contributor-billing/config.d.ts +3 -0
- package/dist/old-contributor-billing/config.d.ts.map +1 -0
- package/dist/old-contributor-billing/config.js +4 -0
- package/dist/old-contributor-billing/editor.d.ts +3 -0
- package/dist/old-contributor-billing/editor.d.ts.map +1 -0
- package/dist/old-contributor-billing/editor.js +8 -0
- package/dist/old-contributor-billing/module.d.ts +3 -0
- package/dist/old-contributor-billing/module.d.ts.map +1 -0
- package/dist/old-contributor-billing/module.js +9 -0
- package/dist/old-contributor-billing/util.d.ts.map +1 -0
- package/dist/{editors/contributor-billing → old-contributor-billing}/util.js +11 -9
- package/dist/powerhouse.manifest.json +6 -41
- package/dist/processors/index.d.ts +1 -6
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -18
- package/dist/scripts/contributor-billing/createExpenseReportCsv.d.ts.map +1 -1
- package/dist/scripts/contributor-billing/createExpenseReportCsv.js +24 -24
- package/dist/scripts/contributor-billing/createXeroCsv.d.ts.map +1 -1
- package/dist/scripts/contributor-billing/createXeroCsv.js +52 -46
- package/dist/scripts/invoice/autoTagging.d.ts +1 -1
- package/dist/scripts/invoice/autoTagging.d.ts.map +1 -1
- package/dist/scripts/invoice/autoTagging.js +168 -138
- package/dist/scripts/invoice/exampleBatchTxn.js +16 -16
- package/dist/scripts/invoice/gnosisTransactionBuilder.d.ts.map +1 -1
- package/dist/scripts/invoice/gnosisTransactionBuilder.js +32 -25
- package/dist/scripts/invoice/pdfToClaudeAI.d.ts.map +1 -1
- package/dist/scripts/invoice/pdfToClaudeAI.js +36 -30
- package/dist/scripts/invoice/requestFinance.d.ts.map +1 -1
- package/dist/scripts/invoice/requestFinance.js +13 -13
- package/dist/style.css +407 -13659
- package/dist/subgraphs/billing-statement/resolvers.d.ts +1 -1
- package/dist/subgraphs/billing-statement/resolvers.d.ts.map +1 -1
- package/dist/subgraphs/billing-statement/resolvers.js +16 -5
- package/dist/subgraphs/billing-statement/schema.d.ts.map +1 -1
- package/dist/subgraphs/billing-statement/schema.js +12 -67
- package/dist/subgraphs/expense-report/resolvers.d.ts +1 -1
- package/dist/subgraphs/expense-report/resolvers.d.ts.map +1 -1
- package/dist/subgraphs/expense-report/resolvers.js +4 -5
- package/dist/subgraphs/expense-report/schema.d.ts.map +1 -1
- package/dist/subgraphs/expense-report/schema.js +5 -48
- package/dist/subgraphs/index.d.ts +1 -0
- package/dist/subgraphs/index.d.ts.map +1 -1
- package/dist/subgraphs/index.js +1 -0
- package/dist/subgraphs/integrations/resolvers.d.ts +1 -1
- package/dist/subgraphs/integrations/resolvers.d.ts.map +1 -1
- package/dist/subgraphs/integrations/resolvers.js +4 -5
- package/dist/subgraphs/integrations/schema.d.ts.map +1 -1
- package/dist/subgraphs/integrations/schema.js +3 -43
- package/dist/subgraphs/invoice/index.d.ts.map +1 -1
- package/dist/subgraphs/invoice/index.js +1 -20
- package/dist/subgraphs/invoice/resolvers.d.ts +1 -1
- package/dist/subgraphs/invoice/resolvers.d.ts.map +1 -1
- package/dist/subgraphs/invoice/resolvers.js +4 -9
- package/dist/subgraphs/invoice/schema.d.ts.map +1 -1
- package/dist/subgraphs/invoice/schema.js +14 -232
- package/dist/subgraphs/{invoice → invoice-addon}/customResolvers.d.ts +1 -1
- package/dist/subgraphs/invoice-addon/customResolvers.d.ts.map +1 -0
- package/dist/subgraphs/{invoice → invoice-addon}/customResolvers.js +38 -34
- package/dist/subgraphs/invoice-addon/index.d.ts +11 -0
- package/dist/subgraphs/invoice-addon/index.d.ts.map +1 -0
- package/dist/subgraphs/invoice-addon/index.js +11 -0
- package/dist/subgraphs/invoice-addon/resolvers.d.ts +3 -0
- package/dist/subgraphs/invoice-addon/resolvers.d.ts.map +1 -0
- package/dist/subgraphs/invoice-addon/resolvers.js +12 -0
- package/dist/subgraphs/invoice-addon/schema.d.ts +3 -0
- package/dist/subgraphs/invoice-addon/schema.d.ts.map +1 -0
- package/dist/subgraphs/invoice-addon/schema.js +52 -0
- package/package.json +9 -20
- package/dist/document-models/expense-report/gen/expense-report/actions.d.ts +0 -8
- package/dist/document-models/expense-report/gen/expense-report/actions.d.ts.map +0 -1
- package/dist/document-models/expense-report/gen/expense-report/actions.js +0 -1
- package/dist/document-models/expense-report/gen/expense-report/creators.d.ts +0 -4
- package/dist/document-models/expense-report/gen/expense-report/creators.d.ts.map +0 -1
- package/dist/document-models/expense-report/gen/expense-report/creators.js +0 -3
- package/dist/document-models/expense-report/gen/expense-report/error.d.ts +0 -2
- package/dist/document-models/expense-report/gen/expense-report/error.d.ts.map +0 -1
- package/dist/document-models/expense-report/gen/expense-report/error.js +0 -1
- package/dist/document-models/expense-report/gen/expense-report/operations.d.ts +0 -7
- package/dist/document-models/expense-report/gen/expense-report/operations.d.ts.map +0 -1
- package/dist/document-models/expense-report/gen/expense-report/operations.js +0 -3
- package/dist/document-models/expense-report/src/tests/expense-report.test.d.ts +0 -6
- package/dist/document-models/expense-report/src/tests/expense-report.test.d.ts.map +0 -1
- package/dist/document-models/expense-report/src/tests/expense-report.test.js +0 -24
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +0 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderStats.d.ts.map +0 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +0 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts.map +0 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableSection.d.ts.map +0 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.d.ts.map +0 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.js +0 -2
- package/dist/editors/contributor-billing/util.d.ts.map +0 -1
- package/dist/editors/hooks/useBillingStatementDocument.d.ts +0 -4
- package/dist/editors/hooks/useBillingStatementDocument.d.ts.map +0 -1
- package/dist/editors/hooks/useBillingStatementDocument.js +0 -8
- package/dist/editors/hooks/useExpenseReportDocument.d.ts +0 -4
- package/dist/editors/hooks/useExpenseReportDocument.d.ts.map +0 -1
- package/dist/editors/hooks/useExpenseReportDocument.js +0 -8
- package/dist/editors/hooks/useIntegrationsDocument.d.ts +0 -4
- package/dist/editors/hooks/useIntegrationsDocument.d.ts.map +0 -1
- package/dist/editors/hooks/useIntegrationsDocument.js +0 -8
- package/dist/editors/hooks/useInvoiceDocument.d.ts +0 -4
- package/dist/editors/hooks/useInvoiceDocument.d.ts.map +0 -1
- package/dist/editors/hooks/useInvoiceDocument.js +0 -8
- package/dist/editors/integrations/config.d.ts +0 -3
- package/dist/editors/integrations/config.d.ts.map +0 -1
- package/dist/editors/integrations/config.js +0 -3
- package/dist/editors/invoice/exportSAFTPT.d.ts +0 -184
- package/dist/editors/invoice/exportSAFTPT.d.ts.map +0 -1
- package/dist/editors/invoice/exportSAFTPT.js +0 -548
- package/dist/processors/line-item-processor/index.d.ts +0 -11
- package/dist/processors/line-item-processor/index.d.ts.map +0 -1
- package/dist/processors/line-item-processor/index.js +0 -36
- package/dist/subgraphs/invoice/customResolvers.d.ts.map +0 -1
- package/editors/invoice/assets/custom.d.ts +0 -4
- package/editors/invoice/assets/powerhouseLogo.png +0 -0
- /package/dist/editors/contributor-billing/components/{InvoiceTable/HeaderStats.d.ts → HeaderStats.d.ts} +0 -0
- /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/HeaderControls.d.ts +0 -0
- /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/HeaderControls.js +0 -0
- /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/InvoiceTable.d.ts +0 -0
- /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/InvoiceTable.js +0 -0
- /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/InvoiceTableRow.d.ts +0 -0
- /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/InvoiceTableRow.js +0 -0
- /package/dist/{editors/contributor-billing → old-contributor-billing}/components/InvoiceTable/InvoiceTableSection.d.ts +0 -0
- /package/dist/{editors/contributor-billing → old-contributor-billing}/util.d.ts +0 -0
|
@@ -1,548 +0,0 @@
|
|
|
1
|
-
// Helper function to format numbers with appropriate decimal places
|
|
2
|
-
function formatNumber(value, decimals = 2) {
|
|
3
|
-
return value.toFixed(decimals);
|
|
4
|
-
}
|
|
5
|
-
// Helper function to format numbers with high precision for unit prices
|
|
6
|
-
function formatUnitPrice(value) {
|
|
7
|
-
return value.toFixed(7);
|
|
8
|
-
}
|
|
9
|
-
// Portuguese month names
|
|
10
|
-
const PORTUGUESE_MONTHS = [
|
|
11
|
-
"Janeiro",
|
|
12
|
-
"Fevereiro",
|
|
13
|
-
"Março",
|
|
14
|
-
"Abril",
|
|
15
|
-
"Maio",
|
|
16
|
-
"Junho",
|
|
17
|
-
"Julho",
|
|
18
|
-
"Agosto",
|
|
19
|
-
"Setembro",
|
|
20
|
-
"Outubro",
|
|
21
|
-
"Novembro",
|
|
22
|
-
"Dezembro",
|
|
23
|
-
];
|
|
24
|
-
// Helper function to get Portuguese month name
|
|
25
|
-
function getPortugueseMonth(monthIndex) {
|
|
26
|
-
return PORTUGUESE_MONTHS[monthIndex] || "";
|
|
27
|
-
}
|
|
28
|
-
export class SAFTPTExporter {
|
|
29
|
-
invoice;
|
|
30
|
-
options;
|
|
31
|
-
constructor(options) {
|
|
32
|
-
this.invoice = options.invoice;
|
|
33
|
-
this.options = options;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Convert the invoice state to SAF-T PT XML format
|
|
37
|
-
* @returns SAF-T PT XML string
|
|
38
|
-
*/
|
|
39
|
-
convertInvoiceToSAFTPT() {
|
|
40
|
-
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
41
|
-
<AuditFile xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.04_01">
|
|
42
|
-
${this.generateHeader()}
|
|
43
|
-
${this.generateMasterFiles()}
|
|
44
|
-
${this.generateSourceDocuments()}
|
|
45
|
-
</AuditFile>`;
|
|
46
|
-
return xml;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Generate the Header section
|
|
50
|
-
*/
|
|
51
|
-
generateHeader() {
|
|
52
|
-
const issuer = this.invoice.issuer;
|
|
53
|
-
const taxId = this.extractTaxId(issuer);
|
|
54
|
-
const issueDate = new Date(this.invoice.dateIssued);
|
|
55
|
-
// Derive fiscal period from invoice date if not provided
|
|
56
|
-
const fiscalYear = this.options.fiscalPeriod?.fiscalYear || issueDate.getFullYear();
|
|
57
|
-
const month = issueDate.getMonth() + 1;
|
|
58
|
-
const startDate = this.options.fiscalPeriod?.startDate ||
|
|
59
|
-
`${fiscalYear}-${String(month).padStart(2, "0")}-01`;
|
|
60
|
-
const endDate = this.options.fiscalPeriod?.endDate ||
|
|
61
|
-
this.getLastDayOfMonth(fiscalYear, month);
|
|
62
|
-
const dateCreated = this.formatDate(new Date().toISOString());
|
|
63
|
-
// Default software info from TOConline (Portuguese SAF-T example)
|
|
64
|
-
const softwareInfo = this.options.softwareInfo || {
|
|
65
|
-
productCompanyTaxID: "503692310",
|
|
66
|
-
softwareCertificateNumber: "1662",
|
|
67
|
-
productID: "TOConline/Ordem dos Contabilistas Certificados",
|
|
68
|
-
productVersion: "3.0.4988",
|
|
69
|
-
};
|
|
70
|
-
// Generate HeaderComment with Portuguese month name if not provided
|
|
71
|
-
const portugueseMonth = getPortugueseMonth(issueDate.getMonth());
|
|
72
|
-
const headerComment = this.options.headerComment || `SAF-T ${portugueseMonth} ${fiscalYear}`;
|
|
73
|
-
return `<Header>
|
|
74
|
-
<AuditFileVersion>1.04_01</AuditFileVersion>
|
|
75
|
-
<CompanyID>${this.escapeXml(taxId)}</CompanyID>
|
|
76
|
-
<TaxRegistrationNumber>${this.escapeXml(taxId)}</TaxRegistrationNumber>
|
|
77
|
-
<TaxAccountingBasis>${this.options.taxAccountingBasis || "F"}</TaxAccountingBasis>
|
|
78
|
-
<CompanyName>${this.escapeXml(issuer.name || "")}</CompanyName>
|
|
79
|
-
<BusinessName>${this.escapeXml(issuer.name || "")}</BusinessName>
|
|
80
|
-
${this.generateCompanyAddress(issuer)}
|
|
81
|
-
<FiscalYear>${fiscalYear}</FiscalYear>
|
|
82
|
-
<StartDate>${startDate}</StartDate>
|
|
83
|
-
<EndDate>${endDate}</EndDate>
|
|
84
|
-
<CurrencyCode>${this.escapeXml(this.invoice.currency || "EUR")}</CurrencyCode>
|
|
85
|
-
<DateCreated>${dateCreated}</DateCreated>
|
|
86
|
-
<TaxEntity>${this.escapeXml(this.options.taxEntity || "Global")}</TaxEntity>
|
|
87
|
-
<ProductCompanyTaxID>${this.escapeXml(softwareInfo.productCompanyTaxID)}</ProductCompanyTaxID>
|
|
88
|
-
<SoftwareCertificateNumber>${this.escapeXml(softwareInfo.softwareCertificateNumber)}</SoftwareCertificateNumber>
|
|
89
|
-
<ProductID>${this.escapeXml(softwareInfo.productID)}</ProductID>
|
|
90
|
-
<ProductVersion>${this.escapeXml(softwareInfo.productVersion)}</ProductVersion>
|
|
91
|
-
<HeaderComment>${this.escapeXml(headerComment)}</HeaderComment>
|
|
92
|
-
${issuer.contactInfo?.email ? `<Email>${this.escapeXml(issuer.contactInfo.email)}</Email>` : ""}
|
|
93
|
-
</Header>`;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Generate company address block
|
|
97
|
-
*/
|
|
98
|
-
generateCompanyAddress(entity) {
|
|
99
|
-
const address = entity.address;
|
|
100
|
-
const addressDetail = [
|
|
101
|
-
address?.streetAddress,
|
|
102
|
-
address?.extendedAddress,
|
|
103
|
-
].filter(Boolean).join(", ");
|
|
104
|
-
return `<CompanyAddress>
|
|
105
|
-
<AddressDetail>${this.escapeXml(addressDetail || "Desconhecido")}</AddressDetail>
|
|
106
|
-
<City>${this.escapeXml(address?.city || "Desconhecido")}</City>
|
|
107
|
-
<PostalCode>${this.escapeXml(address?.postalCode || "Desconhecido")}</PostalCode>
|
|
108
|
-
<Country>${this.escapeXml(entity.country || "PT")}</Country>
|
|
109
|
-
</CompanyAddress>`;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Generate the MasterFiles section
|
|
113
|
-
*/
|
|
114
|
-
generateMasterFiles() {
|
|
115
|
-
return `<MasterFiles>
|
|
116
|
-
${this.generateCustomer()}
|
|
117
|
-
${this.generateProducts()}
|
|
118
|
-
${this.generateTaxTable()}
|
|
119
|
-
</MasterFiles>`;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Generate customer entry
|
|
123
|
-
*/
|
|
124
|
-
generateCustomer() {
|
|
125
|
-
const payer = this.invoice.payer;
|
|
126
|
-
const taxId = this.extractTaxId(payer);
|
|
127
|
-
const customerId = this.options.customerId || "1";
|
|
128
|
-
const addressDetail = [
|
|
129
|
-
payer.address?.streetAddress,
|
|
130
|
-
payer.address?.extendedAddress,
|
|
131
|
-
].filter(Boolean).join("\n") || "Desconhecido";
|
|
132
|
-
return `<Customer>
|
|
133
|
-
<CustomerID>${this.escapeXml(customerId)}</CustomerID>
|
|
134
|
-
<AccountID>Desconhecido</AccountID>
|
|
135
|
-
<CustomerTaxID>${this.escapeXml(taxId || "Consumidor Final")}</CustomerTaxID>
|
|
136
|
-
<CompanyName>${this.escapeXml(payer.name || "Consumidor Final")}</CompanyName>
|
|
137
|
-
<BillingAddress>
|
|
138
|
-
<AddressDetail>${this.escapeXml(addressDetail)}</AddressDetail>
|
|
139
|
-
<City>${this.escapeXml(payer.address?.city || "Desconhecido")}</City>
|
|
140
|
-
<PostalCode>${this.escapeXml(payer.address?.postalCode || "Desconhecido")}</PostalCode>
|
|
141
|
-
<Country>${this.escapeXml(payer.country || "PT")}</Country>
|
|
142
|
-
</BillingAddress>
|
|
143
|
-
<ShipToAddress>
|
|
144
|
-
<AddressDetail>${this.escapeXml(addressDetail)}</AddressDetail>
|
|
145
|
-
<City>${this.escapeXml(payer.address?.city || "Desconhecido")}</City>
|
|
146
|
-
<PostalCode>${this.escapeXml(payer.address?.postalCode || "Desconhecido")}</PostalCode>
|
|
147
|
-
<Country>${this.escapeXml(payer.country || "PT")}</Country>
|
|
148
|
-
</ShipToAddress>
|
|
149
|
-
<SelfBillingIndicator>0</SelfBillingIndicator>
|
|
150
|
-
</Customer>`;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Generate products from line items
|
|
154
|
-
*/
|
|
155
|
-
generateProducts() {
|
|
156
|
-
// Create unique product entries from line items
|
|
157
|
-
const productMap = new Map();
|
|
158
|
-
this.invoice.lineItems.forEach((item, index) => {
|
|
159
|
-
const code = String(index + 1).padStart(3, "0");
|
|
160
|
-
if (!productMap.has(item.description)) {
|
|
161
|
-
productMap.set(item.description, {
|
|
162
|
-
code,
|
|
163
|
-
description: item.description,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
// If no products, add a default service product
|
|
168
|
-
if (productMap.size === 0) {
|
|
169
|
-
productMap.set("Serviços", {
|
|
170
|
-
code: "001",
|
|
171
|
-
description: "Prestação de Serviços",
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
return Array.from(productMap.values())
|
|
175
|
-
.map((product) => `<Product>
|
|
176
|
-
<ProductType>S</ProductType>
|
|
177
|
-
<ProductCode>${this.escapeXml(product.code)}</ProductCode>
|
|
178
|
-
<ProductDescription>${this.escapeXml(product.description)}</ProductDescription>
|
|
179
|
-
<ProductNumberCode>${this.escapeXml(product.code)}</ProductNumberCode>
|
|
180
|
-
</Product>`)
|
|
181
|
-
.join("\n ");
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Generate tax table with all Portuguese tax rates (PT, PT-MA, PT-AC regions)
|
|
185
|
-
* This includes the complete tax table as required by SAF-T PT specification
|
|
186
|
-
*/
|
|
187
|
-
generateTaxTable() {
|
|
188
|
-
// Complete Portuguese tax table with all regions (Continental, Madeira, Azores)
|
|
189
|
-
return `<TaxTable>
|
|
190
|
-
<TaxTableEntry>
|
|
191
|
-
<TaxType>IVA</TaxType>
|
|
192
|
-
<TaxCountryRegion>PT</TaxCountryRegion>
|
|
193
|
-
<TaxCode>NOR</TaxCode>
|
|
194
|
-
<Description>Normal</Description>
|
|
195
|
-
<TaxPercentage>23</TaxPercentage>
|
|
196
|
-
</TaxTableEntry>
|
|
197
|
-
<TaxTableEntry>
|
|
198
|
-
<TaxType>IVA</TaxType>
|
|
199
|
-
<TaxCountryRegion>PT</TaxCountryRegion>
|
|
200
|
-
<TaxCode>INT</TaxCode>
|
|
201
|
-
<Description>Intermédia</Description>
|
|
202
|
-
<TaxPercentage>13</TaxPercentage>
|
|
203
|
-
</TaxTableEntry>
|
|
204
|
-
<TaxTableEntry>
|
|
205
|
-
<TaxType>IVA</TaxType>
|
|
206
|
-
<TaxCountryRegion>PT</TaxCountryRegion>
|
|
207
|
-
<TaxCode>RED</TaxCode>
|
|
208
|
-
<Description>Reduzida</Description>
|
|
209
|
-
<TaxPercentage>6</TaxPercentage>
|
|
210
|
-
</TaxTableEntry>
|
|
211
|
-
<TaxTableEntry>
|
|
212
|
-
<TaxType>IVA</TaxType>
|
|
213
|
-
<TaxCountryRegion>PT</TaxCountryRegion>
|
|
214
|
-
<TaxCode>ISE</TaxCode>
|
|
215
|
-
<Description>Isenta</Description>
|
|
216
|
-
<TaxPercentage>0</TaxPercentage>
|
|
217
|
-
</TaxTableEntry>
|
|
218
|
-
<TaxTableEntry>
|
|
219
|
-
<TaxType>IVA</TaxType>
|
|
220
|
-
<TaxCountryRegion>PT-MA</TaxCountryRegion>
|
|
221
|
-
<TaxCode>NOR</TaxCode>
|
|
222
|
-
<Description>Normal</Description>
|
|
223
|
-
<TaxPercentage>22</TaxPercentage>
|
|
224
|
-
</TaxTableEntry>
|
|
225
|
-
<TaxTableEntry>
|
|
226
|
-
<TaxType>IVA</TaxType>
|
|
227
|
-
<TaxCountryRegion>PT-MA</TaxCountryRegion>
|
|
228
|
-
<TaxCode>INT</TaxCode>
|
|
229
|
-
<Description>Intermédia</Description>
|
|
230
|
-
<TaxPercentage>12</TaxPercentage>
|
|
231
|
-
</TaxTableEntry>
|
|
232
|
-
<TaxTableEntry>
|
|
233
|
-
<TaxType>IVA</TaxType>
|
|
234
|
-
<TaxCountryRegion>PT-MA</TaxCountryRegion>
|
|
235
|
-
<TaxCode>ISE</TaxCode>
|
|
236
|
-
<Description>Isenta</Description>
|
|
237
|
-
<TaxPercentage>0</TaxPercentage>
|
|
238
|
-
</TaxTableEntry>
|
|
239
|
-
<TaxTableEntry>
|
|
240
|
-
<TaxType>IVA</TaxType>
|
|
241
|
-
<TaxCountryRegion>PT-AC</TaxCountryRegion>
|
|
242
|
-
<TaxCode>ISE</TaxCode>
|
|
243
|
-
<Description>Isenta</Description>
|
|
244
|
-
<TaxPercentage>0</TaxPercentage>
|
|
245
|
-
</TaxTableEntry>
|
|
246
|
-
<TaxTableEntry>
|
|
247
|
-
<TaxType>IVA</TaxType>
|
|
248
|
-
<TaxCountryRegion>PT-AC</TaxCountryRegion>
|
|
249
|
-
<TaxCode>INT</TaxCode>
|
|
250
|
-
<Description>Intermédia</Description>
|
|
251
|
-
<TaxPercentage>9</TaxPercentage>
|
|
252
|
-
</TaxTableEntry>
|
|
253
|
-
<TaxTableEntry>
|
|
254
|
-
<TaxType>IVA</TaxType>
|
|
255
|
-
<TaxCountryRegion>PT-AC</TaxCountryRegion>
|
|
256
|
-
<TaxCode>RED</TaxCode>
|
|
257
|
-
<Description>Reduzida</Description>
|
|
258
|
-
<TaxPercentage>4</TaxPercentage>
|
|
259
|
-
</TaxTableEntry>
|
|
260
|
-
<TaxTableEntry>
|
|
261
|
-
<TaxType>IVA</TaxType>
|
|
262
|
-
<TaxCountryRegion>PT-AC</TaxCountryRegion>
|
|
263
|
-
<TaxCode>NOR</TaxCode>
|
|
264
|
-
<Description>Normal</Description>
|
|
265
|
-
<TaxPercentage>16</TaxPercentage>
|
|
266
|
-
</TaxTableEntry>
|
|
267
|
-
<TaxTableEntry>
|
|
268
|
-
<TaxType>IVA</TaxType>
|
|
269
|
-
<TaxCountryRegion>PT-MA</TaxCountryRegion>
|
|
270
|
-
<TaxCode>RED</TaxCode>
|
|
271
|
-
<Description>Reduzida</Description>
|
|
272
|
-
<TaxPercentage>4</TaxPercentage>
|
|
273
|
-
</TaxTableEntry>
|
|
274
|
-
</TaxTable>`;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Get Portuguese tax code based on rate
|
|
278
|
-
*/
|
|
279
|
-
getTaxCode(rate) {
|
|
280
|
-
if (rate === 0)
|
|
281
|
-
return "ISE";
|
|
282
|
-
if (rate === 6 || rate === 4)
|
|
283
|
-
return "RED";
|
|
284
|
-
if (rate === 13 || rate === 12 || rate === 9)
|
|
285
|
-
return "INT";
|
|
286
|
-
if (rate === 23 || rate === 22 || rate === 16)
|
|
287
|
-
return "NOR";
|
|
288
|
-
return "ISE"; // Default to exempt for unknown rates
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Generate the SourceDocuments section
|
|
292
|
-
*/
|
|
293
|
-
generateSourceDocuments() {
|
|
294
|
-
const totalCredit = this.invoice.lineItems.reduce((sum, item) => sum + item.totalPriceTaxIncl, 0);
|
|
295
|
-
return `<SourceDocuments>
|
|
296
|
-
<SalesInvoices>
|
|
297
|
-
<NumberOfEntries>1</NumberOfEntries>
|
|
298
|
-
<TotalDebit>0.00</TotalDebit>
|
|
299
|
-
<TotalCredit>${formatNumber(totalCredit)}</TotalCredit>
|
|
300
|
-
${this.generateInvoice()}
|
|
301
|
-
</SalesInvoices>
|
|
302
|
-
<MovementOfGoods>
|
|
303
|
-
<NumberOfMovementLines>0</NumberOfMovementLines>
|
|
304
|
-
<TotalQuantityIssued>0</TotalQuantityIssued>
|
|
305
|
-
</MovementOfGoods>
|
|
306
|
-
<WorkingDocuments>
|
|
307
|
-
<NumberOfEntries>0</NumberOfEntries>
|
|
308
|
-
<TotalDebit>0.00</TotalDebit>
|
|
309
|
-
<TotalCredit>0.00</TotalCredit>
|
|
310
|
-
</WorkingDocuments>
|
|
311
|
-
<Payments>
|
|
312
|
-
<NumberOfEntries>0</NumberOfEntries>
|
|
313
|
-
<TotalDebit>0.00</TotalDebit>
|
|
314
|
-
<TotalCredit>0.00</TotalCredit>
|
|
315
|
-
</Payments>
|
|
316
|
-
</SourceDocuments>`;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Generate single invoice entry
|
|
320
|
-
*/
|
|
321
|
-
generateInvoice() {
|
|
322
|
-
const invoiceDate = this.formatDate(this.invoice.dateIssued);
|
|
323
|
-
const invoiceDateTime = this.formatDateTime(this.invoice.dateIssued);
|
|
324
|
-
const period = new Date(this.invoice.dateIssued).getMonth() + 1;
|
|
325
|
-
// Format invoice number for SAF-T (e.g., "FT 2025/1")
|
|
326
|
-
const invoiceNo = this.formatInvoiceNo(this.invoice.invoiceNo);
|
|
327
|
-
// ATCUD - use provided or generate based on example format (JJBDDFHD-sequence)
|
|
328
|
-
const sequenceNum = this.extractSequenceNumber(this.invoice.invoiceNo);
|
|
329
|
-
const atcud = this.options.atcud || `JJBDDFHD-${sequenceNum}`;
|
|
330
|
-
// Hash info - placeholder values (real hash requires certified software)
|
|
331
|
-
const hashInfo = this.options.hashInfo || {
|
|
332
|
-
hash: "Sn7zDVVOxNcAcW74Yd1b9YBHuwloo5y59NCW0MGBiBkuUz1fpLe8748ODBeFg5++Uzo2qNPfnzTOagpfe1IO3FZ54PJ65RquXuJ3TUc1rJMlEA0O89NGIVPbnbMQbk8CLFBkEolJoqfoqFHHc/GIedejFEyf+KrjhjsmxG/WvI4=",
|
|
333
|
-
hashControl: "1",
|
|
334
|
-
};
|
|
335
|
-
// Default source ID from example
|
|
336
|
-
const sourceId = this.options.sourceId || "919456";
|
|
337
|
-
const customerId = this.options.customerId || "1";
|
|
338
|
-
// Default EAC code from example (63110 = Data processing, hosting and related activities)
|
|
339
|
-
const eacCode = this.options.eacCode || "63110";
|
|
340
|
-
// Calculate totals
|
|
341
|
-
const netTotal = this.invoice.lineItems.reduce((sum, item) => sum + item.totalPriceTaxExcl, 0);
|
|
342
|
-
const grossTotal = this.invoice.lineItems.reduce((sum, item) => sum + item.totalPriceTaxIncl, 0);
|
|
343
|
-
const taxPayable = grossTotal - netTotal;
|
|
344
|
-
return `<Invoice>
|
|
345
|
-
<InvoiceNo>${this.escapeXml(invoiceNo)}</InvoiceNo>
|
|
346
|
-
<ATCUD>${this.escapeXml(atcud)}</ATCUD>
|
|
347
|
-
<DocumentStatus>
|
|
348
|
-
<InvoiceStatus>N</InvoiceStatus>
|
|
349
|
-
<InvoiceStatusDate>${invoiceDateTime}</InvoiceStatusDate>
|
|
350
|
-
<SourceID>${this.escapeXml(sourceId)}</SourceID>
|
|
351
|
-
<SourceBilling>P</SourceBilling>
|
|
352
|
-
</DocumentStatus>
|
|
353
|
-
<Hash>${this.escapeXml(hashInfo.hash)}</Hash>
|
|
354
|
-
<HashControl>${this.escapeXml(hashInfo.hashControl)}</HashControl>
|
|
355
|
-
<Period>${period}</Period>
|
|
356
|
-
<InvoiceDate>${invoiceDate}</InvoiceDate>
|
|
357
|
-
<InvoiceType>FT</InvoiceType>
|
|
358
|
-
<SpecialRegimes>
|
|
359
|
-
<SelfBillingIndicator>0</SelfBillingIndicator>
|
|
360
|
-
<CashVATSchemeIndicator>0</CashVATSchemeIndicator>
|
|
361
|
-
<ThirdPartiesBillingIndicator>0</ThirdPartiesBillingIndicator>
|
|
362
|
-
</SpecialRegimes>
|
|
363
|
-
<SourceID>${this.escapeXml(sourceId)}</SourceID>
|
|
364
|
-
<EACCode>${this.escapeXml(eacCode)}</EACCode>
|
|
365
|
-
<SystemEntryDate>${invoiceDateTime}</SystemEntryDate>
|
|
366
|
-
<CustomerID>${this.escapeXml(customerId)}</CustomerID>
|
|
367
|
-
${this.generateInvoiceLines()}
|
|
368
|
-
<DocumentTotals>
|
|
369
|
-
<TaxPayable>${formatNumber(taxPayable, 1)}</TaxPayable>
|
|
370
|
-
<NetTotal>${formatNumber(netTotal)}</NetTotal>
|
|
371
|
-
<GrossTotal>${formatNumber(grossTotal)}</GrossTotal>
|
|
372
|
-
</DocumentTotals>
|
|
373
|
-
</Invoice>`;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Generate invoice line items
|
|
377
|
-
*/
|
|
378
|
-
generateInvoiceLines() {
|
|
379
|
-
return this.invoice.lineItems
|
|
380
|
-
.map((item, index) => this.generateInvoiceLine(item, index + 1))
|
|
381
|
-
.join("\n ");
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Generate a single invoice line
|
|
385
|
-
*/
|
|
386
|
-
generateInvoiceLine(item, lineNumber) {
|
|
387
|
-
const taxPointDate = this.formatDate(this.invoice.dateIssued);
|
|
388
|
-
const taxCode = this.getTaxCode(item.taxPercent);
|
|
389
|
-
const productCode = String(lineNumber).padStart(3, "0");
|
|
390
|
-
// Tax exemption info (for 0% VAT) - using default from Portuguese SAF-T example
|
|
391
|
-
const taxExemption = item.taxPercent === 0 ? this.options.taxExemption || {
|
|
392
|
-
reason: "Outras situações de não liquidação do imposto (Exemplos: art",
|
|
393
|
-
code: "M99",
|
|
394
|
-
} : null;
|
|
395
|
-
return `<Line>
|
|
396
|
-
<LineNumber>${lineNumber}</LineNumber>
|
|
397
|
-
<ProductCode>${productCode}</ProductCode>
|
|
398
|
-
<ProductDescription>${this.escapeXml(item.description)}</ProductDescription>
|
|
399
|
-
<Quantity>${formatNumber(item.quantity)}</Quantity>
|
|
400
|
-
<UnitOfMeasure>UN</UnitOfMeasure>
|
|
401
|
-
<UnitPrice>${formatUnitPrice(item.unitPriceTaxExcl)}</UnitPrice>
|
|
402
|
-
<TaxPointDate>${taxPointDate}</TaxPointDate>
|
|
403
|
-
<Description>${this.escapeXml(item.description)}</Description>
|
|
404
|
-
<CreditAmount>${formatNumber(item.totalPriceTaxExcl)}</CreditAmount>
|
|
405
|
-
<Tax>
|
|
406
|
-
<TaxType>IVA</TaxType>
|
|
407
|
-
<TaxCountryRegion>PT</TaxCountryRegion>
|
|
408
|
-
<TaxCode>${taxCode}</TaxCode>
|
|
409
|
-
<TaxPercentage>${item.taxPercent}</TaxPercentage>
|
|
410
|
-
</Tax>
|
|
411
|
-
${taxExemption ? `<TaxExemptionReason>${this.escapeXml(taxExemption.reason)}</TaxExemptionReason>
|
|
412
|
-
<TaxExemptionCode>${this.escapeXml(taxExemption.code)}</TaxExemptionCode>` : ""}
|
|
413
|
-
</Line>`;
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Format invoice number for SAF-T PT format
|
|
417
|
-
* Converts "Invoice-123" to "FT 2025/123"
|
|
418
|
-
*/
|
|
419
|
-
formatInvoiceNo(invoiceNo) {
|
|
420
|
-
// Check if already in SAF-T format
|
|
421
|
-
if (/^[A-Z]{2}\s\d{4}\/\d+$/.test(invoiceNo)) {
|
|
422
|
-
return invoiceNo;
|
|
423
|
-
}
|
|
424
|
-
// Extract sequence number
|
|
425
|
-
const sequenceMatch = invoiceNo.match(/\d+/);
|
|
426
|
-
const sequence = sequenceMatch ? sequenceMatch[0] : "1";
|
|
427
|
-
const year = new Date(this.invoice.dateIssued).getFullYear();
|
|
428
|
-
return `FT ${year}/${sequence}`;
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Extract sequence number from invoice number
|
|
432
|
-
*/
|
|
433
|
-
extractSequenceNumber(invoiceNo) {
|
|
434
|
-
const match = invoiceNo.match(/\d+/);
|
|
435
|
-
return match ? match[0] : "1";
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* Extract tax ID from legal entity
|
|
439
|
-
*/
|
|
440
|
-
extractTaxId(entity) {
|
|
441
|
-
if (!entity?.id)
|
|
442
|
-
return "";
|
|
443
|
-
const taxId = entity.id?.taxId;
|
|
444
|
-
const corpRegId = entity.id?.corpRegId;
|
|
445
|
-
// Remove country prefix if present (e.g., "PT515947504" -> "515947504")
|
|
446
|
-
const id = taxId || corpRegId || "";
|
|
447
|
-
return id.replace(/^[A-Z]{2}/, "");
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Format date as YYYY-MM-DD
|
|
451
|
-
*/
|
|
452
|
-
formatDate(dateString) {
|
|
453
|
-
if (!dateString)
|
|
454
|
-
return "";
|
|
455
|
-
try {
|
|
456
|
-
const date = new Date(dateString);
|
|
457
|
-
if (isNaN(date.getTime()))
|
|
458
|
-
return "";
|
|
459
|
-
return date.toISOString().split("T")[0];
|
|
460
|
-
}
|
|
461
|
-
catch {
|
|
462
|
-
return "";
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Format datetime as YYYY-MM-DDTHH:MM:SS
|
|
467
|
-
*/
|
|
468
|
-
formatDateTime(dateString) {
|
|
469
|
-
if (!dateString)
|
|
470
|
-
return "";
|
|
471
|
-
try {
|
|
472
|
-
const date = new Date(dateString);
|
|
473
|
-
if (isNaN(date.getTime()))
|
|
474
|
-
return "";
|
|
475
|
-
return date.toISOString().replace(/\.\d{3}Z$/, "");
|
|
476
|
-
}
|
|
477
|
-
catch {
|
|
478
|
-
return "";
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
/**
|
|
482
|
-
* Get last day of month
|
|
483
|
-
*/
|
|
484
|
-
getLastDayOfMonth(year, month) {
|
|
485
|
-
const lastDay = new Date(year, month, 0).getDate();
|
|
486
|
-
return `${year}-${String(month).padStart(2, "0")}-${String(lastDay).padStart(2, "0")}`;
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* Escape special XML characters
|
|
490
|
-
*/
|
|
491
|
-
escapeXml(str) {
|
|
492
|
-
return str
|
|
493
|
-
.replace(/&/g, "&")
|
|
494
|
-
.replace(/</g, "<")
|
|
495
|
-
.replace(/>/g, ">")
|
|
496
|
-
.replace(/"/g, """)
|
|
497
|
-
.replace(/'/g, "'");
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* Export to file
|
|
501
|
-
*/
|
|
502
|
-
exportToFile(filename) {
|
|
503
|
-
const xml = this.convertInvoiceToSAFTPT();
|
|
504
|
-
const finalFilename = filename || this.options.filename || "saft-pt.xml";
|
|
505
|
-
const blob = new Blob([xml], { type: "application/xml" });
|
|
506
|
-
return new File([blob], finalFilename, { type: "application/xml" });
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* Trigger download in browser
|
|
510
|
-
*/
|
|
511
|
-
downloadSAFTPT(filename) {
|
|
512
|
-
const xml = this.convertInvoiceToSAFTPT();
|
|
513
|
-
const finalFilename = filename || this.options.filename || "saft-pt.xml";
|
|
514
|
-
const blob = new Blob([xml], { type: "application/xml" });
|
|
515
|
-
const link = document.createElement("a");
|
|
516
|
-
link.href = URL.createObjectURL(blob);
|
|
517
|
-
link.download = finalFilename;
|
|
518
|
-
document.body.appendChild(link);
|
|
519
|
-
link.click();
|
|
520
|
-
document.body.removeChild(link);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Export an invoice to SAF-T PT format
|
|
525
|
-
* @param options Export options
|
|
526
|
-
* @returns The generated XML file
|
|
527
|
-
*/
|
|
528
|
-
export function exportToSAFTPT(options) {
|
|
529
|
-
const exporter = new SAFTPTExporter(options);
|
|
530
|
-
return exporter.exportToFile();
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* Export and download an invoice as SAF-T PT
|
|
534
|
-
* @param options Export options
|
|
535
|
-
*/
|
|
536
|
-
export function downloadSAFTPT(options) {
|
|
537
|
-
const exporter = new SAFTPTExporter(options);
|
|
538
|
-
exporter.downloadSAFTPT();
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Convert invoice to SAF-T PT XML string
|
|
542
|
-
* @param options Export options
|
|
543
|
-
* @returns SAF-T PT XML string
|
|
544
|
-
*/
|
|
545
|
-
export function convertToSAFTPTXml(options) {
|
|
546
|
-
const exporter = new SAFTPTExporter(options);
|
|
547
|
-
return exporter.convertInvoiceToSAFTPT();
|
|
548
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { PHDocument } from "document-model";
|
|
2
|
-
import { type IAnalyticsStore } from "@powerhousedao/analytics-engine-core";
|
|
3
|
-
import { type InternalTransmitterUpdate, type IProcessor } from "document-drive";
|
|
4
|
-
export declare class LineItemProcessorProcessor implements IProcessor {
|
|
5
|
-
private readonly analyticsStore;
|
|
6
|
-
constructor(analyticsStore: IAnalyticsStore);
|
|
7
|
-
onStrands<TDocument extends PHDocument>(strands: InternalTransmitterUpdate[]): Promise<void>;
|
|
8
|
-
onDisconnect(): Promise<void>;
|
|
9
|
-
private clearSource;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/line-item-processor/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC3F,OAAO,EAAE,KAAK,yBAAyB,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjF,qBAAa,0BAA2B,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAAd,cAAc,EAAE,eAAe;IAItD,SAAS,CAAC,SAAS,SAAS,UAAU,EAC1C,OAAO,EAAE,yBAAyB,EAAE,GACnC,OAAO,CAAC,IAAI,CAAC;IAwBV,YAAY;YAEJ,WAAW;CAO1B"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { AnalyticsPath } from "@powerhousedao/analytics-engine-core";
|
|
2
|
-
import {} from "document-drive";
|
|
3
|
-
export class LineItemProcessorProcessor {
|
|
4
|
-
analyticsStore;
|
|
5
|
-
constructor(analyticsStore) {
|
|
6
|
-
this.analyticsStore = analyticsStore;
|
|
7
|
-
//
|
|
8
|
-
}
|
|
9
|
-
async onStrands(strands) {
|
|
10
|
-
if (strands.length === 0) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
for (const strand of strands) {
|
|
14
|
-
if (strand.operations.length === 0) {
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
const firstOp = strand.operations[0];
|
|
18
|
-
const source = AnalyticsPath.fromString(`ph/${strand.driveId}/${strand.documentId}/${strand.branch}/${strand.scope}`);
|
|
19
|
-
if (firstOp.index === 0) {
|
|
20
|
-
await this.clearSource(source);
|
|
21
|
-
}
|
|
22
|
-
for (const operation of strand.operations) {
|
|
23
|
-
console.log(">>> ", operation.type);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async onDisconnect() { }
|
|
28
|
-
async clearSource(source) {
|
|
29
|
-
try {
|
|
30
|
-
await this.analyticsStore.clearSeriesBySource(source, true);
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
console.error(e);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customResolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/invoice/customResolvers.ts"],"names":[],"mappings":"AAOA,QAAA,IAAI,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,GAAG,CAAC;IACpB,SAAS,EAAE,MAAM,CAAA;CACpB,CAAM,CAAC;AAQR,UAAU,yBAAyB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACrB;AAaD,eAAO,MAAM,4BAA4B,GAAU,GAAG,GAAG,EAAE,MAAM,GAAG,iBAwEnE,CAAC;AAEF,eAAO,MAAM,mCAAmC,GAAU,GAAG,GAAG,EAAE,MAAM,GAAG;;;;;;;;;;;EAkC1E,CAAA;AAED,eAAO,MAAM,6BAA6B,GAAU,GAAG,GAAG,EAAE,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;EA8E1F,CAAA;AAGD,eAAO,MAAM,UAAU,GAAI,iBAAiB,GAAG,SAE9C,CAAC;AAGF,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAG/B,eAAO,MAAM,6BAA6B,YAyBzC,CAAA;AAwCD,eAAO,MAAM,aAAa,GAAU,KAAK,GAAG,EAAE,KAAK,GAAG,iBAkJrD,CAAA"}
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|