Skip to content

Commit 4a1c0ea

Browse files
authored
Merge pull request #3527 from Northeastern-Electric-Racing/#3526-finance-visual-fixes
numbers and spending bar
2 parents 99549c8 + 65319c0 commit 4a1c0ea

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

src/backend/src/utils/finance.utils.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { Prisma, Reimbursement_Status_Type } from '@prisma/client';
22
import { wbsPipe, SpendingBarData, ReimbursementRequestData } from 'shared';
33
import prisma from '../prisma/prisma';
4-
import { getReimbursementRequestQueryArgs } from '../prisma-query-args/reimbursement-requests.query-args';
54
import { NotFoundException } from './errors.utils';
6-
import { getTeamQueryArgs } from '../prisma-query-args/teams.query-args';
75

86
export const getProjectSegmentedWhereInput = (
97
organizationId: string,
@@ -214,7 +212,7 @@ export const getReimbursementRequestsByProject = async (
214212
},
215213
select: {
216214
reimbursementStatuses: true,
217-
totalCost: true,
215+
totalCost: true
218216
}
219217
});
220218

@@ -314,7 +312,7 @@ export const getReimbursementRequestsByTeam = async (
314312
},
315313
select: {
316314
reimbursementStatuses: true,
317-
totalCost: true,
315+
totalCost: true
318316
}
319317
});
320318

@@ -668,7 +666,7 @@ export const getReimbursementRequestCategoryData = async (
668666
},
669667
select: {
670668
reimbursementStatuses: true,
671-
totalCost: true,
669+
totalCost: true
672670
}
673671
});
674672

src/frontend/src/apis/finance.api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ export const downloadBlobsToPdf = async (blobData: Blob[], filename: string) =>
293293
await Promise.all(promises);
294294

295295
// Save the PDF as an ArrayBuffer
296-
const pdfBytes = await pdfDoc.save();
296+
const pdfBytes: Uint8Array = await pdfDoc.save();
297297

298298
// Convert the ArrayBuffer to a Blob
299-
const pdfBlob = new Blob([pdfBytes], { type: 'application/pdf' });
299+
const pdfBlob = new Blob([pdfBytes.buffer as ArrayBuffer], { type: 'application/pdf' });
300300

301301
// Save the Blob as a file using file-saver
302302
saveAs(pdfBlob, filename);

src/frontend/src/pages/FinancePage/FinanceComponents/PieChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const FinancePieChart: React.FC<FinancePieChartProps> = ({
203203
</Box>
204204
) : (
205205
<>
206-
<ResponsiveContainer width="100%" height={300} style={{ background: 'transparent' }}>
206+
<ResponsiveContainer width={250} height={250} style={{ background: 'transparent' }}>
207207
<RechartsPieChart margin={{ top: 0, right: 0, bottom: 20, left: 0 }} style={{ background: 'transparent' }}>
208208
<Pie
209209
data={adjustedData}

src/frontend/src/pages/FinancePage/FinanceComponents/SpendingBar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ const SpendingBar = ({ data, title, edit }: SpendingBarProps) => {
160160
align: 'center',
161161
textAlign: 'center',
162162
formatter: (value, context) => {
163-
const realValue = value - average;
163+
const realValue = Math.round((value - average) * 100) / 100;
164164
let { label } = context.dataset;
165165
const datasetMeta = context.chart.getDatasetMeta(context.datasetIndex);
166166
const bar: any = datasetMeta.data[context.dataIndex];
@@ -207,10 +207,10 @@ const SpendingBar = ({ data, title, edit }: SpendingBarProps) => {
207207

208208
const title = context.dataset.label;
209209

210-
const value = context.parsed.x - average; // for horizontal bar, use .x — use .y for vertical
210+
const value = Math.round((context.parsed.x - average) * 100) / 100; // for horizontal bar, use .x — use .y for vertical
211211

212212
if (dataset.spendingInfo.totalBudget < getTotalMoneySpentNotAvailable(dataset.spendingInfo)) {
213-
return `Spending is $${Math.abs(dataset.spendingInfo.available)} overbudget!`;
213+
return `Spending is $${Math.abs(Math.round(dataset.spendingInfo.available * 100) / 100)} overbudget!`;
214214
}
215215

216216
return `${title}: $${value}`;

0 commit comments

Comments
 (0)