feat(banking): add cost centres and VAT to account allocations
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { getBankAllocationAmounts } from "../utils/bankAllocationTax"
|
||||
import dayjs from "dayjs"
|
||||
|
||||
export const EXPENSE_BOOKING_MODE_ITEMS = [
|
||||
@@ -308,7 +309,7 @@ export const getStatementAllocationImmediateExpenseImpact = (allocation: any) =>
|
||||
if (allocation?.account === null || allocation?.account === undefined) return 0
|
||||
|
||||
const mode = normalizeExpenseBookingMode(allocation?.bookingMode)
|
||||
const amount = Number(allocation?.amount || 0)
|
||||
const amount = getBankAllocationAmounts(allocation).amountNet
|
||||
if (mode !== "expense") return 0
|
||||
return Number((-amount).toFixed(2))
|
||||
}
|
||||
@@ -317,7 +318,7 @@ export const getStatementAllocationImmediateExpenseAmount = (allocation: any) =>
|
||||
return Math.max(0, getStatementAllocationImmediateExpenseImpact(allocation))
|
||||
}
|
||||
|
||||
export const getStatementAccountExpenseTotal = (allocations: any[] = []) => {
|
||||
export const getStatementAccountExpenseTotal = (allocations: any[] = [], gross = false) => {
|
||||
const balances = new Map<string, number>()
|
||||
const addAmount = (account: any, amount: number) => {
|
||||
const id = account?.id || account
|
||||
@@ -330,7 +331,8 @@ export const getStatementAccountExpenseTotal = (allocations: any[] = []) => {
|
||||
;(allocations || []).forEach((allocation) => {
|
||||
if (normalizeExpenseBookingMode(allocation?.bookingMode) !== "expense") return
|
||||
|
||||
const amount = Number(allocation?.amount || 0)
|
||||
const amounts = getBankAllocationAmounts(allocation)
|
||||
const amount = gross ? amounts.amountGross : amounts.amountNet
|
||||
addAmount(allocation?.account, amount)
|
||||
addAmount(allocation?.contraAccount, -amount)
|
||||
})
|
||||
@@ -344,7 +346,7 @@ export const getStatementAccountExpenseTotal = (allocations: any[] = []) => {
|
||||
|
||||
export const getStatementAllocationDepreciationAmount = (allocation: any, rangeStart: any, rangeEnd: any) => {
|
||||
const mode = normalizeExpenseBookingMode(allocation?.bookingMode)
|
||||
const rawAmount = Number(allocation?.amount || 0)
|
||||
const rawAmount = getBankAllocationAmounts(allocation).amountNet
|
||||
const amount = Math.abs(rawAmount)
|
||||
if (mode === "expense" || rawAmount >= 0 || amount <= 0) return 0
|
||||
|
||||
@@ -360,7 +362,7 @@ export const getStatementAllocationDepreciationAmount = (allocation: any, rangeS
|
||||
}
|
||||
|
||||
export const getStatementAllocationDepreciationRow = (allocation: any, rangeStart: any, rangeEnd: any) => {
|
||||
const totalAmount = Math.abs(Number(allocation?.amount || 0))
|
||||
const totalAmount = Math.abs(getBankAllocationAmounts(allocation).amountNet)
|
||||
const months = Number(allocation?.depreciationMonths || 0)
|
||||
const startDate = allocation?.depreciationStartDate || allocation?.created_at
|
||||
const method = normalizeDepreciationMethod(allocation?.depreciationMethod)
|
||||
|
||||
Reference in New Issue
Block a user