Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
28a2a19
#3271: still getting a null constraint in seed data and tests
wavehassman Mar 6, 2025
6133907
#3271: prettier + linting
wavehassman Mar 6, 2025
d8aa4eb
Merge branch 'feature/finance-redesign' into #3271-rerun-schema-changes
wavehassman Mar 11, 2025
83c16c5
#3271: error utils
wavehassman Mar 11, 2025
b6aa024
#3271 fixed null constraint
wavehassman Mar 22, 2025
2795eb0
#3271 uncomment seed data
wavehassman Mar 22, 2025
f80896b
#3271 prettier
wavehassman Mar 22, 2025
80e824a
#3271: endpoints and hooks work
wavehassman Mar 24, 2025
1b68e66
#3271: prettier
wavehassman Mar 24, 2025
5723b9d
#3271 requested changes
wavehassman Mar 26, 2025
2fbf051
migration changes
wavehassman Mar 29, 2025
04b15d8
migration changes
wavehassman Mar 29, 2025
2ab1e87
#3271 index coes organization bound
wavehassman Mar 29, 2025
e81deba
Merge branch 'feature/finance-redesign' into #3271-rerun-schema-changes
wavehassman Apr 1, 2025
21d7ed1
Revert "Merge branch 'feature/finance-redesign' into #3271-rerun-sche…
wavehassman Apr 1, 2025
c5857d7
revert 1 commit
wavehassman Apr 1, 2025
d18030a
Revert "Merge branch 'feature/finance-redesign' into #3271-rerun-sche…
wavehassman Apr 1, 2025
6367f73
maybe rebasing will help??
wavehassman Apr 1, 2025
caec5cb
fix merge
wavehassman Mar 6, 2025
cbd8e64
migration merge
wavehassman Mar 22, 2025
470191d
more rebase
wavehassman Mar 24, 2025
0552a08
migration changes
wavehassman Mar 29, 2025
7f7a8a4
revert 1 commit
wavehassman Apr 1, 2025
7401e64
#3271: learned my lesson to not use git hub to fix merge conflicts
wavehassman Apr 1, 2025
2e46d16
Merge branch '#3271-rerun-schema-changes' of https://github.com/North…
wavehassman Apr 1, 2025
3e90a5e
#3271: changed query args to make more sense
wavehassman Apr 1, 2025
9614a73
merge develop into feature
wavehassman Apr 2, 2025
5c06a89
#3271 New Migration
wavehassman Apr 2, 2025
770c2f8
#3271 Edit Migration
wavehassman Apr 2, 2025
f536c08
#3271: migration
wavehassman Apr 2, 2025
abb5996
#3271 naming changes
wavehassman Apr 2, 2025
588821a
#3271: added code to index code
wavehassman Apr 2, 2025
1023c28
#3271 merge conflicts
wavehassman Apr 4, 2025
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
110 changes: 106 additions & 4 deletions src/backend/src/controllers/reimbursement-requests.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class ReimbursementRequestsController {
const {
dateOfExpense,
vendorId,
account,
indexCodeId,
otherReimbursementProducts,
wbsReimbursementProducts,
accountCodeId,
Expand All @@ -66,7 +66,7 @@ export default class ReimbursementRequestsController {
const createdReimbursementRequest = await ReimbursementRequestService.createReimbursementRequest(
user,
vendorId,
account,
indexCodeId,
otherReimbursementProducts,
wbsReimbursementProducts,
accountCodeId,
Expand Down Expand Up @@ -101,7 +101,7 @@ export default class ReimbursementRequestsController {
const {
dateOfExpense,
vendorId,
account,
indexCodeId,
accountCodeId,
totalCost,
otherReimbursementProducts,
Expand All @@ -112,7 +112,7 @@ export default class ReimbursementRequestsController {
const updatedReimbursementRequestId = await ReimbursementRequestService.editReimbursementRequest(
requestId,
vendorId,
account,
indexCodeId,
accountCodeId,
totalCost,
otherReimbursementProducts,
Expand Down Expand Up @@ -468,4 +468,106 @@ export default class ReimbursementRequestsController {
next(error);
}
}

static async createIndexCode(req: Request, res: Response, next: NextFunction) {
try {
const { name, code } = req.body;
const indexCode = await ReimbursementRequestService.createIndexCode(name, code, req.currentUser, req.organization);
res.status(200).json(indexCode);
} catch (error: unknown) {
next(error);
}
}

static async getSingleIndexCode(req: Request, res: Response, next: NextFunction) {
try {
const { indexCodeId } = req.params;

const indexCode = await ReimbursementRequestService.getSingleIndexCode(indexCodeId, req.organization);

res.status(200).json(indexCode);
} catch (error: unknown) {
next(error);
}
}

static async getAllIndexCodes(req: Request, res: Response, next: NextFunction) {
try {
const indexCodes = await ReimbursementRequestService.getAllIndexCodes(req.organization);
res.status(200).json(indexCodes);
} catch (error: unknown) {
next(error);
}
}

static async deleteIndexCode(req: Request, res: Response, next: NextFunction) {
try {
const { indexCodeId } = req.params;

const deletedIndexCode = await ReimbursementRequestService.deleteIndexCode(
indexCodeId,
req.currentUser,
req.organization
);
res.status(200).json(deletedIndexCode);
} catch (error: unknown) {
next(error);
}
}

static async createOtherReimbursementProductReason(req: Request, res: Response, next: NextFunction) {
try {
const { name, budget, indexCodeId, accountCodes } = req.body;
const otherReimbursementProductReason = await ReimbursementRequestService.createOtherReimbursementProductReason(
name,
budget,
indexCodeId,
accountCodes,
req.currentUser,
req.organization
);
res.status(200).json(otherReimbursementProductReason);
} catch (error: unknown) {
next(error);
}
}

static async getAllOtherReimbursementProductReasons(req: Request, res: Response, next: NextFunction) {
try {
const otherReimbursementProductReasons = await ReimbursementRequestService.getAllOtherReimbursementProductReasons(
req.organization
);
res.status(200).json(otherReimbursementProductReasons);
} catch (error: unknown) {
next(error);
}
}

static async getSingleOtherReimbursementProductReason(req: Request, res: Response, next: NextFunction) {
try {
const { otherReimbursementProductReasonId } = req.params;
const otherProductReason = await ReimbursementRequestService.getSingleOtherReimbursementProductReason(
otherReimbursementProductReasonId,
req.organization
);
res.status(200).json(otherProductReason);
} catch (error: unknown) {
next(error);
}
}

static async deleteOtherReimbursementProductReason(req: Request, res: Response, next: NextFunction) {
try {
const { otherReimbursementProductReasonId } = req.params;

const deletedOtherProductReason = await ReimbursementRequestService.deleteOtherReimbursementProductReason(
otherReimbursementProductReasonId,
req.currentUser,
req.organization
);
res.status(200).json(deletedOtherProductReason);
} catch (error: unknown) {
next(error);
}
}
}
21 changes: 21 additions & 0 deletions src/backend/src/prisma-query-args/account-code.query-args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Prisma } from '@prisma/client';
import { getUserQueryArgs } from './user.query-args';

export type AccountCodeQueryArgs = ReturnType<typeof getAccountCodeQueryArgs>;

export const getAccountCodeQueryArgs = (organizationId: string) =>
Prisma.validator<Prisma.Account_CodeDefaultArgs>()({
include: {
indexCodes: {
include: {
userCreated: {
...getUserQueryArgs(organizationId),
include: {
organizations: true,
roles: true
}
}
}
}
}
});
17 changes: 17 additions & 0 deletions src/backend/src/prisma-query-args/index-code.query-args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Prisma } from '@prisma/client';
import { getUserQueryArgs } from './user.query-args';

export type IndexCodeQueryArgs = ReturnType<typeof getIndexCodeQueryArgs>;

export const getIndexCodeQueryArgs = (organizationId: string) =>
Prisma.validator<Prisma.Index_CodeDefaultArgs>()({
include: {
userCreated: {
...getUserQueryArgs(organizationId),
include: {
roles: true,
organizations: true
}
}
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Prisma } from '@prisma/client';
import { getUserQueryArgs } from './user.query-args';
import { getIndexCodeQueryArgs } from './index-code.query-args';
import { getAccountCodeQueryArgs } from './account-code.query-args';

export type ReimbursementProductOtherReasonQueryArgs = ReturnType<typeof getReimbursementProductOtherReasonQueryArgs>;

export const getReimbursementProductOtherReasonQueryArgs = (organizationId: string) =>
Prisma.validator<Prisma.Reimbursement_Product_Other_ReasonDefaultArgs>()({
include: {
userCreated: getUserQueryArgs(organizationId),
indexCode: getIndexCodeQueryArgs(organizationId),
accountCodes: getAccountCodeQueryArgs(organizationId)
}
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Prisma } from '@prisma/client';
import { getReimbursementProductOtherReasonQueryArgs } from './reimbursement-product-other-reason.query-args';

export type ReimbursementProductQueryArgs = ReturnType<typeof getReimbursementProductQueryArgs>;

export type ReimbursementProductReasonQueryArgs = ReturnType<typeof getReimbursementProductReasonQueryArgs>;

export const getReimbursementProductReasonQueryArgs = (_organizationId: string) =>
export const getReimbursementProductReasonQueryArgs = (organizationId: string) =>
Prisma.validator<Prisma.Reimbursement_Product_ReasonDefaultArgs>()({
include: {
wbsElement: true
wbsElement: true,
otherReason: getReimbursementProductOtherReasonQueryArgs(organizationId)
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { getVendorQueryArgs } from './vendor.query-args';
import { getUserQueryArgs } from './user.query-args';
import { getReceiptQueryArgs } from './receipt-query.args';
import { getReimbursementProductQueryArgs } from './reimbursement-products.query-args';
import { getIndexCodeQueryArgs } from './index-code.query-args';
import { getAccountCodeQueryArgs } from './account-code.query-args';

export type ReimbursementRequestQueryArgs = ReturnType<typeof getReimbursementRequestQueryArgs>;

Expand All @@ -12,7 +14,8 @@ export const getReimbursementRequestQueryArgs = (organizationId: string) =>
include: {
recipient: getUserQueryArgs(organizationId),
vendor: getVendorQueryArgs(organizationId),
accountCode: true,
indexCode: getIndexCodeQueryArgs(organizationId),
accountCode: getAccountCodeQueryArgs(organizationId),
receiptPictures: getReceiptQueryArgs(organizationId),
reimbursementStatuses: getReimbursementStatusQueryArgs(organizationId),
reimbursementProducts: {
Expand Down
17 changes: 9 additions & 8 deletions src/backend/src/prisma/manual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import prisma from './prisma';
import { Club_Accounts, Reimbursement_Status_Type, WBS_Element_Status } from '@prisma/client';
import { Reimbursement_Status_Type, WBS_Element_Status } from '@prisma/client';
import { calculateEndDate } from 'shared';
import { writeFileSync } from 'fs';
import { getUserFullName } from '../utils/users.utils';
Expand Down Expand Up @@ -164,14 +164,14 @@ const downloadReimbursementRequests = async () => {
where: {
dateDeleted: null
},
include: { reimbursementStatuses: true, vendor: true }
include: { reimbursementStatuses: true, vendor: true, indexCode: true }
});

const promises = rrs.map(
async (rr) =>
await `${rr.saboId},${await getUserFullName(rr.recipientId)},${rr.totalCost},${
rr.reimbursementStatuses[rr.reimbursementStatuses.length - 1].type
},${rr.account},${rr.dateCreated},${rr.dateDelivered ?? ''},${
},${rr.indexCode},${rr.dateCreated},${rr.dateDelivered ?? ''},${
rr.reimbursementStatuses.find((rs) => rs.type === Reimbursement_Status_Type.SABO_SUBMITTED)?.dateCreated ?? ''
},${rr.vendor.name}`
);
Expand All @@ -188,7 +188,8 @@ const getTotalAmountOwedForCashAndBudgetForSubmittedToSaboAndPendingFinanceTeam
dateDeleted: null
},
include: {
reimbursementStatuses: true
reimbursementStatuses: true,
indexCode: true
}
});

Expand All @@ -201,27 +202,27 @@ const getTotalAmountOwedForCashAndBudgetForSubmittedToSaboAndPendingFinanceTeam
);

const totalAmountOwedForCashSabo = submittedToSabo.reduce((acc, curr) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming other organizations won't have the exact same accounts as us, this will have to be reworked. You should make it another ticket but it def needs to be done

Copy link
Copy Markdown
Contributor Author

@wavehassman wavehassman Mar 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would someone go about this like high level? Trying to write up a ticket and am stuck

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh actually I didn't realize this was the manual file, don't worry about it

if (curr.account === 'CASH') {
if (curr.indexCode.name === 'CASH') {
return acc + curr.totalCost / 100;
}
return 0;
}, 0);
const totalAmountOwedForBudgetSabo = submittedToSabo.reduce((acc, curr) => {
if (curr.account === Club_Accounts.BUDGET) {
if (curr.indexCode.name === 'Budget') {
return acc + curr.totalCost / 100;
}
return acc + 0;
}, 0);

const totalAmountOwedForCashFinance = pendingFinance.reduce((acc, curr) => {
if (curr.account === Club_Accounts.CASH) {
if (curr.indexCode.name === 'Cash') {
return acc + curr.totalCost / 100;
}
return acc + 0;
}, 0);

const totalAmountOwedForBudgetFinance = pendingFinance.reduce((acc, curr) => {
if (curr.account === Club_Accounts.BUDGET) {
if (curr.indexCode.name === 'Budget') {
return acc + curr.totalCost / 100;
}
return acc + 0;
Expand Down
Loading