if (d.last_sales && d.last_sales.length) { const escapeHistory = value => String(value ?? '').replace(/[&<>"']/g, c => ({'&': '&', '<': '<', '>': '>', '"': '"', "'": '''}[c])); const rows = d.last_sales.map(s => { const rate = parseFloat(s.rate) || 0; const tax = parseFloat(s.tax_percent) || 0; const total = rate * (1 + tax / 100); return `${escapeHistory(s.party)}: Rs.${rate.toFixed(2)} + ${tax}% = Rs.${total.toFixed(2)} (${escapeHistory(s.date)})`; }).join('
'); html += `
OTHER PARTIES
${rows}
`; }