fix(diff): show GST rate strikethrough when submitter changes it on edit

qtyChanged/priceChanged/nameChanged were tracked for the diff view but
gstChanged was missing, so an edited GST % showed only the new value
with no strikethrough of the old one. Added gstChanged detection and
two-line rendering (old % struck through, new % in amber) to match the
other diff columns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Hardik 2026-05-27 03:34:54 +05:30
parent e0c97cbf5d
commit a8e3b5d69b

View file

@ -282,6 +282,7 @@ export function LineItemsEditor({
const qtyChanged = orig && Number(orig.quantity) !== item.quantity; const qtyChanged = orig && Number(orig.quantity) !== item.quantity;
const priceChanged = orig && Number(orig.unitPrice) !== item.unitPrice; const priceChanged = orig && Number(orig.unitPrice) !== item.unitPrice;
const nameChanged = orig && orig.name !== item.name; const nameChanged = orig && orig.name !== item.name;
const gstChanged = orig && Number(orig.gstRate ?? 0.18) !== (item.gstRate ?? 0.18);
const taxableAmt = item.quantity * item.unitPrice; const taxableAmt = item.quantity * item.unitPrice;
const gstAmt = taxableAmt * (item.gstRate ?? 0.18); const gstAmt = taxableAmt * (item.gstRate ?? 0.18);
const acct = item.accountId ? accountMap[item.accountId] : null; const acct = item.accountId ? accountMap[item.accountId] : null;
@ -305,7 +306,10 @@ export function LineItemsEditor({
<span className={priceChanged ? "text-amber-700 font-medium" : ""}>{formatCurrency(item.unitPrice)}</span> <span className={priceChanged ? "text-amber-700 font-medium" : ""}>{formatCurrency(item.unitPrice)}</span>
</td> </td>
<td className="py-2 pl-4 text-right">{formatCurrency(taxableAmt)}</td> <td className="py-2 pl-4 text-right">{formatCurrency(taxableAmt)}</td>
<td className="py-2 pl-4 text-right text-neutral-500">{Math.round((item.gstRate ?? 0.18) * 100)}%</td> <td className="py-2 pl-4 text-right text-neutral-500">
{gstChanged && <span className="block text-neutral-400 line-through text-xs">{Math.round((orig.gstRate ?? 0.18) * 100)}%</span>}
<span className={gstChanged ? "text-amber-700 font-medium" : ""}>{Math.round((item.gstRate ?? 0.18) * 100)}%</span>
</td>
<td className="py-2 pl-4 text-right">{formatCurrency(taxableAmt + gstAmt)}</td> <td className="py-2 pl-4 text-right">{formatCurrency(taxableAmt + gstAmt)}</td>
{showAccount && ( {showAccount && (
<td className="py-2 pl-4 text-xs text-neutral-500 font-mono"> <td className="py-2 pl-4 text-xs text-neutral-500 font-mono">