dev #251
@@ -119,10 +119,13 @@ const reportRows = computed(() => {
|
|||||||
relevantCostCentreIds.value.has(account.costCentre)
|
relevantCostCentreIds.value.has(account.costCentre)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Expenses reduce the cost centre result; incoming documents marked as income increase it.
|
||||||
|
const sign = invoice.expense === false ? 1 : -1
|
||||||
|
|
||||||
return matchingAccounts.map((account, index) => {
|
return matchingAccounts.map((account, index) => {
|
||||||
const amountNet = Number(account.amountNet || 0)
|
const amountNet = Number(account.amountNet || 0) * sign
|
||||||
const amountTax = Number(account.amountTax || 0)
|
const amountTax = Number(account.amountTax || 0) * sign
|
||||||
const amountGross = Number(account.amountGross || amountNet + amountTax || 0)
|
const amountGross = Number(account.amountGross || Number(account.amountNet || 0) + Number(account.amountTax || 0) || 0) * sign
|
||||||
const accountCostCentre = costCentreMap.value.get(getCostCentreId(account.costCentre))
|
const accountCostCentre = costCentreMap.value.get(getCostCentreId(account.costCentre))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -196,8 +199,7 @@ const reportRows = computed(() => {
|
|||||||
const centre = costCentreMap.value.get(getCostCentreId(allocation.costcentre))
|
const centre = costCentreMap.value.get(getCostCentreId(allocation.costcentre))
|
||||||
const account = accounts.value.find(account => account.id === (allocation.account?.id || allocation.account)) || allocation.ownaccount
|
const account = accounts.value.find(account => account.id === (allocation.account?.id || allocation.account)) || allocation.ownaccount
|
||||||
const amounts = getBankAllocationAmounts(allocation)
|
const amounts = getBankAllocationAmounts(allocation)
|
||||||
// As for incoming documents, expenses are positive and refunds negative.
|
// The bank amount is already signed: outflows (expenses) negative, inflows positive.
|
||||||
const sign = amounts.kind === "input" || (amounts.kind === "none" && amounts.amountGross < 0) ? -1 : 1
|
|
||||||
return [{
|
return [{
|
||||||
id: `bank-${allocation.id}`,
|
id: `bank-${allocation.id}`,
|
||||||
sourceLabel: "Bankbuchung",
|
sourceLabel: "Bankbuchung",
|
||||||
@@ -209,9 +211,9 @@ const reportRows = computed(() => {
|
|||||||
accountLabel: `${account?.number || ""} ${account?.label || account?.name || ""}`.trim() || "-",
|
accountLabel: `${account?.number || ""} ${account?.label || account?.name || ""}`.trim() || "-",
|
||||||
costCentreName: centre ? `${centre.number} - ${centre.name}` : "-",
|
costCentreName: centre ? `${centre.number} - ${centre.name}` : "-",
|
||||||
description: allocation.description || statement.text || "-",
|
description: allocation.description || statement.text || "-",
|
||||||
amountNet: amounts.amountNet * sign,
|
amountNet: amounts.amountNet,
|
||||||
amountTax: amounts.amountTax * sign,
|
amountTax: amounts.amountTax,
|
||||||
amountGross: amounts.amountGross * sign,
|
amountGross: amounts.amountGross,
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
return [...incomingRows, ...outgoingRows, ...bankRows]
|
return [...incomingRows, ...outgoingRows, ...bankRows]
|
||||||
|
|||||||
Reference in New Issue
Block a user