diff --git a/backend/api/v1/modules/a76/items/imports/temporary/validators/create.py b/backend/api/v1/modules/a76/items/imports/temporary/validators/create.py index 7c3ae0d8..2507f953 100644 --- a/backend/api/v1/modules/a76/items/imports/temporary/validators/create.py +++ b/backend/api/v1/modules/a76/items/imports/temporary/validators/create.py @@ -109,4 +109,22 @@ def validate_create( message="Description in Spanish es obligatorio", solution="Proporciona una descripción del item en español", code="REQUIRED" + ) + + # 8. Validar customs.origin_country + if not line.customs or not line.customs.origin_country: + errors.add_error( + field="customs.origin_country", + message="País de Origen es obligatorio", + solution="Selecciona el país de origen del item", + code="REQUIRED" + ) + + # 9. Validar customs.fraction_type + if not line.customs or not line.customs.fraction_type: + errors.add_error( + field="customs.fraction_type", + message="Tipo de Tarifa es obligatorio", + solution="Selecciona el tipo de tarifa (GENERAL, PROSEC, ALADI, TLCS)", + code="REQUIRED" ) \ No newline at end of file diff --git a/backend/api/v1/modules/a76/items/imports/temporary/validators/update.py b/backend/api/v1/modules/a76/items/imports/temporary/validators/update.py index 8feaa515..08aed895 100644 --- a/backend/api/v1/modules/a76/items/imports/temporary/validators/update.py +++ b/backend/api/v1/modules/a76/items/imports/temporary/validators/update.py @@ -138,14 +138,25 @@ def validate_update( # 8. Validar datos aduanales si se proporcionan if line.customs: - # Validar país de origen - if line.customs.origin_country is not None and not line.customs.origin_country: - errors.add_error( - field="customs.origin_country", - message="Origin Country no puede estar vacío", - solution="Selecciona el país de origen del item", - code="REQUIRED" - ) + # Validar país de origen (OBLIGATORIO) + if line.customs.origin_country is not None: + if not line.customs.origin_country: + errors.add_error( + field="customs.origin_country", + message="País de Origen es obligatorio", + solution="Selecciona el país de origen del item", + code="REQUIRED" + ) + + # Validar tipo de tarifa (OBLIGATORIO) + if line.customs.fraction_type is not None: + if not line.customs.fraction_type: + errors.add_error( + field="customs.fraction_type", + message="Tipo de Tarifa es obligatorio", + solution="Selecciona el tipo de tarifa (GENERAL, PROSEC, ALADI, TLCS)", + code="REQUIRED" + ) # Validar preferencia arancelaria if line.customs.preference is not None and not line.customs.preference: @@ -184,15 +195,16 @@ def validate_update( code="INVALID_VALUE" ) - # 9. Validar descripción en español si se proporciona + # 9. Validar descripción en español (OBLIGATORIA) if line.description and hasattr(line.description, 'description_spanish'): - if line.description.description_spanish is not None and not line.description.description_spanish: - errors.add_error( - field="description.description_spanish", - message="La descripción en español no puede estar vacía", - solution="Proporciona una descripción del item en español", - code="REQUIRED" - ) + if line.description.description_spanish is not None: + if not line.description.description_spanish.strip(): + errors.add_error( + field="description.description_spanish", + message="Descripción en Español es obligatoria", + solution="Proporciona una descripción del item en español", + code="REQUIRED" + ) # 10. Validar subpartidas si se actualizan if line.fa_data and line.fa_data.is_subitem: diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/item-sheet-fa.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/item-sheet-fa.svelte index a091ac75..5bf87a1c 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/item-sheet-fa.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/item-sheet-fa.svelte @@ -23,6 +23,7 @@ editingItem = $bindable(), invoice, onSave, + onCancel, isSaving = false }: { open: boolean; @@ -30,6 +31,7 @@ editingItem: Partial; invoice: Invoice | null; onSave: () => void; + onCancel?: () => void; isSaving?: boolean; } = $props(); @@ -55,7 +57,7 @@

- @@ -164,7 +166,7 @@