fix: frontend VAT preview — extract VAT from inclusive amount, not add on top

This commit is contained in:
BOHA
2026-03-23 13:27:50 +01:00
parent 8b5f216960
commit a4c4a377c9

View File

@@ -783,7 +783,7 @@ export default function ReceivedInvoices({ statsMonth, statsYear, uploadOpen, se
{uploadMeta[idx]?.amount && ( {uploadMeta[idx]?.amount && (
<div style={{ fontSize: '0.75rem', color: 'var(--text-tertiary)', marginTop: '-0.25rem', marginBottom: '0.5rem' }}> <div style={{ fontSize: '0.75rem', color: 'var(--text-tertiary)', marginTop: '-0.25rem', marginBottom: '0.5rem' }}>
DPH: {formatCurrency( DPH: {formatCurrency(
parseFloat(uploadMeta[idx].amount || '0') * parseFloat(uploadMeta[idx].vat_rate || '21') / 100, (() => { const a = parseFloat(uploadMeta[idx].amount || '0'); const r = parseFloat(uploadMeta[idx].vat_rate || '21'); return r > 0 ? Math.round((a - a / (1 + r / 100)) * 100) / 100 : 0; })(),
uploadMeta[idx].currency || 'CZK' uploadMeta[idx].currency || 'CZK'
)} )}
</div> </div>
@@ -911,7 +911,7 @@ export default function ReceivedInvoices({ statsMonth, statsYear, uploadOpen, se
{editInvoice.amount && ( {editInvoice.amount && (
<div style={{ fontSize: '0.75rem', color: 'var(--text-tertiary)', marginBottom: '0.75rem' }}> <div style={{ fontSize: '0.75rem', color: 'var(--text-tertiary)', marginBottom: '0.75rem' }}>
DPH: {formatCurrency( DPH: {formatCurrency(
parseFloat(editInvoice.amount || '0') * parseFloat(editInvoice.vat_rate || '21') / 100, (() => { const a = parseFloat(editInvoice.amount || '0'); const r = parseFloat(editInvoice.vat_rate || '21'); return r > 0 ? Math.round((a - a / (1 + r / 100)) * 100) / 100 : 0; })(),
editInvoice.currency || 'CZK' editInvoice.currency || 'CZK'
)} )}
</div> </div>