From c5636189570ed426a6c4ff9c1512a4348c896804 Mon Sep 17 00:00:00 2001 From: Carlos Escalante Date: Fri, 3 Jul 2026 16:13:18 -0600 Subject: [PATCH] Tasa Cero: regenerate API types + installment-plan client helpers Co-Authored-By: Claude Opus 4.8 (1M context) --- frontend/src/lib/api-types.gen.ts | 346 ++++++++++++++++++++++++++++++ frontend/src/lib/api.ts | 29 +++ 2 files changed, 375 insertions(+) diff --git a/frontend/src/lib/api-types.gen.ts b/frontend/src/lib/api-types.gen.ts index 6e2495b..4cb9f40 100644 --- a/frontend/src/lib/api-types.gen.ts +++ b/frontend/src/lib/api-types.gen.ts @@ -396,6 +396,53 @@ export interface paths { patch?: never; trace?: never; }; + "/api/v1/installment-plans/": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** List Installment Plans */ + get: operations["list_installment_plans_api_v1_installment_plans__get"]; + put?: never; + /** + * Create Installment Plan + * @description Convert an existing credit-card purchase into a Tasa Cero plan. + */ + post: operations["create_installment_plan_api_v1_installment_plans__post"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/api/v1/installment-plans/{plan_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Get Installment Plan */ + get: operations["get_installment_plan_api_v1_installment_plans__plan_id__get"]; + put?: never; + post?: never; + /** + * Delete Installment Plan + * @description Unconvert: remove the plan and its cuotas; the anchor becomes a normal + * transaction again. + */ + delete: operations["delete_installment_plan_api_v1_installment_plans__plan_id__delete"]; + options?: never; + head?: never; + /** + * Update Installment Plan + * @description Edit a plan; cuota rows are regenerated (per-cuota edits are lost). + */ + patch: operations["update_installment_plan_api_v1_installment_plans__plan_id__patch"]; + trace?: never; + }; "/api/v1/municipal-receipts/": { parameters: { query?: never; @@ -1189,6 +1236,121 @@ export interface components { /** Detail */ detail?: components["schemas"]["ValidationError"][]; }; + /** InstallmentPlanCreate */ + InstallmentPlanCreate: { + /** First Installment Date */ + first_installment_date?: string | null; + /** + * Num Installments + * @default 3 + */ + num_installments: number; + /** Transaction Id */ + transaction_id: number; + }; + /** InstallmentPlanDetail */ + InstallmentPlanDetail: { + /** Anchor Transaction Id */ + anchor_transaction_id: number; + /** + * Cuotas + * @default [] + */ + cuotas: components["schemas"]["TransactionRead"][]; + /** Cuotas Billed */ + cuotas_billed: number; + /** Currency */ + currency: string; + /** + * First Installment Date + * Format: date-time + */ + first_installment_date: string; + /** Id */ + id: number; + /** Installment Amount */ + installment_amount: number; + /** Is Completed */ + is_completed: boolean; + /** Last Installment Amount */ + last_installment_amount: number; + /** Merchant */ + merchant: string; + /** Next Cuota Date */ + next_cuota_date?: string | null; + /** Notes */ + notes?: string | null; + /** Num Installments */ + num_installments: number; + /** Paid Amount */ + paid_amount: number; + /** + * Purchase Date + * Format: date-time + */ + purchase_date: string; + /** Remaining Amount */ + remaining_amount: number; + /** Total Amount */ + total_amount: number; + }; + /** InstallmentPlanListResponse */ + InstallmentPlanListResponse: { + /** Plans */ + plans: components["schemas"]["InstallmentPlanRead"][]; + /** Total Remaining */ + total_remaining: number; + }; + /** InstallmentPlanRead */ + InstallmentPlanRead: { + /** Anchor Transaction Id */ + anchor_transaction_id: number; + /** Cuotas Billed */ + cuotas_billed: number; + /** Currency */ + currency: string; + /** + * First Installment Date + * Format: date-time + */ + first_installment_date: string; + /** Id */ + id: number; + /** Installment Amount */ + installment_amount: number; + /** Is Completed */ + is_completed: boolean; + /** Last Installment Amount */ + last_installment_amount: number; + /** Merchant */ + merchant: string; + /** Next Cuota Date */ + next_cuota_date?: string | null; + /** Notes */ + notes?: string | null; + /** Num Installments */ + num_installments: number; + /** Paid Amount */ + paid_amount: number; + /** + * Purchase Date + * Format: date-time + */ + purchase_date: string; + /** Remaining Amount */ + remaining_amount: number; + /** Total Amount */ + total_amount: number; + }; + /** InstallmentPlanUpdate */ + InstallmentPlanUpdate: { + /** First Installment Date */ + first_installment_date?: string | null; + /** Notes */ + notes?: string | null; + /** Num Installments */ + num_installments?: number | null; + }; /** LoginRequest */ LoginRequest: { /** Password */ @@ -1857,6 +2019,13 @@ export interface components { deferred_to_next_cycle: boolean; /** Id */ id: number; + /** Installment Plan Id */ + installment_plan_id?: number | null; + /** + * Is Installment Anchor + * @default false + */ + is_installment_anchor: boolean; /** Merchant */ merchant: string; /** Notes */ @@ -2955,6 +3124,183 @@ export interface operations { }; }; }; + list_installment_plans_api_v1_installment_plans__get: { + parameters: { + query?: never; + header?: { + authorization?: string | null; + }; + path?: never; + cookie?: { + ws_token?: string | null; + }; + }; + requestBody?: never; + responses: { + /** @description Successful Response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["InstallmentPlanListResponse"]; + }; + }; + /** @description Validation Error */ + 422: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["HTTPValidationError"]; + }; + }; + }; + }; + create_installment_plan_api_v1_installment_plans__post: { + parameters: { + query?: never; + header?: { + authorization?: string | null; + }; + path?: never; + cookie?: { + ws_token?: string | null; + }; + }; + requestBody: { + content: { + "application/json": components["schemas"]["InstallmentPlanCreate"]; + }; + }; + responses: { + /** @description Successful Response */ + 201: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["InstallmentPlanRead"]; + }; + }; + /** @description Validation Error */ + 422: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["HTTPValidationError"]; + }; + }; + }; + }; + get_installment_plan_api_v1_installment_plans__plan_id__get: { + parameters: { + query?: never; + header?: { + authorization?: string | null; + }; + path: { + plan_id: number; + }; + cookie?: { + ws_token?: string | null; + }; + }; + requestBody?: never; + responses: { + /** @description Successful Response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["InstallmentPlanDetail"]; + }; + }; + /** @description Validation Error */ + 422: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["HTTPValidationError"]; + }; + }; + }; + }; + delete_installment_plan_api_v1_installment_plans__plan_id__delete: { + parameters: { + query?: never; + header?: { + authorization?: string | null; + }; + path: { + plan_id: number; + }; + cookie?: { + ws_token?: string | null; + }; + }; + requestBody?: never; + responses: { + /** @description Successful Response */ + 204: { + headers: { + [name: string]: unknown; + }; + content?: never; + }; + /** @description Validation Error */ + 422: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["HTTPValidationError"]; + }; + }; + }; + }; + update_installment_plan_api_v1_installment_plans__plan_id__patch: { + parameters: { + query?: never; + header?: { + authorization?: string | null; + }; + path: { + plan_id: number; + }; + cookie?: { + ws_token?: string | null; + }; + }; + requestBody: { + content: { + "application/json": components["schemas"]["InstallmentPlanUpdate"]; + }; + }; + responses: { + /** @description Successful Response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["InstallmentPlanRead"]; + }; + }; + /** @description Validation Error */ + 422: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["HTTPValidationError"]; + }; + }; + }; + }; list_receipts_api_v1_municipal_receipts__get: { parameters: { query?: never; diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index e4227f1..3a65a23 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -240,6 +240,35 @@ export const upsertBalanceOverride = ( export const deleteBalanceOverride = (year: number, month: number) => api.delete(`/budget/balance-override/${year}/${month}`); +// --- Installment Plans (Tasa Cero) --- + +export type InstallmentPlan = Schema<'InstallmentPlanRead'>; +export type InstallmentPlanDetail = Schema<'InstallmentPlanDetail'>; +export type InstallmentPlanListResponse = Schema<'InstallmentPlanListResponse'>; + +export interface InstallmentPlanCreate { + transaction_id: number; + num_installments?: number; + first_installment_date?: string | null; +} + +export interface InstallmentPlanUpdate { + num_installments?: number; + first_installment_date?: string | null; + notes?: string | null; +} + +export const getInstallmentPlans = () => + api.get("/installment-plans/"); +export const getInstallmentPlanDetail = (id: number) => + api.get(`/installment-plans/${id}`); +export const createInstallmentPlan = (data: InstallmentPlanCreate) => + api.post("/installment-plans/", data); +export const updateInstallmentPlan = (id: number, data: InstallmentPlanUpdate) => + api.patch(`/installment-plans/${id}`, data); +export const deleteInstallmentPlan = (id: number) => + api.delete(`/installment-plans/${id}`); + // --- Salarios --- export type SalariosSummary = Schema<'SalariosSummary'>;