feat: Add company certificate upload API and fields, and remove purchase order and delivery date from invoice mapping.

This commit is contained in:
Galindo97
2026-02-18 11:08:57 -06:00
parent f19f051e59
commit c29dd299bc
2 changed files with 64 additions and 8 deletions

View File

@@ -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<ApiResponse<void>> {
export async function uploadCompanyLogo(id: number, file: File): Promise<ApiResponse<{ message: string; logo_path: string; company_id: number }>> {
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<ApiResp
body: formData,
credentials: 'include'
});
const data = await response.json();
if (!response.ok) {
return {
error: data.detail || data.message || 'Error al subir el logo',
status: response.status
};
}
return {
data,
status: response.status
};
}
export async function uploadCompanyCertificate(id: number, type: string, file: File, password?: string): Promise<ApiResponse<{ message: string; file_path: string }>> {
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

View File

@@ -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,
};
}