-
-
-
Income
-
- {Object.entries(statsPerProject[project.code]?.totalIncomePerCurrency).map(([currency, total]) => (
-
- {formatCurrency(total, currency)}
-
- ))}
- {!Object.entries(statsPerProject[project.code]?.totalIncomePerCurrency).length && (
-
0.00
- )}
+
+
+
+
+
+
Income
+
+ {Object.entries(statsPerProject[project.code]?.totalIncomePerCurrency).map(([currency, total]) => (
+
+ {formatCurrency(total, currency)}
+
+ ))}
+ {!Object.entries(statsPerProject[project.code]?.totalIncomePerCurrency).length && (
+
0.00
+ )}
+
+
+
+
Expenses
+
+ {Object.entries(statsPerProject[project.code]?.totalExpensesPerCurrency).map(
+ ([currency, total]) => (
+
+ {formatCurrency(total, currency)}
+
+ )
+ )}
+ {!Object.entries(statsPerProject[project.code]?.totalExpensesPerCurrency).length && (
+
0.00
+ )}
+
+
+
+
Profit
+
+ {Object.entries(statsPerProject[project.code]?.profitPerCurrency).map(([currency, total]) => (
+
= 0 ? "text-green-500" : "text-red-500"
+ }`}
+ >
+ {formatCurrency(total, currency)}
+
+ ))}
+ {!Object.entries(statsPerProject[project.code]?.profitPerCurrency).length && (
+
0.00
+ )}
+
-
-
Expenses
-
- {Object.entries(statsPerProject[project.code]?.totalExpensesPerCurrency).map(([currency, total]) => (
-
- {formatCurrency(total, currency)}
-
- ))}
- {!Object.entries(statsPerProject[project.code]?.totalExpensesPerCurrency).length && (
-
0.00
- )}
-
-
-
-
Profit
-
- {Object.entries(statsPerProject[project.code]?.profitPerCurrency).map(([currency, total]) => (
-
= 0 ? "text-green-500" : "text-red-500"
- }`}
- >
- {formatCurrency(total, currency)}
-
- ))}
- {!Object.entries(statsPerProject[project.code]?.profitPerCurrency).length && (
-
0.00
- )}
-
-
-
-
-
+
+
+
))}
-
- Create New Project
+
+
Create New Project
)
diff --git a/components/dashboard/stats-widget.tsx b/components/dashboard/stats-widget.tsx
index 4fa0afb..08c17b1 100644
--- a/components/dashboard/stats-widget.tsx
+++ b/components/dashboard/stats-widget.tsx
@@ -7,6 +7,7 @@ import { getProjects } from "@/models/projects"
import { getDashboardStats, getProjectStats } from "@/models/stats"
import { TransactionFilters } from "@/models/transactions"
import { ArrowDown, ArrowUp, BicepsFlexed } from "lucide-react"
+import Link from "next/link"
export async function StatsWidget({ filters }: { filters: TransactionFilters }) {
const user = await getCurrentUser()
@@ -27,61 +28,72 @@ export async function StatsWidget({ filters }: { filters: TransactionFilters })
-
-
- Total Income
-
-
-
- {Object.entries(stats.totalIncomePerCurrency).map(([currency, total]) => (
-
- {formatCurrency(total, currency)}
-
- ))}
- {!Object.entries(stats.totalIncomePerCurrency).length && 0.00
}
-
-
-
-
- Total Expenses
-
-
-
- {Object.entries(stats.totalExpensesPerCurrency).map(([currency, total]) => (
-
- {formatCurrency(total, currency)}
-
- ))}
- {!Object.entries(stats.totalExpensesPerCurrency).length && 0.00
}
-
-
-
-
- Net Profit
-
-
-
- {Object.entries(stats.profitPerCurrency).map(([currency, total]) => (
- = 0 ? "text-green-500" : "text-red-500"
- }`}
- >
- {formatCurrency(total, currency)}
-
- ))}
- {!Object.entries(stats.profitPerCurrency).length && 0.00
}
-
-
-
-
- Processed Transactions
-
-
- {stats.invoicesProcessed}
-
-
+
+
+
+ Total Income
+
+
+
+ {Object.entries(stats.totalIncomePerCurrency).map(([currency, total]) => (
+
+ {formatCurrency(total, currency)}
+
+ ))}
+ {!Object.entries(stats.totalIncomePerCurrency).length && 0.00
}
+
+
+
+
+
+
+ Total Expenses
+
+
+
+ {Object.entries(stats.totalExpensesPerCurrency).map(([currency, total]) => (
+
+ {formatCurrency(total, currency)}
+
+ ))}
+ {!Object.entries(stats.totalExpensesPerCurrency).length && 0.00
}
+
+
+
+
+
+
+ Net Profit
+
+
+
+ {Object.entries(stats.profitPerCurrency).map(([currency, total]) => (
+ = 0 ? "text-green-500" : "text-red-500"
+ }`}
+ >
+ {formatCurrency(total, currency)}
+
+ ))}
+ {!Object.entries(stats.profitPerCurrency).length && 0.00
}
+
+
+
+
+
+
+ Processed Transactions
+
+
+ {stats.invoicesProcessed}
+
+
+
diff --git a/components/transactions/edit.tsx b/components/transactions/edit.tsx
index 691cf58..6787ca1 100644
--- a/components/transactions/edit.tsx
+++ b/components/transactions/edit.tsx
@@ -1,6 +1,8 @@
"use client"
import { deleteTransactionAction, saveTransactionAction } from "@/app/(app)/transactions/actions"
+import { ItemsDetectTool } from "@/components/agents/items-detect"
+import ToolWindow from "@/components/agents/tool-window"
import { FormError } from "@/components/forms/error"
import { FormSelectCategory } from "@/components/forms/select-category"
import { FormSelectCurrency } from "@/components/forms/select-currency"
@@ -8,14 +10,12 @@ import { FormSelectProject } from "@/components/forms/select-project"
import { FormSelectType } from "@/components/forms/select-type"
import { FormInput, FormTextarea } from "@/components/forms/simple"
import { Button } from "@/components/ui/button"
+import { TransactionData } from "@/models/transactions"
import { Category, Currency, Field, Project, Transaction } from "@/prisma/client"
import { format } from "date-fns"
import { Loader2, Save, Trash2 } from "lucide-react"
import { useRouter } from "next/navigation"
import { startTransition, useActionState, useEffect, useMemo, useState } from "react"
-import ToolWindow from "@/components/agents/tool-window"
-import { ItemsDetectTool } from "@/components/agents/items-detect"
-import { TransactionData } from "@/models/transactions"
export default function TransactionEditForm({
transaction,
diff --git a/models/transactions.ts b/models/transactions.ts
index a66f5d4..16a4ab7 100644
--- a/models/transactions.ts
+++ b/models/transactions.ts
@@ -31,6 +31,7 @@ export type TransactionFilters = {
ordering?: string
categoryCode?: string
projectCode?: string
+ type?: string
page?: number
}
@@ -54,11 +55,11 @@ export const getTransactions = cache(
if (filters) {
if (filters.search) {
where.OR = [
- { name: { contains: filters.search, mode: 'insensitive' } },
- { merchant: { contains: filters.search, mode: 'insensitive' } },
- { description: { contains: filters.search, mode: 'insensitive' } },
- { note: { contains: filters.search, mode: 'insensitive' } },
- { text: { contains: filters.search, mode: 'insensitive' } },
+ { name: { contains: filters.search, mode: "insensitive" } },
+ { merchant: { contains: filters.search, mode: "insensitive" } },
+ { description: { contains: filters.search, mode: "insensitive" } },
+ { note: { contains: filters.search, mode: "insensitive" } },
+ { text: { contains: filters.search, mode: "insensitive" } },
]
}
@@ -77,6 +78,10 @@ export const getTransactions = cache(
where.projectCode = filters.projectCode
}
+ if (filters.type) {
+ where.type = filters.type
+ }
+
if (filters.ordering) {
const isDesc = filters.ordering.startsWith("-")
const field = isDesc ? filters.ordering.slice(1) : filters.ordering
@@ -148,7 +153,7 @@ export const updateTransaction = async (id: string, userId: string, data: Transa
data: {
...standard,
extra: extra,
- items: data.items ? data.items as Prisma.InputJsonValue : [],
+ items: data.items ? (data.items as Prisma.InputJsonValue) : [],
},
})
}