hvp-shared 6.88.0 → 6.90.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,40 @@
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
+ * Fallback SAT product code when section mapping is not found.
39
+ */
40
+ export declare const DEFAULT_SAT_PRODUCT_CODE = "01010101";
@@ -0,0 +1,58 @@
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.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
+ * Fallback SAT product code when section mapping is not found.
57
+ */
58
+ exports.DEFAULT_SAT_PRODUCT_CODE = "01010101";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,50 @@
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_SAT_PRODUCT_CODE", () => {
47
+ it("should be 01010101 (No identificado)", () => {
48
+ expect(global_invoice_enums_1.DEFAULT_SAT_PRODUCT_CODE).toBe("01010101");
49
+ });
50
+ });
@@ -26,3 +26,4 @@ export * from './documentation.enums';
26
26
  export * from './settlement.enums';
27
27
  export * from './client-billing.enums';
28
28
  export * from './sat-income-invoice';
29
+ export * from './global-invoice.enums';
@@ -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,2 @@
1
+ export * from './requests';
2
+ export * from './responses';
@@ -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,81 @@
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
+ satUnitCode: string;
37
+ facturamaProductId?: string;
38
+ quantity: number;
39
+ unitPrice: number;
40
+ subtotal: number;
41
+ discount: number;
42
+ taxRate: number;
43
+ taxAmount: number;
44
+ total: number;
45
+ originalPaymentMethod: string;
46
+ isScaledByCashPercentage: boolean;
47
+ }
48
+ /**
49
+ * Global invoice data for the monthly grid view.
50
+ * Does NOT include lineItems (too large for list).
51
+ *
52
+ * @example GET /api/billing/global-invoices?year=2026
53
+ */
54
+ export interface GlobalInvoiceListItemResponse {
55
+ id: string;
56
+ year: number;
57
+ month: number;
58
+ status: GlobalInvoiceStatus;
59
+ summary: GlobalInvoiceSummaryResponse;
60
+ cfdiUuid?: string;
61
+ stampedAt?: string;
62
+ cancelledAt?: string;
63
+ errorMessage?: string;
64
+ attemptCount: number;
65
+ createdAt: string;
66
+ updatedAt: string;
67
+ }
68
+ /**
69
+ * Full global invoice detail including all line items.
70
+ *
71
+ * @example GET /api/billing/global-invoices/:id
72
+ */
73
+ export interface GlobalInvoiceDetailResponse extends GlobalInvoiceListItemResponse {
74
+ facturamaId?: string;
75
+ facturamaSerie?: string;
76
+ facturamaFolio?: string;
77
+ cancellationMotive?: string;
78
+ isCronTriggered: boolean;
79
+ lastAttemptAt?: string;
80
+ lineItems: GlobalInvoiceLineItemResponse[];
81
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * Global Invoice API - Response Types
4
+ *
5
+ * Response types for the global invoice (Factura Global) endpoints.
6
+ *
7
+ * @see /api/billing/global-invoices/*
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -13,3 +13,4 @@ export * from './time-off-request';
13
13
  export * from './job';
14
14
  export * from './inventory-session';
15
15
  export * from './client-billing';
16
+ export * from './global-invoice';
@@ -29,3 +29,4 @@ __exportStar(require("./time-off-request"), exports);
29
29
  __exportStar(require("./job"), exports);
30
30
  __exportStar(require("./inventory-session"), exports);
31
31
  __exportStar(require("./client-billing"), exports);
32
+ __exportStar(require("./global-invoice"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvp-shared",
3
- "version": "6.88.0",
3
+ "version": "6.90.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",