feat: add partidas tab form component with CRUD functionality

- Implemented the partidas tab form in Svelte for managing partidas.
- Added functionality to create, edit, delete, and list partidas.
- Integrated a dialog for adding and editing partidas with validation.
- Included a checkbox component for selecting partidas.
- Added total calculations for partidas in the UI.
- Enhanced UI with buttons for various actions and a responsive table layout.
This commit is contained in:
Galindo97
2025-12-24 09:10:10 -06:00
parent 6a06f19b1c
commit 7585cedd3e
16 changed files with 6971 additions and 290 deletions

View File

@@ -24,16 +24,20 @@ export interface ExchangeRateListResponse {
/**
* Get exchange rate by date
*/
export async function getExchangeRateByDate(date: string): Promise<ExchangeRate | null> {
export async function getExchangeRateByDate(date: string, companyId: number): Promise<ExchangeRate | null> {
try {
// Convert date to ISO format with time for backend datetime field
const dateWithTime = `${date}T00:00:00`;
const response = await api.get<ExchangeRateListResponse>(`/v1/a76/exchange-rate?date=${dateWithTime}`);
// Get all exchange rates and filter by date on client side
const response = await api.get<ExchangeRateListResponse>(`/v1/a76/exchange-rate/?company_id=${companyId}`);
if (response.data && response.data.items && response.data.items.length > 0) {
// Find USD exchange rate
const usdRate = response.data.items.find(rate => rate.foreign_currency === 'USD');
return usdRate || null;
// Filter by date and find USD exchange rate
const dateOnly = date.split('T')[0]; // Get YYYY-MM-DD part
const matchingRates = response.data.items.filter(rate => {
const rateDate = rate.date.split('T')[0];
return rateDate === dateOnly && rate.foreign_currency === 'USD';
});
return matchingRates.length > 0 ? matchingRates[0] : null;
}
return null;

View File

@@ -50,6 +50,41 @@ export interface PedimentoValidation {
responsible_id?: number | null;
}
export interface PedimentoIncrementables {
insured_value?: number | null;
packaging?: number | null;
freight?: number | null;
deductibles?: number | null;
currency?: string | null;
not_affect_usd_value?: number | null;
not_affect_customs_value?: number | null;
}
export interface PedimentoDecrementables {
freight?: number | null;
insurance?: number | null;
loading?: number | null;
unloading?: number | null;
others?: number | null;
currency?: string | null;
not_affect_usd_value?: number | null;
}
export interface PedimentoIndexes {
update_factor_type?: number | null;
update_factor?: number | null;
manual_update_factor?: number | 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;
}
export interface Pedimento {
id: number;
tenant_id: number;
@@ -67,12 +102,17 @@ export interface Pedimento {
paid_price?: number | null;
gross_weight?: number | null;
exchange_rate?: number | null;
observaciones?: string | null;
created_at: string;
// Sub-resources
pedimento_dates?: PedimentoDates | null;
pedimento_payments?: PedimentoPayments | null;
pedimento_transport_means?: PedimentoTransportMeans | null;
pedimento_validation?: PedimentoValidation | null;
pedimento_validation?: PedimentoValidation | null;
pedimento_incrementables?: PedimentoIncrementables | null;
pedimento_decrementables?: PedimentoDecrementables | null;
pedimento_indexes?: PedimentoIndexes | null;
pedimento_config_additional?: PedimentoConfigAdditional | null;
}
export interface PedimentoListResponse {
@@ -97,11 +137,16 @@ export interface CreatePedimentoData {
paid_price?: number | null;
gross_weight?: number | null;
exchange_rate?: number | null;
observaciones?: string | null;
// Sub-resources
pedimento_dates?: PedimentoDates | null;
pedimento_payments?: PedimentoPayments | null;
pedimento_transport_means?: PedimentoTransportMeans | null;
pedimento_validation?: PedimentoValidation | null;
pedimento_incrementables?: PedimentoIncrementables | null;
pedimento_decrementables?: PedimentoDecrementables | null;
pedimento_indexes?: PedimentoIndexes | null;
pedimento_config_additional?: PedimentoConfigAdditional | null;
}
export interface UpdatePedimentoData {
@@ -119,11 +164,16 @@ export interface UpdatePedimentoData {
paid_price?: number | null;
gross_weight?: number | null;
exchange_rate?: number | null;
observaciones?: string | null;
// Sub-resources
pedimento_dates?: PedimentoDates | null;
pedimento_payments?: PedimentoPayments | null;
pedimento_transport_means?: PedimentoTransportMeans | null;
pedimento_validation?: PedimentoValidation | null;
pedimento_incrementables?: PedimentoIncrementables | null;
pedimento_decrementables?: PedimentoDecrementables | null;
pedimento_indexes?: PedimentoIndexes | null;
pedimento_config_additional?: PedimentoConfigAdditional | null;
}
export interface PedimentoFilters {