fix(clients_and_providers): include 'both' type in client/provider filters and update UI indicators
This commit is contained in:
@@ -7,6 +7,11 @@
|
||||
import type { InvoiceType } from '$lib/api/dashboard/refrence_data/invoice_types';
|
||||
import type { CustomsBroker } from '$lib/api/dashboard/a76/customs-brokers';
|
||||
import type { ClientProvider } from '$lib/api/dashboard/a76/clients-providers';
|
||||
import {
|
||||
"sidebar.client_provider_type.client_indicator" as clientIndicator,
|
||||
"sidebar.client_provider_type.provider_indicator" as providerIndicator,
|
||||
"sidebar.client_provider_type.both_indicator" as bothIndicator
|
||||
} from '$lib/paraglide/messages.js';
|
||||
|
||||
let {
|
||||
invoice,
|
||||
@@ -176,8 +181,24 @@
|
||||
]
|
||||
);
|
||||
|
||||
// Combinar clientes y proveedores para shipped_to
|
||||
const allClientsProviders = [...clients, ...providers];
|
||||
// Combinar clientes y proveedores para shipped_to, evitando duplicados de tipo "both"
|
||||
const allClientsProviders = $derived.by(() => {
|
||||
const uniqueMap = new Map();
|
||||
|
||||
// Agregar todos los clientes
|
||||
clients.forEach(c => {
|
||||
uniqueMap.set(c.id, { ...c, type: c.client_or_provider });
|
||||
});
|
||||
|
||||
// Agregar proveedores solo si no existen (evita duplicados de "both")
|
||||
providers.forEach(p => {
|
||||
if (!uniqueMap.has(p.id)) {
|
||||
uniqueMap.set(p.id, { ...p, type: p.client_or_provider });
|
||||
}
|
||||
});
|
||||
|
||||
return Array.from(uniqueMap.values());
|
||||
});
|
||||
|
||||
// Filtrar regímenes por tipo de operación (1='E' exp, 2='I' imp) y obtener valores únicos
|
||||
const filteredRegimens = $derived.by(() => {
|
||||
@@ -363,7 +384,7 @@
|
||||
<Select.Content class="max-h-[300px]">
|
||||
{#each allClientsProviders as cp}
|
||||
<Select.Item value={String(cp.id)}>
|
||||
{cp.name} ({cp.type === 'client' ? 'C' : 'P'})
|
||||
{cp.name} ({cp.type === 'client' ? clientIndicator() : cp.type === 'provider' ? providerIndicator() : bothIndicator()})
|
||||
</Select.Item>
|
||||
{/each}
|
||||
</Select.Content>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { ColumnDef } from "@tanstack/table-core";
|
||||
import { renderComponent, renderSnippet } from "$lib/components/ui/data-table/index.js";
|
||||
import { createRawSnippet } from "svelte";
|
||||
// @ts-ignore - Svelte component import
|
||||
import DataTableActions from "./data-table-actions.svelte";
|
||||
import type { Pedimento } from "$lib/api/dashboard/a76/pedimentos";
|
||||
|
||||
@@ -201,34 +202,6 @@ export function createColumns(onSuccess?: () => void): ColumnDef<Pedimento>[] {
|
||||
return renderSnippet(dateSnippet, { date: formatDate(row.original.pedimento_dates?.payment_date) });
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorKey: "pedimento_config_update_rectification.pediment_rectifed_18",
|
||||
header: "Pedimento 18",
|
||||
cell: ({ row }) => {
|
||||
const ped18Snippet = createRawSnippet<[{ value?: string | null }]>((getValue) => {
|
||||
const { value } = getValue();
|
||||
return {
|
||||
render: () =>
|
||||
`<div class="text-sm">${value || '-'}</div>`
|
||||
};
|
||||
});
|
||||
return renderSnippet(ped18Snippet, { value: row.original.pedimento_config_update_rectification?.pediment_rectifed_18 });
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorKey: "pedimento_config_update_rectification.r1",
|
||||
header: "Pedimento R1",
|
||||
cell: ({ row }) => {
|
||||
const r1Snippet = createRawSnippet<[{ value?: string | null }]>((getValue) => {
|
||||
const { value } = getValue();
|
||||
return {
|
||||
render: () =>
|
||||
`<div class="text-sm">${value || '-'}</div>`
|
||||
};
|
||||
});
|
||||
return renderSnippet(r1Snippet, { value: row.original.pedimento_config_update_rectification?.r1 });
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorKey: "pedimento_validation.electronic_signature",
|
||||
header: "Acuse Electrónico",
|
||||
|
||||
Reference in New Issue
Block a user