arcli 0.1.2 → 1.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 +78 -0
- package/LICENSE +21 -0
- package/README.md +169 -4
- package/dist/cli/commands/billing-family.command.d.ts +2 -0
- package/dist/cli/commands/billing-family.command.js +30 -0
- package/dist/cli/commands/billing-family.command.js.map +1 -0
- package/dist/cli/commands/billing-shortcuts.command.d.ts +2 -0
- package/dist/cli/commands/billing-shortcuts.command.js +18 -0
- package/dist/cli/commands/billing-shortcuts.command.js.map +1 -0
- package/dist/cli/commands/billing.command.interactive-preview.d.ts +18 -0
- package/dist/cli/commands/billing.command.interactive-preview.js +69 -0
- package/dist/cli/commands/billing.command.interactive-preview.js.map +1 -0
- package/dist/cli/commands/billing.command.options.d.ts +2 -0
- package/dist/cli/commands/billing.command.options.js +65 -0
- package/dist/cli/commands/billing.command.options.js.map +1 -0
- package/dist/cli/commands/billing.command.output.d.ts +12 -0
- package/dist/cli/commands/billing.command.output.js +33 -0
- package/dist/cli/commands/billing.command.output.js.map +1 -0
- package/dist/cli/commands/billing.command.parser.d.ts +21 -0
- package/dist/cli/commands/billing.command.parser.js +170 -0
- package/dist/cli/commands/billing.command.parser.js.map +1 -0
- package/dist/cli/commands/billing.command.shared.d.ts +7 -0
- package/dist/cli/commands/billing.command.shared.js +99 -0
- package/dist/cli/commands/billing.command.shared.js.map +1 -0
- package/dist/cli/commands/billing.command.shortcuts.d.ts +7 -0
- package/dist/cli/commands/billing.command.shortcuts.js +52 -0
- package/dist/cli/commands/billing.command.shortcuts.js.map +1 -0
- package/dist/cli/commands/config.command.d.ts +2 -0
- package/dist/cli/commands/config.command.js +125 -0
- package/dist/cli/commands/config.command.js.map +1 -0
- package/dist/cli/commands/examples.command.d.ts +2 -0
- package/dist/cli/commands/examples.command.js +14 -0
- package/dist/cli/commands/examples.command.js.map +1 -0
- package/dist/cli/commands/fce-obligation.command.d.ts +2 -0
- package/dist/cli/commands/fce-obligation.command.js +51 -0
- package/dist/cli/commands/fce-obligation.command.js.map +1 -0
- package/dist/cli/commands/storybook.command.d.ts +2 -0
- package/dist/cli/commands/storybook.command.js +26 -0
- package/dist/cli/commands/storybook.command.js.map +1 -0
- package/dist/cli/help.d.ts +11 -0
- package/dist/cli/help.js +534 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +41 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/program.d.ts +2 -0
- package/dist/cli/program.js +30 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/cli/types.d.ts +6 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/version.d.ts +1 -0
- package/dist/cli/version.js +2 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/dates/arca-date.d.ts +6 -0
- package/dist/lib/dates/arca-date.js +45 -0
- package/dist/lib/dates/arca-date.js.map +1 -0
- package/dist/lib/errors/app-error.d.ts +14 -0
- package/dist/lib/errors/app-error.js +29 -0
- package/dist/lib/errors/app-error.js.map +1 -0
- package/dist/lib/files/read-json-file.d.ts +1 -0
- package/dist/lib/files/read-json-file.js +21 -0
- package/dist/lib/files/read-json-file.js.map +1 -0
- package/dist/lib/paths/mask-path.d.ts +1 -0
- package/dist/lib/paths/mask-path.js +17 -0
- package/dist/lib/paths/mask-path.js.map +1 -0
- package/dist/lib/security/certificate.d.ts +7 -0
- package/dist/lib/security/certificate.js +16 -0
- package/dist/lib/security/certificate.js.map +1 -0
- package/dist/lib/security/pem.d.ts +5 -0
- package/dist/lib/security/pem.js +36 -0
- package/dist/lib/security/pem.js.map +1 -0
- package/dist/modules/billing/billing-response.d.ts +4 -0
- package/dist/modules/billing/billing-response.js +74 -0
- package/dist/modules/billing/billing-response.js.map +1 -0
- package/dist/modules/billing/billing.amounts.d.ts +19 -0
- package/dist/modules/billing/billing.amounts.js +72 -0
- package/dist/modules/billing/billing.amounts.js.map +1 -0
- package/dist/modules/billing/billing.associated-period.d.ts +8 -0
- package/dist/modules/billing/billing.associated-period.js +40 -0
- package/dist/modules/billing/billing.associated-period.js.map +1 -0
- package/dist/modules/billing/billing.associated-vouchers.d.ts +12 -0
- package/dist/modules/billing/billing.associated-vouchers.js +73 -0
- package/dist/modules/billing/billing.associated-vouchers.js.map +1 -0
- package/dist/modules/billing/billing.constants.d.ts +2 -0
- package/dist/modules/billing/billing.constants.js +3 -0
- package/dist/modules/billing/billing.constants.js.map +1 -0
- package/dist/modules/billing/billing.currency.d.ts +18 -0
- package/dist/modules/billing/billing.currency.js +53 -0
- package/dist/modules/billing/billing.currency.js.map +1 -0
- package/dist/modules/billing/billing.date-range.d.ts +9 -0
- package/dist/modules/billing/billing.date-range.js +52 -0
- package/dist/modules/billing/billing.date-range.js.map +1 -0
- package/dist/modules/billing/billing.display.d.ts +13 -0
- package/dist/modules/billing/billing.display.js +137 -0
- package/dist/modules/billing/billing.display.js.map +1 -0
- package/dist/modules/billing/billing.fce.d.ts +21 -0
- package/dist/modules/billing/billing.fce.js +59 -0
- package/dist/modules/billing/billing.fce.js.map +1 -0
- package/dist/modules/billing/billing.iva-receptor.d.ts +7 -0
- package/dist/modules/billing/billing.iva-receptor.js +58 -0
- package/dist/modules/billing/billing.iva-receptor.js.map +1 -0
- package/dist/modules/billing/billing.json-format.d.ts +6 -0
- package/dist/modules/billing/billing.json-format.js +5 -0
- package/dist/modules/billing/billing.json-format.js.map +1 -0
- package/dist/modules/billing/billing.labels.d.ts +9 -0
- package/dist/modules/billing/billing.labels.js +108 -0
- package/dist/modules/billing/billing.labels.js.map +1 -0
- package/dist/modules/billing/billing.mappers.d.ts +8 -0
- package/dist/modules/billing/billing.mappers.js +60 -0
- package/dist/modules/billing/billing.mappers.js.map +1 -0
- package/dist/modules/billing/billing.presenter.d.ts +7 -0
- package/dist/modules/billing/billing.presenter.js +3 -0
- package/dist/modules/billing/billing.presenter.js.map +1 -0
- package/dist/modules/billing/billing.schemas.d.ts +107 -0
- package/dist/modules/billing/billing.schemas.js +106 -0
- package/dist/modules/billing/billing.schemas.js.map +1 -0
- package/dist/modules/billing/billing.serialize.d.ts +8 -0
- package/dist/modules/billing/billing.serialize.js +53 -0
- package/dist/modules/billing/billing.serialize.js.map +1 -0
- package/dist/modules/billing/billing.service.d.ts +27 -0
- package/dist/modules/billing/billing.service.js +146 -0
- package/dist/modules/billing/billing.service.js.map +1 -0
- package/dist/modules/billing/billing.text.d.ts +8 -0
- package/dist/modules/billing/billing.text.js +52 -0
- package/dist/modules/billing/billing.text.js.map +1 -0
- package/dist/modules/billing/billing.types.d.ts +13 -0
- package/dist/modules/billing/billing.types.internal.d.ts +27 -0
- package/dist/modules/billing/billing.types.internal.js +2 -0
- package/dist/modules/billing/billing.types.internal.js.map +1 -0
- package/dist/modules/billing/billing.types.js +2 -0
- package/dist/modules/billing/billing.types.js.map +1 -0
- package/dist/modules/billing/billing.validation.d.ts +7 -0
- package/dist/modules/billing/billing.validation.js +80 -0
- package/dist/modules/billing/billing.validation.js.map +1 -0
- package/dist/modules/billing/voucher-kind-map.d.ts +9 -0
- package/dist/modules/billing/voucher-kind-map.js +180 -0
- package/dist/modules/billing/voucher-kind-map.js.map +1 -0
- package/dist/modules/config/config-doctor.d.ts +15 -0
- package/dist/modules/config/config-doctor.js +125 -0
- package/dist/modules/config/config-doctor.js.map +1 -0
- package/dist/modules/config/config-value-parser.d.ts +2 -0
- package/dist/modules/config/config-value-parser.js +99 -0
- package/dist/modules/config/config-value-parser.js.map +1 -0
- package/dist/modules/config/config.presenter.d.ts +7 -0
- package/dist/modules/config/config.presenter.js +88 -0
- package/dist/modules/config/config.presenter.js.map +1 -0
- package/dist/modules/config/config.schemas.d.ts +110 -0
- package/dist/modules/config/config.schemas.js +103 -0
- package/dist/modules/config/config.schemas.js.map +1 -0
- package/dist/modules/config/config.service.d.ts +20 -0
- package/dist/modules/config/config.service.js +82 -0
- package/dist/modules/config/config.service.js.map +1 -0
- package/dist/modules/examples/examples.d.ts +1 -0
- package/dist/modules/examples/examples.js +191 -0
- package/dist/modules/examples/examples.js.map +1 -0
- package/dist/modules/fce/fce-obligation.d.ts +20 -0
- package/dist/modules/fce/fce-obligation.js +33 -0
- package/dist/modules/fce/fce-obligation.js.map +1 -0
- package/dist/modules/fce/fce-obligation.presenter.d.ts +9 -0
- package/dist/modules/fce/fce-obligation.presenter.js +32 -0
- package/dist/modules/fce/fce-obligation.presenter.js.map +1 -0
- package/dist/modules/storybook/showcase-theme.d.ts +7 -0
- package/dist/modules/storybook/showcase-theme.js +6 -0
- package/dist/modules/storybook/showcase-theme.js.map +1 -0
- package/dist/modules/storybook/showcase.d.ts +2 -0
- package/dist/modules/storybook/showcase.js +310 -0
- package/dist/modules/storybook/showcase.js.map +1 -0
- package/dist/modules/update-check/update-check.presenter.d.ts +2 -0
- package/dist/modules/update-check/update-check.presenter.js +6 -0
- package/dist/modules/update-check/update-check.presenter.js.map +1 -0
- package/dist/modules/update-check/update-check.service.d.ts +8 -0
- package/dist/modules/update-check/update-check.service.js +72 -0
- package/dist/modules/update-check/update-check.service.js.map +1 -0
- package/dist/services/arca/arca-billing.gateway.d.ts +10 -0
- package/dist/services/arca/arca-billing.gateway.js +22 -0
- package/dist/services/arca/arca-billing.gateway.js.map +1 -0
- package/dist/services/arca/arca-client.factory.d.ts +5 -0
- package/dist/services/arca/arca-client.factory.js +7 -0
- package/dist/services/arca/arca-client.factory.js.map +1 -0
- package/dist/services/arca/arca-context.resolver.d.ts +44 -0
- package/dist/services/arca/arca-context.resolver.js +120 -0
- package/dist/services/arca/arca-context.resolver.js.map +1 -0
- package/dist/services/arca/arca-fce-obligation.gateway.d.ts +7 -0
- package/dist/services/arca/arca-fce-obligation.gateway.js +36 -0
- package/dist/services/arca/arca-fce-obligation.gateway.js.map +1 -0
- package/dist/ui/components/contentPanel.d.ts +5 -0
- package/dist/ui/components/contentPanel.js +11 -0
- package/dist/ui/components/contentPanel.js.map +1 -0
- package/dist/ui/components/errorPanel.d.ts +1 -0
- package/dist/ui/components/errorPanel.js +13 -0
- package/dist/ui/components/errorPanel.js.map +1 -0
- package/dist/ui/components/index.d.ts +6 -0
- package/dist/ui/components/index.js +7 -0
- package/dist/ui/components/index.js.map +1 -0
- package/dist/ui/components/keyValuePanel.d.ts +3 -0
- package/dist/ui/components/keyValuePanel.js +14 -0
- package/dist/ui/components/keyValuePanel.js.map +1 -0
- package/dist/ui/components/noticePanel.d.ts +3 -0
- package/dist/ui/components/noticePanel.js +11 -0
- package/dist/ui/components/noticePanel.js.map +1 -0
- package/dist/ui/components/rawPanel.d.ts +1 -0
- package/dist/ui/components/rawPanel.js +5 -0
- package/dist/ui/components/rawPanel.js.map +1 -0
- package/dist/ui/components/statusPanel.d.ts +3 -0
- package/dist/ui/components/statusPanel.js +20 -0
- package/dist/ui/components/statusPanel.js.map +1 -0
- package/dist/ui/index.d.ts +5 -0
- package/dist/ui/index.js +6 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/presenters/billing.presenter.d.ts +2 -0
- package/dist/ui/presenters/billing.presenter.js +2 -0
- package/dist/ui/presenters/billing.presenter.js.map +1 -0
- package/dist/ui/presenters/config.presenter.d.ts +1 -0
- package/dist/ui/presenters/config.presenter.js +2 -0
- package/dist/ui/presenters/config.presenter.js.map +1 -0
- package/dist/ui/presenters/errors.presenter.d.ts +1 -0
- package/dist/ui/presenters/errors.presenter.js +89 -0
- package/dist/ui/presenters/errors.presenter.js.map +1 -0
- package/dist/ui/presenters/errors.zod-presenter.d.ts +2 -0
- package/dist/ui/presenters/errors.zod-presenter.js +103 -0
- package/dist/ui/presenters/errors.zod-presenter.js.map +1 -0
- package/dist/ui/presenters/index.d.ts +4 -0
- package/dist/ui/presenters/index.js +5 -0
- package/dist/ui/presenters/index.js.map +1 -0
- package/dist/ui/presenters/showcase.presenter.d.ts +1 -0
- package/dist/ui/presenters/showcase.presenter.js +2 -0
- package/dist/ui/presenters/showcase.presenter.js.map +1 -0
- package/dist/ui/primitives/index.d.ts +10 -0
- package/dist/ui/primitives/index.js +11 -0
- package/dist/ui/primitives/index.js.map +1 -0
- package/dist/ui/primitives/renderDivider.d.ts +5 -0
- package/dist/ui/primitives/renderDivider.js +5 -0
- package/dist/ui/primitives/renderDivider.js.map +1 -0
- package/dist/ui/primitives/renderFooter.d.ts +7 -0
- package/dist/ui/primitives/renderFooter.js +6 -0
- package/dist/ui/primitives/renderFooter.js.map +1 -0
- package/dist/ui/primitives/renderJson.d.ts +3 -0
- package/dist/ui/primitives/renderJson.js +19 -0
- package/dist/ui/primitives/renderJson.js.map +1 -0
- package/dist/ui/primitives/renderKeyValue.d.ts +14 -0
- package/dist/ui/primitives/renderKeyValue.js +34 -0
- package/dist/ui/primitives/renderKeyValue.js.map +1 -0
- package/dist/ui/primitives/renderLogo.d.ts +2 -0
- package/dist/ui/primitives/renderLogo.js +28 -0
- package/dist/ui/primitives/renderLogo.js.map +1 -0
- package/dist/ui/primitives/renderObject.d.ts +1 -0
- package/dist/ui/primitives/renderObject.js +19 -0
- package/dist/ui/primitives/renderObject.js.map +1 -0
- package/dist/ui/primitives/renderPanel.d.ts +23 -0
- package/dist/ui/primitives/renderPanel.js +114 -0
- package/dist/ui/primitives/renderPanel.js.map +1 -0
- package/dist/ui/primitives/renderSubtitle.d.ts +7 -0
- package/dist/ui/primitives/renderSubtitle.js +6 -0
- package/dist/ui/primitives/renderSubtitle.js.map +1 -0
- package/dist/ui/primitives/renderTable.d.ts +6 -0
- package/dist/ui/primitives/renderTable.js +14 -0
- package/dist/ui/primitives/renderTable.js.map +1 -0
- package/dist/ui/primitives/text.d.ts +18 -0
- package/dist/ui/primitives/text.js +154 -0
- package/dist/ui/primitives/text.js.map +1 -0
- package/dist/ui/stream/index.d.ts +1 -0
- package/dist/ui/stream/index.js +2 -0
- package/dist/ui/stream/index.js.map +1 -0
- package/dist/ui/stream/terminal-stream.d.ts +10 -0
- package/dist/ui/stream/terminal-stream.js +20 -0
- package/dist/ui/stream/terminal-stream.js.map +1 -0
- package/dist/ui/theme/index.d.ts +1 -0
- package/dist/ui/theme/index.js +2 -0
- package/dist/ui/theme/index.js.map +1 -0
- package/dist/ui/theme/theme.d.ts +27 -0
- package/dist/ui/theme/theme.js +41 -0
- package/dist/ui/theme/theme.js.map +1 -0
- package/llms.txt +161 -0
- package/package.json +99 -35
- package/.babelrc +0 -4
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -17
- package/.npmignore +0 -1
- package/lib/arcli.js +0 -275
- package/lib/arcli.min.js +0 -1
- package/src/config.js +0 -22
- package/src/consoler.js +0 -10
- package/src/index.js +0 -21
- package/src/init.js +0 -13
- package/src/run.js +0 -4
- package/src/spinner.js +0 -39
- package/tst/index.js +0 -26
- package/webpack.config.js +0 -47
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type VoucherLetter = 'a' | 'b' | 'c';
|
|
2
|
+
export type VoucherFamily = 'factura' | 'nota-credito' | 'nota-debito' | 'factura-credito-electronica' | 'nota-credito-electronica' | 'nota-debito-electronica';
|
|
3
|
+
export type VoucherShortcut = 'fa' | 'fb' | 'fc' | 'nca' | 'ncb' | 'ncc' | 'nda' | 'ndb' | 'ndc' | 'fcea' | 'fceb' | 'fcec' | 'ncea' | 'nceb' | 'ncec' | 'ndea' | 'ndeb' | 'ndec';
|
|
4
|
+
export type VoucherDisplayName = 'Factura A' | 'Factura B' | 'Factura C' | 'Nota de credito A' | 'Nota de credito B' | 'Nota de credito C' | 'Nota de debito A' | 'Nota de debito B' | 'Nota de debito C' | 'Factura de credito electronica A' | 'Factura de credito electronica B' | 'Factura de credito electronica C' | 'Nota de credito electronica A' | 'Nota de credito electronica B' | 'Nota de credito electronica C' | 'Nota de debito electronica A' | 'Nota de debito electronica B' | 'Nota de debito electronica C';
|
|
5
|
+
export interface VoucherKindDefinition {
|
|
6
|
+
readonly arcaType: number;
|
|
7
|
+
readonly displayName: VoucherDisplayName;
|
|
8
|
+
readonly family: VoucherFamily;
|
|
9
|
+
readonly isElectronicCredit: boolean;
|
|
10
|
+
readonly letter: VoucherLetter;
|
|
11
|
+
readonly requiresAssociatedVoucher: boolean;
|
|
12
|
+
readonly shortcut: VoucherShortcut;
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CreateVoucherResultDto } from '@arcasdk/core/lib/application/dto/electronic-billing';
|
|
2
|
+
import type { INextVoucher } from '@arcasdk/core/lib/domain/types/voucher.types';
|
|
3
|
+
import type { VoucherKindDefinition } from './billing.types';
|
|
4
|
+
export interface BillingGateway {
|
|
5
|
+
createNextVoucher(payload: INextVoucher): Promise<CreateVoucherResultDto>;
|
|
6
|
+
getQuotation(currencyCode: string): Promise<number>;
|
|
7
|
+
}
|
|
8
|
+
export interface BillingResponseSummary {
|
|
9
|
+
readonly cae: string | null;
|
|
10
|
+
readonly caeVencimiento: string | null;
|
|
11
|
+
readonly errors: unknown[];
|
|
12
|
+
readonly events: unknown[];
|
|
13
|
+
readonly observaciones: string[];
|
|
14
|
+
readonly observacion: string | null;
|
|
15
|
+
readonly raw: CreateVoucherResultDto | null;
|
|
16
|
+
readonly resultado: string | null;
|
|
17
|
+
readonly suggestions: string[];
|
|
18
|
+
readonly status: 'aprobado' | 'observado' | 'rechazado';
|
|
19
|
+
}
|
|
20
|
+
export interface BillingExecutionResult {
|
|
21
|
+
readonly dryRun: boolean;
|
|
22
|
+
readonly environment: 'produccion' | 'testing';
|
|
23
|
+
readonly payload: INextVoucher;
|
|
24
|
+
readonly response: BillingResponseSummary;
|
|
25
|
+
readonly voucherKind: VoucherKindDefinition;
|
|
26
|
+
readonly warnings?: readonly string[];
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.types.internal.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.types.internal.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.types.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BillingCommandInput, BillingConcept } from './billing.schemas';
|
|
2
|
+
import type { VoucherKindDefinition } from './billing.types';
|
|
3
|
+
export declare function ensureDateOrder(serviceStartDate: string, serviceEndDate: string): void;
|
|
4
|
+
export declare function validateConceptDateInputs(input: BillingCommandInput, voucherKind: VoucherKindDefinition): void;
|
|
5
|
+
export declare function validateDocumentIdentity(input: BillingCommandInput, voucherKind: VoucherKindDefinition): void;
|
|
6
|
+
export declare function validateBillingDateWindow(billingDate: string, today: string, concept: BillingConcept, voucherKind: VoucherKindDefinition): void;
|
|
7
|
+
export declare function validatePaymentDueDate(paymentDueDate: string, minimumPaymentDueDate: string): void;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { diffArcaDatesInDays, formatArcaDateAsArgentineDate } from '../../lib/dates/arca-date.js';
|
|
2
|
+
import { InputValidationError } from '../../lib/errors/app-error.js';
|
|
3
|
+
import { formatDocumentFlag, formatVoucherLabel } from './billing.mappers.js';
|
|
4
|
+
export function ensureDateOrder(serviceStartDate, serviceEndDate) {
|
|
5
|
+
if (serviceStartDate > serviceEndDate) {
|
|
6
|
+
throw new InputValidationError('La fecha de inicio de servicio no puede ser posterior a la fecha de fin.');
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function validateConceptDateInputs(input, voucherKind) {
|
|
10
|
+
const hasAnyServiceDate = Boolean(input.serviceStartDate || input.serviceEndDate);
|
|
11
|
+
const hasPartialServiceDate = Boolean(input.serviceStartDate) !== Boolean(input.serviceEndDate);
|
|
12
|
+
if (input.paymentDueDate) {
|
|
13
|
+
if (voucherKind.isElectronicCredit && voucherKind.family !== 'factura-credito-electronica') {
|
|
14
|
+
throw new InputValidationError(`La ${formatVoucherLabel(voucherKind)} no lleva vencimiento de pago. Quite --vencimiento.`);
|
|
15
|
+
}
|
|
16
|
+
if (!voucherKind.isElectronicCredit && input.concept === 'productos') {
|
|
17
|
+
throw new InputValidationError('El concepto "productos" no usa --vencimiento.');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (input.concept === 'productos') {
|
|
21
|
+
if (hasAnyServiceDate) {
|
|
22
|
+
throw new InputValidationError('El concepto "productos" no usa fechas de servicio. Quite --servicio-desde y --servicio-hasta.');
|
|
23
|
+
}
|
|
24
|
+
if (input.dueDay) {
|
|
25
|
+
throw new InputValidationError('El concepto "productos" no usa --dia. Use solo fecha o monto.');
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (hasPartialServiceDate) {
|
|
30
|
+
throw new InputValidationError('Si informa fechas de servicio, debe enviar ambas: --servicio-desde y --servicio-hasta.');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function validateDocumentIdentity(input, voucherKind) {
|
|
34
|
+
if (input.documentType === 'consumidor-final') {
|
|
35
|
+
if (input.ivaCondition !== 'consumidor-final') {
|
|
36
|
+
throw new InputValidationError(`La ${formatVoucherLabel(voucherKind)} usa consumidor final solo con --ir-cf o --iva-receptor consumidor-final.`);
|
|
37
|
+
}
|
|
38
|
+
if (typeof input.documentNumber === 'number' && input.documentNumber !== 0) {
|
|
39
|
+
throw new InputValidationError(`La ${formatVoucherLabel(voucherKind)} usa consumidor final solo con documento 0. Use --consumidor-final.`);
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (typeof input.documentNumber !== 'number') {
|
|
44
|
+
throw new InputValidationError(`La ${formatVoucherLabel(voucherKind)} requiere documento del receptor. Use ${formatDocumentFlag(input.documentType)}.`);
|
|
45
|
+
}
|
|
46
|
+
if ((input.documentType === 'cuit' || input.documentType === 'cuil') &&
|
|
47
|
+
!/^\d{11}$/.test(String(input.documentNumber))) {
|
|
48
|
+
throw new InputValidationError(`${formatDocumentFlag(input.documentType)} debe tener 11 digitos en ${formatVoucherLabel(voucherKind)}.`);
|
|
49
|
+
}
|
|
50
|
+
if (input.documentType === 'dni' && !/^\d{7,8}$/.test(String(input.documentNumber))) {
|
|
51
|
+
throw new InputValidationError(`--dni debe tener 7 u 8 digitos en ${formatVoucherLabel(voucherKind)}.`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Ventana de CbteFch respecto de hoy segun ARCA (errores 10016 y 10152). */
|
|
55
|
+
function resolveBillingDateWindow(concept, voucherKind) {
|
|
56
|
+
if (voucherKind.isElectronicCredit) {
|
|
57
|
+
return { maxDaysAfter: 1, maxDaysBefore: 5, sameMonthWhenFuture: true };
|
|
58
|
+
}
|
|
59
|
+
if (concept === 'productos') {
|
|
60
|
+
return { maxDaysAfter: 5, maxDaysBefore: 5, sameMonthWhenFuture: true };
|
|
61
|
+
}
|
|
62
|
+
return { maxDaysAfter: 10, maxDaysBefore: 10, sameMonthWhenFuture: false };
|
|
63
|
+
}
|
|
64
|
+
export function validateBillingDateWindow(billingDate, today, concept, voucherKind) {
|
|
65
|
+
const window = resolveBillingDateWindow(concept, voucherKind);
|
|
66
|
+
const offset = diffArcaDatesInDays(today, billingDate);
|
|
67
|
+
const label = formatArcaDateAsArgentineDate(billingDate);
|
|
68
|
+
if (offset < -window.maxDaysBefore || offset > window.maxDaysAfter) {
|
|
69
|
+
throw new InputValidationError(`La fecha ${label} esta fuera de rango para la ${formatVoucherLabel(voucherKind)}: ARCA acepta hasta ${window.maxDaysBefore} dias antes y ${window.maxDaysAfter} despues de hoy.`);
|
|
70
|
+
}
|
|
71
|
+
if (window.sameMonthWhenFuture && offset > 0 && billingDate.slice(0, 6) !== today.slice(0, 6)) {
|
|
72
|
+
throw new InputValidationError(`La fecha ${label} es futura y cae en otro mes. Para la ${formatVoucherLabel(voucherKind)} ARCA solo acepta fechas futuras dentro del mes actual.`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export function validatePaymentDueDate(paymentDueDate, minimumPaymentDueDate) {
|
|
76
|
+
if (paymentDueDate < minimumPaymentDueDate) {
|
|
77
|
+
throw new InputValidationError(`El vencimiento de pago (${formatArcaDateAsArgentineDate(paymentDueDate)}) no puede ser anterior al ${formatArcaDateAsArgentineDate(minimumPaymentDueDate)}.`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=billing.validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.validation.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAI3E,MAAM,UAAU,eAAe,CAAC,gBAAwB,EAAE,cAAsB;IAC9E,IAAI,gBAAgB,GAAG,cAAc,EAAE,CAAC;QACtC,MAAM,IAAI,oBAAoB,CAAC,0EAA0E,CAAC,CAAC;IAC7G,CAAC;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAA0B,EAAE,WAAkC;IACtG,MAAM,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;IAClF,MAAM,qBAAqB,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAEhG,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QACzB,IAAI,WAAW,CAAC,kBAAkB,IAAI,WAAW,CAAC,MAAM,KAAK,6BAA6B,EAAE,CAAC;YAC3F,MAAM,IAAI,oBAAoB,CAC5B,MAAM,kBAAkB,CAAC,WAAW,CAAC,qDAAqD,CAC3F,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,kBAAkB,I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vD,MAAM,KAAK,GAAG,6BAA6B,CAAC,WAAW,CAAC,CAAC;IAEzD,IAAI,MAAM,GAAG,CAAC,MAAM,CAAC,aAAa,IAAI,MAAM,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;QACnE,MAAM,IAAI,oBAAoB,CAC5B,YAAY,KAAK,gCAAgC,kBAAkB,CAAC,WAAW,CAAC,uBAAuB,MAAM,CAAC,aAAa,iBAAiB,MAAM,CAAC,YAAY,kBAAkB,CAClL,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,mBAAmB,IAAI,MAAM,GAAG,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAC9F,MAAM,IAAI,oBAAoB,CAC5B,YAAY,KAAK,yCAAyC,kBAAkB,CAAC,WAAW,CAAC,yDAAyD,CACnJ,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,cAAsB,EAAE,qBAA6B;IAC1F,IAAI,cAAc,GAAG,qBAAqB,EAAE,CAAC;QAC3C,MAAM,IAAI,oBAAoB,CAC5B,2BAA2B,6BAA6B,CAAC,cAAc,CAAC,8BAA8B,6BAA6B,CAAC,qBAAqB,CAAC,GAAG,CAC9J,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { VoucherFamily, VoucherKindDefinition, VoucherLetter, VoucherShortcut } from './billing.types';
|
|
2
|
+
export declare const VOUCHER_KIND_MAP: Record<VoucherShortcut, VoucherKindDefinition>;
|
|
3
|
+
export declare const VOUCHER_SHORTCUTS: readonly VoucherShortcut[];
|
|
4
|
+
export declare const VOUCHER_FAMILIES: readonly VoucherFamily[];
|
|
5
|
+
export declare const VOUCHER_LETTERS: readonly ["a", "b", "c"];
|
|
6
|
+
export declare function getVoucherKindByShortcut(shortcut: string): VoucherKindDefinition | null;
|
|
7
|
+
export declare function getVoucherKindByFamilyAndLetter(family: VoucherFamily, letter: VoucherLetter): VoucherKindDefinition | null;
|
|
8
|
+
export declare function getVoucherKindByArcaType(arcaType: number): VoucherKindDefinition | null;
|
|
9
|
+
export declare function isVoucherShortcut(value: string): value is VoucherShortcut;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
export const VOUCHER_KIND_MAP = {
|
|
2
|
+
fa: {
|
|
3
|
+
arcaType: 1,
|
|
4
|
+
displayName: 'Factura A',
|
|
5
|
+
family: 'factura',
|
|
6
|
+
isElectronicCredit: false,
|
|
7
|
+
letter: 'a',
|
|
8
|
+
requiresAssociatedVoucher: false,
|
|
9
|
+
shortcut: 'fa',
|
|
10
|
+
},
|
|
11
|
+
fb: {
|
|
12
|
+
arcaType: 6,
|
|
13
|
+
displayName: 'Factura B',
|
|
14
|
+
family: 'factura',
|
|
15
|
+
isElectronicCredit: false,
|
|
16
|
+
letter: 'b',
|
|
17
|
+
requiresAssociatedVoucher: false,
|
|
18
|
+
shortcut: 'fb',
|
|
19
|
+
},
|
|
20
|
+
fc: {
|
|
21
|
+
arcaType: 11,
|
|
22
|
+
displayName: 'Factura C',
|
|
23
|
+
family: 'factura',
|
|
24
|
+
isElectronicCredit: false,
|
|
25
|
+
letter: 'c',
|
|
26
|
+
requiresAssociatedVoucher: false,
|
|
27
|
+
shortcut: 'fc',
|
|
28
|
+
},
|
|
29
|
+
nca: {
|
|
30
|
+
arcaType: 3,
|
|
31
|
+
displayName: 'Nota de credito A',
|
|
32
|
+
family: 'nota-credito',
|
|
33
|
+
isElectronicCredit: false,
|
|
34
|
+
letter: 'a',
|
|
35
|
+
requiresAssociatedVoucher: true,
|
|
36
|
+
shortcut: 'nca',
|
|
37
|
+
},
|
|
38
|
+
ncb: {
|
|
39
|
+
arcaType: 8,
|
|
40
|
+
displayName: 'Nota de credito B',
|
|
41
|
+
family: 'nota-credito',
|
|
42
|
+
isElectronicCredit: false,
|
|
43
|
+
letter: 'b',
|
|
44
|
+
requiresAssociatedVoucher: true,
|
|
45
|
+
shortcut: 'ncb',
|
|
46
|
+
},
|
|
47
|
+
ncc: {
|
|
48
|
+
arcaType: 13,
|
|
49
|
+
displayName: 'Nota de credito C',
|
|
50
|
+
family: 'nota-credito',
|
|
51
|
+
isElectronicCredit: false,
|
|
52
|
+
letter: 'c',
|
|
53
|
+
requiresAssociatedVoucher: true,
|
|
54
|
+
shortcut: 'ncc',
|
|
55
|
+
},
|
|
56
|
+
nda: {
|
|
57
|
+
arcaType: 2,
|
|
58
|
+
displayName: 'Nota de debito A',
|
|
59
|
+
family: 'nota-debito',
|
|
60
|
+
isElectronicCredit: false,
|
|
61
|
+
letter: 'a',
|
|
62
|
+
requiresAssociatedVoucher: true,
|
|
63
|
+
shortcut: 'nda',
|
|
64
|
+
},
|
|
65
|
+
ndb: {
|
|
66
|
+
arcaType: 7,
|
|
67
|
+
displayName: 'Nota de debito B',
|
|
68
|
+
family: 'nota-debito',
|
|
69
|
+
isElectronicCredit: false,
|
|
70
|
+
letter: 'b',
|
|
71
|
+
requiresAssociatedVoucher: true,
|
|
72
|
+
shortcut: 'ndb',
|
|
73
|
+
},
|
|
74
|
+
ndc: {
|
|
75
|
+
arcaType: 12,
|
|
76
|
+
displayName: 'Nota de debito C',
|
|
77
|
+
family: 'nota-debito',
|
|
78
|
+
isElectronicCredit: false,
|
|
79
|
+
letter: 'c',
|
|
80
|
+
requiresAssociatedVoucher: true,
|
|
81
|
+
shortcut: 'ndc',
|
|
82
|
+
},
|
|
83
|
+
fcea: {
|
|
84
|
+
arcaType: 201,
|
|
85
|
+
displayName: 'Factura de credito electronica A',
|
|
86
|
+
family: 'factura-credito-electronica',
|
|
87
|
+
isElectronicCredit: true,
|
|
88
|
+
letter: 'a',
|
|
89
|
+
requiresAssociatedVoucher: false,
|
|
90
|
+
shortcut: 'fcea',
|
|
91
|
+
},
|
|
92
|
+
fceb: {
|
|
93
|
+
arcaType: 206,
|
|
94
|
+
displayName: 'Factura de credito electronica B',
|
|
95
|
+
family: 'factura-credito-electronica',
|
|
96
|
+
isElectronicCredit: true,
|
|
97
|
+
letter: 'b',
|
|
98
|
+
requiresAssociatedVoucher: false,
|
|
99
|
+
shortcut: 'fceb',
|
|
100
|
+
},
|
|
101
|
+
fcec: {
|
|
102
|
+
arcaType: 211,
|
|
103
|
+
displayName: 'Factura de credito electronica C',
|
|
104
|
+
family: 'factura-credito-electronica',
|
|
105
|
+
isElectronicCredit: true,
|
|
106
|
+
letter: 'c',
|
|
107
|
+
requiresAssociatedVoucher: false,
|
|
108
|
+
shortcut: 'fcec',
|
|
109
|
+
},
|
|
110
|
+
ncea: {
|
|
111
|
+
arcaType: 203,
|
|
112
|
+
displayName: 'Nota de credito electronica A',
|
|
113
|
+
family: 'nota-credito-electronica',
|
|
114
|
+
isElectronicCredit: true,
|
|
115
|
+
letter: 'a',
|
|
116
|
+
requiresAssociatedVoucher: true,
|
|
117
|
+
shortcut: 'ncea',
|
|
118
|
+
},
|
|
119
|
+
nceb: {
|
|
120
|
+
arcaType: 208,
|
|
121
|
+
displayName: 'Nota de credito electronica B',
|
|
122
|
+
family: 'nota-credito-electronica',
|
|
123
|
+
isElectronicCredit: true,
|
|
124
|
+
letter: 'b',
|
|
125
|
+
requiresAssociatedVoucher: true,
|
|
126
|
+
shortcut: 'nceb',
|
|
127
|
+
},
|
|
128
|
+
ncec: {
|
|
129
|
+
arcaType: 213,
|
|
130
|
+
displayName: 'Nota de credito electronica C',
|
|
131
|
+
family: 'nota-credito-electronica',
|
|
132
|
+
isElectronicCredit: true,
|
|
133
|
+
letter: 'c',
|
|
134
|
+
requiresAssociatedVoucher: true,
|
|
135
|
+
shortcut: 'ncec',
|
|
136
|
+
},
|
|
137
|
+
ndea: {
|
|
138
|
+
arcaType: 202,
|
|
139
|
+
displayName: 'Nota de debito electronica A',
|
|
140
|
+
family: 'nota-debito-electronica',
|
|
141
|
+
isElectronicCredit: true,
|
|
142
|
+
letter: 'a',
|
|
143
|
+
requiresAssociatedVoucher: true,
|
|
144
|
+
shortcut: 'ndea',
|
|
145
|
+
},
|
|
146
|
+
ndeb: {
|
|
147
|
+
arcaType: 207,
|
|
148
|
+
displayName: 'Nota de debito electronica B',
|
|
149
|
+
family: 'nota-debito-electronica',
|
|
150
|
+
isElectronicCredit: true,
|
|
151
|
+
letter: 'b',
|
|
152
|
+
requiresAssociatedVoucher: true,
|
|
153
|
+
shortcut: 'ndeb',
|
|
154
|
+
},
|
|
155
|
+
ndec: {
|
|
156
|
+
arcaType: 212,
|
|
157
|
+
displayName: 'Nota de debito electronica C',
|
|
158
|
+
family: 'nota-debito-electronica',
|
|
159
|
+
isElectronicCredit: true,
|
|
160
|
+
letter: 'c',
|
|
161
|
+
requiresAssociatedVoucher: true,
|
|
162
|
+
shortcut: 'ndec',
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
export const VOUCHER_SHORTCUTS = Object.freeze(Object.keys(VOUCHER_KIND_MAP));
|
|
166
|
+
export const VOUCHER_FAMILIES = Object.freeze(Array.from(new Set(VOUCHER_SHORTCUTS.map((shortcut) => VOUCHER_KIND_MAP[shortcut].family))));
|
|
167
|
+
export const VOUCHER_LETTERS = Object.freeze(['a', 'b', 'c']);
|
|
168
|
+
export function getVoucherKindByShortcut(shortcut) {
|
|
169
|
+
return VOUCHER_KIND_MAP[shortcut] ?? null;
|
|
170
|
+
}
|
|
171
|
+
export function getVoucherKindByFamilyAndLetter(family, letter) {
|
|
172
|
+
return (VOUCHER_SHORTCUTS.map((shortcut) => VOUCHER_KIND_MAP[shortcut]).find((definition) => definition.family === family && definition.letter === letter) ?? null);
|
|
173
|
+
}
|
|
174
|
+
export function getVoucherKindByArcaType(arcaType) {
|
|
175
|
+
return (VOUCHER_SHORTCUTS.map((shortcut) => VOUCHER_KIND_MAP[shortcut]).find((definition) => definition.arcaType === arcaType) ?? null);
|
|
176
|
+
}
|
|
177
|
+
export function isVoucherShortcut(value) {
|
|
178
|
+
return value in VOUCHER_KIND_MAP;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=voucher-kind-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voucher-kind-map.js","sourceRoot":"","sources":["../../../src/modules/billing/voucher-kind-map.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAmD;IAC9E,EAAE,EAAE;QACF,QAAQ,EAAE,CAAC;QACX,WAAW,EAAE,WAAW;QACxB,MAAM,EAAE,SAAS;QACjB,kBAAkB,EAAE,KAAK;QACzB,MAAM,EAAE,GAAG;QACX,yBAAyB,EAAE,KAAK;QAChC,QAAQ,EAAE,IAAI;KACf;IACD,EAAE,EAAE;QACF,QAAQ,EAAE,CAAC;QACX,WAAW,EAAE,WAAW;QACxB,MAAM,EAAE,SAAS;QACjB,kBAAkB,EAAE,KAAK;QACzB,MAAM,EAAE,GAAG;QACX,yBAAyB,EAAE,KAAK;QAChC,QAAQ,EAAE,IAAI;KACf;IACD,EAAE,EAAE;QACF,QAAQ,EAAE,EAAE;QACZ,WAAW,EAAE,WAAW;QACxB,MAAM,EAAE,SAAS;QACjB,kBAAkB,EAAE,KAAK;QACzB,MAAM,EAAE,GAAG;QACX,yBAAyB,EAAE,KAAK;QAChC,QAAQ,EAAE,IAAI;KACf;IACD,GAAG,EAAE;QACH,QAAQ,EAAE,CAAC;QACX,WAAW,EAAE,mBAAmB;QAChC,MAAM,EAAE,cAAc;QACtB,kBAAkB,EAAE,KAAK;QACzB,MAAM,EAAE,GAAG;QACX,yBAAyB,EAAE,IAAI;QAC/B,QAAQ,EAAE,KAAK;KAChB;IACD,GAAG,EAAE;QACH,QAAQ,EAAE,CAAC;QACX,WAAW,EAAE,mBAAmB;QAChC,MAAM,EAAE,cAAc;QACtB,kBAAkB,EAAE,KAAK;QACzB,MAAM,EAAE,GAAG;QACX,yBAAyB,EAAE,IAAI;QAC/B,QAAQ,EAAE,KAAK;KAChB;IACD,GAAG,EAAE;QACH,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,CAAC,UAAU,CAAC,QAAQ,KAAK,QAAQ,CACjD,IAAI,IAAI,CACV,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,KAAK,IAAI,gBAAgB,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ArcaRuntimeValidation } from '../../services/arca/arca-context.resolver';
|
|
2
|
+
import type { ArcliConfig } from './config.schemas';
|
|
3
|
+
export interface ConfigDoctorReport {
|
|
4
|
+
readonly checks: ReadonlyArray<{
|
|
5
|
+
readonly category: 'error' | 'ok' | 'warning';
|
|
6
|
+
readonly detail: string;
|
|
7
|
+
readonly label: string;
|
|
8
|
+
}>;
|
|
9
|
+
readonly ok: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ConfigDoctorRuntimeCheck {
|
|
12
|
+
readonly error?: string;
|
|
13
|
+
readonly validation?: ArcaRuntimeValidation;
|
|
14
|
+
}
|
|
15
|
+
export declare function buildConfigDoctorReport(config: ArcliConfig, runtimeCheck?: ConfigDoctorRuntimeCheck): ConfigDoctorReport;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { isCertificateExpiringSoon, readCertificateExpiry } from '../../lib/security/certificate.js';
|
|
2
|
+
import { readPemFile } from '../../lib/security/pem.js';
|
|
3
|
+
const CERTIFICATE_EXPIRY_WARNING_DAYS = 30;
|
|
4
|
+
function buildCertificateExpiryCheck(label, certPath) {
|
|
5
|
+
if (!certPath) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
const pemContent = readPemFile(certPath, 'certificado');
|
|
10
|
+
const expiry = readCertificateExpiry(pemContent);
|
|
11
|
+
const formattedDate = expiry.expiresAt.toLocaleDateString('es-AR');
|
|
12
|
+
if (expiry.isExpired) {
|
|
13
|
+
return { category: 'error', detail: `El certificado vencio el ${formattedDate}.`, label };
|
|
14
|
+
}
|
|
15
|
+
if (isCertificateExpiringSoon(expiry, CERTIFICATE_EXPIRY_WARNING_DAYS)) {
|
|
16
|
+
return {
|
|
17
|
+
category: 'warning',
|
|
18
|
+
detail: `El certificado vence en ${expiry.daysRemaining} dias (${formattedDate}). Renuevelo pronto.`,
|
|
19
|
+
label,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return { category: 'ok', detail: `El certificado vence el ${formattedDate}.`, label };
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
return {
|
|
26
|
+
category: 'warning',
|
|
27
|
+
detail: `No se pudo verificar el vencimiento del certificado: ${error instanceof Error ? error.message : String(error)}`,
|
|
28
|
+
label,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function buildConfigDoctorReport(config, runtimeCheck) {
|
|
33
|
+
const checks = [];
|
|
34
|
+
const conditionalChecks = [
|
|
35
|
+
{
|
|
36
|
+
label: 'CUIT',
|
|
37
|
+
ok: config.cuit,
|
|
38
|
+
okDetail: 'CUIT listo para emitir comprobantes.',
|
|
39
|
+
warningDetail: 'Configure su CUIT con "arcli config establecer cuit <valor>".',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: 'Punto de venta',
|
|
43
|
+
ok: config.puntoVentaPorDefecto,
|
|
44
|
+
okDetail: `Punto de venta por defecto: ${config.puntoVentaPorDefecto}.`,
|
|
45
|
+
warningDetail: 'Configure un punto de venta por defecto con "arcli config establecer puntoVenta <valor>".',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: 'Concepto',
|
|
49
|
+
ok: config.conceptoPorDefecto,
|
|
50
|
+
okDetail: `Concepto por defecto: ${config.conceptoPorDefecto}.`,
|
|
51
|
+
warningDetail: 'Puede fijar un concepto por defecto con "arcli config establecer concepto servicios".',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: 'IVA receptor',
|
|
55
|
+
ok: config.ivaReceptorPorDefecto,
|
|
56
|
+
okDetail: `IVA receptor por defecto: ${config.ivaReceptorPorDefecto}.`,
|
|
57
|
+
warningDetail: 'Puede fijar un IVA receptor por defecto con "arcli config establecer ivaReceptor consumidor-final".',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: 'Credenciales testing',
|
|
61
|
+
ok: config.cert.testing && config.key.testing,
|
|
62
|
+
okDetail: 'Certificado y clave de testing configurados.',
|
|
63
|
+
warningDetail: 'Faltan credenciales de testing. Configure "cert.testing" y "key.testing" con "arcli config establecer".',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
label: 'Credenciales produccion',
|
|
67
|
+
ok: config.cert.produccion && config.key.produccion,
|
|
68
|
+
okDetail: 'Certificado y clave de produccion configurados.',
|
|
69
|
+
warningDetail: 'Todavia no hay credenciales de produccion configuradas. Puede cargarlas con "cert.produccion" y "key.produccion".',
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
for (const check of conditionalChecks) {
|
|
73
|
+
checks.push(check.ok
|
|
74
|
+
? { category: 'ok', detail: check.okDetail, label: check.label }
|
|
75
|
+
: { category: 'warning', detail: check.warningDetail, label: check.label });
|
|
76
|
+
}
|
|
77
|
+
for (const [label, certPath] of [
|
|
78
|
+
['Vencimiento cert. testing', config.cert.testing],
|
|
79
|
+
['Vencimiento cert. produccion', config.cert.produccion],
|
|
80
|
+
]) {
|
|
81
|
+
const certificateCheck = buildCertificateExpiryCheck(label, certPath);
|
|
82
|
+
if (certificateCheck) {
|
|
83
|
+
checks.push(certificateCheck);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
checks.push({
|
|
87
|
+
category: 'ok',
|
|
88
|
+
detail: `Entorno por defecto: ${config.entornoPorDefecto}.`,
|
|
89
|
+
label: 'Entorno',
|
|
90
|
+
});
|
|
91
|
+
checks.push({
|
|
92
|
+
category: 'ok',
|
|
93
|
+
detail: `Emitir por defecto: ${config.output.emitirPorDefecto ? 'si' : 'no'}.`,
|
|
94
|
+
label: 'Emision',
|
|
95
|
+
});
|
|
96
|
+
checks.push({
|
|
97
|
+
category: 'ok',
|
|
98
|
+
detail: `Salida JSON por defecto: ${config.output.jsonPorDefecto ? 'si' : 'no'}.`,
|
|
99
|
+
label: 'JSON',
|
|
100
|
+
});
|
|
101
|
+
checks.push({
|
|
102
|
+
category: 'ok',
|
|
103
|
+
detail: `Respuesta bruta por defecto: ${config.output.brutoPorDefecto ? 'si' : 'no'}.`,
|
|
104
|
+
label: 'Bruto',
|
|
105
|
+
});
|
|
106
|
+
if (runtimeCheck?.validation) {
|
|
107
|
+
checks.push({
|
|
108
|
+
category: 'ok',
|
|
109
|
+
detail: `Configuracion valida para ${runtimeCheck.validation.environment}.`,
|
|
110
|
+
label: 'Revision activa',
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else if (runtimeCheck?.error) {
|
|
114
|
+
checks.push({
|
|
115
|
+
category: 'error',
|
|
116
|
+
detail: runtimeCheck.error,
|
|
117
|
+
label: 'Revision activa',
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
checks,
|
|
122
|
+
ok: checks.every((check) => check.category === 'ok'),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=config-doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-doctor.js","sourceRoot":"","sources":["../../../src/modules/config/config-doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAKrD,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAgB3C,SAAS,2BAA2B,CAClC,KAAa,EACb,QAA4B;IAE5B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,WAAW,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QACxD,MAAM,MA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C;YACV,QAAQ,EAAE,OAAO;YACjB,MAAM,EAAE,YAAY,CAAC,KAAK;YAC1B,KAAK,EAAE,iBAAiB;SACzB,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,MAAM;QACN,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,IAAI,CAAC;KACrD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type CanonicalConfigKey = 'alicuotaPorDefecto' | 'aliasCbu' | 'cbu' | 'cert.produccion' | 'cert.testing' | 'conceptoPorDefecto' | 'cotizacionPorDefecto' | 'cuit' | 'entornoPorDefecto' | 'ivaReceptorPorDefecto' | 'key.produccion' | 'key.testing' | 'monedaPorDefecto' | 'output.emitirPorDefecto' | 'output.jsonPorDefecto' | 'output.brutoPorDefecto' | 'puntoVentaPorDefecto' | 'ticketPath' | 'verificarFce';
|
|
2
|
+
export declare function parseConfigValue(key: CanonicalConfigKey, value: string): boolean | number | string;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { readPemFile } from '../../lib/security/pem.js';
|
|
2
|
+
import { arcliDefaultConceptSchema, arcliDefaultIvaConditionSchema, arcliDefaultIvaRateSchema, arcliEnvironmentSchema, } from './config.schemas.js';
|
|
3
|
+
function parseBoolean(value) {
|
|
4
|
+
const normalizedValue = value.trim().toLowerCase();
|
|
5
|
+
if (normalizedValue === 'true' || normalizedValue === '1' || normalizedValue === 'si' || normalizedValue === 'sí') {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (normalizedValue === 'false' || normalizedValue === '0' || normalizedValue === 'no') {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
throw new Error(`El valor "${value}" no es un booleano valido. Use true/false, si/no o 1/0.`);
|
|
12
|
+
}
|
|
13
|
+
function parseNonEmptyString(value) {
|
|
14
|
+
const normalizedValue = value.trim();
|
|
15
|
+
if (!normalizedValue) {
|
|
16
|
+
throw new Error('El valor no puede estar vacio.');
|
|
17
|
+
}
|
|
18
|
+
return normalizedValue;
|
|
19
|
+
}
|
|
20
|
+
function parseIvaRate(value) {
|
|
21
|
+
const result = arcliDefaultIvaRateSchema.safeParse(value);
|
|
22
|
+
if (!result.success) {
|
|
23
|
+
throw new Error(`La alicuota "${value}" no es valida. Use 0, 2.5, 5, 10.5, 21 o 27.`);
|
|
24
|
+
}
|
|
25
|
+
return result.data;
|
|
26
|
+
}
|
|
27
|
+
function parseCbu(value) {
|
|
28
|
+
const normalizedValue = value.trim();
|
|
29
|
+
if (!/^\d{22}$/.test(normalizedValue)) {
|
|
30
|
+
throw new Error(`El CBU "${value}" no es valido: debe tener 22 digitos.`);
|
|
31
|
+
}
|
|
32
|
+
return normalizedValue;
|
|
33
|
+
}
|
|
34
|
+
function parseCbuAlias(value) {
|
|
35
|
+
const normalizedValue = value.trim();
|
|
36
|
+
if (!/^[A-Za-z0-9.-]{6,20}$/.test(normalizedValue)) {
|
|
37
|
+
throw new Error(`El alias "${value}" no es valido: debe tener entre 6 y 20 letras, numeros, puntos o guiones.`);
|
|
38
|
+
}
|
|
39
|
+
return normalizedValue;
|
|
40
|
+
}
|
|
41
|
+
function parsePositiveInteger(value) {
|
|
42
|
+
const parsedValue = Number.parseInt(value.trim(), 10);
|
|
43
|
+
if (!Number.isInteger(parsedValue) || parsedValue <= 0) {
|
|
44
|
+
throw new Error(`El valor "${value}" no es un entero positivo valido.`);
|
|
45
|
+
}
|
|
46
|
+
return parsedValue;
|
|
47
|
+
}
|
|
48
|
+
function parsePositiveNumber(value) {
|
|
49
|
+
const parsedValue = Number.parseFloat(value.trim());
|
|
50
|
+
if (!Number.isFinite(parsedValue) || parsedValue <= 0) {
|
|
51
|
+
throw new Error(`El valor "${value}" no es un numero positivo valido.`);
|
|
52
|
+
}
|
|
53
|
+
return parsedValue;
|
|
54
|
+
}
|
|
55
|
+
function parsePemPath(value, label) {
|
|
56
|
+
const normalizedValue = parseNonEmptyString(value);
|
|
57
|
+
readPemFile(normalizedValue, label);
|
|
58
|
+
return normalizedValue;
|
|
59
|
+
}
|
|
60
|
+
export function parseConfigValue(key, value) {
|
|
61
|
+
switch (key) {
|
|
62
|
+
case 'alicuotaPorDefecto':
|
|
63
|
+
return parseIvaRate(value);
|
|
64
|
+
case 'aliasCbu':
|
|
65
|
+
return parseCbuAlias(value);
|
|
66
|
+
case 'cbu':
|
|
67
|
+
return parseCbu(value);
|
|
68
|
+
case 'conceptoPorDefecto':
|
|
69
|
+
return arcliDefaultConceptSchema.parse(value.trim().toLowerCase());
|
|
70
|
+
case 'cotizacionPorDefecto':
|
|
71
|
+
return parsePositiveNumber(value);
|
|
72
|
+
case 'cuit':
|
|
73
|
+
return value.trim();
|
|
74
|
+
case 'entornoPorDefecto':
|
|
75
|
+
return arcliEnvironmentSchema.parse(value.trim().toLowerCase());
|
|
76
|
+
case 'ivaReceptorPorDefecto':
|
|
77
|
+
return arcliDefaultIvaConditionSchema.parse(value.trim().toLowerCase());
|
|
78
|
+
case 'monedaPorDefecto':
|
|
79
|
+
return value.trim().toUpperCase();
|
|
80
|
+
case 'verificarFce':
|
|
81
|
+
case 'output.emitirPorDefecto':
|
|
82
|
+
case 'output.jsonPorDefecto':
|
|
83
|
+
case 'output.brutoPorDefecto':
|
|
84
|
+
return parseBoolean(value);
|
|
85
|
+
case 'puntoVentaPorDefecto':
|
|
86
|
+
return parsePositiveInteger(value);
|
|
87
|
+
case 'ticketPath':
|
|
88
|
+
return parseNonEmptyString(value);
|
|
89
|
+
case 'cert.produccion':
|
|
90
|
+
case 'cert.testing':
|
|
91
|
+
return parsePemPath(value, 'certificado');
|
|
92
|
+
case 'key.produccion':
|
|
93
|
+
case 'key.testing':
|
|
94
|
+
return parsePemPath(value, 'clave privada');
|
|
95
|
+
default:
|
|
96
|
+
return parseNonEmptyString(value);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=config-value-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-value-parser.js","sourceRoot":"","sources":["../../../src/modules/config/config-value-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EACL,yBAAyB,EACzB,8BAA8B,EAC9B,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAuB1B,SAAS,YAAY,CAAC,KAAa;IACjC,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAEnD,IAAI,eAAe,KAAK,MAAM,IAAI,eAAe,KAAK,GAAG,IAAI,eAAe,KAAK,IAAI,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAClH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,eAAe,KAAK,OAAO,IAAI,eAAe,KAAK,GAAG,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QACvF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,aAAa,KAAK,0DAA0D,CAAC,CAAC;AAChG,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAErC,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,MAAM,MAAM,GAAG,yBAAyB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAE1D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,gBAAgB,KAAK,+CAA+C,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,SAAS,QAAQ,CAAC,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jB,OAAO,YAAY,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QAC5C,KAAK,gBAAgB,CAAC;QACtB,KAAK,aAAa;YAChB,OAAO,YAAY,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;QAC9C;YACE,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ArcliConfig } from './config.schemas';
|
|
2
|
+
import type { ConfigDoctorReport } from './config-doctor';
|
|
3
|
+
export declare function formatConfig(config: ArcliConfig, effectiveTicketPath: string): string;
|
|
4
|
+
export declare function formatConfigPath(configPath: string): string;
|
|
5
|
+
export declare function formatConfigAsText(config: ArcliConfig, effectiveTicketPath: string): string;
|
|
6
|
+
export declare function formatConfigDoctor(report: ConfigDoctorReport): string;
|
|
7
|
+
export declare function formatConfigDoctorAsText(report: ConfigDoctorReport): string;
|