Segunda mejora en el recálculo automático de los importes los items de factura

This commit is contained in:
David Arranz 2025-11-09 12:58:17 +01:00
parent ff036a7d81
commit 3198a75f73

View File

@ -96,7 +96,14 @@ export function useInvoiceAutoRecalc(
const prev = itemCache.current.get(idx);
const next = calculateItemTotals(item, deferredDiscount);
if (!prev || JSON.stringify(prev) !== JSON.stringify(next)) {
const itemHasChanges =
!prev ||
prev.subtotal_amount !== next.subtotal_amount ||
prev.total_amount !== next.total_amount ||
prev.taxes_amount !== next.taxes_amount;
//if (!prev || JSON.stringify(prev) !== JSON.stringify(next)) { <-- Costoso y poco preciso
if (itemHasChanges) {
shouldUpdateHeader = true;
itemCache.current.set(idx, next);
setInvoiceItemTotals(form, idx, next);