mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 21:35:19 +00:00
feat: use structured output, import CSV, bugfixes
This commit is contained in:
@@ -3,10 +3,11 @@ import { Transaction } from "@prisma/client"
|
||||
export function calcTotalPerCurrency(transactions: Transaction[]): Record<string, number> {
|
||||
return transactions.reduce((acc, transaction) => {
|
||||
if (transaction.convertedCurrencyCode) {
|
||||
acc[transaction.convertedCurrencyCode] =
|
||||
(acc[transaction.convertedCurrencyCode] || 0) + (transaction.convertedTotal || 0)
|
||||
acc[transaction.convertedCurrencyCode.toUpperCase()] =
|
||||
(acc[transaction.convertedCurrencyCode.toUpperCase()] || 0) + (transaction.convertedTotal || 0)
|
||||
} else if (transaction.currencyCode) {
|
||||
acc[transaction.currencyCode] = (acc[transaction.currencyCode] || 0) + (transaction.total || 0)
|
||||
acc[transaction.currencyCode.toUpperCase()] =
|
||||
(acc[transaction.currencyCode.toUpperCase()] || 0) + (transaction.total || 0)
|
||||
}
|
||||
return acc
|
||||
}, {} as Record<string, number>)
|
||||
|
||||
Reference in New Issue
Block a user