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,8 @@
|
|
|
1
|
+
import type { BillingConcept, BillingDocumentType, BillingIvaCondition } from './billing.schemas';
|
|
2
|
+
import type { VoucherKindDefinition } from './billing.types';
|
|
3
|
+
export declare function resolveBillingConceptCode(concept: BillingConcept): number;
|
|
4
|
+
export declare function resolveBillingDocumentTypeCode(documentType: BillingDocumentType): number;
|
|
5
|
+
export declare function resolveBillingIvaConditionCode(ivaCondition: BillingIvaCondition): number;
|
|
6
|
+
export declare function resolveBillingCurrencyCode(currencyCode?: string): string;
|
|
7
|
+
export declare function formatVoucherLabel(voucherKind: VoucherKindDefinition): string;
|
|
8
|
+
export declare function formatDocumentFlag(documentType: BillingDocumentType): string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { DEFAULT_CURRENCY_CODE } from './billing.constants.js';
|
|
2
|
+
const BILLING_CONCEPT_MAP = {
|
|
3
|
+
productos: 1,
|
|
4
|
+
servicios: 2,
|
|
5
|
+
'productos-servicios': 3,
|
|
6
|
+
};
|
|
7
|
+
const BILLING_DOCUMENT_TYPE_MAP = {
|
|
8
|
+
'consumidor-final': 99,
|
|
9
|
+
cuil: 86,
|
|
10
|
+
cuit: 80,
|
|
11
|
+
dni: 96,
|
|
12
|
+
};
|
|
13
|
+
const BILLING_IVA_CONDITION_MAP = {
|
|
14
|
+
'cliente-del-exterior': 9,
|
|
15
|
+
'consumidor-final': 5,
|
|
16
|
+
'iva-liberado': 10,
|
|
17
|
+
'iva-no-alcanzado': 15,
|
|
18
|
+
'monotributista-social': 13,
|
|
19
|
+
'monotributo-trabajador-independiente-promovido': 16,
|
|
20
|
+
'proveedor-del-exterior': 8,
|
|
21
|
+
'responsable-inscripto': 1,
|
|
22
|
+
'responsable-monotributo': 6,
|
|
23
|
+
'sujeto-exento': 4,
|
|
24
|
+
'sujeto-no-categorizado': 7,
|
|
25
|
+
};
|
|
26
|
+
const BILLING_CURRENCY_CODE_MAP = {
|
|
27
|
+
ARS: 'PES',
|
|
28
|
+
DOL: 'DOL',
|
|
29
|
+
PES: 'PES',
|
|
30
|
+
USD: 'DOL',
|
|
31
|
+
};
|
|
32
|
+
export function resolveBillingConceptCode(concept) {
|
|
33
|
+
return BILLING_CONCEPT_MAP[concept];
|
|
34
|
+
}
|
|
35
|
+
export function resolveBillingDocumentTypeCode(documentType) {
|
|
36
|
+
return BILLING_DOCUMENT_TYPE_MAP[documentType];
|
|
37
|
+
}
|
|
38
|
+
export function resolveBillingIvaConditionCode(ivaCondition) {
|
|
39
|
+
return BILLING_IVA_CONDITION_MAP[ivaCondition];
|
|
40
|
+
}
|
|
41
|
+
export function resolveBillingCurrencyCode(currencyCode = DEFAULT_CURRENCY_CODE) {
|
|
42
|
+
const normalizedCode = currencyCode.trim().toUpperCase();
|
|
43
|
+
return BILLING_CURRENCY_CODE_MAP[normalizedCode] ?? normalizedCode;
|
|
44
|
+
}
|
|
45
|
+
export function formatVoucherLabel(voucherKind) {
|
|
46
|
+
return voucherKind.displayName.toLowerCase();
|
|
47
|
+
}
|
|
48
|
+
export function formatDocumentFlag(documentType) {
|
|
49
|
+
switch (documentType) {
|
|
50
|
+
case 'cuit':
|
|
51
|
+
return '--cuit';
|
|
52
|
+
case 'cuil':
|
|
53
|
+
return '--cuil';
|
|
54
|
+
case 'dni':
|
|
55
|
+
return '--dni';
|
|
56
|
+
default:
|
|
57
|
+
return '--consumidor-final';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=billing.mappers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.mappers.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.mappers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAI5D,MAAM,mBAAmB,GAAmC;IAC1D,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC;IACZ,qBAAqB,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,yBAAyB,GAAwC;IACrE,kBAAkB,EAAE,EAAE;IACtB,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IACR,GAAG,EAAE,EAAE;CACR,CAAC;AAEF,MAAM,yBAAyB,GAAwC;IACrE,sBAAsB,EAAE,CAAC;IACzB,kBAAkB,EAAE,CAAC;IACrB,cAAc,EAAE,EAAE;IAClB,kBAAkB,EAAE,EAAE;IACtB,uBAAuB,EAAE,EAAE;IAC3B,gDAAgD,EAAE,EAAE;IACpD,wBAAwB,EAAE,CAAC;IAC3B,uBAAuB,EAAE,CAAC;IAC1B,yBAAyB,EAAE,CAAC;IAC5B,eAAe,EAAE,CAAC;IAClB,wBAAwB,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,yBAAyB,GAA2B;IACxD,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;CACX,CAAC;AAEF,MAAM,UAAU,yBAAyB,CAAC,OAAuB;IAC/D,OAAO,mBAAmB,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,YAAiC;IAC9E,OAAO,yBAAyB,CAAC,YAAY,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,YAAiC;IAC9E,OAAO,yBAAyB,CAAC,YAAY,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,YAAY,GAAG,qBAAqB;IAC7E,MAAM,cAAc,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAEzD,OAAO,yBAAyB,CAAC,cAAc,CAAC,IAAI,cAAc,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,WAAkC;IACnE,OAAO,WAAW,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,YAAiC;IAClE,QAAQ,YAAY,EAAE,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC;QAClB,KAAK,KAAK;YACR,OAAO,OAAO,CAAC;QACjB;YACE,OAAO,oBAAoB,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { formatBillingResultAsJson } from './billing.json-format';
|
|
2
|
+
export { formatBillingResultAsText } from './billing.text';
|
|
3
|
+
export interface BillingPresenterOptions {
|
|
4
|
+
readonly environment?: 'produccion' | 'testing';
|
|
5
|
+
readonly previewShown?: boolean;
|
|
6
|
+
readonly raw?: boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.presenter.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.presenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const billingConceptSchema: z.ZodPreprocess<z.ZodEnum<{
|
|
3
|
+
productos: "productos";
|
|
4
|
+
"productos-servicios": "productos-servicios";
|
|
5
|
+
servicios: "servicios";
|
|
6
|
+
}>>;
|
|
7
|
+
export declare const billingDocumentTypeSchema: z.ZodEnum<{
|
|
8
|
+
"consumidor-final": "consumidor-final";
|
|
9
|
+
cuil: "cuil";
|
|
10
|
+
cuit: "cuit";
|
|
11
|
+
dni: "dni";
|
|
12
|
+
}>;
|
|
13
|
+
export declare const billingIvaConditionSchema: z.ZodEnum<{
|
|
14
|
+
"consumidor-final": "consumidor-final";
|
|
15
|
+
"cliente-del-exterior": "cliente-del-exterior";
|
|
16
|
+
"iva-liberado": "iva-liberado";
|
|
17
|
+
"iva-no-alcanzado": "iva-no-alcanzado";
|
|
18
|
+
"monotributista-social": "monotributista-social";
|
|
19
|
+
"monotributo-trabajador-independiente-promovido": "monotributo-trabajador-independiente-promovido";
|
|
20
|
+
"proveedor-del-exterior": "proveedor-del-exterior";
|
|
21
|
+
"responsable-inscripto": "responsable-inscripto";
|
|
22
|
+
"responsable-monotributo": "responsable-monotributo";
|
|
23
|
+
"sujeto-exento": "sujeto-exento";
|
|
24
|
+
"sujeto-no-categorizado": "sujeto-no-categorizado";
|
|
25
|
+
}>;
|
|
26
|
+
export declare const billingIvaRateSchema: z.ZodPreprocess<z.ZodEnum<{
|
|
27
|
+
0: "0";
|
|
28
|
+
5: "5";
|
|
29
|
+
2.5: "2.5";
|
|
30
|
+
10.5: "10.5";
|
|
31
|
+
21: "21";
|
|
32
|
+
27: "27";
|
|
33
|
+
}>>;
|
|
34
|
+
export declare const billingCommandSchema: z.ZodObject<{
|
|
35
|
+
associatedPeriod: z.ZodOptional<z.ZodObject<{
|
|
36
|
+
desde: z.ZodOptional<z.ZodString>;
|
|
37
|
+
hasta: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, z.core.$strip>>;
|
|
39
|
+
associatedVoucher: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
cuit: z.ZodOptional<z.ZodString>;
|
|
41
|
+
fecha: z.ZodOptional<z.ZodString>;
|
|
42
|
+
numero: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
puntoVenta: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
shortcut: z.ZodOptional<z.ZodString>;
|
|
45
|
+
tipo: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
billingDate: z.ZodOptional<z.ZodString>;
|
|
48
|
+
cancellation: z.ZodDefault<z.ZodBoolean>;
|
|
49
|
+
cbu: z.ZodOptional<z.ZodString>;
|
|
50
|
+
cbuAlias: z.ZodOptional<z.ZodString>;
|
|
51
|
+
concept: z.ZodPreprocess<z.ZodEnum<{
|
|
52
|
+
productos: "productos";
|
|
53
|
+
"productos-servicios": "productos-servicios";
|
|
54
|
+
servicios: "servicios";
|
|
55
|
+
}>>;
|
|
56
|
+
currencyCode: z.ZodDefault<z.ZodString>;
|
|
57
|
+
documentNumber: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
documentType: z.ZodDefault<z.ZodEnum<{
|
|
59
|
+
"consumidor-final": "consumidor-final";
|
|
60
|
+
cuil: "cuil";
|
|
61
|
+
cuit: "cuit";
|
|
62
|
+
dni: "dni";
|
|
63
|
+
}>>;
|
|
64
|
+
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
65
|
+
emit: z.ZodDefault<z.ZodBoolean>;
|
|
66
|
+
exchangeRate: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
exemptAmount: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
ivaRate: z.ZodOptional<z.ZodPreprocess<z.ZodEnum<{
|
|
69
|
+
0: "0";
|
|
70
|
+
5: "5";
|
|
71
|
+
2.5: "2.5";
|
|
72
|
+
10.5: "10.5";
|
|
73
|
+
21: "21";
|
|
74
|
+
27: "27";
|
|
75
|
+
}>>>;
|
|
76
|
+
dueDay: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
ivaCondition: z.ZodEnum<{
|
|
78
|
+
"consumidor-final": "consumidor-final";
|
|
79
|
+
"cliente-del-exterior": "cliente-del-exterior";
|
|
80
|
+
"iva-liberado": "iva-liberado";
|
|
81
|
+
"iva-no-alcanzado": "iva-no-alcanzado";
|
|
82
|
+
"monotributista-social": "monotributista-social";
|
|
83
|
+
"monotributo-trabajador-independiente-promovido": "monotributo-trabajador-independiente-promovido";
|
|
84
|
+
"proveedor-del-exterior": "proveedor-del-exterior";
|
|
85
|
+
"responsable-inscripto": "responsable-inscripto";
|
|
86
|
+
"responsable-monotributo": "responsable-monotributo";
|
|
87
|
+
"sujeto-exento": "sujeto-exento";
|
|
88
|
+
"sujeto-no-categorizado": "sujeto-no-categorizado";
|
|
89
|
+
}>;
|
|
90
|
+
paymentDueDate: z.ZodOptional<z.ZodString>;
|
|
91
|
+
pointOfSale: z.ZodOptional<z.ZodNumber>;
|
|
92
|
+
sameCurrency: z.ZodDefault<z.ZodBoolean>;
|
|
93
|
+
serviceEndDate: z.ZodOptional<z.ZodString>;
|
|
94
|
+
serviceStartDate: z.ZodOptional<z.ZodString>;
|
|
95
|
+
shortcut: z.ZodPipe<z.ZodString, z.ZodTransform<"fa" | "fb" | "fc" | "nca" | "ncb" | "ncc" | "nda" | "ndb" | "ndc" | "fcea" | "fceb" | "fcec" | "ncea" | "nceb" | "ncec" | "ndea" | "ndeb" | "ndec", string>>;
|
|
96
|
+
totalAmount: z.ZodNumber;
|
|
97
|
+
untaxedAmount: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
transferMode: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
99
|
+
adc: "adc";
|
|
100
|
+
sca: "sca";
|
|
101
|
+
}>>>;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
export type BillingConcept = z.infer<typeof billingConceptSchema>;
|
|
104
|
+
export type BillingDocumentType = z.infer<typeof billingDocumentTypeSchema>;
|
|
105
|
+
export type BillingIvaCondition = z.infer<typeof billingIvaConditionSchema>;
|
|
106
|
+
export type BillingIvaRate = z.infer<typeof billingIvaRateSchema>;
|
|
107
|
+
export type BillingCommandInput = z.infer<typeof billingCommandSchema>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const BILLING_CONCEPT_ALIASES = {
|
|
3
|
+
p: 'productos',
|
|
4
|
+
producto: 'productos',
|
|
5
|
+
productos: 'productos',
|
|
6
|
+
ps: 'productos-servicios',
|
|
7
|
+
'productos-y-servicios': 'productos-servicios',
|
|
8
|
+
'productos-servicios': 'productos-servicios',
|
|
9
|
+
s: 'servicios',
|
|
10
|
+
servicio: 'servicios',
|
|
11
|
+
servicios: 'servicios',
|
|
12
|
+
};
|
|
13
|
+
export const billingConceptSchema = z.preprocess((value) => {
|
|
14
|
+
if (typeof value !== 'string') {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
const normalizedValue = value.trim().toLowerCase();
|
|
18
|
+
return BILLING_CONCEPT_ALIASES[normalizedValue] ?? value;
|
|
19
|
+
}, z.enum(['productos', 'productos-servicios', 'servicios']));
|
|
20
|
+
export const billingDocumentTypeSchema = z.enum(['consumidor-final', 'cuil', 'cuit', 'dni']);
|
|
21
|
+
export const billingIvaConditionSchema = z.enum([
|
|
22
|
+
'cliente-del-exterior',
|
|
23
|
+
'consumidor-final',
|
|
24
|
+
'iva-liberado',
|
|
25
|
+
'iva-no-alcanzado',
|
|
26
|
+
'monotributista-social',
|
|
27
|
+
'monotributo-trabajador-independiente-promovido',
|
|
28
|
+
'proveedor-del-exterior',
|
|
29
|
+
'responsable-inscripto',
|
|
30
|
+
'responsable-monotributo',
|
|
31
|
+
'sujeto-exento',
|
|
32
|
+
'sujeto-no-categorizado',
|
|
33
|
+
]);
|
|
34
|
+
const IVA_RATE_VALUES = ['0', '2.5', '5', '10.5', '21', '27'];
|
|
35
|
+
// Acepta "10,5", "10.5" o "10.5%".
|
|
36
|
+
export const billingIvaRateSchema = z.preprocess((value) => typeof value === 'number'
|
|
37
|
+
? String(value)
|
|
38
|
+
: typeof value === 'string'
|
|
39
|
+
? value.trim().replace(',', '.').replace(/%$/, '')
|
|
40
|
+
: value, z.enum(IVA_RATE_VALUES, { message: 'La alicuota debe ser 0, 2.5, 5, 10.5, 21 o 27.' }));
|
|
41
|
+
const billingAssociatedVoucherSchema = z
|
|
42
|
+
.object({
|
|
43
|
+
cuit: z
|
|
44
|
+
.string()
|
|
45
|
+
.trim()
|
|
46
|
+
.regex(/^\d{11}$/)
|
|
47
|
+
.optional(),
|
|
48
|
+
fecha: z.string().trim().optional(),
|
|
49
|
+
numero: z.number().int().positive().optional(),
|
|
50
|
+
puntoVenta: z.number().int().positive().optional(),
|
|
51
|
+
shortcut: z.string().trim().min(1).optional(),
|
|
52
|
+
tipo: z.number().int().positive().optional(),
|
|
53
|
+
})
|
|
54
|
+
.optional();
|
|
55
|
+
const billingAssociatedPeriodSchema = z
|
|
56
|
+
.object({
|
|
57
|
+
desde: z.string().trim().optional(),
|
|
58
|
+
hasta: z.string().trim().optional(),
|
|
59
|
+
})
|
|
60
|
+
.optional();
|
|
61
|
+
export const billingCommandSchema = z.object({
|
|
62
|
+
associatedPeriod: billingAssociatedPeriodSchema,
|
|
63
|
+
associatedVoucher: billingAssociatedVoucherSchema,
|
|
64
|
+
billingDate: z.string().trim().optional(),
|
|
65
|
+
cancellation: z.boolean().default(false),
|
|
66
|
+
cbu: z
|
|
67
|
+
.string()
|
|
68
|
+
.trim()
|
|
69
|
+
.regex(/^\d{22}$/, 'El CBU debe tener 22 digitos')
|
|
70
|
+
.optional(),
|
|
71
|
+
cbuAlias: z
|
|
72
|
+
.string()
|
|
73
|
+
.trim()
|
|
74
|
+
.regex(/^[A-Za-z0-9.-]{6,20}$/, 'El alias debe tener entre 6 y 20 caracteres (letras, numeros, punto o guion)')
|
|
75
|
+
.optional(),
|
|
76
|
+
concept: billingConceptSchema,
|
|
77
|
+
currencyCode: z.string().trim().length(3).default('ARS'),
|
|
78
|
+
documentNumber: z.number().int().nonnegative().optional(),
|
|
79
|
+
documentType: billingDocumentTypeSchema.default('consumidor-final'),
|
|
80
|
+
dryRun: z.boolean().default(false),
|
|
81
|
+
emit: z.boolean().default(false),
|
|
82
|
+
exchangeRate: z.number().positive().optional(),
|
|
83
|
+
exemptAmount: z.number().positive().optional(),
|
|
84
|
+
ivaRate: billingIvaRateSchema.optional(),
|
|
85
|
+
dueDay: z.number().int().min(1).max(31).optional(),
|
|
86
|
+
ivaCondition: billingIvaConditionSchema,
|
|
87
|
+
paymentDueDate: z.string().trim().optional(),
|
|
88
|
+
pointOfSale: z.number().int().positive().optional(),
|
|
89
|
+
sameCurrency: z.boolean().default(false),
|
|
90
|
+
serviceEndDate: z.string().trim().optional(),
|
|
91
|
+
serviceStartDate: z.string().trim().optional(),
|
|
92
|
+
shortcut: z
|
|
93
|
+
.string()
|
|
94
|
+
.trim()
|
|
95
|
+
.min(1)
|
|
96
|
+
.transform((value) => value),
|
|
97
|
+
totalAmount: z.number().positive(),
|
|
98
|
+
untaxedAmount: z.number().positive().optional(),
|
|
99
|
+
transferMode: z
|
|
100
|
+
.string()
|
|
101
|
+
.trim()
|
|
102
|
+
.toLowerCase()
|
|
103
|
+
.pipe(z.enum(['adc', 'sca']))
|
|
104
|
+
.optional(),
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=billing.schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.schemas.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,uBAAuB,GAAG;IAC9B,CAAC,EAAE,WAAW;IACd,QAAQ,EAAE,WAAW;IACrB,SAAS,EAAE,WAAW;IACtB,EAAE,EAAE,qBAAqB;IACzB,uBAAuB,EAAE,qBAAqB;IAC9C,qBAAqB,EAAE,qBA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ACvC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAC5C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACnD,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACxC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAC5C,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAC9C,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,CAAC;SACN,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAwB,CAAC;IACjD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC/C,YAAY,EAAE,CAAC;SACZ,MAAM,EAAE;SACR,IAAI,EAAE;SACN,WAAW,EAAE;SACb,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;SAC5B,QAAQ,EAAE;CACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BillingExecutionResult } from './billing.types.internal';
|
|
2
|
+
interface BillingSerializeOptions {
|
|
3
|
+
readonly raw?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function serializeBillingResult(result: BillingExecutionResult, options?: BillingSerializeOptions): Record<string, unknown>;
|
|
6
|
+
export declare function serializeBillingBatch(results: BillingExecutionResult[], options?: BillingSerializeOptions): Array<Record<string, unknown>>;
|
|
7
|
+
export declare function formatRawBillingResponse(result: BillingExecutionResult): Record<string, string> | NonNullable<BillingExecutionResult['response']['raw']>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
function formatRawResponse(result) {
|
|
2
|
+
if (result.response.raw) {
|
|
3
|
+
return result.response.raw;
|
|
4
|
+
}
|
|
5
|
+
return {
|
|
6
|
+
mensaje: 'Sin emision real. Use --emitir para obtener una respuesta de ARCA.',
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function formatVoucherSummary(result) {
|
|
10
|
+
return {
|
|
11
|
+
atajo: result.voucherKind.shortcut,
|
|
12
|
+
avisos: result.warnings ?? [],
|
|
13
|
+
cae: result.response.cae,
|
|
14
|
+
caeVencimiento: result.response.caeVencimiento,
|
|
15
|
+
comprobante: result.voucherKind.displayName,
|
|
16
|
+
errores: result.response.errors,
|
|
17
|
+
estado: result.response.status,
|
|
18
|
+
eventos: result.response.events,
|
|
19
|
+
observaciones: result.response.observaciones,
|
|
20
|
+
observacion: result.response.observacion,
|
|
21
|
+
solicitud: result.payload,
|
|
22
|
+
previsualizacion: result.dryRun,
|
|
23
|
+
resultado: result.response.resultado,
|
|
24
|
+
sugerencias: result.response.suggestions,
|
|
25
|
+
tipoArca: result.voucherKind.arcaType,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function serializeBillingResult(result, options = {}) {
|
|
29
|
+
if (options.raw) {
|
|
30
|
+
return {
|
|
31
|
+
atajo: result.voucherKind.shortcut,
|
|
32
|
+
avisos: result.warnings ?? [],
|
|
33
|
+
comprobante: result.voucherKind.displayName,
|
|
34
|
+
solicitud: result.payload,
|
|
35
|
+
previsualizacion: result.dryRun,
|
|
36
|
+
respuesta: formatRawResponse(result),
|
|
37
|
+
sugerencias: result.response.suggestions,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return formatVoucherSummary(result);
|
|
41
|
+
}
|
|
42
|
+
export function serializeBillingBatch(results, options = {}) {
|
|
43
|
+
return results.map((result, index) => ({
|
|
44
|
+
atajo: result.voucherKind.shortcut,
|
|
45
|
+
indice: index + 1,
|
|
46
|
+
comprobante: result.voucherKind.displayName,
|
|
47
|
+
...serializeBillingResult(result, options),
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
export function formatRawBillingResponse(result) {
|
|
51
|
+
return formatRawResponse(result);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=billing.serialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.serialize.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.serialize.ts"],"names":[],"mappings":"AAMA,SAAS,iBAAiB,CACxB,MAA8B;IAE9B,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,OAAO,EAAE,oEAAoE;KAC9E,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,MAA8B;IAC1D,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ;QAClC,MAAM,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE;QAC7B,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG;QACxB,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,cAAc;QAC9C,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,WAAW;QAC3C,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;QAC/B,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;QAC9B,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;QAC/B,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,aAAa;QAC5C,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW;QACxC,SAAS,EAAE,MAAM,CAAC,OAAO;QACzB,gBAAgB,EAAE,MAAM,CAAC,MAAM;QAC/B,SAAS,EAAE,MAAM,CAAC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../../services/arca/arca-context.resolver';
|
|
3
|
+
import { type FceObligationGateway } from '../fce/fce-obligation';
|
|
4
|
+
import type { BillingCommandInput } from './billing.schemas';
|
|
5
|
+
import type { VoucherKindDefinition } from './billing.types';
|
|
6
|
+
import type { BillingExecutionResult, BillingGateway } from './billing.types.internal';
|
|
7
|
+
export interface BillingExecutionOptions {
|
|
8
|
+
readonly gateway: BillingGateway;
|
|
9
|
+
readonly input: BillingCommandInput;
|
|
10
|
+
readonly runtime: ResolvedArcaRuntime;
|
|
11
|
+
readonly warnings?: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export declare class BillingService {
|
|
14
|
+
/**
|
|
15
|
+
* Completa la cotizacion oficial cuando el comprobante se cancela en la misma moneda extranjera.
|
|
16
|
+
* Se resuelve antes de la vista previa para que el preview muestre el valor que se va a enviar.
|
|
17
|
+
*/
|
|
18
|
+
resolveExchangeRate(input: BillingCommandInput, gateway: BillingGateway): Promise<BillingCommandInput>;
|
|
19
|
+
execute(options: BillingExecutionOptions): Promise<BillingExecutionResult>;
|
|
20
|
+
/**
|
|
21
|
+
* Avisa si el comprobante elegido no coincide con el regimen FCE del receptor.
|
|
22
|
+
* Es informativo: si ARCA no responde, devuelve el motivo como aviso y no frena la emision.
|
|
23
|
+
*/
|
|
24
|
+
resolveFceWarnings(input: BillingCommandInput, gateway: FceObligationGateway): Promise<string[]>;
|
|
25
|
+
buildVoucherPayload(input: BillingCommandInput, runtime: ResolvedArcaRuntime, voucherKind?: VoucherKindDefinition): INextVoucher;
|
|
26
|
+
private requireVoucherKind;
|
|
27
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { formatDateAsArcaDate, parseArgentineDateInputAsArcaDate } from '../../lib/dates/arca-date.js';
|
|
2
|
+
import { InputValidationError } from '../../lib/errors/app-error.js';
|
|
3
|
+
import { evaluateFceObligation, shouldCheckFceObligation } from '../fce/fce-obligation.js';
|
|
4
|
+
import { resolveTaxAmounts } from './billing.amounts.js';
|
|
5
|
+
import { resolveAssociatedPeriod } from './billing.associated-period.js';
|
|
6
|
+
import { resolveAssociatedVouchers } from './billing.associated-vouchers.js';
|
|
7
|
+
import { isForeignCurrency, needsOfficialExchangeRate, resolveBillingCurrencyFields } from './billing.currency.js';
|
|
8
|
+
import { resolveBillingDateRange } from './billing.date-range.js';
|
|
9
|
+
import { resolveElectronicCreditOptionals } from './billing.fce.js';
|
|
10
|
+
import { validateConsumerIdentification, validateIvaConditionForVoucher } from './billing.iva-receptor.js';
|
|
11
|
+
import { resolveBillingConceptCode, resolveBillingCurrencyCode, resolveBillingDocumentTypeCode, resolveBillingIvaConditionCode, } from './billing.mappers.js';
|
|
12
|
+
import { validateDocumentIdentity } from './billing.validation.js';
|
|
13
|
+
import { createDryRunResponse, mapBillingResponse } from './billing-response.js';
|
|
14
|
+
import { getVoucherKindByShortcut } from './voucher-kind-map.js';
|
|
15
|
+
export class BillingService {
|
|
16
|
+
/**
|
|
17
|
+
* Completa la cotizacion oficial cuando el comprobante se cancela en la misma moneda extranjera.
|
|
18
|
+
* Se resuelve antes de la vista previa para que el preview muestre el valor que se va a enviar.
|
|
19
|
+
*/
|
|
20
|
+
async resolveExchangeRate(input, gateway) {
|
|
21
|
+
if (!needsOfficialExchangeRate(input)) {
|
|
22
|
+
return input;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
...input,
|
|
26
|
+
exchangeRate: await gateway.getQuotation(resolveBillingCurrencyCode(input.currencyCode)),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async execute(options) {
|
|
30
|
+
const voucherKind = this.requireVoucherKind(options.input.shortcut);
|
|
31
|
+
const payload = this.buildVoucherPayload(options.input, options.runtime, voucherKind);
|
|
32
|
+
if (options.input.dryRun || !options.input.emit) {
|
|
33
|
+
return {
|
|
34
|
+
dryRun: true,
|
|
35
|
+
environment: options.runtime.environment,
|
|
36
|
+
payload,
|
|
37
|
+
response: createDryRunResponse(),
|
|
38
|
+
voucherKind,
|
|
39
|
+
warnings: options.warnings ?? [],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const response = await options.gateway.createNextVoucher(payload);
|
|
43
|
+
return {
|
|
44
|
+
dryRun: false,
|
|
45
|
+
environment: options.runtime.environment,
|
|
46
|
+
payload,
|
|
47
|
+
response: mapBillingResponse(response),
|
|
48
|
+
voucherKind,
|
|
49
|
+
warnings: options.warnings ?? [],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Avisa si el comprobante elegido no coincide con el regimen FCE del receptor.
|
|
54
|
+
* Es informativo: si ARCA no responde, devuelve el motivo como aviso y no frena la emision.
|
|
55
|
+
*/
|
|
56
|
+
async resolveFceWarnings(input, gateway) {
|
|
57
|
+
const voucherKind = this.requireVoucherKind(input.shortcut);
|
|
58
|
+
if (!shouldCheckFceObligation(input, voucherKind)) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
const issueDate = input.billingDate
|
|
62
|
+
? parseArgentineDateInputAsArcaDate(input.billingDate)
|
|
63
|
+
: formatDateAsArcaDate(new Date());
|
|
64
|
+
const amountInPesos = input.totalAmount * (isForeignCurrency(input) ? (input.exchangeRate ?? 1) : 1);
|
|
65
|
+
try {
|
|
66
|
+
const obligation = await gateway.getObligation(input.documentNumber, issueDate);
|
|
67
|
+
return evaluateFceObligation(obligation, voucherKind, amountInPesos);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
const reason = error instanceof Error ? error.message : 'error desconocido';
|
|
71
|
+
return [`No se pudo verificar el regimen FCE del receptor: ${reason}`];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
buildVoucherPayload(input, runtime, voucherKind = this.requireVoucherKind(input.shortcut)) {
|
|
75
|
+
const pointOfSale = input.pointOfSale ?? runtime.pointOfSale;
|
|
76
|
+
if (!pointOfSale) {
|
|
77
|
+
throw new InputValidationError('Falta el punto de venta. Use --punto-venta o --pv, o configurelo con "arcli config establecer puntoVenta <valor>".');
|
|
78
|
+
}
|
|
79
|
+
const dateRange = resolveBillingDateRange(input, voucherKind);
|
|
80
|
+
const concept = resolveBillingConceptCode(input.concept);
|
|
81
|
+
const documentType = resolveBillingDocumentTypeCode(input.documentType);
|
|
82
|
+
const ivaCondition = resolveBillingIvaConditionCode(input.ivaCondition);
|
|
83
|
+
const associatedVouchers = resolveAssociatedVouchers({
|
|
84
|
+
billingDate: dateRange.billingDate,
|
|
85
|
+
emitterCuit: runtime.context.cuit,
|
|
86
|
+
input,
|
|
87
|
+
requireVoucherKind: (shortcut) => this.requireVoucherKind(shortcut),
|
|
88
|
+
voucherKind,
|
|
89
|
+
});
|
|
90
|
+
const currencyFields = resolveBillingCurrencyFields(input, dateRange.billingDate, formatDateAsArcaDate(new Date()));
|
|
91
|
+
const taxAmounts = resolveTaxAmounts(input, voucherKind);
|
|
92
|
+
validateDocumentIdentity(input, voucherKind);
|
|
93
|
+
validateIvaConditionForVoucher(input.ivaCondition, voucherKind);
|
|
94
|
+
validateConsumerIdentification(input, currencyFields.MonCotiz, voucherKind);
|
|
95
|
+
const payload = {
|
|
96
|
+
CantReg: 1,
|
|
97
|
+
CbteFch: dateRange.billingDate,
|
|
98
|
+
CbteTipo: voucherKind.arcaType,
|
|
99
|
+
Concepto: concept,
|
|
100
|
+
CondicionIVAReceptorId: ivaCondition,
|
|
101
|
+
DocTipo: documentType,
|
|
102
|
+
FchServDesde: dateRange.serviceStartDate,
|
|
103
|
+
FchServHasta: dateRange.serviceEndDate,
|
|
104
|
+
FchVtoPago: dateRange.paymentDueDate,
|
|
105
|
+
ImpIVA: taxAmounts.ivaAmount,
|
|
106
|
+
ImpNeto: taxAmounts.netAmount,
|
|
107
|
+
ImpOpEx: taxAmounts.exemptAmount,
|
|
108
|
+
ImpTotConc: taxAmounts.untaxedAmount,
|
|
109
|
+
ImpTotal: input.totalAmount,
|
|
110
|
+
ImpTrib: 0,
|
|
111
|
+
MonCotiz: currencyFields.MonCotiz,
|
|
112
|
+
MonId: currencyFields.MonId,
|
|
113
|
+
PtoVta: pointOfSale,
|
|
114
|
+
};
|
|
115
|
+
if (currencyFields.CanMisMonExt) {
|
|
116
|
+
payload.CanMisMonExt = currencyFields.CanMisMonExt;
|
|
117
|
+
}
|
|
118
|
+
if (taxAmounts.iva) {
|
|
119
|
+
payload.Iva = taxAmounts.iva;
|
|
120
|
+
}
|
|
121
|
+
if (typeof input.documentNumber === 'number') {
|
|
122
|
+
payload.DocNro = input.documentNumber;
|
|
123
|
+
}
|
|
124
|
+
if (associatedVouchers) {
|
|
125
|
+
payload.CbtesAsoc = associatedVouchers;
|
|
126
|
+
}
|
|
127
|
+
const associatedPeriod = resolveAssociatedPeriod(input, voucherKind, dateRange.billingDate);
|
|
128
|
+
if (associatedPeriod) {
|
|
129
|
+
payload.PeriodoAsoc = associatedPeriod;
|
|
130
|
+
}
|
|
131
|
+
const optionals = resolveElectronicCreditOptionals(input, voucherKind);
|
|
132
|
+
if (optionals) {
|
|
133
|
+
payload.Opcionales = optionals;
|
|
134
|
+
}
|
|
135
|
+
// El SDK tipa DocNro como obligatorio, pero el CLI permite omitirlo cuando el usuario no lo informa.
|
|
136
|
+
return payload;
|
|
137
|
+
}
|
|
138
|
+
requireVoucherKind(shortcut) {
|
|
139
|
+
const definition = getVoucherKindByShortcut(shortcut);
|
|
140
|
+
if (!definition) {
|
|
141
|
+
throw new InputValidationError(`El atajo "${shortcut}" no corresponde a un comprobante soportado.`);
|
|
142
|
+
}
|
|
143
|
+
return definition;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=billing.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.service.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,O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AAE,CAAC;YACnB,OAAO,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;QAC/B,CAAC;QAED,IAAI,OAAO,KAAK,CAAC,cAAc,KAAK,QAAQ,EAAE,CAAC;YAC7C,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC;QACxC,CAAC;QAED,IAAI,kBAAkB,EAAE,CAAC;YACvB,OAAO,CAAC,SAAS,GAAG,kBAAkB,CAAC;QACzC,CAAC;QAED,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;QAE5F,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,CAAC,WAAW,GAAG,gBAAgB,CAAC;QACzC,CAAC;QAED,MAAM,SAAS,GAAG,gCAAgC,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAEvE,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;QACjC,CAAC;QAED,qGAAqG;QACrG,OAAO,OAAuB,CAAC;IACjC,CAAC;IAEO,kBAAkB,CAAC,QAAgB;QACzC,MAAM,UAAU,GAAG,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAEtD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,oBAAoB,CAAC,aAAa,QAAQ,8CAA8C,CAAC,CAAC;QACtG,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BillingExecutionResult } from './billing.types.internal';
|
|
2
|
+
interface BillingTextOptions {
|
|
3
|
+
readonly environment?: 'produccion' | 'testing';
|
|
4
|
+
readonly previewShown?: boolean;
|
|
5
|
+
readonly raw?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function formatBillingResultAsText(result: BillingExecutionResult, options?: BillingTextOptions): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { contentPanel, renderObject } from '../../ui/index.js';
|
|
2
|
+
import { formatEnvironmentBanner, formatPayloadPreview, formatResultPanel, formatStatusBadge } from './billing.display.js';
|
|
3
|
+
import { formatRawBillingResponse } from './billing.serialize.js';
|
|
4
|
+
function formatObservationList(observaciones) {
|
|
5
|
+
return observaciones.map((item, index) => `${index + 1}. ${item}`).join('\n');
|
|
6
|
+
}
|
|
7
|
+
function formatWarningsPanel(result) {
|
|
8
|
+
const warnings = result.warnings ?? [];
|
|
9
|
+
if (warnings.length === 0) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return [contentPanel('Avisos', warnings.map((item) => `• ${item}`).join('\n'), 'wide', 'warning')];
|
|
13
|
+
}
|
|
14
|
+
export function formatBillingResultAsText(result, options = {}) {
|
|
15
|
+
const environmentLines = [
|
|
16
|
+
...(options.previewShown ? [] : formatEnvironmentBanner(options.environment ?? result.environment)),
|
|
17
|
+
...(options.previewShown ? [] : formatWarningsPanel(result)),
|
|
18
|
+
];
|
|
19
|
+
if (options.raw) {
|
|
20
|
+
if (result.dryRun) {
|
|
21
|
+
return [...environmentLines, formatPayloadPreview(result)].join('\n\n');
|
|
22
|
+
}
|
|
23
|
+
const lines = [contentPanel('Respuesta bruta', renderObject(formatRawBillingResponse(result)), 'wide', 'info')];
|
|
24
|
+
if (!options.previewShown) {
|
|
25
|
+
lines.unshift(formatPayloadPreview(result));
|
|
26
|
+
}
|
|
27
|
+
return [...environmentLines, ...lines].join('\n\n');
|
|
28
|
+
}
|
|
29
|
+
if (result.dryRun) {
|
|
30
|
+
return [...environmentLines, formatPayloadPreview(result)].join('\n\n');
|
|
31
|
+
}
|
|
32
|
+
const lines = [...environmentLines];
|
|
33
|
+
if (!options.previewShown) {
|
|
34
|
+
lines.push(formatPayloadPreview(result));
|
|
35
|
+
}
|
|
36
|
+
lines.push(formatResultPanel(result, formatStatusBadge(result)));
|
|
37
|
+
if (result.response.observaciones.length > 0) {
|
|
38
|
+
lines.push(contentPanel('Observaciones', formatObservationList(result.response.observaciones), 'wide', 'warning'));
|
|
39
|
+
}
|
|
40
|
+
if (result.response.events.length > 0) {
|
|
41
|
+
lines.push(contentPanel('Eventos', renderObject(result.response.events), 'wide', 'info'));
|
|
42
|
+
}
|
|
43
|
+
if (result.response.errors.length > 0) {
|
|
44
|
+
lines.push(contentPanel('Errores', renderObject(result.response.errors), 'wide', 'danger'));
|
|
45
|
+
}
|
|
46
|
+
const suggestions = result.response.suggestions ?? [];
|
|
47
|
+
if (suggestions.length > 0) {
|
|
48
|
+
lines.push(contentPanel('Sugerencias', suggestions.map((item) => `• ${item}`).join('\n'), 'wide', 'info'));
|
|
49
|
+
}
|
|
50
|
+
return lines.join('\n\n');
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=billing.text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.text.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxH,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAS/D,SAAS,qBAAqB,CAAC,aAAgC;IAC7D,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,mBAAmB,CAAC,MAA8B;IACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;IAEvC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAA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