sinfactura-types 1.10.340 → 1.10.341

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.
@@ -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.341",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",