correjido un error que no permitia buscar por usuario y añadido soporte

de busqueda por estado

Signed-off-by: fede <federico.nicolas.polidoro@gmail.com>
This commit is contained in:
fede committed 2026-11-28 16:32:40 -03:00
1 parent fe5b5d7a00
commit 837fd8fa44
9 files changed
+112 -22

No files matched your search

+74 -18
View File
@@ -3,6 +3,8 @@
import {
Button,
DataTableSkeleton,
DatePicker,
DatePickerInput,
InlineNotification,
Table,
TableBody,
@@ -31,7 +33,9 @@
});
let facturas = $derived<Factura[]>(Array.isArray(data.facturas) ? data.facturas : []);
let filtros = $derived(data.filtros ?? { numero: '', cliente: '', estado: '', desde: '', hasta: '' });
let filtros = $derived(
data.filtros ?? { numero: '', cliente: '', estado: '', desde: '', hasta: '' }
);
let cargando = $derived(data.facturas === undefined || data.facturas === null);
let puedeVentas = $derived(getPermissions().includes(13));
@@ -104,16 +108,25 @@
<div class="mb-4 flex flex-wrap items-center justify-between gap-2">
<h1 class="page-title">Gestión de Facturas</h1>
{#if puedeVentas}
<Button icon={Add} onclick={() => goto('/facturas/nueva')}>
Nueva Factura
</Button>
<Button icon={Add} onclick={() => goto('/facturas/nueva')}>Nueva Factura</Button>
{/if}
</div>
{#if !puedeVentas}
<InlineNotification kind="warning" title="Sin permisos" subtitle="No tenés permiso para gestionar ventas y facturación." hideCloseButton />
<InlineNotification
kind="warning"
title="Sin permisos"
subtitle="No tenés permiso para gestionar ventas y facturación."
hideCloseButton
/>
{:else}
<form class="mb-6 flex flex-wrap items-end gap-4" onsubmit={(e) => { e.preventDefault(); buscar(); }}>
<form
class="mb-6 flex flex-wrap items-end gap-4"
onsubmit={(e) => {
e.preventDefault();
buscar();
}}
>
<div class="min-w-56 flex-1">
<TextInput labelText="Buscar" placeholder="N° factura o cliente" bind:value={numero} />
</div>
@@ -127,12 +140,15 @@
<SelectItem value="PAGADA" text="Pagada" />
<SelectItem value="CANCELADA" text="Cancelada" />
</Select>
<div class="min-w-36">
<TextInput labelText="Desde" placeholder="YYYY-MM-DD" bind:value={desde} />
</div>
<div class="min-w-36">
<TextInput labelText="Hasta" placeholder="YYYY-MM-DD" bind:value={hasta} />
</div>
<DatePicker
datePickerType="range"
dateFormat="Y-m-d"
bind:valueFrom={desde}
bind:valueTo={hasta}
>
<DatePickerInput labelText="Desde" placeholder="yyyy-mm-dd" />
<DatePickerInput labelText="Hasta" placeholder="yyyy-mm-dd" />
</DatePicker>
<div class="flex gap-2">
<Button type="submit" icon={Search}>Buscar</Button>
<Button kind="ghost" icon={Close} onclick={limpiar}>Limpiar</Button>
@@ -147,7 +163,19 @@
{/if}
{#if cargando}
<DataTableSkeleton headers={[{ key: 'numero', value: 'N° Factura' }, { key: 'cliente', value: 'Cliente' }, { key: 'fecha', value: 'Fecha' }, { key: 'total', value: 'Total' }, { key: 'estado', value: 'Estado' }]} rows={5} size="compact" showHeader={false} showToolbar={false} />
<DataTableSkeleton
headers={[
{ key: 'numero', value: 'N° Factura' },
{ key: 'cliente', value: 'Cliente' },
{ key: 'fecha', value: 'Fecha' },
{ key: 'total', value: 'Total' },
{ key: 'estado', value: 'Estado' }
]}
rows={5}
size="compact"
showHeader={false}
showToolbar={false}
/>
{:else if facturas.length === 0}
<TableContainer title="Facturas">
<Table>
@@ -193,10 +221,34 @@
</TableCell>
<TableCell>
<div class="flex flex-wrap gap-1">
<Button kind="ghost" size="small" icon={View} onclick={() => { facturaVer = f; openVer = true; }}>Ver</Button>
<Button kind="ghost" size="small" icon={Edit} disabled={f.estado === 'CANCELADA' || f.estado === 'PAGADA'}>Modificar</Button>
<Button kind="ghost" size="small" icon={Money} disabled={f.estado === 'CANCELADA' || f.estado === 'PAGADA'}>Registrar Pago</Button>
<Button kind="danger-ghost" size="small" icon={Close} disabled={f.estado === 'CANCELADA'}>Cancelar</Button>
<Button
kind="ghost"
size="small"
icon={View}
onclick={() => {
facturaVer = f;
openVer = true;
}}>Ver</Button
>
<Button
kind="ghost"
size="small"
icon={Edit}
disabled={f.estado === 'CANCELADA' || f.estado === 'PAGADA'}>Modificar</Button
>
<Button
kind="ghost"
size="small"
icon={Money}
disabled={f.estado === 'CANCELADA' || f.estado === 'PAGADA'}
>Registrar Pago</Button
>
<Button
kind="danger-ghost"
size="small"
icon={Close}
disabled={f.estado === 'CANCELADA'}>Cancelar</Button
>
</div>
</TableCell>
</TableRow>
@@ -221,7 +273,11 @@
<p class="mb-2 font-semibold">Ítems</p>
<ul class="list-disc pl-5">
{#each facturaVer.detalles as d (d.repuestoId)}
<li>Repuesto {d.repuestoId} — cant. {d.cantidad} × {formatMonto(d.precioUnitario)} = {formatMonto(d.subtotal)}</li>
<li>
Repuesto {d.repuestoId} — cant. {d.cantidad} × {formatMonto(d.precioUnitario)} = {formatMonto(
d.subtotal
)}
</li>
{/each}
</ul>
</div>