platform-types 1.10.832 → 1.10.833
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/refundObligation.js +12 -5
- package/dist/refundObligation.d.ts +24 -9
- package/dist/refundObligation.js +12 -5
- package/dist/return.d.ts +63 -6
- package/dist/rma.d.ts +3 -2
- package/package.json +1 -1
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
* Refund obligations — money the store owes a customer back, tracked until it is
|
|
4
4
|
* proven returned.
|
|
5
5
|
*
|
|
6
|
-
* An obligation is created inside the transaction of whatever made the money owed
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* An obligation is created inside the transaction of whatever made the money owed —
|
|
7
|
+
* a purchase withdrawal's hand-off (`awaiting-goods`, at a provisional amount), a
|
|
8
|
+
* `Return` paid by `provider` (which opens it, or re-amounts the hand-off's), a late
|
|
9
|
+
* capture on a withdrawn order — and closes on its own when Mercado Pago reports the refund, when an
|
|
9
10
|
* operator closes a payment attempt's resolution as `refunded`, or when a
|
|
10
11
|
* chargeback settled the money back. An open dispute holds it; a lifted dispute
|
|
11
12
|
* reopens it. Closure moves no money and writes no ledger row: it records a fact.
|
|
12
|
-
* The one ledger write is the
|
|
13
|
-
*
|
|
13
|
+
* The one ledger write is the in-transit debit of a linked payment's credit
|
|
14
|
+
* ({@link RefundObligationLedgerCredit}), written by the `Return` that settles the
|
|
15
|
+
* obligation's parent (a `provider` one, or any withdrawal-bound one) — the only writer —
|
|
16
|
+
* for every obligation of that parent that carries one, closed included.
|
|
14
17
|
*
|
|
15
18
|
* ⚠️ The stored row carries none of the main table's index-key attributes
|
|
16
19
|
* (`status`, `customerId`, `dated`, `updatedAt`, `terminalId`, `inboxKey`), so it
|
|
@@ -55,6 +58,9 @@ exports.REFUND_OBLIGATION_HOLD_REASONS = ['dispute-open', 'reimbursed'];
|
|
|
55
58
|
* - `operator` — an operator closed it by hand.
|
|
56
59
|
* - `chargeback` — a settled chargeback took the money back.
|
|
57
60
|
* - `api-refund` — a refund the api itself made (reserved; no writer yet).
|
|
61
|
+
* - `account-credit` — settled by the `Return`'s `DEVOLUCION` account credit: an `offline` obligation of a seña
|
|
62
|
+
* order's withdrawal, closed in that `Return`'s own transaction (the delivery netted the seña out of its
|
|
63
|
+
* debit, so the credit IS the seña's refund). No drawer event, no `ACCOUNT#` row of its own.
|
|
58
64
|
*/
|
|
59
65
|
exports.REFUND_OBLIGATION_CLOSED_BY = [
|
|
60
66
|
'detected-refund',
|
|
@@ -62,6 +68,7 @@ exports.REFUND_OBLIGATION_CLOSED_BY = [
|
|
|
62
68
|
'operator',
|
|
63
69
|
'chargeback',
|
|
64
70
|
'api-refund',
|
|
71
|
+
'account-credit',
|
|
65
72
|
];
|
|
66
73
|
/** Where a {@link StatutoryInstant} came from: the platform global it was computed with. */
|
|
67
74
|
exports.REFUND_OBLIGATION_DUE_SOURCE = 'global:refundObligationDueDays';
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
* Refund obligations — money the store owes a customer back, tracked until it is
|
|
3
3
|
* proven returned.
|
|
4
4
|
*
|
|
5
|
-
* An obligation is created inside the transaction of whatever made the money owed
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* An obligation is created inside the transaction of whatever made the money owed —
|
|
6
|
+
* a purchase withdrawal's hand-off (`awaiting-goods`, at a provisional amount), a
|
|
7
|
+
* `Return` paid by `provider` (which opens it, or re-amounts the hand-off's), a late
|
|
8
|
+
* capture on a withdrawn order — and closes on its own when Mercado Pago reports the refund, when an
|
|
8
9
|
* operator closes a payment attempt's resolution as `refunded`, or when a
|
|
9
10
|
* chargeback settled the money back. An open dispute holds it; a lifted dispute
|
|
10
11
|
* reopens it. Closure moves no money and writes no ledger row: it records a fact.
|
|
11
|
-
* The one ledger write is the
|
|
12
|
-
*
|
|
12
|
+
* The one ledger write is the in-transit debit of a linked payment's credit
|
|
13
|
+
* ({@link RefundObligationLedgerCredit}), written by the `Return` that settles the
|
|
14
|
+
* obligation's parent (a `provider` one, or any withdrawal-bound one) — the only writer —
|
|
15
|
+
* for every obligation of that parent that carries one, closed included.
|
|
13
16
|
*
|
|
14
17
|
* ⚠️ The stored row carries none of the main table's index-key attributes
|
|
15
18
|
* (`status`, `customerId`, `dated`, `updatedAt`, `terminalId`, `inboxKey`), so it
|
|
@@ -52,8 +55,11 @@ export declare const REFUND_OBLIGATION_HOLD_REASONS: readonly ["dispute-open", "
|
|
|
52
55
|
* - `operator` — an operator closed it by hand.
|
|
53
56
|
* - `chargeback` — a settled chargeback took the money back.
|
|
54
57
|
* - `api-refund` — a refund the api itself made (reserved; no writer yet).
|
|
58
|
+
* - `account-credit` — settled by the `Return`'s `DEVOLUCION` account credit: an `offline` obligation of a seña
|
|
59
|
+
* order's withdrawal, closed in that `Return`'s own transaction (the delivery netted the seña out of its
|
|
60
|
+
* debit, so the credit IS the seña's refund). No drawer event, no `ACCOUNT#` row of its own.
|
|
55
61
|
*/
|
|
56
|
-
export declare const REFUND_OBLIGATION_CLOSED_BY: readonly ["detected-refund", "resolution-refunded", "operator", "chargeback", "api-refund"];
|
|
62
|
+
export declare const REFUND_OBLIGATION_CLOSED_BY: readonly ["detected-refund", "resolution-refunded", "operator", "chargeback", "api-refund", "account-credit"];
|
|
57
63
|
/** Where a {@link StatutoryInstant} came from: the platform global it was computed with. */
|
|
58
64
|
export declare const REFUND_OBLIGATION_DUE_SOURCE = "global:refundObligationDueDays";
|
|
59
65
|
/** The longest operator `reason` `POST /refund-obligations` accepts, in characters after trimming. */
|
|
@@ -81,8 +87,8 @@ declare global {
|
|
|
81
87
|
}
|
|
82
88
|
/**
|
|
83
89
|
* The payment-link credit an obligation's money was booked to, when there is one: the customer's ledger
|
|
84
|
-
* still holds it as a credit, so the
|
|
85
|
-
* transaction, one `ACCOUNT#` row per obligation.
|
|
90
|
+
* still holds it as a credit, so the `Return` that settles the obligation's parent debits the share being
|
|
91
|
+
* refunded ("in transit") in its own transaction, one `ACCOUNT#` row per obligation (`RIT#{obligationId}`).
|
|
86
92
|
*/
|
|
87
93
|
interface RefundObligationLedgerCredit {
|
|
88
94
|
/** The `ACCOUNT#{storeId}` credit row's SK — the per-source payment row's `accountId`. */
|
|
@@ -115,6 +121,12 @@ declare global {
|
|
|
115
121
|
actor?: string;
|
|
116
122
|
/** The operator's own words, for `operator`. */
|
|
117
123
|
reason?: string;
|
|
124
|
+
/**
|
|
125
|
+
* For `operator`: the money went back from the operator's till (`payout: 'drawer'`) in the closure's own
|
|
126
|
+
* transaction. A seña's `Return` excludes that amount from its `DEVOLUCION` credit. Absent on a closure that
|
|
127
|
+
* recorded no payout, and on one written before the payout was recorded on the closure.
|
|
128
|
+
*/
|
|
129
|
+
payout?: (typeof REFUND_OBLIGATION_PAYOUTS)[number];
|
|
118
130
|
/** For `detected-refund`: the ids of the payment's `refunds[]` dated at or after `createdAt`. */
|
|
119
131
|
providerRefundIds?: string[];
|
|
120
132
|
}
|
|
@@ -122,7 +134,10 @@ declare global {
|
|
|
122
134
|
/** The row's sort key: `{orderId}#{parentId}#{kind}#{paymentId | 'till'}`. */
|
|
123
135
|
obligationId: string;
|
|
124
136
|
orderId: string;
|
|
125
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* What made the money owed: the purchase withdrawal (`ARR…`) — the hand-off's and its `Return`'s — else the
|
|
139
|
+
* RMA (`RMA…`) a `provider` `Return` settles, else that `Return` itself (`RET…`).
|
|
140
|
+
*/
|
|
126
141
|
parentId: string;
|
|
127
142
|
kind: RefundObligationKind;
|
|
128
143
|
/** The Mercado Pago payment the money came in on. Absent for `offline`. */
|
package/dist/refundObligation.js
CHANGED
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
* Refund obligations — money the store owes a customer back, tracked until it is
|
|
3
3
|
* proven returned.
|
|
4
4
|
*
|
|
5
|
-
* An obligation is created inside the transaction of whatever made the money owed
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* An obligation is created inside the transaction of whatever made the money owed —
|
|
6
|
+
* a purchase withdrawal's hand-off (`awaiting-goods`, at a provisional amount), a
|
|
7
|
+
* `Return` paid by `provider` (which opens it, or re-amounts the hand-off's), a late
|
|
8
|
+
* capture on a withdrawn order — and closes on its own when Mercado Pago reports the refund, when an
|
|
8
9
|
* operator closes a payment attempt's resolution as `refunded`, or when a
|
|
9
10
|
* chargeback settled the money back. An open dispute holds it; a lifted dispute
|
|
10
11
|
* reopens it. Closure moves no money and writes no ledger row: it records a fact.
|
|
11
|
-
* The one ledger write is the
|
|
12
|
-
*
|
|
12
|
+
* The one ledger write is the in-transit debit of a linked payment's credit
|
|
13
|
+
* ({@link RefundObligationLedgerCredit}), written by the `Return` that settles the
|
|
14
|
+
* obligation's parent (a `provider` one, or any withdrawal-bound one) — the only writer —
|
|
15
|
+
* for every obligation of that parent that carries one, closed included.
|
|
13
16
|
*
|
|
14
17
|
* ⚠️ The stored row carries none of the main table's index-key attributes
|
|
15
18
|
* (`status`, `customerId`, `dated`, `updatedAt`, `terminalId`, `inboxKey`), so it
|
|
@@ -52,6 +55,9 @@ export const REFUND_OBLIGATION_HOLD_REASONS = ['dispute-open', 'reimbursed'];
|
|
|
52
55
|
* - `operator` — an operator closed it by hand.
|
|
53
56
|
* - `chargeback` — a settled chargeback took the money back.
|
|
54
57
|
* - `api-refund` — a refund the api itself made (reserved; no writer yet).
|
|
58
|
+
* - `account-credit` — settled by the `Return`'s `DEVOLUCION` account credit: an `offline` obligation of a seña
|
|
59
|
+
* order's withdrawal, closed in that `Return`'s own transaction (the delivery netted the seña out of its
|
|
60
|
+
* debit, so the credit IS the seña's refund). No drawer event, no `ACCOUNT#` row of its own.
|
|
55
61
|
*/
|
|
56
62
|
export const REFUND_OBLIGATION_CLOSED_BY = [
|
|
57
63
|
'detected-refund',
|
|
@@ -59,6 +65,7 @@ export const REFUND_OBLIGATION_CLOSED_BY = [
|
|
|
59
65
|
'operator',
|
|
60
66
|
'chargeback',
|
|
61
67
|
'api-refund',
|
|
68
|
+
'account-credit',
|
|
62
69
|
];
|
|
63
70
|
/** Where a {@link StatutoryInstant} came from: the platform global it was computed with. */
|
|
64
71
|
export const REFUND_OBLIGATION_DUE_SOURCE = 'global:refundObligationDueDays';
|
package/dist/return.d.ts
CHANGED
|
@@ -98,8 +98,28 @@ declare global {
|
|
|
98
98
|
interface ReturnLedgerBasisUnavailableData {
|
|
99
99
|
flow: ReturnFlow;
|
|
100
100
|
}
|
|
101
|
-
/**
|
|
102
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Where a customer return's value is paid. Omission on a request or legacy row means account.
|
|
103
|
+
*
|
|
104
|
+
* - `account` — a `DEVOLUCION` credit on the customer's account.
|
|
105
|
+
* - `cash` — paid out of the till.
|
|
106
|
+
* - `provider` — the money goes back through the payments it came in on: the same `DEVOLUCION` credit as
|
|
107
|
+
* `account`, plus one refund obligation per payment bucket (`RefundObligation`, parent the withdrawal the
|
|
108
|
+
* return settles, else its RMA, else the return itself), opened at the amount the server re-derives. An
|
|
109
|
+
* `applyCredit`-linked payment's link credit is debited in transit (`RIT#{obligationId}`) in the same
|
|
110
|
+
* transaction, so the account credit is never spendable — as on any withdrawal-bound return, whatever its
|
|
111
|
+
* method, for every obligation of the withdrawal carrying one. Needs no `acknowledgeNoProviderRefund`.
|
|
112
|
+
*/
|
|
113
|
+
type ReturnRefundMethod = 'account' | 'cash' | 'provider';
|
|
114
|
+
/**
|
|
115
|
+
* `data` of `409 RETURN_WITHDRAWAL_HOLDS_LINE`: a return with no `rmaId` named a quantity a live purchase
|
|
116
|
+
* withdrawal holds — its `requested`/`accepted` lines, or the approved lines of its open
|
|
117
|
+
* `purchase-withdrawal` RMA (`rmaId`). Settle that withdrawal through its own RMA instead.
|
|
118
|
+
*/
|
|
119
|
+
interface ReturnWithdrawalHoldsLineData {
|
|
120
|
+
withdrawalId: string;
|
|
121
|
+
rmaId?: string;
|
|
122
|
+
}
|
|
103
123
|
/** Return planning refusals: invalid selected lines, too many return summaries, or more than 100 transaction items. */
|
|
104
124
|
type ReturnPlanFailureCode = 'RETURN_INVALID_SUBSET' | 'RETURN_LIMIT_REACHED' | 'RETURN_TRANSACTION_TOO_LARGE' | 'UNIT_QUANTITY_NOT_WHOLE' | 'UNIT_QUANTITY_UNREPRESENTABLE';
|
|
105
125
|
/**
|
|
@@ -275,6 +295,11 @@ declare global {
|
|
|
275
295
|
* nothing backfills it and no reader derives it from `reason`.
|
|
276
296
|
*/
|
|
277
297
|
flow?: ReturnFlow;
|
|
298
|
+
/**
|
|
299
|
+
* The RMA this return settled (`CreateReturnRequest.rmaId`), moved `received → settled` in the return's own
|
|
300
|
+
* transaction. Operator-only. Absent on a return that bound none, and on every return written before it existed.
|
|
301
|
+
*/
|
|
302
|
+
rmaId?: string;
|
|
278
303
|
notes?: string;
|
|
279
304
|
userId: string;
|
|
280
305
|
/**
|
|
@@ -722,6 +747,8 @@ declare global {
|
|
|
722
747
|
* stripped from every customer surface. Absent on legacy summaries.
|
|
723
748
|
*/
|
|
724
749
|
flow?: ReturnFlow;
|
|
750
|
+
/** Mirrors `Return.rmaId`. Operator-only: stripped from every customer surface. */
|
|
751
|
+
rmaId?: string;
|
|
725
752
|
ncStatus?: ReturnCreditNoteStatus;
|
|
726
753
|
creditNoteId?: string;
|
|
727
754
|
/**
|
|
@@ -843,8 +870,37 @@ declare global {
|
|
|
843
870
|
*/
|
|
844
871
|
interface CreateReturnRequest {
|
|
845
872
|
mode: 'return';
|
|
846
|
-
/**
|
|
873
|
+
/**
|
|
874
|
+
* Omission credits the customer account. Cash pays the full server-calculated return total; no provider
|
|
875
|
+
* refund. A walk-in order (the system customer) is always refunded in cash, whatever is sent, but only up to
|
|
876
|
+
* what the order was paid; the unpaid rest lowers what the order still owes.
|
|
877
|
+
*
|
|
878
|
+
* `provider` opens the refund obligations (see {@link ReturnRefundMethod}). A return bound to a
|
|
879
|
+
* purchase-withdrawal RMA defaults to `provider` while the re-derived amount owed is above 0, and any other
|
|
880
|
+
* method is then `409 RETURN_REFUND_METHOD_PROVIDER_REQUIRED`; with nothing owed (an unpaid order) it
|
|
881
|
+
* defaults to `account`. `provider` on an order with no linked payment, no approved attempt payment and no
|
|
882
|
+
* till leg is `409 RETURN_PROVIDER_NO_PAYMENT`; one whose payments owe nothing is
|
|
883
|
+
* `409 RETURN_PROVIDER_NOTHING_OWED`. A payment in a currency the order cannot convert at its frozen rate is
|
|
884
|
+
* `409 RETURN_PROVIDER_CURRENCY_MISMATCH`; a link credit the in-transit debit cannot vet is
|
|
885
|
+
* `409 RETURN_LEDGER_BASIS_UNAVAILABLE`; an obligation still owed that the re-derived amount gives nothing
|
|
886
|
+
* is `409 RETURN_OBLIGATION_RECONCILE_REQUIRED`. Each writes nothing and one ERROR row.
|
|
887
|
+
*/
|
|
847
888
|
refundMethod?: ReturnRefundMethod;
|
|
889
|
+
/**
|
|
890
|
+
* The RMA this return settles. Read strongly; it must be this order's and `received`, else `404
|
|
891
|
+
* RMA_NOT_FOUND`, `409 RETURN_RMA_ORDER_MISMATCH` or `409 RETURN_RMA_NOT_RECEIVED`. The return's lines must
|
|
892
|
+
* EQUAL a `purchase-withdrawal` RMA's approved lines (index and quantity), and stay within any other RMA's
|
|
893
|
+
* approved quantity on the lines it names, else `409 RETURN_RMA_LINES_MISMATCH`. The return then takes its
|
|
894
|
+
* flow from the RMA (`purchase-withdrawal` for that source, else `Rma.flow`, else the reason's), stores
|
|
895
|
+
* `rmaId`, and settles the RMA (`received → settled`, `settledReturnId`) in its own transaction; a
|
|
896
|
+
* withdrawal-bound return also moves the withdrawal (`refund-pending` while an obligation is owed, else
|
|
897
|
+
* `completed`).
|
|
898
|
+
*
|
|
899
|
+
* Absent: a return that names a quantity a live purchase withdrawal holds is
|
|
900
|
+
* `409 RETURN_WITHDRAWAL_HOLDS_LINE` (`ReturnWithdrawalHoldsLineData`); a truncated read of the order's open
|
|
901
|
+
* RMAs is `503 RETURN_REQUESTS_UNAVAILABLE`.
|
|
902
|
+
*/
|
|
903
|
+
rmaId?: string;
|
|
848
904
|
/** Client-minted UUID; the idempotency key. A replay returns the original outcome. */
|
|
849
905
|
requestId: string;
|
|
850
906
|
orderId: string;
|
|
@@ -889,9 +945,10 @@ declare global {
|
|
|
889
945
|
emitCreditNote?: boolean;
|
|
890
946
|
sendEmail?: boolean;
|
|
891
947
|
/**
|
|
892
|
-
* Required when the order has a non-empty `linkedPayments` map
|
|
893
|
-
*
|
|
894
|
-
*
|
|
948
|
+
* Required when the order has a non-empty `linkedPayments` map and the
|
|
949
|
+
* return pays by `account` or `cash`: the operator acknowledges SINFACTURA
|
|
950
|
+
* does NOT refund or unlink the provider payment. `provider` needs none.
|
|
951
|
+
* The return pays by refundMethod (account by default; always cash on a walk-in order).
|
|
895
952
|
*/
|
|
896
953
|
acknowledgeNoProviderRefund?: boolean;
|
|
897
954
|
/**
|
package/dist/rma.d.ts
CHANGED
|
@@ -301,8 +301,9 @@ declare global {
|
|
|
301
301
|
refundAs: ChangeOfMindRefundAs;
|
|
302
302
|
};
|
|
303
303
|
/**
|
|
304
|
-
* The refunds owed on this request, as on a withdrawal
|
|
305
|
-
*
|
|
304
|
+
* The refunds owed on this request, as on a withdrawal: one per refund
|
|
305
|
+
* obligation whose `parentId` is this RMA, which the `provider` `Return`
|
|
306
|
+
* settling it opens. Absent while there is none.
|
|
306
307
|
*/
|
|
307
308
|
refunds?: OrderPurchaseWithdrawalRefundView[];
|
|
308
309
|
}
|