Fix BWA Calc
This commit is contained in:
@@ -7,7 +7,6 @@ import {
|
||||
import {
|
||||
getIncomingInvoiceDepreciationRows,
|
||||
getIncomingInvoiceImmediateExpenseNet,
|
||||
getStatementAllocationDepreciationRow,
|
||||
getStatementAllocationImmediateExpenseAmount
|
||||
} from "~/composables/useDepreciation"
|
||||
|
||||
@@ -79,9 +78,9 @@ const loadSummary = async () => {
|
||||
|
||||
const statementDate = allocation?.bankstatement?.date || allocation?.bankstatement?.valueDate || allocation?.date || allocation?.created_at
|
||||
const date = dayjs(statementDate)
|
||||
const amount = Number(allocation?.amount || 0)
|
||||
const amount = getStatementAllocationImmediateExpenseAmount(allocation)
|
||||
|
||||
return amount < 0 && date.isValid() && !date.isBefore(bounds.start, "day") && !date.isAfter(bounds.end, "day")
|
||||
return amount > 0 && date.isValid() && !date.isBefore(bounds.start, "day") && !date.isAfter(bounds.end, "day")
|
||||
})
|
||||
|
||||
const income = outputDocs.reduce((sum: number, doc: any) => {
|
||||
@@ -103,12 +102,11 @@ const loadSummary = async () => {
|
||||
}, 0)
|
||||
|
||||
const directAccountExpenses = directExpenses.reduce((sum: number, allocation: any) => {
|
||||
return sum + getStatementAllocationImmediateExpenseAmount(allocation)
|
||||
return sum + Number(getStatementAllocationImmediateExpenseAmount(allocation) || 0)
|
||||
}, 0)
|
||||
|
||||
const depreciationRows = [
|
||||
...inputDocs.flatMap((invoice: any) => getIncomingInvoiceDepreciationRows(invoice, bounds.start, bounds.end)),
|
||||
...(allocations || []).map((allocation: any) => getStatementAllocationDepreciationRow(allocation, bounds.start, bounds.end)).filter(Boolean)
|
||||
...inputDocs.flatMap((invoice: any) => getIncomingInvoiceDepreciationRows(invoice, bounds.start, bounds.end))
|
||||
]
|
||||
|
||||
const depreciations = depreciationRows.reduce((sum: number, row: any) => sum + Number(row.amount || 0), 0)
|
||||
|
||||
Reference in New Issue
Block a user