mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
feat: bugfixes, spedup, bulk actions,
This commit is contained in:
@@ -40,6 +40,9 @@ export const getFilesByTransactionId = cache(async (id: string) => {
|
||||
in: transaction.files as string[],
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
})
|
||||
}
|
||||
return []
|
||||
|
||||
@@ -2,11 +2,7 @@ import { prisma } from "@/lib/db"
|
||||
import { calcTotalPerCurrency } from "@/lib/stats"
|
||||
import { Prisma } from "@prisma/client"
|
||||
import { cache } from "react"
|
||||
|
||||
export type StatsFilters = {
|
||||
dateFrom?: string
|
||||
dateTo?: string
|
||||
}
|
||||
import { TransactionFilters } from "./transactions"
|
||||
|
||||
export type DashboardStats = {
|
||||
totalIncomePerCurrency: Record<string, number>
|
||||
@@ -15,7 +11,7 @@ export type DashboardStats = {
|
||||
invoicesProcessed: number
|
||||
}
|
||||
|
||||
export const getDashboardStats = cache(async (filters: StatsFilters = {}): Promise<DashboardStats> => {
|
||||
export const getDashboardStats = cache(async (filters: TransactionFilters = {}): Promise<DashboardStats> => {
|
||||
const where: Prisma.TransactionWhereInput = {}
|
||||
|
||||
if (filters.dateFrom || filters.dateTo) {
|
||||
@@ -51,7 +47,7 @@ export type ProjectStats = {
|
||||
invoicesProcessed: number
|
||||
}
|
||||
|
||||
export const getProjectStats = cache(async (projectId: string, filters: StatsFilters = {}) => {
|
||||
export const getProjectStats = cache(async (projectId: string, filters: TransactionFilters = {}) => {
|
||||
const where: Prisma.TransactionWhereInput = {
|
||||
projectCode: projectId,
|
||||
}
|
||||
|
||||
@@ -120,6 +120,12 @@ export const deleteTransaction = async (id: string): Promise<Transaction | undef
|
||||
}
|
||||
}
|
||||
|
||||
export const bulkDeleteTransactions = async (ids: string[]) => {
|
||||
return await prisma.transaction.deleteMany({
|
||||
where: { id: { in: ids } },
|
||||
})
|
||||
}
|
||||
|
||||
const splitTransactionDataExtraFields = async (
|
||||
data: TransactionData
|
||||
): Promise<{ standard: TransactionData; extra: Prisma.InputJsonValue }> => {
|
||||
|
||||
Reference in New Issue
Block a user