hvp-shared 7.0.0 → 7.2.1
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/constants/background-job.constants.d.ts +0 -6
- package/dist/constants/background-job.constants.js +2 -14
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/inventory-report/index.d.ts +8 -0
- package/dist/contracts/inventory-report/index.js +24 -0
- package/dist/contracts/inventory-report/requests.d.ts +27 -0
- package/dist/contracts/inventory-report/requests.js +10 -0
- package/dist/contracts/inventory-report/responses.d.ts +81 -0
- package/dist/contracts/inventory-report/responses.js +10 -0
- package/dist/contracts/inventory-report/types.d.ts +294 -0
- package/dist/contracts/inventory-report/types.js +57 -0
- package/dist/contracts/qvet/responses.d.ts +0 -37
- package/package.json +1 -1
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* Job types for QVET sync operations
|
|
9
9
|
*/
|
|
10
10
|
export declare enum JobType {
|
|
11
|
-
SYNC_SALES = "SYNC_SALES",
|
|
12
11
|
SYNC_PURCHASES = "SYNC_PURCHASES",
|
|
13
12
|
SYNC_INVENTORY = "SYNC_INVENTORY",
|
|
14
13
|
SYNC_TRANSFERS = "SYNC_TRANSFERS",
|
|
@@ -18,7 +17,6 @@ export declare enum JobType {
|
|
|
18
17
|
SYNC_CASH_FLOWS = "SYNC_CASH_FLOWS",
|
|
19
18
|
SYNC_PURCHASE_INVOICES = "SYNC_PURCHASE_INVOICES",
|
|
20
19
|
SYNC_PURCHASE_ORDERS = "SYNC_PURCHASE_ORDERS",
|
|
21
|
-
SYNC_STOCK_CONFIG = "SYNC_STOCK_CONFIG",
|
|
22
20
|
SYNC_CATALOG = "SYNC_CATALOG",
|
|
23
21
|
SYNC_SUPPLIERS = "SYNC_SUPPLIERS",
|
|
24
22
|
SYNC_CLIENTS = "SYNC_CLIENTS",
|
|
@@ -38,8 +36,6 @@ export declare enum JobType {
|
|
|
38
36
|
* Each report type has specific parameter requirements.
|
|
39
37
|
*/
|
|
40
38
|
export declare enum ReportType {
|
|
41
|
-
/** Sales report - uses date range params */
|
|
42
|
-
SALES = "SALES",
|
|
43
39
|
/** Purchases report - uses date range params */
|
|
44
40
|
PURCHASES = "PURCHASES",
|
|
45
41
|
/** Inventory movements report - uses date range params */
|
|
@@ -62,8 +58,6 @@ export declare enum ReportType {
|
|
|
62
58
|
CLIENTS = "CLIENTS",
|
|
63
59
|
/** Product catalog - no date params required */
|
|
64
60
|
CATALOG = "CATALOG",
|
|
65
|
-
/** Stock configuration - no date params required */
|
|
66
|
-
STOCK_CONFIG = "STOCK_CONFIG",
|
|
67
61
|
/** Suppliers catalog - no date params required */
|
|
68
62
|
SUPPLIERS = "SUPPLIERS",
|
|
69
63
|
/** Collection details (Cobros detalle) - uses date range params */
|
|
@@ -12,7 +12,6 @@ exports.JOB_STATUS_LABELS = exports.JOB_STEP_LABELS = exports.SUB_TASK_STATUS_LA
|
|
|
12
12
|
*/
|
|
13
13
|
var JobType;
|
|
14
14
|
(function (JobType) {
|
|
15
|
-
JobType["SYNC_SALES"] = "SYNC_SALES";
|
|
16
15
|
JobType["SYNC_PURCHASES"] = "SYNC_PURCHASES";
|
|
17
16
|
JobType["SYNC_INVENTORY"] = "SYNC_INVENTORY";
|
|
18
17
|
JobType["SYNC_TRANSFERS"] = "SYNC_TRANSFERS";
|
|
@@ -22,7 +21,6 @@ var JobType;
|
|
|
22
21
|
JobType["SYNC_CASH_FLOWS"] = "SYNC_CASH_FLOWS";
|
|
23
22
|
JobType["SYNC_PURCHASE_INVOICES"] = "SYNC_PURCHASE_INVOICES";
|
|
24
23
|
JobType["SYNC_PURCHASE_ORDERS"] = "SYNC_PURCHASE_ORDERS";
|
|
25
|
-
JobType["SYNC_STOCK_CONFIG"] = "SYNC_STOCK_CONFIG";
|
|
26
24
|
JobType["SYNC_CATALOG"] = "SYNC_CATALOG";
|
|
27
25
|
JobType["SYNC_SUPPLIERS"] = "SYNC_SUPPLIERS";
|
|
28
26
|
JobType["SYNC_CLIENTS"] = "SYNC_CLIENTS";
|
|
@@ -43,8 +41,6 @@ var JobType;
|
|
|
43
41
|
*/
|
|
44
42
|
var ReportType;
|
|
45
43
|
(function (ReportType) {
|
|
46
|
-
/** Sales report - uses date range params */
|
|
47
|
-
ReportType["SALES"] = "SALES";
|
|
48
44
|
/** Purchases report - uses date range params */
|
|
49
45
|
ReportType["PURCHASES"] = "PURCHASES";
|
|
50
46
|
/** Inventory movements report - uses date range params */
|
|
@@ -67,8 +63,6 @@ var ReportType;
|
|
|
67
63
|
ReportType["CLIENTS"] = "CLIENTS";
|
|
68
64
|
/** Product catalog - no date params required */
|
|
69
65
|
ReportType["CATALOG"] = "CATALOG";
|
|
70
|
-
/** Stock configuration - no date params required */
|
|
71
|
-
ReportType["STOCK_CONFIG"] = "STOCK_CONFIG";
|
|
72
66
|
/** Suppliers catalog - no date params required */
|
|
73
67
|
ReportType["SUPPLIERS"] = "SUPPLIERS";
|
|
74
68
|
/** Collection details (Cobros detalle) - uses date range params */
|
|
@@ -99,7 +93,6 @@ var SubTaskStatus;
|
|
|
99
93
|
* Mapping of report types to their parameter type
|
|
100
94
|
*/
|
|
101
95
|
exports.REPORT_PARAM_TYPES = {
|
|
102
|
-
[ReportType.SALES]: 'date_range',
|
|
103
96
|
[ReportType.PURCHASES]: 'date_range',
|
|
104
97
|
[ReportType.MOVEMENTS]: 'date_range',
|
|
105
98
|
[ReportType.TRANSFERS]: 'date_range',
|
|
@@ -111,7 +104,6 @@ exports.REPORT_PARAM_TYPES = {
|
|
|
111
104
|
[ReportType.INVENTORY_SNAPSHOT]: 'snapshot',
|
|
112
105
|
[ReportType.CLIENTS]: 'no_params',
|
|
113
106
|
[ReportType.CATALOG]: 'no_params',
|
|
114
|
-
[ReportType.STOCK_CONFIG]: 'no_params',
|
|
115
107
|
[ReportType.SUPPLIERS]: 'no_params',
|
|
116
108
|
[ReportType.COLLECTION_DETAILS]: 'date_range',
|
|
117
109
|
[ReportType.SALE_DETAILS]: 'date_range',
|
|
@@ -145,7 +137,6 @@ var JobStep;
|
|
|
145
137
|
* Human-readable labels for job types (Spanish for UI)
|
|
146
138
|
*/
|
|
147
139
|
exports.JOB_TYPE_LABELS = {
|
|
148
|
-
[JobType.SYNC_SALES]: 'Sincronizar Ventas',
|
|
149
140
|
[JobType.SYNC_PURCHASES]: 'Sincronizar Compras',
|
|
150
141
|
[JobType.SYNC_INVENTORY]: 'Sincronizar Inventario',
|
|
151
142
|
[JobType.SYNC_TRANSFERS]: 'Sincronizar Traspasos',
|
|
@@ -155,13 +146,12 @@ exports.JOB_TYPE_LABELS = {
|
|
|
155
146
|
[JobType.SYNC_CASH_FLOWS]: 'Sincronizar Entradas/Salidas',
|
|
156
147
|
[JobType.SYNC_PURCHASE_INVOICES]: 'Sincronizar Facturas Compra',
|
|
157
148
|
[JobType.SYNC_PURCHASE_ORDERS]: 'Sincronizar Pedidos',
|
|
158
|
-
[JobType.SYNC_STOCK_CONFIG]: 'Sincronizar Config. Stock',
|
|
159
149
|
[JobType.SYNC_CATALOG]: 'Sincronizar Catálogo',
|
|
160
150
|
[JobType.SYNC_SUPPLIERS]: 'Sincronizar Proveedores',
|
|
161
151
|
[JobType.SYNC_CLIENTS]: 'Sincronizar Clientes',
|
|
162
152
|
[JobType.SYNC_INVENTORY_SNAPSHOT]: 'Sincronizar Snapshot Inventario',
|
|
163
153
|
[JobType.SYNC_COLLECTION_DETAILS]: 'Sincronizar Cobros Detalle',
|
|
164
|
-
[JobType.SYNC_SALE_DETAILS]: 'Sincronizar
|
|
154
|
+
[JobType.SYNC_SALE_DETAILS]: 'Sincronizar Ventas',
|
|
165
155
|
[JobType.SYNC_PAYABLES]: 'Sincronizar Cuentas por Pagar',
|
|
166
156
|
[JobType.SYNC_STAFF]: 'Sincronizar Personal',
|
|
167
157
|
[JobType.SYNC_PETS]: 'Sincronizar Mascotas',
|
|
@@ -174,7 +164,6 @@ exports.JOB_TYPE_LABELS = {
|
|
|
174
164
|
* Human-readable labels for report types (Spanish for UI)
|
|
175
165
|
*/
|
|
176
166
|
exports.REPORT_TYPE_LABELS = {
|
|
177
|
-
[ReportType.SALES]: 'Ventas',
|
|
178
167
|
[ReportType.PURCHASES]: 'Compras',
|
|
179
168
|
[ReportType.MOVEMENTS]: 'Movimientos',
|
|
180
169
|
[ReportType.TRANSFERS]: 'Traspasos',
|
|
@@ -186,10 +175,9 @@ exports.REPORT_TYPE_LABELS = {
|
|
|
186
175
|
[ReportType.INVENTORY_SNAPSHOT]: 'Cortes de Inventario',
|
|
187
176
|
[ReportType.CLIENTS]: 'Clientes',
|
|
188
177
|
[ReportType.CATALOG]: 'Catálogo',
|
|
189
|
-
[ReportType.STOCK_CONFIG]: 'Config. Stock',
|
|
190
178
|
[ReportType.SUPPLIERS]: 'Proveedores',
|
|
191
179
|
[ReportType.COLLECTION_DETAILS]: 'Cobros Detalle',
|
|
192
|
-
[ReportType.SALE_DETAILS]: '
|
|
180
|
+
[ReportType.SALE_DETAILS]: 'Ventas',
|
|
193
181
|
[ReportType.PAYABLES]: 'Cuentas por Pagar',
|
|
194
182
|
[ReportType.STAFF]: 'Personal',
|
|
195
183
|
[ReportType.PETS]: 'Mascotas',
|
package/dist/contracts/index.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Inventory Report API Contracts
|
|
4
|
+
*
|
|
5
|
+
* Types, request and response definitions for inventory report endpoints.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
__exportStar(require("./types"), exports);
|
|
23
|
+
__exportStar(require("./requests"), exports);
|
|
24
|
+
__exportStar(require("./responses"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inventory Report Requests
|
|
3
|
+
*
|
|
4
|
+
* Request types for inventory report generation.
|
|
5
|
+
*
|
|
6
|
+
* @example POST /api/inventory/reports/generate
|
|
7
|
+
* @example GET /api/inventory/reports/periods
|
|
8
|
+
*/
|
|
9
|
+
import { ReportPeriodType } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Generate Inventory Report Request
|
|
12
|
+
*
|
|
13
|
+
* Generates a complete inventory report for the specified period.
|
|
14
|
+
*
|
|
15
|
+
* @example POST /api/inventory/reports/generate
|
|
16
|
+
* { "periodType": "monthly", "year": 2026, "month": 3 }
|
|
17
|
+
*/
|
|
18
|
+
export interface GenerateInventoryReportRequest {
|
|
19
|
+
/** Period type */
|
|
20
|
+
periodType: ReportPeriodType;
|
|
21
|
+
/** Year */
|
|
22
|
+
year: number;
|
|
23
|
+
/** Month (1-12) — required for monthly, start month for quarterly */
|
|
24
|
+
month: number;
|
|
25
|
+
/** Branch filter (omit for global report) */
|
|
26
|
+
branch?: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Inventory Report Requests
|
|
4
|
+
*
|
|
5
|
+
* Request types for inventory report generation.
|
|
6
|
+
*
|
|
7
|
+
* @example POST /api/inventory/reports/generate
|
|
8
|
+
* @example GET /api/inventory/reports/periods
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inventory Report Responses
|
|
3
|
+
*
|
|
4
|
+
* Response types for inventory report endpoints.
|
|
5
|
+
*
|
|
6
|
+
* @example POST /api/inventory/reports/generate
|
|
7
|
+
* @example GET /api/inventory/reports/periods
|
|
8
|
+
*/
|
|
9
|
+
import { ReportSummary, FlowByCategory, TopShrinkageItem, PurchaseVsSaleItem, ConsumptionItem, CfAnomalyItem, PeriodComparisonRow } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Full Inventory Report Response
|
|
12
|
+
*
|
|
13
|
+
* Contains all 7 report sections.
|
|
14
|
+
*
|
|
15
|
+
* @example POST /api/inventory/reports/generate
|
|
16
|
+
*/
|
|
17
|
+
export interface InventoryReportResponse {
|
|
18
|
+
/** Section 1: Executive summary with key metrics */
|
|
19
|
+
summary: ReportSummary;
|
|
20
|
+
/** Section 2: Stock flow aggregated by usageType */
|
|
21
|
+
flowByCategory: FlowByCategory[];
|
|
22
|
+
/** Section 3: Products with highest real shrinkage (excludes consumption and CF artifacts) */
|
|
23
|
+
topShrinkage: TopShrinkageItem[];
|
|
24
|
+
/** Section 4: Purchase vs sale analysis for directSale items */
|
|
25
|
+
purchaseVsSale: PurchaseVsSaleItem[];
|
|
26
|
+
/** Section 5: Internal consumption analysis for internalUse items */
|
|
27
|
+
consumption: ConsumptionItem[];
|
|
28
|
+
/** Section 6: Items flagged as possible conversion factor anomalies */
|
|
29
|
+
cfAnomalies: CfAnomalyItem[];
|
|
30
|
+
/** Section 7: Period-over-period comparison metrics */
|
|
31
|
+
periodComparison: PeriodComparisonRow[];
|
|
32
|
+
/** Report generation metadata */
|
|
33
|
+
metadata: ReportMetadata;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Report generation metadata
|
|
37
|
+
*/
|
|
38
|
+
export interface ReportMetadata {
|
|
39
|
+
/** When the report was generated */
|
|
40
|
+
generatedAt: string;
|
|
41
|
+
/** Period date range */
|
|
42
|
+
period: {
|
|
43
|
+
from: string;
|
|
44
|
+
to: string;
|
|
45
|
+
};
|
|
46
|
+
/** Previous period date range (for comparison) */
|
|
47
|
+
previousPeriod?: {
|
|
48
|
+
from: string;
|
|
49
|
+
to: string;
|
|
50
|
+
};
|
|
51
|
+
/** Branch filter applied */
|
|
52
|
+
branch?: string;
|
|
53
|
+
/** Number of months in the period */
|
|
54
|
+
periodMonths: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Available Report Period
|
|
58
|
+
*
|
|
59
|
+
* Represents a period that can be generated (has snapshot data).
|
|
60
|
+
*/
|
|
61
|
+
export interface AvailableReportPeriod {
|
|
62
|
+
/** Year */
|
|
63
|
+
year: number;
|
|
64
|
+
/** Month (1-12) */
|
|
65
|
+
month: number;
|
|
66
|
+
/** Label for display (e.g., "Marzo 2026") */
|
|
67
|
+
label: string;
|
|
68
|
+
/** Snapshot date used for end of period */
|
|
69
|
+
snapshotDate: string;
|
|
70
|
+
/** Total items in snapshot */
|
|
71
|
+
totalItems: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Available Periods Response
|
|
75
|
+
*
|
|
76
|
+
* @example GET /api/inventory/reports/periods
|
|
77
|
+
*/
|
|
78
|
+
export interface AvailablePeriodsResponse {
|
|
79
|
+
/** Available monthly periods (sorted newest first) */
|
|
80
|
+
months: AvailableReportPeriod[];
|
|
81
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Inventory Report Responses
|
|
4
|
+
*
|
|
5
|
+
* Response types for inventory report endpoints.
|
|
6
|
+
*
|
|
7
|
+
* @example POST /api/inventory/reports/generate
|
|
8
|
+
* @example GET /api/inventory/reports/periods
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inventory Report Types
|
|
3
|
+
*
|
|
4
|
+
* Domain types for periodic inventory reports (monthly, quarterly, annual).
|
|
5
|
+
* These reports aggregate stock flow data, detect anomalies, and compare periods.
|
|
6
|
+
*/
|
|
7
|
+
import { StockFlow } from '../stock-calculation/types';
|
|
8
|
+
/**
|
|
9
|
+
* Report period type
|
|
10
|
+
*/
|
|
11
|
+
export declare enum ReportPeriodType {
|
|
12
|
+
monthly = "monthly",
|
|
13
|
+
quarterly = "quarterly",
|
|
14
|
+
annual = "annual"
|
|
15
|
+
}
|
|
16
|
+
export declare const REPORT_PERIOD_TYPE_LABELS: Record<ReportPeriodType, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Shrinkage flag — classifies the nature of each product's shrinkage
|
|
19
|
+
*/
|
|
20
|
+
export declare enum ShrinkageFlag {
|
|
21
|
+
/** Real unexplained loss */
|
|
22
|
+
realLoss = "real_loss",
|
|
23
|
+
/** Likely caused by conversion factor mismatch */
|
|
24
|
+
conversionArtifact = "conversion_artifact",
|
|
25
|
+
/** Expected consumption (internalUse items) */
|
|
26
|
+
expectedConsumption = "expected_consumption",
|
|
27
|
+
/** Surplus — more stock than expected */
|
|
28
|
+
surplus = "surplus",
|
|
29
|
+
/** Negligible (within tolerance) */
|
|
30
|
+
negligible = "negligible"
|
|
31
|
+
}
|
|
32
|
+
export declare const SHRINKAGE_FLAG_LABELS: Record<ShrinkageFlag, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Section 1: Executive Summary
|
|
35
|
+
*/
|
|
36
|
+
export interface ReportSummary {
|
|
37
|
+
/** Period date range */
|
|
38
|
+
period: {
|
|
39
|
+
from: string;
|
|
40
|
+
to: string;
|
|
41
|
+
};
|
|
42
|
+
/** Branch filter applied (undefined = all) */
|
|
43
|
+
branch?: string;
|
|
44
|
+
/** Stock value at period end (PVP) */
|
|
45
|
+
endStockValuePvp: number;
|
|
46
|
+
/** Stock value at period end (unit cost / PMPC) */
|
|
47
|
+
endStockValueCost: number;
|
|
48
|
+
/** Total products with movement in period */
|
|
49
|
+
productsWithMovement: number;
|
|
50
|
+
/** Total products in catalog */
|
|
51
|
+
totalCatalogProducts: number;
|
|
52
|
+
/** Aggregate purchase quantity */
|
|
53
|
+
totalPurchasesQty: number;
|
|
54
|
+
/** Aggregate purchase value (cost) */
|
|
55
|
+
totalPurchasesValue: number;
|
|
56
|
+
/** Aggregate sales quantity */
|
|
57
|
+
totalSalesQty: number;
|
|
58
|
+
/** Aggregate sales value (cost) */
|
|
59
|
+
totalSalesValue: number;
|
|
60
|
+
/** Total shrinkage units (directSale + autoDeduct only) */
|
|
61
|
+
totalShrinkageQty: number;
|
|
62
|
+
/** Total shrinkage value */
|
|
63
|
+
totalShrinkageValue: number;
|
|
64
|
+
/** Total internal consumption value */
|
|
65
|
+
totalConsumptionValue: number;
|
|
66
|
+
/** Number of items flagged as conversion artifacts */
|
|
67
|
+
conversionArtifactCount: number;
|
|
68
|
+
/** Comparison with previous period (same length) */
|
|
69
|
+
previousPeriod?: PeriodDelta;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Delta between current and previous period
|
|
73
|
+
*/
|
|
74
|
+
export interface PeriodDelta {
|
|
75
|
+
/** Previous period date range */
|
|
76
|
+
period: {
|
|
77
|
+
from: string;
|
|
78
|
+
to: string;
|
|
79
|
+
};
|
|
80
|
+
/** End stock value delta (%) */
|
|
81
|
+
stockValueDeltaPct: number;
|
|
82
|
+
/** Sales qty delta (%) */
|
|
83
|
+
salesDeltaPct: number;
|
|
84
|
+
/** Purchases qty delta (%) */
|
|
85
|
+
purchasesDeltaPct: number;
|
|
86
|
+
/** Shrinkage value delta (%) */
|
|
87
|
+
shrinkageDeltaPct: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Section 2: Flow by Category
|
|
91
|
+
*
|
|
92
|
+
* Aggregated stock flow grouped by usageType or section.
|
|
93
|
+
*/
|
|
94
|
+
export interface FlowByCategory {
|
|
95
|
+
/** Grouping key (usageType value or section name) */
|
|
96
|
+
category: string;
|
|
97
|
+
/** Display label */
|
|
98
|
+
label: string;
|
|
99
|
+
/** Number of products in this category */
|
|
100
|
+
productCount: number;
|
|
101
|
+
/** Aggregated flow */
|
|
102
|
+
flow: StockFlow;
|
|
103
|
+
/** Aggregated end stock value (cost) */
|
|
104
|
+
endStockValue: number;
|
|
105
|
+
/** Delta vs previous period (%) — undefined if no previous data */
|
|
106
|
+
endStockDeltaPct?: number;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Section 3: Top Shrinkage Items (real losses)
|
|
110
|
+
*/
|
|
111
|
+
export interface TopShrinkageItem {
|
|
112
|
+
qvetCode: number;
|
|
113
|
+
description: string;
|
|
114
|
+
section: string;
|
|
115
|
+
family: string;
|
|
116
|
+
usageType: string;
|
|
117
|
+
conversionFactor: number;
|
|
118
|
+
unitCost: number;
|
|
119
|
+
flow: StockFlow;
|
|
120
|
+
/** Classification of the shrinkage */
|
|
121
|
+
flag: ShrinkageFlag;
|
|
122
|
+
/** Shrinkage as % of available stock */
|
|
123
|
+
shrinkagePct: number;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Section 4: Purchase vs Sale Analysis
|
|
127
|
+
*/
|
|
128
|
+
export interface PurchaseVsSaleItem {
|
|
129
|
+
qvetCode: number;
|
|
130
|
+
description: string;
|
|
131
|
+
section: string;
|
|
132
|
+
family: string;
|
|
133
|
+
/** Total purchases (units, converted to sale units) */
|
|
134
|
+
purchasesQty: number;
|
|
135
|
+
/** Total purchase value (cost) */
|
|
136
|
+
purchasesValue: number;
|
|
137
|
+
/** Total sales (units) */
|
|
138
|
+
salesQty: number;
|
|
139
|
+
/** Total sales value (cost) */
|
|
140
|
+
salesValue: number;
|
|
141
|
+
/** Coverage ratio: purchases / sales. >1 = building stock, <1 = depleting */
|
|
142
|
+
coverageRatio: number | null;
|
|
143
|
+
/** Current end stock */
|
|
144
|
+
endStock: number;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Section 5: Internal Consumption Analysis
|
|
148
|
+
*/
|
|
149
|
+
export interface ConsumptionItem {
|
|
150
|
+
qvetCode: number;
|
|
151
|
+
description: string;
|
|
152
|
+
section: string;
|
|
153
|
+
family: string;
|
|
154
|
+
/** Consumed units = available - actualStock */
|
|
155
|
+
consumed: number;
|
|
156
|
+
/** Consumed value (cost) */
|
|
157
|
+
consumedValue: number;
|
|
158
|
+
/** Monthly consumption rate */
|
|
159
|
+
monthlyRate: number;
|
|
160
|
+
/** End stock */
|
|
161
|
+
endStock: number;
|
|
162
|
+
/** Days of stock remaining at current rate */
|
|
163
|
+
stockDaysRemaining: number | null;
|
|
164
|
+
/** Low stock flag (< 15 days remaining) */
|
|
165
|
+
isLowStock: boolean;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Section 6: Conversion Factor Anomaly
|
|
169
|
+
*/
|
|
170
|
+
export interface CfAnomalyItem {
|
|
171
|
+
qvetCode: number;
|
|
172
|
+
description: string;
|
|
173
|
+
section: string;
|
|
174
|
+
conversionFactor: number;
|
|
175
|
+
/** Raw shrinkage (units) — may be unrealistic due to CF */
|
|
176
|
+
shrinkage: number;
|
|
177
|
+
/** Shrinkage value */
|
|
178
|
+
shrinkageValue: number;
|
|
179
|
+
/** Shrinkage as % of available */
|
|
180
|
+
shrinkagePct: number;
|
|
181
|
+
/** Initial stock */
|
|
182
|
+
initialStock: number;
|
|
183
|
+
/** End stock */
|
|
184
|
+
actualStock: number;
|
|
185
|
+
/** Purchases (converted) */
|
|
186
|
+
purchasesTotal: number;
|
|
187
|
+
/** Likely explanation */
|
|
188
|
+
likelyCause: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Section 7: Period Comparison (multi-metric)
|
|
192
|
+
*/
|
|
193
|
+
export interface PeriodComparisonRow {
|
|
194
|
+
/** Metric name */
|
|
195
|
+
metric: string;
|
|
196
|
+
/** Display label (Spanish) */
|
|
197
|
+
label: string;
|
|
198
|
+
/** Current period value */
|
|
199
|
+
current: number;
|
|
200
|
+
/** Previous period value */
|
|
201
|
+
previous: number;
|
|
202
|
+
/** Absolute delta */
|
|
203
|
+
delta: number;
|
|
204
|
+
/** Percentage delta */
|
|
205
|
+
deltaPct: number | null;
|
|
206
|
+
/** Unit for display (e.g., "units", "$", "%") */
|
|
207
|
+
unit: string;
|
|
208
|
+
}
|
|
209
|
+
/** Classification for a report line */
|
|
210
|
+
export type ReportLineClassification = 'consumption' | 'expired' | 'confirmed_loss' | 'unconfirmed_loss' | 'surplus' | 'negligible';
|
|
211
|
+
export declare const REPORT_LINE_CLASSIFICATION_LABELS: Record<ReportLineClassification, string>;
|
|
212
|
+
/** One product in one branch — the atomic unit of the V2 report */
|
|
213
|
+
export interface ReportLine {
|
|
214
|
+
qvetCode: number;
|
|
215
|
+
description: string;
|
|
216
|
+
section: string;
|
|
217
|
+
family: string;
|
|
218
|
+
usageType: string;
|
|
219
|
+
branch: string;
|
|
220
|
+
unitCost: number;
|
|
221
|
+
conversionFactor: number;
|
|
222
|
+
initialStock: number;
|
|
223
|
+
purchases: number;
|
|
224
|
+
transfersIn: number;
|
|
225
|
+
transfersOut: number;
|
|
226
|
+
sold: number;
|
|
227
|
+
actualStock: number;
|
|
228
|
+
available: number;
|
|
229
|
+
theoreticalStock: number;
|
|
230
|
+
shrinkage: number;
|
|
231
|
+
shrinkageValue: number;
|
|
232
|
+
expiredQty: number;
|
|
233
|
+
expiredValue: number;
|
|
234
|
+
classification: ReportLineClassification;
|
|
235
|
+
}
|
|
236
|
+
/** Per-product-per-branch override */
|
|
237
|
+
export interface ReportOverrideV2 {
|
|
238
|
+
qvetCode: number;
|
|
239
|
+
/** null = all branches */
|
|
240
|
+
branch: string | null;
|
|
241
|
+
action: 'ignore';
|
|
242
|
+
reason?: string;
|
|
243
|
+
reviewedBy?: string;
|
|
244
|
+
reviewedByName?: string;
|
|
245
|
+
reviewedAt?: string;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Waterfall V2 — same structure at every level (global, branch, section).
|
|
249
|
+
*
|
|
250
|
+
* Shows base (sin overrides, FIXED) and adjusted (con overrides).
|
|
251
|
+
* Equation: balance = consumption + expired + realLoss (ALWAYS holds)
|
|
252
|
+
*/
|
|
253
|
+
export interface WaterfallV2 {
|
|
254
|
+
baseFaltantes: number;
|
|
255
|
+
baseSobrantes: number;
|
|
256
|
+
baseBalance: number;
|
|
257
|
+
faltantes: number;
|
|
258
|
+
sobrantes: number;
|
|
259
|
+
balance: number;
|
|
260
|
+
consumption: number;
|
|
261
|
+
expired: number;
|
|
262
|
+
realLoss: number;
|
|
263
|
+
itemCount: number;
|
|
264
|
+
}
|
|
265
|
+
/** Waterfalls at all levels */
|
|
266
|
+
export interface ReportWaterfalls {
|
|
267
|
+
global: WaterfallV2;
|
|
268
|
+
branches: {
|
|
269
|
+
branch: string;
|
|
270
|
+
waterfall: WaterfallV2;
|
|
271
|
+
}[];
|
|
272
|
+
sections: {
|
|
273
|
+
section: string;
|
|
274
|
+
waterfall: WaterfallV2;
|
|
275
|
+
}[];
|
|
276
|
+
}
|
|
277
|
+
/** V2 persisted report document */
|
|
278
|
+
export interface InventoryReportDocumentV2 {
|
|
279
|
+
id: string;
|
|
280
|
+
periodType: ReportPeriodType;
|
|
281
|
+
year: number;
|
|
282
|
+
month: number;
|
|
283
|
+
status: 'draft' | 'closed';
|
|
284
|
+
schemaVersion: number;
|
|
285
|
+
lines: ReportLine[];
|
|
286
|
+
overrides: ReportOverrideV2[];
|
|
287
|
+
waterfall: ReportWaterfalls;
|
|
288
|
+
metadata: import('./responses').ReportMetadata;
|
|
289
|
+
createdByName?: string;
|
|
290
|
+
closedByName?: string;
|
|
291
|
+
closedAt?: string;
|
|
292
|
+
createdAt?: string;
|
|
293
|
+
updatedAt?: string;
|
|
294
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Inventory Report Types
|
|
4
|
+
*
|
|
5
|
+
* Domain types for periodic inventory reports (monthly, quarterly, annual).
|
|
6
|
+
* These reports aggregate stock flow data, detect anomalies, and compare periods.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.REPORT_LINE_CLASSIFICATION_LABELS = exports.SHRINKAGE_FLAG_LABELS = exports.ShrinkageFlag = exports.REPORT_PERIOD_TYPE_LABELS = exports.ReportPeriodType = void 0;
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Enums
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Report period type
|
|
15
|
+
*/
|
|
16
|
+
var ReportPeriodType;
|
|
17
|
+
(function (ReportPeriodType) {
|
|
18
|
+
ReportPeriodType["monthly"] = "monthly";
|
|
19
|
+
ReportPeriodType["quarterly"] = "quarterly";
|
|
20
|
+
ReportPeriodType["annual"] = "annual";
|
|
21
|
+
})(ReportPeriodType || (exports.ReportPeriodType = ReportPeriodType = {}));
|
|
22
|
+
exports.REPORT_PERIOD_TYPE_LABELS = {
|
|
23
|
+
[ReportPeriodType.monthly]: 'Mensual',
|
|
24
|
+
[ReportPeriodType.quarterly]: 'Trimestral',
|
|
25
|
+
[ReportPeriodType.annual]: 'Anual',
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Shrinkage flag — classifies the nature of each product's shrinkage
|
|
29
|
+
*/
|
|
30
|
+
var ShrinkageFlag;
|
|
31
|
+
(function (ShrinkageFlag) {
|
|
32
|
+
/** Real unexplained loss */
|
|
33
|
+
ShrinkageFlag["realLoss"] = "real_loss";
|
|
34
|
+
/** Likely caused by conversion factor mismatch */
|
|
35
|
+
ShrinkageFlag["conversionArtifact"] = "conversion_artifact";
|
|
36
|
+
/** Expected consumption (internalUse items) */
|
|
37
|
+
ShrinkageFlag["expectedConsumption"] = "expected_consumption";
|
|
38
|
+
/** Surplus — more stock than expected */
|
|
39
|
+
ShrinkageFlag["surplus"] = "surplus";
|
|
40
|
+
/** Negligible (within tolerance) */
|
|
41
|
+
ShrinkageFlag["negligible"] = "negligible";
|
|
42
|
+
})(ShrinkageFlag || (exports.ShrinkageFlag = ShrinkageFlag = {}));
|
|
43
|
+
exports.SHRINKAGE_FLAG_LABELS = {
|
|
44
|
+
[ShrinkageFlag.realLoss]: 'Pérdida real',
|
|
45
|
+
[ShrinkageFlag.conversionArtifact]: 'Posible error de conversión',
|
|
46
|
+
[ShrinkageFlag.expectedConsumption]: 'Consumo esperado',
|
|
47
|
+
[ShrinkageFlag.surplus]: 'Sobrante',
|
|
48
|
+
[ShrinkageFlag.negligible]: 'Despreciable',
|
|
49
|
+
};
|
|
50
|
+
exports.REPORT_LINE_CLASSIFICATION_LABELS = {
|
|
51
|
+
consumption: 'Consumo interno',
|
|
52
|
+
expired: 'Caducidad',
|
|
53
|
+
confirmed_loss: 'Pérdida confirmada',
|
|
54
|
+
unconfirmed_loss: 'Sin confirmar',
|
|
55
|
+
surplus: 'Sobrante',
|
|
56
|
+
negligible: 'Despreciable',
|
|
57
|
+
};
|
|
@@ -43,43 +43,6 @@ export interface QvetPaginatedResponse<T> {
|
|
|
43
43
|
data: T[];
|
|
44
44
|
pagination: QvetPagination;
|
|
45
45
|
}
|
|
46
|
-
/**
|
|
47
|
-
* @deprecated Use QvetSaleDetailResponse instead. This type is from Report 14 which is being removed.
|
|
48
|
-
*/
|
|
49
|
-
export interface QvetSaleResponse {
|
|
50
|
-
id: string;
|
|
51
|
-
date: string;
|
|
52
|
-
warehouse: string;
|
|
53
|
-
subtotal: number;
|
|
54
|
-
paidAmount: number;
|
|
55
|
-
total: number;
|
|
56
|
-
quantity: number;
|
|
57
|
-
discount: number;
|
|
58
|
-
debt: number;
|
|
59
|
-
taxAmount: number;
|
|
60
|
-
taxRate: number;
|
|
61
|
-
paymentMethod: string;
|
|
62
|
-
priceList: string;
|
|
63
|
-
qvetCode: number;
|
|
64
|
-
productName: string;
|
|
65
|
-
section: string;
|
|
66
|
-
family: string;
|
|
67
|
-
subfamily: string;
|
|
68
|
-
isActive: boolean;
|
|
69
|
-
hasStockControl: boolean;
|
|
70
|
-
customerName: string;
|
|
71
|
-
qvetCustomerId?: number;
|
|
72
|
-
petName?: string;
|
|
73
|
-
qvetPetId?: number;
|
|
74
|
-
sellerName: string;
|
|
75
|
-
sellerInitials?: string;
|
|
76
|
-
branch: string;
|
|
77
|
-
syncedAt: string;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* @deprecated Use ApiListSuccessResponse<QvetSaleResponse[]> instead.
|
|
81
|
-
*/
|
|
82
|
-
export type QvetSalesListResponse = QvetPaginatedResponse<QvetSaleResponse>;
|
|
83
46
|
/**
|
|
84
47
|
* Sales summary statistics data for a period.
|
|
85
48
|
* Backend wraps with: ApiSingleSuccessResponse<QvetSalesSummaryData>
|