From 41d551132324424ee28dd29799c6a237ba435852 Mon Sep 17 00:00:00 2001 From: hreyes Date: Tue, 14 Apr 2026 10:20:07 -0600 Subject: [PATCH] feature/clases-formulario-faltante --- .../common/csv_ingestion_rollout.md | 38 ---- .../classes/forms/FixedAssetClassForm.svelte | 186 +++++++++++++----- 2 files changed, 133 insertions(+), 91 deletions(-) delete mode 100644 backend/api/v1/modules/a76/layouts_csv/common/csv_ingestion_rollout.md diff --git a/backend/api/v1/modules/a76/layouts_csv/common/csv_ingestion_rollout.md b/backend/api/v1/modules/a76/layouts_csv/common/csv_ingestion_rollout.md deleted file mode 100644 index c8974b12..00000000 --- a/backend/api/v1/modules/a76/layouts_csv/common/csv_ingestion_rollout.md +++ /dev/null @@ -1,38 +0,0 @@ -# CSV Ingestion Global Rollout - -## Goal -- Apply one CSV ingestion policy across all upload flows. -- Detect regressions early in scan/commit execution. - -## Rollout Stages -- Stage 1: Enable common `CsvReadPlan` path for semiconsolidated layouts (`classes`, `parts`, `pedmientos`). -- Stage 2: Enable common deduped-header iterator for legacy transportation layouts (`drivers`, `trailers`). -- Stage 3: Keep `facturas` business parsing while enforcing common encoding + dialect detection. -- Stage 4: Reuse common encoding detection in non-layout ingestion (`carta_porte_codes` seed). - -## Metrics To Track -- `csv_scan_failed_total{layout}`: scan failures by layout. -- `csv_commit_failed_total{layout}`: commit failures by layout. -- `csv_decode_fallback_total{layout,encoding}`: resolved encoding different from UTF-8. -- `csv_headerless_detected_total{layout}`: files treated as headerless. -- `csv_rows_processed_total{layout,stage}`: processed rows in scan/commit. - -## Alerting Rules -- Alert when `csv_scan_failed_total{layout}` spikes > 2x baseline for 15 minutes. -- Alert when `csv_commit_failed_total{layout}` spikes > 2x baseline for 15 minutes. -- Alert when `csv_decode_fallback_total` changes abruptly after deployment. -- Alert when median `csv_rows_processed_total` drops sharply for active layouts. - -## Logging Requirements -- Log resolved encoding and selected dialect once per job. -- Log `header_mode` (`header`, `headerless`, `auto`) once per job. -- Keep `job_id`, `layout`, `tenant_id`, `company_id` in structured logs. - -## Verification Checklist -- Validate one UTF-8 and one CP1252 file per layout in staging. -- Validate comma and semicolon delimiters in staging. -- Validate scan and commit consistency for line numbers and stored values. - -## Rollback Strategy -- Revert to previous release if scan/commit failures exceed threshold for 30 minutes. -- Keep compatibility wrappers in `csv_reader` to reduce rollback blast radius. diff --git a/frontend/src/lib/components/dashboard/goods/classes/forms/FixedAssetClassForm.svelte b/frontend/src/lib/components/dashboard/goods/classes/forms/FixedAssetClassForm.svelte index 3fb918c1..adbf03e1 100644 --- a/frontend/src/lib/components/dashboard/goods/classes/forms/FixedAssetClassForm.svelte +++ b/frontend/src/lib/components/dashboard/goods/classes/forms/FixedAssetClassForm.svelte @@ -27,6 +27,7 @@ type FDACatalog } from '$lib/api/dashboard/a76/general_catalogs/fda-catalog'; import { companyStore } from '$lib/stores/company.svelte'; + import * as RadioGroup from '$lib/components/ui/radio-group'; interface Props { onSave?: (data: any) => void; @@ -64,7 +65,7 @@ annual_depreciation_rate: initialData?.annual_depreciation_rate || '', fda_key: initialData?.fda_key || '', eccn_code: initialData?.eccn_code || '', - iva_exempt_fraction: initialData?.iva_exempt_fraction || false, + iva_exempt_fraction: '', physical_review: initialData?.physical_review || false, carta_porte_code: initialData?.carta_porte_code || '', // Campos de tarifas de importación/exportación @@ -82,6 +83,16 @@ us_fraction_fixed_rate: '' }); + /** Sí / No (legacy); el valor persistido es `iva_exempt_fraction` (string máx. 4) */ + let ivaExemptChoice = $state<'no' | 'yes'>('no'); + + function setIvaExemptChoice(choice: 'no' | 'yes') { + ivaExemptChoice = choice; + if (choice === 'no') { + formData.iva_exempt_fraction = ''; + } + } + // Reactively update formData when initialData changes $effect(() => { if (initialData) { @@ -102,13 +113,23 @@ // Mapear fda_code a fda_key si existe formData.fda_key = snap.fda_code ?? snap.fda_key ?? ''; formData.eccn_code = snap.eccn_code ?? ''; - formData.iva_exempt_fraction = snap.iva_exempt_fraction ?? false; - formData.physical_review = snap.physical_review ?? false; + const ivaRaw = snap.iva_exempt_fraction; + const ivaStr = + ivaRaw !== undefined && ivaRaw !== null && ivaRaw !== false && ivaRaw !== true + ? String(ivaRaw).trim().slice(0, 4) + : ''; + formData.iva_exempt_fraction = ivaStr; + ivaExemptChoice = ivaStr.length > 0 ? 'yes' : 'no'; + formData.physical_review = + snap.physical_review === 1 || + snap.physical_review === true || + snap.physical_review === '1'; formData.carta_porte_code = snap.carta_porte_code ?? ''; formData.import_tariff_code = snap.import_tariff_code ?? ''; formData.import_tariff_type = snap.import_tariff_type ?? ''; formData.export_tariff_code = snap.export_tariff_code ?? ''; formData.export_tariff_type = snap.export_tariff_type ?? ''; + formData.fraction_umt = snap.import_tariff_type ?? ''; // Reiniciar banderas de error al cargar datos showErrors = false; @@ -125,13 +146,19 @@ formData.annual_depreciation_rate = ''; formData.fda_key = ''; formData.eccn_code = ''; - formData.iva_exempt_fraction = false; + formData.iva_exempt_fraction = ''; + ivaExemptChoice = 'no'; formData.physical_review = false; formData.carta_porte_code = ''; formData.import_tariff_code = ''; formData.import_tariff_type = ''; formData.export_tariff_code = ''; formData.export_tariff_type = ''; + formData.unit_measure_key = ''; + formData.fraction_umt = ''; + formData.fraction_uma_key = ''; + formData.us_fraction_ad_valorem = ''; + formData.us_fraction_fixed_rate = ''; // Reiniciar banderas de error al limpiar formulario showErrors = false; @@ -708,12 +735,12 @@ -
+
{formData.unit_of_measure_description || ''} + + Clave U.M.A: + {formData.unit_measure_key || '—'} +
{#if validationErrors.unit_of_measure}

{validationErrors.unit_of_measure}

@@ -735,12 +766,12 @@ -
+
+
+ U.M.T: {formData.fraction_umt || '—'} + Clave U.M.A: + {formData.fraction_uma_key || '—'} +
{#if validationErrors.fraction}

{validationErrors.fraction}

{/if}
- -
-
- -
- - -
+ +
+ +
+ + + AdValorem: {formData.us_fraction_ad_valorem || '0.00'} + Tasa Fija: {formData.us_fraction_fixed_rate || '0.00000000'}
+
+ +
@@ -792,46 +839,79 @@
-
- -
-
- -
- - -
-
- -
- -
- - -
-
+ +
+ +
+ + +
+
+ + +
+ +
+ setIvaExemptChoice(v as 'no' | 'yes')} + class="flex flex-wrap gap-6" + > +
+ + +
+
+ + +
+
+ {#if ivaExemptChoice === 'yes'} +
+ + +
+ {/if} +
+
+ + +
+ +
+ + +
+
+