refactor: standardize quotation marks across all files and improve code consistency
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { prisma } from "@/lib/prisma"
|
||||
import type { Transaction } from "@/lib/types"
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import type { Transaction } from "@/lib/types";
|
||||
|
||||
export interface CreateManyResult {
|
||||
count: number
|
||||
transactions: Transaction[]
|
||||
count: number;
|
||||
transactions: Transaction[];
|
||||
}
|
||||
|
||||
export const transactionService = {
|
||||
@@ -18,18 +18,18 @@ export const transactionService = {
|
||||
accountId: true,
|
||||
fitId: true,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
const existingSet = new Set(
|
||||
existingTransactions.map((t) => `${t.accountId}-${t.fitId}`),
|
||||
)
|
||||
);
|
||||
|
||||
const newTransactions = transactions.filter(
|
||||
(t) => !existingSet.has(`${t.accountId}-${t.fitId}`),
|
||||
)
|
||||
);
|
||||
|
||||
if (newTransactions.length === 0) {
|
||||
return { count: 0, transactions: [] }
|
||||
return { count: 0, transactions: [] };
|
||||
}
|
||||
|
||||
const created = await prisma.transaction.createMany({
|
||||
@@ -45,12 +45,15 @@ export const transactionService = {
|
||||
memo: t.memo,
|
||||
checkNum: t.checkNum,
|
||||
})),
|
||||
})
|
||||
});
|
||||
|
||||
return { count: created.count, transactions: newTransactions }
|
||||
return { count: created.count, transactions: newTransactions };
|
||||
},
|
||||
|
||||
async update(id: string, data: Partial<Omit<Transaction, "id">>): Promise<Transaction> {
|
||||
async update(
|
||||
id: string,
|
||||
data: Partial<Omit<Transaction, "id">>,
|
||||
): Promise<Transaction> {
|
||||
const updated = await prisma.transaction.update({
|
||||
where: { id },
|
||||
data: {
|
||||
@@ -65,7 +68,7 @@ export const transactionService = {
|
||||
memo: data.memo,
|
||||
checkNum: data.checkNum,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
return {
|
||||
id: updated.id,
|
||||
@@ -79,13 +82,12 @@ export const transactionService = {
|
||||
fitId: updated.fitId,
|
||||
memo: updated.memo ?? undefined,
|
||||
checkNum: updated.checkNum ?? undefined,
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
async delete(id: string): Promise<void> {
|
||||
await prisma.transaction.delete({
|
||||
where: { id },
|
||||
})
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user