arcli 2.0.0 → 2.2.0
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/CHANGELOG.md +106 -1
- package/README.md +21 -14
- package/dist/cli/arca-runtime.js +41 -0
- package/dist/cli/commands/billing-family.command.js +36 -9
- package/dist/cli/commands/billing-shortcuts.command.js +8 -2
- package/dist/cli/commands/billing.command.batch.js +28 -12
- package/dist/cli/commands/billing.command.interactive-preview.js +12 -13
- package/dist/cli/commands/billing.command.options.js +83 -39
- package/dist/cli/commands/billing.command.output.js +3 -3
- package/dist/cli/commands/billing.command.parser.js +44 -30
- package/dist/cli/commands/billing.command.pdf.js +9 -6
- package/dist/cli/commands/billing.command.shared.js +86 -49
- package/dist/cli/commands/billing.command.shortcuts.js +3 -4
- package/dist/cli/commands/completion.command.js +140 -0
- package/dist/cli/commands/config.command.js +44 -45
- package/dist/cli/commands/cuit-argument.js +10 -0
- package/dist/cli/commands/examples.command.js +0 -1
- package/dist/cli/commands/export-shortcut.command.js +19 -0
- package/dist/cli/commands/export.command.js +106 -0
- package/dist/cli/commands/export.command.options.js +140 -0
- package/dist/cli/commands/export.command.parser.js +84 -0
- package/dist/cli/commands/export.command.pdf.js +61 -0
- package/dist/cli/commands/fce-obligation.command.js +8 -16
- package/dist/cli/commands/interactive.command.js +9 -8
- package/dist/cli/commands/padron.command.js +46 -0
- package/dist/cli/commands/parameters.command.js +13 -13
- package/dist/cli/commands/pdf.command.js +17 -31
- package/dist/cli/commands/storybook.command.js +4 -4
- package/dist/cli/commands/vouchers.command.js +14 -14
- package/dist/cli/error-output.js +89 -11
- package/dist/cli/global-options.js +55 -0
- package/dist/cli/help-argv.js +0 -1
- package/dist/cli/help.js +243 -391
- package/dist/cli/ignored-global-options.js +32 -0
- package/dist/cli/index.js +12 -14
- package/dist/cli/interactive/advanced-options.js +13 -14
- package/dist/cli/interactive/config.flow.js +59 -20
- package/dist/cli/interactive/export.flow.js +263 -0
- package/dist/cli/interactive/history.flow.js +2 -3
- package/dist/cli/interactive/interactive-mode.js +63 -33
- package/dist/cli/interactive/invoice-picker.js +7 -7
- package/dist/cli/interactive/invoice.flow.js +35 -13
- package/dist/cli/interactive/note.flow.js +16 -16
- package/dist/cli/interactive/pdf.flow.js +9 -7
- package/dist/cli/interactive/prompts.js +0 -1
- package/dist/cli/interactive/receiver-padron.js +52 -0
- package/dist/cli/interactive/repeat.flow.js +10 -11
- package/dist/cli/interactive/session.js +13 -8
- package/dist/cli/interactive/status.flow.js +0 -1
- package/dist/cli/interactive/update.flow.js +0 -1
- package/dist/cli/interactive/validators.js +7 -6
- package/dist/cli/option-parsers.js +14 -4
- package/dist/cli/program.js +14 -5
- package/dist/cli/skipped-options.js +14 -0
- package/dist/cli/spinner.js +0 -1
- package/dist/cli/types.js +0 -1
- package/dist/cli/version.js +1 -2
- package/dist/index.js +0 -1
- package/dist/lib/dates/arca-date.js +3 -4
- package/dist/lib/errors/app-error.js +2 -2
- package/dist/lib/files/read-json-file.js +2 -3
- package/dist/lib/files/restrict-to-owner.js +0 -1
- package/dist/lib/files/write-new-file.js +29 -0
- package/dist/lib/identity/cuit.js +26 -0
- package/dist/lib/identity/format-cuit.js +1 -2
- package/dist/lib/links.js +2 -1
- package/dist/lib/numbers/argentine-amount.js +3 -4
- package/dist/lib/numbers/strict-integer.js +0 -1
- package/dist/lib/paths/mask-path.js +0 -1
- package/dist/lib/security/certificate.js +10 -8
- package/dist/lib/security/pem.js +2 -3
- package/dist/modules/billing/billing-response.js +16 -5
- package/dist/modules/billing/billing.amounts.js +3 -4
- package/dist/modules/billing/billing.associated-period.js +7 -8
- package/dist/modules/billing/billing.associated-vouchers.js +5 -6
- package/dist/modules/billing/billing.batch.js +12 -5
- package/dist/modules/billing/billing.constants.js +0 -1
- package/dist/modules/billing/billing.currency.js +4 -5
- package/dist/modules/billing/billing.date-range.js +27 -11
- package/dist/modules/billing/billing.display.js +14 -8
- package/dist/modules/billing/billing.errors.js +2 -3
- package/dist/modules/billing/billing.fce.js +3 -4
- package/dist/modules/billing/billing.iva-receptor.js +2 -3
- package/dist/modules/billing/billing.json-format.js +0 -1
- package/dist/modules/billing/billing.json-input.js +278 -0
- package/dist/modules/billing/billing.labels.js +1 -2
- package/dist/modules/billing/billing.mappers.js +0 -1
- package/dist/modules/billing/billing.padron.js +59 -0
- package/dist/modules/billing/billing.presenter.js +0 -1
- package/dist/modules/billing/billing.schemas.js +20 -6
- package/dist/modules/billing/billing.serialize.js +11 -15
- package/dist/modules/billing/billing.service.js +25 -4
- package/dist/modules/billing/billing.text.js +4 -13
- package/dist/modules/billing/billing.types.internal.js +0 -1
- package/dist/modules/billing/billing.types.js +0 -1
- package/dist/modules/billing/billing.validation.js +13 -11
- package/dist/modules/billing/voucher-kind-map.js +15 -16
- package/dist/modules/completion/completion.js +53 -0
- package/dist/modules/completion/completion.presenter.js +35 -0
- package/dist/modules/completion/installer.js +92 -0
- package/dist/modules/completion/shell-scripts.js +46 -0
- package/dist/modules/config/certificate-expiry.js +90 -0
- package/dist/modules/config/config-doctor.js +42 -28
- package/dist/modules/config/config-value-parser.js +32 -17
- package/dist/modules/config/config.export-credentials.js +23 -0
- package/dist/modules/config/config.presenter.js +28 -6
- package/dist/modules/config/config.schemas.js +27 -12
- package/dist/modules/config/config.sections.js +31 -11
- package/dist/modules/config/config.service.js +38 -9
- package/dist/modules/examples/examples.js +72 -37
- package/dist/modules/export/export.items.js +149 -0
- package/dist/modules/export/export.json-input.js +91 -0
- package/dist/modules/export/export.mappers.js +293 -0
- package/dist/modules/export/export.presenter.js +2 -0
- package/dist/modules/export/export.response.js +86 -0
- package/dist/modules/export/export.serialize.js +70 -0
- package/dist/modules/export/export.service.js +146 -0
- package/dist/modules/export/export.text.js +177 -0
- package/dist/modules/export/export.types.js +36 -0
- package/dist/modules/fce/fce-obligation.js +3 -4
- package/dist/modules/fce/fce-obligation.presenter.js +2 -3
- package/dist/modules/interactive/amount-input.js +0 -1
- package/dist/modules/interactive/choices.js +10 -2
- package/dist/modules/interactive/config-fields.js +17 -3
- package/dist/modules/interactive/equivalent-command.js +6 -3
- package/dist/modules/interactive/export-equivalent-command.js +40 -0
- package/dist/modules/interactive/invoice-copy.js +1 -2
- package/dist/modules/interactive/periods.js +0 -1
- package/dist/modules/interactive/wizard.js +0 -1
- package/dist/modules/padron/padron.js +23 -0
- package/dist/modules/padron/padron.presenter.js +48 -0
- package/dist/modules/parameters/health.js +0 -1
- package/dist/modules/parameters/parameters.js +2 -3
- package/dist/modules/parameters/parameters.presenter.js +14 -12
- package/dist/modules/parameters/status.js +0 -1
- package/dist/modules/pdf/pdf-data.mapper.js +94 -3
- package/dist/modules/pdf/pdf-decision.js +0 -1
- package/dist/modules/pdf/pdf-file-name.js +0 -1
- package/dist/modules/pdf/pdf-issuer.js +3 -3
- package/dist/modules/pdf/pdf-legends.js +35 -0
- package/dist/modules/pdf/pdf.errors.js +0 -1
- package/dist/modules/pdf/pdf.types.js +0 -1
- package/dist/modules/storybook/showcase-theme.js +0 -1
- package/dist/modules/storybook/showcase.js +35 -23
- package/dist/modules/update-check/changelog.js +0 -1
- package/dist/modules/update-check/update-check.presenter.js +6 -7
- package/dist/modules/update-check/update-check.service.js +0 -1
- package/dist/modules/vouchers/voucher-history.js +0 -1
- package/dist/modules/vouchers/voucher-history.presenter.js +3 -4
- package/dist/services/arca/arca-billing.gateway.js +18 -4
- package/dist/services/arca/arca-client.factory.js +27 -1
- package/dist/services/arca/arca-context.resolver.js +17 -7
- package/dist/services/arca/arca-export.gateway.js +146 -0
- package/dist/services/arca/arca-fce-obligation.gateway.js +2 -3
- package/dist/services/arca/arca-padron.gateway.js +103 -0
- package/dist/services/arca/arca-parameters.gateway.js +2 -3
- package/dist/services/arca/arca-voucher-history.gateway.js +2 -3
- package/dist/services/arca/last-voucher.js +26 -0
- package/dist/services/clipboard/clipboard.js +0 -1
- package/dist/services/pdf/escape-html.js +0 -1
- package/dist/services/pdf/pdf-browser.js +0 -1
- package/dist/services/pdf/pdf-exporter.js +26 -11
- package/dist/services/pdf/pdf-plugin.js +41 -14
- package/dist/ui/components/certificateBanner.js +8 -0
- package/dist/ui/components/contentPanel.js +0 -1
- package/dist/ui/components/errorPanel.js +0 -1
- package/dist/ui/components/index.js +1 -1
- package/dist/ui/components/keyValuePanel.js +0 -1
- package/dist/ui/components/noticePanel.js +0 -1
- package/dist/ui/components/rawPanel.js +0 -1
- package/dist/ui/components/sectionHeading.js +0 -1
- package/dist/ui/components/statusBar.js +0 -1
- package/dist/ui/components/statusPanel.js +0 -1
- package/dist/ui/components/testingBanner.js +0 -1
- package/dist/ui/index.js +0 -1
- package/dist/ui/presenters/billing.presenter.js +0 -1
- package/dist/ui/presenters/config.presenter.js +1 -2
- package/dist/ui/presenters/errors.presenter.js +14 -12
- package/dist/ui/presenters/errors.zod-presenter.js +13 -35
- package/dist/ui/presenters/export.presenter.js +1 -0
- package/dist/ui/presenters/index.js +1 -1
- package/dist/ui/presenters/pdf.presenter.js +1 -2
- package/dist/ui/presenters/showcase.presenter.js +0 -1
- package/dist/ui/primitives/index.js +0 -1
- package/dist/ui/primitives/renderDivider.js +0 -1
- package/dist/ui/primitives/renderFooter.js +0 -1
- package/dist/ui/primitives/renderJson.js +0 -1
- package/dist/ui/primitives/renderKeyValue.js +0 -1
- package/dist/ui/primitives/renderLogo.js +0 -1
- package/dist/ui/primitives/renderObject.js +0 -1
- package/dist/ui/primitives/renderPanel.js +0 -1
- package/dist/ui/primitives/renderSubtitle.js +0 -1
- package/dist/ui/primitives/renderTable.js +0 -1
- package/dist/ui/primitives/terminalWidth.js +0 -1
- package/dist/ui/primitives/text.js +0 -1
- package/dist/ui/stream/index.js +0 -1
- package/dist/ui/stream/terminal-stream.js +13 -2
- package/dist/ui/theme/index.js +0 -1
- package/dist/ui/theme/theme.js +0 -1
- package/llms.txt +122 -45
- package/package.json +1 -2
- package/dist/cli/commands/billing-family.command.d.ts +0 -2
- package/dist/cli/commands/billing-family.command.js.map +0 -1
- package/dist/cli/commands/billing-shortcuts.command.d.ts +0 -2
- package/dist/cli/commands/billing-shortcuts.command.js.map +0 -1
- package/dist/cli/commands/billing.command.batch.d.ts +0 -22
- package/dist/cli/commands/billing.command.batch.js.map +0 -1
- package/dist/cli/commands/billing.command.interactive-preview.d.ts +0 -18
- package/dist/cli/commands/billing.command.interactive-preview.js.map +0 -1
- package/dist/cli/commands/billing.command.options.d.ts +0 -2
- package/dist/cli/commands/billing.command.options.js.map +0 -1
- package/dist/cli/commands/billing.command.output.d.ts +0 -14
- package/dist/cli/commands/billing.command.output.js.map +0 -1
- package/dist/cli/commands/billing.command.parser.d.ts +0 -28
- package/dist/cli/commands/billing.command.parser.js.map +0 -1
- package/dist/cli/commands/billing.command.pdf.d.ts +0 -24
- package/dist/cli/commands/billing.command.pdf.js.map +0 -1
- package/dist/cli/commands/billing.command.shared.d.ts +0 -7
- package/dist/cli/commands/billing.command.shared.js.map +0 -1
- package/dist/cli/commands/billing.command.shortcuts.d.ts +0 -7
- package/dist/cli/commands/billing.command.shortcuts.js.map +0 -1
- package/dist/cli/commands/config.command.d.ts +0 -7
- package/dist/cli/commands/config.command.js.map +0 -1
- package/dist/cli/commands/examples.command.d.ts +0 -2
- package/dist/cli/commands/examples.command.js.map +0 -1
- package/dist/cli/commands/fce-obligation.command.d.ts +0 -2
- package/dist/cli/commands/fce-obligation.command.js.map +0 -1
- package/dist/cli/commands/interactive.command.d.ts +0 -3
- package/dist/cli/commands/interactive.command.js.map +0 -1
- package/dist/cli/commands/parameters.command.d.ts +0 -2
- package/dist/cli/commands/parameters.command.js.map +0 -1
- package/dist/cli/commands/pdf.command.d.ts +0 -2
- package/dist/cli/commands/pdf.command.js.map +0 -1
- package/dist/cli/commands/storybook.command.d.ts +0 -2
- package/dist/cli/commands/storybook.command.js.map +0 -1
- package/dist/cli/commands/vouchers.command.d.ts +0 -2
- package/dist/cli/commands/vouchers.command.js.map +0 -1
- package/dist/cli/error-output.d.ts +0 -7
- package/dist/cli/error-output.js.map +0 -1
- package/dist/cli/help-argv.d.ts +0 -5
- package/dist/cli/help-argv.js.map +0 -1
- package/dist/cli/help.d.ts +0 -12
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/interactive/advanced-options.d.ts +0 -21
- package/dist/cli/interactive/advanced-options.js.map +0 -1
- package/dist/cli/interactive/config.flow.d.ts +0 -5
- package/dist/cli/interactive/config.flow.js.map +0 -1
- package/dist/cli/interactive/history.flow.d.ts +0 -6
- package/dist/cli/interactive/history.flow.js.map +0 -1
- package/dist/cli/interactive/interactive-mode.d.ts +0 -3
- package/dist/cli/interactive/interactive-mode.js.map +0 -1
- package/dist/cli/interactive/invoice-picker.d.ts +0 -25
- package/dist/cli/interactive/invoice-picker.js.map +0 -1
- package/dist/cli/interactive/invoice.flow.d.ts +0 -20
- package/dist/cli/interactive/invoice.flow.js.map +0 -1
- package/dist/cli/interactive/note.flow.d.ts +0 -32
- package/dist/cli/interactive/note.flow.js.map +0 -1
- package/dist/cli/interactive/pdf.flow.d.ts +0 -5
- package/dist/cli/interactive/pdf.flow.js.map +0 -1
- package/dist/cli/interactive/prompts.d.ts +0 -57
- package/dist/cli/interactive/prompts.js.map +0 -1
- package/dist/cli/interactive/repeat.flow.d.ts +0 -13
- package/dist/cli/interactive/repeat.flow.js.map +0 -1
- package/dist/cli/interactive/session.d.ts +0 -22
- package/dist/cli/interactive/session.js.map +0 -1
- package/dist/cli/interactive/status.flow.d.ts +0 -3
- package/dist/cli/interactive/status.flow.js.map +0 -1
- package/dist/cli/interactive/update.flow.d.ts +0 -6
- package/dist/cli/interactive/update.flow.js.map +0 -1
- package/dist/cli/interactive/validators.d.ts +0 -9
- package/dist/cli/interactive/validators.js.map +0 -1
- package/dist/cli/option-parsers.d.ts +0 -6
- package/dist/cli/option-parsers.js.map +0 -1
- package/dist/cli/program.d.ts +0 -2
- package/dist/cli/program.js.map +0 -1
- package/dist/cli/spinner.d.ts +0 -8
- package/dist/cli/spinner.js.map +0 -1
- package/dist/cli/types.d.ts +0 -6
- package/dist/cli/types.js.map +0 -1
- package/dist/cli/version.d.ts +0 -1
- package/dist/cli/version.js.map +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/dates/arca-date.d.ts +0 -19
- package/dist/lib/dates/arca-date.js.map +0 -1
- package/dist/lib/errors/app-error.d.ts +0 -17
- package/dist/lib/errors/app-error.js.map +0 -1
- package/dist/lib/files/read-json-file.d.ts +0 -1
- package/dist/lib/files/read-json-file.js.map +0 -1
- package/dist/lib/files/restrict-to-owner.d.ts +0 -7
- package/dist/lib/files/restrict-to-owner.js.map +0 -1
- package/dist/lib/identity/format-cuit.d.ts +0 -2
- package/dist/lib/identity/format-cuit.js.map +0 -1
- package/dist/lib/links.d.ts +0 -2
- package/dist/lib/links.js.map +0 -1
- package/dist/lib/numbers/argentine-amount.d.ts +0 -23
- package/dist/lib/numbers/argentine-amount.js.map +0 -1
- package/dist/lib/numbers/strict-integer.d.ts +0 -4
- package/dist/lib/numbers/strict-integer.js.map +0 -1
- package/dist/lib/paths/mask-path.d.ts +0 -1
- package/dist/lib/paths/mask-path.js.map +0 -1
- package/dist/lib/security/certificate.d.ts +0 -7
- package/dist/lib/security/certificate.js.map +0 -1
- package/dist/lib/security/pem.d.ts +0 -5
- package/dist/lib/security/pem.js.map +0 -1
- package/dist/modules/billing/billing-response.d.ts +0 -4
- package/dist/modules/billing/billing-response.js.map +0 -1
- package/dist/modules/billing/billing.amounts.d.ts +0 -21
- package/dist/modules/billing/billing.amounts.js.map +0 -1
- package/dist/modules/billing/billing.associated-period.d.ts +0 -8
- package/dist/modules/billing/billing.associated-period.js.map +0 -1
- package/dist/modules/billing/billing.associated-vouchers.d.ts +0 -12
- package/dist/modules/billing/billing.associated-vouchers.js.map +0 -1
- package/dist/modules/billing/billing.batch.d.ts +0 -23
- package/dist/modules/billing/billing.batch.js.map +0 -1
- package/dist/modules/billing/billing.constants.d.ts +0 -2
- package/dist/modules/billing/billing.constants.js.map +0 -1
- package/dist/modules/billing/billing.currency.d.ts +0 -18
- package/dist/modules/billing/billing.currency.js.map +0 -1
- package/dist/modules/billing/billing.date-range.d.ts +0 -9
- package/dist/modules/billing/billing.date-range.js.map +0 -1
- package/dist/modules/billing/billing.display.d.ts +0 -13
- package/dist/modules/billing/billing.display.js.map +0 -1
- package/dist/modules/billing/billing.errors.d.ts +0 -12
- package/dist/modules/billing/billing.errors.js.map +0 -1
- package/dist/modules/billing/billing.fce.d.ts +0 -21
- package/dist/modules/billing/billing.fce.js.map +0 -1
- package/dist/modules/billing/billing.iva-receptor.d.ts +0 -8
- package/dist/modules/billing/billing.iva-receptor.js.map +0 -1
- package/dist/modules/billing/billing.json-format.d.ts +0 -6
- package/dist/modules/billing/billing.json-format.js.map +0 -1
- package/dist/modules/billing/billing.labels.d.ts +0 -9
- package/dist/modules/billing/billing.labels.js.map +0 -1
- package/dist/modules/billing/billing.mappers.d.ts +0 -8
- package/dist/modules/billing/billing.mappers.js.map +0 -1
- package/dist/modules/billing/billing.presenter.d.ts +0 -7
- package/dist/modules/billing/billing.presenter.js.map +0 -1
- package/dist/modules/billing/billing.schemas.d.ts +0 -142
- package/dist/modules/billing/billing.schemas.js.map +0 -1
- package/dist/modules/billing/billing.serialize.d.ts +0 -8
- package/dist/modules/billing/billing.serialize.js.map +0 -1
- package/dist/modules/billing/billing.service.d.ts +0 -27
- package/dist/modules/billing/billing.service.js.map +0 -1
- package/dist/modules/billing/billing.text.d.ts +0 -8
- package/dist/modules/billing/billing.text.js.map +0 -1
- package/dist/modules/billing/billing.types.d.ts +0 -13
- package/dist/modules/billing/billing.types.internal.d.ts +0 -30
- package/dist/modules/billing/billing.types.internal.js.map +0 -1
- package/dist/modules/billing/billing.types.js.map +0 -1
- package/dist/modules/billing/billing.validation.d.ts +0 -7
- package/dist/modules/billing/billing.validation.js.map +0 -1
- package/dist/modules/billing/voucher-kind-map.d.ts +0 -9
- package/dist/modules/billing/voucher-kind-map.js.map +0 -1
- package/dist/modules/config/config-doctor.d.ts +0 -15
- package/dist/modules/config/config-doctor.js.map +0 -1
- package/dist/modules/config/config-value-parser.d.ts +0 -2
- package/dist/modules/config/config-value-parser.js.map +0 -1
- package/dist/modules/config/config.presenter.d.ts +0 -15
- package/dist/modules/config/config.presenter.js.map +0 -1
- package/dist/modules/config/config.schemas.d.ts +0 -154
- package/dist/modules/config/config.schemas.js.map +0 -1
- package/dist/modules/config/config.sections.d.ts +0 -14
- package/dist/modules/config/config.sections.js.map +0 -1
- package/dist/modules/config/config.service.d.ts +0 -35
- package/dist/modules/config/config.service.js.map +0 -1
- package/dist/modules/examples/examples.d.ts +0 -1
- package/dist/modules/examples/examples.js.map +0 -1
- package/dist/modules/fce/fce-obligation.d.ts +0 -20
- package/dist/modules/fce/fce-obligation.js.map +0 -1
- package/dist/modules/fce/fce-obligation.presenter.d.ts +0 -9
- package/dist/modules/fce/fce-obligation.presenter.js.map +0 -1
- package/dist/modules/interactive/amount-input.d.ts +0 -4
- package/dist/modules/interactive/amount-input.js.map +0 -1
- package/dist/modules/interactive/choices.d.ts +0 -13
- package/dist/modules/interactive/choices.js.map +0 -1
- package/dist/modules/interactive/config-fields.d.ts +0 -20
- package/dist/modules/interactive/config-fields.js.map +0 -1
- package/dist/modules/interactive/equivalent-command.d.ts +0 -8
- package/dist/modules/interactive/equivalent-command.js.map +0 -1
- package/dist/modules/interactive/invoice-copy.d.ts +0 -19
- package/dist/modules/interactive/invoice-copy.js.map +0 -1
- package/dist/modules/interactive/periods.d.ts +0 -7
- package/dist/modules/interactive/periods.js.map +0 -1
- package/dist/modules/interactive/wizard.d.ts +0 -16
- package/dist/modules/interactive/wizard.js.map +0 -1
- package/dist/modules/parameters/health.d.ts +0 -17
- package/dist/modules/parameters/health.js.map +0 -1
- package/dist/modules/parameters/parameters.d.ts +0 -50
- package/dist/modules/parameters/parameters.js.map +0 -1
- package/dist/modules/parameters/parameters.presenter.d.ts +0 -12
- package/dist/modules/parameters/parameters.presenter.js.map +0 -1
- package/dist/modules/parameters/status.d.ts +0 -31
- package/dist/modules/parameters/status.js.map +0 -1
- package/dist/modules/pdf/pdf-data.mapper.d.ts +0 -4
- package/dist/modules/pdf/pdf-data.mapper.js.map +0 -1
- package/dist/modules/pdf/pdf-decision.d.ts +0 -14
- package/dist/modules/pdf/pdf-decision.js.map +0 -1
- package/dist/modules/pdf/pdf-file-name.d.ts +0 -3
- package/dist/modules/pdf/pdf-file-name.js.map +0 -1
- package/dist/modules/pdf/pdf-issuer.d.ts +0 -8
- package/dist/modules/pdf/pdf-issuer.js.map +0 -1
- package/dist/modules/pdf/pdf.errors.d.ts +0 -9
- package/dist/modules/pdf/pdf.errors.js.map +0 -1
- package/dist/modules/pdf/pdf.types.d.ts +0 -91
- package/dist/modules/pdf/pdf.types.js.map +0 -1
- package/dist/modules/storybook/showcase-theme.d.ts +0 -7
- package/dist/modules/storybook/showcase-theme.js.map +0 -1
- package/dist/modules/storybook/showcase.d.ts +0 -2
- package/dist/modules/storybook/showcase.js.map +0 -1
- package/dist/modules/update-check/changelog.d.ts +0 -23
- package/dist/modules/update-check/changelog.js.map +0 -1
- package/dist/modules/update-check/update-check.presenter.d.ts +0 -6
- package/dist/modules/update-check/update-check.presenter.js.map +0 -1
- package/dist/modules/update-check/update-check.service.d.ts +0 -11
- package/dist/modules/update-check/update-check.service.js.map +0 -1
- package/dist/modules/vouchers/voucher-history.d.ts +0 -39
- package/dist/modules/vouchers/voucher-history.js.map +0 -1
- package/dist/modules/vouchers/voucher-history.presenter.d.ts +0 -29
- package/dist/modules/vouchers/voucher-history.presenter.js.map +0 -1
- package/dist/services/arca/arca-billing.gateway.d.ts +0 -10
- package/dist/services/arca/arca-billing.gateway.js.map +0 -1
- package/dist/services/arca/arca-client.factory.d.ts +0 -5
- package/dist/services/arca/arca-client.factory.js.map +0 -1
- package/dist/services/arca/arca-context.resolver.d.ts +0 -44
- package/dist/services/arca/arca-context.resolver.js.map +0 -1
- package/dist/services/arca/arca-fce-obligation.gateway.d.ts +0 -7
- package/dist/services/arca/arca-fce-obligation.gateway.js.map +0 -1
- package/dist/services/arca/arca-parameters.gateway.d.ts +0 -10
- package/dist/services/arca/arca-parameters.gateway.js.map +0 -1
- package/dist/services/arca/arca-voucher-history.gateway.d.ts +0 -8
- package/dist/services/arca/arca-voucher-history.gateway.js.map +0 -1
- package/dist/services/clipboard/clipboard.d.ts +0 -2
- package/dist/services/clipboard/clipboard.js.map +0 -1
- package/dist/services/pdf/escape-html.d.ts +0 -6
- package/dist/services/pdf/escape-html.js.map +0 -1
- package/dist/services/pdf/pdf-browser.d.ts +0 -5
- package/dist/services/pdf/pdf-browser.js.map +0 -1
- package/dist/services/pdf/pdf-exporter.d.ts +0 -19
- package/dist/services/pdf/pdf-exporter.js.map +0 -1
- package/dist/services/pdf/pdf-plugin.d.ts +0 -50
- package/dist/services/pdf/pdf-plugin.js.map +0 -1
- package/dist/ui/components/contentPanel.d.ts +0 -5
- package/dist/ui/components/contentPanel.js.map +0 -1
- package/dist/ui/components/errorPanel.d.ts +0 -1
- package/dist/ui/components/errorPanel.js.map +0 -1
- package/dist/ui/components/index.d.ts +0 -9
- package/dist/ui/components/index.js.map +0 -1
- package/dist/ui/components/keyValuePanel.d.ts +0 -3
- package/dist/ui/components/keyValuePanel.js.map +0 -1
- package/dist/ui/components/noticePanel.d.ts +0 -3
- package/dist/ui/components/noticePanel.js.map +0 -1
- package/dist/ui/components/rawPanel.d.ts +0 -1
- package/dist/ui/components/rawPanel.js.map +0 -1
- package/dist/ui/components/sectionHeading.d.ts +0 -3
- package/dist/ui/components/sectionHeading.js.map +0 -1
- package/dist/ui/components/statusBar.d.ts +0 -19
- package/dist/ui/components/statusBar.js.map +0 -1
- package/dist/ui/components/statusPanel.d.ts +0 -3
- package/dist/ui/components/statusPanel.js.map +0 -1
- package/dist/ui/components/testingBanner.d.ts +0 -2
- package/dist/ui/components/testingBanner.js.map +0 -1
- package/dist/ui/index.d.ts +0 -5
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/presenters/billing.presenter.d.ts +0 -2
- package/dist/ui/presenters/billing.presenter.js.map +0 -1
- package/dist/ui/presenters/config.presenter.d.ts +0 -1
- package/dist/ui/presenters/config.presenter.js.map +0 -1
- package/dist/ui/presenters/errors.presenter.d.ts +0 -1
- package/dist/ui/presenters/errors.presenter.js.map +0 -1
- package/dist/ui/presenters/errors.zod-presenter.d.ts +0 -4
- package/dist/ui/presenters/errors.zod-presenter.js.map +0 -1
- package/dist/ui/presenters/index.d.ts +0 -6
- package/dist/ui/presenters/index.js.map +0 -1
- package/dist/ui/presenters/pdf.presenter.d.ts +0 -13
- package/dist/ui/presenters/pdf.presenter.js.map +0 -1
- package/dist/ui/presenters/showcase.presenter.d.ts +0 -1
- package/dist/ui/presenters/showcase.presenter.js.map +0 -1
- package/dist/ui/primitives/index.d.ts +0 -10
- package/dist/ui/primitives/index.js.map +0 -1
- package/dist/ui/primitives/renderDivider.d.ts +0 -5
- package/dist/ui/primitives/renderDivider.js.map +0 -1
- package/dist/ui/primitives/renderFooter.d.ts +0 -7
- package/dist/ui/primitives/renderFooter.js.map +0 -1
- package/dist/ui/primitives/renderJson.d.ts +0 -3
- package/dist/ui/primitives/renderJson.js.map +0 -1
- package/dist/ui/primitives/renderKeyValue.d.ts +0 -14
- package/dist/ui/primitives/renderKeyValue.js.map +0 -1
- package/dist/ui/primitives/renderLogo.d.ts +0 -3
- package/dist/ui/primitives/renderLogo.js.map +0 -1
- package/dist/ui/primitives/renderObject.d.ts +0 -1
- package/dist/ui/primitives/renderObject.js.map +0 -1
- package/dist/ui/primitives/renderPanel.d.ts +0 -27
- package/dist/ui/primitives/renderPanel.js.map +0 -1
- package/dist/ui/primitives/renderSubtitle.d.ts +0 -7
- package/dist/ui/primitives/renderSubtitle.js.map +0 -1
- package/dist/ui/primitives/renderTable.d.ts +0 -6
- package/dist/ui/primitives/renderTable.js.map +0 -1
- package/dist/ui/primitives/terminalWidth.d.ts +0 -4
- package/dist/ui/primitives/terminalWidth.js.map +0 -1
- package/dist/ui/primitives/text.d.ts +0 -28
- package/dist/ui/primitives/text.js.map +0 -1
- package/dist/ui/stream/index.d.ts +0 -1
- package/dist/ui/stream/index.js.map +0 -1
- package/dist/ui/stream/terminal-stream.d.ts +0 -16
- package/dist/ui/stream/terminal-stream.js.map +0 -1
- package/dist/ui/theme/index.d.ts +0 -1
- package/dist/ui/theme/index.js.map +0 -1
- package/dist/ui/theme/theme.d.ts +0 -68
- package/dist/ui/theme/theme.js.map +0 -1
|
@@ -22,16 +22,16 @@ export const arcliDefaultCurrencySchema = z
|
|
|
22
22
|
.length(3)
|
|
23
23
|
.transform((value) => value.toUpperCase());
|
|
24
24
|
export const arcliPdfModeSchema = z.enum(['siempre', 'preguntar', 'nunca']);
|
|
25
|
+
/** Rutas de certificado o clave por entorno; no se leen al parsear la config. */
|
|
26
|
+
const certificatePathsSchema = z.object({
|
|
27
|
+
produccion: z.string().trim().min(1).optional(),
|
|
28
|
+
testing: z.string().trim().min(1).optional(),
|
|
29
|
+
});
|
|
25
30
|
// Misma normalizacion que --alicuota ("10,5", "10.5%").
|
|
26
31
|
export const arcliDefaultIvaRateSchema = billingIvaRateSchema;
|
|
27
32
|
export const arcliConfigSchema = z.object({
|
|
28
33
|
alicuotaPorDefecto: arcliDefaultIvaRateSchema.optional(),
|
|
29
|
-
cert:
|
|
30
|
-
.object({
|
|
31
|
-
produccion: z.string().trim().min(1).optional(),
|
|
32
|
-
testing: z.string().trim().min(1).optional(),
|
|
33
|
-
})
|
|
34
|
-
.default({}),
|
|
34
|
+
cert: certificatePathsSchema.default({}),
|
|
35
35
|
cuit: z
|
|
36
36
|
.string()
|
|
37
37
|
.trim()
|
|
@@ -45,7 +45,7 @@ export const arcliConfigSchema = z.object({
|
|
|
45
45
|
aliasCbu: z
|
|
46
46
|
.string()
|
|
47
47
|
.trim()
|
|
48
|
-
.regex(/^[A-Za-z0-9.-]{6,20}$/, 'El alias debe tener entre 6 y 20 caracteres (letras,
|
|
48
|
+
.regex(/^[A-Za-z0-9.-]{6,20}$/, 'El alias debe tener entre 6 y 20 caracteres (letras, números, punto o guion)')
|
|
49
49
|
.optional(),
|
|
50
50
|
conceptoPorDefecto: arcliDefaultConceptSchema.optional(),
|
|
51
51
|
ivaReceptorPorDefecto: arcliDefaultIvaConditionSchema.optional(),
|
|
@@ -67,12 +67,16 @@ export const arcliConfigSchema = z.object({
|
|
|
67
67
|
})
|
|
68
68
|
.default({}),
|
|
69
69
|
entornoPorDefecto: arcliEnvironmentSchema.default('testing'),
|
|
70
|
-
|
|
70
|
+
/** WSFEX (factura de exportacion) usa su propio certificado, autorizado al servicio wsfex. */
|
|
71
|
+
exportacion: z
|
|
71
72
|
.object({
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
/** Codigo de la tabla de actividades de WSFEX que va en `Actividades` de la factura E. */
|
|
74
|
+
actividad: z.number().int().positive().optional(),
|
|
75
|
+
cert: certificatePathsSchema.default({}),
|
|
76
|
+
key: certificatePathsSchema.default({}),
|
|
74
77
|
})
|
|
75
|
-
.
|
|
78
|
+
.optional(),
|
|
79
|
+
key: certificatePathsSchema.default({}),
|
|
76
80
|
output: z
|
|
77
81
|
.object({
|
|
78
82
|
emitirPorDefecto: z.boolean().default(false),
|
|
@@ -87,8 +91,14 @@ export const arcliConfigSchema = z.object({
|
|
|
87
91
|
comprobantesPorLista: z.number().int().min(1).max(MAX_RECENT_VOUCHERS).optional(),
|
|
88
92
|
puntoVentaPorDefecto: z.number().int().positive().optional(),
|
|
89
93
|
ticketPath: z.string().trim().min(1).optional(),
|
|
94
|
+
/** Completar el IVA receptor desde el padron al facturar con --cuit. Sin definir, si. */
|
|
95
|
+
consultarPadron: z.boolean().optional(),
|
|
90
96
|
verificarFce: z.boolean().optional(),
|
|
91
97
|
});
|
|
98
|
+
/** El entorno como se lee en un texto; el valor (`produccion`) sigue igual en flags, claves y JSON. */
|
|
99
|
+
export function formatEnvironmentLabel(environment) {
|
|
100
|
+
return environment === 'produccion' ? 'producción' : environment;
|
|
101
|
+
}
|
|
92
102
|
export const CONFIG_DEFAULTS = {
|
|
93
103
|
cert: {},
|
|
94
104
|
emisor: {},
|
|
@@ -120,6 +130,11 @@ export const configPublicKeySchema = z.enum([
|
|
|
120
130
|
'emisor.razonSocial',
|
|
121
131
|
'entorno',
|
|
122
132
|
'emitir',
|
|
133
|
+
'exportacion.actividad',
|
|
134
|
+
'exportacion.cert.produccion',
|
|
135
|
+
'exportacion.cert.testing',
|
|
136
|
+
'exportacion.key.produccion',
|
|
137
|
+
'exportacion.key.testing',
|
|
123
138
|
'ivaReceptor',
|
|
124
139
|
'json',
|
|
125
140
|
'key.produccion',
|
|
@@ -132,5 +147,5 @@ export const configPublicKeySchema = z.enum([
|
|
|
132
147
|
'puntoVenta',
|
|
133
148
|
'ticketPath',
|
|
134
149
|
'verificarFce',
|
|
150
|
+
'consultarPadron',
|
|
135
151
|
]);
|
|
136
|
-
//# sourceMappingURL=config.schemas.js.map
|
|
@@ -6,11 +6,26 @@ export const CONFIG_SECTIONS = [
|
|
|
6
6
|
{ id: 'cuenta', keys: ['cuit', 'puntoVenta', 'entorno'], label: 'Cuenta' },
|
|
7
7
|
{
|
|
8
8
|
id: 'certificados',
|
|
9
|
-
keys: [
|
|
9
|
+
keys: [
|
|
10
|
+
'cert.testing',
|
|
11
|
+
'key.testing',
|
|
12
|
+
'cert.produccion',
|
|
13
|
+
'key.produccion',
|
|
14
|
+
'exportacion.cert.testing',
|
|
15
|
+
'exportacion.key.testing',
|
|
16
|
+
'exportacion.cert.produccion',
|
|
17
|
+
'exportacion.key.produccion',
|
|
18
|
+
'ticketPath',
|
|
19
|
+
],
|
|
10
20
|
label: 'Certificados',
|
|
11
21
|
},
|
|
12
|
-
{
|
|
13
|
-
|
|
22
|
+
{
|
|
23
|
+
id: 'facturacion',
|
|
24
|
+
keys: ['concepto', 'ivaReceptor', 'consultarPadron', 'alicuota', 'moneda', 'cotizacion'],
|
|
25
|
+
label: 'Al facturar',
|
|
26
|
+
},
|
|
27
|
+
{ id: 'fce', keys: ['cbu', 'aliasCbu', 'verificarFce'], label: 'Factura de crédito electrónica (FCE)' },
|
|
28
|
+
{ id: 'exportacion', keys: ['exportacion.actividad'], label: 'Factura de exportación (E)' },
|
|
14
29
|
{
|
|
15
30
|
id: 'emisor',
|
|
16
31
|
keys: [
|
|
@@ -28,27 +43,32 @@ export const CONFIG_SECTIONS = [
|
|
|
28
43
|
];
|
|
29
44
|
/** Nombre de cada dato, igual en `arcli config` y en el modo interactivo. */
|
|
30
45
|
export const CONFIG_LABELS = {
|
|
31
|
-
alicuota: '
|
|
46
|
+
alicuota: 'Alícuota de IVA (A y B)',
|
|
32
47
|
aliasCbu: 'Alias del CBU',
|
|
33
48
|
bruto: 'Salida bruta',
|
|
34
49
|
cbu: 'CBU',
|
|
35
|
-
'cert.produccion': 'Certificado de
|
|
50
|
+
'cert.produccion': 'Certificado de producción',
|
|
36
51
|
'cert.testing': 'Certificado de testing',
|
|
37
52
|
comprobantesPorLista: 'Comprobantes por lista',
|
|
38
53
|
concepto: 'Concepto',
|
|
39
|
-
cotizacion: '
|
|
54
|
+
cotizacion: 'Cotización',
|
|
40
55
|
cuit: 'CUIT del emisor',
|
|
41
|
-
'emisor.condicionIva': '
|
|
56
|
+
'emisor.condicionIva': 'Condición de IVA',
|
|
42
57
|
'emisor.domicilio': 'Domicilio comercial',
|
|
43
58
|
'emisor.iibb': 'Ingresos Brutos',
|
|
44
59
|
'emisor.inicioActividades': 'Inicio de actividades',
|
|
45
60
|
'emisor.logo': 'Logo (PNG o JPG)',
|
|
46
|
-
'emisor.razonSocial': '
|
|
61
|
+
'emisor.razonSocial': 'Razón social',
|
|
47
62
|
emitir: 'Emitir sin --emitir',
|
|
48
63
|
entorno: 'Entorno',
|
|
64
|
+
'exportacion.actividad': 'Actividad de exportación (WSFEX)',
|
|
65
|
+
'exportacion.cert.produccion': 'Certificado de exportación (producción)',
|
|
66
|
+
'exportacion.cert.testing': 'Certificado de exportación (testing)',
|
|
67
|
+
'exportacion.key.produccion': 'Clave de exportación (producción)',
|
|
68
|
+
'exportacion.key.testing': 'Clave de exportación (testing)',
|
|
49
69
|
ivaReceptor: 'IVA del receptor',
|
|
50
70
|
json: 'Salida JSON',
|
|
51
|
-
'key.produccion': 'Clave privada de
|
|
71
|
+
'key.produccion': 'Clave privada de producción',
|
|
52
72
|
'key.testing': 'Clave privada de testing',
|
|
53
73
|
moneda: 'Moneda',
|
|
54
74
|
pdf: 'Cuando generar el PDF',
|
|
@@ -56,6 +76,6 @@ export const CONFIG_LABELS = {
|
|
|
56
76
|
pdfNavegador: 'Navegador para PDFs',
|
|
57
77
|
puntoVenta: 'Punto de venta',
|
|
58
78
|
ticketPath: 'Carpeta de tickets WSAA',
|
|
59
|
-
verificarFce: 'Verificar
|
|
79
|
+
verificarFce: 'Verificar régimen FCE del receptor',
|
|
80
|
+
consultarPadron: 'IVA del receptor desde el padrón',
|
|
60
81
|
};
|
|
61
|
-
//# sourceMappingURL=config.sections.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Conf from 'conf';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
|
+
import { ConfigurationError } from '../../lib/errors/app-error.js';
|
|
4
5
|
import { arcliConfigSchema, CONFIG_DEFAULTS, configPublicKeySchema, } from './config.schemas.js';
|
|
5
6
|
import { parseConfigValue } from './config-value-parser.js';
|
|
6
7
|
const CONFIG_KEY_ALIASES = {
|
|
@@ -21,6 +22,11 @@ const CONFIG_KEY_ALIASES = {
|
|
|
21
22
|
'emisor.razonSocial': 'emisor.razonSocial',
|
|
22
23
|
entorno: 'entornoPorDefecto',
|
|
23
24
|
emitir: 'output.emitirPorDefecto',
|
|
25
|
+
'exportacion.actividad': 'exportacion.actividad',
|
|
26
|
+
'exportacion.cert.produccion': 'exportacion.cert.produccion',
|
|
27
|
+
'exportacion.cert.testing': 'exportacion.cert.testing',
|
|
28
|
+
'exportacion.key.produccion': 'exportacion.key.produccion',
|
|
29
|
+
'exportacion.key.testing': 'exportacion.key.testing',
|
|
24
30
|
ivaReceptor: 'ivaReceptorPorDefecto',
|
|
25
31
|
json: 'output.jsonPorDefecto',
|
|
26
32
|
'key.produccion': 'key.produccion',
|
|
@@ -33,22 +39,46 @@ const CONFIG_KEY_ALIASES = {
|
|
|
33
39
|
puntoVenta: 'puntoVentaPorDefecto',
|
|
34
40
|
ticketPath: 'ticketPath',
|
|
35
41
|
verificarFce: 'verificarFce',
|
|
42
|
+
consultarPadron: 'consultarPadron',
|
|
36
43
|
};
|
|
37
44
|
/** Valida un valor como lo haria `arcli config establecer`, sin guardarlo. Lanza un Error con el motivo. */
|
|
38
45
|
export function validateConfigValue(publicKey, rawValue) {
|
|
39
46
|
parseConfigValue(CONFIG_KEY_ALIASES[publicKey], rawValue);
|
|
40
47
|
}
|
|
48
|
+
function storeLocation(options) {
|
|
49
|
+
return {
|
|
50
|
+
configName: options.configName ?? 'config',
|
|
51
|
+
cwd: options.cwd,
|
|
52
|
+
projectName: options.projectName ?? 'arcli',
|
|
53
|
+
projectSuffix: '',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Ruta del config.json sin leerlo: `Conf` la calcula al construirse, pero tambien lee el archivo. Sin defaults y
|
|
58
|
+
* con un deserializador que no parsea, no hay nada que escribir y el archivo queda como esta.
|
|
59
|
+
*/
|
|
60
|
+
function resolveStorePath(options) {
|
|
61
|
+
return new Conf({ ...storeLocation(options), deserialize: () => ({}) }).path;
|
|
62
|
+
}
|
|
63
|
+
function invalidConfigFileError(path) {
|
|
64
|
+
return new ConfigurationError('El archivo de configuración tiene JSON inválido y no se puede leer.', { path }, 'Corregilo a mano, o renombralo (por ejemplo, a config.json.bak) y volve a cargar los datos con `arcli config establecer` o desde "Configuracion" en `arcli`. ARCLI no lo borra ni lo pisa.');
|
|
65
|
+
}
|
|
41
66
|
export class ConfigService {
|
|
42
67
|
store;
|
|
43
68
|
constructor(options = {}) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
69
|
+
try {
|
|
70
|
+
this.store = new Conf({
|
|
71
|
+
...storeLocation(options),
|
|
72
|
+
clearInvalidConfig: false,
|
|
73
|
+
defaults: CONFIG_DEFAULTS,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
if (error instanceof SyntaxError) {
|
|
78
|
+
throw invalidConfigFileError(resolveStorePath(options));
|
|
79
|
+
}
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
52
82
|
}
|
|
53
83
|
close() {
|
|
54
84
|
this.store._closeWatcher();
|
|
@@ -128,4 +158,3 @@ function deleteAtPath(target, path) {
|
|
|
128
158
|
delete parent[last];
|
|
129
159
|
}
|
|
130
160
|
}
|
|
131
|
-
//# sourceMappingURL=config.service.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { toArgentineCalendarDate } from '../../lib/dates/arca-date.js';
|
|
2
2
|
import { badge, renderLogo, sectionHeading, toneText } from '../../ui/index.js';
|
|
3
3
|
import { VOUCHER_FAMILIES, VOUCHER_KIND_MAP, VOUCHER_SHORTCUTS } from '../billing/voucher-kind-map.js';
|
|
4
|
-
|
|
4
|
+
import { EXPORT_VOUCHER_KIND } from '../export/export.types.js';
|
|
5
|
+
const ISSUER_HINT = 'Estos ejemplos asumen que ya resolviste cuit emisor, credenciales y, en la versión mínima, también punto de venta por config.';
|
|
5
6
|
function resolveAmount(definition) {
|
|
6
7
|
if (definition.letter === 'a') {
|
|
7
8
|
return 1;
|
|
@@ -23,22 +24,23 @@ function resolveIdentityShort(definition) {
|
|
|
23
24
|
}
|
|
24
25
|
return ['--cfinal', '--ir-cf'];
|
|
25
26
|
}
|
|
27
|
+
/** Una nota asocia una factura de su misma letra y categoria: `nca` -> `fa`, `ndeb` -> `fceb`. */
|
|
26
28
|
function resolveAssociatedShortcut(definition) {
|
|
29
|
+
return `${definition.isElectronicCredit ? 'fce' : 'f'}${definition.letter}`;
|
|
30
|
+
}
|
|
31
|
+
const EXAMPLE_CBU = '0110599520000012345678';
|
|
32
|
+
/** En NC/ND FCE el asociado tiene que ser del CUIT emisor: `--acuit` se omite y se toma de la config. */
|
|
33
|
+
function resolveAssociatedFlags(definition, form) {
|
|
27
34
|
if (!definition.requiresAssociatedVoucher) {
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
if (definition.family === 'nota-credito') {
|
|
31
|
-
return `f${definition.letter}`;
|
|
32
|
-
}
|
|
33
|
-
if (definition.family === 'nota-debito') {
|
|
34
|
-
return `f${definition.letter}`;
|
|
35
|
-
}
|
|
36
|
-
if (definition.family === 'nota-credito-electronica') {
|
|
37
|
-
return `fce${definition.letter}`;
|
|
35
|
+
return [];
|
|
38
36
|
}
|
|
39
|
-
return
|
|
37
|
+
return [
|
|
38
|
+
`--ac ${resolveAssociatedShortcut(definition)}`,
|
|
39
|
+
form === 'long' ? '--asociado-punto-venta 3' : '--apv 3',
|
|
40
|
+
'--ar 120',
|
|
41
|
+
...(definition.isElectronicCredit ? [] : ['--acuit 20333333334']),
|
|
42
|
+
];
|
|
40
43
|
}
|
|
41
|
-
const EXAMPLE_CBU = '0110599520000012345678';
|
|
42
44
|
function formatExampleDate(value) {
|
|
43
45
|
const day = String(value.getDate()).padStart(2, '0');
|
|
44
46
|
const month = String(value.getMonth() + 1).padStart(2, '0');
|
|
@@ -78,19 +80,15 @@ function buildMinimalLong(definition, dates) {
|
|
|
78
80
|
'--concepto servicios',
|
|
79
81
|
];
|
|
80
82
|
command.push(...resolveIdentityLong(definition));
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
command.push(...resolveElectronicCreditFlags(definition, dates, 'minimal'), '--previsualizar');
|
|
83
|
+
command.push(...resolveAssociatedFlags(definition, 'long'));
|
|
84
|
+
command.push(...resolveElectronicCreditFlags(definition, dates, 'minimal'));
|
|
85
85
|
return command.join(' ');
|
|
86
86
|
}
|
|
87
87
|
function buildMinimalShort(definition, dates) {
|
|
88
88
|
const command = [`arcli ${definition.shortcut}`, `-m ${resolveAmount(definition)}`, '--cs'];
|
|
89
89
|
command.push(...resolveIdentityShort(definition));
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
command.push(...resolveElectronicCreditFlags(definition, dates, 'minimal'), '--previsualizar');
|
|
90
|
+
command.push(...resolveAssociatedFlags(definition, 'short'));
|
|
91
|
+
command.push(...resolveElectronicCreditFlags(definition, dates, 'minimal'));
|
|
94
92
|
return command.join(' ');
|
|
95
93
|
}
|
|
96
94
|
function buildFullLong(definition, dates) {
|
|
@@ -109,9 +107,7 @@ function buildFullLong(definition, dates) {
|
|
|
109
107
|
command.push(`--vencimiento ${dates.paymentDue}`);
|
|
110
108
|
}
|
|
111
109
|
command.push(...resolveIdentityLong(definition));
|
|
112
|
-
|
|
113
|
-
command.push(`--ac ${resolveAssociatedShortcut(definition)}`, '--asociado-punto-venta 3', '--ar 120', '--acuit 20409509763');
|
|
114
|
-
}
|
|
110
|
+
command.push(...resolveAssociatedFlags(definition, 'long'));
|
|
115
111
|
command.push(...resolveElectronicCreditFlags(definition, dates, 'full'), '--previsualizar');
|
|
116
112
|
return command.join(' ');
|
|
117
113
|
}
|
|
@@ -131,9 +127,7 @@ function buildFullShort(definition, dates) {
|
|
|
131
127
|
command.push(`--vto ${dates.paymentDue}`);
|
|
132
128
|
}
|
|
133
129
|
command.push(...resolveIdentityShort(definition));
|
|
134
|
-
|
|
135
|
-
command.push(`--ac ${resolveAssociatedShortcut(definition)}`, '--apv 3', '--ar 120', '--acuit 20409509763');
|
|
136
|
-
}
|
|
130
|
+
command.push(...resolveAssociatedFlags(definition, 'short'));
|
|
137
131
|
command.push(...resolveElectronicCreditFlags(definition, dates, 'full'), '--previsualizar');
|
|
138
132
|
return command.join(' ');
|
|
139
133
|
}
|
|
@@ -141,11 +135,11 @@ function formatVoucherExample(definition, dates) {
|
|
|
141
135
|
return [
|
|
142
136
|
sectionHeading(definition.displayName),
|
|
143
137
|
'',
|
|
144
|
-
`${badge('
|
|
145
|
-
`${buildMinimalLong(definition, dates)}`,
|
|
138
|
+
`${badge('MÍNIMA LARGA', 'info')}`,
|
|
139
|
+
`${buildMinimalLong(definition, dates)} --previsualizar`,
|
|
146
140
|
'',
|
|
147
|
-
`${badge('
|
|
148
|
-
`${buildMinimalShort(definition, dates)}`,
|
|
141
|
+
`${badge('MÍNIMA CORTA', 'success')}`,
|
|
142
|
+
`${buildMinimalShort(definition, dates)} --previsualizar`,
|
|
149
143
|
'',
|
|
150
144
|
`${badge('FULL LARGA', 'warning')}`,
|
|
151
145
|
`${buildFullLong(definition, dates)}`,
|
|
@@ -160,26 +154,67 @@ function renderFamilyExamples(family, dates) {
|
|
|
160
154
|
.map((definition) => formatVoucherExample(definition, dates))
|
|
161
155
|
.join('\n\n\n');
|
|
162
156
|
}
|
|
157
|
+
const EXPORT_CLIENT = '--cliente "ACME LLC" --domicilio-cliente "123 Main St" --pais-destino 212 --numero 1';
|
|
158
|
+
/** El comando minimo de la factura E por shortcut, sin modo de ejecucion. Lo usa tambien la ayuda de `fe`. */
|
|
159
|
+
export const EXPORT_MINIMAL_EXAMPLE = `arcli ${EXPORT_VOUCHER_KIND.shortcut} -m 1500 ${EXPORT_CLIENT} --actividad 620100`;
|
|
160
|
+
/** La E no comparte flags de receptor ni de IVA con A, B y C: sus ejemplos se arman aparte. */
|
|
161
|
+
function formatExportExample() {
|
|
162
|
+
const { family, letter, shortcut } = EXPORT_VOUCHER_KIND;
|
|
163
|
+
const fullFlags = [
|
|
164
|
+
'--id-impositivo "12-3456789"',
|
|
165
|
+
'--tipo-expo 2',
|
|
166
|
+
'--item "001|Servicios de consultoría|10|150|unidades"',
|
|
167
|
+
'--fecha-pago 15/11',
|
|
168
|
+
'--forma-pago "Transferencia Internacional"',
|
|
169
|
+
'--obs-comerciales "Orden de compra 778"',
|
|
170
|
+
];
|
|
171
|
+
return [
|
|
172
|
+
sectionHeading(EXPORT_VOUCHER_KIND.displayName),
|
|
173
|
+
'',
|
|
174
|
+
`${badge('MÍNIMA LARGA', 'info')}`,
|
|
175
|
+
`arcli ${family} ${letter} --monto 1500 ${EXPORT_CLIENT} --actividad 620100 --previsualizar`,
|
|
176
|
+
'',
|
|
177
|
+
`${badge('MÍNIMA CORTA', 'success')}`,
|
|
178
|
+
`${EXPORT_MINIMAL_EXAMPLE} --previsualizar`,
|
|
179
|
+
'',
|
|
180
|
+
`${badge('FULL LARGA', 'warning')}`,
|
|
181
|
+
`arcli ${family} ${letter} --monto 1500 ${EXPORT_CLIENT} --actividad 620100 ${fullFlags.join(' ')} --moneda USD --misma-moneda --previsualizar`,
|
|
182
|
+
'',
|
|
183
|
+
`${badge('FULL CORTA', 'debug')}`,
|
|
184
|
+
`arcli ${shortcut} -m 1500 ${EXPORT_CLIENT} --actividad 620100 ${fullFlags.join(' ')} --mda USD --misma-moneda --previsualizar`,
|
|
185
|
+
].join('\n');
|
|
186
|
+
}
|
|
187
|
+
/** El comando minimo por shortcut (`arcli nca -m 1 --cs ...`), sin modo de ejecucion. Lo usa tambien la ayuda. */
|
|
188
|
+
export function buildMinimalShortcutExample(definition, today = new Date()) {
|
|
189
|
+
return buildMinimalShort(definition, resolveExampleDates(today));
|
|
190
|
+
}
|
|
191
|
+
/** El comando minimo por familia y letra (`arcli nota-credito a --monto 1 ...`), sin modo de ejecucion. */
|
|
192
|
+
export function buildMinimalFamilyExample(definition, today = new Date()) {
|
|
193
|
+
return buildMinimalLong(definition, resolveExampleDates(today));
|
|
194
|
+
}
|
|
163
195
|
export function renderExamples(today = new Date()) {
|
|
164
196
|
const dates = resolveExampleDates(today);
|
|
165
197
|
return [
|
|
166
198
|
renderLogo().trim(),
|
|
167
199
|
'',
|
|
168
|
-
`${badge('
|
|
169
|
-
`${badge('FULL', 'warning')}
|
|
200
|
+
`${badge('MÍNIMA', 'info')} datos esenciales`,
|
|
201
|
+
`${badge('FULL', 'warning')} más campos explicitados`,
|
|
170
202
|
`${badge('LARGA', 'success')} comando largo`,
|
|
171
203
|
`${badge('CORTA', 'debug')} shortcut y aliases`,
|
|
172
204
|
'',
|
|
173
205
|
toneText('SEGURIDAD', 'warning'),
|
|
174
206
|
'Todos usan --previsualizar para evitar emisiones reales por error.',
|
|
175
|
-
'Si
|
|
176
|
-
'Para emitir en
|
|
207
|
+
'Si querés emitir de verdad, reemplaza --previsualizar por --emitir.',
|
|
208
|
+
'Para emitir en producción necesitas --produccion junto con --emitir.',
|
|
177
209
|
'Para guardar el PDF con el QR, agrega --exportar-pdf al emitir (ver docs/pdf.md).',
|
|
178
210
|
'',
|
|
179
211
|
ISSUER_HINT,
|
|
180
212
|
'',
|
|
181
|
-
...VOUCHER_FAMILIES.flatMap((family) => [
|
|
213
|
+
...VOUCHER_FAMILIES.flatMap((family) => [
|
|
214
|
+
renderFamilyExamples(family, dates),
|
|
215
|
+
...(family === EXPORT_VOUCHER_KIND.family ? ['', '', formatExportExample()] : []),
|
|
216
|
+
'',
|
|
217
|
+
]),
|
|
182
218
|
'',
|
|
183
219
|
].join('\n');
|
|
184
220
|
}
|
|
185
|
-
//# sourceMappingURL=examples.js.map
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import Big from 'big.js';
|
|
2
|
+
import { InputValidationError } from '../../lib/errors/app-error.js';
|
|
3
|
+
import { parseArgentineAmount } from '../../lib/numbers/argentine-amount.js';
|
|
4
|
+
import { DEFAULT_EXPORT_UNIT_CODE, } from './export.types.js';
|
|
5
|
+
export const DEFAULT_EXPORT_ITEM_DESCRIPTION = 'Según detalle';
|
|
6
|
+
const ITEM_FORMAT_HINT = 'Usá --item "codigo|descripcion|cantidad|precio|unidad" (el código y la unidad son opcionales).';
|
|
7
|
+
function parseItemAmount(part, field, raw) {
|
|
8
|
+
const parsed = parseArgentineAmount(part, { maxDecimals: 6 });
|
|
9
|
+
if (!parsed.ok) {
|
|
10
|
+
throw new InputValidationError(`El ${field} del item "${raw}" no es válido: ${parsed.reason}.`);
|
|
11
|
+
}
|
|
12
|
+
return parsed.value;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Un item por flag. Se separa con `|` para no pelear con las comas de los importes:
|
|
16
|
+
* `001|Servicio de consultoria|1|1000|unidad`. Con cuatro partes se omite el codigo y con tres la unidad.
|
|
17
|
+
*/
|
|
18
|
+
export function parseExportItemArgument(raw) {
|
|
19
|
+
const parts = raw.split('|').map((part) => part.trim());
|
|
20
|
+
if (parts.length < 3 || parts.length > 5) {
|
|
21
|
+
throw new InputValidationError(`El item "${raw}" no es válido. ${ITEM_FORMAT_HINT}`);
|
|
22
|
+
}
|
|
23
|
+
const [codeOrDescription, ...rest] = parts;
|
|
24
|
+
const description = parts.length === 5 ? rest.shift() : codeOrDescription;
|
|
25
|
+
const [quantityPart, pricePart, unitPart] = rest;
|
|
26
|
+
if (!description || !quantityPart || !pricePart) {
|
|
27
|
+
throw new InputValidationError(`El item "${raw}" no es válido: falta la descripción, la cantidad o el precio.`);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
code: parts.length === 5 ? codeOrDescription : undefined,
|
|
31
|
+
description,
|
|
32
|
+
quantity: parseItemAmount(quantityPart, 'la cantidad', raw),
|
|
33
|
+
unit: unitPart ? resolveExportItemUnit(unitPart) : DEFAULT_EXPORT_UNIT_CODE,
|
|
34
|
+
unitPrice: parseItemAmount(pricePart, 'el precio', raw),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** La unidad del item puede ser el codigo de ARCA (`7`) o el nombre de la tabla (`unidad`). */
|
|
38
|
+
export function resolveExportItemUnit(unit) {
|
|
39
|
+
if (typeof unit === 'number') {
|
|
40
|
+
return unit;
|
|
41
|
+
}
|
|
42
|
+
const trimmed = unit.trim();
|
|
43
|
+
if (!trimmed) {
|
|
44
|
+
throw new InputValidationError('La unidad del item no puede estar vacía. Usá --item sin la última parte para usar "unidad".');
|
|
45
|
+
}
|
|
46
|
+
return /^\d+$/.test(trimmed) ? Number(trimmed) : trimmed;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* La tabla de ARCA escribe las unidades en plural ("unidades", "kilogramos") y los ejemplos del CLI en singular
|
|
50
|
+
* ("unidad"): se aceptan las dos formas, sin inventar codigos para nombres que no estan en la tabla.
|
|
51
|
+
*/
|
|
52
|
+
function singularUnitName(value) {
|
|
53
|
+
if (/[dlrnz]es$/.test(value)) {
|
|
54
|
+
return value.slice(0, -2);
|
|
55
|
+
}
|
|
56
|
+
return value.endsWith('s') ? value.slice(0, -1) : value;
|
|
57
|
+
}
|
|
58
|
+
function findUnitByName(units, normalized) {
|
|
59
|
+
const exact = units.find((entry) => entry.name.trim().toLowerCase() === normalized);
|
|
60
|
+
if (exact) {
|
|
61
|
+
return exact;
|
|
62
|
+
}
|
|
63
|
+
const singular = singularUnitName(normalized);
|
|
64
|
+
const matches = units.filter((entry) => singularUnitName(entry.name.trim().toLowerCase()) === singular);
|
|
65
|
+
return matches.length === 1 ? matches[0] : undefined;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Codigo de ARCA de la unidad: si viene un nombre se busca en la tabla de WSFEX. Un nombre desconocido
|
|
69
|
+
* es un error, no un default silencioso.
|
|
70
|
+
*/
|
|
71
|
+
export function resolveUnitCode(unit, units) {
|
|
72
|
+
if (typeof unit === 'number') {
|
|
73
|
+
const known = units.find((entry) => entry.id === unit);
|
|
74
|
+
if (units.length > 0 && !known) {
|
|
75
|
+
throw new InputValidationError(`La unidad ${unit} no existe en la tabla de ARCA.`);
|
|
76
|
+
}
|
|
77
|
+
return unit;
|
|
78
|
+
}
|
|
79
|
+
if (typeof unit === 'string') {
|
|
80
|
+
const match = findUnitByName(units, unit.trim().toLowerCase());
|
|
81
|
+
if (match) {
|
|
82
|
+
return match.id;
|
|
83
|
+
}
|
|
84
|
+
throw new InputValidationError(`La unidad "${unit}" no existe en la tabla de ARCA. Usá el nombre tal como lo informa ARCA o el código numérico.`);
|
|
85
|
+
}
|
|
86
|
+
return DEFAULT_EXPORT_UNIT_CODE;
|
|
87
|
+
}
|
|
88
|
+
function roundAmount(value) {
|
|
89
|
+
return value.round(2, Big.roundHalfUp).toNumber();
|
|
90
|
+
}
|
|
91
|
+
function assertSameTotal(total, amount) {
|
|
92
|
+
if (!total.eq(new Big(amount).round(2, Big.roundHalfUp))) {
|
|
93
|
+
throw new InputValidationError(`La suma de los items (${roundAmount(total).toFixed(2)}) no coincide con --monto (${amount.toFixed(2)}).`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Se valida antes de consultar ARCA: un total que no cierra no tiene por que autenticar en WSAA. */
|
|
97
|
+
export function assertExportItemsTotal(inputs, amount) {
|
|
98
|
+
if (!inputs || inputs.length === 0) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const total = inputs.reduce((sum, item) => sum.plus(new Big(item.quantity).times(item.unitPrice).round(2, Big.roundHalfUp)), new Big(0));
|
|
102
|
+
assertSameTotal(total, amount);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Un item sin `--item` resume el comprobante en un renglon con el total. Con items, la suma tiene que dar
|
|
106
|
+
* el monto: ARCA no valida `Imp_total` contra los items, asi que se valida aca.
|
|
107
|
+
*/
|
|
108
|
+
export function buildExportItems(inputs, amount, units, defaultDescription) {
|
|
109
|
+
if (!inputs || inputs.length === 0) {
|
|
110
|
+
return {
|
|
111
|
+
items: [
|
|
112
|
+
{
|
|
113
|
+
Pro_bonificacion: 0,
|
|
114
|
+
Pro_codigo: '',
|
|
115
|
+
Pro_ds: defaultDescription,
|
|
116
|
+
Pro_precio_uni: amount,
|
|
117
|
+
Pro_qty: 1,
|
|
118
|
+
Pro_total_item: roundAmount(new Big(amount)),
|
|
119
|
+
Pro_umed: DEFAULT_EXPORT_UNIT_CODE,
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
total: roundAmount(new Big(amount)),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const items = inputs.map((item) => {
|
|
126
|
+
if (!item.description.trim()) {
|
|
127
|
+
throw new InputValidationError('Cada item necesita una descripción.');
|
|
128
|
+
}
|
|
129
|
+
const quantity = new Big(item.quantity);
|
|
130
|
+
if (quantity.lte(0)) {
|
|
131
|
+
throw new InputValidationError(`La cantidad del item "${item.description}" tiene que ser mayor a 0.`);
|
|
132
|
+
}
|
|
133
|
+
if (!(item.unitPrice > 0)) {
|
|
134
|
+
throw new InputValidationError(`El precio del item "${item.description}" tiene que ser mayor a 0.`);
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
Pro_bonificacion: 0,
|
|
138
|
+
Pro_codigo: item.code?.trim() ?? '',
|
|
139
|
+
Pro_ds: item.description.trim(),
|
|
140
|
+
Pro_precio_uni: item.unitPrice,
|
|
141
|
+
Pro_qty: quantity.toNumber(),
|
|
142
|
+
Pro_total_item: roundAmount(quantity.times(item.unitPrice)),
|
|
143
|
+
Pro_umed: resolveUnitCode(item.unit, units),
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
const total = items.reduce((sum, item) => sum.plus(item.Pro_total_item), new Big(0));
|
|
147
|
+
assertSameTotal(total, amount);
|
|
148
|
+
return { items, total: roundAmount(total) };
|
|
149
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { InputValidationError } from '../../lib/errors/app-error.js';
|
|
3
|
+
const itemJsonSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
cantidad: z.number(),
|
|
6
|
+
codigo: z.string().optional(),
|
|
7
|
+
descripcion: z.string(),
|
|
8
|
+
precioUnitario: z.number(),
|
|
9
|
+
unidad: z.union([z.string(), z.number()]).optional(),
|
|
10
|
+
})
|
|
11
|
+
.strict();
|
|
12
|
+
/**
|
|
13
|
+
* Forma del JSON de `--cargar`: solo tipos y claves. Los valores (importes, pais, incoterm) los valida el
|
|
14
|
+
* servicio igual que si vinieran por flags. Es `.strict()` para que un typo no se ignore en silencio.
|
|
15
|
+
*/
|
|
16
|
+
export const exportJsonInputSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
actividad: z.number().optional(),
|
|
19
|
+
cliente: z.string().optional(),
|
|
20
|
+
codigoMoneda: z.string().optional(),
|
|
21
|
+
cotizacionMoneda: z.number().optional(),
|
|
22
|
+
cuitPais: z.number().optional(),
|
|
23
|
+
descripcion: z.string().optional(),
|
|
24
|
+
descripcionIncoterm: z.string().optional(),
|
|
25
|
+
domicilioCliente: z.string().optional(),
|
|
26
|
+
emitir: z.boolean().optional(),
|
|
27
|
+
fechaComprobante: z.string().optional(),
|
|
28
|
+
fechaPago: z.string().optional(),
|
|
29
|
+
formaPago: z.string().optional(),
|
|
30
|
+
idImpositivo: z.string().optional(),
|
|
31
|
+
idSolicitud: z.number().optional(),
|
|
32
|
+
idioma: z.number().optional(),
|
|
33
|
+
incoterm: z.string().optional(),
|
|
34
|
+
items: z.array(itemJsonSchema).optional(),
|
|
35
|
+
mismaMoneda: z.boolean().optional(),
|
|
36
|
+
monto: z.number().optional(),
|
|
37
|
+
numero: z.number().optional(),
|
|
38
|
+
observaciones: z.string().optional(),
|
|
39
|
+
observacionesComerciales: z.string().optional(),
|
|
40
|
+
paisDestino: z.union([z.string(), z.number()]).optional(),
|
|
41
|
+
pdf: z.boolean().optional(),
|
|
42
|
+
permisoExistente: z.boolean().optional(),
|
|
43
|
+
permisos: z.array(z.string()).optional(),
|
|
44
|
+
puntoVenta: z.number().optional(),
|
|
45
|
+
previsualizar: z.boolean().optional(),
|
|
46
|
+
tipoExpo: z.union([z.literal(1), z.literal(2), z.literal(4)]).optional(),
|
|
47
|
+
})
|
|
48
|
+
.strict();
|
|
49
|
+
const TYPE_LABELS = {
|
|
50
|
+
array: 'un array',
|
|
51
|
+
boolean: 'true o false',
|
|
52
|
+
number: 'un número',
|
|
53
|
+
object: 'un objeto',
|
|
54
|
+
string: 'un texto',
|
|
55
|
+
};
|
|
56
|
+
function describeIssue(issue) {
|
|
57
|
+
const path = issue.path.map(String).join('.');
|
|
58
|
+
if (issue.code === 'unrecognized_keys') {
|
|
59
|
+
return `La clave "${issue.keys.join('", "')}" no existe en el JSON de --cargar.`;
|
|
60
|
+
}
|
|
61
|
+
if (issue.code === 'invalid_type' && issue.input === undefined) {
|
|
62
|
+
return `Falta "${path}".`;
|
|
63
|
+
}
|
|
64
|
+
if (issue.code === 'invalid_type') {
|
|
65
|
+
return `"${path}" tiene que ser ${TYPE_LABELS[issue.expected] ?? issue.expected}.`;
|
|
66
|
+
}
|
|
67
|
+
return path ? `"${path}": ${issue.message}.` : `${issue.message}.`;
|
|
68
|
+
}
|
|
69
|
+
export function parseExportJsonInput(value) {
|
|
70
|
+
const result = exportJsonInputSchema.safeParse(value, { reportInput: true });
|
|
71
|
+
if (result.success) {
|
|
72
|
+
return result.data;
|
|
73
|
+
}
|
|
74
|
+
throw new InputValidationError(`En el JSON de --cargar: ${result.error.issues.map((issue) => describeIssue(issue)).join(' ')}`);
|
|
75
|
+
}
|
|
76
|
+
/** `--cargar` toma un solo comprobante; el lote de exportacion queda para mas adelante. */
|
|
77
|
+
export function readExportJsonInput(source) {
|
|
78
|
+
if (Array.isArray(source)) {
|
|
79
|
+
throw new InputValidationError('El JSON de --cargar de la factura E tiene que ser un objeto con un comprobante, no un array.');
|
|
80
|
+
}
|
|
81
|
+
return parseExportJsonInput(source);
|
|
82
|
+
}
|
|
83
|
+
export function mapExportJsonItems(items) {
|
|
84
|
+
return items?.map((item) => ({
|
|
85
|
+
code: item.codigo,
|
|
86
|
+
description: item.descripcion,
|
|
87
|
+
quantity: item.cantidad,
|
|
88
|
+
unit: item.unidad,
|
|
89
|
+
unitPrice: item.precioUnitario,
|
|
90
|
+
}));
|
|
91
|
+
}
|