hvp-shared 6.42.0 → 6.44.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.
@@ -0,0 +1,25 @@
1
+ /**
2
+ * HR Enums — shared across backend and frontend.
3
+ *
4
+ * These enums were previously duplicated in both repos.
5
+ * Single source of truth lives here in hvp-shared.
6
+ */
7
+ export declare enum PayrollStatus {
8
+ Pending = "pending",
9
+ Approved = "approved",
10
+ Paid = "paid",
11
+ Billed = "billed"
12
+ }
13
+ export declare enum CfdiStatus {
14
+ Pending = "pending",
15
+ Ready = "ready",
16
+ Stamped = "stamped",
17
+ StampedExternal = "stamped_external",
18
+ Cancelled = "cancelled",
19
+ Error = "error"
20
+ }
21
+ export declare enum HRPaymentType {
22
+ HOURLY = "HOURLY",
23
+ SALARY = "SALARY",
24
+ INFORMAL = "INFORMAL"
25
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * HR Enums — shared across backend and frontend.
4
+ *
5
+ * These enums were previously duplicated in both repos.
6
+ * Single source of truth lives here in hvp-shared.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.HRPaymentType = exports.CfdiStatus = exports.PayrollStatus = void 0;
10
+ var PayrollStatus;
11
+ (function (PayrollStatus) {
12
+ PayrollStatus["Pending"] = "pending";
13
+ PayrollStatus["Approved"] = "approved";
14
+ PayrollStatus["Paid"] = "paid";
15
+ PayrollStatus["Billed"] = "billed";
16
+ })(PayrollStatus || (exports.PayrollStatus = PayrollStatus = {}));
17
+ var CfdiStatus;
18
+ (function (CfdiStatus) {
19
+ CfdiStatus["Pending"] = "pending";
20
+ CfdiStatus["Ready"] = "ready";
21
+ CfdiStatus["Stamped"] = "stamped";
22
+ CfdiStatus["StampedExternal"] = "stamped_external";
23
+ CfdiStatus["Cancelled"] = "cancelled";
24
+ CfdiStatus["Error"] = "error";
25
+ })(CfdiStatus || (exports.CfdiStatus = CfdiStatus = {}));
26
+ var HRPaymentType;
27
+ (function (HRPaymentType) {
28
+ HRPaymentType["HOURLY"] = "HOURLY";
29
+ HRPaymentType["SALARY"] = "SALARY";
30
+ HRPaymentType["INFORMAL"] = "INFORMAL";
31
+ })(HRPaymentType || (exports.HRPaymentType = HRPaymentType = {}));
@@ -14,3 +14,4 @@ export * from './background-job.constants';
14
14
  export * from './job-category.constants';
15
15
  export * from './special-collaborators.constants';
16
16
  export * from './commissions.constants';
17
+ export * from './hr.enums';
@@ -30,3 +30,4 @@ __exportStar(require("./background-job.constants"), exports);
30
30
  __exportStar(require("./job-category.constants"), exports);
31
31
  __exportStar(require("./special-collaborators.constants"), exports);
32
32
  __exportStar(require("./commissions.constants"), exports);
33
+ __exportStar(require("./hr.enums"), exports);
@@ -44,6 +44,7 @@ export interface CreateCollaboratorRequest {
44
44
  dailySalary?: number;
45
45
  accessCode?: string;
46
46
  password?: string;
47
+ qvetAliases?: string[];
47
48
  }
48
49
  /**
49
50
  * Update Collaborator Request
@@ -88,6 +89,7 @@ export interface UpdateCollaboratorRequest {
88
89
  dailySalary?: number;
89
90
  accessCode?: string;
90
91
  password?: string;
92
+ qvetAliases?: string[];
91
93
  }
92
94
  /**
93
95
  * Register Collaborator Request
@@ -71,6 +71,7 @@ export interface AdminCollaboratorResponse extends CollaboratorViewResponse {
71
71
  baseSalary?: number;
72
72
  dailySalary?: number;
73
73
  accessCode?: string;
74
+ qvetAliases: string[];
74
75
  createdBy?: string;
75
76
  updatedBy?: string;
76
77
  }
package/dist/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export * from './validation';
9
9
  export { debugLog } from './utils/debug-logger';
10
10
  export * from './utils/sync-field.helpers';
11
11
  export * from './utils/qvet-catalog.helpers';
12
+ export * from './utils/qvet-staff.helpers';
package/dist/index.js CHANGED
@@ -27,3 +27,4 @@ var debug_logger_1 = require("./utils/debug-logger");
27
27
  Object.defineProperty(exports, "debugLog", { enumerable: true, get: function () { return debug_logger_1.debugLog; } });
28
28
  __exportStar(require("./utils/sync-field.helpers"), exports);
29
29
  __exportStar(require("./utils/qvet-catalog.helpers"), exports);
30
+ __exportStar(require("./utils/qvet-staff.helpers"), exports);
@@ -4,12 +4,8 @@
4
4
  * Each item is self-describing: carries SAT codes, taxed/exempt split,
5
5
  * source key for internal reference, and an optional formula explaining
6
6
  * how the amount was calculated.
7
- *
8
- * NOTE: CfdiStatus and PayrollStatus enums are NOT imported here because
9
- * they live in repo-specific enum files (used in 19+ files each). Instead,
10
- * the `status` and `payrollStatus` fields use `string`, which is compatible
11
- * since TypeScript string enum values ARE strings.
12
7
  */
8
+ import { CfdiStatus, PayrollStatus } from '../constants/hr.enums';
13
9
  export declare enum PayrollItemCategory {
14
10
  BASE_SALARY = "BASE_SALARY",
15
11
  ADDITIONAL_FIXED = "ADDITIONAL_FIXED",
@@ -88,8 +84,7 @@ export interface PayrollEmployeeSnapshot {
88
84
  readonly positionRisk?: string;
89
85
  }
90
86
  export interface PayrollV2Cfdi {
91
- /** CfdiStatus value — typed as string to avoid coupling to repo-specific enums */
92
- readonly status: string;
87
+ readonly status: CfdiStatus;
93
88
  readonly uuid?: string;
94
89
  readonly facturamaId?: string;
95
90
  readonly stampedAt?: Date | string;
@@ -128,8 +123,7 @@ export interface PayrollV2 {
128
123
  readonly jobId?: string;
129
124
  readonly periodStartDate?: string;
130
125
  readonly periodEndDate?: string;
131
- /** PayrollStatus value — typed as string to avoid coupling to repo-specific enums */
132
- readonly payrollStatus?: string;
126
+ readonly payrollStatus?: PayrollStatus;
133
127
  readonly daysPaid?: number;
134
128
  readonly perceptions: PayrollItem[];
135
129
  readonly deductions: PayrollItem[];
@@ -5,11 +5,6 @@
5
5
  * Each item is self-describing: carries SAT codes, taxed/exempt split,
6
6
  * source key for internal reference, and an optional formula explaining
7
7
  * how the amount was calculated.
8
- *
9
- * NOTE: CfdiStatus and PayrollStatus enums are NOT imported here because
10
- * they live in repo-specific enum files (used in 19+ files each). Instead,
11
- * the `status` and `payrollStatus` fields use `string`, which is compatible
12
- * since TypeScript string enum values ARE strings.
13
8
  */
14
9
  Object.defineProperty(exports, "__esModule", { value: true });
15
10
  exports.PayrollItemCategory = void 0;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * QVET Staff Helpers
3
+ *
4
+ * Utility functions for normalizing QVET staff names for alias matching.
5
+ *
6
+ * QVET exports strip accents inconsistently (e.g., AVENDAÑO → AVENDANO or AVENDAO).
7
+ * This normalizer strips all diacritics so lookups work regardless of source encoding.
8
+ */
9
+ /**
10
+ * Normalize a QVET staff name for alias matching.
11
+ *
12
+ * - Uppercase
13
+ * - Strip diacritics (NFD decompose + remove combining marks): ñ→N, é→E, etc.
14
+ * - Collapse multiple whitespace to single space
15
+ * - Trim leading/trailing whitespace
16
+ *
17
+ * @param name - Raw name from QVET export or user input
18
+ * @returns Normalized name, or empty string for null/undefined/empty
19
+ */
20
+ export declare function normalizeQvetName(name: string | null | undefined): string;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /**
3
+ * QVET Staff Helpers
4
+ *
5
+ * Utility functions for normalizing QVET staff names for alias matching.
6
+ *
7
+ * QVET exports strip accents inconsistently (e.g., AVENDAÑO → AVENDANO or AVENDAO).
8
+ * This normalizer strips all diacritics so lookups work regardless of source encoding.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.normalizeQvetName = normalizeQvetName;
12
+ /**
13
+ * Normalize a QVET staff name for alias matching.
14
+ *
15
+ * - Uppercase
16
+ * - Strip diacritics (NFD decompose + remove combining marks): ñ→N, é→E, etc.
17
+ * - Collapse multiple whitespace to single space
18
+ * - Trim leading/trailing whitespace
19
+ *
20
+ * @param name - Raw name from QVET export or user input
21
+ * @returns Normalized name, or empty string for null/undefined/empty
22
+ */
23
+ function normalizeQvetName(name) {
24
+ if (!name)
25
+ return '';
26
+ return name
27
+ .normalize('NFD')
28
+ .replace(/[\u0300-\u036f]/g, '')
29
+ .toUpperCase()
30
+ .replace(/\s+/g, ' ')
31
+ .trim();
32
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const qvet_staff_helpers_1 = require("./qvet-staff.helpers");
4
+ describe('normalizeQvetName', () => {
5
+ describe('diacritic stripping', () => {
6
+ it('should strip ñ → N', () => {
7
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('AVENDAÑO')).toBe('AVENDANO');
8
+ });
9
+ it('should strip accented vowels', () => {
10
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('FÉLIX VELÁZQUEZ')).toBe('FELIX VELAZQUEZ');
11
+ });
12
+ it('should strip ü', () => {
13
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('GÜERO')).toBe('GUERO');
14
+ });
15
+ it('should handle mixed accented and non-accented chars', () => {
16
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('María de Lourdes Avendaño Talarico'))
17
+ .toBe('MARIA DE LOURDES AVENDANO TALARICO');
18
+ });
19
+ });
20
+ describe('uppercase', () => {
21
+ it('should convert lowercase to uppercase', () => {
22
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('felix velazquez')).toBe('FELIX VELAZQUEZ');
23
+ });
24
+ it('should convert mixed case to uppercase', () => {
25
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('Sara Delgado Inurreta')).toBe('SARA DELGADO INURRETA');
26
+ });
27
+ });
28
+ describe('whitespace handling', () => {
29
+ it('should collapse double spaces', () => {
30
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('RAFAEL A GARCIA')).toBe('RAFAEL A GARCIA');
31
+ });
32
+ it('should collapse multiple spaces', () => {
33
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('RAFAEL A. GARCIA LOPEZ')).toBe('RAFAEL A. GARCIA LOPEZ');
34
+ });
35
+ it('should trim leading whitespace', () => {
36
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)(' FELIX')).toBe('FELIX');
37
+ });
38
+ it('should trim trailing whitespace', () => {
39
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('FELIX ')).toBe('FELIX');
40
+ });
41
+ it('should handle tabs and newlines', () => {
42
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('FELIX\tVELAZQUEZ\n')).toBe('FELIX VELAZQUEZ');
43
+ });
44
+ });
45
+ describe('null/empty handling', () => {
46
+ it('should return empty string for null', () => {
47
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)(null)).toBe('');
48
+ });
49
+ it('should return empty string for undefined', () => {
50
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)(undefined)).toBe('');
51
+ });
52
+ it('should return empty string for empty string', () => {
53
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('')).toBe('');
54
+ });
55
+ it('should return empty string for whitespace-only string', () => {
56
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)(' ')).toBe('');
57
+ });
58
+ });
59
+ describe('NFC pre-composed input', () => {
60
+ it('should handle NFC-composed ñ', () => {
61
+ // NFC: ñ as single codepoint U+00F1
62
+ const nfc = 'PI\u00F1A';
63
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)(nfc)).toBe('PINA');
64
+ });
65
+ it('should handle NFD-decomposed ñ', () => {
66
+ // NFD: n + combining tilde U+0303
67
+ const nfd = 'PIN\u0303A';
68
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)(nfd)).toBe('PINA');
69
+ });
70
+ it('should produce same result for NFC and NFD input', () => {
71
+ const nfc = 'COLMENARES PI\u00F1A';
72
+ const nfd = 'COLMENARES PIN\u0303A';
73
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)(nfc)).toBe((0, qvet_staff_helpers_1.normalizeQvetName)(nfd));
74
+ });
75
+ });
76
+ describe('real-world QVET names', () => {
77
+ it('should normalize QVET-stripped names', () => {
78
+ // QVET already stripped some diacritics but left others
79
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('KARLA NUEZ BARRERA')).toBe('KARLA NUEZ BARRERA');
80
+ });
81
+ it('should normalize names with original accents', () => {
82
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('Karla Sofía Núñez Barrera')).toBe('KARLA SOFIA NUNEZ BARRERA');
83
+ });
84
+ it('should handle Leonardo Méndez case (partial stripping)', () => {
85
+ // QVET exported as "Leonardo Guillermo Mndez Porres" (stripped é completely)
86
+ expect((0, qvet_staff_helpers_1.normalizeQvetName)('Leonardo Guillermo Mndez Porres'))
87
+ .toBe('LEONARDO GUILLERMO MNDEZ PORRES');
88
+ });
89
+ });
90
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvp-shared",
3
- "version": "6.42.0",
3
+ "version": "6.44.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",