hvp-shared 6.7.1 → 6.9.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.
|
@@ -15,8 +15,51 @@ export declare enum JobType {
|
|
|
15
15
|
SYNC_MOVEMENTS = "SYNC_MOVEMENTS",
|
|
16
16
|
SYNC_STOCK_CONFIG = "SYNC_STOCK_CONFIG",
|
|
17
17
|
SYNC_CATALOG = "SYNC_CATALOG",
|
|
18
|
+
SYNC_CLIENTS = "SYNC_CLIENTS",
|
|
19
|
+
SYNC_INVENTORY_SNAPSHOT = "SYNC_INVENTORY_SNAPSHOT",
|
|
20
|
+
SYNC_BATCH = "SYNC_BATCH",
|
|
18
21
|
SYNC_ALL = "SYNC_ALL"
|
|
19
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Report types for batch sync operations.
|
|
25
|
+
* Each report type has specific parameter requirements.
|
|
26
|
+
*/
|
|
27
|
+
export declare enum ReportType {
|
|
28
|
+
/** Sales report - uses date range params */
|
|
29
|
+
SALES = "SALES",
|
|
30
|
+
/** Purchases report - uses date range params */
|
|
31
|
+
PURCHASES = "PURCHASES",
|
|
32
|
+
/** Inventory movements report - uses date range params */
|
|
33
|
+
MOVEMENTS = "MOVEMENTS",
|
|
34
|
+
/** Transfers report - uses date range params */
|
|
35
|
+
TRANSFERS = "TRANSFERS",
|
|
36
|
+
/** Inventory snapshot - uses snapshot date param */
|
|
37
|
+
INVENTORY_SNAPSHOT = "INVENTORY_SNAPSHOT",
|
|
38
|
+
/** Clients list - no date params required */
|
|
39
|
+
CLIENTS = "CLIENTS",
|
|
40
|
+
/** Product catalog - no date params required */
|
|
41
|
+
CATALOG = "CATALOG",
|
|
42
|
+
/** Stock configuration - no date params required */
|
|
43
|
+
STOCK_CONFIG = "STOCK_CONFIG"
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Sub-task status within a batch job
|
|
47
|
+
*/
|
|
48
|
+
export declare enum SubTaskStatus {
|
|
49
|
+
PENDING = "pending",
|
|
50
|
+
IN_PROGRESS = "in_progress",
|
|
51
|
+
COMPLETED = "completed",
|
|
52
|
+
FAILED = "failed",
|
|
53
|
+
SKIPPED = "skipped"
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Parameter type for each report type
|
|
57
|
+
*/
|
|
58
|
+
export type ReportParamType = 'date_range' | 'snapshot' | 'no_params';
|
|
59
|
+
/**
|
|
60
|
+
* Mapping of report types to their parameter type
|
|
61
|
+
*/
|
|
62
|
+
export declare const REPORT_PARAM_TYPES: Record<ReportType, ReportParamType>;
|
|
20
63
|
/**
|
|
21
64
|
* Job execution status
|
|
22
65
|
*/
|
|
@@ -40,6 +83,14 @@ export declare enum JobStep {
|
|
|
40
83
|
* Human-readable labels for job types (Spanish for UI)
|
|
41
84
|
*/
|
|
42
85
|
export declare const JOB_TYPE_LABELS: Record<JobType, string>;
|
|
86
|
+
/**
|
|
87
|
+
* Human-readable labels for report types (Spanish for UI)
|
|
88
|
+
*/
|
|
89
|
+
export declare const REPORT_TYPE_LABELS: Record<ReportType, string>;
|
|
90
|
+
/**
|
|
91
|
+
* Human-readable labels for sub-task status (Spanish for UI)
|
|
92
|
+
*/
|
|
93
|
+
export declare const SUB_TASK_STATUS_LABELS: Record<SubTaskStatus, string>;
|
|
43
94
|
/**
|
|
44
95
|
* Human-readable labels for job steps (Spanish for UI)
|
|
45
96
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Used by frontend (polling) and backend (job execution).
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.JOB_STATUS_LABELS = exports.JOB_STEP_LABELS = exports.JOB_TYPE_LABELS = exports.JobStep = exports.JobStatus = exports.JobType = void 0;
|
|
9
|
+
exports.JOB_STATUS_LABELS = exports.JOB_STEP_LABELS = exports.SUB_TASK_STATUS_LABELS = exports.REPORT_TYPE_LABELS = exports.JOB_TYPE_LABELS = exports.JobStep = exports.JobStatus = exports.REPORT_PARAM_TYPES = exports.SubTaskStatus = exports.ReportType = exports.JobType = void 0;
|
|
10
10
|
/**
|
|
11
11
|
* Job types for QVET sync operations
|
|
12
12
|
*/
|
|
@@ -19,8 +19,58 @@ var JobType;
|
|
|
19
19
|
JobType["SYNC_MOVEMENTS"] = "SYNC_MOVEMENTS";
|
|
20
20
|
JobType["SYNC_STOCK_CONFIG"] = "SYNC_STOCK_CONFIG";
|
|
21
21
|
JobType["SYNC_CATALOG"] = "SYNC_CATALOG";
|
|
22
|
+
JobType["SYNC_CLIENTS"] = "SYNC_CLIENTS";
|
|
23
|
+
JobType["SYNC_INVENTORY_SNAPSHOT"] = "SYNC_INVENTORY_SNAPSHOT";
|
|
24
|
+
JobType["SYNC_BATCH"] = "SYNC_BATCH";
|
|
22
25
|
JobType["SYNC_ALL"] = "SYNC_ALL";
|
|
23
26
|
})(JobType || (exports.JobType = JobType = {}));
|
|
27
|
+
/**
|
|
28
|
+
* Report types for batch sync operations.
|
|
29
|
+
* Each report type has specific parameter requirements.
|
|
30
|
+
*/
|
|
31
|
+
var ReportType;
|
|
32
|
+
(function (ReportType) {
|
|
33
|
+
/** Sales report - uses date range params */
|
|
34
|
+
ReportType["SALES"] = "SALES";
|
|
35
|
+
/** Purchases report - uses date range params */
|
|
36
|
+
ReportType["PURCHASES"] = "PURCHASES";
|
|
37
|
+
/** Inventory movements report - uses date range params */
|
|
38
|
+
ReportType["MOVEMENTS"] = "MOVEMENTS";
|
|
39
|
+
/** Transfers report - uses date range params */
|
|
40
|
+
ReportType["TRANSFERS"] = "TRANSFERS";
|
|
41
|
+
/** Inventory snapshot - uses snapshot date param */
|
|
42
|
+
ReportType["INVENTORY_SNAPSHOT"] = "INVENTORY_SNAPSHOT";
|
|
43
|
+
/** Clients list - no date params required */
|
|
44
|
+
ReportType["CLIENTS"] = "CLIENTS";
|
|
45
|
+
/** Product catalog - no date params required */
|
|
46
|
+
ReportType["CATALOG"] = "CATALOG";
|
|
47
|
+
/** Stock configuration - no date params required */
|
|
48
|
+
ReportType["STOCK_CONFIG"] = "STOCK_CONFIG";
|
|
49
|
+
})(ReportType || (exports.ReportType = ReportType = {}));
|
|
50
|
+
/**
|
|
51
|
+
* Sub-task status within a batch job
|
|
52
|
+
*/
|
|
53
|
+
var SubTaskStatus;
|
|
54
|
+
(function (SubTaskStatus) {
|
|
55
|
+
SubTaskStatus["PENDING"] = "pending";
|
|
56
|
+
SubTaskStatus["IN_PROGRESS"] = "in_progress";
|
|
57
|
+
SubTaskStatus["COMPLETED"] = "completed";
|
|
58
|
+
SubTaskStatus["FAILED"] = "failed";
|
|
59
|
+
SubTaskStatus["SKIPPED"] = "skipped";
|
|
60
|
+
})(SubTaskStatus || (exports.SubTaskStatus = SubTaskStatus = {}));
|
|
61
|
+
/**
|
|
62
|
+
* Mapping of report types to their parameter type
|
|
63
|
+
*/
|
|
64
|
+
exports.REPORT_PARAM_TYPES = {
|
|
65
|
+
[ReportType.SALES]: 'date_range',
|
|
66
|
+
[ReportType.PURCHASES]: 'date_range',
|
|
67
|
+
[ReportType.MOVEMENTS]: 'date_range',
|
|
68
|
+
[ReportType.TRANSFERS]: 'date_range',
|
|
69
|
+
[ReportType.INVENTORY_SNAPSHOT]: 'snapshot',
|
|
70
|
+
[ReportType.CLIENTS]: 'no_params',
|
|
71
|
+
[ReportType.CATALOG]: 'no_params',
|
|
72
|
+
[ReportType.STOCK_CONFIG]: 'no_params',
|
|
73
|
+
};
|
|
24
74
|
/**
|
|
25
75
|
* Job execution status
|
|
26
76
|
*/
|
|
@@ -53,8 +103,34 @@ exports.JOB_TYPE_LABELS = {
|
|
|
53
103
|
[JobType.SYNC_MOVEMENTS]: 'Sincronizar Movimientos',
|
|
54
104
|
[JobType.SYNC_STOCK_CONFIG]: 'Sincronizar Config. Stock',
|
|
55
105
|
[JobType.SYNC_CATALOG]: 'Sincronizar Catálogo',
|
|
106
|
+
[JobType.SYNC_CLIENTS]: 'Sincronizar Clientes',
|
|
107
|
+
[JobType.SYNC_INVENTORY_SNAPSHOT]: 'Sincronizar Snapshot Inventario',
|
|
108
|
+
[JobType.SYNC_BATCH]: 'Sincronización por Lotes',
|
|
56
109
|
[JobType.SYNC_ALL]: 'Sincronizar Todo',
|
|
57
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Human-readable labels for report types (Spanish for UI)
|
|
113
|
+
*/
|
|
114
|
+
exports.REPORT_TYPE_LABELS = {
|
|
115
|
+
[ReportType.SALES]: 'Ventas',
|
|
116
|
+
[ReportType.PURCHASES]: 'Compras',
|
|
117
|
+
[ReportType.MOVEMENTS]: 'Movimientos',
|
|
118
|
+
[ReportType.TRANSFERS]: 'Traspasos',
|
|
119
|
+
[ReportType.INVENTORY_SNAPSHOT]: 'Snapshot Inventario',
|
|
120
|
+
[ReportType.CLIENTS]: 'Clientes',
|
|
121
|
+
[ReportType.CATALOG]: 'Catálogo',
|
|
122
|
+
[ReportType.STOCK_CONFIG]: 'Config. Stock',
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Human-readable labels for sub-task status (Spanish for UI)
|
|
126
|
+
*/
|
|
127
|
+
exports.SUB_TASK_STATUS_LABELS = {
|
|
128
|
+
[SubTaskStatus.PENDING]: 'Pendiente',
|
|
129
|
+
[SubTaskStatus.IN_PROGRESS]: 'En proceso',
|
|
130
|
+
[SubTaskStatus.COMPLETED]: 'Completado',
|
|
131
|
+
[SubTaskStatus.FAILED]: 'Fallido',
|
|
132
|
+
[SubTaskStatus.SKIPPED]: 'Omitido',
|
|
133
|
+
};
|
|
58
134
|
/**
|
|
59
135
|
* Human-readable labels for job steps (Spanish for UI)
|
|
60
136
|
*/
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Represents one line item in a sale transaction
|
|
10
10
|
*/
|
|
11
11
|
export interface QvetSaleResponse {
|
|
12
|
-
|
|
12
|
+
id: string;
|
|
13
13
|
date: string;
|
|
14
14
|
warehouse: string;
|
|
15
15
|
subtotal: number;
|
|
@@ -90,7 +90,7 @@ export interface QvetSalesQueryParams {
|
|
|
90
90
|
year?: number;
|
|
91
91
|
month?: number;
|
|
92
92
|
halfMonth?: 1 | 2;
|
|
93
|
-
|
|
93
|
+
branch?: string;
|
|
94
94
|
section?: string;
|
|
95
95
|
family?: string;
|
|
96
96
|
qvetCode?: number;
|
|
@@ -104,7 +104,7 @@ export interface QvetSalesQueryParams {
|
|
|
104
104
|
* Represents one line item in a purchase transaction
|
|
105
105
|
*/
|
|
106
106
|
export interface QvetPurchaseResponse {
|
|
107
|
-
|
|
107
|
+
id: string;
|
|
108
108
|
qvetCode: number;
|
|
109
109
|
productName: string;
|
|
110
110
|
barcode: string;
|
|
@@ -184,7 +184,7 @@ export interface QvetPurchasesQueryParams {
|
|
|
184
184
|
year?: number;
|
|
185
185
|
month?: number;
|
|
186
186
|
halfMonth?: 1 | 2;
|
|
187
|
-
|
|
187
|
+
branch?: string;
|
|
188
188
|
section?: string;
|
|
189
189
|
family?: string;
|
|
190
190
|
supplier?: string;
|
|
@@ -193,3 +193,78 @@ export interface QvetPurchasesQueryParams {
|
|
|
193
193
|
skip?: number;
|
|
194
194
|
sort?: string;
|
|
195
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Single movement record from QVET
|
|
198
|
+
* Represents an inventory movement (sale, purchase, transfer, adjustment, etc.)
|
|
199
|
+
*/
|
|
200
|
+
export interface QvetMovementResponse {
|
|
201
|
+
id: string;
|
|
202
|
+
date: string;
|
|
203
|
+
warehouse: string;
|
|
204
|
+
movementType: string;
|
|
205
|
+
quantity: number;
|
|
206
|
+
runningStock: number;
|
|
207
|
+
staffName: string;
|
|
208
|
+
counterparty: string;
|
|
209
|
+
qvetCode: number;
|
|
210
|
+
productName: string;
|
|
211
|
+
section: string;
|
|
212
|
+
family: string;
|
|
213
|
+
subfamily: string;
|
|
214
|
+
conversionFactor: number;
|
|
215
|
+
lastPurchaseCost: number;
|
|
216
|
+
avgPurchaseCost: number;
|
|
217
|
+
batchReference: string | null;
|
|
218
|
+
expirationDate: string | null;
|
|
219
|
+
branch: string;
|
|
220
|
+
syncedAt: string;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Paginated list of movements
|
|
224
|
+
*/
|
|
225
|
+
export interface QvetMovementsListResponse {
|
|
226
|
+
ok: boolean;
|
|
227
|
+
data: QvetMovementResponse[];
|
|
228
|
+
pagination: {
|
|
229
|
+
total: number;
|
|
230
|
+
limit: number;
|
|
231
|
+
skip: number;
|
|
232
|
+
hasMore: boolean;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Movements summary statistics for a period
|
|
237
|
+
*/
|
|
238
|
+
export interface QvetMovementsSummaryResponse {
|
|
239
|
+
ok: boolean;
|
|
240
|
+
data: {
|
|
241
|
+
totalRecords: number;
|
|
242
|
+
totalQuantityIn: number;
|
|
243
|
+
totalQuantityOut: number;
|
|
244
|
+
uniqueProducts: number;
|
|
245
|
+
byMovementType: Array<{
|
|
246
|
+
type: string;
|
|
247
|
+
count: number;
|
|
248
|
+
totalQuantity: number;
|
|
249
|
+
}>;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Query parameters for movements endpoint
|
|
254
|
+
*/
|
|
255
|
+
export interface QvetMovementsQueryParams {
|
|
256
|
+
startDate?: string;
|
|
257
|
+
endDate?: string;
|
|
258
|
+
year?: number;
|
|
259
|
+
month?: number;
|
|
260
|
+
quarter?: 1 | 2 | 3 | 4;
|
|
261
|
+
branch?: string;
|
|
262
|
+
warehouse?: string;
|
|
263
|
+
movementType?: string;
|
|
264
|
+
section?: string;
|
|
265
|
+
family?: string;
|
|
266
|
+
qvetCode?: number;
|
|
267
|
+
limit?: number;
|
|
268
|
+
skip?: number;
|
|
269
|
+
sort?: string;
|
|
270
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Interfaces for background job system.
|
|
5
5
|
* Used by frontend (polling) and backend (job execution).
|
|
6
6
|
*/
|
|
7
|
-
import { JobStatus, JobStep, JobType } from '../constants/background-job.constants';
|
|
7
|
+
import { JobStatus, JobStep, JobType, ReportType, SubTaskStatus } from '../constants/background-job.constants';
|
|
8
8
|
/**
|
|
9
9
|
* Job progress information
|
|
10
10
|
*/
|
|
@@ -40,6 +40,85 @@ export interface JobError {
|
|
|
40
40
|
/** Stack trace (only in development) */
|
|
41
41
|
stack?: string;
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Parameters for date-range based reports (Sales, Purchases, Movements, Transfers)
|
|
45
|
+
*/
|
|
46
|
+
export interface DateRangeParams {
|
|
47
|
+
/** Year to sync */
|
|
48
|
+
year: number;
|
|
49
|
+
/** Month to sync (1-12). If omitted, syncs full year */
|
|
50
|
+
month?: number;
|
|
51
|
+
/** Half month (1 = days 1-15, 2 = days 16-end). Optional */
|
|
52
|
+
halfMonth?: 1 | 2;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Parameters for snapshot-based reports (Inventory Snapshot)
|
|
56
|
+
*/
|
|
57
|
+
export interface SnapshotParams {
|
|
58
|
+
/** The specific date to get inventory snapshot for (ISO string) */
|
|
59
|
+
snapshotDate: string;
|
|
60
|
+
/** Optional: filter by warehouse */
|
|
61
|
+
warehouse?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Union type for all possible sync parameters
|
|
65
|
+
*/
|
|
66
|
+
export type SyncParams = DateRangeParams | SnapshotParams | Record<string, never>;
|
|
67
|
+
/**
|
|
68
|
+
* Result for a single sub-task
|
|
69
|
+
*/
|
|
70
|
+
export interface SubTaskResult {
|
|
71
|
+
/** Total records processed */
|
|
72
|
+
recordsProcessed: number;
|
|
73
|
+
/** New records created */
|
|
74
|
+
recordsCreated: number;
|
|
75
|
+
/** Existing records updated */
|
|
76
|
+
recordsUpdated: number;
|
|
77
|
+
/** Non-fatal errors encountered */
|
|
78
|
+
errors: string[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A sub-task within a batch job
|
|
82
|
+
*/
|
|
83
|
+
export interface BatchSubTask {
|
|
84
|
+
/** Unique identifier for this sub-task */
|
|
85
|
+
id: string;
|
|
86
|
+
/** Report type to sync */
|
|
87
|
+
reportType: ReportType;
|
|
88
|
+
/** Current status */
|
|
89
|
+
status: SubTaskStatus;
|
|
90
|
+
/** Parameters specific to this report type */
|
|
91
|
+
params: SyncParams;
|
|
92
|
+
/** Progress percentage (0-100) */
|
|
93
|
+
progress: number;
|
|
94
|
+
/** Human-readable progress message */
|
|
95
|
+
progressMessage: string;
|
|
96
|
+
/** When the sub-task started */
|
|
97
|
+
startedAt?: string;
|
|
98
|
+
/** When the sub-task completed */
|
|
99
|
+
completedAt?: string;
|
|
100
|
+
/** Duration in milliseconds */
|
|
101
|
+
durationMs?: number;
|
|
102
|
+
/** Result when completed */
|
|
103
|
+
result?: SubTaskResult;
|
|
104
|
+
/** Error message when failed */
|
|
105
|
+
error?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Summary of batch job sub-tasks
|
|
109
|
+
*/
|
|
110
|
+
export interface BatchSubTasksSummary {
|
|
111
|
+
/** Total number of sub-tasks */
|
|
112
|
+
total: number;
|
|
113
|
+
/** Number completed successfully */
|
|
114
|
+
completed: number;
|
|
115
|
+
/** Number failed */
|
|
116
|
+
failed: number;
|
|
117
|
+
/** Number skipped */
|
|
118
|
+
skipped: number;
|
|
119
|
+
/** Number still pending */
|
|
120
|
+
pending: number;
|
|
121
|
+
}
|
|
43
122
|
/**
|
|
44
123
|
* Background job response (for API)
|
|
45
124
|
*/
|
|
@@ -68,6 +147,12 @@ export interface BackgroundJobResponse {
|
|
|
68
147
|
result?: JobResult;
|
|
69
148
|
/** Error (when failed) */
|
|
70
149
|
error?: JobError;
|
|
150
|
+
/** Index of current sub-task being processed (for batch jobs) */
|
|
151
|
+
currentSubTaskIndex?: number;
|
|
152
|
+
/** Sub-tasks in this batch job */
|
|
153
|
+
subTasks?: BatchSubTask[];
|
|
154
|
+
/** Summary of sub-task statuses (for batch jobs) */
|
|
155
|
+
subTasksSummary?: BatchSubTasksSummary;
|
|
71
156
|
}
|
|
72
157
|
/**
|
|
73
158
|
* Request to create a new sync job
|
|
@@ -78,6 +163,18 @@ export interface CreateSyncJobRequest {
|
|
|
78
163
|
/** Optional parameters for the sync */
|
|
79
164
|
params?: Record<string, unknown>;
|
|
80
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Request to create a batch sync job
|
|
168
|
+
*/
|
|
169
|
+
export interface CreateBatchSyncJobRequest {
|
|
170
|
+
/** Sub-tasks to execute in this batch */
|
|
171
|
+
subTasks: Array<{
|
|
172
|
+
/** Report type to sync */
|
|
173
|
+
reportType: ReportType;
|
|
174
|
+
/** Parameters specific to this report type */
|
|
175
|
+
params: SyncParams;
|
|
176
|
+
}>;
|
|
177
|
+
}
|
|
81
178
|
/**
|
|
82
179
|
* Sync status for a report type
|
|
83
180
|
*/
|
|
@@ -105,3 +202,25 @@ export interface SyncStatusResponse {
|
|
|
105
202
|
startedAt: string;
|
|
106
203
|
}>;
|
|
107
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* A sync suggestion for missing data
|
|
207
|
+
*/
|
|
208
|
+
export interface SyncSuggestion {
|
|
209
|
+
/** Report type */
|
|
210
|
+
reportType: ReportType;
|
|
211
|
+
/** Suggested parameters */
|
|
212
|
+
params: SyncParams;
|
|
213
|
+
/** Human-readable description */
|
|
214
|
+
description: string;
|
|
215
|
+
/** Priority (lower = more important) */
|
|
216
|
+
priority: number;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Sync suggestions response
|
|
220
|
+
*/
|
|
221
|
+
export interface SyncSuggestionsResponse {
|
|
222
|
+
/** List of suggested syncs */
|
|
223
|
+
suggestions: SyncSuggestion[];
|
|
224
|
+
/** When suggestions were generated */
|
|
225
|
+
generatedAt: string;
|
|
226
|
+
}
|