sinfactura-types 1.10.337 → 1.10.339

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.
@@ -216,6 +216,14 @@ declare global {
216
216
  * status edit) leaves the attribute ABSENT rather than writing a default, so
217
217
  * a row without it is not a row whose reason was lost.
218
218
  *
219
+ * ⚠️ **It can arrive on the PARENT's frame, not only on an occurrence's** —
220
+ * and a client that only expects the latter will miss the most common case.
221
+ * Excluding the series' own FIRST date cancels the parent row itself, and
222
+ * the cancelled copy is dropped from the batch by the emit-once filter, so
223
+ * the frame the store receives is the re-read parent. It carries the reason.
224
+ * Branch on the field, never on whether the row looks like a parent or an
225
+ * occurrence.
226
+ *
219
227
  * ⚠️ **Forward-only** — rows cancelled before this shipped carry nothing,
220
228
  * and nothing backfills them. A historical `CANCELLED` occurrence of a
221
229
  * skipped date is therefore indistinguishable from a real cancellation, by
package/dist/report.d.ts CHANGED
@@ -440,5 +440,163 @@ declare global {
440
440
  */
441
441
  costlessProducts?: string[];
442
442
  }
443
+ /**
444
+ * ONE observed day of the inventory-value series — one valued snapshot of a
445
+ * store's whole catalogue, written by the nightly job and never recomputed.
446
+ *
447
+ * ⚠️ **A point exists only for a day that was actually MEASURED.** There is no
448
+ * row for a day before the job first ran for this store, none for a night the
449
+ * job could not finish the store, and none for a night its catalogue read came
450
+ * back short. The series is therefore SPARSE by design and a consumer must
451
+ * render a gap: interpolating one, or drawing a zero, asserts a valuation
452
+ * nobody took. {@link InventoryValueSeriesCoverage} is how a caller tells the
453
+ * two apart without inspecting the array.
454
+ *
455
+ * ⚠️ **The figures are a SNAPSHOT of the moment they were taken, not a day's
456
+ * aggregate.** The job runs shortly after Buenos Aires midnight, so `date` is
457
+ * the business day the valuation OPENS — never a close, never an average.
458
+ */
459
+ interface InventoryValuePoint {
460
+ /** `YYYYMMDD` as a NUMBER, Buenos Aires — the business day this valuation opens. */
461
+ date: number;
462
+ /** Unix ms the snapshot was taken. The point's real instant; `date` is its label. */
463
+ observedAt: number;
464
+ /**
465
+ * Σ (`Product.cost` × `Product.stock`), FX-converted into `currency`.
466
+ *
467
+ * ⚠️ **A FLOOR whenever `costlessProducts` or `unconvertedProducts` is
468
+ * non-zero** — an unvalued product contributes its UNITS to `units` and
469
+ * NOTHING here, because an absent cost means UNVALUED and never zero
470
+ * ({@link Product.cost}). `complete` beside it is the single flag that says
471
+ * whether this figure describes the whole catalogue.
472
+ *
473
+ * ⚠️ Store-wide, on the same last-cost basis `GET /reports?mode=stocks`
474
+ * uses at its store scope. It is NOT a per-warehouse figure and none is
475
+ * published — see {@link InventoryValueSeries.scope}.
476
+ */
477
+ value: number;
478
+ /** The catalog currency id `value` is denominated in. Per point, because a store may change it. */
479
+ currency: string;
480
+ /** Σ `Product.stock` over the same catalogue — counted for EVERY product, valued or not. */
481
+ units: number;
482
+ /** Non-disabled products folded into this point, valued or not. */
483
+ products: number;
484
+ /**
485
+ * Products counted in `units` but excluded from `value` for carrying no
486
+ * `cost`. Same name, same meaning and same remedy as
487
+ * `GET /reports?mode=stocks`' own `costlessProducts` — a cost on the
488
+ * PRODUCT. Emitted always, `0` included: a `0` is the positive statement
489
+ * that nothing was left out for want of a cost.
490
+ */
491
+ costlessProducts: number;
492
+ /**
493
+ * The OTHER excluded population: products costed in a currency the store
494
+ * holds no trustworthy rate for. Remedy is a currency subscription on the
495
+ * STORE, which is why it is not folded into `costlessProducts`. A product
496
+ * can be in both and is counted in both. Emitted always, `0` included.
497
+ */
498
+ unconvertedProducts: number;
499
+ /** The catalog currency ids behind `unconvertedProducts`, ascending. Empty when none. */
500
+ unconvertedCurrencies: string[];
501
+ /** `costlessProducts === 0 && unconvertedProducts === 0` — `value` covers the whole catalogue. */
502
+ complete: boolean;
503
+ }
504
+ /**
505
+ * What the caller asked for versus what was actually observed.
506
+ *
507
+ * ⚠️ **This is the part of the response that carries the platform's honesty
508
+ * about history, and it must be read before the points are charted.** The
509
+ * series begins the day the nightly job first ran for a store. Dates before
510
+ * that were never measured, are never manufactured, and will never appear —
511
+ * this platform is forward-only and nothing backfills them.
512
+ */
513
+ interface InventoryValueSeriesCoverage {
514
+ /** The requested window, inclusive, echoed as resolved (`YYYYMMDD`). */
515
+ from: number;
516
+ to: number;
517
+ /** Calendar days in `[from, to]`, inclusive. */
518
+ requestedDays: number;
519
+ /** Days in that window that carry a real observation — `points.length`. */
520
+ observedDays: number;
521
+ /** `requestedDays - observedDays`. Days with NO valuation, for any reason. */
522
+ missingDays: number;
523
+ /** Earliest / latest observed day INSIDE the window. Absent when nothing was observed. */
524
+ firstObserved?: number;
525
+ lastObserved?: number;
526
+ /**
527
+ * The earliest day this store has ANY observation for, window or not —
528
+ * i.e. the day its history begins. `null` when the store has never been
529
+ * snapshotted at all (the job has not run for it yet).
530
+ */
531
+ historyBeginsOn: number | null;
532
+ /**
533
+ * The whole requested window lies BEFORE this store's first observation,
534
+ * so the empty `points` array means "not measured", never "worth nothing".
535
+ * `false` whenever `historyBeginsOn` is `null` — a store with no history at
536
+ * all is not a store whose history starts later.
537
+ */
538
+ beforeHistory: boolean;
539
+ }
540
+ /**
541
+ * `GET /reports?mode=inventory-value-series&from=YYYYMMDD&to=YYYYMMDD` payload
542
+ * — ADMIN/MANAGER, behind `advancedReports`.
543
+ *
544
+ * ⚠️ **STORE-WIDE ONLY, and there is deliberately no warehouse dimension.**
545
+ * The per-warehouse book (`InventoryLevel`) is written exclusively by explicit
546
+ * operator inventory actions — receipts, adjustments, write-offs, transfers.
547
+ * The order and sale paths move `Product.stock` and never touch a level row,
548
+ * by documented design. A per-warehouse valued SERIES would therefore trend
549
+ * upward for a store that sells everything it receives, and no label prevents
550
+ * a line chart from being read as inventory value. So the dimension is absent
551
+ * rather than captioned, and `scope` is pinned to the one book that sees every
552
+ * movement.
553
+ */
554
+ /**
555
+ * What one nightly inventory-value run did, as its EventBridge response body.
556
+ *
557
+ * Not a browser-facing payload — the only reader is an operator reading a log
558
+ * line — but it is published beside the series it fills because the two must
559
+ * describe the same states in the same words: every counter here is a way a
560
+ * day can be ABSENT from {@link InventoryValueSeries}, and a fourth one added
561
+ * to the job without a name here is a gap nobody can account for.
562
+ */
563
+ interface InventoryValueSnapshotRunResult {
564
+ /** Tenants on the roster. A FLOOR, not a count, when `rosterTruncated`. */
565
+ stores: number;
566
+ /** Tenants that got a NEW point for `date`. */
567
+ storesObserved: number;
568
+ /** Tenants whose day was ALREADY observed — the conditional put refused it. A healthy outcome. */
569
+ storesAlreadyObserved: number;
570
+ /** Tenants whose catalogue read came back short, so NO row was written and the day stays absent. */
571
+ storesTruncated: number;
572
+ storesFailed: number;
573
+ /** Tenants the run's clock never reached. */
574
+ storesUnreached: number;
575
+ rosterTruncated: boolean;
576
+ /** The Buenos Aires business day every row this run wrote is labelled with. */
577
+ date: number;
578
+ /** Every tenant on the roster ended with a point for `date`, new or already present. */
579
+ complete: boolean;
580
+ }
581
+ interface InventoryValueSeries {
582
+ /** Pinned. The literal exists so a future second scope cannot arrive unannounced. */
583
+ scope: 'store';
584
+ /** Observed days only, ascending by `date`. SPARSE — see {@link InventoryValuePoint}. */
585
+ points: InventoryValuePoint[];
586
+ coverage: InventoryValueSeriesCoverage;
587
+ /**
588
+ * The denomination of the LATEST point. Absent when nothing was observed.
589
+ * ⚠️ Not a property of the series: read each point's own `currency`
590
+ * whenever `mixedCurrency` is `true`.
591
+ */
592
+ currency?: string;
593
+ /**
594
+ * The window's points are not all in one denomination, because the store
595
+ * changed its display currency inside it. Each point is internally
596
+ * consistent; the SERIES is not comparable across the change, and a
597
+ * consumer must not chart the values as one line.
598
+ */
599
+ mixedCurrency: boolean;
600
+ }
443
601
  }
444
602
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.337",
3
+ "version": "1.10.339",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",