From c29dd299bc46bc044d67f214dc4f915f04f914cb Mon Sep 17 00:00:00 2001 From: Galindo97 Date: Wed, 18 Feb 2026 11:08:57 -0600 Subject: [PATCH] feat: Add company certificate upload API and fields, and remove purchase order and delivery date from invoice mapping. --- .../dashboard/a76/general_catalogs/company.ts | 68 +++++++++++++++++-- .../dashboard/invoices/edit/save-invoice.ts | 4 +- 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/frontend/src/lib/api/dashboard/a76/general_catalogs/company.ts b/frontend/src/lib/api/dashboard/a76/general_catalogs/company.ts index 16cd3b02..b0029ec5 100644 --- a/frontend/src/lib/api/dashboard/a76/general_catalogs/company.ts +++ b/frontend/src/lib/api/dashboard/a76/general_catalogs/company.ts @@ -104,7 +104,7 @@ export interface Company { responsible_last_name: string | null; responsible_mother_last_name: string | null; responsible_rfc?: string | null; - position?: string | null; + position?: string | null; has_express_line?: boolean; is_service_company?: boolean; order_format_type?: string | null; @@ -229,6 +229,27 @@ export interface Company { cfdi?: CompanyCFDI | null; created_at: string | null; updated_at: string | null; + // Flattened Certificate Fields + fiel_cer?: string | null; + fiel_key?: string | null; + fiel_pass?: string | null; + fiel_access?: string | null; + fiel_cer_exp?: number | null; + fiel_key_exp?: number | null; + + cfdi_cert_cer?: string | null; + cfdi_cert_key?: string | null; + cfdi_cert_pass?: string | null; + cfdi_cert_access?: string | null; + cfdi_cert_cer_exp?: number | null; + cfdi_cert_key_exp?: number | null; + + cancel_cer?: string | null; + cancel_key?: string | null; + cancel_pass?: string | null; + cancel_access?: string | null; + cancel_cer_exp?: number | null; + cancel_key_exp?: number | null; } export interface CompanyCreate { @@ -319,12 +340,12 @@ export async function deleteCompany(id: number): Promise> { export async function uploadCompanyLogo(id: number, file: File): Promise> { const formData = new FormData(); formData.append('file', file); - + // Para FormData, usamos fetch directamente ya que necesitamos omitir Content-Type // para que el navegador establezca el boundary automáticamente const token = localStorage.getItem('access_token'); const API_BASE_URL = (import.meta.env.VITE_API_URL || '').replace(/\/+$/, ''); - + const response = await fetch(`${API_BASE_URL}/v1/a76/company/${id}/upload-logo`, { method: 'POST', headers: { @@ -333,16 +354,51 @@ export async function uploadCompanyLogo(id: number, file: File): Promise> { + const formData = new FormData(); + formData.append('file', file); + formData.append('type', type); + if (password) { + formData.append('password', password); + } + + const token = localStorage.getItem('access_token'); + const API_BASE_URL = (import.meta.env.VITE_API_URL || '').replace(/\/+$/, ''); + + const response = await fetch(`${API_BASE_URL}/v1/a76/company/${id}/upload-certificate`, { + method: 'POST', + headers: { + 'Authorization': `Bearer ${token}`, + }, + body: formData, + credentials: 'include' + }); + + const data = await response.json(); + + if (!response.ok) { + return { + error: data.detail || data.message || 'Error al subir el certificado', + status: response.status + }; + } + return { data, status: response.status diff --git a/frontend/src/lib/components/dashboard/invoices/edit/save-invoice.ts b/frontend/src/lib/components/dashboard/invoices/edit/save-invoice.ts index 0460e0df..3df967a2 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/save-invoice.ts +++ b/frontend/src/lib/components/dashboard/invoices/edit/save-invoice.ts @@ -127,7 +127,7 @@ function buildInvoicePayload(formData: FormDataSet): CreateInvoiceData | UpdateI vu_observations: othersFormData?.observations_vu || undefined, comments_status: othersFormData?.comments_status || undefined, option_iv18: othersFormData?.option_iv18 || undefined, - purchase_order: continuationFormData?.purchase_order || undefined, + payment_terms: continuationFormData?.payment_terms || undefined, handling_fees: continuationFormData?.handling_fees || undefined, cfdi_uuid: continuationFormData?.cfdi_uuid || undefined, @@ -292,7 +292,7 @@ function buildLogisticsData(generalFormData: any, observationFormData: any, othe // Fechas Logísticas de OthersTabForm (se pasan en othersFormData) entry_exit_date: othersFormData?.entry_exit_date || null, payment_date: othersFormData?.payment_date || null, - delivery_date: othersFormData?.delivery_date || null, + vehicle_data: continuationFormData?.vehicle_data || null, }; }