refactor: standardize quotation marks across all files and improve code consistency
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import { prisma } from "@/lib/prisma"
|
||||
import type { BankingData, Account, Transaction, Folder, Category } from "@/lib/types"
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import type {
|
||||
BankingData,
|
||||
Account,
|
||||
Transaction,
|
||||
Folder,
|
||||
Category,
|
||||
} from "@/lib/types";
|
||||
|
||||
export const bankingService = {
|
||||
async getAllData(): Promise<BankingData> {
|
||||
@@ -17,50 +23,57 @@ export const bankingService = {
|
||||
}),
|
||||
prisma.folder.findMany(),
|
||||
prisma.category.findMany(),
|
||||
])
|
||||
]);
|
||||
|
||||
// Transform Prisma models to match our types
|
||||
return {
|
||||
accounts: accounts.map((a): Account => ({
|
||||
id: a.id,
|
||||
name: a.name,
|
||||
bankId: a.bankId,
|
||||
accountNumber: a.accountNumber,
|
||||
type: a.type as Account["type"],
|
||||
folderId: a.folderId,
|
||||
balance: a.balance,
|
||||
currency: a.currency,
|
||||
lastImport: a.lastImport,
|
||||
})),
|
||||
transactions: transactions.map((t): Transaction => ({
|
||||
id: t.id,
|
||||
accountId: t.accountId,
|
||||
date: t.date,
|
||||
amount: t.amount,
|
||||
description: t.description,
|
||||
type: t.type as Transaction["type"],
|
||||
categoryId: t.categoryId,
|
||||
isReconciled: t.isReconciled,
|
||||
fitId: t.fitId,
|
||||
memo: t.memo ?? undefined,
|
||||
checkNum: t.checkNum ?? undefined,
|
||||
})),
|
||||
folders: folders.map((f): Folder => ({
|
||||
id: f.id,
|
||||
name: f.name,
|
||||
parentId: f.parentId,
|
||||
color: f.color,
|
||||
icon: f.icon,
|
||||
})),
|
||||
categories: categories.map((c): Category => ({
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
color: c.color,
|
||||
icon: c.icon,
|
||||
keywords: JSON.parse(c.keywords) as string[],
|
||||
parentId: c.parentId,
|
||||
})),
|
||||
}
|
||||
accounts: accounts.map(
|
||||
(a): Account => ({
|
||||
id: a.id,
|
||||
name: a.name,
|
||||
bankId: a.bankId,
|
||||
accountNumber: a.accountNumber,
|
||||
type: a.type as Account["type"],
|
||||
folderId: a.folderId,
|
||||
balance: a.balance,
|
||||
currency: a.currency,
|
||||
lastImport: a.lastImport,
|
||||
}),
|
||||
),
|
||||
transactions: transactions.map(
|
||||
(t): Transaction => ({
|
||||
id: t.id,
|
||||
accountId: t.accountId,
|
||||
date: t.date,
|
||||
amount: t.amount,
|
||||
description: t.description,
|
||||
type: t.type as Transaction["type"],
|
||||
categoryId: t.categoryId,
|
||||
isReconciled: t.isReconciled,
|
||||
fitId: t.fitId,
|
||||
memo: t.memo ?? undefined,
|
||||
checkNum: t.checkNum ?? undefined,
|
||||
}),
|
||||
),
|
||||
folders: folders.map(
|
||||
(f): Folder => ({
|
||||
id: f.id,
|
||||
name: f.name,
|
||||
parentId: f.parentId,
|
||||
color: f.color,
|
||||
icon: f.icon,
|
||||
}),
|
||||
),
|
||||
categories: categories.map(
|
||||
(c): Category => ({
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
color: c.color,
|
||||
icon: c.icon,
|
||||
keywords: JSON.parse(c.keywords) as string[],
|
||||
parentId: c.parentId,
|
||||
}),
|
||||
),
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user