Monedero configurable por servicio y artículo
- Campo genera_monedero (default true) en servicios e items de inventario - Puntos proporcionales a las líneas elegibles al liquidar la venta - Toggle con icono Wallet en Servicios e Inventario
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { FC } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { Boxes, Plus, AlertTriangle, PackageCheck, ArrowDownToLine, ArrowUpFromLine, History } from 'lucide-react';
|
||||
import { Boxes, Plus, AlertTriangle, PackageCheck, ArrowDownToLine, ArrowUpFromLine, History, Wallet } from 'lucide-react';
|
||||
import Layout from '../components/Layout';
|
||||
import MovimientosPanel from '../components/inventario/MovimientosPanel';
|
||||
import AlertasPanel from '../components/inventario/AlertasPanel';
|
||||
@@ -153,6 +153,16 @@ const Inventario: FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const toggleMonedero = async (it: InventoryItem) => {
|
||||
try {
|
||||
await odooApi.updateInventoryItem(it.id, { genera_monedero: it.genera_monedero === false });
|
||||
toast.success(it.genera_monedero === false ? 'El artículo ahora genera monedero' : 'El artículo ya no genera monedero');
|
||||
load();
|
||||
} catch {
|
||||
toast.error('Error al actualizar monedero');
|
||||
}
|
||||
};
|
||||
|
||||
const lvl = summary.levels;
|
||||
|
||||
return (
|
||||
@@ -276,6 +286,17 @@ const Inventario: FC = () => {
|
||||
<td className="px-4 py-3 text-theme-muted">{it.expiry_date || '—'}</td>
|
||||
<td className="px-4 py-3">
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={() => toggleMonedero(it)}
|
||||
title={it.genera_monedero === false ? 'No genera monedero — clic para activar' : 'Genera monedero — clic para desactivar'}
|
||||
>
|
||||
<Wallet
|
||||
size={14}
|
||||
className={it.genera_monedero === false ? 'text-theme-muted opacity-50' : 'text-theme-accent'}
|
||||
/>
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={() => openHistory(it)}><History size={14} /></Button>
|
||||
<Button size="sm" onClick={() => openAdjust(it)}>Ajustar</Button>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { FC } from 'react';
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Star, Edit2, Plus, Clock, Tag, Package, Search } from 'lucide-react';
|
||||
import { Star, Wallet, Edit2, Plus, Clock, Tag, Package, Search } from 'lucide-react';
|
||||
import Layout from '../components/Layout';
|
||||
import {
|
||||
Card,
|
||||
@@ -123,6 +123,17 @@ const Servicios: FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const toggleMonedero = async (s: Service) => {
|
||||
try {
|
||||
await odooApi.updateService(s.id, { genera_monedero: s.genera_monedero === false });
|
||||
toast.success(s.genera_monedero === false ? 'El servicio ahora genera monedero' : 'El servicio ya no genera monedero');
|
||||
await load();
|
||||
} catch (err) {
|
||||
toast.error('Error al actualizar monedero');
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
const openCreate = () => {
|
||||
setEditing(null);
|
||||
setForm(emptyForm);
|
||||
@@ -273,18 +284,31 @@ const Servicios: FC = () => {
|
||||
/>
|
||||
<h4 className="font-medium text-theme-heading pr-2 truncate">{s.name}</h4>
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => toggleFavorite(s)}
|
||||
title={s.is_favorite ? 'Quitar favorito' : 'Marcar favorito'}
|
||||
>
|
||||
<Star
|
||||
size={18}
|
||||
className={s.is_favorite ? 'text-amber-500' : 'text-theme-muted'}
|
||||
fill={s.is_favorite ? 'currentColor' : 'none'}
|
||||
/>
|
||||
</Button>
|
||||
<div className="flex items-center shrink-0">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => toggleMonedero(s)}
|
||||
title={s.genera_monedero === false ? 'No genera monedero — clic para activar' : 'Genera monedero — clic para desactivar'}
|
||||
>
|
||||
<Wallet
|
||||
size={18}
|
||||
className={s.genera_monedero === false ? 'text-theme-muted opacity-50' : 'text-theme-accent'}
|
||||
/>
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => toggleFavorite(s)}
|
||||
title={s.is_favorite ? 'Quitar favorito' : 'Marcar favorito'}
|
||||
>
|
||||
<Star
|
||||
size={18}
|
||||
className={s.is_favorite ? 'text-amber-500' : 'text-theme-muted'}
|
||||
fill={s.is_favorite ? 'currentColor' : 'none'}
|
||||
/>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2 text-xs text-theme-muted mb-4">
|
||||
<span className="inline-flex items-center bg-theme-bg rounded-md px-2 py-0.5">
|
||||
|
||||
@@ -239,6 +239,7 @@ export interface Service {
|
||||
color: string;
|
||||
service_group: string;
|
||||
is_favorite: boolean;
|
||||
genera_monedero?: boolean;
|
||||
}
|
||||
|
||||
export interface Doctor {
|
||||
@@ -383,6 +384,7 @@ export interface InventoryItem {
|
||||
expiry_date: string | null;
|
||||
last_count_date: string | null;
|
||||
active: boolean;
|
||||
genera_monedero?: boolean;
|
||||
notes: string;
|
||||
stock_level: InventoryLevel;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user