platform-types 1.10.826 → 1.10.828
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/cjs/return.js +13 -1
- package/dist/purchaseWithdrawal.d.ts +2 -1
- package/dist/return.d.ts +130 -2
- package/dist/return.js +12 -0
- package/dist/rma.d.ts +17 -0
- package/package.json +1 -1
package/dist/cjs/return.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RETURN_REASON_FLOWS = exports.RETURN_FLOWS = exports.RETURN_LINE_DISPOSITIONS = void 0;
|
|
3
|
+
exports.RETURN_SERVER_CREDIT_NOTE_FLOWS = exports.RETURN_REASON_FLOWS = exports.RETURN_FLOWS = exports.RETURN_LINE_DISPOSITIONS = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Every state a returned line's physical disposition can be in, as a runtime
|
|
6
6
|
* value so the api's Zod enum, the app's picker and the union below derive
|
|
@@ -33,3 +33,15 @@ exports.RETURN_REASON_FLOWS = {
|
|
|
33
33
|
billing_error: 'administrative',
|
|
34
34
|
other: 'administrative',
|
|
35
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* The flows in which the SERVER decides a return's credit note: every flow but
|
|
38
|
+
* `administrative`. Each of them is a refund of value, so on an order holding a
|
|
39
|
+
* live domestic factura with credit left to give the note is required — see
|
|
40
|
+
* {@link CreateReturnRequest.emitCreditNote}. `administrative` keeps the
|
|
41
|
+
* client's flag.
|
|
42
|
+
*/
|
|
43
|
+
exports.RETURN_SERVER_CREDIT_NOTE_FLOWS = [
|
|
44
|
+
'purchase-withdrawal',
|
|
45
|
+
'change-of-mind',
|
|
46
|
+
'warranty',
|
|
47
|
+
];
|
|
@@ -143,7 +143,8 @@ declare global {
|
|
|
143
143
|
* `purchase-withdrawal-received` mail is queued after the commit and
|
|
144
144
|
* stamps `emailQueuedAt`, and the mail worker records `emailStatus`:
|
|
145
145
|
* `sent`, or `not-sent` when the order's customer has no address to mail
|
|
146
|
-
* or the send was refused for good (a suppressed address included)
|
|
146
|
+
* or the send was refused for good (a suppressed address included), or
|
|
147
|
+
* when an operator decided the request before the mail went out.
|
|
147
148
|
*/
|
|
148
149
|
interface PurchaseWithdrawalAcknowledgement {
|
|
149
150
|
/** Unix ms. */
|
package/dist/return.d.ts
CHANGED
|
@@ -17,8 +17,87 @@ export declare const RETURN_FLOWS: readonly ["purchase-withdrawal", "change-of-m
|
|
|
17
17
|
export declare const RETURN_REASON_FLOWS: {
|
|
18
18
|
readonly [R in ReturnReason]: Exclude<ReturnFlow, 'purchase-withdrawal'>;
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* The flows in which the SERVER decides a return's credit note: every flow but
|
|
22
|
+
* `administrative`. Each of them is a refund of value, so on an order holding a
|
|
23
|
+
* live domestic factura with credit left to give the note is required — see
|
|
24
|
+
* {@link CreateReturnRequest.emitCreditNote}. `administrative` keeps the
|
|
25
|
+
* client's flag.
|
|
26
|
+
*/
|
|
27
|
+
export declare const RETURN_SERVER_CREDIT_NOTE_FLOWS: readonly ["purchase-withdrawal", "change-of-mind", "warranty"];
|
|
20
28
|
declare global {
|
|
21
29
|
type ReturnFlow = (typeof RETURN_FLOWS)[number];
|
|
30
|
+
/**
|
|
31
|
+
* Why `409 RETURN_FISCAL_IN_FLIGHT` asks the return to wait. No return was
|
|
32
|
+
* written (one answered at commit, when a factura took the fence after the
|
|
33
|
+
* read, has burned a return id); the same request (same `requestId`) may be
|
|
34
|
+
* resent. Checked on
|
|
35
|
+
* every server-decided flow (`RETURN_SERVER_CREDIT_NOTE_FLOWS`), whether or not
|
|
36
|
+
* the order holds a factura yet — the order's first factura is exactly the one
|
|
37
|
+
* still in flight.
|
|
38
|
+
*
|
|
39
|
+
* - `pending-cae` — a factura entry of the order has `fiscalStatus`
|
|
40
|
+
* `pending_cae` (sent to ARCA, no CAE yet). Retry once the pending-invoice
|
|
41
|
+
* drain settles it.
|
|
42
|
+
* - `in-progress` — a factura is being issued for this order right now (also
|
|
43
|
+
* when one took the fence between the read and the commit). Retry once it
|
|
44
|
+
* ends.
|
|
45
|
+
* - `uncertain` — an earlier factura issuance of this order was interrupted
|
|
46
|
+
* and its outcome at ARCA is not confirmed. Retry only after support
|
|
47
|
+
* reconciles it.
|
|
48
|
+
* - `stranded` — ARCA authorized a voucher for this order that could not be
|
|
49
|
+
* recorded on it. Retry only after support records it.
|
|
50
|
+
*/
|
|
51
|
+
type ReturnFiscalInFlightCause = 'pending-cae' | 'in-progress' | 'uncertain' | 'stranded';
|
|
52
|
+
/**
|
|
53
|
+
* Why `409 RETURN_CREDIT_NOTE_UNALLOCATABLE` cannot attach the required
|
|
54
|
+
* credit note to one factura. Nothing was written. An operator data problem,
|
|
55
|
+
* not retryable as it stands.
|
|
56
|
+
*
|
|
57
|
+
* - `multiple-facturas` — the order holds more than one live domestic factura
|
|
58
|
+
* (credited or not). Product scope, not a data fault: the credit-note
|
|
59
|
+
* pipeline cannot attribute a note to one of several facturas
|
|
60
|
+
* (`NC_MULTI_FAC_UNSUPPORTED`), so the return is refused before it commits
|
|
61
|
+
* rather than leaving a note that will be rejected.
|
|
62
|
+
* - `missing-invoice-id` — the order's factura entry names no `invoiceId`, so
|
|
63
|
+
* its fiscal row cannot be read.
|
|
64
|
+
* - `unnumbered-factura` — a live factura entry carries no valid voucher
|
|
65
|
+
* number (and is not `pending_cae`), or a live entry carries no
|
|
66
|
+
* `invoiceType` at all and is counted as a factura, failing closed.
|
|
67
|
+
*/
|
|
68
|
+
type ReturnCreditNoteUnallocatableCause = 'multiple-facturas' | 'missing-invoice-id' | 'unnumbered-factura';
|
|
69
|
+
/**
|
|
70
|
+
* `data` of `409 RETURN_CREDIT_NOTE_REQUIRED`: the request sent
|
|
71
|
+
* `emitCreditNote: false` for a return whose `flow` requires the credit note
|
|
72
|
+
* on this order. Nothing was written. Resend without the flag (or `true`).
|
|
73
|
+
*/
|
|
74
|
+
interface ReturnCreditNoteRequiredData {
|
|
75
|
+
flow: ReturnFlow;
|
|
76
|
+
}
|
|
77
|
+
/** `data` of `409 RETURN_FISCAL_IN_FLIGHT` — see {@link ReturnFiscalInFlightCause}. */
|
|
78
|
+
interface ReturnFiscalInFlightData {
|
|
79
|
+
flow: ReturnFlow;
|
|
80
|
+
cause: ReturnFiscalInFlightCause;
|
|
81
|
+
}
|
|
82
|
+
/** `data` of `409 RETURN_CREDIT_NOTE_UNALLOCATABLE` — see {@link ReturnCreditNoteUnallocatableCause}. */
|
|
83
|
+
interface ReturnCreditNoteUnallocatableData {
|
|
84
|
+
flow: ReturnFlow;
|
|
85
|
+
cause: ReturnCreditNoteUnallocatableCause;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* `data` of `409 RETURN_LEDGER_BASIS_UNAVAILABLE` when the SERVER required the
|
|
89
|
+
* credit note: the factura's fiscal row cannot carry it — the row is missing
|
|
90
|
+
* or has no lines, a returned line does not map to a billed one, an earlier
|
|
91
|
+
* return cannot be read, or the voucher's currency or IVA is not allocatable.
|
|
92
|
+
* Nothing was written. An operator data problem, not retryable as it stands.
|
|
93
|
+
* Ranked after `RETURN_CREDIT_NOTE_UNALLOCATABLE` and before
|
|
94
|
+
* `RETURN_CREDIT_NOTE_REQUIRED`. The same code's other uses (an
|
|
95
|
+
* `administrative` return that asked for the note, a moved ledger basis at
|
|
96
|
+
* commit) carry no `data`.
|
|
97
|
+
*/
|
|
98
|
+
interface ReturnLedgerBasisUnavailableData {
|
|
99
|
+
flow: ReturnFlow;
|
|
100
|
+
}
|
|
22
101
|
/** Where a customer return's value is paid. Omission on a request or legacy row means account. */
|
|
23
102
|
type ReturnRefundMethod = 'account' | 'cash';
|
|
24
103
|
/** Return planning refusals: invalid selected lines, too many return summaries, or more than 100 transaction items. */
|
|
@@ -186,6 +265,16 @@ declare global {
|
|
|
186
265
|
*/
|
|
187
266
|
owedReduction?: number;
|
|
188
267
|
reason: ReturnReason;
|
|
268
|
+
/**
|
|
269
|
+
* The legal track this return followed, derived by the server when it is
|
|
270
|
+
* committed: `RETURN_REASON_FLOWS[reason]`. It decides the credit note (see
|
|
271
|
+
* {@link CreateReturnRequest.emitCreditNote}). Never client-settable.
|
|
272
|
+
* Operator-only.
|
|
273
|
+
*
|
|
274
|
+
* ⚠️ OPTIONAL PERMANENTLY. Absent on every return written before it existed;
|
|
275
|
+
* nothing backfills it and no reader derives it from `reason`.
|
|
276
|
+
*/
|
|
277
|
+
flow?: ReturnFlow;
|
|
189
278
|
notes?: string;
|
|
190
279
|
userId: string;
|
|
191
280
|
/**
|
|
@@ -412,8 +501,9 @@ declare global {
|
|
|
412
501
|
*/
|
|
413
502
|
type ReturnDirection = 'customer' | 'supplier';
|
|
414
503
|
/**
|
|
415
|
-
* Credit-note state machine for a return: `not_requested` (no NC
|
|
416
|
-
*
|
|
504
|
+
* Credit-note state machine for a return: `not_requested` (no NC issued:
|
|
505
|
+
* none asked for on an `administrative` return, or none owed on a
|
|
506
|
+
* server-decided flow — no live domestic factura with credit left), `pending` (outcome not yet settled — an attempt is in flight, or its
|
|
417
507
|
* outcome is unknown: a submit whose answer never came back, or a
|
|
418
508
|
* `pending_cae` voucher), `authorized` (ARCA granted; `creditNoteId`
|
|
419
509
|
* stamped), `rejected` (refused; retryable via return-credit-note mode
|
|
@@ -627,6 +717,11 @@ declare global {
|
|
|
627
717
|
/** Mirrors Return.owedReduction: the unpaid part of a walk-in return, which lowered what the order owes. */
|
|
628
718
|
owedReduction?: number;
|
|
629
719
|
reason: ReturnReason;
|
|
720
|
+
/**
|
|
721
|
+
* Mirrors `Return.flow`, written in the same transaction. Operator-only:
|
|
722
|
+
* stripped from every customer surface. Absent on legacy summaries.
|
|
723
|
+
*/
|
|
724
|
+
flow?: ReturnFlow;
|
|
630
725
|
ncStatus?: ReturnCreditNoteStatus;
|
|
631
726
|
creditNoteId?: string;
|
|
632
727
|
/**
|
|
@@ -758,6 +853,39 @@ declare global {
|
|
|
758
853
|
items: CreateReturnRequestItem[];
|
|
759
854
|
reason: ReturnReason;
|
|
760
855
|
notes?: string;
|
|
856
|
+
/**
|
|
857
|
+
* Whether the return issues a credit note. Who decides depends on the
|
|
858
|
+
* return's flow (`RETURN_REASON_FLOWS[reason]`):
|
|
859
|
+
*
|
|
860
|
+
* - `administrative`: this flag, omission meaning `false`.
|
|
861
|
+
* - `warranty`, `change-of-mind`, `purchase-withdrawal`
|
|
862
|
+
* (`RETURN_SERVER_CREDIT_NOTE_FLOWS`): the server. When the order holds a
|
|
863
|
+
* live domestic factura (`pending_cae` included, or a live entry with no
|
|
864
|
+
* `invoiceType`) that still has credit left to give, the note is REQUIRED
|
|
865
|
+
* and issued whether or not this flag is sent. Otherwise no note is
|
|
866
|
+
* issued, whatever it says — a factura already credited in full owes
|
|
867
|
+
* none. An order whose only live factura is an export or FCE one also
|
|
868
|
+
* commits with no note, and files one `RETURN_CREDIT_NOTE_MANUAL`
|
|
869
|
+
* operator row: that credit note must be issued by hand. Each refusal
|
|
870
|
+
* below writes nothing:
|
|
871
|
+
* 1. `409 RETURN_FISCAL_IN_FLIGHT` (`ReturnFiscalInFlightData`) while a
|
|
872
|
+
* factura is `pending_cae`, being issued, uncertain or stranded —
|
|
873
|
+
* checked on every server-decided flow, factura or not;
|
|
874
|
+
* 2. `409 RETURN_CREDIT_NOTE_UNALLOCATABLE`
|
|
875
|
+
* (`ReturnCreditNoteUnallocatableData`) when the note cannot be
|
|
876
|
+
* attached to exactly one factura;
|
|
877
|
+
* 3. `409 RETURN_LEDGER_BASIS_UNAVAILABLE`
|
|
878
|
+
* (`ReturnLedgerBasisUnavailableData`) when that factura's fiscal row
|
|
879
|
+
* cannot carry it;
|
|
880
|
+
* 4. `409 RETURN_CREDIT_NOTE_REQUIRED` (`ReturnCreditNoteRequiredData`)
|
|
881
|
+
* when this flag is an explicit `false`.
|
|
882
|
+
*
|
|
883
|
+
* On these flows the commit also asserts that no factura was appended and
|
|
884
|
+
* no factura issuance took the fence since the read: a factura landing in
|
|
885
|
+
* between answers `409 ORDER_VERSION_CONFLICT`, a fence taken in between
|
|
886
|
+
* `409 RETURN_FISCAL_IN_FLIGHT` (`in-progress` unless the re-read says
|
|
887
|
+
* otherwise).
|
|
888
|
+
*/
|
|
761
889
|
emitCreditNote?: boolean;
|
|
762
890
|
sendEmail?: boolean;
|
|
763
891
|
/**
|
package/dist/return.js
CHANGED
|
@@ -30,3 +30,15 @@ export const RETURN_REASON_FLOWS = {
|
|
|
30
30
|
billing_error: 'administrative',
|
|
31
31
|
other: 'administrative',
|
|
32
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* The flows in which the SERVER decides a return's credit note: every flow but
|
|
35
|
+
* `administrative`. Each of them is a refund of value, so on an order holding a
|
|
36
|
+
* live domestic factura with credit left to give the note is required — see
|
|
37
|
+
* {@link CreateReturnRequest.emitCreditNote}. `administrative` keeps the
|
|
38
|
+
* client's flag.
|
|
39
|
+
*/
|
|
40
|
+
export const RETURN_SERVER_CREDIT_NOTE_FLOWS = [
|
|
41
|
+
'purchase-withdrawal',
|
|
42
|
+
'change-of-mind',
|
|
43
|
+
'warranty',
|
|
44
|
+
];
|
package/dist/rma.d.ts
CHANGED
|
@@ -144,6 +144,14 @@ declare global {
|
|
|
144
144
|
warrantyEndsAt?: StatutoryInstant;
|
|
145
145
|
/** The store's change-of-mind terms as they stood when requested. Set only on a `change-of-mind` request. */
|
|
146
146
|
changeOfMind?: RmaChangeOfMindTerms;
|
|
147
|
+
/**
|
|
148
|
+
* Set only on a `shopper` request, in its create transaction (`shownAt`);
|
|
149
|
+
* the `return-request-received` mail then stamps `emailQueuedAt` and its
|
|
150
|
+
* worker `emailStatus`. Absent on an operator request, which mails nothing,
|
|
151
|
+
* and on a shopper request opened before the acknowledgement shipped — a
|
|
152
|
+
* missing `acknowledgement` is not an unsent one.
|
|
153
|
+
*/
|
|
154
|
+
acknowledgement?: ReturnRequestAcknowledgement;
|
|
147
155
|
/** Lowercase, rebuilt on every write. A row missing it is invisible to search. */
|
|
148
156
|
search?: string;
|
|
149
157
|
createdAt: number;
|
|
@@ -219,6 +227,15 @@ declare global {
|
|
|
219
227
|
type RmaSource = (typeof RMA_SOURCES)[number];
|
|
220
228
|
/** The flows a shopper's own return request can land in. */
|
|
221
229
|
type ShopperReturnRequestFlow = Extract<ReturnFlow, 'warranty' | 'change-of-mind'>;
|
|
230
|
+
/**
|
|
231
|
+
* A shopper return request's acknowledgement — the purchase withdrawal's
|
|
232
|
+
* shape: `shownAt` (the `201` showed the request number), `emailQueuedAt`
|
|
233
|
+
* (the `return-request-received` mail was queued) and `emailStatus` (`sent`,
|
|
234
|
+
* or `not-sent` when the customer has no address, the send was refused for
|
|
235
|
+
* good, or an operator decided the request before the mail went out). The operator reads an undelivered acknowledgement off it; the
|
|
236
|
+
* shopper's view never carries it.
|
|
237
|
+
*/
|
|
238
|
+
type ReturnRequestAcknowledgement = PurchaseWithdrawalAcknowledgement;
|
|
222
239
|
/** The change-of-mind terms snapshotted onto a request, so a later policy edit does not rewrite them. */
|
|
223
240
|
interface RmaChangeOfMindTerms {
|
|
224
241
|
endsAt: StatutoryInstant;
|