sinfactura-types 1.10.336 → 1.10.337

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/invoice.d.ts CHANGED
@@ -210,10 +210,7 @@ declare global {
210
210
  * under. ARCA numbers each `(PtoVta, CbteTipo)` as its own sequence, so a
211
211
  * voucher is named by the triple (punto de venta, voucher class, number) and
212
212
  * the recorded number alone names nothing. This field records the first
213
- * member. ⚠️ The second — the voucher class the attempt was submitted as — is
214
- * NOT recorded beside the marker: the reconcile reads the row's `invoiceType`
215
- * for it, which is the submitted class for an attempt made by the issue path,
216
- * since that path writes both in the same row from the same voucher. Written in
213
+ * member; `attemptedInvoiceType` below records the second. Written in
217
214
  * the same write as `attemptedCbteNro`, by both of its writers (the issue
218
215
  * path's pending-row write and the outage drain's pre-submit marker), and
219
216
  * removed wherever that marker is removed.
@@ -226,6 +223,31 @@ declare global {
226
223
  * for an operator rather than guessing a sequence to query.
227
224
  */
228
225
  attemptedPointOfSale?: number;
226
+ /**
227
+ * The voucher class (AFIP `CbteTipo`) the attempt recorded in
228
+ * `attemptedCbteNro` was SUBMITTED as — the second member of the (punto de
229
+ * venta, voucher class, number) triple that names a voucher at ARCA.
230
+ *
231
+ * ⚠️ It is the AS-SUBMITTED class, and it can differ from this row's
232
+ * `invoiceType` while the row is `pending_cae`. The outage drain rebuilds the
233
+ * voucher before it submits, and the class follows the store's afip config
234
+ * and the class rules in force at THAT moment, so a drain-made attempt can go
235
+ * out under a class the row does not carry. The two agree again once the
236
+ * drain persists: that write stores the class ARCA authorised as
237
+ * `invoiceType` and removes this field.
238
+ *
239
+ * Written in the same write as `attemptedCbteNro` and `attemptedPointOfSale`,
240
+ * by both of their writers (the issue path's pending-row write and the outage
241
+ * drain's pre-submit marker), and removed in the same write wherever they are
242
+ * removed (adopt/authorise persist, authoritative rejection, marker clear).
243
+ *
244
+ * ABSENT MEANS UNKNOWN — never "equal to `invoiceType`". Forward-only: a row
245
+ * that recorded its attempt before this field existed carries the marker
246
+ * without it, and the drain holds such a row for an operator rather than
247
+ * guessing a sequence to query. Any incomplete marker set is held the same
248
+ * way, whichever member is missing.
249
+ */
250
+ attemptedInvoiceType?: number;
229
251
  invoicePrinted?: boolean;
230
252
  /**
231
253
  * Server-derived ms epoch, stamped by the WSS `ack` handler on an
package/dist/report.d.ts CHANGED
@@ -31,6 +31,64 @@ declare global {
31
31
  net?: number;
32
32
  /** `cost - returnCost`. Forward-only — see `returns`. */
33
33
  netCost?: number;
34
+ /**
35
+ * Delivered orders on this day whose `Order.cost` is ABSENT — the orders
36
+ * left out of `cost`.
37
+ *
38
+ * ⚠️ **`cost`, `netCost` and every margin derived from them are computed
39
+ * over COSTED orders only**, while `quantity` and `total` still count and
40
+ * sum EVERY delivered order. That asymmetry is deliberate: revenue is
41
+ * known for an uncosted order and COGS is not, and summing an absent cost
42
+ * as `0` reported the order at 100 % margin ({@link Order.cost} — absence
43
+ * means WITHHELD or UNKNOWN, never 0).
44
+ *
45
+ * ⚠️ So `total - cost` is NOT this day's margin. The cost-comparable
46
+ * revenue base is `total - uncostedTotal`, and the margin a client may
47
+ * render is `(total - uncostedTotal) - cost`. A non-zero
48
+ * `uncostedQuantity` means the day's COGS figure describes a SUBSET and
49
+ * must be presented as partial.
50
+ *
51
+ * ⚠️ **Emitted on every row, `0` included — never omitted.** `0` is the
52
+ * positive statement "every delivered order on this day is costed, the
53
+ * figures beside it are complete". Absence therefore means the response
54
+ * came from a build predating this field, NOT that nothing was excluded;
55
+ * a client that reads absence as zero renders a pre-change, silently
56
+ * inflated margin as certified. Optional here only because the frontends
57
+ * lag this contract by one publish.
58
+ */
59
+ uncostedQuantity?: number;
60
+ /**
61
+ * GROSS revenue of the {@link ReportSales.uncostedQuantity} orders — the
62
+ * revenue that has no COGS behind it. Subtract it from `total` to get the
63
+ * base `cost` is comparable against. Emitted always, `0` included.
64
+ */
65
+ uncostedTotal?: number;
66
+ /**
67
+ * Returns dated this day whose `Return.cost` is ABSENT — the returns left
68
+ * out of `returnCost`.
69
+ *
70
+ * ⚠️ Same rule as `uncostedQuantity`, and over a SCOPE deliberately kept
71
+ * aligned with it: a return is uncosted when any returned line states no
72
+ * cost **or** when the originating `Order.cost` is absent. The second
73
+ * half is load-bearing — an order's cost is all-or-nothing over ALL its
74
+ * lines, so returning a costed line of an otherwise-uncosted order would
75
+ * otherwise reverse a COGS that `cost` never contained, and the formula
76
+ * above would render a LOSS on an ordinary day. Applied to the returns
77
+ * leg: an
78
+ * uncosted return still contributes its credited amount to `returns` and
79
+ * `net` (the credit is known), and contributes NOTHING to `returnCost` or
80
+ * `netCost`. It does not reduce the cost side of margin at all — the
81
+ * bucket's return-COGS is partial and this count is how a client knows.
82
+ * Emitted always, `0` included.
83
+ */
84
+ uncostedReturnCount?: number;
85
+ /**
86
+ * Positive sum of the credited totals of the
87
+ * {@link ReportSales.uncostedReturnCount} returns. Subtract it from
88
+ * `returns` for the credit figure `returnCost` is comparable against.
89
+ * Emitted always, `0` included.
90
+ */
91
+ uncostedReturns?: number;
34
92
  }
35
93
  /**
36
94
  * One IVA rate's slice of a `ReportInvoicesAmounts` bucket.
@@ -306,8 +364,24 @@ declare global {
306
364
  currency: string;
307
365
  /** GROSS revenue of delivered orders in this currency. */
308
366
  total: number;
309
- /** GROSS COGS of those orders. */
367
+ /**
368
+ * GROSS COGS of those orders — **the COSTED ones only**. Read it against
369
+ * `total - uncostedTotal`, never against `total`; see
370
+ * {@link ReportSales.uncostedQuantity} for the whole rule.
371
+ */
310
372
  cost: number;
373
+ /**
374
+ * Delivered orders in this currency whose `Order.cost` is absent — the
375
+ * ones left out of `cost`. Emitted always, `0` included; absence means a
376
+ * build predating the field. Same semantics as
377
+ * {@link ReportSales.uncostedQuantity}, per CURRENCY rather than per day.
378
+ *
379
+ * The order side splits per currency because an order carries one; the
380
+ * RETURN side still cannot, for the reason this interface already states.
381
+ */
382
+ uncostedQuantity?: number;
383
+ /** GROSS revenue of those orders, in this currency. Emitted always, `0` included. */
384
+ uncostedTotal?: number;
311
385
  }
312
386
  /**
313
387
  * One product's damaged-return total on
package/dist/return.d.ts CHANGED
@@ -30,7 +30,37 @@ declare global {
30
30
  * discount. Not what the customer is credited.
31
31
  */
32
32
  subtotal: number;
33
- cost: number;
33
+ /**
34
+ * COGS of the returned units — `Σ(quantity × line cost)` over `items`.
35
+ *
36
+ * ⚠️ **OPTIONAL, and absence means UNKNOWN, never 0** — the same rule
37
+ * {@link Order.cost} states, for the same reason. A line's cost comes
38
+ * from the originating `Order.items[index]`, and an order line can
39
+ * genuinely carry none (a storefront sale of a product whose cost was
40
+ * withdrawn, a MercadoLibre order, any presupuesto conversion predating
41
+ * per-line costing). This aggregate is ALL-OR-NOTHING: one uncosted line
42
+ * makes the whole return uncosted, because a partial sum understates
43
+ * COGS while looking like a measurement.
44
+ *
45
+ * ⚠️ **It is also absent whenever the originating `Order.cost` is** —
46
+ * even when every returned line states one. `Order.cost` is
47
+ * all-or-nothing over ALL the order's lines, so returning the costed
48
+ * line of a mixed order would otherwise reverse a COGS the sale never
49
+ * booked, and `GET /reports?mode=sales` (which drops an uncosted order's
50
+ * whole revenue out of the costed base) would report a LOSS for it. The
51
+ * credit is unaffected — `total` and `subtotal` are always stated — and
52
+ * the per-line `items[].cost` is unaffected too; only this aggregate is
53
+ * withheld.
54
+ *
55
+ * ⚠️ `subtotal - cost` over an absent cost is not a margin, it is the
56
+ * whole credit. `GET /reports?mode=sales` excludes such a return from
57
+ * `returnCost`/`netCost` and counts it under `uncostedReturnCount`
58
+ * instead of defaulting it to zero.
59
+ *
60
+ * Forward-only: every return written before this became optional carries
61
+ * a number, `0` included, and those `0`s are stated costs.
62
+ */
63
+ cost?: number;
34
64
  /**
35
65
  * The amount actually credited — `subtotal` after the originating
36
66
  * order's discount multiplier (`1 - Order.discount / 100`). Must agree
@@ -173,7 +203,20 @@ declare global {
173
203
  sku?: string;
174
204
  quantity: number;
175
205
  price: number;
176
- cost: number;
206
+ /**
207
+ * Unit BUY cost, copied from the originating `Order.items[index]`.
208
+ *
209
+ * ⚠️ **OPTIONAL, and absence means UNKNOWN, never 0.** `Order.items` is
210
+ * `Partial<CartLine>[]`, so a stored order line can carry no cost at all
211
+ * — and it does, on every MercadoLibre line with no catalogue cost and
212
+ * on every storefront line whose product cost was withdrawn. The return
213
+ * planner used to default it to `0`, which booked a stated zero cost onto
214
+ * an immutable return row and reported the credit at 100 % margin.
215
+ *
216
+ * An absent line cost makes the whole `Return.cost` absent — see there.
217
+ * Every row written before this became optional carries a number.
218
+ */
219
+ cost?: number;
177
220
  ivaType: number;
178
221
  condition: 'sellable' | 'damaged';
179
222
  /** Whether this line went back into sellable stock — SERVER-DERIVED from `condition === 'sellable'`, never client-accepted. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.336",
3
+ "version": "1.10.337",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",