Skip to content

Commit

Permalink
feat: Round budget requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
coire1 committed Jul 15, 2024
1 parent d0a24a6 commit dbaf22e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion milestone-tracker-frontend/src/components/forms/NewSom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const otherSomsBudget = computed(() => {
const missingMilestones = milestonesIndex.filter(m => !otherSoms.value.map(o => o.milestone).includes(m))
missingMilestones.forEach((m) => {
if (m !== props.milestone) {
const cost = (m === lastMilestone) ? props.proposal.budget * 0.15 : props.proposal.budget * 0.05
const cost = (m === lastMilestone) ? Math.floor(props.proposal.budget * 0.15) : Math.floor(props.proposal.budget * 0.05)
definedCost = definedCost + cost
}
})
Expand Down
27 changes: 17 additions & 10 deletions milestone-tracker-frontend/src/utils/milestones.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,19 @@ const canAllSomsBeSignedOffByReviews = (soms, fundId) => {
}

const isPreviousSomSignedOff = (soms, currentSom) => {
if (currentSom.milestone === 1) {
return true
}
const previousMl = soms.find((s) => s.milestone === currentSom.milestone - 1)
if (previousMl) {
return previousMl.signoffs.length > 0
if (currentSom) {
if (currentSom.milestone === 1) {
return true
}
const previousMl = soms.find((s) => {
if (s) {
return s.milestone === currentSom.milestone - 1
}
return false
})
if (previousMl) {
return previousMl.signoffs.length > 0
}
}
return false
}
Expand All @@ -237,7 +244,7 @@ const maxCostF9 = (proposal, otherSomsBudget, isLastMilestone) => {
const availableBudget = proposal.budget - otherSomsBudget
const maxMilestoneBudget = parseFloat(env.VITE_MAX_MILESTONE_BUDGET)
const budgetRule = Math.min(
(proposal.budget * maxMilestoneBudget), availableBudget
Math.ceil(proposal.budget * maxMilestoneBudget), availableBudget
)
if (!isLastMilestone && proposal.budget > 0) {
return budgetRule
Expand All @@ -258,12 +265,12 @@ const maxMonthF9 = () => 24

const minCostF10 = (proposal, milestone, isLastMilestone) => {
return () => {
let _min = proposal.budget * 0.05
let _min = Math.floor(proposal.budget * 0.05)
if (milestone === 1) {
_min = Math.min(_min, 75000)
}
if (isLastMilestone) {
_min = proposal.budget * 0.15
_min = Math.floor(proposal.budget * 0.15)
}
return _min
}
Expand All @@ -274,7 +281,7 @@ const maxCostF10 = (proposal, otherSomsBudget, isLastMilestone, milestone) => {
const availableBudget = proposal.budget - otherSomsBudget
const maxMilestoneBudget = 0.30
const budgetRule = Math.min(
(proposal.budget * maxMilestoneBudget), availableBudget
Math.ceil(proposal.budget * maxMilestoneBudget), availableBudget
)
const _max = (!isLastMilestone && proposal.budget > 0) ? budgetRule : availableBudget
if (milestone === 1) {
Expand Down

0 comments on commit dbaf22e

Please sign in to comment.