Merge pull request 'pedimentos' (#36) from pedimentos into development

Reviewed-on: ADUANASOFT/anexo76#36
This commit is contained in:
2025-12-31 14:24:57 +00:00
58 changed files with 941 additions and 362 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

@@ -56,8 +56,8 @@ export interface PedimentoIncrementables {
freight?: number | null;
deductibles?: number | null;
currency?: string | null;
not_affect_usd_value?: number | null;
not_affect_customs_value?: number | null;
not_affect_usd_value?: boolean | null;
not_affect_customs_value?: boolean | null;
}
export interface PedimentoDecrementables {
@@ -67,22 +67,86 @@ export interface PedimentoDecrementables {
unloading?: number | null;
others?: number | null;
currency?: string | null;
not_affect_usd_value?: number | null;
not_affect_usd_value?: boolean | null;
}
export interface PedimentoIndexes {
update_factor_type?: number | null;
update_factor?: number | null;
manual_update_factor?: number | null;
manual_update_factor?: boolean | null;
}
export interface PedimentoConfigAdditional {
manual_pedimento_year?: string | null;
add_po_identifier?: number | null;
do_not_exempt_norms_complement_x?: number | null;
enable_import_invoice_recipient?: number | null;
send_502_validation_file_for_consolidated?: number | null;
add_remove_norms?: number | null;
add_po_identifier?: boolean | null;
do_not_exempt_norms_complement_x?: boolean | null;
enable_import_invoice_recipient?: boolean | null;
send_502_validation_file_for_consolidated?: boolean | null;
add_remove_norms?: boolean | null;
}
export interface PedimentoConfigCalculations {
dta_type?: string | null;
dta_operation?: boolean | null;
dta_vehicle_count?: boolean | null;
dta_mixed_rate_8permil?: boolean | null;
pays_vat?: boolean | null;
pays_prevalidation?: boolean | null;
include_sagar_certificate_fee?: boolean | null;
fixed_vehicle_dta_fee?: boolean | null;
additional_fixed_fee?: number | null;
additional_fixed_fee_payment_method?: number | null;
}
export interface PedimentoConfigSurcharges {
surcharge_igi?: boolean | null;
surcharge_dta?: boolean | null;
surcharge_vat?: boolean | null;
surcharge_isan?: boolean | null;
surcharge_ieps?: boolean | null;
surcharge_cc?: boolean | null;
}
export interface PedimentoConfigParameters {
is_embassy?: boolean | null;
embassy_dta?: string | null;
rule_3121_section_ii?: boolean | null;
use_previous_tariff?: boolean | null;
use_payment_date_fi?: boolean | null;
add_state_supplier_record_505?: boolean | null;
customs_value_calculation?: boolean | null;
two_decimals_unit_value?: boolean | null;
customs_value_per_item?: boolean | null;
is_national_supplier?: boolean | null;
is_consolidated?: boolean | null;
}
export interface PedimentoConfigUpdates {
update_vat?: boolean | null;
update_advalorem?: boolean | null;
update_dta?: boolean | null;
update_cc?: boolean | null;
update_ieps?: boolean | null;
}
export interface PedimentoConfigUpdateRectification {
update_vat?: boolean | null;
update_advalorem?: boolean | null;
update_dta?: boolean | null;
update_cc?: boolean | null;
update_ieps?: boolean | null;
calculate_surcharge?: boolean | null;
}
export interface Identificador {
id?: number;
pedimento_id?: number;
caso: string;
complemento1: string;
complemento2: string;
complemento3: string;
nodo: string;
observaciones: string;
}
export interface Pedimento {
@@ -102,7 +166,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 +177,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 +207,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 +217,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 +240,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 +250,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 {