facturas 0.26.1 → 0.28.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/dist/{chunk-FVTQIAZ4.mjs → chunk-D3Z4RZTH.mjs} +93 -7
- package/dist/{chunk-FVTQIAZ4.mjs.map → chunk-D3Z4RZTH.mjs.map} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/docs/getting-started/arca-setup.md +106 -0
- package/docs/getting-started/cli.md +165 -0
- package/docs/getting-started/quickstart.md +214 -0
- package/docs/guides/avoid-duplicates.md +240 -0
- package/docs/guides/credit-notes.md +342 -0
- package/docs/guides/export.md +156 -0
- package/docs/guides/invoices.md +360 -0
- package/docs/guides/printed-voucher.md +334 -0
- package/docs/guides/production.md +110 -0
- package/docs/guides/taxpayers.md +127 -0
- package/docs/guides/wsmtxca.md +180 -0
- package/docs/llms.txt +65 -0
- package/docs/reference/arca-services.md +129 -0
- package/docs/reference/cli.md +521 -0
- package/docs/reference/client.md +304 -0
- package/docs/reference/configuration.md +161 -0
- package/docs/reference/errors.md +162 -0
- package/docs/reference/examples.md +23 -0
- package/docs/reference/public-api.md +142 -0
- package/package.json +4 -2
- package/skills/facturas/SKILL.md +293 -0
|
@@ -6714,7 +6714,8 @@ async function consultKey({ store, environment, taxId, idempotencyKey }, stored,
|
|
|
6714
6714
|
readSettledRecord(recorded),
|
|
6715
6715
|
options,
|
|
6716
6716
|
taxId,
|
|
6717
|
-
(owner, other) => storeCall(() => store.get(settledKey(environment, owner, other)))
|
|
6717
|
+
(owner, other) => storeCall(() => store.get(settledKey(environment, owner, other))),
|
|
6718
|
+
(owner, other) => storeCall(() => store.get(attemptKey(environment, owner, other)))
|
|
6718
6719
|
);
|
|
6719
6720
|
};
|
|
6720
6721
|
if (locked || !store.withLock) {
|
|
@@ -6764,19 +6765,44 @@ function readSettledRecord(json) {
|
|
|
6764
6765
|
);
|
|
6765
6766
|
}
|
|
6766
6767
|
}
|
|
6767
|
-
async function settledOutcome(select, reservation, settled2, options, taxId, settledFor) {
|
|
6768
|
+
async function settledOutcome(select, reservation, settled2, options, taxId, settledFor, reservedFor) {
|
|
6768
6769
|
if (settled2.kind === "conflict") {
|
|
6769
6770
|
return settledConflict(settled2, reservation, options);
|
|
6770
6771
|
}
|
|
6772
|
+
const once = lookupOnce(select);
|
|
6771
6773
|
const outcome = await consultReservation2(
|
|
6772
|
-
|
|
6774
|
+
once,
|
|
6773
6775
|
reservation,
|
|
6774
6776
|
options,
|
|
6775
6777
|
taxId,
|
|
6776
6778
|
true
|
|
6777
6779
|
);
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
+
if (outcome.kind === "indeterminate") {
|
|
6781
|
+
return outcome.lookup.kind === "not_found" ? withheld(
|
|
6782
|
+
reservation,
|
|
6783
|
+
{
|
|
6784
|
+
kind: "blocked",
|
|
6785
|
+
by: settled2.by,
|
|
6786
|
+
byTaxId: settled2.byTaxId ?? taxId
|
|
6787
|
+
},
|
|
6788
|
+
options,
|
|
6789
|
+
settled2.number
|
|
6790
|
+
) : outcome;
|
|
6791
|
+
}
|
|
6792
|
+
const own = await ownLateWrite(
|
|
6793
|
+
once,
|
|
6794
|
+
reservation,
|
|
6795
|
+
settled2,
|
|
6796
|
+
outcome,
|
|
6797
|
+
options,
|
|
6798
|
+
taxId,
|
|
6799
|
+
settledFor,
|
|
6800
|
+
reservedFor
|
|
6801
|
+
);
|
|
6802
|
+
if (own !== void 0) {
|
|
6803
|
+
return own;
|
|
6804
|
+
}
|
|
6805
|
+
if (outcome.kind !== "conflict" || await successionDisputed(settled2, taxId, settledFor)) {
|
|
6780
6806
|
return outcome;
|
|
6781
6807
|
}
|
|
6782
6808
|
return withheld(
|
|
@@ -6806,6 +6832,66 @@ function reservationEvidence(reservation, options) {
|
|
|
6806
6832
|
{ ...options, service: reservation.service ?? "wsfe" }
|
|
6807
6833
|
);
|
|
6808
6834
|
}
|
|
6835
|
+
async function ownLateWrite(select, reservation, settled2, found, options, taxId, settledFor, reservedFor) {
|
|
6836
|
+
const own = await consultReservation2(select, reservation, options, taxId);
|
|
6837
|
+
if (own.kind !== "authorized") {
|
|
6838
|
+
return;
|
|
6839
|
+
}
|
|
6840
|
+
let owner = settled2.byTaxId ?? taxId;
|
|
6841
|
+
let next = settled2.by;
|
|
6842
|
+
let released = false;
|
|
6843
|
+
for (let hop = 0; hop < 16; hop += 1) {
|
|
6844
|
+
const json = await reservedFor(owner, next);
|
|
6845
|
+
if (json === null) {
|
|
6846
|
+
return;
|
|
6847
|
+
}
|
|
6848
|
+
const record = readRecord(json);
|
|
6849
|
+
const theirs = await consultReservation2(
|
|
6850
|
+
select,
|
|
6851
|
+
{ ...record, number: settled2.number },
|
|
6852
|
+
options,
|
|
6853
|
+
owner
|
|
6854
|
+
);
|
|
6855
|
+
if (theirs.kind === "authorized") {
|
|
6856
|
+
return;
|
|
6857
|
+
}
|
|
6858
|
+
if (theirs.kind === "indeterminate") {
|
|
6859
|
+
return theirs;
|
|
6860
|
+
}
|
|
6861
|
+
released ||= record.rejectedAt !== void 0;
|
|
6862
|
+
const after = await settledFor(owner, next);
|
|
6863
|
+
const successor = after === null ? null : readSettledRecord(after);
|
|
6864
|
+
if (successor?.kind !== "superseded") {
|
|
6865
|
+
return released ? found : own;
|
|
6866
|
+
}
|
|
6867
|
+
owner = successor.byTaxId ?? owner;
|
|
6868
|
+
next = successor.by;
|
|
6869
|
+
}
|
|
6870
|
+
}
|
|
6871
|
+
function lookupOnce(select) {
|
|
6872
|
+
const lookups = /* @__PURE__ */ new Map();
|
|
6873
|
+
return (options) => {
|
|
6874
|
+
const wsfe = select(options);
|
|
6875
|
+
return {
|
|
6876
|
+
getNextVoucherNumber: (input) => wsfe.getNextVoucherNumber(input),
|
|
6877
|
+
issue: (input) => wsfe.issue(input),
|
|
6878
|
+
lookupVoucher: (input) => {
|
|
6879
|
+
const key = JSON.stringify([
|
|
6880
|
+
options.service ?? "wsfe",
|
|
6881
|
+
input.salesPoint,
|
|
6882
|
+
input.voucherType,
|
|
6883
|
+
input.number
|
|
6884
|
+
]);
|
|
6885
|
+
let lookup = lookups.get(key);
|
|
6886
|
+
if (lookup === void 0) {
|
|
6887
|
+
lookup = wsfe.lookupVoucher(input);
|
|
6888
|
+
lookups.set(key, lookup);
|
|
6889
|
+
}
|
|
6890
|
+
return lookup;
|
|
6891
|
+
}
|
|
6892
|
+
};
|
|
6893
|
+
};
|
|
6894
|
+
}
|
|
6809
6895
|
async function successionDisputed(superseded, taxId, settledFor) {
|
|
6810
6896
|
let owner = superseded.byTaxId ?? taxId;
|
|
6811
6897
|
let next = superseded.by;
|
|
@@ -7035,7 +7121,7 @@ async function resolveRejection(authorization, recovery, options, includeRawResp
|
|
|
7035
7121
|
),
|
|
7036
7122
|
strangerAtNumber
|
|
7037
7123
|
});
|
|
7038
|
-
if (recovered.kind === "authorized" || recovered.kind === "conflict") {
|
|
7124
|
+
if (recovered.kind === "authorized" || recovered.kind === "conflict" || !strangerAtNumber && recovered.kind === "indeterminate" && (recovered.lookup.kind === "failed" || recovered.lookup.kind === "aborted")) {
|
|
7039
7125
|
return recovered;
|
|
7040
7126
|
}
|
|
7041
7127
|
}
|
|
@@ -8344,4 +8430,4 @@ export {
|
|
|
8344
8430
|
createArcaClient,
|
|
8345
8431
|
createFileStore
|
|
8346
8432
|
};
|
|
8347
|
-
//# sourceMappingURL=chunk-
|
|
8433
|
+
//# sourceMappingURL=chunk-D3Z4RZTH.mjs.map
|