Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added picked up status transition #171

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 2 additions & 12 deletions backend/models/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
54 changes: 1 addition & 53 deletions backend/service/annotatedGetters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'],
},
])
)
Expand All @@ -254,17 +207,13 @@ 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
)
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([
{
Expand Down Expand Up @@ -292,7 +241,6 @@ const getAnnotatedSponsorshipFundsByIdList = async (idList = []) => {
$concat: ['/SF/', { $toString: '$_id' }],
},
funding_spent: fundingSpent,
amount_reimbursed: amountReimbursed,
name: {
$concat: ['$organization', ' - ', '$semester'],
},
Expand Down
41 changes: 35 additions & 6 deletions frontend/src/components/TicketContent/UPRAdminContentTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -77,7 +97,7 @@ const UPRAdminContentTable = () => {
</Table>

<Center pb="7px">
{currentTicket.status === 'SENT_TO_COORDINATOR' ? (
{currentTicket.status === 'SENT_TO_COORDINATOR' && (
<Button
colorScheme="blue"
size="sm"
Expand All @@ -90,16 +110,25 @@ const UPRAdminContentTable = () => {
>
Transition To Purchased
</Button>
) : (
)}
{currentTicket.status === 'ORDERED' && (
<Button
colorScheme="green"
colorScheme="blue"
size="sm"
onClick={saveFields}
disabled={!changed}
mr="20px"
onClick={transitionToPickedUp}
>
Save Fields
Transition To Picked Up
</Button>
)}
<Button
colorScheme="green"
size="sm"
onClick={saveFields}
disabled={!changed}
>
Save Fields
</Button>
</Center>
</VStack>
)
Expand Down
Loading