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.
Files changed (292) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/LICENSE +21 -0
  3. package/README.md +169 -4
  4. package/dist/cli/commands/billing-family.command.d.ts +2 -0
  5. package/dist/cli/commands/billing-family.command.js +30 -0
  6. package/dist/cli/commands/billing-family.command.js.map +1 -0
  7. package/dist/cli/commands/billing-shortcuts.command.d.ts +2 -0
  8. package/dist/cli/commands/billing-shortcuts.command.js +18 -0
  9. package/dist/cli/commands/billing-shortcuts.command.js.map +1 -0
  10. package/dist/cli/commands/billing.command.interactive-preview.d.ts +18 -0
  11. package/dist/cli/commands/billing.command.interactive-preview.js +69 -0
  12. package/dist/cli/commands/billing.command.interactive-preview.js.map +1 -0
  13. package/dist/cli/commands/billing.command.options.d.ts +2 -0
  14. package/dist/cli/commands/billing.command.options.js +65 -0
  15. package/dist/cli/commands/billing.command.options.js.map +1 -0
  16. package/dist/cli/commands/billing.command.output.d.ts +12 -0
  17. package/dist/cli/commands/billing.command.output.js +33 -0
  18. package/dist/cli/commands/billing.command.output.js.map +1 -0
  19. package/dist/cli/commands/billing.command.parser.d.ts +21 -0
  20. package/dist/cli/commands/billing.command.parser.js +170 -0
  21. package/dist/cli/commands/billing.command.parser.js.map +1 -0
  22. package/dist/cli/commands/billing.command.shared.d.ts +7 -0
  23. package/dist/cli/commands/billing.command.shared.js +99 -0
  24. package/dist/cli/commands/billing.command.shared.js.map +1 -0
  25. package/dist/cli/commands/billing.command.shortcuts.d.ts +7 -0
  26. package/dist/cli/commands/billing.command.shortcuts.js +52 -0
  27. package/dist/cli/commands/billing.command.shortcuts.js.map +1 -0
  28. package/dist/cli/commands/config.command.d.ts +2 -0
  29. package/dist/cli/commands/config.command.js +125 -0
  30. package/dist/cli/commands/config.command.js.map +1 -0
  31. package/dist/cli/commands/examples.command.d.ts +2 -0
  32. package/dist/cli/commands/examples.command.js +14 -0
  33. package/dist/cli/commands/examples.command.js.map +1 -0
  34. package/dist/cli/commands/fce-obligation.command.d.ts +2 -0
  35. package/dist/cli/commands/fce-obligation.command.js +51 -0
  36. package/dist/cli/commands/fce-obligation.command.js.map +1 -0
  37. package/dist/cli/commands/storybook.command.d.ts +2 -0
  38. package/dist/cli/commands/storybook.command.js +26 -0
  39. package/dist/cli/commands/storybook.command.js.map +1 -0
  40. package/dist/cli/help.d.ts +11 -0
  41. package/dist/cli/help.js +534 -0
  42. package/dist/cli/help.js.map +1 -0
  43. package/dist/cli/index.d.ts +2 -0
  44. package/dist/cli/index.js +41 -0
  45. package/dist/cli/index.js.map +1 -0
  46. package/dist/cli/program.d.ts +2 -0
  47. package/dist/cli/program.js +30 -0
  48. package/dist/cli/program.js.map +1 -0
  49. package/dist/cli/types.d.ts +6 -0
  50. package/dist/cli/types.js +2 -0
  51. package/dist/cli/types.js.map +1 -0
  52. package/dist/cli/version.d.ts +1 -0
  53. package/dist/cli/version.js +2 -0
  54. package/dist/cli/version.js.map +1 -0
  55. package/dist/index.d.ts +1 -0
  56. package/dist/index.js +2 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/lib/dates/arca-date.d.ts +6 -0
  59. package/dist/lib/dates/arca-date.js +45 -0
  60. package/dist/lib/dates/arca-date.js.map +1 -0
  61. package/dist/lib/errors/app-error.d.ts +14 -0
  62. package/dist/lib/errors/app-error.js +29 -0
  63. package/dist/lib/errors/app-error.js.map +1 -0
  64. package/dist/lib/files/read-json-file.d.ts +1 -0
  65. package/dist/lib/files/read-json-file.js +21 -0
  66. package/dist/lib/files/read-json-file.js.map +1 -0
  67. package/dist/lib/paths/mask-path.d.ts +1 -0
  68. package/dist/lib/paths/mask-path.js +17 -0
  69. package/dist/lib/paths/mask-path.js.map +1 -0
  70. package/dist/lib/security/certificate.d.ts +7 -0
  71. package/dist/lib/security/certificate.js +16 -0
  72. package/dist/lib/security/certificate.js.map +1 -0
  73. package/dist/lib/security/pem.d.ts +5 -0
  74. package/dist/lib/security/pem.js +36 -0
  75. package/dist/lib/security/pem.js.map +1 -0
  76. package/dist/modules/billing/billing-response.d.ts +4 -0
  77. package/dist/modules/billing/billing-response.js +74 -0
  78. package/dist/modules/billing/billing-response.js.map +1 -0
  79. package/dist/modules/billing/billing.amounts.d.ts +19 -0
  80. package/dist/modules/billing/billing.amounts.js +72 -0
  81. package/dist/modules/billing/billing.amounts.js.map +1 -0
  82. package/dist/modules/billing/billing.associated-period.d.ts +8 -0
  83. package/dist/modules/billing/billing.associated-period.js +40 -0
  84. package/dist/modules/billing/billing.associated-period.js.map +1 -0
  85. package/dist/modules/billing/billing.associated-vouchers.d.ts +12 -0
  86. package/dist/modules/billing/billing.associated-vouchers.js +73 -0
  87. package/dist/modules/billing/billing.associated-vouchers.js.map +1 -0
  88. package/dist/modules/billing/billing.constants.d.ts +2 -0
  89. package/dist/modules/billing/billing.constants.js +3 -0
  90. package/dist/modules/billing/billing.constants.js.map +1 -0
  91. package/dist/modules/billing/billing.currency.d.ts +18 -0
  92. package/dist/modules/billing/billing.currency.js +53 -0
  93. package/dist/modules/billing/billing.currency.js.map +1 -0
  94. package/dist/modules/billing/billing.date-range.d.ts +9 -0
  95. package/dist/modules/billing/billing.date-range.js +52 -0
  96. package/dist/modules/billing/billing.date-range.js.map +1 -0
  97. package/dist/modules/billing/billing.display.d.ts +13 -0
  98. package/dist/modules/billing/billing.display.js +137 -0
  99. package/dist/modules/billing/billing.display.js.map +1 -0
  100. package/dist/modules/billing/billing.fce.d.ts +21 -0
  101. package/dist/modules/billing/billing.fce.js +59 -0
  102. package/dist/modules/billing/billing.fce.js.map +1 -0
  103. package/dist/modules/billing/billing.iva-receptor.d.ts +7 -0
  104. package/dist/modules/billing/billing.iva-receptor.js +58 -0
  105. package/dist/modules/billing/billing.iva-receptor.js.map +1 -0
  106. package/dist/modules/billing/billing.json-format.d.ts +6 -0
  107. package/dist/modules/billing/billing.json-format.js +5 -0
  108. package/dist/modules/billing/billing.json-format.js.map +1 -0
  109. package/dist/modules/billing/billing.labels.d.ts +9 -0
  110. package/dist/modules/billing/billing.labels.js +108 -0
  111. package/dist/modules/billing/billing.labels.js.map +1 -0
  112. package/dist/modules/billing/billing.mappers.d.ts +8 -0
  113. package/dist/modules/billing/billing.mappers.js +60 -0
  114. package/dist/modules/billing/billing.mappers.js.map +1 -0
  115. package/dist/modules/billing/billing.presenter.d.ts +7 -0
  116. package/dist/modules/billing/billing.presenter.js +3 -0
  117. package/dist/modules/billing/billing.presenter.js.map +1 -0
  118. package/dist/modules/billing/billing.schemas.d.ts +107 -0
  119. package/dist/modules/billing/billing.schemas.js +106 -0
  120. package/dist/modules/billing/billing.schemas.js.map +1 -0
  121. package/dist/modules/billing/billing.serialize.d.ts +8 -0
  122. package/dist/modules/billing/billing.serialize.js +53 -0
  123. package/dist/modules/billing/billing.serialize.js.map +1 -0
  124. package/dist/modules/billing/billing.service.d.ts +27 -0
  125. package/dist/modules/billing/billing.service.js +146 -0
  126. package/dist/modules/billing/billing.service.js.map +1 -0
  127. package/dist/modules/billing/billing.text.d.ts +8 -0
  128. package/dist/modules/billing/billing.text.js +52 -0
  129. package/dist/modules/billing/billing.text.js.map +1 -0
  130. package/dist/modules/billing/billing.types.d.ts +13 -0
  131. package/dist/modules/billing/billing.types.internal.d.ts +27 -0
  132. package/dist/modules/billing/billing.types.internal.js +2 -0
  133. package/dist/modules/billing/billing.types.internal.js.map +1 -0
  134. package/dist/modules/billing/billing.types.js +2 -0
  135. package/dist/modules/billing/billing.types.js.map +1 -0
  136. package/dist/modules/billing/billing.validation.d.ts +7 -0
  137. package/dist/modules/billing/billing.validation.js +80 -0
  138. package/dist/modules/billing/billing.validation.js.map +1 -0
  139. package/dist/modules/billing/voucher-kind-map.d.ts +9 -0
  140. package/dist/modules/billing/voucher-kind-map.js +180 -0
  141. package/dist/modules/billing/voucher-kind-map.js.map +1 -0
  142. package/dist/modules/config/config-doctor.d.ts +15 -0
  143. package/dist/modules/config/config-doctor.js +125 -0
  144. package/dist/modules/config/config-doctor.js.map +1 -0
  145. package/dist/modules/config/config-value-parser.d.ts +2 -0
  146. package/dist/modules/config/config-value-parser.js +99 -0
  147. package/dist/modules/config/config-value-parser.js.map +1 -0
  148. package/dist/modules/config/config.presenter.d.ts +7 -0
  149. package/dist/modules/config/config.presenter.js +88 -0
  150. package/dist/modules/config/config.presenter.js.map +1 -0
  151. package/dist/modules/config/config.schemas.d.ts +110 -0
  152. package/dist/modules/config/config.schemas.js +103 -0
  153. package/dist/modules/config/config.schemas.js.map +1 -0
  154. package/dist/modules/config/config.service.d.ts +20 -0
  155. package/dist/modules/config/config.service.js +82 -0
  156. package/dist/modules/config/config.service.js.map +1 -0
  157. package/dist/modules/examples/examples.d.ts +1 -0
  158. package/dist/modules/examples/examples.js +191 -0
  159. package/dist/modules/examples/examples.js.map +1 -0
  160. package/dist/modules/fce/fce-obligation.d.ts +20 -0
  161. package/dist/modules/fce/fce-obligation.js +33 -0
  162. package/dist/modules/fce/fce-obligation.js.map +1 -0
  163. package/dist/modules/fce/fce-obligation.presenter.d.ts +9 -0
  164. package/dist/modules/fce/fce-obligation.presenter.js +32 -0
  165. package/dist/modules/fce/fce-obligation.presenter.js.map +1 -0
  166. package/dist/modules/storybook/showcase-theme.d.ts +7 -0
  167. package/dist/modules/storybook/showcase-theme.js +6 -0
  168. package/dist/modules/storybook/showcase-theme.js.map +1 -0
  169. package/dist/modules/storybook/showcase.d.ts +2 -0
  170. package/dist/modules/storybook/showcase.js +310 -0
  171. package/dist/modules/storybook/showcase.js.map +1 -0
  172. package/dist/modules/update-check/update-check.presenter.d.ts +2 -0
  173. package/dist/modules/update-check/update-check.presenter.js +6 -0
  174. package/dist/modules/update-check/update-check.presenter.js.map +1 -0
  175. package/dist/modules/update-check/update-check.service.d.ts +8 -0
  176. package/dist/modules/update-check/update-check.service.js +72 -0
  177. package/dist/modules/update-check/update-check.service.js.map +1 -0
  178. package/dist/services/arca/arca-billing.gateway.d.ts +10 -0
  179. package/dist/services/arca/arca-billing.gateway.js +22 -0
  180. package/dist/services/arca/arca-billing.gateway.js.map +1 -0
  181. package/dist/services/arca/arca-client.factory.d.ts +5 -0
  182. package/dist/services/arca/arca-client.factory.js +7 -0
  183. package/dist/services/arca/arca-client.factory.js.map +1 -0
  184. package/dist/services/arca/arca-context.resolver.d.ts +44 -0
  185. package/dist/services/arca/arca-context.resolver.js +120 -0
  186. package/dist/services/arca/arca-context.resolver.js.map +1 -0
  187. package/dist/services/arca/arca-fce-obligation.gateway.d.ts +7 -0
  188. package/dist/services/arca/arca-fce-obligation.gateway.js +36 -0
  189. package/dist/services/arca/arca-fce-obligation.gateway.js.map +1 -0
  190. package/dist/ui/components/contentPanel.d.ts +5 -0
  191. package/dist/ui/components/contentPanel.js +11 -0
  192. package/dist/ui/components/contentPanel.js.map +1 -0
  193. package/dist/ui/components/errorPanel.d.ts +1 -0
  194. package/dist/ui/components/errorPanel.js +13 -0
  195. package/dist/ui/components/errorPanel.js.map +1 -0
  196. package/dist/ui/components/index.d.ts +6 -0
  197. package/dist/ui/components/index.js +7 -0
  198. package/dist/ui/components/index.js.map +1 -0
  199. package/dist/ui/components/keyValuePanel.d.ts +3 -0
  200. package/dist/ui/components/keyValuePanel.js +14 -0
  201. package/dist/ui/components/keyValuePanel.js.map +1 -0
  202. package/dist/ui/components/noticePanel.d.ts +3 -0
  203. package/dist/ui/components/noticePanel.js +11 -0
  204. package/dist/ui/components/noticePanel.js.map +1 -0
  205. package/dist/ui/components/rawPanel.d.ts +1 -0
  206. package/dist/ui/components/rawPanel.js +5 -0
  207. package/dist/ui/components/rawPanel.js.map +1 -0
  208. package/dist/ui/components/statusPanel.d.ts +3 -0
  209. package/dist/ui/components/statusPanel.js +20 -0
  210. package/dist/ui/components/statusPanel.js.map +1 -0
  211. package/dist/ui/index.d.ts +5 -0
  212. package/dist/ui/index.js +6 -0
  213. package/dist/ui/index.js.map +1 -0
  214. package/dist/ui/presenters/billing.presenter.d.ts +2 -0
  215. package/dist/ui/presenters/billing.presenter.js +2 -0
  216. package/dist/ui/presenters/billing.presenter.js.map +1 -0
  217. package/dist/ui/presenters/config.presenter.d.ts +1 -0
  218. package/dist/ui/presenters/config.presenter.js +2 -0
  219. package/dist/ui/presenters/config.presenter.js.map +1 -0
  220. package/dist/ui/presenters/errors.presenter.d.ts +1 -0
  221. package/dist/ui/presenters/errors.presenter.js +89 -0
  222. package/dist/ui/presenters/errors.presenter.js.map +1 -0
  223. package/dist/ui/presenters/errors.zod-presenter.d.ts +2 -0
  224. package/dist/ui/presenters/errors.zod-presenter.js +103 -0
  225. package/dist/ui/presenters/errors.zod-presenter.js.map +1 -0
  226. package/dist/ui/presenters/index.d.ts +4 -0
  227. package/dist/ui/presenters/index.js +5 -0
  228. package/dist/ui/presenters/index.js.map +1 -0
  229. package/dist/ui/presenters/showcase.presenter.d.ts +1 -0
  230. package/dist/ui/presenters/showcase.presenter.js +2 -0
  231. package/dist/ui/presenters/showcase.presenter.js.map +1 -0
  232. package/dist/ui/primitives/index.d.ts +10 -0
  233. package/dist/ui/primitives/index.js +11 -0
  234. package/dist/ui/primitives/index.js.map +1 -0
  235. package/dist/ui/primitives/renderDivider.d.ts +5 -0
  236. package/dist/ui/primitives/renderDivider.js +5 -0
  237. package/dist/ui/primitives/renderDivider.js.map +1 -0
  238. package/dist/ui/primitives/renderFooter.d.ts +7 -0
  239. package/dist/ui/primitives/renderFooter.js +6 -0
  240. package/dist/ui/primitives/renderFooter.js.map +1 -0
  241. package/dist/ui/primitives/renderJson.d.ts +3 -0
  242. package/dist/ui/primitives/renderJson.js +19 -0
  243. package/dist/ui/primitives/renderJson.js.map +1 -0
  244. package/dist/ui/primitives/renderKeyValue.d.ts +14 -0
  245. package/dist/ui/primitives/renderKeyValue.js +34 -0
  246. package/dist/ui/primitives/renderKeyValue.js.map +1 -0
  247. package/dist/ui/primitives/renderLogo.d.ts +2 -0
  248. package/dist/ui/primitives/renderLogo.js +28 -0
  249. package/dist/ui/primitives/renderLogo.js.map +1 -0
  250. package/dist/ui/primitives/renderObject.d.ts +1 -0
  251. package/dist/ui/primitives/renderObject.js +19 -0
  252. package/dist/ui/primitives/renderObject.js.map +1 -0
  253. package/dist/ui/primitives/renderPanel.d.ts +23 -0
  254. package/dist/ui/primitives/renderPanel.js +114 -0
  255. package/dist/ui/primitives/renderPanel.js.map +1 -0
  256. package/dist/ui/primitives/renderSubtitle.d.ts +7 -0
  257. package/dist/ui/primitives/renderSubtitle.js +6 -0
  258. package/dist/ui/primitives/renderSubtitle.js.map +1 -0
  259. package/dist/ui/primitives/renderTable.d.ts +6 -0
  260. package/dist/ui/primitives/renderTable.js +14 -0
  261. package/dist/ui/primitives/renderTable.js.map +1 -0
  262. package/dist/ui/primitives/text.d.ts +18 -0
  263. package/dist/ui/primitives/text.js +154 -0
  264. package/dist/ui/primitives/text.js.map +1 -0
  265. package/dist/ui/stream/index.d.ts +1 -0
  266. package/dist/ui/stream/index.js +2 -0
  267. package/dist/ui/stream/index.js.map +1 -0
  268. package/dist/ui/stream/terminal-stream.d.ts +10 -0
  269. package/dist/ui/stream/terminal-stream.js +20 -0
  270. package/dist/ui/stream/terminal-stream.js.map +1 -0
  271. package/dist/ui/theme/index.d.ts +1 -0
  272. package/dist/ui/theme/index.js +2 -0
  273. package/dist/ui/theme/index.js.map +1 -0
  274. package/dist/ui/theme/theme.d.ts +27 -0
  275. package/dist/ui/theme/theme.js +41 -0
  276. package/dist/ui/theme/theme.js.map +1 -0
  277. package/llms.txt +161 -0
  278. package/package.json +99 -35
  279. package/.babelrc +0 -4
  280. package/.eslintignore +0 -1
  281. package/.eslintrc.js +0 -17
  282. package/.npmignore +0 -1
  283. package/lib/arcli.js +0 -275
  284. package/lib/arcli.min.js +0 -1
  285. package/src/config.js +0 -22
  286. package/src/consoler.js +0 -10
  287. package/src/index.js +0 -21
  288. package/src/init.js +0 -13
  289. package/src/run.js +0 -4
  290. package/src/spinner.js +0 -39
  291. package/tst/index.js +0 -26
  292. package/webpack.config.js +0 -47
@@ -0,0 +1,6 @@
1
+ export interface GlobalCliOptions {
2
+ readonly bruto?: boolean;
3
+ readonly json?: boolean;
4
+ readonly produccion?: boolean;
5
+ readonly testing?: boolean;
6
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/cli/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export declare const CLI_VERSION = "1.2.0";
@@ -0,0 +1,2 @@
1
+ export const CLI_VERSION = '1.2.0';
2
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/cli/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC"}
@@ -0,0 +1 @@
1
+ import './cli/index';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import './cli/index.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function formatDateAsArcaDate(value: Date): string;
2
+ /** Dias entre dos fechas ARCA (yyyymmdd): positivo si `to` es posterior a `from`. */
3
+ export declare function diffArcaDatesInDays(from: string, to: string): number;
4
+ export declare function maxArcaDate(...values: string[]): string;
5
+ export declare function formatArcaDateAsArgentineDate(value: string): string;
6
+ export declare function parseArgentineDateInputAsArcaDate(value: string, referenceDate?: Date): string;
@@ -0,0 +1,45 @@
1
+ import { InputValidationError } from '../errors/app-error.js';
2
+ const ARGENTINE_DATE_FORMAT_HINT = 'Use D, DD, D-MM, D/MM, D-MM-YY, D/MM/YY, D-MM-YYYY o D/MM/YYYY.';
3
+ // Usa la fecha local: con toISOString, despues de las 21 hs en Argentina la fecha saltaba al dia siguiente.
4
+ export function formatDateAsArcaDate(value) {
5
+ const year = String(value.getFullYear());
6
+ const month = String(value.getMonth() + 1).padStart(2, '0');
7
+ const day = String(value.getDate()).padStart(2, '0');
8
+ return `${year}${month}${day}`;
9
+ }
10
+ function arcaDateToUtcTime(value) {
11
+ return Date.UTC(Number(value.slice(0, 4)), Number(value.slice(4, 6)) - 1, Number(value.slice(6, 8)));
12
+ }
13
+ /** Dias entre dos fechas ARCA (yyyymmdd): positivo si `to` es posterior a `from`. */
14
+ export function diffArcaDatesInDays(from, to) {
15
+ return Math.round((arcaDateToUtcTime(to) - arcaDateToUtcTime(from)) / 86_400_000);
16
+ }
17
+ export function maxArcaDate(...values) {
18
+ return values.reduce((latest, value) => (value > latest ? value : latest));
19
+ }
20
+ export function formatArcaDateAsArgentineDate(value) {
21
+ return `${value.slice(6, 8)}/${value.slice(4, 6)}/${value.slice(0, 4)}`;
22
+ }
23
+ export function parseArgentineDateInputAsArcaDate(value, referenceDate = new Date()) {
24
+ const normalizedValue = value.trim();
25
+ const dateMatch = /^(\d{1,2})(?:([-/])(\d{1,2})(?:\2(\d{2}|\d{4}))?)?$/.exec(normalizedValue);
26
+ if (!dateMatch) {
27
+ throw new InputValidationError(`La fecha "${value}" no es valida. ${ARGENTINE_DATE_FORMAT_HINT}`);
28
+ }
29
+ const [, rawDay, , rawMonth, explicitYear] = dateMatch;
30
+ const day = rawDay.padStart(2, '0');
31
+ const month = (rawMonth ?? String(referenceDate.getMonth() + 1)).padStart(2, '0');
32
+ const year = resolveYear(explicitYear, referenceDate);
33
+ const date = new Date(Number(year), Number(month) - 1, Number(day));
34
+ if (date.getFullYear() !== Number(year) || date.getMonth() !== Number(month) - 1 || date.getDate() !== Number(day)) {
35
+ throw new InputValidationError(`La fecha "${value}" no es valida.`);
36
+ }
37
+ return `${year}${month}${day}`;
38
+ }
39
+ function resolveYear(explicitYear, referenceDate) {
40
+ if (!explicitYear) {
41
+ return String(referenceDate.getFullYear());
42
+ }
43
+ return explicitYear.length === 2 ? `20${explicitYear}` : explicitYear;
44
+ }
45
+ //# sourceMappingURL=arca-date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arca-date.js","sourceRoot":"","sources":["../../../src/lib/dates/arca-date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,0BAA0B,GAAG,iEAAiE,CAAC;AAErG,4GAA4G;AAC5G,MAAM,UAAU,oBAAoB,CAAC,KAAW;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAErD,OAAO,GAAG,IAAI,GAAG,KAAK,GAAG,GAAG,EAAE,CAAC;AACjC,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa;IACtC,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACvG,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,EAAU;IAC1D,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,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AAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAEpE,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,KAAK,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QACnH,MAAM,IAAI,oBAAoB,CAAC,aAAa,KAAK,iBAAiB,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,GAAG,IAAI,GAAG,KAAK,GAAG,GAAG,EAAE,CAAC;AACjC,CAAC;AAED,SAAS,WAAW,CAAC,YAAgC,EAAE,aAAmB;IACxE,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,YAAY,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;AACxE,CAAC"}
@@ -0,0 +1,14 @@
1
+ export declare class AppError extends Error {
2
+ readonly code: string;
3
+ readonly details?: Record<string, unknown>;
4
+ constructor(message: string, options: {
5
+ code: string;
6
+ details?: Record<string, unknown>;
7
+ });
8
+ }
9
+ export declare class ConfigurationError extends AppError {
10
+ constructor(message: string, details?: Record<string, unknown>);
11
+ }
12
+ export declare class InputValidationError extends AppError {
13
+ constructor(message: string, details?: Record<string, unknown>);
14
+ }
@@ -0,0 +1,29 @@
1
+ export class AppError extends Error {
2
+ code;
3
+ details;
4
+ constructor(message, options) {
5
+ super(message);
6
+ this.name = 'AppError';
7
+ this.code = options.code;
8
+ this.details = options.details;
9
+ }
10
+ }
11
+ export class ConfigurationError extends AppError {
12
+ constructor(message, details) {
13
+ super(message, {
14
+ code: 'CONFIGURATION_ERROR',
15
+ details,
16
+ });
17
+ this.name = 'ConfigurationError';
18
+ }
19
+ }
20
+ export class InputValidationError extends AppError {
21
+ constructor(message, details) {
22
+ super(message, {
23
+ code: 'INPUT_VALIDATION_ERROR',
24
+ details,
25
+ });
26
+ this.name = 'InputValidationError';
27
+ }
28
+ }
29
+ //# sourceMappingURL=app-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-error.js","sourceRoot":"","sources":["../../../src/lib/errors/app-error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjB,IAAI,CAAS;IACb,OAAO,CAA2B;IAElD,YAAmB,OAAe,EAAE,OAA4D;QAC9F,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACjC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,QAAQ;IAC9C,YAAmB,OAAe,EAAE,OAAiC;QACnE,KAAK,CAAC,OAAO,EAAE;YACb,IAAI,EAAE,qBAAqB;YAC3B,OAAO;SACR,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,QAAQ;IAChD,YAAmB,OAAe,EAAE,OAAiC;QACnE,KAAK,CAAC,OAAO,EAAE;YACb,IAAI,EAAE,wBAAwB;YAC9B,OAAO;SACR,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export declare function readJsonFile<T>(filePath: string): T;
@@ -0,0 +1,21 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { InputValidationError } from '../errors/app-error.js';
3
+ export function readJsonFile(filePath) {
4
+ if (!existsSync(filePath)) {
5
+ throw new InputValidationError(`La ruta del archivo JSON no existe: ${filePath}`, {
6
+ path: filePath,
7
+ });
8
+ }
9
+ const rawContent = readFileSync(filePath, 'utf8');
10
+ try {
11
+ return JSON.parse(rawContent);
12
+ }
13
+ catch (error) {
14
+ const message = error instanceof Error ? error.message : 'JSON invalido';
15
+ throw new InputValidationError(`No se pudo leer el archivo JSON "${filePath}": ${message}`, {
16
+ cause: error instanceof Error ? error.message : 'JSON invalido',
17
+ path: filePath,
18
+ });
19
+ }
20
+ }
21
+ //# sourceMappingURL=read-json-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-json-file.js","sourceRoot":"","sources":["../../../src/lib/files/read-json-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,UAAU,YAAY,CAAI,QAAgB;IAC9C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,oBAAoB,CAAC,uCAAuC,QAAQ,EAAE,EAAE;YAChF,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IAED,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAElD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAM,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QAEzE,MAAM,IAAI,oBAAoB,CAAC,oCAAoC,QAAQ,MAAM,OAAO,EAAE,EAAE;YAC1F,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;YAC/D,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function maskPath(filePath: string): string;
@@ -0,0 +1,17 @@
1
+ import { basename, dirname } from 'node:path';
2
+ export function maskPath(filePath) {
3
+ const normalizedPath = filePath.trim();
4
+ if (!normalizedPath) {
5
+ return filePath;
6
+ }
7
+ const fileName = basename(normalizedPath);
8
+ const parentDirectory = basename(dirname(normalizedPath));
9
+ if (!fileName) {
10
+ return normalizedPath;
11
+ }
12
+ if (!parentDirectory || parentDirectory === '.' || parentDirectory === fileName) {
13
+ return `.../${fileName}`;
14
+ }
15
+ return `.../${parentDirectory}/${fileName}`;
16
+ }
17
+ //# sourceMappingURL=mask-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mask-path.js","sourceRoot":"","sources":["../../../src/lib/paths/mask-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,UAAU,QAAQ,CAAC,QAAgB;IACvC,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;IAEvC,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC1C,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;IAE1D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,IAAI,CAAC,eAAe,IAAI,eAAe,KAAK,GAAG,IAAI,eAAe,KAAK,QAAQ,EAAE,CAAC;QAChF,OAAO,OAAO,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAED,OAAO,OAAO,eAAe,IAAI,QAAQ,EAAE,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface CertificateExpiry {
2
+ readonly daysRemaining: number;
3
+ readonly expiresAt: Date;
4
+ readonly isExpired: boolean;
5
+ }
6
+ export declare function readCertificateExpiry(pemContent: string): CertificateExpiry;
7
+ export declare function isCertificateExpiringSoon(expiry: CertificateExpiry, thresholdDays: number): boolean;
@@ -0,0 +1,16 @@
1
+ import { X509Certificate } from 'node:crypto';
2
+ const MS_PER_DAY = 24 * 60 * 60 * 1000;
3
+ export function readCertificateExpiry(pemContent) {
4
+ const certificate = new X509Certificate(pemContent);
5
+ const expiresAt = new Date(certificate.validTo);
6
+ const daysRemaining = Math.ceil((expiresAt.getTime() - Date.now()) / MS_PER_DAY);
7
+ return {
8
+ daysRemaining,
9
+ expiresAt,
10
+ isExpired: daysRemaining < 0,
11
+ };
12
+ }
13
+ export function isCertificateExpiringSoon(expiry, thresholdDays) {
14
+ return !expiry.isExpired && expiry.daysRemaining <= thresholdDays;
15
+ }
16
+ //# sourceMappingURL=certificate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"certificate.js","sourceRoot":"","sources":["../../../src/lib/security/certificate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,UAAU,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAQvC,MAAM,UAAU,qBAAqB,CAAC,UAAkB;IACtD,MAAM,WAAW,GAAG,IAAI,eAAe,CAAC,UAAU,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC;IAEjF,OAAO;QACL,aAAa;QACb,SAAS;QACT,SAAS,EAAE,aAAa,GAAG,CAAC;KAC7B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,MAAyB,EAAE,aAAqB;IACxF,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,aAAa,IAAI,aAAa,CAAC;AACpE,CAAC"}
@@ -0,0 +1,5 @@
1
+ type PemKind = 'certificado' | 'clave privada';
2
+ export declare function ensurePathExists(filePath: string, label: PemKind): void;
3
+ export declare function ensurePemFormat(content: string, filePath: string, label: PemKind): void;
4
+ export declare function readPemFile(filePath: string, label: PemKind): string;
5
+ export {};
@@ -0,0 +1,36 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { ConfigurationError } from '../errors/app-error.js';
3
+ import { maskPath } from '../paths/mask-path.js';
4
+ function expectedPemHeader(kind) {
5
+ return kind === 'certificado' ? '-----BEGIN CERTIFICATE-----' : '-----BEGIN PRIVATE KEY-----';
6
+ }
7
+ function acceptedPemHeaders(kind) {
8
+ if (kind === 'certificado') {
9
+ return ['BEGIN CERTIFICATE'];
10
+ }
11
+ return ['BEGIN PRIVATE KEY', 'BEGIN RSA PRIVATE KEY', 'BEGIN EC PRIVATE KEY', 'BEGIN ENCRYPTED PRIVATE KEY'];
12
+ }
13
+ export function ensurePathExists(filePath, label) {
14
+ if (!existsSync(filePath)) {
15
+ throw new ConfigurationError(`La ruta del ${label} no existe: ${maskPath(filePath)}`, {
16
+ path: maskPath(filePath),
17
+ });
18
+ }
19
+ }
20
+ export function ensurePemFormat(content, filePath, label) {
21
+ const normalizedContent = content.trim();
22
+ const hasAcceptedHeader = acceptedPemHeaders(label).some((header) => normalizedContent.includes(`-----${header}-----`));
23
+ const hasAcceptedFooter = normalizedContent.includes('-----END');
24
+ if (!hasAcceptedHeader || !hasAcceptedFooter) {
25
+ throw new ConfigurationError(`La ${label === 'certificado' ? 'ruta del certificado' : 'ruta de la clave privada'} apunta a un archivo con formato PEM invalido: ${maskPath(filePath)}. Debe contener un bloque como ${expectedPemHeader(label)}.`, {
26
+ path: maskPath(filePath),
27
+ });
28
+ }
29
+ }
30
+ export function readPemFile(filePath, label) {
31
+ ensurePathExists(filePath, label);
32
+ const content = readFileSync(filePath, 'utf8');
33
+ ensurePemFormat(content, filePath, label);
34
+ return content;
35
+ }
36
+ //# sourceMappingURL=pem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pem.js","sourceRoot":"","sources":["../../../src/lib/security/pem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAI9C,SAAS,iBAAiB,CAAC,IAAa;IACtC,OAAO,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,6BAA6B,CAAC;AAChG,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAa;IACvC,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;QAC3B,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,CAAC,mBAAmB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,6BAA6B,CAAC,CAAC;AAC/G,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,KAAc;IAC/D,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,kBAAkB,CAAC,eAAe,KAAK,eAAe,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE;YACpF,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC;SACzB,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,QAAgB,EAAE,KAAc;IAC/E,MAAM,iBAAiB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IACzC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAClE,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,MAAM,OAAO,CAAC,CAClD,CAAC;IACF,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAEjE,IAAI,CAAC,iBAAiB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC7C,MAAM,IAAI,kBAAkB,CAC1B,MAAM,KAAK,KAAK,aAAa,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,0BAA0B,kDAAkD,QAAQ,CAAC,QAAQ,CAAC,kCAAkC,iBAAiB,CAAC,KAAK,CAAC,GAAG,EACpN;YACE,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC;SACzB,CACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAgB,EAAE,KAAc;IAC1D,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAElC,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE/C,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAE1C,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { CreateVoucherResultDto } from '@arcasdk/core/lib/application/dto/electronic-billing';
2
+ import type { BillingResponseSummary } from './billing.types.internal';
3
+ export declare function createDryRunResponse(): BillingResponseSummary;
4
+ export declare function mapBillingResponse(response: CreateVoucherResultDto): BillingResponseSummary;
@@ -0,0 +1,74 @@
1
+ export function createDryRunResponse() {
2
+ return {
3
+ cae: null,
4
+ caeVencimiento: null,
5
+ errors: [],
6
+ events: [],
7
+ observaciones: [],
8
+ observacion: null,
9
+ raw: null,
10
+ resultado: null,
11
+ suggestions: [],
12
+ status: 'observado',
13
+ };
14
+ }
15
+ export function mapBillingResponse(response) {
16
+ const detail = response.response?.FeDetResp?.FECAEDetResponse?.[0];
17
+ const events = response.response?.Events?.Evt ?? [];
18
+ const errors = response.response?.Errors?.Err ?? [];
19
+ const observaciones = detail?.Observaciones?.Obs?.map((item) => item.Msg).filter((msg) => Boolean(msg)) ?? [];
20
+ const resultado = detail?.Resultado ?? null;
21
+ const suggestions = buildResponseSuggestions({
22
+ errors,
23
+ observaciones,
24
+ resultado,
25
+ });
26
+ return {
27
+ cae: response.cae ?? null,
28
+ caeVencimiento: response.caeFchVto ?? null,
29
+ errors,
30
+ events,
31
+ observaciones,
32
+ observacion: observaciones.join(' | ') || null,
33
+ raw: response,
34
+ resultado,
35
+ suggestions,
36
+ status: resolveBillingStatus({
37
+ errors,
38
+ observaciones,
39
+ resultado,
40
+ }),
41
+ };
42
+ }
43
+ function buildResponseSuggestions(options) {
44
+ const messages = [
45
+ ...options.observaciones,
46
+ ...options.errors
47
+ .map((error) => typeof error === 'object' && error && 'Msg' in error ? String(error.Msg ?? '') : '')
48
+ .filter(Boolean),
49
+ ].join(' | ');
50
+ const suggestions = new Set();
51
+ if (/transacci[oó]n activa/i.test(messages) || /error interno de base de datos/i.test(messages)) {
52
+ suggestions.add('ARCA devolvio un error transitorio. Espere unos segundos y vuelva a intentar la emision.');
53
+ }
54
+ if (/cuit receptora.*no existe/i.test(messages)) {
55
+ suggestions.add('Revise el CUIT del receptor o emita con un receptor valido del padron para testing.');
56
+ }
57
+ if (/objeto IVA es obligatorio/i.test(messages)) {
58
+ suggestions.add('Revise IVA receptor y el calculo de IVA del comprobante antes de reintentar.');
59
+ }
60
+ if (options.resultado === 'R' && suggestions.size === 0) {
61
+ suggestions.add('Revise observaciones y errores de ARCA antes de volver a emitir.');
62
+ }
63
+ return [...suggestions];
64
+ }
65
+ function resolveBillingStatus(options) {
66
+ if (options.resultado === 'R' || options.errors.length > 0) {
67
+ return 'rechazado';
68
+ }
69
+ if (options.resultado === 'A' && options.observaciones.length === 0) {
70
+ return 'aprobado';
71
+ }
72
+ return 'observado';
73
+ }
74
+ //# sourceMappingURL=billing-response.js.map
@@ -0,0 +1 @@
1
+ {"version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C;AAC1B,CAAC;AAED,SAAS,oBAAoB,CAAC,OAI7B;IACC,IAAI,OAAO,CAAC,SAAS,KAAK,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3D,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,KAAK,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpE,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { IIva } from '@arcasdk/core/lib/domain/types/voucher.types';
2
+ import type { BillingCommandInput, BillingIvaRate } from './billing.schemas';
3
+ import type { VoucherKindDefinition } from './billing.types';
4
+ export declare const DEFAULT_IVA_RATE: BillingIvaRate;
5
+ export interface TaxAmounts {
6
+ readonly exemptAmount: number;
7
+ readonly iva?: IIva[];
8
+ readonly ivaAmount: number;
9
+ readonly netAmount: number;
10
+ readonly untaxedAmount: number;
11
+ }
12
+ type TaxAmountsInput = Pick<BillingCommandInput, 'exemptAmount' | 'ivaRate' | 'totalAmount' | 'untaxedAmount'>;
13
+ export declare function resolveIvaRateLabel(aliquotId: number): string | undefined;
14
+ /**
15
+ * Reparte el total entre no gravado, exento, neto gravado e IVA.
16
+ * ImpTotal = ImpTotConc + ImpOpEx + ImpNeto + ImpIVA (10048); la C no informa IVA (10071).
17
+ */
18
+ export declare function resolveTaxAmounts(input: TaxAmountsInput, voucherKind: VoucherKindDefinition): TaxAmounts;
19
+ export {};
@@ -0,0 +1,72 @@
1
+ import Big from 'big.js';
2
+ import { InputValidationError } from '../../lib/errors/app-error.js';
3
+ import { formatVoucherLabel } from './billing.mappers.js';
4
+ /** Ids de alicuota de FEParamGetTiposIva. */
5
+ const IVA_RATE_DEFINITIONS = {
6
+ '0': { id: 3, rate: '0' },
7
+ '2.5': { id: 9, rate: '0.025' },
8
+ '5': { id: 8, rate: '0.05' },
9
+ '10.5': { id: 4, rate: '0.105' },
10
+ '21': { id: 5, rate: '0.21' },
11
+ '27': { id: 6, rate: '0.27' },
12
+ };
13
+ export const DEFAULT_IVA_RATE = '21';
14
+ export function resolveIvaRateLabel(aliquotId) {
15
+ const entry = Object.entries(IVA_RATE_DEFINITIONS).find(([, definition]) => definition.id === aliquotId);
16
+ return entry ? `${entry[0].replace('.', ',')}%` : undefined;
17
+ }
18
+ function validateLetterCAmounts(input, voucherKind) {
19
+ const flags = [
20
+ input.ivaRate ? '--alicuota' : undefined,
21
+ input.exemptAmount ? '--exento' : undefined,
22
+ input.untaxedAmount ? '--nogravado' : undefined,
23
+ ].filter((flag) => Boolean(flag));
24
+ if (flags.length > 0) {
25
+ throw new InputValidationError(`La ${formatVoucherLabel(voucherKind)} no discrimina IVA ni importes exentos o no gravados. Quite ${flags.join(', ')}.`);
26
+ }
27
+ }
28
+ /**
29
+ * Reparte el total entre no gravado, exento, neto gravado e IVA.
30
+ * ImpTotal = ImpTotConc + ImpOpEx + ImpNeto + ImpIVA (10048); la C no informa IVA (10071).
31
+ */
32
+ export function resolveTaxAmounts(input, voucherKind) {
33
+ if (voucherKind.letter === 'c') {
34
+ validateLetterCAmounts(input, voucherKind);
35
+ return {
36
+ exemptAmount: 0,
37
+ ivaAmount: 0,
38
+ netAmount: input.totalAmount,
39
+ untaxedAmount: 0,
40
+ };
41
+ }
42
+ const exemptAmount = input.exemptAmount ?? 0;
43
+ const untaxedAmount = input.untaxedAmount ?? 0;
44
+ const taxedTotal = new Big(input.totalAmount).minus(exemptAmount).minus(untaxedAmount);
45
+ if (taxedTotal.lt(0)) {
46
+ throw new InputValidationError('El importe exento mas el no gravado no puede superar el monto total.');
47
+ }
48
+ if (taxedTotal.eq(0)) {
49
+ return { exemptAmount, ivaAmount: 0, netAmount: 0, untaxedAmount };
50
+ }
51
+ const definition = IVA_RATE_DEFINITIONS[input.ivaRate ?? DEFAULT_IVA_RATE];
52
+ const netAmount = roundAmount(taxedTotal.div(new Big(1).plus(definition.rate)));
53
+ const ivaAmount = roundAmount(taxedTotal.minus(netAmount));
54
+ // Con neto mayor a cero el array de IVA es obligatorio, incluso al 0% (10070).
55
+ return {
56
+ exemptAmount,
57
+ iva: [
58
+ {
59
+ BaseImp: netAmount,
60
+ Id: definition.id,
61
+ Importe: ivaAmount,
62
+ },
63
+ ],
64
+ ivaAmount,
65
+ netAmount,
66
+ untaxedAmount,
67
+ };
68
+ }
69
+ function roundAmount(value) {
70
+ return value.round(2, Big.roundHalfUp).toNumber();
71
+ }
72
+ //# sourceMappingURL=billing.amounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.amounts.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.amounts.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,QAAQ,CAAC;AAEzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAIvD,6CAA6C;AAC7C,MAAM,oBAAoB,GAA2E;IACnG,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE;IACzB,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;IAC/B,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;IAC5B,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;IAChC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;IAC7B,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAmB,IAAI,CAAC;AAYrD,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,MAAM,KAAK,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PeriodoAsoc } from '@arcasdk/core/lib/domain/types/voucher.types';
2
+ import type { BillingCommandInput } from './billing.schemas';
3
+ import type { VoucherKindDefinition } from './billing.types';
4
+ /**
5
+ * PeriodoAsoc es la alternativa a CbtesAsoc para NC/ND que ajustan un periodo y no una factura puntual (10197).
6
+ * No aplica a facturas (10198) ni a comprobantes FCE (10196).
7
+ */
8
+ export declare function resolveAssociatedPeriod(input: Pick<BillingCommandInput, 'associatedPeriod' | 'associatedVoucher'>, voucherKind: VoucherKindDefinition, billingDate: string): IPeriodoAsoc | undefined;
@@ -0,0 +1,40 @@
1
+ import { formatArcaDateAsArgentineDate, parseArgentineDateInputAsArcaDate } from '../../lib/dates/arca-date.js';
2
+ import { InputValidationError } from '../../lib/errors/app-error.js';
3
+ import { formatVoucherLabel } from './billing.mappers.js';
4
+ const MINIMUM_PERIOD_DATE = '20060101';
5
+ /**
6
+ * PeriodoAsoc es la alternativa a CbtesAsoc para NC/ND que ajustan un periodo y no una factura puntual (10197).
7
+ * No aplica a facturas (10198) ni a comprobantes FCE (10196).
8
+ */
9
+ export function resolveAssociatedPeriod(input, voucherKind, billingDate) {
10
+ const period = input.associatedPeriod;
11
+ if (!period) {
12
+ return undefined;
13
+ }
14
+ const label = formatVoucherLabel(voucherKind);
15
+ if (!voucherKind.requiresAssociatedVoucher) {
16
+ throw new InputValidationError(`La ${label} no usa periodo asociado: solo aplica a notas de credito o debito.`);
17
+ }
18
+ if (voucherKind.isElectronicCredit) {
19
+ throw new InputValidationError(`La ${label} no admite periodo asociado: ARCA solo lo acepta en notas comunes. Use el comprobante asociado (--ac).`);
20
+ }
21
+ if (input.associatedVoucher) {
22
+ throw new InputValidationError('Use un comprobante asociado (--ac/--at) o un periodo asociado (--periodo-desde/--periodo-hasta), pero no ambos.');
23
+ }
24
+ if (!period.desde || !period.hasta) {
25
+ throw new InputValidationError('El periodo asociado requiere ambas fechas: --periodo-desde y --periodo-hasta.');
26
+ }
27
+ const FchDesde = parseArgentineDateInputAsArcaDate(period.desde);
28
+ const FchHasta = parseArgentineDateInputAsArcaDate(period.hasta);
29
+ if (FchDesde < MINIMUM_PERIOD_DATE) {
30
+ throw new InputValidationError('El periodo asociado tiene que ser posterior al 01/01/2006.');
31
+ }
32
+ if (FchDesde > FchHasta) {
33
+ throw new InputValidationError('En el periodo asociado, --periodo-desde no puede ser posterior a --periodo-hasta.');
34
+ }
35
+ if (FchHasta > billingDate) {
36
+ throw new InputValidationError(`El periodo asociado no puede terminar despues de la fecha de la ${label} (${formatArcaDateAsArgentineDate(billingDate)}).`);
37
+ }
38
+ return { FchDesde, FchHasta };
39
+ }
40
+ //# sourceMappingURL=billing.associated-period.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.associated-period.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.associated-period.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAC7G,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAIvD,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAA0E,EAC1E,WAAkC,EAClC,WAAmB;IAEnB,MAAM,MAAM,GAAG,KAAK,CAAC,gBAAgB,CAAC;IAEtC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAE9C,IAAI,CAAC,WAAW,CAAC,yBAAyB,EAAE,CAAC;QAC3C,MAAM,IAAI,oBAAoB,CAAC,MAAM,KAAK,oEAAoE,CAAC,CAAC;IAClH,CAAC;IAED,IAAI,WAAW,CAAC,kBAAkB,EAAE,CAAC;QACnC,MAAM,IAAI,oBAAoB,CAC5B,MAAM,KAAK,wGAAwG,CACpH,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC5B,MAAM,IAAI,oBAAoB,CAC5B,iHAAiH,CAClH,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACnC,MAAM,IAAI,oBAAoB,CAAC,+EAA+E,CAAC,CAAC;IAClH,CAAC;IAED,MAAM,QAAQ,GAAG,iCAAiC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,iCAAiC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEjE,IAAI,QAAQ,GAAG,mBAAmB,EAAE,CAAC;QACnC,MAAM,IAAI,oBAAoB,CAAC,4DAA4D,CAAC,CAAC;IAC/F,CAAC;IAED,IAAI,QAAQ,GAAG,QAAQ,EAAE,CAAC;QACxB,MAAM,IAAI,oBAAoB,CAAC,mFAAmF,CAAC,CAAC;IACtH,CAAC;IAED,IAAI,QAAQ,GAAG,WAAW,EAAE,CAAC;QAC3B,MAAM,IAAI,oBAAoB,CAC5B,mEAAmE,KAAK,KAAK,6BAA6B,CAAC,WAAW,CAAC,IAAI,CAC5H,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ICbtesAsoc } from '@arcasdk/core/lib/domain/types/voucher.types';
2
+ import type { BillingCommandInput } from './billing.schemas';
3
+ import type { VoucherKindDefinition } from './billing.types';
4
+ interface ResolveAssociatedVoucherOptions {
5
+ readonly billingDate: string;
6
+ readonly emitterCuit: number;
7
+ readonly input: BillingCommandInput;
8
+ readonly requireVoucherKind: (shortcut: string) => VoucherKindDefinition;
9
+ readonly voucherKind: VoucherKindDefinition;
10
+ }
11
+ export declare function resolveAssociatedVouchers(options: ResolveAssociatedVoucherOptions): ICbtesAsoc[] | undefined;
12
+ export {};
@@ -0,0 +1,73 @@
1
+ import { formatArcaDateAsArgentineDate, parseArgentineDateInputAsArcaDate } from '../../lib/dates/arca-date.js';
2
+ import { InputValidationError } from '../../lib/errors/app-error.js';
3
+ import { formatVoucherLabel } from './billing.mappers.js';
4
+ export function resolveAssociatedVouchers(options) {
5
+ const { billingDate, emitterCuit, input, requireVoucherKind, voucherKind } = options;
6
+ if (!voucherKind.requiresAssociatedVoucher) {
7
+ if (input.associatedVoucher) {
8
+ throw new InputValidationError(`El comprobante ${formatVoucherLabel(voucherKind)} no usa comprobante asociado.`);
9
+ }
10
+ return undefined;
11
+ }
12
+ // Con periodo asociado la nota no lleva CbtesAsoc; lo valida resolveAssociatedPeriod.
13
+ if (input.associatedPeriod && !input.associatedVoucher) {
14
+ return undefined;
15
+ }
16
+ const associatedVoucher = input.associatedVoucher;
17
+ // En NC/ND FCE el asociado siempre es del propio emisor (10155), asi que el CUIT puede omitirse.
18
+ const associatedCuit = associatedVoucher?.cuit ?? (voucherKind.isElectronicCredit ? String(emitterCuit) : undefined);
19
+ const associatedVoucherType = associatedVoucher?.tipo ?? resolveAssociatedVoucherType(associatedVoucher?.shortcut, requireVoucherKind);
20
+ const associatedVoucherKind = associatedVoucher?.shortcut
21
+ ? requireVoucherKind(associatedVoucher.shortcut)
22
+ : undefined;
23
+ if (!associatedVoucher?.numero || !associatedVoucher.puntoVenta || !associatedVoucherType || !associatedCuit) {
24
+ throw new InputValidationError(`El comprobante ${formatVoucherLabel(voucherKind)} requiere comprobante asociado. Use --ac o --at, junto con --apv o --asociado-punto-venta, --ar y --acuit${voucherKind.isElectronicCredit ? '' : ', o un periodo con --periodo-desde y --periodo-hasta'}.`);
25
+ }
26
+ if (associatedVoucherKind) {
27
+ validateAssociatedVoucherKind(associatedVoucherKind, voucherKind);
28
+ }
29
+ if (voucherKind.isElectronicCredit && associatedCuit !== String(emitterCuit)) {
30
+ throw new InputValidationError(`En la ${formatVoucherLabel(voucherKind)} el comprobante asociado tiene que ser del CUIT emisor (${emitterCuit}). Quite --acuit o use ese CUIT.`);
31
+ }
32
+ const associatedDate = resolveAssociatedVoucherDate(associatedVoucher.fecha, billingDate, voucherKind);
33
+ return [
34
+ {
35
+ ...(associatedDate ? { CbteFch: associatedDate } : {}),
36
+ Cuit: associatedCuit,
37
+ Nro: associatedVoucher.numero,
38
+ PtoVta: associatedVoucher.puntoVenta,
39
+ Tipo: associatedVoucherType,
40
+ },
41
+ ];
42
+ }
43
+ function resolveAssociatedVoucherDate(rawDate, billingDate, voucherKind) {
44
+ if (!rawDate) {
45
+ if (voucherKind.isElectronicCredit) {
46
+ throw new InputValidationError(`La ${formatVoucherLabel(voucherKind)} requiere la fecha del comprobante asociado. Use --afecha <fecha>.`);
47
+ }
48
+ return undefined;
49
+ }
50
+ const associatedDate = parseArgentineDateInputAsArcaDate(rawDate);
51
+ if (associatedDate > billingDate) {
52
+ throw new InputValidationError(`La fecha del comprobante asociado (${formatArcaDateAsArgentineDate(associatedDate)}) no puede ser posterior a la de la ${formatVoucherLabel(voucherKind)} (${formatArcaDateAsArgentineDate(billingDate)}).`);
53
+ }
54
+ return associatedDate;
55
+ }
56
+ function resolveAssociatedVoucherType(shortcut, requireVoucherKind) {
57
+ if (!shortcut) {
58
+ return undefined;
59
+ }
60
+ return requireVoucherKind(shortcut).arcaType;
61
+ }
62
+ function validateAssociatedVoucherKind(associatedVoucherKind, voucherKind) {
63
+ if (associatedVoucherKind.family !== 'factura' && associatedVoucherKind.family !== 'factura-credito-electronica') {
64
+ throw new InputValidationError(`El comprobante asociado de ${formatVoucherLabel(voucherKind)} debe ser una factura, no otra nota.`);
65
+ }
66
+ if (associatedVoucherKind.letter !== voucherKind.letter) {
67
+ throw new InputValidationError(`El comprobante asociado debe usar la misma letra que ${formatVoucherLabel(voucherKind)}.`);
68
+ }
69
+ if (associatedVoucherKind.isElectronicCredit !== voucherKind.isElectronicCredit) {
70
+ throw new InputValidationError(`El comprobante asociado debe pertenecer a la misma categoria electronica que ${formatVoucherLabel(voucherKind)}.`);
71
+ }
72
+ }
73
+ //# sourceMappingURL=billing.associated-vouchers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.associated-vouchers.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.associated-vouchers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAC7G,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAYvD,MAAM,UAAU,yBAAyB,CAAC,OAAwC;IAChF,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAErF,IAAI,CAAC,WAAW,CAAC,yBAAyB,EAAE,CAAC;QAC3C,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,MAAM,IAAI,oBAAoB,CAAC,kBAAkB,kBAAkB,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAC;QACnH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,sFAAsF;IACtF,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;QACvD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IAClD,iGAAiG;IACjG,MAAM,cAAc,GAAG,iBAAiB,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACrH,MAAM,qBAAqB,GACzB,iBAAiB,EAAE,IAAI,IAAI,4BAA4B,CAAC,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAC3G,MAAM,qBAAqB,GAAG,iBAAiB,EAAE,QAA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