pedimentos UI

This commit is contained in:
Galindo97
2025-12-23 14:15:05 -06:00
parent d3a0086188
commit 150efdfd99
61 changed files with 1033 additions and 256 deletions

View File

@@ -26,23 +26,32 @@ export interface ExchangeRateListResponse {
*/
export async function getExchangeRateByDate(date: string, companyId: number): Promise<ExchangeRate | null> {
try {
console.log('📡 [API] Solicitando tipos de cambio para company_id:', companyId);
// Get all exchange rates and filter by date on client side
const response = await api.get<ExchangeRateListResponse>(`/v1/a76/exchange-rate/?company_id=${companyId}`);
console.log('📡 [API] Respuesta recibida:', response.data?.total, 'tipos de cambio');
if (response.data && response.data.items && response.data.items.length > 0) {
// Filter by date and find USD exchange rate
const dateOnly = date.split('T')[0]; // Get YYYY-MM-DD part
console.log('🔍 [API] Buscando fecha:', dateOnly, 'en', response.data.items.length, 'registros');
const matchingRates = response.data.items.filter(rate => {
const rateDate = rate.date.split('T')[0];
return rateDate === dateOnly && rate.foreign_currency === 'USD';
const matches = rateDate === dateOnly && rate.foreign_currency === 'USD';
console.log(' - Comparando:', rateDate, '===', dateOnly, '&& USD ===', rate.foreign_currency, '→', matches);
return matches;
});
console.log('✅ [API] Encontrados', matchingRates.length, 'tipos de cambio que coinciden');
return matchingRates.length > 0 ? matchingRates[0] : null;
}
console.log('⚠️ [API] No hay datos en la respuesta');
return null;
} catch (error) {
console.error('Error fetching exchange rate:', error);
console.error('❌ [API] Error fetching exchange rate:', error);
return null;
}
}

View File

@@ -85,6 +85,69 @@ export interface PedimentoConfigAdditional {
add_remove_norms?: number | null;
}
export interface PedimentoConfigCalculations {
dta_type?: string | null;
dta_operation?: number | null;
dta_vehicle_count?: number | null;
dta_mixed_rate_8permil?: number | null;
pays_vat?: number | null;
pays_prevalidation?: number | null;
include_sagar_certificate_fee?: number | null;
fixed_vehicle_dta_fee?: number | null;
additional_fixed_fee?: number | null;
additional_fixed_fee_payment_method?: number | null;
}
export interface PedimentoConfigSurcharges {
surcharge_igi?: number | null;
surcharge_dta?: number | null;
surcharge_vat?: number | null;
surcharge_isan?: number | null;
surcharge_ieps?: number | null;
surcharge_cc?: number | null;
}
export interface PedimentoConfigParameters {
is_embassy?: number | null;
embassy_dta?: string | null;
rule_3121_section_ii?: number | null;
use_previous_tariff?: number | null;
use_payment_date_fi?: number | null;
add_state_supplier_record_505?: number | null;
customs_value_calculation?: number | null;
two_decimals_unit_value?: number | null;
customs_value_per_item?: number | null;
is_national_supplier?: number | null;
is_consolidated?: number | null;
}
export interface PedimentoConfigUpdates {
update_vat?: number | null;
update_advalorem?: number | null;
update_dta?: number | null;
update_cc?: number | null;
update_ieps?: number | null;
}
export interface PedimentoConfigUpdateRectification {
update_vat?: number | null;
update_advalorem?: number | null;
update_cc?: number | null;
update_ieps?: number | null;
calculate_surcharge?: number | null;
}
export interface Identificador {
id?: number;
pedimento_id?: number;
caso: string;
complemento1: string;
complemento2: string;
complemento3: string;
nodo: string;
observaciones: string;
}
export interface Pedimento {
id: number;
tenant_id: number;
@@ -102,7 +165,7 @@ export interface Pedimento {
paid_price?: number | null;
gross_weight?: number | null;
exchange_rate?: number | null;
observaciones?: string | null;
observations?: string | null;
created_at: string;
// Sub-resources
pedimento_dates?: PedimentoDates | null;
@@ -113,6 +176,12 @@ export interface Pedimento {
pedimento_decrementables?: PedimentoDecrementables | null;
pedimento_indexes?: PedimentoIndexes | null;
pedimento_config_additional?: PedimentoConfigAdditional | null;
pedimento_config_calculations?: PedimentoConfigCalculations | null;
pedimento_config_surcharges?: PedimentoConfigSurcharges | null;
pedimento_config_parameters?: PedimentoConfigParameters | null;
pedimento_config_updates?: PedimentoConfigUpdates | null;
pedimento_config_update_rectification?: PedimentoConfigUpdateRectification | null;
identificadores?: Identificador[] | null;
}
export interface PedimentoListResponse {
@@ -137,7 +206,7 @@ export interface CreatePedimentoData {
paid_price?: number | null;
gross_weight?: number | null;
exchange_rate?: number | null;
observaciones?: string | null;
observations?: string | null;
// Sub-resources
pedimento_dates?: PedimentoDates | null;
pedimento_payments?: PedimentoPayments | null;
@@ -147,6 +216,12 @@ export interface CreatePedimentoData {
pedimento_decrementables?: PedimentoDecrementables | null;
pedimento_indexes?: PedimentoIndexes | null;
pedimento_config_additional?: PedimentoConfigAdditional | null;
pedimento_config_calculations?: PedimentoConfigCalculations | null;
pedimento_config_surcharges?: PedimentoConfigSurcharges | null;
pedimento_config_parameters?: PedimentoConfigParameters | null;
pedimento_config_updates?: PedimentoConfigUpdates | null;
pedimento_config_update_rectification?: PedimentoConfigUpdateRectification | null;
identificadores?: Identificador[] | null;
}
export interface UpdatePedimentoData {
@@ -164,7 +239,7 @@ export interface UpdatePedimentoData {
paid_price?: number | null;
gross_weight?: number | null;
exchange_rate?: number | null;
observaciones?: string | null;
observations?: string | null;
// Sub-resources
pedimento_dates?: PedimentoDates | null;
pedimento_payments?: PedimentoPayments | null;
@@ -174,6 +249,12 @@ export interface UpdatePedimentoData {
pedimento_decrementables?: PedimentoDecrementables | null;
pedimento_indexes?: PedimentoIndexes | null;
pedimento_config_additional?: PedimentoConfigAdditional | null;
pedimento_config_calculations?: PedimentoConfigCalculations | null;
pedimento_config_surcharges?: PedimentoConfigSurcharges | null;
pedimento_config_parameters?: PedimentoConfigParameters | null;
pedimento_config_updates?: PedimentoConfigUpdates | null;
pedimento_config_update_rectification?: PedimentoConfigUpdateRectification | null;
identificadores?: Identificador[] | null;
}
export interface PedimentoFilters {