feat: correct total tax on incoming invoices

This commit is contained in:
2026-08-09 16:35:47 +02:00
parent 94008e8072
commit 8301d8777e
14 changed files with 129 additions and 103 deletions

View File

@@ -12,17 +12,15 @@ export const useSum = () => {
}
const getIncomingInvoiceSum = (invoice) => {
let sum = 0
invoice.accounts.forEach(account => {
const totals = (invoice.accounts || []).reduce((result, account) => ({
net: result.net + Number(account.amountNet || 0),
tax: result.tax + Number(account.amountTax || 0)
}), { net: 0, tax: 0 })
const tax = invoice.taxAmountOverride !== null && invoice.taxAmountOverride !== undefined && invoice.taxAmountOverride !== ""
? Number(invoice.taxAmountOverride)
: totals.tax
sum += account.amountTax
sum += account.amountNet
})
return sum.toFixed(2)
return (totals.net + tax).toFixed(2)
}
const getCreatedDocumentSum = (createddocument,createddocuments = []) => {