Skip to content

Commit 666b0e4

Browse files
authored
Merge pull request #74 from chechojgb/buttonsLovers
Buttons lovers
2 parents 8401343 + d277808 commit 666b0e4

File tree

12 files changed

+1008
-180
lines changed

12 files changed

+1008
-180
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
use Illuminate\Support\Facades\Auth;
7+
use Illuminate\Support\Facades\DB;
8+
use Inertia\Inertia;
9+
10+
class BLInventarioController extends Controller
11+
{
12+
public function index()
13+
{
14+
$user = Auth::user();
15+
return Inertia::render('BLInventario', [
16+
'user' => $user,
17+
]);
18+
}
19+
}

app/Http/Controllers/BLMarcacionController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,5 @@ public function actualizarEstado(BLPedidoItem $item, Request $request)
109109
]);
110110
}
111111
}
112+
113+

app/Http/Controllers/BLPedidosController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class BLPedidosController extends Controller
2626
public function index()
2727
{
2828
$user = Auth::user();
29-
$productos = BlProducto::with(['color', 'empaques.movimientos'])
29+
$productos = BlProducto::with(['color', 'empaques'])
3030
->get()
3131
->map(function ($producto) {
3232
return [
@@ -36,10 +36,8 @@ public function index()
3636
'color_nombre' => $producto->color->nombre,
3737
'descripcion' => $producto->descripcion,
3838
'stock_total' => $producto->empaques
39-
->where('estado', 'disponible') // Filtra solo empaques disponibles
40-
->sum(function ($empaque) {
41-
return $empaque->movimientos->sum('cantidad') * $empaque->cantidad_por_empaque;
42-
}),
39+
->where('estado', 'disponible') // ✅ solo empaques disponibles
40+
->sum('cantidad_por_empaque'), // ✅ sumamos directamente la cantidad
4341
];
4442
})
4543
->filter(function ($producto) {

app/Http/Controllers/BlCuentaCobroController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ class BlCuentaCobroController extends Controller
1919
public function index()
2020
{
2121
$user = Auth::user();
22+
$cuentas = BlCuentaCobro::with(['items.marcacion.pedido.items.empaque.producto', 'usuario'])->get();
2223
return Inertia::render('BLCuentaCobro', [
2324
'user' => $user,
25+
'cuentasCobro' => $cuentas,
2426
]);
2527
}
2628

app/Http/Controllers/BlProductoController.php

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ class BlProductoController extends Controller
2222
{
2323
public function index()
2424
{
25-
$productos = BlProducto::with(['color', 'empaques.movimientos'])
25+
$productos = BlProducto::with(['color', 'empaques'])
2626
->get()
2727
->map(function ($producto) {
2828
return [
2929
'id' => $producto->id,
3030
'tipo_producto' => $producto->tipo_producto,
3131
'tamanio' => $producto->tamanio,
32-
'color_nombre' => $producto->color->codigo,
32+
'color_nombre' => $producto->color->nombre,
3333
'descripcion' => $producto->descripcion,
34-
'stock_total' => $producto->empaques->sum(function ($empaque) {
35-
return $empaque->movimientos->sum('cantidad') * $empaque->cantidad_por_empaque;
36-
}),
34+
'stock_total' => $producto->empaques
35+
->where('estado', 'disponible')
36+
->sum('cantidad_por_empaque'),
3737
];
3838
});
3939
// dd($productos->pluck('descripcion'));
@@ -62,32 +62,8 @@ public function indexHistorico()
6262
}),
6363
];
6464
});
65-
$entrada = BlMovimiento::with(['movible.empaque.producto.color', 'usuario'])
66-
->where('tipo', 'entrada')
67-
->get()
68-
->map(function ($movimiento) {
69-
if ($movimiento->movible instanceof \App\Models\BLPedidoItem) {
70-
$item = $movimiento->movible;
71-
$producto = $item->empaque->producto;
72-
73-
return [
74-
'id' => $movimiento->id,
75-
'pedido_id' => $item->pedido_id,
76-
'producto' => $producto->tipo_producto,
77-
'tamanio' => $producto->tamanio,
78-
'color' => $producto->color->nombre,
79-
'cantidad_empaques' => $item->cantidad_empaques,
80-
'cantidad' => $movimiento->cantidad,
81-
'motivo' => $movimiento->motivo,
82-
'usuario' => $movimiento->usuario->name,
83-
'fecha' => $movimiento->created_at->format('d-m-Y H:i'),
84-
'tipo' => $movimiento->tipo,
85-
];
86-
}
87-
88-
return null; // si el movible no es un BLPedidoItem
89-
})
90-
->filter();
65+
$entrada = BlMovimiento::with(['movible.producto', 'usuario'])
66+
->where('tipo', 'entrada')->get();
9167
$marcacion = BlMovimiento::with(['movible', 'usuario'])
9268
->where('tipo', 'pedido')
9369
->whereIn('motivo', [

resources/js/components/BL/historicoBL.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ export default function EntradaBL({ historico }) {
3535
>
3636
<div className="space-y-1">
3737
<p className="font-semibold ">
38-
{item.producto || "No existe"} - {item.tamanio} - {item.color}
38+
{item.movible.producto.descripcion || "No existe"}
3939
</p>
4040
<p className="text-xs ">
41-
{item.fecha}{item.tipo || "sin tipo"}{" "}
42-
<span className="font-medium">{item.usuario}</span>
41+
{format(new Date(item.updated_at), "dd-MM-yyyy HH:mm")}{item.tipo || "sin tipo"}{" "}
42+
<span className="font-medium">{item.usuario.name}</span>
4343
</p>
4444
</div>
4545
<Badge
4646
variant="outline"
4747
className="text-sm border-green-300 text-green-600"
4848
>
49-
{item.cantidad_por_empaque} und
49+
{item.movible.cantidad_por_empaque} und
5050
</Badge>
5151
</div>
5252
))

resources/js/components/BL/tablaMarcacionBL.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export default function TablaMarcacionBL({itemsPedidos, search}) {
165165
const marcacion = row.original.marcaciones?.[0];
166166
const tieneUsuario = marcacion?.trabajador;
167167
const esCompletado = row.original.estado === "completado";
168-
const noEsPagado = marcacion?.pagado === 0;
168+
const noEsPagado = !marcacion?.pagado;
169169
const esElegible = tieneUsuario && esCompletado && noEsPagado;
170170

171171
return (

resources/js/components/app-sidebar.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
SidebarHeader,
99
SidebarMenu,
1010
SidebarMenuButton,
11-
SidebarMenuItem
11+
SidebarMenuItem,
1212
} from '@/components/ui/sidebar';
1313
import { Link, usePage } from '@inertiajs/react';
1414
import {
@@ -26,7 +26,8 @@ import {
2626
ListOrderedIcon,
2727
BadgeCheck,
2828
BadgeDollarSign,
29-
PcCase
29+
PcCase,
30+
BookMarked
3031
} from 'lucide-react';
3132
import AppLogo from './app-logo';
3233
import { userHasArea } from '@/components/utils/useAuthUtils';
@@ -124,6 +125,12 @@ const staticNavItems = [
124125
href: '/BLproductosInventario/BLCuentaCobro',
125126
icon: BadgeDollarSign,
126127
proyectosPermitidos: ['Button Lovers', 'AZZU', 'Button LoversM'],
128+
},
129+
{
130+
title: 'Inventario',
131+
href: '/BLproductosInventario/BLInventario',
132+
icon: BookMarked,
133+
proyectosPermitidos: ['Button Lovers', 'AZZU', 'Button LoversM'],
127134
}
128135

129136
];

0 commit comments

Comments
 (0)