Se modifico Pedimento detail se empezaron a agregar elementos del auditor y detalle completo del pedimento
This commit is contained in:
97
src/api/coves.js
Normal file
97
src/api/coves.js
Normal file
@@ -0,0 +1,97 @@
|
||||
import { fetchWithAuth } from '../fetchWithAuth';
|
||||
|
||||
const API_BASE_URL = process.env.NODE_ENV === 'production'
|
||||
? 'https://your-production-api.com/api/v1'
|
||||
: 'http://192.168.1.79:8000/api/v1';
|
||||
|
||||
export const fetchPedimentoCoves = async (pedimentoId, page = 1, pageSize = 10, filters = {}) => {
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
pedimento: pedimentoId,
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
});
|
||||
|
||||
// Agregar filtros si existen
|
||||
if (filters.numero_cove) {
|
||||
params.append('numero_cove__icontains', filters.numero_cove);
|
||||
}
|
||||
if (filters.cove_descargado !== undefined && filters.cove_descargado !== '') {
|
||||
params.append('cove_descargado', filters.cove_descargado);
|
||||
}
|
||||
if (filters.acuse_cove_descargado !== undefined && filters.acuse_cove_descargado !== '') {
|
||||
params.append('acuse_cove_descargado', filters.acuse_cove_descargado);
|
||||
}
|
||||
if (filters.date_from) {
|
||||
params.append('created_at__gte', filters.date_from);
|
||||
}
|
||||
if (filters.date_to) {
|
||||
params.append('created_at__lte', filters.date_to);
|
||||
}
|
||||
|
||||
const response = await fetchWithAuth(`${API_BASE_URL}/customs/coves/?${params}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return {
|
||||
results: data.results,
|
||||
count: data.count,
|
||||
next: data.next,
|
||||
previous: data.previous
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error fetching COVEs:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const downloadCove = async (coveId) => {
|
||||
try {
|
||||
const response = await fetchWithAuth(`${API_BASE_URL}/customs/coves/${coveId}/download/`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.style.display = 'none';
|
||||
a.href = url;
|
||||
a.download = `COVE_${coveId}.pdf`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
} catch (error) {
|
||||
console.error('Error downloading COVE:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const downloadAcuseCove = async (coveId) => {
|
||||
try {
|
||||
const response = await fetchWithAuth(`${API_BASE_URL}/customs/coves/${coveId}/download-acuse/`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.style.display = 'none';
|
||||
a.href = url;
|
||||
a.download = `ACUSE_COVE_${coveId}.pdf`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
} catch (error) {
|
||||
console.error('Error downloading COVE acuse:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
103
src/api/edocuments.js
Normal file
103
src/api/edocuments.js
Normal file
@@ -0,0 +1,103 @@
|
||||
import { fetchWithAuth } from '../fetchWithAuth';
|
||||
|
||||
const API_BASE_URL = process.env.NODE_ENV === 'production'
|
||||
? 'https://your-production-api.com/api/v1'
|
||||
: 'http://192.168.1.79:8000/api/v1';
|
||||
|
||||
export const fetchPedimentoEdocuments = async (pedimentoId, page = 1, pageSize = 10, filters = {}) => {
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
pedimento: pedimentoId,
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
});
|
||||
|
||||
// Agregar filtros si existen
|
||||
if (filters.numero_edocument) {
|
||||
params.append('numero_edocument__icontains', filters.numero_edocument);
|
||||
}
|
||||
if (filters.clave) {
|
||||
params.append('clave__icontains', filters.clave);
|
||||
}
|
||||
if (filters.descripcion) {
|
||||
params.append('descripcion__icontains', filters.descripcion);
|
||||
}
|
||||
if (filters.edocument_descargado !== undefined && filters.edocument_descargado !== '') {
|
||||
params.append('edocument_descargado', filters.edocument_descargado);
|
||||
}
|
||||
if (filters.acuse_descargado !== undefined && filters.acuse_descargado !== '') {
|
||||
params.append('acuse_descargado', filters.acuse_descargado);
|
||||
}
|
||||
if (filters.date_from) {
|
||||
params.append('created_at__gte', filters.date_from);
|
||||
}
|
||||
if (filters.date_to) {
|
||||
params.append('created_at__lte', filters.date_to);
|
||||
}
|
||||
|
||||
const response = await fetchWithAuth(`${API_BASE_URL}/customs/edocuments/?${params}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return {
|
||||
results: data.results,
|
||||
count: data.count,
|
||||
next: data.next,
|
||||
previous: data.previous
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error fetching EDocs:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const downloadEdocument = async (edocId) => {
|
||||
try {
|
||||
const response = await fetchWithAuth(`${API_BASE_URL}/customs/edocuments/${edocId}/download/`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.style.display = 'none';
|
||||
a.href = url;
|
||||
a.download = `EDOC_${edocId}.pdf`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
} catch (error) {
|
||||
console.error('Error downloading EDocs:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const downloadAcuseEdocument = async (edocId) => {
|
||||
try {
|
||||
const response = await fetchWithAuth(`${API_BASE_URL}/customs/edocuments/${edocId}/download-acuse/`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.style.display = 'none';
|
||||
a.href = url;
|
||||
a.download = `ACUSE_EDOC_${edocId}.pdf`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
} catch (error) {
|
||||
console.error('Error downloading EDocs acuse:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -5,10 +5,12 @@ export interface PedimentoDocument {
|
||||
id: string;
|
||||
organizacion: string;
|
||||
pedimento: string;
|
||||
pedimento_numero: string;
|
||||
archivo: string;
|
||||
document_type: number;
|
||||
size: number;
|
||||
extension: string;
|
||||
fuente: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
@@ -20,17 +22,38 @@ export interface PedimentoDocumentsResponse {
|
||||
results: PedimentoDocument[];
|
||||
}
|
||||
|
||||
export interface DocumentFilters {
|
||||
document_type?: string;
|
||||
archivo__icontains?: string;
|
||||
extension?: string;
|
||||
created_at__date?: string;
|
||||
ordering?: string;
|
||||
}
|
||||
|
||||
const API_URL = (import.meta as any).env.VITE_EFC_API_URL;
|
||||
|
||||
export async function fetchPedimentoDocuments(
|
||||
pedimentoId: string,
|
||||
page: number = 1,
|
||||
pageSize: number = 10
|
||||
pageSize: number = 10,
|
||||
filters: DocumentFilters = {}
|
||||
): Promise<PedimentoDocumentsResponse> {
|
||||
try {
|
||||
const res = await fetchWithAuth(
|
||||
`${API_URL}/record/documents/?page=${page}&page_size=${pageSize}&pedimento=${pedimentoId}`
|
||||
);
|
||||
// Construir URL con filtros
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
pedimento: pedimentoId
|
||||
});
|
||||
|
||||
// Agregar filtros si existen
|
||||
Object.entries(filters).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== '') {
|
||||
params.append(key, value.toString());
|
||||
}
|
||||
});
|
||||
|
||||
const res = await fetchWithAuth(`${API_URL}/record/documents/?${params.toString()}`);
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error('No autorizado o error en la petición');
|
||||
|
||||
109
src/api/procesos.js
Normal file
109
src/api/procesos.js
Normal file
@@ -0,0 +1,109 @@
|
||||
import { fetchWithAuth } from '../fetchWithAuth';
|
||||
|
||||
const API_BASE_URL = process.env.NODE_ENV === 'production'
|
||||
? 'https://your-production-api.com/api/v1'
|
||||
: 'http://192.168.1.79:8000/api/v1';
|
||||
|
||||
export const fetchPedimentoProcesos = async (pedimentoId, page = 1, pageSize = 10, filters = {}) => {
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
pedimento: pedimentoId,
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
});
|
||||
|
||||
// Agregar filtros si existen
|
||||
if (filters.estado !== undefined && filters.estado !== '') {
|
||||
params.append('estado', filters.estado);
|
||||
}
|
||||
if (filters.servicio !== undefined && filters.servicio !== '') {
|
||||
params.append('servicio', filters.servicio);
|
||||
}
|
||||
if (filters.organizacion_name) {
|
||||
params.append('organizacion_name__icontains', filters.organizacion_name);
|
||||
}
|
||||
if (filters.date_from) {
|
||||
params.append('created_at__gte', filters.date_from);
|
||||
}
|
||||
if (filters.date_to) {
|
||||
params.append('created_at__lte', filters.date_to);
|
||||
}
|
||||
if (filters.updated_from) {
|
||||
params.append('updated_at__gte', filters.updated_from);
|
||||
}
|
||||
if (filters.updated_to) {
|
||||
params.append('updated_at__lte', filters.updated_to);
|
||||
}
|
||||
|
||||
const response = await fetchWithAuth(`${API_BASE_URL}/customs/procesamientopedimentos/?${params}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return {
|
||||
results: data.results,
|
||||
count: data.count,
|
||||
next: data.next,
|
||||
previous: data.previous
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error fetching Procesos:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
// Mapeo de estados
|
||||
export const getEstadoLabel = (estado) => {
|
||||
const estados = {
|
||||
1: 'Pendiente',
|
||||
2: 'En Proceso',
|
||||
3: 'Completado',
|
||||
4: 'Error',
|
||||
5: 'Cancelado'
|
||||
};
|
||||
return estados[estado] || `Estado ${estado}`;
|
||||
};
|
||||
|
||||
export const getEstadoColor = (estado) => {
|
||||
const colores = {
|
||||
1: 'bg-yellow-100 text-yellow-800',
|
||||
2: 'bg-blue-100 text-blue-800',
|
||||
3: 'bg-green-100 text-green-800',
|
||||
4: 'bg-red-100 text-red-800',
|
||||
5: 'bg-gray-100 text-gray-800'
|
||||
};
|
||||
return colores[estado] || 'bg-gray-100 text-gray-800';
|
||||
};
|
||||
|
||||
// Mapeo de servicios
|
||||
export const getServicioLabel = (servicio) => {
|
||||
const servicios = {
|
||||
1: 'Digitalización',
|
||||
2: 'Validación',
|
||||
3: 'Procesamiento SAT',
|
||||
4: 'Generación COVEs',
|
||||
5: 'Generación EDocs',
|
||||
6: 'Envío VUCEM',
|
||||
7: 'Clasificación',
|
||||
8: 'Archivo Digital',
|
||||
9: 'Notificaciones'
|
||||
};
|
||||
return servicios[servicio] || `Servicio ${servicio}`;
|
||||
};
|
||||
|
||||
export const getServicioColor = (servicio) => {
|
||||
const colores = {
|
||||
1: 'bg-purple-100 text-purple-800',
|
||||
2: 'bg-indigo-100 text-indigo-800',
|
||||
3: 'bg-blue-100 text-blue-800',
|
||||
4: 'bg-cyan-100 text-cyan-800',
|
||||
5: 'bg-teal-100 text-teal-800',
|
||||
6: 'bg-green-100 text-green-800',
|
||||
7: 'bg-yellow-100 text-yellow-800',
|
||||
8: 'bg-orange-100 text-orange-800',
|
||||
9: 'bg-pink-100 text-pink-800'
|
||||
};
|
||||
return colores[servicio] || 'bg-gray-100 text-gray-800';
|
||||
};
|
||||
Reference in New Issue
Block a user