From 83e6d5beb82a759960524326d25d23e5f51f2386 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Mon, 22 Jul 2024 21:08:43 -0400 Subject: [PATCH 1/4] Retrieve Specific Reimbursement Data --- src/backend/src/prisma/manual.ts | 125 ++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 2 deletions(-) diff --git a/src/backend/src/prisma/manual.ts b/src/backend/src/prisma/manual.ts index 397cd17571..2c7297b2a3 100644 --- a/src/backend/src/prisma/manual.ts +++ b/src/backend/src/prisma/manual.ts @@ -4,7 +4,8 @@ */ import prisma from './prisma'; -import { Role, WBS_Element_Status } from '@prisma/client'; +import { Reimbursement_Status, Role, WBS_Element_Status } from '@prisma/client'; +import { appendFileSync, writeFileSync } from 'fs'; import { calculateEndDate } from 'shared'; /* eslint-disable @typescript-eslint/no-unused-vars */ @@ -15,7 +16,9 @@ import { calculateEndDate } from 'shared'; */ /** Execute all given prisma database interaction scripts written in this function */ -const executeScripts = async () => {}; +const executeScripts = async () => { + await downloadReimbursementDataByProject(); +}; /** * Update user's role given userId and new role @@ -25,6 +28,124 @@ const setUserRole = async (id: number, role: Role) => { await prisma.user.update({ where: { userId: id }, data: { role } }); }; +const downloadReimbursementDataByProject = async () => { + const wbsElements = await prisma.wBS_Element.findMany({ + include: { + reimbursementProductReasons: { + include: { + reimbursementProduct: { + include: { + reimbursementRequest: { + include: { + reimbursementStatuses: true + } + }, + reimbursementProductReason: { + include: { + wbsElement: { + include: { + workPackage: { + include: { + project: { + include: { + wbsElement: true + } + } + } + } + } + } + } + } + } + } + } + } + } + }); + + let products = wbsElements.reduce((acc, curr) => { + return acc.concat(curr.reimbursementProductReasons.map((reason) => reason.reimbursementProduct)); + }, []); + + products = products.filter((product) => { + return !product.reimbursementRequest.reimbursementStatuses.some( + (status: Reimbursement_Status) => status.type === 'DENIED' + ) && product.reimbursementRequest.dateDeleted === null && product.dateDeleted === null; + }); + + console.log(products[0]); + + type ProductInfo = { + account: string; + totalAmount: number; + }; + + const productsByProjectOrReason = new Map(); + + products.forEach((product, i) => { + if (product.reimbursementProductReason.otherReason) { + const reason = product.reimbursementProductReason.otherReason; + if (productsByProjectOrReason.has(reason)) { + appendFileSync('debug.txt', `index: ${i}\n`); + const current = productsByProjectOrReason.get(reason); + productsByProjectOrReason.set(reason, { + account: current.account, + totalAmount: current.totalAmount + product.cost + }); + } else { + appendFileSync('debug.txt', `index: ${i}\n`); + productsByProjectOrReason.set(reason, { + account: product.reimbursementProductReason.otherReason, + totalAmount: product.cost + }); + } + } else { + let reason = product.reimbursementProductReason.wbsElement?.name || 'N/A'; + + if (product.reimbursementProductReason.wbsElement?.workPackage) { + reason = product.reimbursementProductReason.wbsElement.workPackage.project.wbsElement.name; + } + + if (productsByProjectOrReason.has(reason)) { + appendFileSync('debug.txt', `index: ${i}\n`); + const current = productsByProjectOrReason.get(reason); + appendFileSync('debug.txt', `current: ${JSON.stringify(current)}\n`); + productsByProjectOrReason.set(reason, { + account: current.account, + totalAmount: current.totalAmount + product.cost + }); + appendFileSync( + 'debug.txt', + `amount: ${product.cost}, name: ${product.name}, identifier: ${product.reimbursementRequest.identifier}\n` + ); + appendFileSync('debug.txt', `updated: ${JSON.stringify(productsByProjectOrReason.get(reason))}\n`); + } else { + appendFileSync('debug.txt', `current: 0\n`); + appendFileSync('debug.txt', `index: ${i}\n`); + + productsByProjectOrReason.set(reason, { + account: reason, + totalAmount: product.cost + }); + appendFileSync('debug.txt', `amount: ${product.cost}, name: ${product.name}\n`); + appendFileSync('debug.txt', `updated: ${JSON.stringify(productsByProjectOrReason.get(reason))}\n`); + } + } + }); + + const headers = ['Account', 'Total Amount']; + const data = Array.from(productsByProjectOrReason).map(([key, value]) => [value.account, value.totalAmount / 100.0]); + + const totalAmount = data.reduce((acc, curr) => acc + (curr[1] as number), 0); + + // write csv file + writeFileSync( + 'reimbursementData.csv', + `${headers.join(',')}\n${data.map((row) => row.join(',')).join('\n')}\nTotal Amount,${totalAmount}` + ); +}; + /** * Print metrics on accepted Change Requests with timeline impact */ From 6af41a4f89b48fd9f99e4417fc87c787d8e34018 Mon Sep 17 00:00:00 2001 From: patriots1 Date: Thu, 19 Mar 2026 17:49:02 -0400 Subject: [PATCH 2/4] #3988 fix DOM priority issue stop propogation from tooltips to calendar grid --- .../pages/CalendarPage/CalendarWeekView.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/pages/CalendarPage/CalendarWeekView.tsx b/src/frontend/src/pages/CalendarPage/CalendarWeekView.tsx index dcccbc2085..6295a7d229 100644 --- a/src/frontend/src/pages/CalendarPage/CalendarWeekView.tsx +++ b/src/frontend/src/pages/CalendarPage/CalendarWeekView.tsx @@ -405,7 +405,11 @@ const CalendarWeekView: React.FC = ({ enterDelay={0} leaveDelay={200} title={ - setTooltipHovered(true)} onMouseLeave={() => setTooltipHovered(false)}> + setTooltipHovered(true)} + onMouseLeave={() => setTooltipHovered(false)} + onMouseDown={(e) => e.stopPropagation()} + > = ({ enterDelay={0} leaveDelay={200} title={ - setTooltipHovered(true)} onMouseLeave={() => setTooltipHovered(false)}> + setTooltipHovered(true)} + onMouseLeave={() => setTooltipHovered(false)} + onMouseDown={(e) => e.stopPropagation()} + > = ({ enterDelay={0} leaveDelay={200} title={ - setTooltipHovered(true)} onMouseLeave={() => setTooltipHovered(false)}> + setTooltipHovered(true)} + onMouseLeave={() => setTooltipHovered(false)} + onMouseDown={(e) => e.stopPropagation()} + > setLockedTooltipEventId(null)} /> } From 0012f56a2085d610a25d4d65c88b074f23e814c5 Mon Sep 17 00:00:00 2001 From: patriots1 Date: Thu, 19 Mar 2026 17:58:19 -0400 Subject: [PATCH 3/4] Trigger CI From 11cd70fc99e79ededd51b4e4b8889d60d052f2a6 Mon Sep 17 00:00:00 2001 From: patriots1 Date: Thu, 19 Mar 2026 18:09:24 -0400 Subject: [PATCH 4/4] #3998 fix build issue --- src/backend/src/prisma/manual.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/backend/src/prisma/manual.ts b/src/backend/src/prisma/manual.ts index 4647dbea4b..7f37579661 100644 --- a/src/backend/src/prisma/manual.ts +++ b/src/backend/src/prisma/manual.ts @@ -17,9 +17,7 @@ import { getUserFullName } from '../utils/users.utils.js'; */ /** Execute all given prisma database interaction scripts written in this function */ -const executeScripts = async () => { - await downloadReimbursementDataByProject(); -}; +const executeScripts = async () => {}; /** * Print metrics on accepted Change Requests with timeline impact