feat: hecha funcionalidad del cu-12

Signed-off-by: fede <federico.nicolas.polidoro@gmail.com>
This commit is contained in:
fede committed 2026-11-23 20:09:25 -03:00
1 parent 5a8d4bc2d6
commit 37d357357a
14 files changed
+672 -116

No files matched your search

+5 -80
View File
@@ -1,19 +1,8 @@
<script lang="ts">
import Header from '$lib/components/Header.svelte';
import {
Button,
DataTableSkeleton,
InlineNotification,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableHeader,
TableRow
} from 'carbon-components-svelte';
import { InventoryManagement, Play, Return } from 'carbon-icons-svelte';
import { goto, invalidate } from '$app/navigation';
import { Button, DataTableSkeleton, InlineNotification } from 'carbon-components-svelte';
import { InventoryManagement, Return, Time } from 'carbon-icons-svelte';
import { goto } from '$app/navigation';
import ModalStructured from '$lib/components/ModalStructured.svelte';
import FiltrosStock from './FiltrosStock.svelte';
import TablaStock from './TablaStock.svelte';
@@ -24,8 +13,7 @@
import IngresarStockForm from './IngresarStockForm.svelte';
import DevolucionStockForm from './DevolucionStockForm.svelte';
import { formatearCantidad } from './formatoCantidad';
import { liberarReserva } from '$lib/hooks/stock/liberarReserva';
import type { Almacen, Cliente, ReservaStock, StockItem } from '../../types';
import type { Almacen, Cliente, StockItem } from '../../types';
let { data } = $props();
@@ -38,7 +26,6 @@
let stock = $derived<StockItem[]>(Array.isArray(data.stock) ? data.stock : []);
let almacenes = $derived<Almacen[]>(Array.isArray(data.almacenes) ? data.almacenes : []);
let clientes = $derived<Cliente[]>(Array.isArray(data.clientes) ? data.clientes : []);
let reservas = $derived<ReservaStock[]>(Array.isArray(data.reservas) ? data.reservas : []);
let filtros = $derived(data.filtros ?? { q: '', almacenId: 0, estado: '' });
let cargando = $derived(data.stock === undefined || data.stock === null);
@@ -92,21 +79,6 @@
};
openInfo = true;
}
async function liberar(r: ReservaStock) {
const res = await liberarReserva(r.ID);
if (typeof res === 'string') {
error = res;
return;
}
await invalidate('stock:load');
}
function fecha(v?: string) {
if (!v) return '-';
const d = new Date(v);
return Number.isNaN(d.getTime()) ? '-' : d.toLocaleDateString();
}
</script>
<Header />
@@ -121,6 +93,7 @@
<Button kind="tertiary" icon={Return} onclick={() => (openDevolucion = true)}>
Registrar Devolución
</Button>
<Button kind="tertiary" icon={Time} onclick={() => goto('/stock/reservas')}>Reservas</Button>
</div>
</div>
@@ -154,54 +127,6 @@
onVer={verRegistro}
/>
{/if}
{#if data.reservasError}
<InlineNotification
kind="error"
title="Reservas"
subtitle={data.reservasError}
hideCloseButton
/>
{/if}
{#if !cargando}
<TableContainer title="Reservas activas">
<Table>
<TableHead>
<TableRow>
<TableHeader>Repuesto</TableHeader>
<TableHeader>Almacén</TableHeader>
<TableHeader>Cantidad</TableHeader>
<TableHeader>Cliente</TableHeader>
<TableHeader>Vencimiento</TableHeader>
<TableHeader>Acciones</TableHeader>
</TableRow>
</TableHead>
<TableBody>
{#if reservas.length === 0}
<TableRow>
<TableCell colspan={6}>No hay reservas activas.</TableCell>
</TableRow>
{:else}
{#each reservas as r (r.ID)}
<TableRow>
<TableCell>{r.repuesto?.nombre ?? r.repuesto_id}</TableCell>
<TableCell>{r.almacen?.codigo ?? r.almacen_id}</TableCell>
<TableCell>{formatearCantidad(r.cantidad)}</TableCell>
<TableCell>{r.cliente?.nombre ?? '-'}</TableCell>
<TableCell>{fecha(r.fecha_vencimiento)}</TableCell>
<TableCell class="acciones-cell">
<Button kind="ghost" size="small" icon={Play} onclick={() => liberar(r)}>
Liberar
</Button>
</TableCell>
</TableRow>
{/each}
{/if}
</TableBody>
</Table>
</TableContainer>
{/if}
</div>
<IngresarStockForm bind:open={openIngreso} {almacenes} onClose={() => (openIngreso = false)} />