Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
eff975d
Bump @tanstack/react-query from 5.97.0 to 5.99.0
dependabot[bot] Apr 13, 2026
f996938
Bump the patch-prod-dependencies group across 1 directory with 4 updates
dependabot[bot] May 7, 2026
77865f1
Bump fast-uri from 3.1.0 to 3.1.2
dependabot[bot] May 9, 2026
fe4b5b5
Bump the minor-dev-dependencies group across 1 directory with 7 updates
dependabot[bot] May 15, 2026
12bce59
Bump hono from 4.12.12 to 4.12.23
dependabot[bot] May 28, 2026
7c1a7d7
#690 add deletedAt to purchase and allocation models
b-at-neu Jun 3, 2026
2a5f671
#690 soft delete purchase
b-at-neu Jun 3, 2026
fbe13a8
#690 filter soft-deleted purchases in purchase service reads
b-at-neu Jun 3, 2026
944eb01
#690 soft delete allocation and filter soft-deleted rows in allocatio…
b-at-neu Jun 3, 2026
f057111
#690 filter soft-deleted allocations and purchases in allocation-grou…
b-at-neu Jun 3, 2026
be0b368
#690 filter soft-deleted purchases in designation service
b-at-neu Jun 3, 2026
9c6d9b8
#690 filter soft-deleted purchases in dashboard and year-comparison s…
b-at-neu Jun 3, 2026
aca4634
#690 fix formatting and prisma config dotenv
b-at-neu Jun 3, 2026
4878b76
#690 revert dotenv import in prisma.config
b-at-neu Jun 3, 2026
c03e42c
Merge pull request #691 from SGAOperations/690-fix-delete-purchase
b-at-neu Jun 3, 2026
42f7ea4
Merge pull request #689 from SGAOperations/dependabot/npm_and_yarn/ho…
b-at-neu Jun 3, 2026
ca2710f
Merge pull request #688 from SGAOperations/dependabot/npm_and_yarn/mi…
b-at-neu Jun 3, 2026
ce40f86
Merge pull request #684 from SGAOperations/dependabot/npm_and_yarn/pa…
b-at-neu Jun 3, 2026
b03e74b
Merge pull request #686 from SGAOperations/dependabot/npm_and_yarn/fa…
b-at-neu Jun 3, 2026
e028ee5
Merge pull request #674 from SGAOperations/dependabot/npm_and_yarn/ta…
b-at-neu Jun 3, 2026
93850c2
Bump next from 16.2.5 to 16.2.7
dependabot[bot] Jun 3, 2026
c180292
Merge pull request #692 from SGAOperations/dependabot/npm_and_yarn/ne…
b-at-neu Jun 3, 2026
b04c3b2
bump version to 2.7.4
b-at-neu Jun 3, 2026
77e50e7
Merge pull request #693 from SGAOperations/bump-version-2-7-4
b-at-neu Jun 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
820 changes: 372 additions & 448 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vaultz",
"version": "2.7.3",
"version": "2.7.4",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
Expand Down Expand Up @@ -32,7 +32,7 @@
"@radix-ui/react-slot": "^1.2.4",
"@radix-ui/react-tabs": "^1.1.13",
"@radix-ui/react-tooltip": "^1.2.8",
"@tanstack/react-query": "^5.97.0",
"@tanstack/react-query": "^5.99.0",
"@tanstack/react-table": "^8.21.3",
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
"@uploadthing/react": "^7.3.3",
Expand All @@ -41,15 +41,15 @@
"cmdk": "^1.1.1",
"fast-fuzzy": "^1.12.0",
"lucide-react": "^1.8.0",
"next": "16.2.3",
"next": "16.2.7",
"next-themes": "^0.4.6",
"nuqs": "^2.8.9",
"pg": "^8.20.0",
"prettier": "^3.8.2",
"prettier": "^3.8.3",
"prettier-plugin-tailwindcss": "^0.7.2",
"react": "19.2.5",
"react": "19.2.6",
"react-day-picker": "^9.14.0",
"react-dom": "19.2.5",
"react-dom": "19.2.6",
"react-hook-form": "^7.72.1",
"recharts": "^3.5.1",
"sonner": "^2.0.7",
Expand All @@ -67,11 +67,11 @@
"@types/react-dom": "^19",
"cli-progress": "^3.12.0",
"eslint": "^9",
"eslint-config-next": "16.2.3",
"prisma": "^7.7.0",
"eslint-config-next": "16.2.6",
"prisma": "^7.8.0",
"tailwindcss": "^4",
"tsx": "^4.21.0",
"tsx": "^4.22.0",
"tw-animate-css": "^1.4.0",
"typescript": "6.0.2"
"typescript": "6.0.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "Allocation" ADD COLUMN "deletedAt" TIMESTAMP(3);

-- AlterTable
ALTER TABLE "Purchase" ADD COLUMN "deletedAt" TIMESTAMP(3);
8 changes: 5 additions & 3 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ model Purchase {
excludeFromTotal Boolean @default(false)
expenseReportCreated Boolean @default(false)
reimbursed Boolean @default(false)
deletedAt DateTime?

categoryId String
category Category @relation(fields: [categoryId], references: [id])
Expand Down Expand Up @@ -185,9 +186,10 @@ model AllocationGroup {
}

model Allocation {
id String @id @default(uuid())
name String
amount Decimal
id String @id @default(uuid())
name String
amount Decimal
deletedAt DateTime?

designationId String
designation Designation @relation(fields: [designationId], references: [id])
Expand Down
18 changes: 12 additions & 6 deletions prisma/services/allocation-groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ export async function getAllAllocationGroups(
where: designationId ? { designationId } : undefined,
include: {
allocations: {
where: periodId
? { periodId }
: yearId
? { period: { yearId } }
: undefined,
where: {
deletedAt: null,
...(periodId
? { periodId }
: yearId
? { period: { yearId } }
: undefined),
},
include: {
purchases: {
where: { deletedAt: null },
orderBy: [{ purchasedAt: 'desc' }, { createdAt: 'desc' }],
include: {
user: true,
Expand Down Expand Up @@ -62,6 +66,7 @@ export async function getAllocationGroup({
allocations: {
include: {
purchases: {
where: { deletedAt: null },
orderBy: [{ purchasedAt: 'desc' }, { createdAt: 'desc' }],
include: { user: true, process: { select: { templateId: true } } },
},
Expand Down Expand Up @@ -99,9 +104,10 @@ export async function getAllocationGroupWithStats({
include: {
designation: true,
allocations: {
where: periodId ? { periodId } : undefined,
where: periodId ? { periodId, deletedAt: null } : { deletedAt: null },
include: {
purchases: {
where: { deletedAt: null },
orderBy: [{ purchasedAt: 'desc' }, { createdAt: 'desc' }],
include: { user: true, process: { select: { templateId: true } } },
},
Expand Down
12 changes: 9 additions & 3 deletions prisma/services/allocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export async function getAllocationById({
where: { id },
include: {
purchases: {
where: { deletedAt: null },
orderBy: [{ purchasedAt: 'desc' }, { createdAt: 'desc' }],
include: { user: true, process: { select: { templateId: true } } },
},
Expand All @@ -83,12 +84,14 @@ export async function getMiscAllocations(
const allocations = await prisma.allocation.findMany({
where: {
allocationGroupId: null,
deletedAt: null,
...(designationId && { designationId }),
...(periodId && { periodId }),
...(yearId && { period: { yearId } }),
},
include: {
purchases: {
where: { deletedAt: null },
orderBy: [{ purchasedAt: 'desc' }, { createdAt: 'desc' }],
include: { user: true, process: { select: { templateId: true } } },
},
Expand Down Expand Up @@ -130,7 +133,7 @@ export async function deleteAllocation(
): Promise<ResponseType<void>> {
const allocation = await prisma.allocation.findUnique({
where: { id },
include: { purchases: { take: 1 } },
include: { purchases: { where: { deletedAt: null }, take: 1 } },
});

if (!allocation) return { error: 'Allocation not found.' };
Expand All @@ -141,7 +144,10 @@ export async function deleteAllocation(
'Cannot delete an allocation that has purchases. Remove all purchases first.',
};

await prisma.allocation.delete({ where: { id } });
await prisma.allocation.update({
where: { id },
data: { deletedAt: new Date() },
});

revalidatePath('/allocation-groups');
}
Expand All @@ -158,7 +164,7 @@ export async function copyAllocationsFromPeriod({
includeCarryover: boolean;
}): Promise<ResponseType<{ count: number }>> {
const sourceAllocations = await prisma.allocation.findMany({
where: { periodId: fromPeriodId },
where: { periodId: fromPeriodId, deletedAt: null },
include: { purchases: { where: { excludeFromTotal: false } } },
});

Expand Down
16 changes: 13 additions & 3 deletions prisma/services/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export async function getDashboardStatsByDesignation(
select: { amount: true },
}),
prisma.purchase.findMany({
where: { category: { designationId }, yearId, excludeFromTotal: false },
where: {
category: { designationId },
yearId,
excludeFromTotal: false,
deletedAt: null,
},
select: { amount: true },
}),
]);
Expand All @@ -42,7 +47,12 @@ export async function getPurchasesByMonthForDesignation(
yearId: string,
) {
const purchases = await prisma.purchase.findMany({
where: { category: { designationId }, yearId, excludeFromTotal: false },
where: {
category: { designationId },
yearId,
excludeFromTotal: false,
deletedAt: null,
},
select: { amount: true, purchasedAt: true },
orderBy: [{ purchasedAt: 'asc' }, { createdAt: 'asc' }],
});
Expand Down Expand Up @@ -90,7 +100,7 @@ export async function getSpendingByCategoryForDesignation(
select: { amount: true },
},
purchases: {
where: { yearId, excludeFromTotal: false },
where: { yearId, excludeFromTotal: false, deletedAt: null },
select: { amount: true },
},
transfersFrom: {
Expand Down
2 changes: 2 additions & 0 deletions prisma/services/designation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export async function getAllDesignations(): Promise<
categories: {
select: {
purchases: {
where: { deletedAt: null },
orderBy: [{ purchasedAt: 'desc' }, { createdAt: 'desc' }],
include: {
user: true,
Expand Down Expand Up @@ -76,6 +77,7 @@ export async function getDesignation({
categories: {
select: {
purchases: {
where: { deletedAt: null },
orderBy: [{ purchasedAt: 'desc' }, { createdAt: 'desc' }],
include: { user: true, process: { select: { templateId: true } } },
},
Expand Down
16 changes: 12 additions & 4 deletions prisma/services/purchase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function getLatestPurchases(
): Promise<PurchaseWithUser[]> {
const purchases = await prisma.purchase.findMany({
take: limit,
where: { deletedAt: null },
orderBy: [{ purchasedAt: 'desc' }, { createdAt: 'desc' }],
include: { user: true, process: { select: { templateId: true } } },
});
Expand All @@ -31,7 +32,11 @@ export async function getPurchasesByDesignation({
yearId: string;
}): Promise<PurchaseWithUser[]> {
const purchases = await prisma.purchase.findMany({
where: { yearId, category: { designationId, deletedAt: null } },
where: {
yearId,
deletedAt: null,
category: { designationId, deletedAt: null },
},
orderBy: [{ purchasedAt: 'desc' }, { createdAt: 'desc' }],
include: { user: true, process: { select: { templateId: true } } },
});
Expand Down Expand Up @@ -214,7 +219,10 @@ export async function updatePurchase({
export async function deletePurchase(
id: string,
): Promise<ResponseType<Purchase>> {
const purchase = await prisma.purchase.delete({ where: { id } });
const purchase = await prisma.purchase.update({
where: { id },
data: { deletedAt: new Date() },
});

revalidatePath('/');
revalidatePath('/designation');
Expand All @@ -226,7 +234,7 @@ export async function getPurchaseProcess(
purchaseId: string,
): Promise<PurchaseProcessData | null> {
const purchase = await prisma.purchase.findUnique({
where: { id: purchaseId },
where: { id: purchaseId, deletedAt: null },
include: {
process: {
include: {
Expand Down Expand Up @@ -322,7 +330,7 @@ export async function getBatchPurchaseProcessData(
if (purchaseIds.length === 0) return {};

const purchases = await prisma.purchase.findMany({
where: { id: { in: purchaseIds } },
where: { id: { in: purchaseIds }, deletedAt: null },
select: {
id: true,
process: {
Expand Down
6 changes: 5 additions & 1 deletion prisma/services/year-comparison.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export async function getYearComparisonData({
select: { yearId: true, amount: true },
},
purchases: {
where: { excludeFromTotal: false, yearId: { in: yearIds } },
where: {
excludeFromTotal: false,
yearId: { in: yearIds },
deletedAt: null,
},
select: { amount: true, yearId: true },
},
transfersTo: {
Expand Down
Loading