sinfactura-types 1.10.340 → 1.10.342

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/ai.d.ts CHANGED
@@ -295,5 +295,175 @@ declare global {
295
295
  * of it.
296
296
  */
297
297
  type SupplierDocExtractErrorCode = 'INVALID_BASE64' | 'UNSUPPORTED_MEDIA_TYPE' | 'CONTENT_TOO_LARGE' | 'DOCUMENT_TOO_MANY_PAGES' | 'COST_CEILING_EXCEEDED' | 'AI_DOC_EXTRACT_DISABLED' | 'AI_OPT_OUT' | 'DOC_EXTRACT_BLOCKED' | 'DOC_EXTRACT_TOO_LONG' | 'DOC_EXTRACT_GENERATION_FAILED';
298
+ /**
299
+ * One suggested line.
300
+ *
301
+ * ⚠️ `sku` and `name` are read off the store's OWN product row by the
302
+ * server, never echoed from the model, so they always describe the real
303
+ * catalogue entry behind `productId`. `productId` itself is guaranteed to
304
+ * exist, to belong to the authenticated store and to be sale-eligible — the
305
+ * server refuses the WHOLE draft rather than returning a line it cannot
306
+ * prove all three of.
307
+ */
308
+ interface QuoteDraftLine {
309
+ /** `PROD` + digits — a real, enabled, sale-eligible product of this store. */
310
+ productId: string;
311
+ sku: string;
312
+ name: string;
313
+ /** A whole number of units, 1–999. Never `0`, never fractional, never clamped from something else. */
314
+ quantity: number;
315
+ /**
316
+ * One sentence on why this product answers the request, at most 200
317
+ * characters. Model-generated prose — display it, never parse it.
318
+ */
319
+ rationale: string;
320
+ }
321
+ interface QuoteDraftRequest {
322
+ /**
323
+ * The operator's request, in their own words — 3 to 600 characters.
324
+ *
325
+ * ⚠️ Do NOT put customer data in here. It reaches the model, and this
326
+ * endpoint's whole input-minimisation posture is that nothing personal
327
+ * does (Ley 25.326).
328
+ */
329
+ request: string;
330
+ /**
331
+ * `CUST` + 6–10 digits.
332
+ *
333
+ * ⚠️ ECHOED BACK, never read. The server does not fetch the customer, does
334
+ * not validate it beyond that shape, and never sends it to the model — who
335
+ * a quote is for changes nothing about which products match. It exists so
336
+ * a client can round-trip the quote form's state through the call. The
337
+ * presupuesto CREATE path is what validates the customer.
338
+ */
339
+ customerId?: string;
340
+ }
341
+ /**
342
+ * `data` payload of the success envelope — the body is
343
+ * `{ message, data: QuoteDraftResponse }`.
344
+ *
345
+ * ⚠️ `lines` is never empty on a 200. A draft with no lines is a refusal
346
+ * instead, and WHICH refusal says whether it cost anything — see
347
+ * `QuoteDraftErrorCode`.
348
+ */
349
+ interface QuoteDraftResponse {
350
+ lines: QuoteDraftLine[];
351
+ /**
352
+ * How many catalogue rows the model was actually shown.
353
+ *
354
+ * ⚠️ Read this WITH `truncated`, never instead of it: it is the size of
355
+ * the grounded subset, not the number of products that matched.
356
+ */
357
+ candidateCount: number;
358
+ /**
359
+ * How many of the store's products matched the request and survived
360
+ * eligibility, BEFORE the candidate cap — the denominator `truncated`
361
+ * is a fact about.
362
+ *
363
+ * ⚠️ Read it WITH `candidateCount`: the pair is what lets a client say
364
+ * "60 of 137" rather than the useless "60, and there were more". It is
365
+ * `>= candidateCount` always, and EQUAL to it whenever `truncated` is
366
+ * false. It is a count of matches, NOT of the catalogue — a store with
367
+ * 5 000 products whose request matched 3 reports `3`.
368
+ */
369
+ matchedCount: number;
370
+ /**
371
+ * `true` when MORE of the store's catalogue matched the request than was
372
+ * shown to the model — because the request reduced to more search terms
373
+ * than are searched, because one term's matches were cut, because the
374
+ * union exceeded the candidate cap, or because a term's read spent its
375
+ * page/wall-clock budget before it filled.
376
+ *
377
+ * ⚠️ It means "there may be a better line we never offered", NOT "no
378
+ * match" — those are different answers and the empty case never reaches a
379
+ * 200 at all. A client should surface this as a prompt to narrow the
380
+ * request, and must not present a truncated draft as an exhaustive read of
381
+ * the catalogue.
382
+ */
383
+ truncated: boolean;
384
+ /** The model that produced it. */
385
+ model: string;
386
+ /** Echoed from the request when it was sent — see `QuoteDraftRequest.customerId`. */
387
+ customerId?: string;
388
+ }
389
+ /**
390
+ * The `error` codes this endpoint answers. Bare SCREAMING_SNAKE, no prefix.
391
+ *
392
+ * Three refusal FAMILIES, split on WHO PAID, the same reasoning
393
+ * `SupplierDocExtractErrorCode` records:
394
+ *
395
+ * · FREE — `VALIDATION_FAILED`, `QUOTE_DRAFT_NO_MATCH`,
396
+ * `COST_CEILING_EXCEEDED`, `AI_OPT_OUT`. No model call was made and nothing
397
+ * was metered.
398
+ * · METERED, ordinary — `QUOTE_DRAFT_AMBIGUOUS`. The call ran and the model
399
+ * legitimately found nothing to suggest.
400
+ * · METERED, model fault — `QUOTE_DRAFT_BLOCKED`,
401
+ * `QUOTE_DRAFT_GENERATION_FAILED`, `QUOTE_DRAFT_UNGROUNDED`,
402
+ * `QUOTE_DRAFT_INVALID_QUANTITY`, `QUOTE_DRAFT_DUPLICATE_LINE`,
403
+ * `QUOTE_DRAFT_TOO_MANY_LINES`. The call ran and its output was refused.
404
+ * Retrying spends again and rarely helps.
405
+ *
406
+ * Per member:
407
+ * - `VALIDATION_FAILED` · 400 — the request body failed its schema: `request`
408
+ * outside 3–600 characters after trimming, or a `customerId` that is not
409
+ * `CUST` + 6–10 digits. ⚠️ Listed HERE rather than left to `GatingErrorCode`
410
+ * because it is not a member of that union — it comes from the shared
411
+ * request validator, and the domain unions that can answer it
412
+ * (`PresupuestoErrorCode` among them) each carry it.
413
+ * - `QUOTE_DRAFT_NO_MATCH` · 422 — nothing in the catalogue matched the
414
+ * request at all, so no model call was made. ⚠️ NOT the same answer as
415
+ * `QUOTE_DRAFT_AMBIGUOUS`: this one is free and is fixed by naming a
416
+ * product the store actually sells.
417
+ * - `QUOTE_DRAFT_AMBIGUOUS` · 422 — candidates existed, the model saw them,
418
+ * and it proposed no line. The call WAS metered. Fixed by a more specific
419
+ * request, not by retrying the same one.
420
+ * - `COST_CEILING_EXCEEDED` · 403 OR 503, and the app must switch on which.
421
+ * 403 is the TENANT's own ceiling and carries `feature: 'aiFeatures'`; 503
422
+ * is the platform-wide ceiling and is an operator hard-stop no tenant
423
+ * action clears. ⚠️ Both carry `period: 'daily' | 'monthly'`, and on the
424
+ * 403 `upsell` is TRUE only for `monthly` — a daily ceiling is a single
425
+ * app-scope value applying to every tier, so no upgrade clears it and it
426
+ * resets at midnight instead. ⚠️ The code lands in BOTH `error` and
427
+ * `message`, matching the shipped ceiling mapper: `message` is NOT prose on
428
+ * this member and must not be shown to a user verbatim.
429
+ * - `AI_OPT_OUT` · 403 — this store switched AI off, explicitly. The same code
430
+ * the sibling AI endpoints use, not a second spelling of it. ⚠️ A store read
431
+ * that THREW does NOT answer this: the gate is fail-closed in that it never
432
+ * proceeds, but it RETHROWS, so the wire answer is the wrapper's 500, not a
433
+ * 403. Do not treat this code as covering "AI may be off".
434
+ * - `QUOTE_DRAFT_BLOCKED` · 422 — the guardrail refused the request. ⚠️
435
+ * Carries one DOCUMENTED EXTRA key, `reason: string` — the guardrail's
436
+ * filter TYPE NAMES, never the blocked content. It is the only member with
437
+ * it, so read it optionally rather than off the union.
438
+ * - `QUOTE_DRAFT_GENERATION_FAILED` · 502 — the model answered in a shape
439
+ * that does not parse.
440
+ * - `QUOTE_DRAFT_UNGROUNDED` · 502 — the model named a product that is not in
441
+ * this store's candidate set: an invented id, another store's id, a
442
+ * disabled product, or one that is not sale-eligible. ⚠️ The WHOLE draft is
443
+ * refused, never just the offending line. A silently shorter list is
444
+ * indistinguishable from a complete one, and a model that ignored a closed
445
+ * set it was handed has tainted the ids that happened to be valid too.
446
+ * - `QUOTE_DRAFT_INVALID_QUANTITY` · 502 — a proposed quantity was not a whole
447
+ * number in 1–999. Refused, never clamped and never defaulted to 1:
448
+ * substituting a plausible number hides the misread from the one human who
449
+ * could catch it.
450
+ * - `QUOTE_DRAFT_DUPLICATE_LINE` · 502 — the same product was proposed twice.
451
+ * - `QUOTE_DRAFT_TOO_MANY_LINES` · 502 — more than 20 lines were proposed.
452
+ *
453
+ * ⚠️ Both of those two are REACHABLE, and keeping them so is a constraint on
454
+ * the server rather than a fact about it. They were briefly shadowed: the
455
+ * same two bounds also sat on the model's forced tool schema, which is
456
+ * `safeParse`d BEFORE the belt runs, so an out-of-range quantity or a 21st
457
+ * line was rejected a step earlier and reached the wire as the generic
458
+ * `QUOTE_DRAFT_GENERATION_FAILED`. The bounds now live on the belt alone.
459
+ * ⛔ A client may build a distinct affordance for each; putting either bound
460
+ * back on the tool schema would collapse it again without failing any type.
461
+ *
462
+ * ⚠️ Cross-cutting refusals are NOT listed here and are still reachable —
463
+ * `PLAN_UPGRADE_REQUIRED` above all, since the endpoint is `aiFeatures`-
464
+ * entitled, and `IMPERSONATION_READONLY`, since it is an AI-spend route.
465
+ * Check `GatingErrorCode` IN ADDITION to this union, never instead of it.
466
+ */
467
+ type QuoteDraftErrorCode = 'VALIDATION_FAILED' | 'QUOTE_DRAFT_NO_MATCH' | 'QUOTE_DRAFT_AMBIGUOUS' | 'COST_CEILING_EXCEEDED' | 'AI_OPT_OUT' | 'QUOTE_DRAFT_BLOCKED' | 'QUOTE_DRAFT_GENERATION_FAILED' | 'QUOTE_DRAFT_UNGROUNDED' | 'QUOTE_DRAFT_INVALID_QUANTITY' | 'QUOTE_DRAFT_DUPLICATE_LINE' | 'QUOTE_DRAFT_TOO_MANY_LINES';
298
468
  }
299
469
  export {};
package/dist/ai.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // AI contracts — the MANAGER platform-spend report, plus the tenant-facing
2
2
  // AI suggestion endpoints (product enrichment, supplier-invoice document
3
- // extraction). Every suggestion endpoint here is SUGGESTION-ONLY: each
3
+ // extraction, presupuesto line drafting). Every suggestion endpoint here is
4
+ // SUGGESTION-ONLY: each
4
5
  // section below restates what its own call does not persist.
5
6
  export {};
package/dist/cjs/ai.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  // AI contracts — the MANAGER platform-spend report, plus the tenant-facing
3
3
  // AI suggestion endpoints (product enrichment, supplier-invoice document
4
- // extraction). Every suggestion endpoint here is SUGGESTION-ONLY: each
4
+ // extraction, presupuesto line drafting). Every suggestion endpoint here is
5
+ // SUGGESTION-ONLY: each
5
6
  // section below restates what its own call does not persist.
6
7
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ /**
3
+ * The annualised inventory HOLDING-COST rate a tenant declares about itself —
4
+ * the input a carrying-cost KPI needs and which this platform has never held.
5
+ *
6
+ * ## One rate, not a breakdown
7
+ *
8
+ * A holding-cost assumption is published as ONE annualised percentage, never as
9
+ * itemised categories (capital, storage, insurance, shrinkage, obsolescence). A
10
+ * tenant that fills two of five categories produces a total that LOOKS complete
11
+ * and is not, and no consumer can detect the difference from the wire — a
12
+ * partial breakdown and a deliberate one serialise identically. A single rate is
13
+ * either declared or it is not, and that is a state a consumer can render.
14
+ *
15
+ * ## Effective-dated, because a rate has a history
16
+ *
17
+ * Each rate is stamped with the business day it takes effect, and the whole
18
+ * series is kept. "What rate was in force last quarter" is answerable, so a KPI
19
+ * for an earlier period is computed with the assumption that was actually held
20
+ * then. A single mutable config value cannot answer that question at all, which
21
+ * is why this is not a `Store.config` leaf: the only honest consumer behaviour
22
+ * with a mutable value would be to refuse the KPI for every period before the
23
+ * configuration date.
24
+ *
25
+ * A correction to an effective date already declared is accepted and SUPERSEDES
26
+ * it; both rows survive, so the history records the correction as well as the
27
+ * first answer. See {@link HoldingCostRate}.
28
+ *
29
+ * ⚠️ **Nothing is backfilled and no rate is defaulted.** A period before a
30
+ * tenant's first entry has NO rate, permanently. That is not zero.
31
+ *
32
+ * ## The EOQ order cost is deliberately absent
33
+ *
34
+ * An economic-order-quantity calculation also needs a per-order placement cost.
35
+ * It is NOT published here and no field holds one — `calculateEoq` has no call
36
+ * sites, so an input for it would be a settings field that changes nothing any
37
+ * code path can observe. {@link HoldingCostConfig.orderCostConfigured} is pinned
38
+ * `false` so the exclusion is a stated fact on the wire rather than an omission
39
+ * a consumer has to infer.
40
+ */
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.HOLDING_COST_MIN_ANNUAL_RATE_PERCENT = exports.HOLDING_COST_MAX_ANNUAL_RATE_PERCENT = void 0;
43
+ /**
44
+ * The largest annualised holding-cost rate that may be stored, as a percentage.
45
+ *
46
+ * ⚠️ **1000, not 100, and the market is the reason.** A holding-cost rate is
47
+ * dominated by the cost of capital, and Argentine nominal annual rates have run
48
+ * well past 100% — a ceiling at 100 would refuse an ARS tenant's honest
49
+ * assumption. 1000% is roughly four times the worst policy rate observed here,
50
+ * so it cannot reject a legitimate figure, while still refusing the class this
51
+ * bound exists for: a typo, a fraction sent as basis points, and an unbounded
52
+ * number reaching a stored attribute on an authenticated-adjacent write path.
53
+ *
54
+ * A rate ABOVE this is refused rather than clamped. Clamping would store a
55
+ * number nobody declared and the KPI would then be computed from it silently.
56
+ */
57
+ exports.HOLDING_COST_MAX_ANNUAL_RATE_PERCENT = 1000;
58
+ /** The smallest storable rate. Zero is a legitimate, declared assumption — see {@link HoldingCostRateResolution}. */
59
+ exports.HOLDING_COST_MIN_ANNUAL_RATE_PERCENT = 0;
package/dist/cjs/index.js CHANGED
@@ -42,6 +42,7 @@ __exportStar(require("./customer.js"), exports);
42
42
  __exportStar(require("./cycleCount.js"), exports);
43
43
  __exportStar(require("./delivery.js"), exports);
44
44
  __exportStar(require("./gating.js"), exports);
45
+ __exportStar(require("./holdingCost.js"), exports);
45
46
  __exportStar(require("./demo.js"), exports);
46
47
  __exportStar(require("./impersonation.js"), exports);
47
48
  __exportStar(require("./imports.js"), exports);
@@ -0,0 +1,190 @@
1
+ /**
2
+ * The annualised inventory HOLDING-COST rate a tenant declares about itself —
3
+ * the input a carrying-cost KPI needs and which this platform has never held.
4
+ *
5
+ * ## One rate, not a breakdown
6
+ *
7
+ * A holding-cost assumption is published as ONE annualised percentage, never as
8
+ * itemised categories (capital, storage, insurance, shrinkage, obsolescence). A
9
+ * tenant that fills two of five categories produces a total that LOOKS complete
10
+ * and is not, and no consumer can detect the difference from the wire — a
11
+ * partial breakdown and a deliberate one serialise identically. A single rate is
12
+ * either declared or it is not, and that is a state a consumer can render.
13
+ *
14
+ * ## Effective-dated, because a rate has a history
15
+ *
16
+ * Each rate is stamped with the business day it takes effect, and the whole
17
+ * series is kept. "What rate was in force last quarter" is answerable, so a KPI
18
+ * for an earlier period is computed with the assumption that was actually held
19
+ * then. A single mutable config value cannot answer that question at all, which
20
+ * is why this is not a `Store.config` leaf: the only honest consumer behaviour
21
+ * with a mutable value would be to refuse the KPI for every period before the
22
+ * configuration date.
23
+ *
24
+ * A correction to an effective date already declared is accepted and SUPERSEDES
25
+ * it; both rows survive, so the history records the correction as well as the
26
+ * first answer. See {@link HoldingCostRate}.
27
+ *
28
+ * ⚠️ **Nothing is backfilled and no rate is defaulted.** A period before a
29
+ * tenant's first entry has NO rate, permanently. That is not zero.
30
+ *
31
+ * ## The EOQ order cost is deliberately absent
32
+ *
33
+ * An economic-order-quantity calculation also needs a per-order placement cost.
34
+ * It is NOT published here and no field holds one — `calculateEoq` has no call
35
+ * sites, so an input for it would be a settings field that changes nothing any
36
+ * code path can observe. {@link HoldingCostConfig.orderCostConfigured} is pinned
37
+ * `false` so the exclusion is a stated fact on the wire rather than an omission
38
+ * a consumer has to infer.
39
+ */
40
+ /**
41
+ * The largest annualised holding-cost rate that may be stored, as a percentage.
42
+ *
43
+ * ⚠️ **1000, not 100, and the market is the reason.** A holding-cost rate is
44
+ * dominated by the cost of capital, and Argentine nominal annual rates have run
45
+ * well past 100% — a ceiling at 100 would refuse an ARS tenant's honest
46
+ * assumption. 1000% is roughly four times the worst policy rate observed here,
47
+ * so it cannot reject a legitimate figure, while still refusing the class this
48
+ * bound exists for: a typo, a fraction sent as basis points, and an unbounded
49
+ * number reaching a stored attribute on an authenticated-adjacent write path.
50
+ *
51
+ * A rate ABOVE this is refused rather than clamped. Clamping would store a
52
+ * number nobody declared and the KPI would then be computed from it silently.
53
+ */
54
+ export declare const HOLDING_COST_MAX_ANNUAL_RATE_PERCENT = 1000;
55
+ /** The smallest storable rate. Zero is a legitimate, declared assumption — see {@link HoldingCostRateResolution}. */
56
+ export declare const HOLDING_COST_MIN_ANNUAL_RATE_PERCENT = 0;
57
+ declare global {
58
+ /**
59
+ * ONE declared version of the holding-cost assumption.
60
+ *
61
+ * ⚠️ **Corrections SUPERSEDE and every version is kept.** A second declaration
62
+ * for an effective date already declared is ACCEPTED: it is stored as a new
63
+ * row and becomes the one in force, while the row it replaced stays readable
64
+ * for ever. Nothing is overwritten and nothing is deleted.
65
+ *
66
+ * ⚠️ **`(effectiveFrom, configuredAt)` is the identity of a version, not
67
+ * `effectiveFrom` alone.** Within one effective date the version with the
68
+ * greatest `configuredAt` is the one in force; a consumer keying a map or a
69
+ * table row on `effectiveFrom` will silently drop corrections.
70
+ *
71
+ * The series is the audit of the tenant's accounting assumption: who declared
72
+ * what, when, and what they changed it to.
73
+ */
74
+ interface HoldingCostRate {
75
+ /** `YYYYMMDD` as a NUMBER, Buenos Aires — the first business day this rate applies to. */
76
+ effectiveFrom: number;
77
+ /**
78
+ * Annualised holding cost as a PERCENTAGE of inventory value — `18.5`
79
+ * means 18.5% per year, not `0.185`.
80
+ *
81
+ * Bounded by {@link HOLDING_COST_MAX_ANNUAL_RATE_PERCENT}. `0` is a real,
82
+ * declared answer and is NOT the same as no rate at all.
83
+ */
84
+ annualRatePercent: number;
85
+ /**
86
+ * The catalog currency id (lowercase, e.g. `'ars'`) the assumption was
87
+ * declared against — the store's display currency at configuration time.
88
+ *
89
+ * ⚠️ **Load-bearing even though the rate itself is a percentage.** The KPI
90
+ * multiplies this rate by a valued-inventory figure, which carries its own
91
+ * denomination. A consumer MUST refuse to apply a rate whose `currency`
92
+ * differs from the valuation's, rather than assuming a percentage is
93
+ * denomination-free: a tenant that re-denominated mid-year declared this
94
+ * rate about a different money.
95
+ */
96
+ currency: string;
97
+ /**
98
+ * Unix ms the version was written. The audit instant, and the TIEBREAKER
99
+ * that decides which version of one `effectiveFrom` is in force —
100
+ * `effectiveFrom` is the business label, this is the version.
101
+ */
102
+ configuredAt: number;
103
+ /** The operator user id (`USR…`) that authorised the version. Never a name, never an address. */
104
+ configuredBy: string;
105
+ /** Free-text operator rationale, at most 500 characters. Absent when none was given. */
106
+ note?: string;
107
+ /**
108
+ * SERVER-DERIVED: a LATER declaration for the SAME `effectiveFrom` replaced
109
+ * this one. Always `false` on {@link HoldingCostRateResolution}'s `rate`,
110
+ * which is by definition the surviving version.
111
+ *
112
+ * ⚠️ **Superseded means CORRECTED, never "no longer in force".** A January
113
+ * rate stops applying once a February rate exists, and that is ordinary
114
+ * effective-dating rather than a correction, so it stays `false`. A UI
115
+ * rendering "the rate history" should show a `true` row as a struck-through
116
+ * earlier answer for the same period, not as an expired one.
117
+ *
118
+ * ⚠️ **Two places this flag is weaker than it looks.**
119
+ *
120
+ * On a TRUNCATED history it is PREFIX-RELATIVE. The flag is derived by
121
+ * looking forward through the returned array, so when `historyTruncated`
122
+ * is `true` the last surviving entry for a date can read `false` while a
123
+ * correction for it exists beyond the cut. `historyTruncated` tells you the
124
+ * LIST is a prefix; it does not tell you the labels were computed over one.
125
+ *
126
+ * On a WRITE ECHO it is as-of-write, not authoritative. The allocator is
127
+ * monotonic per process, so two containers declaring the same
128
+ * `effectiveFrom` concurrently can each be told `false` while only the
129
+ * higher key survives as in force. Re-read if the distinction matters; the
130
+ * GET answer is always authoritative.
131
+ */
132
+ superseded: boolean;
133
+ }
134
+ /**
135
+ * Whether this tenant has a rate for the asked-about day, as a DISCRIMINATED
136
+ * UNION rather than an optional number.
137
+ *
138
+ * ⚠️ **Unconfigured and a configured zero are two different answers and the
139
+ * type says so.** `configured: false` means no assumption exists and the KPI
140
+ * must not be rendered at all; `configured: true` with
141
+ * `rate.annualRatePercent === 0` means the tenant declared that it carries no
142
+ * holding cost, which is a real answer worth showing. An optional
143
+ * `annualRatePercent?: number` would collapse both into `undefined`, and a
144
+ * defaulted `0` would collapse both into a number — either way the honest
145
+ * rendering becomes impossible.
146
+ */
147
+ type HoldingCostRateResolution = {
148
+ configured: false;
149
+ } | {
150
+ configured: true;
151
+ rate: HoldingCostRate;
152
+ };
153
+ /**
154
+ * `GET /store?mode=holdingCost[&asOf=YYYYMMDD][&history=true]` payload —
155
+ * admin tier only.
156
+ */
157
+ interface HoldingCostConfig {
158
+ /** The business day the resolution was taken for (`YYYYMMDD`), echoed as resolved — today when unasked. */
159
+ asOf: number;
160
+ /**
161
+ * The version in force on `asOf`: the NEWEST declaration at or before that
162
+ * day — newest by `(effectiveFrom, configuredAt)`, so a same-day correction
163
+ * wins over the version it corrected, not merely the greatest
164
+ * `effectiveFrom`.
165
+ */
166
+ resolution: HoldingCostRateResolution;
167
+ /**
168
+ * EVERY version this tenant has ever declared — superseded ones included —
169
+ * ascending by `effectiveFrom` and then by `configuredAt`. Present only when
170
+ * `history=true` was asked for; absent means "not requested", never "none
171
+ * exist".
172
+ *
173
+ * ⚠️ **Declarations, not surviving values.** This is deliberately not
174
+ * collapsed to one entry per effective date: the point of accepting a
175
+ * correction rather than refusing it is that the correction is VISIBLE, and
176
+ * a collapsed history hides the event. Read each entry's `superseded` flag
177
+ * rather than assuming one row per date.
178
+ */
179
+ history?: HoldingCostRate[];
180
+ /** The history read hit its page budget, so `history` is a PREFIX. Absent when `history` is. */
181
+ historyTruncated?: boolean;
182
+ /**
183
+ * Pinned `false` — see this module's docblock. The EOQ per-order placement
184
+ * cost is deliberately not collected, and this literal is the statement of
185
+ * that, so a consumer never has to read an absent field as "maybe later".
186
+ */
187
+ orderCostConfigured: false;
188
+ }
189
+ }
190
+ export {};
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The annualised inventory HOLDING-COST rate a tenant declares about itself —
3
+ * the input a carrying-cost KPI needs and which this platform has never held.
4
+ *
5
+ * ## One rate, not a breakdown
6
+ *
7
+ * A holding-cost assumption is published as ONE annualised percentage, never as
8
+ * itemised categories (capital, storage, insurance, shrinkage, obsolescence). A
9
+ * tenant that fills two of five categories produces a total that LOOKS complete
10
+ * and is not, and no consumer can detect the difference from the wire — a
11
+ * partial breakdown and a deliberate one serialise identically. A single rate is
12
+ * either declared or it is not, and that is a state a consumer can render.
13
+ *
14
+ * ## Effective-dated, because a rate has a history
15
+ *
16
+ * Each rate is stamped with the business day it takes effect, and the whole
17
+ * series is kept. "What rate was in force last quarter" is answerable, so a KPI
18
+ * for an earlier period is computed with the assumption that was actually held
19
+ * then. A single mutable config value cannot answer that question at all, which
20
+ * is why this is not a `Store.config` leaf: the only honest consumer behaviour
21
+ * with a mutable value would be to refuse the KPI for every period before the
22
+ * configuration date.
23
+ *
24
+ * A correction to an effective date already declared is accepted and SUPERSEDES
25
+ * it; both rows survive, so the history records the correction as well as the
26
+ * first answer. See {@link HoldingCostRate}.
27
+ *
28
+ * ⚠️ **Nothing is backfilled and no rate is defaulted.** A period before a
29
+ * tenant's first entry has NO rate, permanently. That is not zero.
30
+ *
31
+ * ## The EOQ order cost is deliberately absent
32
+ *
33
+ * An economic-order-quantity calculation also needs a per-order placement cost.
34
+ * It is NOT published here and no field holds one — `calculateEoq` has no call
35
+ * sites, so an input for it would be a settings field that changes nothing any
36
+ * code path can observe. {@link HoldingCostConfig.orderCostConfigured} is pinned
37
+ * `false` so the exclusion is a stated fact on the wire rather than an omission
38
+ * a consumer has to infer.
39
+ */
40
+ /**
41
+ * The largest annualised holding-cost rate that may be stored, as a percentage.
42
+ *
43
+ * ⚠️ **1000, not 100, and the market is the reason.** A holding-cost rate is
44
+ * dominated by the cost of capital, and Argentine nominal annual rates have run
45
+ * well past 100% — a ceiling at 100 would refuse an ARS tenant's honest
46
+ * assumption. 1000% is roughly four times the worst policy rate observed here,
47
+ * so it cannot reject a legitimate figure, while still refusing the class this
48
+ * bound exists for: a typo, a fraction sent as basis points, and an unbounded
49
+ * number reaching a stored attribute on an authenticated-adjacent write path.
50
+ *
51
+ * A rate ABOVE this is refused rather than clamped. Clamping would store a
52
+ * number nobody declared and the KPI would then be computed from it silently.
53
+ */
54
+ export const HOLDING_COST_MAX_ANNUAL_RATE_PERCENT = 1000;
55
+ /** The smallest storable rate. Zero is a legitimate, declared assumption — see {@link HoldingCostRateResolution}. */
56
+ export const HOLDING_COST_MIN_ANNUAL_RATE_PERCENT = 0;
package/dist/index.d.ts CHANGED
@@ -18,6 +18,7 @@ export * from './customer.ts';
18
18
  export * from './cycleCount.ts';
19
19
  export * from './delivery.ts';
20
20
  export * from './gating.ts';
21
+ export * from './holdingCost.ts';
21
22
  export * from './demo.ts';
22
23
  export * from './impersonation.ts';
23
24
  export * from './imports.ts';
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ export * from "./customer.js";
26
26
  export * from "./cycleCount.js";
27
27
  export * from "./delivery.js";
28
28
  export * from "./gating.js";
29
+ export * from "./holdingCost.js";
29
30
  export * from "./demo.js";
30
31
  export * from "./impersonation.js";
31
32
  export * from "./imports.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.340",
3
+ "version": "1.10.342",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",