hvp-shared 6.21.0 → 6.23.0

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/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './types';
6
6
  export * from './constants';
7
7
  export * from './contracts';
8
8
  export * from './validation';
9
+ export * from './inventory-analysis';
9
10
  export { debugLog } from './utils/debug-logger';
10
11
  export * from './utils/sync-field.helpers';
11
12
  export * from './utils/qvet-catalog.helpers';
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./types"), exports);
23
23
  __exportStar(require("./constants"), exports);
24
24
  __exportStar(require("./contracts"), exports);
25
25
  __exportStar(require("./validation"), exports);
26
+ __exportStar(require("./inventory-analysis"), exports);
26
27
  var debug_logger_1 = require("./utils/debug-logger");
27
28
  Object.defineProperty(exports, "debugLog", { enumerable: true, get: function () { return debug_logger_1.debugLog; } });
28
29
  __exportStar(require("./utils/sync-field.helpers"), exports);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Inventory Analysis Module
3
+ *
4
+ * API contracts for inventory analysis endpoints.
5
+ * Calculation logic lives in hvp-backend domain layer.
6
+ */
7
+ export * from './types';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /**
3
+ * Inventory Analysis Module
4
+ *
5
+ * API contracts for inventory analysis endpoints.
6
+ * Calculation logic lives in hvp-backend domain layer.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,193 @@
1
+ /**
2
+ * Inventory Analysis Types
3
+ *
4
+ * Type definitions for inventory analysis calculations.
5
+ * Used by StockProposalService, ConsumptionAnalysisService, etc.
6
+ */
7
+ import { UsageType } from '../constants/catalog-item.constants';
8
+ /**
9
+ * TrendType - Classification of consumption trend
10
+ *
11
+ * Based on Q/Y ratio (quarterly vs yearly consumption).
12
+ */
13
+ export declare enum TrendType {
14
+ /** Growing: Q/Y ratio > GROWTH_THRESHOLD (recent consumption higher than average) */
15
+ GROWING = "growing",
16
+ /** Stable: ratio between DECLINE_THRESHOLD and GROWTH_THRESHOLD */
17
+ STABLE = "stable",
18
+ /** Declining: Q/Y ratio < DECLINE_THRESHOLD (recent consumption lower than average) */
19
+ DECLINING = "declining",
20
+ /** New: Only recent data exists (no historical baseline) */
21
+ NEW = "new",
22
+ /** No Q4: Has historical data but no recent activity */
23
+ NO_RECENT_ACTIVITY = "noRecentActivity",
24
+ /** No Activity: No consumption data at all */
25
+ NO_ACTIVITY = "noActivity"
26
+ }
27
+ /**
28
+ * Stock days configuration by usage type
29
+ */
30
+ export interface StockDaysConfig {
31
+ /** Days of stock for minimum level */
32
+ minDays: number;
33
+ /** Days of stock for optimal level */
34
+ optimalDays: number;
35
+ }
36
+ /**
37
+ * Consumption data for a product
38
+ */
39
+ export interface ConsumptionData {
40
+ /** Average daily consumption (full period) */
41
+ dailyConsumption: number;
42
+ /** Average daily consumption (recent period, e.g., Q4) */
43
+ dailyConsumptionRecent: number;
44
+ /** Q/Y ratio (recent / full period) */
45
+ qyRatio: number;
46
+ /** Calculated trend type */
47
+ trend: TrendType;
48
+ /** Reference consumption for stock calculation */
49
+ referenceConsumption: number;
50
+ }
51
+ /**
52
+ * Stock proposal for a single product
53
+ */
54
+ export interface StockProposal {
55
+ /** Proposed minimum stock level */
56
+ minStock: number;
57
+ /** Proposed optimal stock level */
58
+ optimalStock: number;
59
+ /** Days of coverage used for min */
60
+ minDays: number;
61
+ /** Days of coverage used for optimal */
62
+ optimalDays: number;
63
+ /** Rounding increment used */
64
+ roundingIncrement: number;
65
+ /** Raw (unrounded) min value */
66
+ rawMinStock: number;
67
+ /** Raw (unrounded) optimal value */
68
+ rawOptimalStock: number;
69
+ }
70
+ /**
71
+ * Complete analysis result for a product
72
+ */
73
+ export interface ProductAnalysis {
74
+ /** QVET product code */
75
+ qvetCode: number;
76
+ /** Product description */
77
+ description: string;
78
+ /** Product section */
79
+ section: string;
80
+ /** Usage type classification */
81
+ usageType: UsageType;
82
+ /** Unit cost (for rounding calculations) */
83
+ unitCost: number;
84
+ /** Sales unit (%, ML, TABLETA, etc.) */
85
+ salesUnit: string;
86
+ /** Consumption analysis */
87
+ consumption: ConsumptionData;
88
+ /** Stock proposal */
89
+ proposal: StockProposal;
90
+ }
91
+ /**
92
+ * Request for stock proposal calculation
93
+ */
94
+ export interface StockProposalRequest {
95
+ /** Start date for consumption analysis (ISO 8601) */
96
+ fromDate: string;
97
+ /** End date for consumption analysis (ISO 8601) */
98
+ toDate: string;
99
+ /** Start date for recent period (e.g., Q4 start) - ISO 8601 */
100
+ recentPeriodStart?: string;
101
+ /** Filter by branch */
102
+ branch?: string;
103
+ /** Filter by section */
104
+ section?: string;
105
+ /** Filter by specific product codes */
106
+ qvetCodes?: number[];
107
+ /** Output format */
108
+ format?: 'json' | 'excel';
109
+ }
110
+ /**
111
+ * Response for stock proposal calculation
112
+ */
113
+ export interface StockProposalResponse {
114
+ /** Metadata about the calculation */
115
+ metadata: {
116
+ /** Analysis date range */
117
+ dateRange: {
118
+ from: string;
119
+ to: string;
120
+ };
121
+ /** Recent period date range */
122
+ recentPeriod: {
123
+ from: string;
124
+ to: string;
125
+ };
126
+ /** Total products analyzed */
127
+ totalProducts: number;
128
+ /** Timestamp of calculation */
129
+ calculatedAt: string;
130
+ };
131
+ /** Product analysis results */
132
+ products: ProductAnalysisResponse[];
133
+ /** Summary statistics */
134
+ summary: {
135
+ /** Count by trend type */
136
+ byTrend: Record<TrendType, number>;
137
+ /** Count by usage type */
138
+ byUsageType: Record<UsageType, number>;
139
+ };
140
+ }
141
+ /**
142
+ * Product analysis for API response (flattened)
143
+ */
144
+ export interface ProductAnalysisResponse {
145
+ qvetCode: number;
146
+ description: string;
147
+ section: string;
148
+ usageType: UsageType;
149
+ dailyConsumption: number;
150
+ dailyConsumptionRecent: number;
151
+ monthlyConsumption: number;
152
+ qyRatio: number;
153
+ trend: TrendType;
154
+ referenceConsumption: number;
155
+ currentStock: {
156
+ warehouse: string;
157
+ stock: number;
158
+ }[];
159
+ totalStock: number;
160
+ minStock: number;
161
+ optimalStock: number;
162
+ minDays: number;
163
+ optimalDays: number;
164
+ roundingIncrement: number;
165
+ unitCost: number;
166
+ proposedMinValue: number;
167
+ proposedOptValue: number;
168
+ }
169
+ /**
170
+ * Stock flow data for a product
171
+ */
172
+ export interface StockFlow {
173
+ /** Initial stock at period start */
174
+ initialStock: number;
175
+ /** Purchases during period */
176
+ purchases: number;
177
+ /** Transfers in (received) */
178
+ transfersIn: number;
179
+ /** Transfers out (sent) */
180
+ transfersOut: number;
181
+ /** Available = initial + purchases + transfersIn - transfersOut */
182
+ available: number;
183
+ /** Units sold */
184
+ sold: number;
185
+ /** Theoretical stock = available - sold */
186
+ theoreticalStock: number;
187
+ /** Actual stock at period end */
188
+ actualStock: number;
189
+ /** Shrinkage (merma) = theoretical - actual */
190
+ shrinkage: number;
191
+ /** Shrinkage value = shrinkage * unitCost */
192
+ shrinkageValue: number;
193
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /**
3
+ * Inventory Analysis Types
4
+ *
5
+ * Type definitions for inventory analysis calculations.
6
+ * Used by StockProposalService, ConsumptionAnalysisService, etc.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.TrendType = void 0;
10
+ // ============================================================================
11
+ // Trend Types
12
+ // ============================================================================
13
+ /**
14
+ * TrendType - Classification of consumption trend
15
+ *
16
+ * Based on Q/Y ratio (quarterly vs yearly consumption).
17
+ */
18
+ var TrendType;
19
+ (function (TrendType) {
20
+ /** Growing: Q/Y ratio > GROWTH_THRESHOLD (recent consumption higher than average) */
21
+ TrendType["GROWING"] = "growing";
22
+ /** Stable: ratio between DECLINE_THRESHOLD and GROWTH_THRESHOLD */
23
+ TrendType["STABLE"] = "stable";
24
+ /** Declining: Q/Y ratio < DECLINE_THRESHOLD (recent consumption lower than average) */
25
+ TrendType["DECLINING"] = "declining";
26
+ /** New: Only recent data exists (no historical baseline) */
27
+ TrendType["NEW"] = "new";
28
+ /** No Q4: Has historical data but no recent activity */
29
+ TrendType["NO_RECENT_ACTIVITY"] = "noRecentActivity";
30
+ /** No Activity: No consumption data at all */
31
+ TrendType["NO_ACTIVITY"] = "noActivity";
32
+ })(TrendType || (exports.TrendType = TrendType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvp-shared",
3
- "version": "6.21.0",
3
+ "version": "6.23.0",
4
4
  "description": "Shared types and utilities for HVP backend and frontend",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",