platform-types 1.10.832 → 1.10.834

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.
@@ -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
- * (a purchase withdrawal's cancellation, a return, a late capture on a withdrawn
8
- * order) and closes on its own when Mercado Pago reports the refund, when an
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 creator's in-transit debit of a linked payment's
13
- * credit ({@link RefundObligationLedgerCredit}), at creation.
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
- * (a purchase withdrawal's cancellation, a return, a late capture on a withdrawn
7
- * order) and closes on its own when Mercado Pago reports the refund, when an
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 creator's in-transit debit of a linked payment's
12
- * credit ({@link RefundObligationLedgerCredit}), at creation.
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 creator debits the share being refunded ("in transit") in its own
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
- /** The withdrawal or RMA that made the money owed. */
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`. */
@@ -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
- * (a purchase withdrawal's cancellation, a return, a late capture on a withdrawn
7
- * order) and closes on its own when Mercado Pago reports the refund, when an
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 creator's in-transit debit of a linked payment's
12
- * credit ({@link RefundObligationLedgerCredit}), at creation.
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
@@ -64,8 +64,15 @@ declare global {
64
64
  * - `unnumbered-factura` — a live factura entry carries no valid voucher
65
65
  * number (and is not `pending_cae`), or a live entry carries no
66
66
  * `invoiceType` at all and is counted as a factura, failing closed.
67
+ * - `freight-line-unmapped` — the return gives the freight back
68
+ * ({@link Return.freight}) and every factura line maps to a goods line,
69
+ * none to the order's freight line: the factura carries no freight line. A
70
+ * note without the freight would credit less than the return, so none is
71
+ * committed. A factura whose freight line differs from the order's (sku,
72
+ * name, quantity, unit or IVA) fails the whole line mapping instead, and
73
+ * answers `409 RETURN_LEDGER_BASIS_UNAVAILABLE`.
67
74
  */
68
- type ReturnCreditNoteUnallocatableCause = 'multiple-facturas' | 'missing-invoice-id' | 'unnumbered-factura';
75
+ type ReturnCreditNoteUnallocatableCause = 'multiple-facturas' | 'missing-invoice-id' | 'unnumbered-factura' | 'freight-line-unmapped';
69
76
  /**
70
77
  * `data` of `409 RETURN_CREDIT_NOTE_REQUIRED`: the request sent
71
78
  * `emitCreditNote: false` for a return whose `flow` requires the credit note
@@ -98,8 +105,28 @@ declare global {
98
105
  interface ReturnLedgerBasisUnavailableData {
99
106
  flow: ReturnFlow;
100
107
  }
101
- /** Where a customer return's value is paid. Omission on a request or legacy row means account. */
102
- type ReturnRefundMethod = 'account' | 'cash';
108
+ /**
109
+ * Where a customer return's value is paid. Omission on a request or legacy row means account.
110
+ *
111
+ * - `account` — a `DEVOLUCION` credit on the customer's account.
112
+ * - `cash` — paid out of the till.
113
+ * - `provider` — the money goes back through the payments it came in on: the same `DEVOLUCION` credit as
114
+ * `account`, plus one refund obligation per payment bucket (`RefundObligation`, parent the withdrawal the
115
+ * return settles, else its RMA, else the return itself), opened at the amount the server re-derives. An
116
+ * `applyCredit`-linked payment's link credit is debited in transit (`RIT#{obligationId}`) in the same
117
+ * transaction, so the account credit is never spendable — as on any withdrawal-bound return, whatever its
118
+ * method, for every obligation of the withdrawal carrying one. Needs no `acknowledgeNoProviderRefund`.
119
+ */
120
+ type ReturnRefundMethod = 'account' | 'cash' | 'provider';
121
+ /**
122
+ * `data` of `409 RETURN_WITHDRAWAL_HOLDS_LINE`: a return with no `rmaId` named a quantity a live purchase
123
+ * withdrawal holds — its `requested`/`accepted` lines, or the approved lines of its open
124
+ * `purchase-withdrawal` RMA (`rmaId`). Settle that withdrawal through its own RMA instead.
125
+ */
126
+ interface ReturnWithdrawalHoldsLineData {
127
+ withdrawalId: string;
128
+ rmaId?: string;
129
+ }
103
130
  /** Return planning refusals: invalid selected lines, too many return summaries, or more than 100 transaction items. */
104
131
  type ReturnPlanFailureCode = 'RETURN_INVALID_SUBSET' | 'RETURN_LIMIT_REACHED' | 'RETURN_TRANSACTION_TOO_LARGE' | 'UNIT_QUANTITY_NOT_WHOLE' | 'UNIT_QUANTITY_UNREPRESENTABLE';
105
132
  /**
@@ -193,6 +220,18 @@ declare global {
193
220
  */
194
221
  warehouseId?: string;
195
222
  items: ReturnItem[];
223
+ /**
224
+ * The order's freight line, given back by the `purchase-withdrawal` return that exhausts the order's goods
225
+ * lines. Server-appended, never client-settable: a body naming the freight index is
226
+ * `400 RETURN_INVALID_SUBSET`. `total` is the freight line's charge (`freightLineTotal`, never discounted)
227
+ * in the order's currency, and it is part of {@link Return.total}. Not a {@link ReturnItem}: it restocks
228
+ * nothing and writes no `SALE#`, `INCOME#` or disposition. The credit note's subset is `items` plus this.
229
+ * Operator-only, like the rest of the row.
230
+ *
231
+ * ⚠️ OPTIONAL PERMANENTLY. Absent on every other return — every other flow, a withdrawal return that leaves
232
+ * goods behind, an order with no freight line or one charged at 0 — and on every row written before it existed.
233
+ */
234
+ freight?: ReturnFreight;
196
235
  /** Operator-only intake allocations. Absent on legacy returns means no recorded movement snapshot. */
197
236
  stockMovements?: ReturnStockMovement[];
198
237
  /**
@@ -234,8 +273,10 @@ declare global {
234
273
  /**
235
274
  * The commercial refund in the originating order's currency. Selected
236
275
  * units use the sale's per-unit rounding rule, capped at the remaining
237
- * recorded charge; the final units refund that charge less earlier
238
- * `ReturnSummary.total` amounts. Historical returns remain as recorded.
276
+ * recorded charge; the final units refund that charge, less its freight
277
+ * line, less earlier `ReturnSummary.total` amounts. Historical returns
278
+ * remain as recorded. The one exception keeps the freight: a return
279
+ * carrying {@link Return.freight} refunds it too.
239
280
  *
240
281
  * The ACCOUNT credit is a separate conversion into the customer ledger's
241
282
  * currency, and a credit note reverses its factura's fiscal economics in
@@ -275,6 +316,11 @@ declare global {
275
316
  * nothing backfills it and no reader derives it from `reason`.
276
317
  */
277
318
  flow?: ReturnFlow;
319
+ /**
320
+ * The RMA this return settled (`CreateReturnRequest.rmaId`), moved `received → settled` in the return's own
321
+ * transaction. Operator-only. Absent on a return that bound none, and on every return written before it existed.
322
+ */
323
+ rmaId?: string;
278
324
  notes?: string;
279
325
  userId: string;
280
326
  /**
@@ -614,6 +660,15 @@ declare global {
614
660
  * for the idempotency window and claims no second number.
615
661
  */
616
662
  type ReturnCreditNoteErrorCode = 'PARTIAL_NC_AFIP_DOWN' | 'NC_MULTI_FAC_UNSUPPORTED' | 'NC_EXCEEDS_FAC_TOTAL' | 'CBTE_ASOC_NOT_FOUND' | 'CBTE_ASOC_NOT_CREDITABLE' | 'CBTE_ASOC_AMBIGUOUS' | 'INVOICE_POINT_OF_SALE_CONFLICT' | 'INVOICE_POINT_OF_SALE_RESERVED' | 'INVOICE_MIXED_CURRENCY' | 'LINE_CURRENCY_NOT_INVOICEABLE' | 'LINE_IVA_TYPE_NOT_INVOICEABLE' | 'AFIP_LINE_FX_UNSTAMPED' | 'CUSTOMER_AFIP_SHAPE_INVALID' | 'AFIP_BNA_RATE_UNAVAILABLE' | 'PARTIAL_NC_INVALID_SUBSET' | 'PARTIAL_NC_REQUIRES_CBTE' | 'INVOICE_PERSIST_AFTER_CAE_FAILED' | 'NC_EMISSION_FAILED';
663
+ /** The freight a `purchase-withdrawal` return gives back — see {@link Return.freight}. */
664
+ interface ReturnFreight {
665
+ /** The freight line's index in `Order.items`. */
666
+ orderItemIndex: number;
667
+ /** The freight line's whole quantity. */
668
+ quantity: number;
669
+ /** The freight line's charge in the order's currency (`freightLineTotal`). */
670
+ total: number;
671
+ }
617
672
  interface ReturnItem {
618
673
  /**
619
674
  * Index of the line in the ORIGINATING `Order.items` array. Returns are
@@ -722,6 +777,8 @@ declare global {
722
777
  * stripped from every customer surface. Absent on legacy summaries.
723
778
  */
724
779
  flow?: ReturnFlow;
780
+ /** Mirrors `Return.rmaId`. Operator-only: stripped from every customer surface. */
781
+ rmaId?: string;
725
782
  ncStatus?: ReturnCreditNoteStatus;
726
783
  creditNoteId?: string;
727
784
  /**
@@ -843,8 +900,37 @@ declare global {
843
900
  */
844
901
  interface CreateReturnRequest {
845
902
  mode: 'return';
846
- /** Omission credits the customer account. Cash pays the full server-calculated return total; no provider refund. A walk-in order (the system customer) is always refunded in cash, whatever is sent, but only up to what the order was paid; the unpaid rest lowers what the order still owes. */
903
+ /**
904
+ * Omission credits the customer account. Cash pays the full server-calculated return total; no provider
905
+ * refund. A walk-in order (the system customer) is always refunded in cash, whatever is sent, but only up to
906
+ * what the order was paid; the unpaid rest lowers what the order still owes.
907
+ *
908
+ * `provider` opens the refund obligations (see {@link ReturnRefundMethod}). A return bound to a
909
+ * purchase-withdrawal RMA defaults to `provider` while the re-derived amount owed is above 0, and any other
910
+ * method is then `409 RETURN_REFUND_METHOD_PROVIDER_REQUIRED`; with nothing owed (an unpaid order) it
911
+ * defaults to `account`. `provider` on an order with no linked payment, no approved attempt payment and no
912
+ * till leg is `409 RETURN_PROVIDER_NO_PAYMENT`; one whose payments owe nothing is
913
+ * `409 RETURN_PROVIDER_NOTHING_OWED`. A payment in a currency the order cannot convert at its frozen rate is
914
+ * `409 RETURN_PROVIDER_CURRENCY_MISMATCH`; a link credit the in-transit debit cannot vet is
915
+ * `409 RETURN_LEDGER_BASIS_UNAVAILABLE`; an obligation still owed that the re-derived amount gives nothing
916
+ * is `409 RETURN_OBLIGATION_RECONCILE_REQUIRED`. Each writes nothing and one ERROR row.
917
+ */
847
918
  refundMethod?: ReturnRefundMethod;
919
+ /**
920
+ * The RMA this return settles. Read strongly; it must be this order's and `received`, else `404
921
+ * RMA_NOT_FOUND`, `409 RETURN_RMA_ORDER_MISMATCH` or `409 RETURN_RMA_NOT_RECEIVED`. The return's lines must
922
+ * EQUAL a `purchase-withdrawal` RMA's approved lines (index and quantity), and stay within any other RMA's
923
+ * approved quantity on the lines it names, else `409 RETURN_RMA_LINES_MISMATCH`. The return then takes its
924
+ * flow from the RMA (`purchase-withdrawal` for that source, else `Rma.flow`, else the reason's), stores
925
+ * `rmaId`, and settles the RMA (`received → settled`, `settledReturnId`) in its own transaction; a
926
+ * withdrawal-bound return also moves the withdrawal (`refund-pending` while an obligation is owed, else
927
+ * `completed`).
928
+ *
929
+ * Absent: a return that names a quantity a live purchase withdrawal holds is
930
+ * `409 RETURN_WITHDRAWAL_HOLDS_LINE` (`ReturnWithdrawalHoldsLineData`); a truncated read of the order's open
931
+ * RMAs is `503 RETURN_REQUESTS_UNAVAILABLE`.
932
+ */
933
+ rmaId?: string;
848
934
  /** Client-minted UUID; the idempotency key. A replay returns the original outcome. */
849
935
  requestId: string;
850
936
  orderId: string;
@@ -889,9 +975,10 @@ declare global {
889
975
  emitCreditNote?: boolean;
890
976
  sendEmail?: boolean;
891
977
  /**
892
- * Required when the order has a non-empty `linkedPayments` map: the
893
- * operator acknowledges SINFACTURA does NOT refund or unlink the provider
894
- * payment. The return pays by refundMethod (account by default; always cash on a walk-in order).
978
+ * Required when the order has a non-empty `linkedPayments` map and the
979
+ * return pays by `account` or `cash`: the operator acknowledges SINFACTURA
980
+ * does NOT refund or unlink the provider payment. `provider` needs none.
981
+ * The return pays by refundMethod (account by default; always cash on a walk-in order).
895
982
  */
896
983
  acknowledgeNoProviderRefund?: boolean;
897
984
  /**
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. No writer links a
305
- * refund to a shopper request yet, so it is absent today.
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platform-types",
3
- "version": "1.10.832",
3
+ "version": "1.10.834",
4
4
  "description": "Shared wire and entity contracts for the platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",