facturas 0.15.0 → 0.16.1

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/README.md CHANGED
@@ -62,7 +62,7 @@ Tratá siempre los cuatro resultados:
62
62
 
63
63
  | Resultado | Qué significa y qué hacer |
64
64
  | --- | --- |
65
- | `authorized` | Guardá el comprobante, el CAE y el `qr` para imprimir. `recoveredByMatch: true` significa que el input guardado coincidió con la identidad consultada. Esto prueba consistencia, no autoría. |
65
+ | `authorized` | Guardá el comprobante, el CAE, `voucher.header` y el `qr` para imprimir. La cabecera tiene el mismo formato en una autorización directa o recuperada. `recoveredByMatch: true` significa que el input guardado coincidió con la identidad consultada. Esto prueba consistencia, no autoría. |
66
66
  | `rejected` | Revisá los `issues` de ARCA. Una clave queda ligada a su input incluso después de un rechazo. |
67
67
  | `indeterminate` | Conservá el número y la evidencia. Conciliá o repetí el input idéntico con su clave existente. |
68
68
  | `conflict` | Hay otro comprobante en el número reservado. Detené el flujo e investigá. |
@@ -3661,6 +3661,7 @@ function toPreview(prepared, options) {
3661
3661
  return {
3662
3662
  voucherClass,
3663
3663
  voucherType: data.voucherType,
3664
+ header: fiscalHeader(data),
3664
3665
  amounts,
3665
3666
  request: options.service === "wsmtxca" ? wsmtxcaRequest(data) : data,
3666
3667
  ...options.service === "wsmtxca" ? { service: "wsmtxca" } : {}
@@ -4035,10 +4036,11 @@ async function runAuthorization(wsfe, { data, voucherClass, amounts }, options,
4035
4036
  number
4036
4037
  };
4037
4038
  const includedRequest = requestEvidence(data, number, options);
4038
- const voucher = (cae, caeExpiry) => issuedVoucher(
4039
+ const voucher = (cae, caeExpiry, lookup) => issuedVoucher(
4039
4040
  { attempted, voucherClass, data, amounts, taxId },
4040
4041
  cae,
4041
- caeExpiry
4042
+ caeExpiry,
4043
+ lookup
4042
4044
  );
4043
4045
  const recovery = {
4044
4046
  wsfe,
@@ -4228,15 +4230,17 @@ async function recoverInvoice({
4228
4230
  ...includedRequest
4229
4231
  };
4230
4232
  }
4233
+ const lookupSummary = toVoucherSummary(lookup.voucher);
4231
4234
  return {
4232
4235
  kind: "authorized",
4233
4236
  recoveredByMatch: true,
4234
4237
  voucher: voucher(
4235
4238
  lookup.voucher.cae,
4236
- lookup.voucher.caeExpiry
4239
+ lookup.voucher.caeExpiry,
4240
+ lookupSummary
4237
4241
  ),
4238
4242
  attempt,
4239
- lookup: { ...toVoucherSummary(lookup.voucher), ...rawResponse },
4243
+ lookup: { ...lookupSummary, ...rawResponse },
4240
4244
  ...includedRequest
4241
4245
  };
4242
4246
  }
@@ -4630,7 +4634,7 @@ function consultReservation(select, record, options, taxId, strangerAtNumber = f
4630
4634
  record.number,
4631
4635
  storedOptions
4632
4636
  ),
4633
- voucher: (cae, caeExpiry) => issuedVoucher(
4637
+ voucher: (cae, caeExpiry, lookup) => issuedVoucher(
4634
4638
  {
4635
4639
  attempted,
4636
4640
  voucherClass: prepared.voucherClass,
@@ -4639,7 +4643,8 @@ function consultReservation(select, record, options, taxId, strangerAtNumber = f
4639
4643
  taxId: record.representedTaxId ?? taxId
4640
4644
  },
4641
4645
  cae,
4642
- caeExpiry
4646
+ caeExpiry,
4647
+ lookup
4643
4648
  )
4644
4649
  });
4645
4650
  }
@@ -4652,19 +4657,48 @@ function issuedVoucher({
4652
4657
  data,
4653
4658
  amounts,
4654
4659
  taxId
4655
- }, cae, caeExpiry) {
4660
+ }, cae, caeExpiry, lookup) {
4656
4661
  const date = toIsoDate(data.voucherDate) ?? data.voucherDate;
4657
4662
  const qr = voucherQr({ attempted, data, taxId, date, cae });
4658
4663
  return {
4659
4664
  ...attempted,
4660
4665
  voucherClass,
4661
4666
  date,
4667
+ header: fiscalHeader(data, lookup),
4662
4668
  cae,
4663
4669
  caeExpiry: toIsoDate(caeExpiry) ?? caeExpiry,
4664
4670
  amounts,
4665
4671
  ...qr === void 0 ? {} : { qr }
4666
4672
  };
4667
4673
  }
4674
+ function fiscalHeader(data, lookup) {
4675
+ const sent = normalizeWsfeVoucherInput(data);
4676
+ const header = {
4677
+ concept: lookup?.concept ?? sent.concept,
4678
+ documentType: lookup?.documentType ?? sent.documentType,
4679
+ documentNumber: String(lookup?.documentNumber ?? sent.documentNumber),
4680
+ receiverVatConditionId: lookup?.receiverVatConditionId ?? sent.receiverVatConditionId,
4681
+ currencyId: lookup?.currencyId ?? sent.currencyId
4682
+ };
4683
+ const exchangeRate2 = lookup?.exchangeRate ?? sent.exchangeRate;
4684
+ if (exchangeRate2 !== void 0) {
4685
+ header.exchangeRate = serializeArcaExchangeRate(
4686
+ exchangeRate2,
4687
+ "exchangeRate"
4688
+ );
4689
+ }
4690
+ for (const field of [
4691
+ "serviceStartDate",
4692
+ "serviceEndDate",
4693
+ "paymentDueDate"
4694
+ ]) {
4695
+ const date = toIsoDate(lookup?.[field]) ?? toIsoDate(sent[field]);
4696
+ if (date !== void 0) {
4697
+ header[field] = date;
4698
+ }
4699
+ }
4700
+ return header;
4701
+ }
4668
4702
  function voucherQr({
4669
4703
  attempted,
4670
4704
  data,
@@ -5299,4 +5333,4 @@ export {
5299
5333
  withLease,
5300
5334
  createFileStore
5301
5335
  };
5302
- //# sourceMappingURL=chunk-6XQTT3GH.mjs.map
5336
+ //# sourceMappingURL=chunk-5O2FESHA.mjs.map