From 97b3ea52bc75bff9511588cbc4d1719a90132fd9 Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Wed, 31 Dec 2025 10:37:23 -0600 Subject: [PATCH 1/4] feat: Update environment variables and Docker configurations for production setup --- .env.example | 1 + README.md | 8 +++++++- backend/requirements.txt | 1 + docker-compose.prod.yml | 37 +++++++++++++++++++--------------- frontend/Dockerfile.prod | 12 ++++++++++- frontend/package.json | 1 + frontend/src/lib/server/api.ts | 9 ++++++++- frontend/svelte.config.js | 7 ++++++- 8 files changed, 56 insertions(+), 20 deletions(-) diff --git a/.env.example b/.env.example index b303d5e4..c66ef877 100644 --- a/.env.example +++ b/.env.example @@ -32,6 +32,7 @@ CORE_DB_PASSWORD=postgres # ----- Frontend ----- NODE_ENV=development VITE_API_URL=http://localhost:8000/api +INTERNAL_API_URL=http://backend:8000/api VITE_KEYCLOAK_REALM=master VITE_KEYCLOAK_URL=http://localhost:8080 VITE_KEYCLOAK_CLIENT_ID=anexo76-frontend diff --git a/README.md b/README.md index 956de442..d6d16209 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,13 @@ python -c "from core.database import init_db; init_db()" ``` docker build -t dev.aduanasoft.com/anexo76/backend:latest -f ./backend/Dockerfile ./backend -docker build -t dev.aduanasoft.com/anexo76/frontend:latest -f ./frontend/Dockerfile.prod ./frontend +docker build \ +--build-arg VITE_API_URL=https://anexo76-dev.aduanasoft.com/api/ \ +--build-arg VITE_KEYCLOAK_URL=https://anexo76-dev.aduanasoft.com/kcauth/ \ +--build-arg INTERNAL_API_URL=http://backend:3467/api/ \ +-t dev.aduanasoft.com/anexo76/frontend:latest \ +-f ./frontend/Dockerfile.prod \ +./frontend ``` Publica en el registro (ajusta el registry si corresponde): diff --git a/backend/requirements.txt b/backend/requirements.txt index 9f13d289..1e600ac7 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -1,6 +1,7 @@ # Core Framework fastapi==0.119.0 uvicorn[standard]==0.37.0 +gunicorn==23.0.0 pydantic==2.12.3 pydantic[email]==2.12.3 pydantic-settings==2.11.0 diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 4339e0a8..7a676940 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -87,18 +87,19 @@ services: KC_DB_USERNAME: postgres KC_DB_PASSWORD: ${POSTGRES_KEYCLOAK_PASSWORD:-postgres} KC_DB_SCHEMA: public - KC_HOSTNAME: localhost + KC_HOSTNAME: anexo76-dev.aduanasoft.com KC_HTTP_ENABLED: "true" KC_HOSTNAME_STRICT: "false" KC_HOSTNAME_STRICT_HTTPS: "false" + KC_PROXY: edge KC_PROXY_HEADERS: "xforwarded" KC_HEALTH_ENABLED: "true" KC_METRICS_ENABLED: "true" KC_HOSTNAME_PATH: /kcauth - KC_LOG_LEVEL: INFO + KC_LOG_LEVEL: INFO JAVA_OPTS_APPEND: "-Xms256m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true" command: - - start-dev + - start - --db=postgres - --db-url-host=postgres-keycloak - --http-relative-path=/kcauth @@ -165,16 +166,26 @@ services: condition: service_healthy keycloak: condition: service_healthy - volumes: - - ./backend:/app - - backend_cache:/app/__pycache__ + volumes: - ./scripts/backend-entrypoint.sh:/entrypoint.sh:ro networks: - backend-net - frontend-net restart: unless-stopped entrypoint: ["/entrypoint.sh"] - command: ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload", "--log-level", "info"] + command: + [ + "gunicorn", + "main:app", + "-k", + "uvicorn.workers.UvicornWorker", + "-w", + "${WEB_CONCURRENCY:-4}", + "-b", + "0.0.0.0:8000", + "--log-level", + "info" + ] healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8000/api/health || exit 1"] interval: 15s @@ -195,13 +206,7 @@ services: # Frontend - SvelteKit frontend: - build: - context: ./frontend - dockerfile: Dockerfile.prod - args: - - BUILDKIT_INLINE_CACHE=1 - - VITE_API_URL=https://anexo76-dev.aduanasoft.com/api/ - - VITE_KEYCLOAK_URL=https://anexo76-dev.aduanasoft.com/kcauth/ + image: dev.aduanasoft.com/anexo76/frontend:latest container_name: anexo76-frontend environment: - NODE_ENV=${NODE_ENV:-development} @@ -213,7 +218,7 @@ services: - KEYCLOAK_URL=${KEYCLOAK_URL:-http://keycloak:8080/kcauth} - KEYCLOAK_REALM=${KEYCLOAK_REALM:-master} - KEYCLOAK_CLIENT_ID=${KEYCLOAK_CLIENT_ID:-anexo76-backend} - - KEYCLOAK_CLIENT_SECRET=${KEYCLOAK_CLIENT_SECRET:-zRU5NuvUFtBSOuh7Kdc372AItoWGLgz9} + - KEYCLOAK_CLIENT_SECRET=${KEYCLOAK_CLIENT_SECRET:-dev-secret} ports: - "5111:5173" depends_on: @@ -226,7 +231,7 @@ services: - frontend-net - auth-net restart: unless-stopped - command: ["node", "build"] + command: ["pnpm", "start"] healthcheck: test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:5173/ || exit 1"] interval: 15s diff --git a/frontend/Dockerfile.prod b/frontend/Dockerfile.prod index 754f6fed..5d7ea7a6 100644 --- a/frontend/Dockerfile.prod +++ b/frontend/Dockerfile.prod @@ -19,6 +19,12 @@ RUN pnpm install --frozen-lockfile ARG VITE_API_URL ENV VITE_API_URL=${VITE_API_URL} +ARG VITE_KEYCLOAK_URL +ENV VITE_KEYCLOAK_URL=${VITE_KEYCLOAK_URL} + +ARG INTERNAL_API_URL +ENV INTERNAL_API_URL=${INTERNAL_API_URL} + # Copiar el resto del código COPY . . @@ -55,5 +61,9 @@ ENV NODE_ENV=production ENV PORT=5173 ENV HOST=0.0.0.0 +# IMPORTANTE: Estas variables se pueden sobrescribir en docker-compose +# pero necesitamos valores por defecto para el build +ENV INTERNAL_API_URL=http://backend:8000/api/ + # Ejecutar aplicación con Node.js -CMD ["node", "build"] +CMD ["pnpm", "start"] diff --git a/frontend/package.json b/frontend/package.json index 8deac80f..ca906270 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,6 +8,7 @@ "i18n:compile": "paraglide-js compile --project ./project.inlang --outdir ./src/lib/paraglide", "build": "vite build", "preview": "vite preview", + "start": "node build/index.js", "prepare": "svelte-kit sync || echo ''", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", diff --git a/frontend/src/lib/server/api.ts b/frontend/src/lib/server/api.ts index 41ec018b..d0d1caeb 100644 --- a/frontend/src/lib/server/api.ts +++ b/frontend/src/lib/server/api.ts @@ -10,12 +10,19 @@ import { redirect, type Cookies } from '@sveltejs/kit'; * Automáticamente reemplaza localhost/127.0.0.1 con 'backend' para Docker */ export function getServerApiUrl(): string { + // Primero intentar con INTERNAL_API_URL (para llamadas server-side en Docker) let apiUrl = process.env.INTERNAL_API_URL; + // Si no está definida, usar VITE_API_URL del entorno runtime (no import.meta.env) + if (!apiUrl) { + apiUrl = process.env.VITE_API_URL; + } + + // Como último recurso, usar el valor de build-time if (!apiUrl) { apiUrl = import.meta.env.VITE_API_URL; // Reemplazar 'localhost' con 'backend' para llamadas desde el servidor (SSR) - apiUrl = apiUrl?.replace('localhost', 'backend').replace('127.0.0.1', 'backend'); + apiUrl = apiUrl?.replace('localhost', 'backend').replace('127.0.0.1', 'backend').replace('anexo76-dev.aduanasoft.com', 'backend'); } // Normalizar la URL: asegurar que termine con '/' diff --git a/frontend/svelte.config.js b/frontend/svelte.config.js index 03c17f28..d3ef3f6a 100644 --- a/frontend/svelte.config.js +++ b/frontend/svelte.config.js @@ -6,7 +6,12 @@ const config = { // Consult https://svelte.dev/docs/kit/integrations // for more information about preprocessors preprocess: vitePreprocess(), - kit: { adapter: adapter() } + kit: { + adapter: adapter(), + csrf: { + checkOrigin: false + } + } }; export default config; From e554c4fca3ac120ee21ca3993985992e90841045 Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Fri, 2 Jan 2026 12:28:44 -0600 Subject: [PATCH 2/4] feat: Refactor logging in exchange rate API and remove unnecessary console statements in various components --- docker-compose.prod.yml | 1 + .../lib/api/dashboard/a76/exchange-rate.ts | 19 ++++++------------- .../pedimentos/edit/dates-tab-form.svelte | 6 ++---- .../edit/other-data-tab-form.svelte | 7 ++----- .../package-transportation-tab-form.svelte | 17 +---------------- 5 files changed, 12 insertions(+), 38 deletions(-) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 7a676940..eb05fe4c 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -229,6 +229,7 @@ services: - ./scripts/frontend-entrypoint.sh:/frontend-entrypoint.sh:ro networks: - frontend-net + - backend-net - auth-net restart: unless-stopped command: ["pnpm", "start"] diff --git a/frontend/src/lib/api/dashboard/a76/exchange-rate.ts b/frontend/src/lib/api/dashboard/a76/exchange-rate.ts index 690d3e9c..89dae9dc 100644 --- a/frontend/src/lib/api/dashboard/a76/exchange-rate.ts +++ b/frontend/src/lib/api/dashboard/a76/exchange-rate.ts @@ -25,30 +25,23 @@ export interface ExchangeRateListResponse { * Get exchange rate by date */ export async function getExchangeRateByDate(date: string, companyId: number): Promise { - try { - console.log('📡 [API] Solicitando tipos de cambio para company_id:', companyId); + try { // Get all exchange rates and filter by date on client side - const response = await api.get(`/v1/a76/exchange-rate/?company_id=${companyId}`); - - console.log('📡 [API] Respuesta recibida:', response.data?.total, 'tipos de cambio'); + const response = await api.get(`/v1/a76/exchange-rate/?company_id=${companyId}`); 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 dateOnly = date.split('T')[0]; // Get YYYY-MM-DD part const matchingRates = response.data.items.filter(rate => { const rateDate = rate.date.split('T')[0]; - const matches = rateDate === dateOnly && rate.foreign_currency === 'USD'; - console.log(' - Comparando:', rateDate, '===', dateOnly, '&& USD ===', rate.foreign_currency, '→', matches); + const matches = rateDate === dateOnly && rate.foreign_currency === 'USD'; 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('❌ [API] Error fetching exchange rate:', error); diff --git a/frontend/src/lib/components/dashboard/pedimentos/edit/dates-tab-form.svelte b/frontend/src/lib/components/dashboard/pedimentos/edit/dates-tab-form.svelte index 2e52e1ce..2b45810e 100644 --- a/frontend/src/lib/components/dashboard/pedimentos/edit/dates-tab-form.svelte +++ b/frontend/src/lib/components/dashboard/pedimentos/edit/dates-tab-form.svelte @@ -25,8 +25,7 @@ // Actualizar formData solo cuando el pedimento cambie desde el servidor $effect(() => { - const currentObservations = pedimento?.observations ?? null; - console.log('🔄 Pedimento changed in dates-tab-form:', currentObservations); + const currentObservations = pedimento?.observations ?? null; // Solo actualizar si el valor del servidor cambió realmente if (currentObservations !== lastServerObservations) { @@ -34,8 +33,7 @@ formData = { observaciones: currentObservations || '' }; - exists = !!currentObservations; - console.log('✅ Updated formData.observaciones:', formData.observaciones); + exists = !!currentObservations; } }); diff --git a/frontend/src/lib/components/dashboard/pedimentos/edit/other-data-tab-form.svelte b/frontend/src/lib/components/dashboard/pedimentos/edit/other-data-tab-form.svelte index 9e8dd0dc..b85cfa5a 100644 --- a/frontend/src/lib/components/dashboard/pedimentos/edit/other-data-tab-form.svelte +++ b/frontend/src/lib/components/dashboard/pedimentos/edit/other-data-tab-form.svelte @@ -163,9 +163,7 @@ // Solo actualizar si las configuraciones cambiaron if (configHash !== lastServerConfigHash) { - lastServerConfigHash = configHash; - console.log('🔄 Cargando datos del servidor en other-data-tab-form'); - console.log('📥 pedimento_config_updates del servidor:', pedimento.pedimento_config_updates); + lastServerConfigHash = configHash; // Mapear pedimento_config_calculations if (pedimento.pedimento_config_calculations) { @@ -214,8 +212,7 @@ formData.actualizar_advalorem = updates.update_advalorem ?? false; formData.actualizar_dta = updates.update_dta ?? false; formData.actualizar_cc = updates.update_cc ?? false; - formData.actualizar_ieps = updates.update_ieps ?? false; - console.log('✅ Mapeado update_dta:', updates.update_dta, '→ formData.actualizar_dta:', formData.actualizar_dta); + formData.actualizar_ieps = updates.update_ieps ?? false; } // Mapear pedimento_config_update_rectification diff --git a/frontend/src/lib/components/dashboard/pedimentos/edit/package-transportation-tab-form.svelte b/frontend/src/lib/components/dashboard/pedimentos/edit/package-transportation-tab-form.svelte index 87a72b7c..32d48f55 100644 --- a/frontend/src/lib/components/dashboard/pedimentos/edit/package-transportation-tab-form.svelte +++ b/frontend/src/lib/components/dashboard/pedimentos/edit/package-transportation-tab-form.svelte @@ -95,25 +95,10 @@ // Cargar datos del pedimento cuando está disponible $effect(() => { if (pedimento && pedimento.pedimento_transport_means) { - const transport = pedimento.pedimento_transport_means; - // Por ahora solo log para ver qué datos vienen - console.log('📦 pedimento_transport_means del servidor:', transport); + const transport = pedimento.pedimento_transport_means; } }); - // Log cuando el componente se monta/desmonta - $effect(() => { - console.log('🚀 BultosTransportesTabForm montado - Datos actuales:', { - transportes: formData.transportes.length, - guias: formData.guias.length, - precintos: formData.precintos.length, - contenedores: formData.contenedores.length - }); - - return () => { - console.log('💥 BultosTransportesTabForm desmontado'); - }; - }); // Estados para diálogos let isTransporteDialogOpen = $state(false); From 104014d0faa7fe0a2e274e3b184b689afbbed549 Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Fri, 2 Jan 2026 13:35:01 -0600 Subject: [PATCH 3/4] feat: Update API endpoints to ensure trailing slashes and adjust data types in models --- backend/api/v1/common/tenant_crud_routes.py | 2 +- .../a76/pedmientos/dtos/pedimento_dates.py | 2 +- .../models/pedimento_config_additional.py | 17 +++++---- .../models/pedimento_config_surcharges.py | 13 +++---- .../api/dashboard/a76/clients-providers.ts | 6 ++-- .../lib/api/dashboard/a76/customs-brokers.ts | 4 +-- frontend/src/lib/api/dashboard/a76/items.ts | 8 ++--- .../src/lib/api/dashboard/a76/pedimentos.ts | 10 +++--- .../pedimentos/edit/general-tab-form.svelte | 35 ++++++++----------- .../pedimentos/edit/[id]/+page.svelte | 3 +- 10 files changed, 46 insertions(+), 54 deletions(-) diff --git a/backend/api/v1/common/tenant_crud_routes.py b/backend/api/v1/common/tenant_crud_routes.py index 3ff9b0a0..26dfa830 100644 --- a/backend/api/v1/common/tenant_crud_routes.py +++ b/backend/api/v1/common/tenant_crud_routes.py @@ -388,7 +388,7 @@ class TenantCRUDRoutes( update_schema = self.update_schema @self.router.put( - f"/{{{self.id_name}}}", + f"/{{{self.id_name}}}/", response_model=self.response_schema, summary=f"Update {self.resource_name}", description=f"Update an existing {self.resource_name} by {self.id_name}", diff --git a/backend/api/v1/modules/a76/pedmientos/dtos/pedimento_dates.py b/backend/api/v1/modules/a76/pedmientos/dtos/pedimento_dates.py index c9c4cb62..a5bf4118 100644 --- a/backend/api/v1/modules/a76/pedmientos/dtos/pedimento_dates.py +++ b/backend/api/v1/modules/a76/pedmientos/dtos/pedimento_dates.py @@ -24,7 +24,7 @@ class PedimentoDatesBase(BaseModel): class PedimentoDatesCreate(BaseModel): """Schema for creating a new Pedimento Dates - pedimento_id and tenant_id are set by backend""" - entry_date: Optional[datetime] = Field(None, description="Entry date") + entry_date: datetime = Field(..., description="Entry date") pedimento_date: Optional[datetime] = Field(None, description="Pedimento date") payment_date: datetime = Field(..., description="Payment date") rectification_payment_date: Optional[datetime] = Field(None, description="Rectification payment date") diff --git a/backend/api/v1/modules/a76/pedmientos/models/pedimento_config_additional.py b/backend/api/v1/modules/a76/pedmientos/models/pedimento_config_additional.py index 22735ad6..e1a839ca 100644 --- a/backend/api/v1/modules/a76/pedmientos/models/pedimento_config_additional.py +++ b/backend/api/v1/modules/a76/pedmientos/models/pedimento_config_additional.py @@ -1,13 +1,12 @@ -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Optional from api.v1.common.base_models import TenantScopedMixin, TimestampMixin from core.database import Base from sqlalchemy import ( + Boolean, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, - SmallInteger, - String, UniqueConstraint, ) from sqlalchemy.orm import Mapped, mapped_column, relationship @@ -38,12 +37,12 @@ class PedimentoConfigAdditional(Base, TenantScopedMixin, TimestampMixin): id: Mapped[int] = mapped_column(Integer) pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False) - add_po_identifier: Mapped[int] = mapped_column(SmallInteger) - do_not_exempt_norms_complement_x: Mapped[int] = mapped_column(SmallInteger) - manual_pedimento_year: Mapped[str] = mapped_column(String(2)) - enable_import_invoice_recipient: Mapped[int] = mapped_column(SmallInteger) - send_502_validation_file_for_consolidated: Mapped[int] = mapped_column(SmallInteger) - add_remove_norms: Mapped[int] = mapped_column(SmallInteger) + add_po_identifier: Mapped[bool] = mapped_column(Boolean) + do_not_exempt_norms_complement_x: Mapped[bool] = mapped_column(Boolean) + manual_pedimento_year: Mapped[Optional[int]] = mapped_column(Integer) + enable_import_invoice_recipient: Mapped[bool] = mapped_column(Boolean) + send_502_validation_file_for_consolidated: Mapped[bool] = mapped_column(Boolean) + add_remove_norms: Mapped[bool] = mapped_column(Boolean) pedimento: Mapped["Pedimentos"] = relationship( "Pedimentos", back_populates="pedimento_config_additional" diff --git a/backend/api/v1/modules/a76/pedmientos/models/pedimento_config_surcharges.py b/backend/api/v1/modules/a76/pedmientos/models/pedimento_config_surcharges.py index 2d2cdd78..6943404a 100644 --- a/backend/api/v1/modules/a76/pedmientos/models/pedimento_config_surcharges.py +++ b/backend/api/v1/modules/a76/pedmientos/models/pedimento_config_surcharges.py @@ -3,6 +3,7 @@ from typing import TYPE_CHECKING from api.v1.common.base_models import TenantScopedMixin, TimestampMixin from core.database import Base from sqlalchemy import ( + Boolean, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, @@ -37,12 +38,12 @@ class PedimentoConfigSurcharges(Base, TenantScopedMixin, TimestampMixin): id: Mapped[int] = mapped_column(Integer) pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False) - surcharge_igi: Mapped[int] = mapped_column(SmallInteger) - surcharge_dta: Mapped[int] = mapped_column(SmallInteger) - surcharge_vat: Mapped[int] = mapped_column(SmallInteger) - surcharge_isan: Mapped[int] = mapped_column(SmallInteger) - surcharge_ieps: Mapped[int] = mapped_column(SmallInteger) - surcharge_cc: Mapped[int] = mapped_column(SmallInteger) + surcharge_igi: Mapped[bool] = mapped_column(Boolean) + surcharge_dta: Mapped[bool] = mapped_column(Boolean) + surcharge_vat: Mapped[bool] = mapped_column(Boolean) + surcharge_isan: Mapped[bool] = mapped_column(Boolean) + surcharge_ieps: Mapped[bool] = mapped_column(Boolean) + surcharge_cc: Mapped[bool] = mapped_column(Boolean) pedimento: Mapped["Pedimentos"] = relationship( "Pedimentos", back_populates="pedimento_config_surcharges" diff --git a/frontend/src/lib/api/dashboard/a76/clients-providers.ts b/frontend/src/lib/api/dashboard/a76/clients-providers.ts index 26d31d69..33830d62 100644 --- a/frontend/src/lib/api/dashboard/a76/clients-providers.ts +++ b/frontend/src/lib/api/dashboard/a76/clients-providers.ts @@ -110,7 +110,7 @@ export const clientsProvidersApi = { } return api.get( - `/v1/a76/clients-providers?${params.toString()}` + `/v1/a76/clients-providers/?${params.toString()}` ); }, @@ -138,7 +138,7 @@ export const clientsProvidersApi = { * @param data - Datos del cliente/proveedor a crear */ create: (companyId: number, data: CreateClientProviderData) => - api.post(`/v1/a76/clients-providers?company_id=${companyId}`, data), + api.post(`/v1/a76/clients-providers/?company_id=${companyId}`, data), /** * Actualiza un cliente/proveedor existente @@ -156,7 +156,7 @@ export const clientsProvidersApi = { */ toggleStatus: (id: number, companyId: number) => api.put( - `/v1/a76/clients-providers/${id}/toggle-status?company_id=${companyId}`, + `/v1/a76/clients-providers/${id}/toggle-status/?company_id=${companyId}`, {} ), diff --git a/frontend/src/lib/api/dashboard/a76/customs-brokers.ts b/frontend/src/lib/api/dashboard/a76/customs-brokers.ts index 149b97b5..9f18da9e 100644 --- a/frontend/src/lib/api/dashboard/a76/customs-brokers.ts +++ b/frontend/src/lib/api/dashboard/a76/customs-brokers.ts @@ -89,7 +89,7 @@ export const customsBrokersApi = { * Lista todos los agentes aduanales */ list: (companyId: string) => { - return api.get(`/v1/a76/customs-brokers?company_id=${companyId}`); + return api.get(`/v1/a76/customs-brokers/?company_id=${companyId}`); }, /** @@ -104,7 +104,7 @@ export const customsBrokersApi = { */ create: (data: CreateCustomsBrokerData) => { const companyId = data.company_id; - return api.post(`/v1/a76/customs-brokers?company_id=${companyId}`, data); + return api.post(`/v1/a76/customs-brokers/?company_id=${companyId}`, data); }, /** diff --git a/frontend/src/lib/api/dashboard/a76/items.ts b/frontend/src/lib/api/dashboard/a76/items.ts index 2dc3e26e..e474411c 100644 --- a/frontend/src/lib/api/dashboard/a76/items.ts +++ b/frontend/src/lib/api/dashboard/a76/items.ts @@ -76,7 +76,7 @@ export const itemsApi = { const params = new URLSearchParams({ company_id: companyId.toString() }); - return api.get(`/v1/a76/items/invoice/${invoiceId}/items?${params.toString()}`); + return api.get(`/v1/a76/items/invoice/${invoiceId}/items/?${params.toString()}`); }, /** @@ -86,7 +86,7 @@ export const itemsApi = { const params = new URLSearchParams({ company_id: companyId.toString() }); - return api.get(`/v1/a76/items/${itemId}?${params.toString()}`); + return api.get(`/v1/a76/items/${itemId}/?${params.toString()}`); }, /** @@ -106,7 +106,7 @@ export const itemsApi = { const params = new URLSearchParams({ company_id: companyId.toString() }); - return api.put(`/v1/a76/items/${itemId}?${params.toString()}`, data); + return api.put(`/v1/a76/items/${itemId}/?${params.toString()}`, data); }, /** @@ -116,6 +116,6 @@ export const itemsApi = { const params = new URLSearchParams({ company_id: companyId.toString() }); - return api.delete(`/v1/a76/items/${itemId}?${params.toString()}`); + return api.delete(`/v1/a76/items/${itemId}/?${params.toString()}`); } }; diff --git a/frontend/src/lib/api/dashboard/a76/pedimentos.ts b/frontend/src/lib/api/dashboard/a76/pedimentos.ts index e80c24d5..0d021705 100644 --- a/frontend/src/lib/api/dashboard/a76/pedimentos.ts +++ b/frontend/src/lib/api/dashboard/a76/pedimentos.ts @@ -276,7 +276,7 @@ export const pedimentosApi = { * @param companyId - ID de la compañía (por defecto 1) */ list: (page = 1, pageSize = 50, filters?: PedimentoFilters, companyId = 1) => { - let url = `/v1/a76/pedimentos?company_id=${companyId}&page=${page}&page_size=${pageSize}`; + let url = `/v1/a76/pedimentos/?company_id=${companyId}&page=${page}&page_size=${pageSize}`; if (filters?.status) { url += `&status=${encodeURIComponent(filters.status)}`; @@ -296,7 +296,7 @@ export const pedimentosApi = { * @param id - ID del pedimento * @param companyId - ID de la compañía (por defecto 1) */ - get: (id: number, companyId = 1) => api.get(`/v1/a76/pedimentos/${id}?company_id=${companyId}`), + get: (id: number, companyId = 1) => api.get(`/v1/a76/pedimentos/${id}/?company_id=${companyId}`), /** * Crea un nuevo pedimento @@ -304,7 +304,7 @@ export const pedimentosApi = { * @param companyId - ID de la compañía (por defecto 1) */ create: (data: CreatePedimentoData, companyId = 1) => - api.post(`/v1/a76/pedimentos?company_id=${companyId}`, data), + api.post(`/v1/a76/pedimentos/?company_id=${companyId}`, data), /** * Actualiza un pedimento existente @@ -313,12 +313,12 @@ export const pedimentosApi = { * @param companyId - ID de la compañía (por defecto 1) */ update: (id: number, data: UpdatePedimentoData, companyId = 1) => - api.put(`/v1/a76/pedimentos/${id}?company_id=${companyId}`, data), + api.put(`/v1/a76/pedimentos/${id}/?company_id=${companyId}`, data), /** * Elimina un pedimento * @param id - ID del pedimento a eliminar * @param companyId - ID de la compañía (por defecto 1) */ - delete: (id: number, companyId = 1) => api.delete(`/v1/a76/pedimentos/${id}?company_id=${companyId}`) + delete: (id: number, companyId = 1) => api.delete(`/v1/a76/pedimentos/${id}/?company_id=${companyId}`) }; diff --git a/frontend/src/lib/components/dashboard/pedimentos/edit/general-tab-form.svelte b/frontend/src/lib/components/dashboard/pedimentos/edit/general-tab-form.svelte index c5d7d51d..c0abfbd6 100644 --- a/frontend/src/lib/components/dashboard/pedimentos/edit/general-tab-form.svelte +++ b/frontend/src/lib/components/dashboard/pedimentos/edit/general-tab-form.svelte @@ -1,4 +1,5 @@