Skip to content

Commit

Permalink
Merge pull request #149 from icefoganalytics/test
Browse files Browse the repository at this point in the history
CSLFT Parent contribution fix
  • Loading branch information
datajohnson authored Sep 16, 2023
2 parents 4451f65 + 1dd0bcf commit 4dbdd7f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion db/4_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2909,7 +2909,8 @@ FROM sfa.person p
LEFT JOIN sfa.person_address pa
ON pa.person_id = p.id
WHERE p.id = @person_id
AND pa.address_type_id = @address_type;
AND pa.address_type_id = @address_type
AND pa.is_active = 1;
GO

-- Get Standard Living Amount
Expand Down
2 changes: 1 addition & 1 deletion src/api/routes/admin/application-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ applicationRouter.patch(
delete data.student_id;
}
const resUpdate = await db("sfa.person_address")
.update({ ...data })
.update({ ...data, is_active: true })
.where({ id: person_address_id })
.returning("*");

Expand Down
5 changes: 4 additions & 1 deletion src/web/src/modules/cslft/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,10 @@ const getters = {
return Math.max(numHelper.round(getters.cslft_parent_net_income - numHelper.getNum(state.cslft.parent_msol)), 0);
},
cslft_calculated_parental_contribution(state, getters) {
return numHelper.getNum(state.cslft.parent_ps_depend_count) === 0 ? 0 : numHelper.round(numHelper.getNum(state.cslft.parent_weekly_contrib) * numHelper.getNum(state.cslft.study_weeks) / numHelper.getNum(state.cslft.parent_ps_depend_count));
let baseDependCount = state.cslft.parent_ps_depend_count || 0; // this does not include current student
baseDependCount +=1;

return numHelper.round(numHelper.getNum(state.cslft.parent_weekly_contrib) * numHelper.getNum(state.cslft.study_weeks) / baseDependCount);
},
cslft_parent_total_contribution(state, getters) {
return numHelper.round(Math.max(numHelper.getNum(state.cslft.parent_contribution_override), numHelper.getNum(getters.cslft_calculated_parental_contribution)));
Expand Down

0 comments on commit 4dbdd7f

Please sign in to comment.