From c85f897f4027344b49ed3a70fa8056cd6f4bcceb Mon Sep 17 00:00:00 2001 From: hreyes Date: Wed, 29 Apr 2026 10:08:52 -0600 Subject: [PATCH] feature/agente-aduanal-no-se-ve --- .../lib/api/dashboard/a76/customs-brokers.ts | 11 +++++++ .../modals/broker-selector-dialog.svelte | 8 +++-- .../invoices/edit/general-tab-form.svelte | 30 ++++++++++++------- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/frontend/src/lib/api/dashboard/a76/customs-brokers.ts b/frontend/src/lib/api/dashboard/a76/customs-brokers.ts index 4dc83595..026aeeb2 100644 --- a/frontend/src/lib/api/dashboard/a76/customs-brokers.ts +++ b/frontend/src/lib/api/dashboard/a76/customs-brokers.ts @@ -44,6 +44,17 @@ export interface CustomsBroker { vu?: CustomsBrokerVU | null; } +/** Etiqueta para listas/selects cuando `name` viene vacĂ­o (clave, patente o id). */ +export function displayCustomsBrokerLabel(b: CustomsBroker): string { + const n = b.name?.trim(); + if (n) return n; + const key = b.broker_key?.trim(); + if (key) return key; + const lic = b.license?.trim(); + if (lic) return lic; + return `#${b.id}`; +} + export interface CustomsBrokerVU { tenant_id?: string | null; company_id?: string | null; diff --git a/frontend/src/lib/components/dashboard/export/manifest/modals/broker-selector-dialog.svelte b/frontend/src/lib/components/dashboard/export/manifest/modals/broker-selector-dialog.svelte index 9edf85d7..bbd3a8e7 100644 --- a/frontend/src/lib/components/dashboard/export/manifest/modals/broker-selector-dialog.svelte +++ b/frontend/src/lib/components/dashboard/export/manifest/modals/broker-selector-dialog.svelte @@ -3,7 +3,11 @@ import { Input } from '$lib/components/ui/input'; import * as Dialog from '$lib/components/ui/dialog'; import { Search, Loader2, Award } from 'lucide-svelte'; - import { customsBrokersApi, type CustomsBroker } from '$lib/api/dashboard/a76/customs-brokers'; + import { + customsBrokersApi, + displayCustomsBrokerLabel, + type CustomsBroker + } from '$lib/api/dashboard/a76/customs-brokers'; import { companyStore } from '$lib/stores/company.svelte'; let { @@ -118,7 +122,7 @@
- {item.name || item.broker_key} + {displayCustomsBrokerLabel(item)}
diff --git a/frontend/src/lib/components/dashboard/invoices/edit/general-tab-form.svelte b/frontend/src/lib/components/dashboard/invoices/edit/general-tab-form.svelte index 013ad08f..f2326a53 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/general-tab-form.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/general-tab-form.svelte @@ -10,7 +10,7 @@ import ManifestSelectorModal from './ManifestSelectorModal.svelte'; import type { Invoice } from '$lib/api/dashboard/a76/invoices'; import type { InvoiceType } from '$lib/api/dashboard/reference_data/invoice_types'; - import type { CustomsBroker } from '$lib/api/dashboard/a76/customs-brokers'; + import { displayCustomsBrokerLabel, type CustomsBroker } from '$lib/api/dashboard/a76/customs-brokers'; import type { ClientProvider } from '$lib/api/dashboard/a76/clients-providers'; interface CodePedimentoRegimen { @@ -617,16 +617,20 @@ class={cn('h-7 max-w-[300px] min-w-[150px] text-xs', hl('customs_broker_id'))} > - {formData.customs_broker_id - ? customsBrokers.find((cb) => cb.id === formData.customs_broker_id)?.name || - m.invoice_edit_general_select_broker_placeholder() - : m.invoice_edit_general_select_broker_placeholder()} + {#if formData.customs_broker_id} + {@const selMex = customsBrokers.find((cb) => cb.id === formData.customs_broker_id)} + {selMex + ? displayCustomsBrokerLabel(selMex) + : `#${formData.customs_broker_id}`} + {:else} + {m.invoice_edit_general_select_broker_placeholder()} + {/if} {#each customsBrokers as broker} - {broker.name} + {displayCustomsBrokerLabel(broker)} {/each} @@ -644,16 +648,20 @@ > - {formData.customs_broker_us_id - ? customsBrokers.find((cb) => cb.id === formData.customs_broker_us_id)?.name || - m.invoice_edit_general_select_broker_placeholder() - : m.invoice_edit_general_select_broker_placeholder()} + {#if formData.customs_broker_us_id} + {@const selUs = customsBrokers.find((cb) => cb.id === formData.customs_broker_us_id)} + {selUs + ? displayCustomsBrokerLabel(selUs) + : `#${formData.customs_broker_us_id}`} + {:else} + {m.invoice_edit_general_select_broker_placeholder()} + {/if} {#each customsBrokers as broker} - {broker.name} + {displayCustomsBrokerLabel(broker)} {/each}