fase 2.2: impuestos configurables por instancia (tasa por servicio/articulo, calculo por linea, desglose en POS/tickets/estado de cuenta, reporte de impuestos, permiso ventas.impuestos) con defaults apagados

This commit is contained in:
2026-10-11 08:04:11 +00:00
parent 28a690aa0f
commit 358b85afcd
22 changed files with 1105 additions and 30 deletions

View File

@@ -14,8 +14,9 @@ import SucursalesPanel from '../components/SucursalesPanel';
import CategoriasPanel from '../components/CategoriasPanel';
import TerminologiaPanel from '../components/TerminologiaPanel';
import { Card, Button, Input, PageHeader, toast } from '../components/ui';
import { odooApi, type Doctor, type ClinicSettings, BRAND_DEFAULT, CLINIC_SETTINGS_DEFAULT } from '../services/odoo';
import { odooApi, type Doctor, type ClinicSettings, type ImpuestosSettings, BRAND_DEFAULT, CLINIC_SETTINGS_DEFAULT, IMPUESTOS_DEFAULT } from '../services/odoo';
import { useAuth } from '../lib/auth';
import { publicarClinicSettings } from '../lib/clinic-settings';
const TABS = [
{ key: 'clinica', label: 'Clínica' },
@@ -101,7 +102,11 @@ const Configuracion: FC = () => {
} catch {
localStorage.removeItem(LEGACY_STORAGE_KEY);
}
if (alive) setSettings(next);
if (alive) setSettings({
...CLINIC_SETTINGS_DEFAULT,
...next,
impuestos: { ...IMPUESTOS_DEFAULT, ...(next.impuestos || {}) },
});
})
.catch(() => {
toast.error('No se pudieron cargar los ajustes de la clínica');
@@ -115,7 +120,10 @@ const Configuracion: FC = () => {
const save = async () => {
try {
const res = await odooApi.putClinicSettings({ ...settings, motivo: 'Ajustes desde Configuración' });
if (res.status === 'success') setSettings(res.settings);
if (res.status === 'success') {
setSettings(res.settings);
publicarClinicSettings(res.settings);
}
toast.success('Configuración guardada');
} catch (err) {
const msg = (err as { response?: { data?: { message?: string } } })?.response?.data?.message;
@@ -127,6 +135,13 @@ const Configuracion: FC = () => {
setSettings((prev) => ({ ...prev, [field]: value }));
};
const updateImpuesto = (patch: Partial<ImpuestosSettings>) => {
setSettings((prev) => ({
...prev,
impuestos: { ...IMPUESTOS_DEFAULT, ...prev.impuestos, ...patch },
}));
};
// ---- Tipo de cambio USD/MXN ----
const [tcCurrent, setTcCurrent] = useState<{ rate: number; date: string; source: string } | null>(null);
const [tcInput, setTcInput] = useState('');
@@ -506,6 +521,74 @@ const Configuracion: FC = () => {
<p className="text-xs text-theme-muted">
Moneda base: <span className="font-medium text-theme-heading">{settings.moneda_base || 'MXN'}</span>
</p>
{/* Impuestos (por instancia). Apagados = comportamiento de
siempre: sin cálculo, sin desglose y sin renglón en tickets. */}
<div className="border border-theme-border rounded-xl p-3 space-y-3">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<Percent size={16} className="text-theme-muted" />
<span className="text-sm font-medium text-theme-heading">Impuestos</span>
</div>
<label className="flex items-center gap-2 text-sm text-theme-muted cursor-pointer">
<input
type="checkbox"
checked={settings.impuestos.activo}
onChange={(e) => updateImpuesto({ activo: e.target.checked })}
className="h-4 w-4 rounded border-theme-border-strong"
/>
Calcular impuestos
</label>
</div>
<p className="text-xs text-theme-muted">
{settings.impuestos.activo
? 'El impuesto se muestra y se cobra en POS, tickets y reportes.'
: 'Apagado: los totales, tickets y reportes salen exactamente como hoy.'}
</p>
{settings.impuestos.activo && (
<>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<Input
label="Nombre del impuesto"
value={settings.impuestos.nombre}
onChange={(e) => updateImpuesto({ nombre: e.target.value })}
placeholder="IVA"
/>
<Input
label="Tasa por defecto (%)"
type="number"
min={0}
max={100}
step={0.01}
value={String(settings.impuestos.tasa_default)}
onChange={(e) => updateImpuesto({ tasa_default: parseFloat(e.target.value) || 0 })}
/>
</div>
<Input
label="Opciones de tasa (%)"
value={settings.impuestos.tasa_opciones.join(', ')}
onChange={(e) => {
const opciones = e.target.value
.split(',')
.map((v) => parseFloat(v.trim()))
.filter((v) => !Number.isNaN(v) && v >= 0 && v <= 100);
updateImpuesto({ tasa_opciones: opciones.length ? opciones : [0] });
}}
placeholder="0, 8, 16"
/>
<label className="flex items-center gap-2 text-sm text-theme-muted cursor-pointer">
<input
type="checkbox"
checked={settings.impuestos.precios_incluyen_impuesto}
onChange={(e) => updateImpuesto({ precios_incluyen_impuesto: e.target.checked })}
className="h-4 w-4 rounded border-theme-border-strong"
/>
Los precios capturados ya incluyen impuesto
</label>
</>
)}
</div>
<div className="pt-2">
<Button onClick={save}>
<Save size={16} className="mr-2" />

View File

@@ -10,6 +10,7 @@ import ConteoPrint from '../components/inventario/ConteoPrint';
import { Card, Button, Input, Select, TextArea, Modal, PageHeader, EmptyState, Skeleton, toast } from '../components/ui';
import { odooApi } from '../services/odoo';
import type { InventoryItem, InventoryMove, InventoryKind, InventoryLevel, InventoryMoveType, InventorySummary, InventoryConteo } from '../services/odoo';
import { useClinicSettings } from '../lib/clinic-settings';
const TABS = [
{ key: 'items', label: 'Items' },
@@ -61,12 +62,14 @@ const MOVE_OPTIONS = [
const emptyItem: Partial<InventoryItem> = {
name: '', kind: 'producto', sku: '', category: '', unit: 'pieza',
qty: 0, qty_optimal: 0, qty_min: 0, cost: 0, price: 0, expiry_date: null, notes: '',
tax_use_default: true, tax_rate: 0,
};
const Inventario: FC = () => {
const [searchParams, setSearchParams] = useSearchParams();
const tab = searchParams.get('tab') || 'items';
const setTab = (t: string) => setSearchParams({ tab: t });
const impuestos = useClinicSettings().impuestos;
const [items, setItems] = useState<InventoryItem[]>([]);
const [summary, setSummary] = useState<InventorySummary>({ levels: { out: 0, critical: 0, low: 0, optimal: 0 }, total_value: 0, count: 0 });
const [loading, setLoading] = useState(true);
@@ -178,7 +181,8 @@ const Inventario: FC = () => {
const openEdit = (it: InventoryItem) => {
setEditItem(it);
setEditForm({ name: it.name, sku: it.sku, category: it.category, unit: it.unit,
cost: it.cost, price: it.price, qty_min: it.qty_min, qty_optimal: it.qty_optimal, notes: it.notes });
cost: it.cost, price: it.price, qty_min: it.qty_min, qty_optimal: it.qty_optimal, notes: it.notes,
tax_use_default: it.tax_use_default !== false, tax_rate: it.tax_rate ?? 0 });
};
const saveEdit = async () => {
@@ -482,6 +486,22 @@ const Inventario: FC = () => {
<Input label="Existencia inicial" type="number" min="0" step="0.01" value={String(newForm.qty ?? 0)} onChange={(e) => setNewForm({ ...newForm, qty: parseFloat(e.target.value) || 0 })} />
<Input label="Costo unitario" type="number" min="0" step="0.01" value={String(newForm.cost ?? 0)} onChange={(e) => setNewForm({ ...newForm, cost: parseFloat(e.target.value) || 0 })} />
<Input label="Precio venta" type="number" min="0" step="0.01" value={String(newForm.price ?? 0)} onChange={(e) => setNewForm({ ...newForm, price: parseFloat(e.target.value) || 0 })} />
{impuestos.activo && (
<Select
label={`Impuesto (${impuestos.nombre})`}
options={[
{ value: 'default', label: `Usar tasa por defecto (${impuestos.tasa_default}%)` },
...[...new Set([...(impuestos.tasa_opciones || []), newForm.tax_rate ?? 0])]
.sort((a, b) => a - b)
.map((o) => ({ value: String(o), label: `${o}%` })),
]}
value={newForm.tax_use_default !== false ? 'default' : String(newForm.tax_rate ?? 0)}
onChange={(e) => {
const v = e.target.value;
setNewForm({ ...newForm, tax_use_default: v === 'default', tax_rate: v === 'default' ? 0 : parseFloat(v) || 0 });
}}
/>
)}
<Input label="Stock mínimo (crítico)" type="number" min="0" step="0.01" value={String(newForm.qty_min ?? 0)} onChange={(e) => setNewForm({ ...newForm, qty_min: parseFloat(e.target.value) || 0 })} />
<Input label="Nivel óptimo" type="number" min="0" step="0.01" value={String(newForm.qty_optimal ?? 0)} onChange={(e) => setNewForm({ ...newForm, qty_optimal: parseFloat(e.target.value) || 0 })} />
{newForm.kind === 'consumible' && (
@@ -500,6 +520,22 @@ const Inventario: FC = () => {
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div className="sm:col-span-2"><Input label="Nombre" value={editForm.name || ''} onChange={(e) => setEditForm({ ...editForm, name: e.target.value })} /></div>
<Input label="Precio venta" type="number" min="0" step="0.01" value={String(editForm.price ?? 0)} onChange={(e) => setEditForm({ ...editForm, price: parseFloat(e.target.value) || 0 })} />
{impuestos.activo && (
<Select
label={`Impuesto (${impuestos.nombre})`}
options={[
{ value: 'default', label: `Usar tasa por defecto (${impuestos.tasa_default}%)` },
...[...new Set([...(impuestos.tasa_opciones || []), editForm.tax_rate ?? 0])]
.sort((a, b) => a - b)
.map((o) => ({ value: String(o), label: `${o}%` })),
]}
value={editForm.tax_use_default !== false ? 'default' : String(editForm.tax_rate ?? 0)}
onChange={(e) => {
const v = e.target.value;
setEditForm({ ...editForm, tax_use_default: v === 'default', tax_rate: v === 'default' ? 0 : parseFloat(v) || 0 });
}}
/>
)}
<Input label="Costo unitario" type="number" min="0" step="0.01" value={String(editForm.cost ?? 0)} onChange={(e) => setEditForm({ ...editForm, cost: parseFloat(e.target.value) || 0 })} />
<Input label="SKU / Código" value={editForm.sku || ''} onChange={(e) => setEditForm({ ...editForm, sku: e.target.value })} />
<Input label="Línea / Categoría" value={editForm.category || ''} onChange={(e) => setEditForm({ ...editForm, category: e.target.value })} />

View File

@@ -21,6 +21,7 @@ import {
import { odooApi, type Service, type Patient, type InventoryItem, type PosCheckoutResult, type Doctor, type Paquete } from '../services/odoo';
import type { PatientPackage } from '../services/odoo';
import { useAuth } from '../lib/auth';
import { useClinicSettings } from '../lib/clinic-settings';
const fmtMoney = (n: number) =>
(n || 0).toLocaleString('es-MX', { style: 'currency', currency: 'MXN', maximumFractionDigits: 2 });
@@ -49,11 +50,15 @@ interface TicketLine {
sesiones?: number;
stock?: number;
unit?: string;
/** Tasa de impuesto (%) de la línea (0 con impuestos apagados) */
tax_rate?: number;
}
const Pos: FC = () => {
const { openPatient } = usePatientDrawer();
const { can } = useAuth();
const impuestos = useClinicSettings().impuestos;
const puedeImpuestos = can('ventas.impuestos');
const [searchParams, setSearchParams] = useSearchParams();
// Catálogo
const [catMode, setCatMode] = useState<'servicios' | 'paquetes' | 'articulos'>('servicios');
@@ -347,16 +352,28 @@ const Pos: FC = () => {
service_id: p.service_id ?? undefined,
paquete_id: p.id,
sesiones: p.sessions,
tax_rate: tasaDePaquete(p),
}];
});
};
// ---- Ticket ----
// Tasa de impuesto que corresponde a un platillo del catálogo (0 si apagado).
const tasaDeServicio = (s: Service) =>
impuestos.activo ? (s.tax_use_default !== false ? impuestos.tasa_default : (s.tax_rate ?? 0)) : 0;
const tasaDeItem = (it: InventoryItem) =>
impuestos.activo ? (it.tax_use_default !== false ? impuestos.tasa_default : (it.tax_rate ?? 0)) : 0;
const tasaDePaquete = (p: Paquete) => {
if (!impuestos.activo) return 0;
const servicio = services.find((s) => s.id === p.service_id);
return servicio ? tasaDeServicio(servicio) : impuestos.tasa_default;
};
const addLine = (service: Service) => { setLines((prev) => {
const key = `s-${service.id}`;
const found = prev.find((l) => l.key === key);
if (found) return prev.map((l) => (l.key === key ? { ...l, qty: l.qty + 1 } : l));
return [...prev, { key, name: service.name, qty: 1, price: service.price, service_id: service.id }];
return [...prev, { key, name: service.name, qty: 1, price: service.price, service_id: service.id, tax_rate: tasaDeServicio(service) }];
});
};
@@ -365,7 +382,7 @@ const Pos: FC = () => {
const key = `i-${item.id}`;
const found = prev.find((l) => l.key === key);
if (found) return prev.map((l) => (l.key === key ? { ...l, qty: l.qty + 1 } : l));
return [...prev, { key, name: item.name, qty: 1, price: item.price || 0, item_id: item.id, stock: item.qty, unit: item.unit }];
return [...prev, { key, name: item.name, qty: 1, price: item.price || 0, item_id: item.id, stock: item.qty, unit: item.unit, tax_rate: tasaDeItem(item) }];
});
};
@@ -380,9 +397,20 @@ const Pos: FC = () => {
if (window.confirm('¿Vaciar el ticket?')) setLines([]);
};
const subtotal = lines.reduce((a, l) => a + l.qty * l.price, 0);
// Desglose del ticket. Con los impuestos apagados: bruto === base, impuesto 0
// y el total sale exactamente igual que antes.
const bruto = lines.reduce((a, l) => a + l.qty * l.price, 0);
const impuestoLinea = (l: TicketLine): number => {
if (!impuestos.activo) return 0;
const t = l.tax_rate ?? 0;
if (t <= 0) return 0;
const b = l.qty * l.price;
return impuestos.precios_incluyen_impuesto ? b - b / (1 + t / 100) : (b * t) / 100;
};
const impuesto = impuestos.activo ? lines.reduce((a, l) => a + impuestoLinea(l), 0) : 0;
const subtotal = impuestos.activo && impuestos.precios_incluyen_impuesto ? bruto - impuesto : bruto;
const discountNum = Math.min(parseFloat(discount) || 0, subtotal);
const total = Math.max(0, subtotal - discountNum);
const total = Math.max(0, subtotal - discountNum + impuesto);
const numItems = lines.reduce((a, l) => a + l.qty, 0);
const puntosPaciente = paciente?.wallet_points ?? 0;
const puedePuntos = puntosPaciente >= total && total > 0;
@@ -443,6 +471,7 @@ const Pos: FC = () => {
...(l.paquete_id ? { paquete_id: l.paquete_id, description: l.name } : {}),
quantity: l.qty,
price_unit: l.price,
...(impuestos.activo ? { tax_rate: l.tax_rate ?? 0 } : {}),
// Asignación a nivel venta: el doctor seleccionado aplica a todas las líneas
...(doctorId ? { prescribed_by_id: parseInt(doctorId, 10) } : {}),
})),
@@ -521,11 +550,15 @@ const Pos: FC = () => {
const key = l.kind === 'service' ? `s-${l.service_id}` : `i-${l.item_id}`;
const found = nuevas.find((x) => x.key === key);
if (found) { found.qty += l.quantity; continue; }
const tasa = l.kind === 'service'
? (() => { const s = services.find((x) => x.id === l.service_id); return s ? tasaDeServicio(s) : impuestos.tasa_default; })()
: (() => { const it = invItems.find((x) => x.id === l.item_id); return it ? tasaDeItem(it) : impuestos.tasa_default; })();
nuevas.push({
key,
name: l.name,
qty: l.quantity,
price: l.price_current ?? l.price_last,
tax_rate: impuestos.activo ? tasa : 0,
...(l.kind === 'service' ? { service_id: l.service_id ?? undefined } : {}),
...(l.kind === 'item' ? { item_id: l.item_id ?? undefined, stock: l.stock ?? undefined, unit: l.unit ?? undefined } : {}),
});
@@ -769,13 +802,37 @@ const Pos: FC = () => {
>
<X size={14} />
</button>
<p className="flex-1 min-w-0 text-sm font-medium text-theme-heading truncate" title={l.name}>
{l.item_id && <Package size={12} className="inline mr-1 text-theme-muted" />}
{l.name}
{l.item_id && l.stock !== undefined && (
<span className="block text-[10px] font-normal text-theme-muted">{l.stock} {l.unit || 'pzas'} en existencia</span>
<div className="flex-1 min-w-0">
<p className="text-sm font-medium text-theme-heading truncate" title={l.name}>
{l.item_id && <Package size={12} className="inline mr-1 text-theme-muted" />}
{l.name}
{l.item_id && l.stock !== undefined && (
<span className="block text-[10px] font-normal text-theme-muted">{l.stock} {l.unit || 'pzas'} en existencia</span>
)}
</p>
{impuestos.activo && (
<span className="flex items-center gap-1.5 text-[11px] text-theme-muted">
<span>{impuestos.nombre}</span>
{puedeImpuestos ? (
<select
value={String(l.tax_rate ?? 0)}
onChange={(e) => updateLine(l.key, { tax_rate: parseFloat(e.target.value) || 0 })}
className="border border-theme-border-strong rounded-md px-1 py-0.5 text-[11px]"
title={`Tasa de ${impuestos.nombre} de la línea`}
>
{[...new Set([...(impuestos.tasa_opciones || []), l.tax_rate ?? 0])]
.sort((a, b) => a - b)
.map((o) => <option key={o} value={String(o)}>{o}%</option>)}
</select>
) : (
<span>{l.tax_rate ?? 0}%</span>
)}
{impuestoLinea(l) > 0 && (
<span>{fmtMoney(impuestoLinea(l))}</span>
)}
</span>
)}
</p>
</div>
<div className="flex items-center gap-0.5 shrink-0">
<Button variant="outline" size="sm" className="!px-1.5" onClick={() => updateLine(l.key, { qty: Math.max(1, l.qty - 1) })}><Minus size={12} /></Button>
<span className="w-6 text-center text-sm font-medium text-theme-heading">{l.qty}</span>
@@ -807,6 +864,19 @@ const Pos: FC = () => {
</span>
</span>
</div>
{impuestos.activo && (
<div className="flex items-center justify-between text-sm">
<span className="text-theme-muted">
{impuestos.nombre}{impuestos.precios_incluyen_impuesto ? ' (incluido)' : ''}
</span>
<span className="text-theme-heading">
{fmtMoney(impuesto)}
<span className="text-xs text-theme-muted ml-1.5">
{toUsd(impuesto) !== null ? `≈ ${fmtUsd(toUsd(impuesto)!)}` : '—'}
</span>
</span>
</div>
)}
<div className="flex items-center justify-between text-sm gap-2">
<span className="text-theme-muted">Descuento</span>
<span className="flex items-center gap-1.5">
@@ -1407,6 +1477,8 @@ const Pos: FC = () => {
})),
subtotal: resultado.sale.subtotal,
discount: resultado.sale.discount,
tax: resultado.sale.tax_total ?? resultado.impuesto ?? 0,
tax_name: impuestos.nombre,
total: resultado.sale.total,
metodo: resultado.payment ? metodoLabel(resultado.payment.payment_method) : 'Puntos',
puntos_usados: resultado.puntos_usados,

View File

@@ -18,6 +18,7 @@ import Layout from '../components/Layout';
import DailyReport from '../components/reportes/DailyReport';
import CortesReport from '../components/reportes/CortesReport';
import IngresosReport from '../components/reportes/IngresosReport';
import ImpuestosReport from '../components/reportes/ImpuestosReport';
import InventarioReport from '../components/reportes/InventarioReport';
import AdeudosReport from '../components/reportes/AdeudosReport';
import ComisionesReport from '../components/reportes/ComisionesReport';
@@ -72,6 +73,7 @@ const FAMILIAS: ReportFamily[] = [
{ key: 'general', label: 'General', desc: 'Resumen del periodo, citas y comisiones' },
{ key: 'diario', label: 'Movimientos diarios', desc: 'Citas, ventas, cobros e inventario del día' },
{ key: 'ingresos', label: 'Ingresos', desc: 'Ventas y formas de pago' },
{ key: 'impuestos', label: 'Impuestos', desc: 'Base e impuesto del periodo por mes, servicio y sucursal' },
{ key: 'cortes', label: 'Cortes de caja', desc: 'Arqueos y cierres por día' },
{ key: 'adeudos', label: 'Adeudos', desc: 'Cartera por cobrar y planes de pago' },
{ key: 'devoluciones', label: 'Devoluciones', desc: 'Ventas devueltas y montos' },
@@ -448,6 +450,8 @@ const ReportesContent: FC = () => {
<CortesReport />
) : tab === 'ingresos' ? (
<IngresosReport />
) : tab === 'impuestos' ? (
<ImpuestosReport />
) : tab === 'inventario' ? (
<InventarioReport />
) : tab === 'adeudos' ? (

View File

@@ -19,6 +19,7 @@ import { odooApi, type Service } from '../services/odoo';
import { useGlosario } from '../lib/glosario';
import { useAuth } from '../lib/auth';
import { useServiceCategories } from '../lib/service-categories';
import { useClinicSettings } from '../lib/clinic-settings';
interface ServiceForm {
name: string;
@@ -32,6 +33,8 @@ interface ServiceForm {
description: string;
color: string;
service_group: string;
tax_use_default: boolean;
tax_rate: string;
}
const emptyForm: ServiceForm = {
@@ -46,12 +49,15 @@ const emptyForm: ServiceForm = {
description: '',
color: '#EDA588',
service_group: '',
tax_use_default: true,
tax_rate: '0',
};
const Servicios: FC = () => {
const { term } = useGlosario();
const { can } = useAuth();
const puedeEditar = can('servicios.editar');
const impuestos = useClinicSettings().impuestos;
const { categories, labelFor } = useServiceCategories();
const categoryOptions = useMemo(
() => [{ value: '', label: 'Todas las categorías' }, ...categories.map((c) => ({ value: c.code, label: c.name }))],
@@ -79,6 +85,12 @@ const Servicios: FC = () => {
const [reordenando, setReordenando] = useState(false);
const [form, setForm] = useState<ServiceForm>(emptyForm);
// Opciones de tasa del selector: las configuradas + la del servicio en edición.
const opcionesImpuesto = useMemo(() => {
const set = new Set<number>([...(impuestos.tasa_opciones || []), parseFloat(form.tax_rate) || 0]);
return [...set].sort((a, b) => a - b);
}, [impuestos.tasa_opciones, form.tax_rate]);
const load = useCallback(async () => {
try {
setLoading(true);
@@ -156,6 +168,8 @@ const Servicios: FC = () => {
description: s.description || '',
color: s.color || '#EDA588',
service_group: s.service_group || '',
tax_use_default: s.tax_use_default !== false,
tax_rate: String(s.tax_rate ?? 0),
});
setModalOpen(true);
};
@@ -177,6 +191,8 @@ const Servicios: FC = () => {
description: s.description || '',
color: s.color || '#EDA588',
service_group: s.service_group || '',
tax_use_default: s.tax_use_default !== false,
tax_rate: String(s.tax_rate ?? 0),
});
setModalOpen(true);
};
@@ -261,6 +277,10 @@ const Servicios: FC = () => {
color: form.color,
service_group: form.service_group,
};
if (impuestos.activo) {
payload.tax_use_default = form.tax_use_default;
payload.tax_rate = form.tax_use_default ? 0 : (parseFloat(form.tax_rate) || 0);
}
try {
setSubmitting(true);
if (editing) {
@@ -566,6 +586,20 @@ const Servicios: FC = () => {
onChange={(e) => setForm({ ...form, color: e.target.value })}
/>
</div>
{impuestos.activo && (
<Select
label={`Impuesto (${impuestos.nombre})`}
options={[
{ value: 'default', label: `Usar tasa por defecto (${impuestos.tasa_default}%)` },
...opcionesImpuesto.map((o) => ({ value: String(o), label: `${o}%` })),
]}
value={form.tax_use_default ? 'default' : form.tax_rate}
onChange={(e) => {
const v = e.target.value;
setForm({ ...form, tax_use_default: v === 'default', tax_rate: v === 'default' ? '0' : v });
}}
/>
)}
<TextArea
label="Descripción"
value={form.description}

View File

@@ -8,6 +8,7 @@ import TicketPrint from '../components/TicketPrint';
import TicketEditor from '../components/TicketEditor';
import { odooApi, type Sale } from '../services/odoo';
import { useAuth } from '../lib/auth';
import { useClinicSettings } from '../lib/clinic-settings';
import { readDateFilterPrefs, writeDateFilterPrefs, DATE_PRESETS, rangeForPreset, type DatePreset } from '../lib/dateRange';
const PREF_KEY = 'skeen_tickets_filtros';
@@ -48,6 +49,7 @@ const PAGE_SIZE = 50;
*/
const Tickets: FC = () => {
const { user, can } = useAuth();
const impuestos = useClinicSettings().impuestos;
const puedeCorregir = user?.role === 'admin' || user?.role === 'gerencia';
const puedeCancelar = can('ventas.cancelar');
const prefs = readDateFilterPrefs(PREF_KEY);
@@ -511,6 +513,8 @@ const Tickets: FC = () => {
})),
subtotal: reimprimir.subtotal,
discount: reimprimir.discount,
tax: reimprimir.tax_total ?? reimprimir.tax ?? 0,
tax_name: impuestos.nombre,
total: reimprimir.total,
amount_paid: reimprimir.amount_paid,
amount_due: reimprimir.amount_due,

View File

@@ -23,6 +23,7 @@ import {
import { odooApi, type Sale, type SaleLine, type Service, type Doctor } from '../services/odoo';
import { exportToExcel } from '../lib/exporter';
import { useAuth } from '../lib/auth';
import { useClinicSettings } from '../lib/clinic-settings';
import { DATE_PRESETS, rangeForPreset, readDateFilterPrefs, writeDateFilterPrefs, type DatePreset } from '../lib/dateRange';
// Rango de fechas recordado entre visitas (igual que los presets de la agenda)
@@ -47,6 +48,7 @@ const paymentMethods = ['Efectivo', 'Tarjeta', 'Transferencia', 'MercadoPago'];
const Ventas: FC = () => {
const { openPatient } = usePatientDrawer();
const { brand, can } = useAuth();
const impuestos = useClinicSettings().impuestos;
const puedeCancelar = can('ventas.cancelar');
const puedeCobrar = can('ventas.cobrar');
const puedeDevolver = can('ventas.devolver');
@@ -904,6 +906,8 @@ const Ventas: FC = () => {
})),
subtotal: printSale.subtotal,
discount: printSale.discount,
tax: printSale.tax_total ?? printSale.tax ?? 0,
tax_name: impuestos.nombre,
total: printSale.total,
amount_paid: printSale.amount_paid,
amount_due: printSale.amount_due,