hvp-shared 6.73.0 → 6.74.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.
@@ -11,25 +11,35 @@ export declare enum InventorySessionStatus {
11
11
  closed = "closed"
12
12
  }
13
13
  export declare const INVENTORY_SESSION_STATUS_LABELS: Record<InventorySessionStatus, string>;
14
- /** Status of an individual item within a session */
14
+ /**
15
+ * Status of an individual item within a session.
16
+ * This is THE field to display. No priority logic needed.
17
+ *
18
+ * Terminal states (session closeable): ok, tolerated, loss, justified
19
+ * Non-terminal: pending, needs_review, verify_qvet, confirmed, recount
20
+ */
15
21
  export declare enum InventoryItemStatus {
16
- pending = "pending",
17
- counted = "counted",
18
- matched = "matched"
19
- }
20
- export declare const INVENTORY_ITEM_STATUS_LABELS: Record<InventoryItemStatus, string>;
21
- /** Auto-calculated review status based on count data vs stock */
22
- export declare enum InventoryReviewStatus {
23
22
  pending = "pending",
24
23
  ok = "ok",
25
24
  tolerated = "tolerated",
26
25
  needs_review = "needs_review",
27
- verify_qvet = "verify_qvet"
26
+ verify_qvet = "verify_qvet",
27
+ confirmed = "confirmed",
28
+ recount = "recount",
29
+ loss = "loss",
30
+ justified = "justified"
28
31
  }
29
- export declare const INVENTORY_REVIEW_STATUS_LABELS: Record<InventoryReviewStatus, string>;
30
- /** Decision made by the manager/reviewer on a counted item */
32
+ export declare const INVENTORY_ITEM_STATUS_LABELS: Record<InventoryItemStatus, string>;
33
+ /** Terminal statuses session can close when all items are in one of these */
34
+ export declare const TERMINAL_ITEM_STATUSES: Set<InventoryItemStatus>;
35
+ /**
36
+ * Decision made by the manager/reviewer on a counted item.
37
+ * Stored in managerDecision for audit. The status field reflects the current state.
38
+ *
39
+ * No "validated" — manager must choose loss or justified for differences.
40
+ * Items that match (ok/tolerated) don't need manager action.
41
+ */
31
42
  export declare enum ManagerDecision {
32
- validated = "validated",
33
43
  loss = "loss",
34
44
  justified = "justified",
35
45
  recount = "recount"
@@ -37,6 +47,7 @@ export declare enum ManagerDecision {
37
47
  export declare const MANAGER_DECISION_LABELS: Record<ManagerDecision, string>;
38
48
  /** Action taken by the collaborator on their own count */
39
49
  export declare enum CollaboratorAction {
40
- confirmed = "confirmed"
50
+ confirmed = "confirmed",
51
+ corrected = "corrected"
41
52
  }
42
53
  export declare const COLLABORATOR_ACTION_LABELS: Record<CollaboratorAction, string>;
@@ -7,7 +7,7 @@
7
7
  * until closure is detected from QVET movements sync.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.COLLABORATOR_ACTION_LABELS = exports.CollaboratorAction = exports.MANAGER_DECISION_LABELS = exports.ManagerDecision = exports.INVENTORY_REVIEW_STATUS_LABELS = exports.InventoryReviewStatus = exports.INVENTORY_ITEM_STATUS_LABELS = exports.InventoryItemStatus = exports.INVENTORY_SESSION_STATUS_LABELS = exports.InventorySessionStatus = void 0;
10
+ exports.COLLABORATOR_ACTION_LABELS = exports.CollaboratorAction = exports.MANAGER_DECISION_LABELS = exports.ManagerDecision = exports.TERMINAL_ITEM_STATUSES = exports.INVENTORY_ITEM_STATUS_LABELS = exports.InventoryItemStatus = exports.INVENTORY_SESSION_STATUS_LABELS = exports.InventorySessionStatus = void 0;
11
11
  // --- Session Status ---
12
12
  /** Lifecycle status of an inventory session */
13
13
  var InventorySessionStatus;
@@ -19,57 +19,74 @@ exports.INVENTORY_SESSION_STATUS_LABELS = {
19
19
  [InventorySessionStatus.open]: "Abierta",
20
20
  [InventorySessionStatus.closed]: "Cerrada",
21
21
  };
22
- // --- Item Status ---
23
- /** Status of an individual item within a session */
22
+ // --- Item Status (unified — single source of truth for display) ---
23
+ /**
24
+ * Status of an individual item within a session.
25
+ * This is THE field to display. No priority logic needed.
26
+ *
27
+ * Terminal states (session closeable): ok, tolerated, loss, justified
28
+ * Non-terminal: pending, needs_review, verify_qvet, confirmed, recount
29
+ */
24
30
  var InventoryItemStatus;
25
31
  (function (InventoryItemStatus) {
32
+ // Auto-calculated from count data
26
33
  InventoryItemStatus["pending"] = "pending";
27
- InventoryItemStatus["counted"] = "counted";
28
- InventoryItemStatus["matched"] = "matched";
34
+ InventoryItemStatus["ok"] = "ok";
35
+ InventoryItemStatus["tolerated"] = "tolerated";
36
+ InventoryItemStatus["needs_review"] = "needs_review";
37
+ InventoryItemStatus["verify_qvet"] = "verify_qvet";
38
+ // Set by collaborator
39
+ InventoryItemStatus["confirmed"] = "confirmed";
40
+ // Set by manager
41
+ InventoryItemStatus["recount"] = "recount";
42
+ InventoryItemStatus["loss"] = "loss";
43
+ InventoryItemStatus["justified"] = "justified";
29
44
  })(InventoryItemStatus || (exports.InventoryItemStatus = InventoryItemStatus = {}));
30
45
  exports.INVENTORY_ITEM_STATUS_LABELS = {
31
46
  [InventoryItemStatus.pending]: "Pendiente",
32
- [InventoryItemStatus.counted]: "Contado",
33
- [InventoryItemStatus.matched]: "Validado",
34
- };
35
- // --- Review Status (auto-calculated) ---
36
- /** Auto-calculated review status based on count data vs stock */
37
- var InventoryReviewStatus;
38
- (function (InventoryReviewStatus) {
39
- InventoryReviewStatus["pending"] = "pending";
40
- InventoryReviewStatus["ok"] = "ok";
41
- InventoryReviewStatus["tolerated"] = "tolerated";
42
- InventoryReviewStatus["needs_review"] = "needs_review";
43
- InventoryReviewStatus["verify_qvet"] = "verify_qvet";
44
- })(InventoryReviewStatus || (exports.InventoryReviewStatus = InventoryReviewStatus = {}));
45
- exports.INVENTORY_REVIEW_STATUS_LABELS = {
46
- [InventoryReviewStatus.pending]: "Pendiente",
47
- [InventoryReviewStatus.ok]: "OK",
48
- [InventoryReviewStatus.tolerated]: "Tolerado",
49
- [InventoryReviewStatus.needs_review]: "Revisar",
50
- [InventoryReviewStatus.verify_qvet]: "Verificar QVET",
47
+ [InventoryItemStatus.ok]: "OK",
48
+ [InventoryItemStatus.tolerated]: "Tolerado",
49
+ [InventoryItemStatus.needs_review]: "Revisar",
50
+ [InventoryItemStatus.verify_qvet]: "Verificar QVET",
51
+ [InventoryItemStatus.confirmed]: "Confirmado",
52
+ [InventoryItemStatus.recount]: "Recontar",
53
+ [InventoryItemStatus.loss]: "Pérdida",
54
+ [InventoryItemStatus.justified]: "Justificado",
51
55
  };
52
- // --- Manager Decision ---
53
- /** Decision made by the manager/reviewer on a counted item */
56
+ /** Terminal statuses session can close when all items are in one of these */
57
+ exports.TERMINAL_ITEM_STATUSES = new Set([
58
+ InventoryItemStatus.ok,
59
+ InventoryItemStatus.tolerated,
60
+ InventoryItemStatus.loss,
61
+ InventoryItemStatus.justified,
62
+ ]);
63
+ // --- Manager Decision (audit field) ---
64
+ /**
65
+ * Decision made by the manager/reviewer on a counted item.
66
+ * Stored in managerDecision for audit. The status field reflects the current state.
67
+ *
68
+ * No "validated" — manager must choose loss or justified for differences.
69
+ * Items that match (ok/tolerated) don't need manager action.
70
+ */
54
71
  var ManagerDecision;
55
72
  (function (ManagerDecision) {
56
- ManagerDecision["validated"] = "validated";
57
73
  ManagerDecision["loss"] = "loss";
58
74
  ManagerDecision["justified"] = "justified";
59
75
  ManagerDecision["recount"] = "recount";
60
76
  })(ManagerDecision || (exports.ManagerDecision = ManagerDecision = {}));
61
77
  exports.MANAGER_DECISION_LABELS = {
62
- [ManagerDecision.validated]: "Validado",
63
78
  [ManagerDecision.loss]: "Pérdida",
64
79
  [ManagerDecision.justified]: "Justificado",
65
80
  [ManagerDecision.recount]: "Recontar",
66
81
  };
67
- // --- Collaborator Action ---
82
+ // --- Collaborator Action (audit field) ---
68
83
  /** Action taken by the collaborator on their own count */
69
84
  var CollaboratorAction;
70
85
  (function (CollaboratorAction) {
71
86
  CollaboratorAction["confirmed"] = "confirmed";
87
+ CollaboratorAction["corrected"] = "corrected";
72
88
  })(CollaboratorAction || (exports.CollaboratorAction = CollaboratorAction = {}));
73
89
  exports.COLLABORATOR_ACTION_LABELS = {
74
90
  [CollaboratorAction.confirmed]: "Confirmado",
91
+ [CollaboratorAction.corrected]: "Corregido",
75
92
  };
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @example POST /api/qvet/inventory-sessions
7
7
  * @example POST /api/qvet/inventory-sessions/:id/upload
8
- * @example POST /api/qvet/inventory-sessions/:id/confirm-matches
8
+ * @example POST /api/qvet/inventory-sessions/:id/apply-review
9
9
  */
10
10
  import { InventorySessionStatus, CollaboratorAction, ManagerDecision } from '../../constants/inventory-session.enums';
11
11
  import { Warehouse } from '../../types/qvet.types';
@@ -20,15 +20,6 @@ export interface CreateInventorySessionRequest {
20
20
  /** Sections to include in the count */
21
21
  sections: string[];
22
22
  }
23
- /**
24
- * Confirm auto-matched items after an upload.
25
- *
26
- * @example POST /api/qvet/inventory-sessions/:id/confirm-matches
27
- */
28
- export interface ConfirmMatchesRequest {
29
- /** QVET codes of items to mark as matched */
30
- qvetCodes: number[];
31
- }
32
23
  /**
33
24
  * Filters for listing inventory sessions.
34
25
  *
@@ -6,6 +6,6 @@
6
6
  *
7
7
  * @example POST /api/qvet/inventory-sessions
8
8
  * @example POST /api/qvet/inventory-sessions/:id/upload
9
- * @example POST /api/qvet/inventory-sessions/:id/confirm-matches
9
+ * @example POST /api/qvet/inventory-sessions/:id/apply-review
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -18,16 +18,14 @@ export interface InventorySessionSummaryResponse {
18
18
  status: InventorySessionStatus;
19
19
  /** Total items in session */
20
20
  totalItems: number;
21
- /** Items with status "pending" */
21
+ /** Items with status "pending" (no count data) */
22
22
  pendingItems: number;
23
- /** Items with status "counted" */
24
- countedItems: number;
25
- /** Items with status "matched" */
26
- matchedItems: number;
27
- /** Items needing review (reviewStatus = needs_review) */
28
- needsReviewItems: number;
29
- /** Items confirmed by collaborator but pending manager decision */
30
- confirmedItems: number;
23
+ /** Items in terminal state (ok, tolerated, loss, justified) */
24
+ resolvedItems: number;
25
+ /** Items needing attention (needs_review, verify_qvet, recount) */
26
+ needsAttentionItems: number;
27
+ /** Items in progress (confirmed waiting for manager) */
28
+ inProgressItems: number;
31
29
  /** Number of times an Excel was uploaded */
32
30
  uploadCount: number;
33
31
  createdByName: string;
@@ -45,20 +43,8 @@ export interface InventorySessionDetailResponse extends InventorySessionSummaryR
45
43
  createdById: string;
46
44
  items: InventorySessionItem[];
47
45
  }
48
- /**
49
- * Item that matched QVET stock during upload.
50
- * Shown in the match preview popup.
51
- */
52
- export interface MatchPreviewItem {
53
- qvetCode: number;
54
- description: string;
55
- section: string;
56
- /** The quantity that matched (counted == QVET stock) */
57
- quantity: number;
58
- }
59
46
  /**
60
47
  * Response after uploading a count Excel.
61
- * Includes upload result + items that can be auto-matched.
62
48
  *
63
49
  * @example POST /api/qvet/inventory-sessions/:id/upload
64
50
  */
@@ -71,16 +57,9 @@ export interface UploadCountsResponse {
71
57
  itemsUpdated: number;
72
58
  /** Items that were not found in the session */
73
59
  itemsNotFound: number;
74
- /** Items skipped (already matched) */
60
+ /** Items skipped (already in terminal state) */
75
61
  itemsSkipped: number;
76
62
  };
77
- /** Items that can be auto-matched (counted == QVET stock) */
78
- matchPreview: {
79
- /** Items eligible for matching */
80
- items: MatchPreviewItem[];
81
- /** Total count of matchable items */
82
- count: number;
83
- };
84
63
  }
85
64
  /**
86
65
  * Warning about stock changes detected during review apply.
@@ -4,11 +4,12 @@
4
4
  * Shared type definitions for inventory session items.
5
5
  * Used by both requests and responses.
6
6
  */
7
- import { InventoryItemStatus, InventoryReviewStatus, ManagerDecision, CollaboratorAction } from '../../constants/inventory-session.enums';
7
+ import { InventoryItemStatus, ManagerDecision, CollaboratorAction } from '../../constants/inventory-session.enums';
8
8
  /**
9
9
  * Item data within an inventory session.
10
10
  *
11
- * Tracks the count state of a single product across uploads.
11
+ * status is THE single source of truth for display no priority logic needed.
12
+ * collaboratorAction and managerDecision are audit fields.
12
13
  */
13
14
  export interface InventorySessionItem {
14
15
  qvetCode: number;
@@ -37,17 +38,11 @@ export interface InventorySessionItem {
37
38
  conversionFactor?: number;
38
39
  stockControlType?: string;
39
40
  usageType?: string;
40
- /** Current item status */
41
+ /** Current item status — THE field to display */
41
42
  status: InventoryItemStatus;
42
- /** When the item was matched (ISO 8601) */
43
- matchedAt?: string;
44
- /** Who confirmed the match */
45
- matchedByName?: string;
46
- /** Auto-calculated review status based on count vs stock */
47
- reviewStatus?: InventoryReviewStatus;
48
- /** Collaborator's confirmation of their count */
43
+ /** Collaborator's action on their count (audit) */
49
44
  collaboratorAction?: CollaboratorAction;
50
- /** Manager/reviewer decision */
45
+ /** Manager/reviewer decision (audit) */
51
46
  managerDecision?: ManagerDecision;
52
47
  /** Notes from the reviewer */
53
48
  reviewerNotes?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvp-shared",
3
- "version": "6.73.0",
3
+ "version": "6.74.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",