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 @@
|
|
|
1
|
+
{"version":3,"file":"billing.constants.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAC3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BillingCommandInput } from './billing.schemas';
|
|
2
|
+
export declare const ARCA_LOCAL_CURRENCY_CODE = "PES";
|
|
3
|
+
export interface BillingCurrencyFields {
|
|
4
|
+
readonly CanMisMonExt?: 'N' | 'S';
|
|
5
|
+
readonly MonCotiz: number;
|
|
6
|
+
readonly MonId: string;
|
|
7
|
+
}
|
|
8
|
+
type CurrencyInput = Pick<BillingCommandInput, 'currencyCode' | 'exchangeRate' | 'sameCurrency'>;
|
|
9
|
+
export declare function isForeignCurrency(input: {
|
|
10
|
+
readonly currencyCode?: string;
|
|
11
|
+
}): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Con CanMisMonExt = S, ARCA exige la cotizacion oficial exacta (error 10038),
|
|
14
|
+
* asi que el CLI la consulta en lugar de pedirsela al usuario.
|
|
15
|
+
*/
|
|
16
|
+
export declare function needsOfficialExchangeRate(input: CurrencyInput): boolean;
|
|
17
|
+
export declare function resolveBillingCurrencyFields(input: CurrencyInput, billingDate: string, today: string): BillingCurrencyFields;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { InputValidationError } from '../../lib/errors/app-error.js';
|
|
2
|
+
import { DEFAULT_EXCHANGE_RATE } from './billing.constants.js';
|
|
3
|
+
import { resolveBillingCurrencyCode } from './billing.mappers.js';
|
|
4
|
+
export const ARCA_LOCAL_CURRENCY_CODE = 'PES';
|
|
5
|
+
export function isForeignCurrency(input) {
|
|
6
|
+
return resolveBillingCurrencyCode(input.currencyCode) !== ARCA_LOCAL_CURRENCY_CODE;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Con CanMisMonExt = S, ARCA exige la cotizacion oficial exacta (error 10038),
|
|
10
|
+
* asi que el CLI la consulta en lugar de pedirsela al usuario.
|
|
11
|
+
*/
|
|
12
|
+
export function needsOfficialExchangeRate(input) {
|
|
13
|
+
return input.sameCurrency && isForeignCurrency(input) && typeof input.exchangeRate !== 'number';
|
|
14
|
+
}
|
|
15
|
+
export function resolveBillingCurrencyFields(input, billingDate, today) {
|
|
16
|
+
const currencyCode = resolveBillingCurrencyCode(input.currencyCode);
|
|
17
|
+
const inputCurrencyCode = input.currencyCode.trim().toUpperCase();
|
|
18
|
+
if (currencyCode === ARCA_LOCAL_CURRENCY_CODE) {
|
|
19
|
+
if (input.sameCurrency) {
|
|
20
|
+
throw new InputValidationError('--misma-moneda solo aplica a comprobantes en moneda extranjera.');
|
|
21
|
+
}
|
|
22
|
+
if (typeof input.exchangeRate === 'number' && input.exchangeRate !== DEFAULT_EXCHANGE_RATE) {
|
|
23
|
+
throw new InputValidationError('En pesos la cotizacion debe ser 1. Quite --cotizacion-moneda o use --cm 1.');
|
|
24
|
+
}
|
|
25
|
+
// ARCA rechaza CanMisMonExt cuando MonId = PES (error 10241).
|
|
26
|
+
return {
|
|
27
|
+
MonCotiz: DEFAULT_EXCHANGE_RATE,
|
|
28
|
+
MonId: currencyCode,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (input.sameCurrency) {
|
|
32
|
+
if (billingDate < today) {
|
|
33
|
+
throw new InputValidationError('Con --misma-moneda la fecha del comprobante no puede ser anterior a hoy: ARCA exige la cotizacion oficial de ese dia y solo se puede consultar la vigente.');
|
|
34
|
+
}
|
|
35
|
+
if (typeof input.exchangeRate !== 'number') {
|
|
36
|
+
throw new InputValidationError(`No se pudo obtener la cotizacion oficial de ${inputCurrencyCode} desde ARCA.`);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
CanMisMonExt: 'S',
|
|
40
|
+
MonCotiz: input.exchangeRate,
|
|
41
|
+
MonId: currencyCode,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (typeof input.exchangeRate !== 'number' || input.exchangeRate === DEFAULT_EXCHANGE_RATE) {
|
|
45
|
+
throw new InputValidationError(`Falta la cotizacion de ${inputCurrencyCode}. Use --cotizacion-moneda o --cm, o --misma-moneda si el pago se hace en ${inputCurrencyCode}.`);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
CanMisMonExt: 'N',
|
|
49
|
+
MonCotiz: input.exchangeRate,
|
|
50
|
+
MonId: currencyCode,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=billing.currency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.currency.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.currency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAG/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,+CAA+C,iBAAiB,cAAc,CAAC,CAAC;QACjH,CAAC;QAED,OAAO;YACL,YAAY,EAAE,GAAG;YACjB,QAAQ,EAAE,KAAK,CAAC,YAAY;YAC5B,KAAK,EAAE,YAAY;SACpB,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,KAAK,CAAC,YAAY,KAAK,QAAQ,IAAI,KAAK,CAAC,YAAY,KAAK,qBAAqB,EAAE,CAAC;QAC3F,MAAM,IAAI,oBAAoB,CAC5B,0BAA0B,iBAAiB,4EAA4E,iBAAiB,GAAG,CAC5I,CAAC;IACJ,CAAC;IAED,OAAO;QACL,YAAY,EAAE,GAAG;QACjB,QAAQ,EAAE,KAAK,CAAC,YAAY;QAC5B,KAAK,EAAE,YAAY;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BillingCommandInput } from './billing.schemas';
|
|
2
|
+
import type { VoucherKindDefinition } from './billing.types';
|
|
3
|
+
export interface BillingDateRange {
|
|
4
|
+
readonly billingDate: string;
|
|
5
|
+
readonly paymentDueDate?: string;
|
|
6
|
+
readonly serviceEndDate?: string;
|
|
7
|
+
readonly serviceStartDate?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveBillingDateRange(input: BillingCommandInput, voucherKind: VoucherKindDefinition, today?: string): BillingDateRange;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { formatDateAsArcaDate, maxArcaDate, parseArgentineDateInputAsArcaDate } from '../../lib/dates/arca-date.js';
|
|
2
|
+
import { isElectronicCreditInvoice } from './billing.fce.js';
|
|
3
|
+
import { ensureDateOrder, validateBillingDateWindow, validateConceptDateInputs, validatePaymentDueDate, } from './billing.validation.js';
|
|
4
|
+
function resolvePaymentDateFromDueDay(dueDay) {
|
|
5
|
+
const referenceDate = new Date();
|
|
6
|
+
const paymentDate = new Date(referenceDate);
|
|
7
|
+
if (dueDay < referenceDate.getDate()) {
|
|
8
|
+
paymentDate.setMonth(paymentDate.getMonth() + 1);
|
|
9
|
+
}
|
|
10
|
+
paymentDate.setDate(dueDay);
|
|
11
|
+
return paymentDate;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Que fechas lleva el comprobante:
|
|
15
|
+
* - servicios: FchServDesde, FchServHasta y FchVtoPago (10049)
|
|
16
|
+
* - factura FCE: FchVtoPago siempre, aunque sea de productos (10163)
|
|
17
|
+
* - NC/ND FCE: sin FchVtoPago salvo anulacion (10175)
|
|
18
|
+
*/
|
|
19
|
+
function shouldSendPaymentDueDate(input, voucherKind) {
|
|
20
|
+
if (voucherKind.isElectronicCredit) {
|
|
21
|
+
return isElectronicCreditInvoice(voucherKind);
|
|
22
|
+
}
|
|
23
|
+
return input.concept !== 'productos';
|
|
24
|
+
}
|
|
25
|
+
function resolveServiceDates(input, billingDate) {
|
|
26
|
+
const defaultServiceEndDate = input.billingDate || !input.dueDay ? billingDate : formatDateAsArcaDate(resolvePaymentDateFromDueDay(input.dueDay));
|
|
27
|
+
const serviceEndDate = input.serviceEndDate
|
|
28
|
+
? parseArgentineDateInputAsArcaDate(input.serviceEndDate)
|
|
29
|
+
: defaultServiceEndDate;
|
|
30
|
+
const serviceStartDate = input.serviceStartDate
|
|
31
|
+
? parseArgentineDateInputAsArcaDate(input.serviceStartDate)
|
|
32
|
+
: serviceEndDate;
|
|
33
|
+
ensureDateOrder(serviceStartDate, serviceEndDate);
|
|
34
|
+
return { serviceEndDate, serviceStartDate };
|
|
35
|
+
}
|
|
36
|
+
export function resolveBillingDateRange(input, voucherKind, today = formatDateAsArcaDate(new Date())) {
|
|
37
|
+
validateConceptDateInputs(input, voucherKind);
|
|
38
|
+
const billingDate = input.billingDate ? parseArgentineDateInputAsArcaDate(input.billingDate) : today;
|
|
39
|
+
validateBillingDateWindow(billingDate, today, input.concept, voucherKind);
|
|
40
|
+
const serviceDates = input.concept === 'productos' ? undefined : resolveServiceDates(input, billingDate);
|
|
41
|
+
if (!shouldSendPaymentDueDate(input, voucherKind)) {
|
|
42
|
+
return { billingDate, ...serviceDates };
|
|
43
|
+
}
|
|
44
|
+
// FCE: el vencimiento no puede ser anterior a la fecha del comprobante ni a hoy (10164).
|
|
45
|
+
const minimumPaymentDueDate = isElectronicCreditInvoice(voucherKind) ? maxArcaDate(billingDate, today) : billingDate;
|
|
46
|
+
const paymentDueDate = input.paymentDueDate
|
|
47
|
+
? parseArgentineDateInputAsArcaDate(input.paymentDueDate)
|
|
48
|
+
: maxArcaDate(serviceDates?.serviceEndDate ?? minimumPaymentDueDate, minimumPaymentDueDate);
|
|
49
|
+
validatePaymentDueDate(paymentDueDate, minimumPaymentDueDate);
|
|
50
|
+
return { billingDate, paymentDueDate, ...serviceDates };
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=billing.date-range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.date-range.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.date-range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAEjH,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAS9B,SAAS,4BAA4B,CAAC,MAAc;IAClD,MAAM,aAAa,GAAG,IAAI,IAAI,EAAE,CAAC;IACjC,MAAM,WAAW,GAAG,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC;IAE5C,IAAI,MAAM,GAAG,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC;QACrC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5B,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;GAKG;AACH,SAAS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O,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAEzG,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,CAAC;QAClD,OAAO,EAAE,WAAW,EAAE,GAAG,YAAY,EAAE,CAAC;IAC1C,CAAC;IAED,yFAAyF;IACzF,MAAM,qBAAqB,GAAG,yBAAyB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;IACrH,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc;QACzC,CAAC,CAAC,iCAAiC,CAAC,KAAK,CAAC,cAAc,CAAC;QACzD,CAAC,CAAC,WAAW,CAAC,YAAY,EAAE,cAAc,IAAI,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;IAE9F,sBAAsB,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC;IAE9D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,YAAY,EAAE,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BillingExecutionResult } from './billing.types.internal';
|
|
2
|
+
export declare function formatEnvironmentBanner(environment: BillingExecutionResult['environment'] | undefined): string[];
|
|
3
|
+
export declare function formatStatusBadge(result: BillingExecutionResult): {
|
|
4
|
+
readonly label: string;
|
|
5
|
+
readonly tone: 'danger' | 'success' | 'warning';
|
|
6
|
+
};
|
|
7
|
+
export declare function formatVoucherSummary(result: BillingExecutionResult): Record<string, unknown>;
|
|
8
|
+
export declare function formatPayloadTable(result: BillingExecutionResult): string;
|
|
9
|
+
export declare function formatPayloadPreview(result: BillingExecutionResult): string;
|
|
10
|
+
export declare function formatResultPanel(result: BillingExecutionResult, status: {
|
|
11
|
+
readonly label: string;
|
|
12
|
+
readonly tone: 'danger' | 'success' | 'warning';
|
|
13
|
+
}): string;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { keyValuePanel, noticePanel, renderKeyValueRows, renderTable, resolveKeyValueLabelWidth, statusPanel, toneText, } from '../../ui/index.js';
|
|
2
|
+
import { resolveIvaRateLabel } from './billing.amounts.js';
|
|
3
|
+
import { formatConceptLabel, formatCurrencyLabel, formatDateLabel, formatDecimalLabel, formatDocumentTypeLabel, formatIvaConditionLabel, formatMoneyLabel, formatNumericLabel, formatTaxIdLabel, } from './billing.labels.js';
|
|
4
|
+
import { getVoucherKindByArcaType } from './voucher-kind-map.js';
|
|
5
|
+
export function formatEnvironmentBanner(environment) {
|
|
6
|
+
if (environment !== 'testing') {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
return [noticePanel('Estas utilizando el entorno de TESTING', 'warning')];
|
|
10
|
+
}
|
|
11
|
+
export function formatStatusBadge(result) {
|
|
12
|
+
switch (result.response.status) {
|
|
13
|
+
case 'aprobado':
|
|
14
|
+
return { label: 'APROBADO', tone: 'success' };
|
|
15
|
+
case 'rechazado':
|
|
16
|
+
return { label: 'RECHAZADO', tone: 'danger' };
|
|
17
|
+
default:
|
|
18
|
+
return { label: 'OBSERVADO', tone: 'warning' };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function formatVoucherSummary(result) {
|
|
22
|
+
return {
|
|
23
|
+
cae: result.response.cae,
|
|
24
|
+
caeVencimiento: result.response.caeVencimiento,
|
|
25
|
+
comprobante: result.voucherKind.displayName,
|
|
26
|
+
errores: result.response.errors,
|
|
27
|
+
estado: result.response.status,
|
|
28
|
+
eventos: result.response.events,
|
|
29
|
+
observaciones: result.response.observaciones,
|
|
30
|
+
observacion: result.response.observacion,
|
|
31
|
+
solicitud: result.payload,
|
|
32
|
+
previsualizacion: result.dryRun,
|
|
33
|
+
resultado: result.response.resultado,
|
|
34
|
+
tipoArca: result.voucherKind.arcaType,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const FCE_OPTIONAL_LABELS = {
|
|
38
|
+
'22': 'Anulacion',
|
|
39
|
+
'27': 'Transferencia',
|
|
40
|
+
'2101': 'CBU',
|
|
41
|
+
'2102': 'Alias CBU',
|
|
42
|
+
};
|
|
43
|
+
function formatFriendlyPayloadRows(result) {
|
|
44
|
+
const payload = result.payload;
|
|
45
|
+
const rows = [
|
|
46
|
+
['Concepto', formatConceptLabel(payload.Concepto)],
|
|
47
|
+
['Punto de venta', formatNumericLabel(payload.PtoVta)],
|
|
48
|
+
['Fecha del comprobante', formatDateLabel(payload.CbteFch)],
|
|
49
|
+
['Tipo de documento', formatDocumentTypeLabel(payload.DocTipo)],
|
|
50
|
+
[
|
|
51
|
+
'Numero de documento',
|
|
52
|
+
typeof payload.DocNro === 'number'
|
|
53
|
+
? payload.DocNro === 0
|
|
54
|
+
? 'Sin especificar'
|
|
55
|
+
: payload.DocTipo === 80 || payload.DocTipo === 86
|
|
56
|
+
? formatTaxIdLabel(payload.DocNro)
|
|
57
|
+
: formatNumericLabel(payload.DocNro)
|
|
58
|
+
: 'No informado',
|
|
59
|
+
],
|
|
60
|
+
['IVA receptor', formatIvaConditionLabel(payload.CondicionIVAReceptorId)],
|
|
61
|
+
['Moneda', formatCurrencyLabel(payload.MonId)],
|
|
62
|
+
['Cotizacion', formatDecimalLabel(payload.MonCotiz)],
|
|
63
|
+
['Importe neto', formatMoneyLabel(payload.ImpNeto)],
|
|
64
|
+
['Importe IVA', formatMoneyLabel(payload.ImpIVA)],
|
|
65
|
+
...(payload.Iva?.[0]
|
|
66
|
+
? [['Alicuota IVA', resolveIvaRateLabel(payload.Iva[0].Id) ?? String(payload.Iva[0].Id)]]
|
|
67
|
+
: []),
|
|
68
|
+
['Importe tributos', formatMoneyLabel(payload.ImpTrib)],
|
|
69
|
+
['Importe exento', formatMoneyLabel(payload.ImpOpEx)],
|
|
70
|
+
['Importe no gravado', formatMoneyLabel(payload.ImpTotConc)],
|
|
71
|
+
['Importe total', formatMoneyLabel(payload.ImpTotal)],
|
|
72
|
+
];
|
|
73
|
+
if (payload.FchServDesde) {
|
|
74
|
+
rows.push(['Servicio desde', formatDateLabel(payload.FchServDesde)]);
|
|
75
|
+
}
|
|
76
|
+
if (payload.FchServHasta) {
|
|
77
|
+
rows.push(['Servicio hasta', formatDateLabel(payload.FchServHasta)]);
|
|
78
|
+
}
|
|
79
|
+
if (payload.FchVtoPago) {
|
|
80
|
+
rows.push(['Vencimiento de pago', formatDateLabel(payload.FchVtoPago)]);
|
|
81
|
+
}
|
|
82
|
+
const associatedVoucher = payload.CbtesAsoc?.[0];
|
|
83
|
+
if (associatedVoucher) {
|
|
84
|
+
const associatedKind = getVoucherKindByArcaType(associatedVoucher.Tipo);
|
|
85
|
+
rows.push(['Comprobante asociado', associatedKind ? associatedKind.displayName : String(associatedVoucher.Tipo)]);
|
|
86
|
+
rows.push(['Punto de venta asociado', formatNumericLabel(associatedVoucher.PtoVta)]);
|
|
87
|
+
rows.push(['Numero asociado', formatNumericLabel(associatedVoucher.Nro)]);
|
|
88
|
+
rows.push(['CUIT asociado', formatTaxIdLabel(associatedVoucher.Cuit)]);
|
|
89
|
+
if (associatedVoucher.CbteFch) {
|
|
90
|
+
rows.push(['Fecha asociado', formatDateLabel(associatedVoucher.CbteFch)]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (payload.PeriodoAsoc) {
|
|
94
|
+
rows.push([
|
|
95
|
+
'Periodo asociado',
|
|
96
|
+
`${formatDateLabel(payload.PeriodoAsoc.FchDesde)} al ${formatDateLabel(payload.PeriodoAsoc.FchHasta)}`,
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
99
|
+
for (const optional of payload.Opcionales ?? []) {
|
|
100
|
+
const label = FCE_OPTIONAL_LABELS[optional.Id];
|
|
101
|
+
if (label) {
|
|
102
|
+
rows.push([label, optional.Id === '22' ? (optional.Valor === 'S' ? 'Si' : 'No') : optional.Valor]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return rows;
|
|
106
|
+
}
|
|
107
|
+
export function formatPayloadTable(result) {
|
|
108
|
+
const rows = formatFriendlyPayloadRows(result);
|
|
109
|
+
return renderTable(rows, { labelWidth: resolveKeyValueLabelWidth('compact', rows) }).trimEnd();
|
|
110
|
+
}
|
|
111
|
+
export function formatPayloadPreview(result) {
|
|
112
|
+
const payloadTable = formatPayloadTable(result);
|
|
113
|
+
const footer = result.dryRun ? toneText('SIN EMITIR', 'warning') : undefined;
|
|
114
|
+
return keyValuePanel(result.voucherKind.displayName, [payloadTable], footer, 'compact');
|
|
115
|
+
}
|
|
116
|
+
export function formatResultPanel(result, status) {
|
|
117
|
+
const summaryRows = [
|
|
118
|
+
['CAE', result.response.cae ?? 'N/D'],
|
|
119
|
+
['Vencimiento CAE', formatDateLabel(result.response.caeVencimiento ?? undefined)],
|
|
120
|
+
['Punto de venta', result.payload.PtoVta],
|
|
121
|
+
['Importe total', formatMoneyLabel(result.payload.ImpTotal)],
|
|
122
|
+
];
|
|
123
|
+
const countRows = [
|
|
124
|
+
['Observaciones', result.response.observaciones.length],
|
|
125
|
+
['Eventos', result.response.events.length],
|
|
126
|
+
['Errores', result.response.errors.length],
|
|
127
|
+
];
|
|
128
|
+
const labelWidth = resolveKeyValueLabelWidth('compact', [...summaryRows, ...countRows]);
|
|
129
|
+
const rows = [
|
|
130
|
+
...renderKeyValueRows(summaryRows, { labelWidth }),
|
|
131
|
+
'',
|
|
132
|
+
...renderKeyValueRows(countRows, { labelWidth }),
|
|
133
|
+
];
|
|
134
|
+
const footer = toneText(status.label, status.tone);
|
|
135
|
+
return statusPanel(result.voucherKind.displayName, rows, footer, 'compact', status.tone);
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=billing.display.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.display.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.display.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,WAAW,E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C;QACrC,CAAC,iBAAiB,EAAE,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,IAAI,SAAS,CAAC,CAAC;QACjF,CAAC,gBAAgB,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QACzC,CAAC,eAAe,EAAE,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;KAC7D,CAAC;IACF,MAAM,SAAS,GAA8C;QAC3D,CAAC,eAAe,EAAE,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;QACvD,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1C,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;KAC3C,CAAC;IACF,MAAM,UAAU,GAAG,yBAAyB,CAAC,SAAS,EAAE,CAAC,GAAG,WAAW,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;IACxF,MAAM,IAAI,GAAG;QACX,GAAG,kBAAkB,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC;QAClD,EAAE;QACF,GAAG,kBAAkB,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,CAAC;KACjD,CAAC;IACF,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAEnD,OAAO,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;AAC3F,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IOpcional } from '@arcasdk/core/lib/domain/types/voucher.types';
|
|
2
|
+
import type { BillingCommandInput } from './billing.schemas';
|
|
3
|
+
import type { VoucherKindDefinition } from './billing.types';
|
|
4
|
+
/** Codigos de "Adicionales por R.G." que usa FCE (FEParamGetTiposOpcional). */
|
|
5
|
+
export declare const FCE_OPTIONAL_IDS: {
|
|
6
|
+
readonly cancellation: "22";
|
|
7
|
+
readonly cbu: "2101";
|
|
8
|
+
readonly cbuAlias: "2102";
|
|
9
|
+
readonly transferMode: "27";
|
|
10
|
+
};
|
|
11
|
+
export declare const DEFAULT_FCE_TRANSFER_MODE = "sca";
|
|
12
|
+
type FceInput = Pick<BillingCommandInput, 'cancellation' | 'cbu' | 'cbuAlias' | 'transferMode'>;
|
|
13
|
+
export declare function isElectronicCreditInvoice(voucherKind: VoucherKindDefinition): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Arma `Opcionales` segun el tipo de comprobante:
|
|
16
|
+
* - factura FCE: CBU obligatorio (10168), alias opcional y modalidad de transferencia obligatoria (10216)
|
|
17
|
+
* - NC/ND FCE: solo el codigo de anulacion, obligatorio (10173); sin CBU, alias ni transferencia (10172)
|
|
18
|
+
* - resto: ningun opcional de FCE (10169)
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveElectronicCreditOptionals(input: FceInput, voucherKind: VoucherKindDefinition): IOpcional[] | undefined;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { InputValidationError } from '../../lib/errors/app-error.js';
|
|
2
|
+
import { formatVoucherLabel } from './billing.mappers.js';
|
|
3
|
+
/** Codigos de "Adicionales por R.G." que usa FCE (FEParamGetTiposOpcional). */
|
|
4
|
+
export const FCE_OPTIONAL_IDS = {
|
|
5
|
+
cancellation: '22',
|
|
6
|
+
cbu: '2101',
|
|
7
|
+
cbuAlias: '2102',
|
|
8
|
+
transferMode: '27',
|
|
9
|
+
};
|
|
10
|
+
export const DEFAULT_FCE_TRANSFER_MODE = 'sca';
|
|
11
|
+
export function isElectronicCreditInvoice(voucherKind) {
|
|
12
|
+
return voucherKind.family === 'factura-credito-electronica';
|
|
13
|
+
}
|
|
14
|
+
function listInvoiceOnlyFlags(input) {
|
|
15
|
+
return [
|
|
16
|
+
input.cbu ? '--cbu' : undefined,
|
|
17
|
+
input.cbuAlias ? '--alias' : undefined,
|
|
18
|
+
input.transferMode ? '--transferencia' : undefined,
|
|
19
|
+
].filter((flag) => Boolean(flag));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Arma `Opcionales` segun el tipo de comprobante:
|
|
23
|
+
* - factura FCE: CBU obligatorio (10168), alias opcional y modalidad de transferencia obligatoria (10216)
|
|
24
|
+
* - NC/ND FCE: solo el codigo de anulacion, obligatorio (10173); sin CBU, alias ni transferencia (10172)
|
|
25
|
+
* - resto: ningun opcional de FCE (10169)
|
|
26
|
+
*/
|
|
27
|
+
export function resolveElectronicCreditOptionals(input, voucherKind) {
|
|
28
|
+
const invoiceOnlyFlags = listInvoiceOnlyFlags(input);
|
|
29
|
+
const label = formatVoucherLabel(voucherKind);
|
|
30
|
+
if (!voucherKind.isElectronicCredit) {
|
|
31
|
+
const flags = input.cancellation ? [...invoiceOnlyFlags, '--anulacion'] : invoiceOnlyFlags;
|
|
32
|
+
if (flags.length > 0) {
|
|
33
|
+
throw new InputValidationError(`${flags.join(', ')} solo aplica a comprobantes de credito electronica (FCE).`);
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
if (!isElectronicCreditInvoice(voucherKind)) {
|
|
38
|
+
if (invoiceOnlyFlags.length > 0) {
|
|
39
|
+
throw new InputValidationError(`La ${label} no lleva ${invoiceOnlyFlags.join(', ')}: solo van en la factura FCE.`);
|
|
40
|
+
}
|
|
41
|
+
return [{ Id: FCE_OPTIONAL_IDS.cancellation, Valor: input.cancellation ? 'S' : 'N' }];
|
|
42
|
+
}
|
|
43
|
+
if (input.cancellation) {
|
|
44
|
+
throw new InputValidationError(`La ${label} no usa --anulacion: solo aplica a notas de credito o debito FCE.`);
|
|
45
|
+
}
|
|
46
|
+
if (!input.cbu) {
|
|
47
|
+
throw new InputValidationError(`La ${label} requiere el CBU del emisor. Use --cbu o configurelo con "arcli config establecer cbu <22 digitos>".`);
|
|
48
|
+
}
|
|
49
|
+
const optionals = [{ Id: FCE_OPTIONAL_IDS.cbu, Valor: input.cbu }];
|
|
50
|
+
if (input.cbuAlias) {
|
|
51
|
+
optionals.push({ Id: FCE_OPTIONAL_IDS.cbuAlias, Valor: input.cbuAlias });
|
|
52
|
+
}
|
|
53
|
+
optionals.push({
|
|
54
|
+
Id: FCE_OPTIONAL_IDS.transferMode,
|
|
55
|
+
Valor: (input.transferMode ?? DEFAULT_FCE_TRANSFER_MODE).toUpperCase(),
|
|
56
|
+
});
|
|
57
|
+
return optionals;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=billing.fce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.fce.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.fce.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAIvD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,YAAY,EAAE,IAAI;IAClB,GAAG,EAAE,MAAM;IACX,QAAQ,EAAE,MAAM;IAChB,YAAY,EAAE,IAAI;CACV,CAAC;AAEX,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAI/C,MAAM,UAAU,yBAAyB,CAAC,WAAkC;IAC1E,OAAO,WAAW,CAAC,MAAM,KAAK,6BAA6B,CAAC;AAC9D,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAe;IAC3C,OAAO;QACL,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QAC/B,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QACtC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS;KACnD,CAAC,MAAM,CA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oBAAoB,CAC5B,MAAM,KAAK,sGAAsG,CAClH,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAgB,CAAC,EAAE,EAAE,EAAE,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAEhF,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,SAAS,CAAC,IAAI,CAAC;QACb,EAAE,EAAE,gBAAgB,CAAC,YAAY;QACjC,KAAK,EAAE,CAAC,KAAK,CAAC,YAAY,IAAI,yBAAyB,CAAC,CAAC,WAAW,EAAE;KACvE,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BillingCommandInput, BillingIvaCondition } from './billing.schemas';
|
|
2
|
+
import type { VoucherKindDefinition, VoucherLetter } from './billing.types';
|
|
3
|
+
/** RG 5700/2025: desde $10.000.000 hay que identificar al consumidor final. */
|
|
4
|
+
export declare const CONSUMER_IDENTIFICATION_THRESHOLD = 10000000;
|
|
5
|
+
export declare function isIvaConditionAllowed(letter: VoucherLetter, ivaCondition: BillingIvaCondition): boolean;
|
|
6
|
+
export declare function validateIvaConditionForVoucher(ivaCondition: BillingIvaCondition, voucherKind: VoucherKindDefinition): void;
|
|
7
|
+
export declare function validateConsumerIdentification(input: Pick<BillingCommandInput, 'documentType' | 'totalAmount'>, exchangeRate: number, voucherKind: VoucherKindDefinition): void;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { InputValidationError } from '../../lib/errors/app-error.js';
|
|
2
|
+
import { formatVoucherLabel } from './billing.mappers.js';
|
|
3
|
+
/**
|
|
4
|
+
* Condiciones IVA del receptor admitidas por letra, segun FEParamGetCondicionIvaReceptor.
|
|
5
|
+
* ARCA rechaza las demas combinaciones con el error 10243.
|
|
6
|
+
*/
|
|
7
|
+
const IVA_CONDITIONS_BY_LETTER = {
|
|
8
|
+
a: [
|
|
9
|
+
'responsable-inscripto',
|
|
10
|
+
'responsable-monotributo',
|
|
11
|
+
'monotributista-social',
|
|
12
|
+
'monotributo-trabajador-independiente-promovido',
|
|
13
|
+
],
|
|
14
|
+
b: [
|
|
15
|
+
'sujeto-exento',
|
|
16
|
+
'consumidor-final',
|
|
17
|
+
'sujeto-no-categorizado',
|
|
18
|
+
'proveedor-del-exterior',
|
|
19
|
+
'cliente-del-exterior',
|
|
20
|
+
'iva-liberado',
|
|
21
|
+
'iva-no-alcanzado',
|
|
22
|
+
],
|
|
23
|
+
c: [
|
|
24
|
+
'responsable-inscripto',
|
|
25
|
+
'responsable-monotributo',
|
|
26
|
+
'monotributista-social',
|
|
27
|
+
'monotributo-trabajador-independiente-promovido',
|
|
28
|
+
'sujeto-exento',
|
|
29
|
+
'consumidor-final',
|
|
30
|
+
'sujeto-no-categorizado',
|
|
31
|
+
'proveedor-del-exterior',
|
|
32
|
+
'cliente-del-exterior',
|
|
33
|
+
'iva-liberado',
|
|
34
|
+
'iva-no-alcanzado',
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
/** RG 5700/2025: desde $10.000.000 hay que identificar al consumidor final. */
|
|
38
|
+
export const CONSUMER_IDENTIFICATION_THRESHOLD = 10_000_000;
|
|
39
|
+
export function isIvaConditionAllowed(letter, ivaCondition) {
|
|
40
|
+
return IVA_CONDITIONS_BY_LETTER[letter].includes(ivaCondition);
|
|
41
|
+
}
|
|
42
|
+
export function validateIvaConditionForVoucher(ivaCondition, voucherKind) {
|
|
43
|
+
if (isIvaConditionAllowed(voucherKind.letter, ivaCondition)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const suggestedLetter = ['a', 'b'].find((letter) => isIvaConditionAllowed(letter, ivaCondition));
|
|
47
|
+
const suggestion = suggestedLetter ? ` Use un comprobante letra ${suggestedLetter.toUpperCase()}.` : '';
|
|
48
|
+
throw new InputValidationError(`La ${formatVoucherLabel(voucherKind)} no admite IVA receptor "${ivaCondition}".${suggestion}`);
|
|
49
|
+
}
|
|
50
|
+
export function validateConsumerIdentification(input, exchangeRate, voucherKind) {
|
|
51
|
+
if (input.documentType !== 'consumidor-final') {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (input.totalAmount * exchangeRate >= CONSUMER_IDENTIFICATION_THRESHOLD) {
|
|
55
|
+
throw new InputValidationError(`La ${formatVoucherLabel(voucherKind)} de $10.000.000 o mas requiere identificar al consumidor final. Use --dni, --cuit o --cuil.`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=billing.iva-receptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.iva-receptor.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.iva-receptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAIvD;;;GAGG;AACH,MAAM,wBAAwB,GAA0D;IACtF,CAAC,EAAE;QACD,uBAAuB;QACvB,yBAAyB;QACzB,uBAAuB;QACvB,gDAAgD;KACjD;IACD,CAAC,EAAE;QACD,eAAe;QACf,kBAAkB;QAClB,wBAAwB;QACxB,wBAAwB;QACxB,sBAAsB;QACtB,cAAc;QACd,kBAAkB;KACnB;IACD,CAAC,EAAE;QACD,uBAAuB;QACvB,yBAAyB;QACzB,uBAAuB;QACvB,gDAAgD;QAChD,eAAe;QACf,kBAAkB;QAClB,wBAAwB;QACxB,wBAAwB;QACxB,sBAAsB;QACtB,cAAc;QACd,kBAAkB;KACnB;CACF,CAAC;AAEF,+EAA+E;AAC/E,MAAM,CAAC,MAAM,iCAAiC,GAAG,UAAU,CAAC;AAE5D,MAAM,UAAU,qBAAqB,CAAC,MAAqB,EAAE,YAAiC;IAC5F,OAAO,wBAAwB,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC5C,YAAiC,EACjC,WAAkC;IAElC,IAAI,qBAAqB,CAAC,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;QAC5D,OAAO;IACT,CAAC;IAED,MAAM,eAAe,GAAI,CAAC,GAAG,EAAE,GAAG,CAAW,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,qBAAqB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAC5G,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,6BAA6B,eAAe,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAExG,MAAM,IAAI,oBAAoB,CAC5B,MAAM,kBAAkB,CAAC,WAAW,CAAC,4BAA4B,YAAY,KAAK,UAAU,EAAE,CAC/F,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC5C,KAAgE,EAChE,YAAoB,EACpB,WAAkC;IAElC,IAAI,KAAK,CAAC,YAAY,KAAK,kBAAkB,EAAE,CAAC;QAC9C,OAAO;IACT,CAAC;IAED,IAAI,KAAK,CAAC,WAAW,GAAG,YAAY,IAAI,iCAAiC,EAAE,CAAC;QAC1E,MAAM,IAAI,oBAAoB,CAC5B,MAAM,kBAAkB,CAAC,WAAW,CAAC,6FAA6F,CACnI,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BillingExecutionResult } from './billing.types.internal';
|
|
2
|
+
interface BillingJsonOptions {
|
|
3
|
+
readonly raw?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function formatBillingResultAsJson(result: BillingExecutionResult, options?: BillingJsonOptions): string;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { serializeBillingResult } from './billing.serialize.js';
|
|
2
|
+
export function formatBillingResultAsJson(result, options = {}) {
|
|
3
|
+
return JSON.stringify(serializeBillingResult(result, { raw: options.raw }), null, 2);
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=billing.json-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.json-format.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.json-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAO7D,MAAM,UAAU,yBAAyB,CAAC,MAA8B,EAAE,UAA8B,EAAE;IACxG,OAAO,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function formatDateLabel(value: string | undefined): string;
|
|
2
|
+
export declare function formatMoneyLabel(value: number | undefined): string;
|
|
3
|
+
export declare function formatConceptLabel(value: number | undefined): string;
|
|
4
|
+
export declare function formatDocumentTypeLabel(value: number | undefined): string;
|
|
5
|
+
export declare function formatIvaConditionLabel(value: number | undefined): string;
|
|
6
|
+
export declare function formatCurrencyLabel(value: string | undefined): string;
|
|
7
|
+
export declare function formatNumericLabel(value: number | undefined): string;
|
|
8
|
+
export declare function formatTaxIdLabel(value: string | number | undefined): string;
|
|
9
|
+
export declare function formatDecimalLabel(value: number | undefined): string;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export function formatDateLabel(value) {
|
|
2
|
+
if (!value) {
|
|
3
|
+
return 'N/D';
|
|
4
|
+
}
|
|
5
|
+
if (/^\d{8}$/.test(value)) {
|
|
6
|
+
return `${value.slice(6, 8)}/${value.slice(4, 6)}/${value.slice(0, 4)}`;
|
|
7
|
+
}
|
|
8
|
+
return value.replaceAll('-', '/');
|
|
9
|
+
}
|
|
10
|
+
export function formatMoneyLabel(value) {
|
|
11
|
+
if (typeof value !== 'number') {
|
|
12
|
+
return 'N/D';
|
|
13
|
+
}
|
|
14
|
+
const hasDecimals = !Number.isInteger(value);
|
|
15
|
+
return `${new Intl.NumberFormat('es-AR', {
|
|
16
|
+
maximumFractionDigits: 2,
|
|
17
|
+
minimumFractionDigits: hasDecimals ? 2 : 0,
|
|
18
|
+
}).format(value)}$`;
|
|
19
|
+
}
|
|
20
|
+
export function formatConceptLabel(value) {
|
|
21
|
+
switch (value) {
|
|
22
|
+
case 1:
|
|
23
|
+
return 'Productos';
|
|
24
|
+
case 2:
|
|
25
|
+
return 'Servicios';
|
|
26
|
+
case 3:
|
|
27
|
+
return 'Productos y servicios';
|
|
28
|
+
default:
|
|
29
|
+
return value ? String(value) : 'N/D';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function formatDocumentTypeLabel(value) {
|
|
33
|
+
switch (value) {
|
|
34
|
+
case 80:
|
|
35
|
+
return 'CUIT';
|
|
36
|
+
case 86:
|
|
37
|
+
return 'CUIL';
|
|
38
|
+
case 96:
|
|
39
|
+
return 'DNI';
|
|
40
|
+
case 99:
|
|
41
|
+
return 'Consumidor final';
|
|
42
|
+
default:
|
|
43
|
+
return value ? String(value) : 'N/D';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function formatIvaConditionLabel(value) {
|
|
47
|
+
switch (value) {
|
|
48
|
+
case 1:
|
|
49
|
+
return 'Responsable inscripto';
|
|
50
|
+
case 4:
|
|
51
|
+
return 'Sujeto exento';
|
|
52
|
+
case 5:
|
|
53
|
+
return 'Consumidor final';
|
|
54
|
+
case 6:
|
|
55
|
+
return 'Responsable monotributo';
|
|
56
|
+
case 7:
|
|
57
|
+
return 'Sujeto no categorizado';
|
|
58
|
+
case 8:
|
|
59
|
+
return 'Proveedor del exterior';
|
|
60
|
+
case 9:
|
|
61
|
+
return 'Cliente del exterior';
|
|
62
|
+
case 10:
|
|
63
|
+
return 'IVA liberado';
|
|
64
|
+
case 13:
|
|
65
|
+
return 'Monotributista social';
|
|
66
|
+
case 15:
|
|
67
|
+
return 'IVA no alcanzado';
|
|
68
|
+
case 16:
|
|
69
|
+
return 'Monotributo trabajador independiente promovido';
|
|
70
|
+
default:
|
|
71
|
+
return value ? String(value) : 'N/D';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function formatCurrencyLabel(value) {
|
|
75
|
+
switch (value) {
|
|
76
|
+
case 'PES':
|
|
77
|
+
return 'Pesos argentinos (ARS)';
|
|
78
|
+
case 'DOL':
|
|
79
|
+
return 'Dolares estadounidenses (USD)';
|
|
80
|
+
default:
|
|
81
|
+
return value ?? 'N/D';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export function formatNumericLabel(value) {
|
|
85
|
+
if (typeof value !== 'number') {
|
|
86
|
+
return 'N/D';
|
|
87
|
+
}
|
|
88
|
+
return new Intl.NumberFormat('es-AR').format(value);
|
|
89
|
+
}
|
|
90
|
+
export function formatTaxIdLabel(value) {
|
|
91
|
+
if (value === undefined || value === null || value === '') {
|
|
92
|
+
return 'No informado';
|
|
93
|
+
}
|
|
94
|
+
const normalizedValue = String(value).replace(/\D/g, '');
|
|
95
|
+
if (!/^\d{11}$/.test(normalizedValue)) {
|
|
96
|
+
return String(value);
|
|
97
|
+
}
|
|
98
|
+
return `${normalizedValue.slice(0, 2)}-${normalizedValue.slice(2, 10)}-${normalizedValue.slice(10)}`;
|
|
99
|
+
}
|
|
100
|
+
export function formatDecimalLabel(value) {
|
|
101
|
+
if (typeof value !== 'number') {
|
|
102
|
+
return 'N/D';
|
|
103
|
+
}
|
|
104
|
+
return new Intl.NumberFormat('es-AR', {
|
|
105
|
+
maximumFractionDigits: 6,
|
|
106
|
+
}).format(value);
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=billing.labels.js.map
|
|
@@ -0,0 +1 @@
|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