hvp-shared 14.5.0 → 14.6.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.
@@ -25,6 +25,7 @@ export * from './hris.constants';
25
25
  export * from './payroll-features.constants';
26
26
  export * from './inventory-session.enums';
27
27
  export * from './shift-checklist.enums';
28
+ export * from './supplier-payments.enums';
28
29
  export * from './documentation.enums';
29
30
  export * from './document.enums';
30
31
  export * from './settlement.enums';
@@ -41,6 +41,7 @@ __exportStar(require("./hris.constants"), exports);
41
41
  __exportStar(require("./payroll-features.constants"), exports);
42
42
  __exportStar(require("./inventory-session.enums"), exports);
43
43
  __exportStar(require("./shift-checklist.enums"), exports);
44
+ __exportStar(require("./supplier-payments.enums"), exports);
44
45
  __exportStar(require("./documentation.enums"), exports);
45
46
  __exportStar(require("./document.enums"), exports);
46
47
  __exportStar(require("./settlement.enums"), exports);
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Supplier Payments Enums ("Próximos pagos a proveedores")
3
+ *
4
+ * Unifies the payment obligations a payer must settle each period across several
5
+ * sources: QVET credit invoices (vencimientos), recurring monthly obligations,
6
+ * and sporadic ad-hoc payments — plus generic per-supplier discount rules.
7
+ *
8
+ * See design doc: resources/research/20260701-supplier-payments-platform.md
9
+ */
10
+ /**
11
+ * Where a payment obligation comes from.
12
+ *
13
+ * - `qvet_credit` (Crédito QVET): a supplier invoice paid by transfer that has a
14
+ * vencimiento (due date) in QVET report 718.
15
+ * - `recurring` (Recurrente): a known monthly obligation not in QVET
16
+ * (Petco, QVET, Medam, SAT, IMSS, Anilab, Yi Health, Península).
17
+ * - `adhoc` (Esporádico): a one-off payment captured manually.
18
+ */
19
+ export declare enum PaymentType {
20
+ qvet_credit = "qvet_credit",
21
+ recurring = "recurring",
22
+ adhoc = "adhoc"
23
+ }
24
+ export declare const PAYMENT_TYPE_LABELS: Record<PaymentType, string>;
25
+ /**
26
+ * Settlement status of a single payment obligation.
27
+ *
28
+ * - `pending` (Pendiente): not yet paid.
29
+ * - `paid` (Pagado): settled.
30
+ * - `scheduled` (Programado): planned for a future pay day but not yet paid.
31
+ * - `cancelled` (Cancelado): no longer owed.
32
+ */
33
+ export declare enum PaymentStatus {
34
+ pending = "pending",
35
+ paid = "paid",
36
+ scheduled = "scheduled",
37
+ cancelled = "cancelled"
38
+ }
39
+ export declare const PAYMENT_STATUS_LABELS: Record<PaymentStatus, string>;
40
+ /**
41
+ * Whether a recurring payment has a fixed amount or a variable one entered each month.
42
+ */
43
+ export declare enum RecurringAmountType {
44
+ fixed = "fixed",
45
+ variable = "variable"
46
+ }
47
+ export declare const RECURRING_AMOUNT_TYPE_LABELS: Record<RecurringAmountType, string>;
48
+ /**
49
+ * Kind of per-supplier discount arrangement.
50
+ *
51
+ * - `percentage` (Porcentaje): e.g. Telvet 5%.
52
+ * - `fixed` (Monto fijo): a flat discount amount.
53
+ */
54
+ export declare enum DiscountRuleType {
55
+ percentage = "percentage",
56
+ fixed = "fixed"
57
+ }
58
+ export declare const DISCOUNT_RULE_TYPE_LABELS: Record<DiscountRuleType, string>;
59
+ /**
60
+ * What base a discount rule applies to.
61
+ *
62
+ * - `period_total` (Total del periodo): applied over the SUM of the supplier's
63
+ * invoices for the period (how Telvet 5% works today).
64
+ */
65
+ export declare enum DiscountAppliesTo {
66
+ period_total = "period_total"
67
+ }
68
+ export declare const DISCOUNT_APPLIES_TO_LABELS: Record<DiscountAppliesTo, string>;
69
+ /** Default pay day (day of month) when a payment doesn't specify one. */
70
+ export declare const DEFAULT_PAY_DAY = 1;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ /**
3
+ * Supplier Payments Enums ("Próximos pagos a proveedores")
4
+ *
5
+ * Unifies the payment obligations a payer must settle each period across several
6
+ * sources: QVET credit invoices (vencimientos), recurring monthly obligations,
7
+ * and sporadic ad-hoc payments — plus generic per-supplier discount rules.
8
+ *
9
+ * See design doc: resources/research/20260701-supplier-payments-platform.md
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DEFAULT_PAY_DAY = exports.DISCOUNT_APPLIES_TO_LABELS = exports.DiscountAppliesTo = exports.DISCOUNT_RULE_TYPE_LABELS = exports.DiscountRuleType = exports.RECURRING_AMOUNT_TYPE_LABELS = exports.RecurringAmountType = exports.PAYMENT_STATUS_LABELS = exports.PaymentStatus = exports.PAYMENT_TYPE_LABELS = exports.PaymentType = void 0;
13
+ // --- Payment type (the source of the obligation) ---
14
+ /**
15
+ * Where a payment obligation comes from.
16
+ *
17
+ * - `qvet_credit` (Crédito QVET): a supplier invoice paid by transfer that has a
18
+ * vencimiento (due date) in QVET report 718.
19
+ * - `recurring` (Recurrente): a known monthly obligation not in QVET
20
+ * (Petco, QVET, Medam, SAT, IMSS, Anilab, Yi Health, Península).
21
+ * - `adhoc` (Esporádico): a one-off payment captured manually.
22
+ */
23
+ var PaymentType;
24
+ (function (PaymentType) {
25
+ PaymentType["qvet_credit"] = "qvet_credit";
26
+ PaymentType["recurring"] = "recurring";
27
+ PaymentType["adhoc"] = "adhoc";
28
+ })(PaymentType || (exports.PaymentType = PaymentType = {}));
29
+ exports.PAYMENT_TYPE_LABELS = {
30
+ [PaymentType.qvet_credit]: "Crédito QVET",
31
+ [PaymentType.recurring]: "Recurrente",
32
+ [PaymentType.adhoc]: "Esporádico",
33
+ };
34
+ // --- Payment status ---
35
+ /**
36
+ * Settlement status of a single payment obligation.
37
+ *
38
+ * - `pending` (Pendiente): not yet paid.
39
+ * - `paid` (Pagado): settled.
40
+ * - `scheduled` (Programado): planned for a future pay day but not yet paid.
41
+ * - `cancelled` (Cancelado): no longer owed.
42
+ */
43
+ var PaymentStatus;
44
+ (function (PaymentStatus) {
45
+ PaymentStatus["pending"] = "pending";
46
+ PaymentStatus["paid"] = "paid";
47
+ PaymentStatus["scheduled"] = "scheduled";
48
+ PaymentStatus["cancelled"] = "cancelled";
49
+ })(PaymentStatus || (exports.PaymentStatus = PaymentStatus = {}));
50
+ exports.PAYMENT_STATUS_LABELS = {
51
+ [PaymentStatus.pending]: "Pendiente",
52
+ [PaymentStatus.paid]: "Pagado",
53
+ [PaymentStatus.scheduled]: "Programado",
54
+ [PaymentStatus.cancelled]: "Cancelado",
55
+ };
56
+ // --- Recurring amount kind ---
57
+ /**
58
+ * Whether a recurring payment has a fixed amount or a variable one entered each month.
59
+ */
60
+ var RecurringAmountType;
61
+ (function (RecurringAmountType) {
62
+ RecurringAmountType["fixed"] = "fixed";
63
+ RecurringAmountType["variable"] = "variable";
64
+ })(RecurringAmountType || (exports.RecurringAmountType = RecurringAmountType = {}));
65
+ exports.RECURRING_AMOUNT_TYPE_LABELS = {
66
+ [RecurringAmountType.fixed]: "Fijo",
67
+ [RecurringAmountType.variable]: "Variable",
68
+ };
69
+ // --- Discount rule ---
70
+ /**
71
+ * Kind of per-supplier discount arrangement.
72
+ *
73
+ * - `percentage` (Porcentaje): e.g. Telvet 5%.
74
+ * - `fixed` (Monto fijo): a flat discount amount.
75
+ */
76
+ var DiscountRuleType;
77
+ (function (DiscountRuleType) {
78
+ DiscountRuleType["percentage"] = "percentage";
79
+ DiscountRuleType["fixed"] = "fixed";
80
+ })(DiscountRuleType || (exports.DiscountRuleType = DiscountRuleType = {}));
81
+ exports.DISCOUNT_RULE_TYPE_LABELS = {
82
+ [DiscountRuleType.percentage]: "Porcentaje",
83
+ [DiscountRuleType.fixed]: "Monto fijo",
84
+ };
85
+ /**
86
+ * What base a discount rule applies to.
87
+ *
88
+ * - `period_total` (Total del periodo): applied over the SUM of the supplier's
89
+ * invoices for the period (how Telvet 5% works today).
90
+ */
91
+ var DiscountAppliesTo;
92
+ (function (DiscountAppliesTo) {
93
+ DiscountAppliesTo["period_total"] = "period_total";
94
+ })(DiscountAppliesTo || (exports.DiscountAppliesTo = DiscountAppliesTo = {}));
95
+ exports.DISCOUNT_APPLIES_TO_LABELS = {
96
+ [DiscountAppliesTo.period_total]: "Total del periodo",
97
+ };
98
+ /** Default pay day (day of month) when a payment doesn't specify one. */
99
+ exports.DEFAULT_PAY_DAY = 1;
@@ -25,4 +25,5 @@ export * from './external-study';
25
25
  export * from './pending-dashboard';
26
26
  export * from './document';
27
27
  export * from './supplier-orders';
28
+ export * from './supplier-payments';
28
29
  export * from './commission-reconciliation';
@@ -41,4 +41,5 @@ __exportStar(require("./external-study"), exports);
41
41
  __exportStar(require("./pending-dashboard"), exports);
42
42
  __exportStar(require("./document"), exports);
43
43
  __exportStar(require("./supplier-orders"), exports);
44
+ __exportStar(require("./supplier-payments"), exports);
44
45
  __exportStar(require("./commission-reconciliation"), exports);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Supplier Payments API Contracts ("Próximos pagos a proveedores")
3
+ */
4
+ export * from "./types";
5
+ export * from "./requests";
6
+ export * from "./responses";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /**
3
+ * Supplier Payments API Contracts ("Próximos pagos a proveedores")
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./types"), exports);
21
+ __exportStar(require("./requests"), exports);
22
+ __exportStar(require("./responses"), exports);
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Supplier Payments — request contracts
3
+ */
4
+ import { DiscountAppliesTo, DiscountRuleType, PaymentStatus, PaymentType, RecurringAmountType } from "../../constants/supplier-payments.enums";
5
+ /**
6
+ * Query params for the unified payments list / summary.
7
+ * @example GET /api/supplier-payments?year=2026&month=6&status=pending
8
+ */
9
+ export interface SupplierPaymentsQueryParams {
10
+ year?: number;
11
+ month?: number;
12
+ /** Alternative to year/month: explicit ISO range. */
13
+ fromDate?: string;
14
+ toDate?: string;
15
+ supplier?: string;
16
+ status?: PaymentStatus;
17
+ type?: PaymentType;
18
+ /** Include per-item detail inside each supplier summary. */
19
+ includeItems?: boolean;
20
+ }
21
+ /**
22
+ * Mark a payment paid/pending (writes the HVP overlay; never touches QVET).
23
+ * @example PATCH /api/supplier-payments/:id/status
24
+ */
25
+ export interface MarkPaymentStatusRequest {
26
+ status: PaymentStatus;
27
+ /** ISO timestamp; defaults to now when marking paid. */
28
+ paidAt?: string;
29
+ paymentMethod?: string;
30
+ notes?: string;
31
+ }
32
+ export interface CreateRecurringPaymentRequest {
33
+ supplier: string;
34
+ concept: string;
35
+ amountType: RecurringAmountType;
36
+ /** Required when amountType = fixed. */
37
+ amount?: number;
38
+ /** Day of month to pay (default 1). */
39
+ payDay?: number;
40
+ isActive?: boolean;
41
+ }
42
+ export type UpdateRecurringPaymentRequest = Partial<CreateRecurringPaymentRequest>;
43
+ export interface CreateAdhocPaymentRequest {
44
+ supplier: string;
45
+ concept: string;
46
+ amount: number;
47
+ /** ISO date it's due / to be paid. */
48
+ dueDate?: string;
49
+ payDay?: number;
50
+ status?: PaymentStatus;
51
+ notes?: string;
52
+ }
53
+ export type UpdateAdhocPaymentRequest = Partial<CreateAdhocPaymentRequest>;
54
+ export interface CreateSupplierDiscountRuleRequest {
55
+ supplier: string;
56
+ type: DiscountRuleType;
57
+ /** Percentage (e.g. 5 for 5%) or fixed amount, per `type`. */
58
+ value: number;
59
+ appliesTo?: DiscountAppliesTo;
60
+ isActive?: boolean;
61
+ }
62
+ export type UpdateSupplierDiscountRuleRequest = Partial<CreateSupplierDiscountRuleRequest>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Supplier Payments — request contracts
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Supplier Payments — response contracts
3
+ */
4
+ import { DiscountAppliesTo, DiscountRuleType, PaymentStatus, RecurringAmountType } from "../../constants/supplier-payments.enums";
5
+ import { SupplierPaymentSummary } from "./types";
6
+ /**
7
+ * The main "próximos pagos" response: per-supplier totals + grand totals.
8
+ * @example GET /api/supplier-payments/summary
9
+ */
10
+ export interface SupplierPaymentsSummaryResponse {
11
+ bySupplier: SupplierPaymentSummary[];
12
+ /** Grand totals across all suppliers. */
13
+ grossTotal: number;
14
+ discountTotal: number;
15
+ netTotal: number;
16
+ pendingTotal: number;
17
+ paidTotal: number;
18
+ supplierCount: number;
19
+ }
20
+ /** A configured recurring monthly payment (HVP-owned). */
21
+ export interface RecurringPaymentResponse {
22
+ id: string;
23
+ supplier: string;
24
+ concept: string;
25
+ amountType: RecurringAmountType;
26
+ amount?: number;
27
+ payDay: number;
28
+ isActive: boolean;
29
+ createdAt: string;
30
+ updatedAt: string;
31
+ createdBy?: string;
32
+ updatedBy?: string;
33
+ }
34
+ /** A sporadic one-off payment (HVP-owned). */
35
+ export interface AdhocPaymentResponse {
36
+ id: string;
37
+ supplier: string;
38
+ concept: string;
39
+ amount: number;
40
+ dueDate?: string;
41
+ payDay?: number;
42
+ status: PaymentStatus;
43
+ paidAt?: string;
44
+ paidById?: string;
45
+ notes?: string;
46
+ createdAt: string;
47
+ updatedAt: string;
48
+ createdBy?: string;
49
+ updatedBy?: string;
50
+ }
51
+ /** A per-supplier discount rule (HVP-owned). */
52
+ export interface SupplierDiscountRuleResponse {
53
+ id: string;
54
+ supplier: string;
55
+ type: DiscountRuleType;
56
+ value: number;
57
+ appliesTo: DiscountAppliesTo;
58
+ isActive: boolean;
59
+ createdAt: string;
60
+ updatedAt: string;
61
+ createdBy?: string;
62
+ updatedBy?: string;
63
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Supplier Payments — response contracts
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Supplier Payments — shared types
3
+ *
4
+ * The unified line item and per-supplier summary the "próximos pagos" view is built on.
5
+ */
6
+ import { PaymentStatus, PaymentType } from "../../constants/supplier-payments.enums";
7
+ /**
8
+ * A single payment obligation, unified across sources (QVET credit / recurring / ad-hoc).
9
+ *
10
+ * Amounts are already net of nothing here — the discount is applied at the summary level
11
+ * (over the supplier's period total), see `SupplierPaymentSummary`.
12
+ */
13
+ export interface SupplierPaymentItem {
14
+ /** Stable id. For QVET credit this is derived from the invoice; for others it's the record id. */
15
+ id: string;
16
+ type: PaymentType;
17
+ supplier: string;
18
+ /** Free-text concept (e.g. "Renta Petco", "IMSS junio"). Optional for QVET invoices. */
19
+ concept?: string;
20
+ amount: number;
21
+ /** ISO date the payment is due (QVET dueDate, or recurring/ad-hoc target). */
22
+ dueDate?: string;
23
+ /** Target day of month to pay (default 1; Petco 16). */
24
+ payDay?: number;
25
+ status: PaymentStatus;
26
+ /** ISO timestamp when it was marked paid. */
27
+ paidAt?: string;
28
+ /** Collaborator id who marked it paid. */
29
+ paidById?: string;
30
+ paymentMethod?: string;
31
+ /** True when the status came from the automatic premarca (QVET), not a user action. */
32
+ isPremarked?: boolean;
33
+ /** QVET credit: the invoice this payment settles (grouped by qvetInvoiceId). */
34
+ qvetInvoiceId?: number;
35
+ invoiceNumber?: string;
36
+ ownNumber?: string;
37
+ /** Recurring: the recurring-payment config id. */
38
+ recurringPaymentId?: string;
39
+ /** Ad-hoc: the ad-hoc payment id. */
40
+ adhocPaymentId?: string;
41
+ notes?: string;
42
+ }
43
+ /**
44
+ * Per-supplier rollup: "cuánto pagar a este proveedor" for the period.
45
+ *
46
+ * `netTotal` is what to actually pay: `grossTotal - discountTotal`.
47
+ */
48
+ export interface SupplierPaymentSummary {
49
+ supplier: string;
50
+ itemCount: number;
51
+ grossTotal: number;
52
+ /** Discount applied over the period total (e.g. Telvet 5%); 0 when no rule. */
53
+ discountTotal: number;
54
+ /** grossTotal - discountTotal — the amount to pay. */
55
+ netTotal: number;
56
+ pendingTotal: number;
57
+ paidTotal: number;
58
+ /** Present when the caller requests item-level detail. */
59
+ items?: SupplierPaymentItem[];
60
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Supplier Payments — shared types
4
+ *
5
+ * The unified line item and per-supplier summary the "próximos pagos" view is built on.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvp-shared",
3
- "version": "14.5.0",
3
+ "version": "14.6.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",