platform-types 1.10.827 → 1.10.829
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 +17 -4
- package/dist/return.d.ts +130 -2
- package/dist/return.js +12 -0
- package/dist/rma.d.ts +11 -5
- 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
|
+
];
|
|
@@ -141,10 +141,23 @@ declare global {
|
|
|
141
141
|
* How the identification code reached the shopper. `shownAt` is when the
|
|
142
142
|
* `201` carried it on screen (the same medium as the request); the
|
|
143
143
|
* `purchase-withdrawal-received` mail is queued after the commit and
|
|
144
|
-
* stamps `emailQueuedAt`, and the mail worker records `emailStatus
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
144
|
+
* stamps `emailQueuedAt`, and the mail worker records `emailStatus: 'sent'`
|
|
145
|
+
* once the mail went out. `emailStatus: 'not-sent'` is written when:
|
|
146
|
+
*
|
|
147
|
+
* - the mail was never queued — platform email sending was off at the
|
|
148
|
+
* request, or the queue write (or the `emailQueuedAt` stamp) failed. This
|
|
149
|
+
* stamp never replaces a verdict the worker already recorded;
|
|
150
|
+
* - the worker found no address on the order's customer row;
|
|
151
|
+
* - the sender did not deliver it — an address suppressed after a bounce, a
|
|
152
|
+
* demo store, or the sender refusing the message;
|
|
153
|
+
* - the send failed for good (a permanent rejection);
|
|
154
|
+
* - an operator decided the request before the mail went out.
|
|
155
|
+
*
|
|
156
|
+
* Each verdict the worker records reaches operator sockets as the record's
|
|
157
|
+
* frame. `emailQueuedAt` with no `emailStatus` is not proof of a mail in
|
|
158
|
+
* flight: some worker exits stamp nothing (a transient send failure whose
|
|
159
|
+
* retries run out, a batch dropped because platform email sending was
|
|
160
|
+
* switched off after the request).
|
|
148
161
|
*/
|
|
149
162
|
interface PurchaseWithdrawalAcknowledgement {
|
|
150
163
|
/** 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
|
@@ -229,11 +229,17 @@ declare global {
|
|
|
229
229
|
type ShopperReturnRequestFlow = Extract<ReturnFlow, 'warranty' | 'change-of-mind'>;
|
|
230
230
|
/**
|
|
231
231
|
* A shopper return request's acknowledgement — the purchase withdrawal's
|
|
232
|
-
* shape: `shownAt` (the
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
232
|
+
* shape and rules ({@link PurchaseWithdrawalAcknowledgement}): `shownAt` (the
|
|
233
|
+
* `201` showed the request number), `emailQueuedAt` (the
|
|
234
|
+
* `return-request-received` mail was queued) and `emailStatus` — `sent`, or
|
|
235
|
+
* `not-sent` when the mail was never queued (platform email sending off, or
|
|
236
|
+
* the queue write or its stamp failing — never over a verdict the worker
|
|
237
|
+
* already recorded), the customer row has no address, the sender did not
|
|
238
|
+
* deliver it (an address suppressed after a bounce, a demo store, or a
|
|
239
|
+
* refused message), the send failed for good, or an operator decided the
|
|
240
|
+
* request before the mail went out. The operator reads an undelivered
|
|
241
|
+
* acknowledgement off it, on `GET /rma` and the `rma` frame each recorded
|
|
242
|
+
* verdict sends; the shopper's view never carries it.
|
|
237
243
|
*/
|
|
238
244
|
type ReturnRequestAcknowledgement = PurchaseWithdrawalAcknowledgement;
|
|
239
245
|
/** The change-of-mind terms snapshotted onto a request, so a later policy edit does not rewrite them. */
|