From ef5564dd25057e6ca5b76f2d59d75abe2dc52fbe Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Fri, 13 Mar 2026 16:53:42 -0600 Subject: [PATCH] Refactor Dockerfile and update models and frontend components - Removed the APP_VERSION argument from the Dockerfile and added TARGETARCH for architecture-specific wkhtmltopdf installation. - Updated models.py to reintroduce the import of PartCountry for consistency. - Enhanced parts.ts interface by adding new optional fields: immex_type, disable_movements, pga_program_code, non_discharge_clients, bom_items, and countries. - Changed formType default in partForm.svelte and edit page to 'fa' for better alignment with the intended functionality. - Improved type handling for non_discharge_clients in partForm.svelte. - Adjusted column span logic in partForm.svelte for better rendering. - Fixed image error handling in partForm.svelte for improved user experience. - Updated license expiration date calculation in init_first_time.sh for compatibility with macOS. --- backend/Dockerfile | 10 +++------- backend/api/v1/modules/a76/parts/models.py | 2 +- frontend/src/lib/api/dashboard/a76/parts.ts | 6 ++++++ .../components/dashboard/goods/parts/partForm.svelte | 8 ++++---- .../dashboard/goods/parts/edit/[[id]]/+page.svelte | 2 +- scripts/init_first_time.sh | 6 +++++- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index f6253da3..6f6a9c20 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -2,12 +2,6 @@ FROM python:3.11-slim WORKDIR /app -# ======================================== -# ARG para recibir la versión desde CI/CD -# ======================================== -ARG APP_VERSION="dev" -ENV APP_VERSION=${APP_VERSION} - # Instalar dependencias del sistema RUN apt-get update && apt-get install -y \ gcc \ @@ -32,7 +26,9 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* # Instalar wkhtmltopdf binario oficial con soporte para footers/headers -RUN curl -k -L -o /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_amd64.deb \ +# TARGETARCH permite amd64 y arm64 (Apple Silicon) +ARG TARGETARCH +RUN curl -k -L -o /tmp/wkhtmltox.deb "https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_${TARGETARCH}.deb" \ && apt-get update \ && apt-get install -y /tmp/wkhtmltox.deb \ && rm /tmp/wkhtmltox.deb \ diff --git a/backend/api/v1/modules/a76/parts/models.py b/backend/api/v1/modules/a76/parts/models.py index 3fd9bd1e..27ba357f 100644 --- a/backend/api/v1/modules/a76/parts/models.py +++ b/backend/api/v1/modules/a76/parts/models.py @@ -26,6 +26,7 @@ from api.v1.modules.public.reference_data.currency_types.models import CurrencyT from api.v1.modules.a24.fa.fa_parts.models import FaPart from api.v1.modules.a24.inv.inv_parts.models import InvPart from api.v1.modules.a24.inv.bom.models import BillOfMaterial +from api.v1.modules.a24.inv.part_countries.models import PartCountry if TYPE_CHECKING: @@ -33,7 +34,6 @@ if TYPE_CHECKING: from api.v1.modules.a76.general_catalogs.units_of_measure.models import ( UnitOfMeasure, ) - from api.v1.modules.a24.inv.part_countries.models import PartCountry class Part(Base, TenantScopedMixin, TimestampMixin): diff --git a/frontend/src/lib/api/dashboard/a76/parts.ts b/frontend/src/lib/api/dashboard/a76/parts.ts index 88ab372f..ece9c57b 100644 --- a/frontend/src/lib/api/dashboard/a76/parts.ts +++ b/frontend/src/lib/api/dashboard/a76/parts.ts @@ -66,6 +66,12 @@ export interface InvData { use_rule_8?: boolean | null; fraction_9801?: string | null; + immex_type?: string | null; + disable_movements?: boolean | null; + pga_program_code?: string | null; + non_discharge_clients?: unknown[] | null; + bom_items?: unknown[] | null; + countries?: unknown[] | null; fraction_type?: string | null; use_alternate_quantity?: boolean | null; repair_unit_cost?: number | null; diff --git a/frontend/src/lib/components/dashboard/goods/parts/partForm.svelte b/frontend/src/lib/components/dashboard/goods/parts/partForm.svelte index b989941b..9c7876a2 100644 --- a/frontend/src/lib/components/dashboard/goods/parts/partForm.svelte +++ b/frontend/src/lib/components/dashboard/goods/parts/partForm.svelte @@ -87,7 +87,7 @@ // --- PROPS --- let { partId = null, - formType = $bindable('inv') + formType = $bindable('fa') }: { partId?: number | null; formType?: 'inv' | 'fa' | 'both' } = $props(); // --- LÓGICA DE ESTADO --- @@ -552,7 +552,7 @@ mex_packing: Number(d.inv_data?.mex_packing) || 0, sales_order: d.inv_data?.sales_order || '', use_rule_8: d.inv_data?.use_rule_8 || false, - non_discharge_clients: d.inv_data?.non_discharge_clients || [] + non_discharge_clients: (d.inv_data?.non_discharge_clients || []) as { client_id: number; name: string; is_active: boolean }[] }; // Relaciones BOM / Paises @@ -1911,7 +1911,7 @@ {#if relationData.length === 0} No hay datos registrados para {relationType === 'bom' @@ -2245,7 +2245,7 @@ src={formData.part_photo} alt="Vista previa" class="h-full w-full object-contain" - onerror={(e) => (e.currentTarget.src = '')} + onerror={(e) => ((e.currentTarget as HTMLImageElement).src = '')} /> {:else} diff --git a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte index 51ded7bd..ee342456 100644 --- a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte +++ b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte @@ -5,7 +5,7 @@ import PrerequisitesModal from '$lib/components/dashboard/PrerequisitesModal.svelte'; let id = $derived($page.params.id === 'new' ? null : Number($page.params.id)); - let type = $state<'inv' | 'fa' | 'both'>('inv'); + let type = $state<'inv' | 'fa' | 'both'>('fa'); // When editing, the PartForm auto-detects the type from the loaded data. // When creating, the user picks the type here. diff --git a/scripts/init_first_time.sh b/scripts/init_first_time.sh index 0469baaf..727b28a0 100755 --- a/scripts/init_first_time.sh +++ b/scripts/init_first_time.sh @@ -965,7 +965,11 @@ echo -e "\n${YELLOW}[9/9] Creando licencia Enterprise para el tenant...${NC}" # Calcular fechas de inicio y expiración (1 año desde hoy) LICENSE_START_DATE=$(date -u +"%Y-%m-%d %H:%M:%S") -LICENSE_EXPIRE_DATE=$(date -u -d "+1 year" +"%Y-%m-%d %H:%M:%S") +if [[ "$(uname)" == "Darwin" ]]; then + LICENSE_EXPIRE_DATE=$(date -u -v+1y +"%Y-%m-%d %H:%M:%S") +else + LICENSE_EXPIRE_DATE=$(date -u -d "+1 year" +"%Y-%m-%d %H:%M:%S") +fi # Verificar si ya existe una licencia para este tenant LICENSE_EXISTS=$(exec_pg_sql "SELECT COUNT(*) FROM core.licenses WHERE tenant_id = ${TENANT_ID};")