diff --git a/backend/models/constants.js b/backend/models/constants.js index 5a61004..b28a442 100644 --- a/backend/models/constants.js +++ b/backend/models/constants.js @@ -9,30 +9,20 @@ const PPR_STATUS = [ 'READY_TO_BUY', 'PURCHASED_AND_RECEIPTS_SUBMITTED', 'REPORTER_REIMBURSE_CONFIRMED', - 'SUBMITTED_FOR_REIMBURSEMENT', - 'REIMBURSED', ] const PPR_STATUS_FUNDING_SPENT = [ 'PURCHASED_AND_RECEIPTS_SUBMITTED', 'REPORTER_REIMBURSE_CONFIRMED', - 'SUBMITTED_FOR_REIMBURSEMENT', - 'REIMBURSED', ] const UPR_STATUS = [ 'SEEKING_APPROVAL', 'SENT_TO_COORDINATOR', 'ORDERED', 'PICKED_UP', - 'SUBMITTED_FOR_REIMBURSEMENT', - 'REIMBURSED', -] -const UPR_STATUS_FUNDING_SPENT = [ - 'ORDERED', - 'PICKED_UP', - 'SUBMITTED_FOR_REIMBURSEMENT', - 'REIMBURSED', ] +const UPR_STATUS_FUNDING_SPENT = ['ORDERED', 'PICKED_UP'] + const APPROVAL_LEVELS = Object.freeze({ director_approval: 'director_approval', team_captain_approval: 'team_captain_approval', diff --git a/backend/service/annotatedGetters.js b/backend/service/annotatedGetters.js index a58113b..c531994 100644 --- a/backend/service/annotatedGetters.js +++ b/backend/service/annotatedGetters.js @@ -151,33 +151,6 @@ const getAnnotatedFundingItemsByIdList = async (idList = []) => { }, }, }, - // filter documents by status (only include docs that count towards amount_reimbursed) - { - $set: { - ppr_docs_reimbursed: { - $filter: { - input: '$ppr_docs', - as: 'ppr_doc', - cond: { - $eq: ['$$ppr_doc.status', 'REIMBURSED'], - }, - }, - }, - }, - }, - { - $set: { - upr_docs_reimbursed: { - $filter: { - input: '$upr_docs', - as: 'upr_doc', - cond: { - $eq: ['$$upr_doc.status', 'REIMBURSED'], - }, - }, - }, - }, - }, { $set: { type: 'FI', @@ -210,30 +183,10 @@ const getAnnotatedFundingItemsByIdList = async (idList = []) => { 2, ], }, - amount_reimbursed: { - $round: [ - { - $sum: [ - { - $sum: '$ppr_docs_reimbursed.cost', - }, - { - $sum: '$upr_docs_reimbursed.cost', - }, - ], - }, - 2, - ], - }, }, }, { - $unset: [ - 'ppr_docs', - 'upr_docs', - 'ppr_docs_reimbursed', - 'upr_docs_reimbursed', - ], + $unset: ['ppr_docs', 'upr_docs'], }, ]) ) @@ -254,7 +207,6 @@ const getAnnotatedSponsorshipFundsByIdList = async (idList = []) => { idList.map(async (id) => { const sponsorshipFund = await SponsorshipFund.findById(id) let fundingSpent = 0 - let amountReimbursed = 0 if (sponsorshipFund.fi_links.length > 0) { const fundingItemList = await getAnnotatedFundingItemsByIdList( sponsorshipFund.fi_links @@ -262,9 +214,6 @@ const getAnnotatedSponsorshipFundsByIdList = async (idList = []) => { fundingSpent = fundingItemList .map((fundingItem) => fundingItem.funding_spent) .reduce((a, b) => a + b, 0) - amountReimbursed = fundingItemList - .map((fundingItem) => fundingItem.amount_reimbursed) - .reduce((a, b) => a + b, 0) } return SponsorshipFund.aggregate([ { @@ -292,7 +241,6 @@ const getAnnotatedSponsorshipFundsByIdList = async (idList = []) => { $concat: ['/SF/', { $toString: '$_id' }], }, funding_spent: fundingSpent, - amount_reimbursed: amountReimbursed, name: { $concat: ['$organization', ' - ', '$semester'], }, diff --git a/frontend/src/components/TicketContent/UPRAdminContentTable.js b/frontend/src/components/TicketContent/UPRAdminContentTable.js index 6eaaa38..47d7d32 100644 --- a/frontend/src/components/TicketContent/UPRAdminContentTable.js +++ b/frontend/src/components/TicketContent/UPRAdminContentTable.js @@ -50,6 +50,26 @@ const UPRAdminContentTable = () => { payload ) await getAllTickets(setAllTickets) + setCurrentTicket({ + ...currentTicket, + status: 'ORDERED', + }) + setChanged(false) + } + + const transitionToPickedUp = async () => { + const payload = { + status: 'PICKED_UP', + } + await axiosPreset.patch( + `${TICKET_ENDPOINTS.UPR}/${currentTicket._id}`, + payload + ) + await getAllTickets(setAllTickets) + setCurrentTicket({ + ...currentTicket, + status: 'PICKED_UP', + }) setChanged(false) } @@ -77,7 +97,7 @@ const UPRAdminContentTable = () => {
- {currentTicket.status === 'SENT_TO_COORDINATOR' ? ( + {currentTicket.status === 'SENT_TO_COORDINATOR' && ( - ) : ( + )} + {currentTicket.status === 'ORDERED' && ( )} +
)