Refactor code structure for improved readability and maintainability
This commit is contained in:
184
frontend/src/lib/api/dashboard/a76/invoice-movements.ts
Normal file
184
frontend/src/lib/api/dashboard/a76/invoice-movements.ts
Normal file
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* API Client para Reportes de Movimientos de Facturas
|
||||
*/
|
||||
import { api } from '$lib/api';
|
||||
|
||||
// ===== TYPES =====
|
||||
|
||||
export type RangeType = 'FF' | 'FP'; // FF = fecha factura, FP = fecha pago
|
||||
export type ReportType = 'Normal' | 'Detallado';
|
||||
export type CurrencyType = 'ME' | 'MN'; // ME = moneda extranjera, MN = moneda nacional
|
||||
export type ExchangeRateType = 'FP' | 'FF';
|
||||
export type MovementTypeFilter = 'COMEX' | 'IMPDF' | 'ALL';
|
||||
export type DischargeFilter = 'SiDes' | 'NoDes' | 'ALL';
|
||||
export type ExportMovementType = 'AFIJO' | 'NODES' | 'SCRAP' | 'REEXP' | 'DONAC' | 'VEMEX' | 'ALL';
|
||||
|
||||
export interface BaseFilter {
|
||||
range_type: RangeType;
|
||||
start_date: string; // YYYYMMDD format
|
||||
end_date: string; // YYYYMMDD format
|
||||
include_cancelled: boolean;
|
||||
provider?: string | null;
|
||||
buyer?: string | null;
|
||||
pedimento_code?: string | null;
|
||||
report_type: ReportType;
|
||||
currency_type: CurrencyType;
|
||||
exchange_rate_type: ExchangeRateType;
|
||||
is_shelter: boolean;
|
||||
database_name: string;
|
||||
}
|
||||
|
||||
export interface ImportTemporaryFilter extends BaseFilter {}
|
||||
|
||||
export interface ImportDefinitiveFilter extends BaseFilter {
|
||||
movement_type: MovementTypeFilter;
|
||||
}
|
||||
|
||||
export interface ImportRepairFilter extends BaseFilter {
|
||||
discharge_filter: DischargeFilter;
|
||||
}
|
||||
|
||||
export interface ExportFilter extends BaseFilter {
|
||||
movement_type: ExportMovementType;
|
||||
discharge_filter: DischargeFilter;
|
||||
use_transport_method: boolean;
|
||||
}
|
||||
|
||||
export interface ExportRepairFilter extends Omit<BaseFilter, 'use_transport_method'> {
|
||||
movement_type: ExportMovementType;
|
||||
discharge_filter: DischargeFilter;
|
||||
}
|
||||
|
||||
export interface AllMovementsFilter {
|
||||
range_type: RangeType;
|
||||
start_date: string; // YYYYMMDD format
|
||||
end_date: string; // YYYYMMDD format
|
||||
include_cancelled: boolean;
|
||||
provider?: string | null;
|
||||
buyer?: string | null;
|
||||
pedimento_code?: string | null;
|
||||
currency_type: CurrencyType;
|
||||
exchange_rate_type: ExchangeRateType;
|
||||
is_shelter: boolean;
|
||||
operation_type?: 'imp' | 'exp' | null;
|
||||
}
|
||||
|
||||
export interface MovementItem {
|
||||
Factura: string;
|
||||
Pedimento: string;
|
||||
FechaFactura: string | null;
|
||||
Estatus: string;
|
||||
ClavePed: string;
|
||||
TipoMovTemDef: string;
|
||||
EsCambioRegimen: string;
|
||||
ValorMPTemp: number;
|
||||
ValorComercialMN: number;
|
||||
TipoCambio: number;
|
||||
ValorAgre: number;
|
||||
TipoExpo: string;
|
||||
PedimentoR1: string | null;
|
||||
EDocument: string | null;
|
||||
NumOperacionVU: string | null;
|
||||
BaseDeDatos: string;
|
||||
NumGafUni: string | null;
|
||||
UsuarioCap: string | null;
|
||||
UsuarioAcr: string | null;
|
||||
Fecha_Pago: string | null;
|
||||
NumCaja: string | null;
|
||||
Pedimento18: string | null;
|
||||
AduanaCru: string | null;
|
||||
Lote: string | null;
|
||||
}
|
||||
|
||||
export interface MovementItemDetailed extends MovementItem {
|
||||
Linea: number;
|
||||
Regimen: string | null;
|
||||
Fecha_Inicio: string | null;
|
||||
Fecha_Fin: string | null;
|
||||
Remesa: string | null;
|
||||
Proveedor: string | null;
|
||||
RFCProveedor: string | null;
|
||||
ProveedorTaxID: string | null;
|
||||
VendidoA: string | null;
|
||||
VendidoARFC: string | null;
|
||||
VendidoATaxID: string | null;
|
||||
AgenteAduanal: string | null;
|
||||
Patente: string | null;
|
||||
NumParte: string | null;
|
||||
DescripcionE: string | null;
|
||||
DescripcionI: string | null;
|
||||
CantidadIE: number;
|
||||
UniMed: string | null;
|
||||
PesoNeto: number;
|
||||
PesoBruto: number;
|
||||
OrdenCompraVenta: string | null;
|
||||
FraccionArancelaria: string | null;
|
||||
Preferencia: string | null;
|
||||
Sector: string | null;
|
||||
PaisOrigen: string | null;
|
||||
Aduana: string | null;
|
||||
Advalorem: string | null;
|
||||
Series: string | null;
|
||||
Marca: string | null;
|
||||
Modelo: string | null;
|
||||
FraccionAmericana: string | null;
|
||||
ECCN: string | null;
|
||||
SimboloEx: string | null;
|
||||
FechaEmision: string | null;
|
||||
Transportista: string | null;
|
||||
}
|
||||
|
||||
// ===== API METHODS =====
|
||||
|
||||
export const invoiceMovementsApi = {
|
||||
// Temporary Imports
|
||||
getTemporaryImports: (filters: ImportTemporaryFilter) =>
|
||||
api.post<MovementItem[]>('/v1/a76/reports/movements/invoices/temporary', filters),
|
||||
|
||||
getTemporaryImportsDetailed: (filters: ImportTemporaryFilter) =>
|
||||
api.post<MovementItemDetailed[]>(
|
||||
'/v1/a76/reports/movements/invoices/temporary-detailed',
|
||||
filters
|
||||
),
|
||||
|
||||
// Definitive Imports
|
||||
getDefinitiveImports: (filters: ImportDefinitiveFilter) =>
|
||||
api.post<MovementItem[]>('/v1/a76/reports/movements/invoices/definitive', filters),
|
||||
|
||||
getDefinitiveImportsDetailed: (filters: ImportDefinitiveFilter) =>
|
||||
api.post<MovementItemDetailed[]>(
|
||||
'/v1/a76/reports/movements/invoices/definitive-detailed',
|
||||
filters
|
||||
),
|
||||
|
||||
// Repair Imports
|
||||
getRepairImports: (filters: ImportRepairFilter) =>
|
||||
api.post<MovementItem[]>('/v1/a76/reports/movements/invoices/repair', filters),
|
||||
|
||||
getRepairImportsDetailed: (filters: ImportRepairFilter) =>
|
||||
api.post<MovementItemDetailed[]>(
|
||||
'/v1/a76/reports/movements/invoices/repair-detailed',
|
||||
filters
|
||||
),
|
||||
|
||||
// Exports
|
||||
getExports: (filters: ExportFilter) =>
|
||||
api.post<MovementItem[]>('/v1/a76/reports/movements/invoices/export', filters),
|
||||
|
||||
getExportsDetailed: (filters: ExportFilter) =>
|
||||
api.post<MovementItemDetailed[]>('/v1/a76/reports/movements/invoices/export-detailed', filters),
|
||||
|
||||
// Export Repairs
|
||||
getExportRepairs: (filters: ExportRepairFilter) =>
|
||||
api.post<MovementItem[]>('/v1/a76/reports/movements/invoices/export-repair', filters),
|
||||
|
||||
getExportRepairsDetailed: (filters: ExportRepairFilter) =>
|
||||
api.post<MovementItemDetailed[]>(
|
||||
'/v1/a76/reports/movements/invoices/export-repair-detailed',
|
||||
filters
|
||||
),
|
||||
|
||||
// All Movements
|
||||
getAllMovements: (filters: AllMovementsFilter) =>
|
||||
api.post<MovementItem[]>('/v1/a76/reports/movements/invoices/all', filters)
|
||||
};
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
BadgeCheck,
|
||||
ChartPie,
|
||||
Database,
|
||||
FileSearch,
|
||||
FileText,
|
||||
Frame,
|
||||
GalleryVerticalEnd,
|
||||
@@ -384,6 +385,17 @@ export function getSidebarData(): SidebarData {
|
||||
icon: BadgeCheck,
|
||||
items: [],
|
||||
},
|
||||
{
|
||||
title: "Reportes",
|
||||
url: "#",
|
||||
icon: FileSearch,
|
||||
items: [
|
||||
{
|
||||
title: "Facturas Impo/Expo",
|
||||
url: "/dashboard/reports/invoices",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: m["sidebar.reference_data.configuracion"](),
|
||||
url: "#",
|
||||
|
||||
6
frontend/src/lib/components/ui/icons/FolderIcon.svelte
Normal file
6
frontend/src/lib/components/ui/icons/FolderIcon.svelte
Normal file
@@ -0,0 +1,6 @@
|
||||
<script lang="ts">
|
||||
export let className: string = '';
|
||||
</script>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class={className}>
|
||||
<path d="M2.75 4A1.75 1.75 0 0 0 1 5.75v8.5A1.75 1.75 0 0 0 2.75 16h14.5A1.75 1.75 0 0 0 19 14.25V7.75A1.75 1.75 0 0 0 17.25 6H9.914a.75.75 0 0 1-.53-.22l-1.414-1.414A1.75 1.75 0 0 0 6.086 4H2.75z"/>
|
||||
</svg>
|
||||
@@ -57,7 +57,7 @@
|
||||
</header>
|
||||
<div class="flex flex-1 flex-col gap-4 p-4 pt-0">
|
||||
<!-- Contenido de cada página -->
|
||||
{@render children()}
|
||||
{@render children?.()}
|
||||
</div>
|
||||
</Sidebar.Inset>
|
||||
</Sidebar.Provider>
|
||||
|
||||
@@ -203,7 +203,7 @@
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
error = e.message || "Error al guardar";
|
||||
toast.error(error);
|
||||
toast.error(error || "Error al guardar");
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { getAuthTokens } from '$lib/server/api';
|
||||
|
||||
export const load: PageServerLoad = async ({ cookies }) => {
|
||||
const { accessToken } = getAuthTokens(cookies);
|
||||
|
||||
if (!accessToken) {
|
||||
throw redirect(302, '/login');
|
||||
}
|
||||
|
||||
return {
|
||||
title: 'Reportes de Facturas'
|
||||
};
|
||||
};
|
||||
1394
frontend/src/routes/dashboard/reports/invoices/+page.svelte
Normal file
1394
frontend/src/routes/dashboard/reports/invoices/+page.svelte
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user