hvp-shared 6.88.0 → 6.89.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/constants/global-invoice.enums.d.ts +46 -0
- package/dist/constants/global-invoice.enums.js +78 -0
- package/dist/constants/global-invoice.enums.test.d.ts +1 -0
- package/dist/constants/global-invoice.enums.test.js +64 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/contracts/global-invoice/index.d.ts +2 -0
- package/dist/contracts/global-invoice/index.js +18 -0
- package/dist/contracts/global-invoice/requests.d.ts +27 -0
- package/dist/contracts/global-invoice/requests.js +11 -0
- package/dist/contracts/global-invoice/responses.d.ts +79 -0
- package/dist/contracts/global-invoice/responses.js +9 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global Invoice (Factura Global) Enums and Constants
|
|
3
|
+
*
|
|
4
|
+
* Used for monthly consolidated invoices issued to RFC XAXX010101000
|
|
5
|
+
* (Público en General) per Mexican SAT requirements.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum GlobalInvoiceStatus {
|
|
8
|
+
draft = "draft",
|
|
9
|
+
stamping = "stamping",
|
|
10
|
+
stamped = "stamped",
|
|
11
|
+
failed = "failed",
|
|
12
|
+
cancelled = "cancelled"
|
|
13
|
+
}
|
|
14
|
+
export declare const GLOBAL_INVOICE_STATUS_LABELS: Record<GlobalInvoiceStatus, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Fixed receiver data for global invoices (Público en General).
|
|
17
|
+
* Per SAT CFDI 4.0 specifications.
|
|
18
|
+
*/
|
|
19
|
+
export declare const GLOBAL_INVOICE_RECEIVER: {
|
|
20
|
+
readonly rfc: "XAXX010101000";
|
|
21
|
+
readonly name: "PUBLICO EN GENERAL";
|
|
22
|
+
readonly cfdiUse: "S01";
|
|
23
|
+
readonly fiscalRegime: "616";
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* SAT periodicity codes for the GlobalInformation node in global invoices.
|
|
27
|
+
* @see SAT Catalog c_Periodicidad
|
|
28
|
+
*/
|
|
29
|
+
export declare const SAT_GLOBAL_PERIODICITY: {
|
|
30
|
+
readonly daily: "01";
|
|
31
|
+
readonly weekly: "02";
|
|
32
|
+
readonly biweekly: "03";
|
|
33
|
+
readonly monthly: "04";
|
|
34
|
+
readonly bimonthly: "05";
|
|
35
|
+
};
|
|
36
|
+
export type SATGlobalPeriodicityCode = (typeof SAT_GLOBAL_PERIODICITY)[keyof typeof SAT_GLOBAL_PERIODICITY];
|
|
37
|
+
/**
|
|
38
|
+
* Maps QVET product sections to SAT ClaveProdServ codes.
|
|
39
|
+
* Used when individual products don't have assigned SAT codes.
|
|
40
|
+
* Admin-configurable via company settings.
|
|
41
|
+
*/
|
|
42
|
+
export declare const DEFAULT_SECTION_SAT_CODES: Record<string, string>;
|
|
43
|
+
/**
|
|
44
|
+
* Fallback SAT product code when section mapping is not found.
|
|
45
|
+
*/
|
|
46
|
+
export declare const DEFAULT_SAT_PRODUCT_CODE = "01010101";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Global Invoice (Factura Global) Enums and Constants
|
|
4
|
+
*
|
|
5
|
+
* Used for monthly consolidated invoices issued to RFC XAXX010101000
|
|
6
|
+
* (Público en General) per Mexican SAT requirements.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DEFAULT_SAT_PRODUCT_CODE = exports.DEFAULT_SECTION_SAT_CODES = exports.SAT_GLOBAL_PERIODICITY = exports.GLOBAL_INVOICE_RECEIVER = exports.GLOBAL_INVOICE_STATUS_LABELS = exports.GlobalInvoiceStatus = void 0;
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Global Invoice Status
|
|
12
|
+
// ============================================================================
|
|
13
|
+
var GlobalInvoiceStatus;
|
|
14
|
+
(function (GlobalInvoiceStatus) {
|
|
15
|
+
GlobalInvoiceStatus["draft"] = "draft";
|
|
16
|
+
GlobalInvoiceStatus["stamping"] = "stamping";
|
|
17
|
+
GlobalInvoiceStatus["stamped"] = "stamped";
|
|
18
|
+
GlobalInvoiceStatus["failed"] = "failed";
|
|
19
|
+
GlobalInvoiceStatus["cancelled"] = "cancelled";
|
|
20
|
+
})(GlobalInvoiceStatus || (exports.GlobalInvoiceStatus = GlobalInvoiceStatus = {}));
|
|
21
|
+
exports.GLOBAL_INVOICE_STATUS_LABELS = {
|
|
22
|
+
[GlobalInvoiceStatus.draft]: "Borrador",
|
|
23
|
+
[GlobalInvoiceStatus.stamping]: "Timbrando...",
|
|
24
|
+
[GlobalInvoiceStatus.stamped]: "Timbrada",
|
|
25
|
+
[GlobalInvoiceStatus.failed]: "Error",
|
|
26
|
+
[GlobalInvoiceStatus.cancelled]: "Cancelada",
|
|
27
|
+
};
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// Global Invoice Receiver (SAT standard)
|
|
30
|
+
// ============================================================================
|
|
31
|
+
/**
|
|
32
|
+
* Fixed receiver data for global invoices (Público en General).
|
|
33
|
+
* Per SAT CFDI 4.0 specifications.
|
|
34
|
+
*/
|
|
35
|
+
exports.GLOBAL_INVOICE_RECEIVER = {
|
|
36
|
+
rfc: "XAXX010101000",
|
|
37
|
+
name: "PUBLICO EN GENERAL",
|
|
38
|
+
cfdiUse: "S01",
|
|
39
|
+
fiscalRegime: "616",
|
|
40
|
+
};
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// SAT Global Information - Periodicity (c_Periodicidad)
|
|
43
|
+
// ============================================================================
|
|
44
|
+
/**
|
|
45
|
+
* SAT periodicity codes for the GlobalInformation node in global invoices.
|
|
46
|
+
* @see SAT Catalog c_Periodicidad
|
|
47
|
+
*/
|
|
48
|
+
exports.SAT_GLOBAL_PERIODICITY = {
|
|
49
|
+
daily: "01",
|
|
50
|
+
weekly: "02",
|
|
51
|
+
biweekly: "03",
|
|
52
|
+
monthly: "04",
|
|
53
|
+
bimonthly: "05",
|
|
54
|
+
};
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// Default Section-to-SAT Code Mapping
|
|
57
|
+
// ============================================================================
|
|
58
|
+
/**
|
|
59
|
+
* Maps QVET product sections to SAT ClaveProdServ codes.
|
|
60
|
+
* Used when individual products don't have assigned SAT codes.
|
|
61
|
+
* Admin-configurable via company settings.
|
|
62
|
+
*/
|
|
63
|
+
exports.DEFAULT_SECTION_SAT_CODES = {
|
|
64
|
+
CONSULTAS: "85121800", // Servicios veterinarios
|
|
65
|
+
CIRUGIAS: "85121801", // Servicios quirúrgicos
|
|
66
|
+
LABORATORIO: "85121802", // Servicios de laboratorio clínico
|
|
67
|
+
HOSPITALIZACION: "85121800", // Servicios médicos
|
|
68
|
+
FARMACIA: "51101500", // Productos farmacéuticos
|
|
69
|
+
ACCESORIOS: "10191500", // Accesorios para mascotas
|
|
70
|
+
ALIMENTO: "10191500", // Alimento para mascotas
|
|
71
|
+
ESTETICA: "85121800", // Servicios de estética animal
|
|
72
|
+
IMAGENOLOGIA: "85121802", // Servicios de diagnóstico por imagen
|
|
73
|
+
VACUNAS: "51101500", // Vacunas
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Fallback SAT product code when section mapping is not found.
|
|
77
|
+
*/
|
|
78
|
+
exports.DEFAULT_SAT_PRODUCT_CODE = "01010101";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const global_invoice_enums_1 = require("./global-invoice.enums");
|
|
4
|
+
describe("GlobalInvoiceStatus", () => {
|
|
5
|
+
it("should have a label for every status value", () => {
|
|
6
|
+
const statusValues = Object.values(global_invoice_enums_1.GlobalInvoiceStatus);
|
|
7
|
+
const labelKeys = Object.keys(global_invoice_enums_1.GLOBAL_INVOICE_STATUS_LABELS);
|
|
8
|
+
expect(labelKeys).toHaveLength(statusValues.length);
|
|
9
|
+
for (const status of statusValues) {
|
|
10
|
+
expect(global_invoice_enums_1.GLOBAL_INVOICE_STATUS_LABELS[status]).toBeDefined();
|
|
11
|
+
expect(typeof global_invoice_enums_1.GLOBAL_INVOICE_STATUS_LABELS[status]).toBe("string");
|
|
12
|
+
expect(global_invoice_enums_1.GLOBAL_INVOICE_STATUS_LABELS[status].length).toBeGreaterThan(0);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
it("should have expected status values", () => {
|
|
16
|
+
expect(global_invoice_enums_1.GlobalInvoiceStatus.draft).toBe("draft");
|
|
17
|
+
expect(global_invoice_enums_1.GlobalInvoiceStatus.stamping).toBe("stamping");
|
|
18
|
+
expect(global_invoice_enums_1.GlobalInvoiceStatus.stamped).toBe("stamped");
|
|
19
|
+
expect(global_invoice_enums_1.GlobalInvoiceStatus.failed).toBe("failed");
|
|
20
|
+
expect(global_invoice_enums_1.GlobalInvoiceStatus.cancelled).toBe("cancelled");
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe("GLOBAL_INVOICE_RECEIVER", () => {
|
|
24
|
+
it("should use SAT standard RFC for público en general", () => {
|
|
25
|
+
expect(global_invoice_enums_1.GLOBAL_INVOICE_RECEIVER.rfc).toBe("XAXX010101000");
|
|
26
|
+
});
|
|
27
|
+
it("should use uppercase name without accents", () => {
|
|
28
|
+
expect(global_invoice_enums_1.GLOBAL_INVOICE_RECEIVER.name).toBe("PUBLICO EN GENERAL");
|
|
29
|
+
});
|
|
30
|
+
it("should use S01 CFDI use (sin efectos fiscales)", () => {
|
|
31
|
+
expect(global_invoice_enums_1.GLOBAL_INVOICE_RECEIVER.cfdiUse).toBe("S01");
|
|
32
|
+
});
|
|
33
|
+
it("should use 616 fiscal regime (sin obligaciones fiscales)", () => {
|
|
34
|
+
expect(global_invoice_enums_1.GLOBAL_INVOICE_RECEIVER.fiscalRegime).toBe("616");
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe("SAT_GLOBAL_PERIODICITY", () => {
|
|
38
|
+
it("should have monthly as 04", () => {
|
|
39
|
+
expect(global_invoice_enums_1.SAT_GLOBAL_PERIODICITY.monthly).toBe("04");
|
|
40
|
+
});
|
|
41
|
+
it("should have all valid SAT periodicity codes", () => {
|
|
42
|
+
const values = Object.values(global_invoice_enums_1.SAT_GLOBAL_PERIODICITY);
|
|
43
|
+
expect(values).toEqual(["01", "02", "03", "04", "05"]);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe("DEFAULT_SECTION_SAT_CODES", () => {
|
|
47
|
+
it("should have all SAT codes as 8-digit numeric strings", () => {
|
|
48
|
+
for (const [section, code] of Object.entries(global_invoice_enums_1.DEFAULT_SECTION_SAT_CODES)) {
|
|
49
|
+
expect(code).toMatch(/^\d{8}$/);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
it("should map veterinary sections to known SAT codes", () => {
|
|
53
|
+
expect(global_invoice_enums_1.DEFAULT_SECTION_SAT_CODES["CONSULTAS"]).toBe("85121800");
|
|
54
|
+
expect(global_invoice_enums_1.DEFAULT_SECTION_SAT_CODES["FARMACIA"]).toBe("51101500");
|
|
55
|
+
});
|
|
56
|
+
it("should not be empty", () => {
|
|
57
|
+
expect(Object.keys(global_invoice_enums_1.DEFAULT_SECTION_SAT_CODES).length).toBeGreaterThan(0);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe("DEFAULT_SAT_PRODUCT_CODE", () => {
|
|
61
|
+
it("should be 01010101 (No identificado)", () => {
|
|
62
|
+
expect(global_invoice_enums_1.DEFAULT_SAT_PRODUCT_CODE).toBe("01010101");
|
|
63
|
+
});
|
|
64
|
+
});
|
package/dist/constants/index.js
CHANGED
|
@@ -42,3 +42,4 @@ __exportStar(require("./documentation.enums"), exports);
|
|
|
42
42
|
__exportStar(require("./settlement.enums"), exports);
|
|
43
43
|
__exportStar(require("./client-billing.enums"), exports);
|
|
44
44
|
__exportStar(require("./sat-income-invoice"), exports);
|
|
45
|
+
__exportStar(require("./global-invoice.enums"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./requests"), exports);
|
|
18
|
+
__exportStar(require("./responses"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global Invoice API - Request Types
|
|
3
|
+
*
|
|
4
|
+
* Request types for the global invoice (Factura Global) endpoints.
|
|
5
|
+
* Admin-only operations for generating, stamping, and managing
|
|
6
|
+
* monthly consolidated invoices.
|
|
7
|
+
*
|
|
8
|
+
* @see /api/billing/global-invoices/*
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Generate a global invoice draft for a specific month.
|
|
12
|
+
*
|
|
13
|
+
* @example POST /api/billing/global-invoices/generate
|
|
14
|
+
*/
|
|
15
|
+
export interface GenerateGlobalInvoiceRequest {
|
|
16
|
+
year: number;
|
|
17
|
+
month: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Cancel a stamped global invoice with SAT motive code.
|
|
21
|
+
*
|
|
22
|
+
* @example POST /api/billing/global-invoices/:id/cancel
|
|
23
|
+
*/
|
|
24
|
+
export interface CancelGlobalInvoiceRequest {
|
|
25
|
+
/** SAT cancellation motive code: "01", "02", "03", "04" */
|
|
26
|
+
motive: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Global Invoice API - Request Types
|
|
4
|
+
*
|
|
5
|
+
* Request types for the global invoice (Factura Global) endpoints.
|
|
6
|
+
* Admin-only operations for generating, stamping, and managing
|
|
7
|
+
* monthly consolidated invoices.
|
|
8
|
+
*
|
|
9
|
+
* @see /api/billing/global-invoices/*
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global Invoice API - Response Types
|
|
3
|
+
*
|
|
4
|
+
* Response types for the global invoice (Factura Global) endpoints.
|
|
5
|
+
*
|
|
6
|
+
* @see /api/billing/global-invoices/*
|
|
7
|
+
*/
|
|
8
|
+
import { GlobalInvoiceStatus } from '../../constants/global-invoice.enums';
|
|
9
|
+
/**
|
|
10
|
+
* Aggregation summary of the global invoice.
|
|
11
|
+
*/
|
|
12
|
+
export interface GlobalInvoiceSummaryResponse {
|
|
13
|
+
totalSubtotal: number;
|
|
14
|
+
totalIva: number;
|
|
15
|
+
totalAmount: number;
|
|
16
|
+
itemCount: number;
|
|
17
|
+
excludedInvoicedCount: number;
|
|
18
|
+
excludedLastDayCount: number;
|
|
19
|
+
cashPercentageApplied: number;
|
|
20
|
+
dominantPaymentForm: string;
|
|
21
|
+
paymentBreakdown: GlobalInvoicePaymentBreakdownItem[];
|
|
22
|
+
}
|
|
23
|
+
export interface GlobalInvoicePaymentBreakdownItem {
|
|
24
|
+
method: string;
|
|
25
|
+
satCode: string;
|
|
26
|
+
total: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Single line item in the global invoice.
|
|
30
|
+
*/
|
|
31
|
+
export interface GlobalInvoiceLineItemResponse {
|
|
32
|
+
productName: string;
|
|
33
|
+
section: string;
|
|
34
|
+
family: string;
|
|
35
|
+
satProductCode: string;
|
|
36
|
+
quantity: number;
|
|
37
|
+
unitPrice: number;
|
|
38
|
+
subtotal: number;
|
|
39
|
+
discount: number;
|
|
40
|
+
taxRate: number;
|
|
41
|
+
taxAmount: number;
|
|
42
|
+
total: number;
|
|
43
|
+
originalPaymentMethod: string;
|
|
44
|
+
isScaledByCashPercentage: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Global invoice data for the monthly grid view.
|
|
48
|
+
* Does NOT include lineItems (too large for list).
|
|
49
|
+
*
|
|
50
|
+
* @example GET /api/billing/global-invoices?year=2026
|
|
51
|
+
*/
|
|
52
|
+
export interface GlobalInvoiceListItemResponse {
|
|
53
|
+
id: string;
|
|
54
|
+
year: number;
|
|
55
|
+
month: number;
|
|
56
|
+
status: GlobalInvoiceStatus;
|
|
57
|
+
summary: GlobalInvoiceSummaryResponse;
|
|
58
|
+
cfdiUuid?: string;
|
|
59
|
+
stampedAt?: string;
|
|
60
|
+
cancelledAt?: string;
|
|
61
|
+
errorMessage?: string;
|
|
62
|
+
attemptCount: number;
|
|
63
|
+
createdAt: string;
|
|
64
|
+
updatedAt: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Full global invoice detail including all line items.
|
|
68
|
+
*
|
|
69
|
+
* @example GET /api/billing/global-invoices/:id
|
|
70
|
+
*/
|
|
71
|
+
export interface GlobalInvoiceDetailResponse extends GlobalInvoiceListItemResponse {
|
|
72
|
+
facturamaId?: string;
|
|
73
|
+
facturamaSerie?: string;
|
|
74
|
+
facturamaFolio?: string;
|
|
75
|
+
cancellationMotive?: string;
|
|
76
|
+
isCronTriggered: boolean;
|
|
77
|
+
lastAttemptAt?: string;
|
|
78
|
+
lineItems: GlobalInvoiceLineItemResponse[];
|
|
79
|
+
}
|
package/dist/contracts/index.js
CHANGED