Skip to content

Commit

Permalink
Merge pull request #258 from icefoganalytics/test
Browse files Browse the repository at this point in the history
Bug Fixes 6/17
  • Loading branch information
datajohnson authored Jun 17, 2024
2 parents 11b1108 + 9ee890f commit e21586c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 23 deletions.
20 changes: 17 additions & 3 deletions src/api/models/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,9 @@ export function FundingFromDraft(draft: any): any[] {
yea_request_amount: cleanNumber(yea_request_amount),
});

if (hasDependents && request_type_id == 4) {
if (request_type_id == 4) {
funding.push({
request_type_id: 32, // Dependent grant for FT
request_type_id: 35, // Grant for FT
status_id: 32, // Online status per Mariazel
received_date: new Date(),
status_date: new Date(),
Expand All @@ -616,8 +616,22 @@ export function FundingFromDraft(draft: any): any[] {
csl_request_amount: application_type_id == 2 ? cleanNumber(loan_amount) : 0,
is_csl_full_amount: application_type_id == 2 && csfa_amounts == "Full amount loans and grants",
is_csg_only: csfa_amounts == "Grants only",
yea_request_amount: cleanNumber(yea_request_amount),
});

if (hasDependents) {
funding.push({
request_type_id: 32, // Dependent grant for FT
status_id: 32, // Online status per Mariazel
received_date: new Date(),
status_date: new Date(),
entering_first_year: draft.program_details.year_entering == 1,
student_is_in_ft_study: draft.program_details.attendance == "Full Time",
csl_request_amount: application_type_id == 2 ? cleanNumber(loan_amount) : 0,
is_csl_full_amount: application_type_id == 2 && csfa_amounts == "Full amount loans and grants",
is_csg_only: csfa_amounts == "Grants only",
yea_request_amount: cleanNumber(yea_request_amount),
});
}
} else if (hasDependents && request_type_id == 5) {
funding.push({
request_type_id: 33, // Dependent grant for PT
Expand Down
24 changes: 10 additions & 14 deletions src/api/repositories/assessment/assessment-cslft-repository-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,12 @@ export class AssessmentCslftRepositoryV2 {
input.parent_discretionary_income = Math.round(input.parent_net_income_total - input.parent_msol);

if (input.parent_discretionary_income > 0) {
console.log("FIND IT", this.application.academic_year_id, input.parent_discretionary_income);

let contribution = await this.db("sfa.parent_contribution_formula")
.where({ academic_year_id: this.application.academic_year_id })
.where("income_from_amount", ">=", input.parent_discretionary_income)
.where("income_to_amount", "<=", input.parent_discretionary_income)
.first();

console.log("CONRIB", contribution);

if (contribution) {
input.parent_weekly_contrib =
(contribution.add_amount +
Expand Down Expand Up @@ -324,7 +320,7 @@ export class AssessmentCslftRepositoryV2 {
} else {
//input.student_previous_contribution = 0; // not sure what to do with this???

input.student_contrib_exempt_reason = "ExempltThis is a test";
input.student_contrib_exempt_reason = "";
total_contribution += input.student_contribution + input.student_other_resources;
}
} else {
Expand Down Expand Up @@ -361,7 +357,7 @@ export class AssessmentCslftRepositoryV2 {
input.spouse_contrib_exempt_reason = "Not Applicable";

if (input.student_contrib_exempt == "NO") {
input.student_contrib_exempt_reason = "Not Exempt" + input.student_contrib_exempt;
input.student_contrib_exempt_reason = "Not Exempt";

if (input.student_contribution_override) {
total_contribution += input.student_contribution_override;
Expand Down Expand Up @@ -614,7 +610,7 @@ parent_contribution
async calculateBase(): Promise<CSLFTAssessmentBase> {
let assess = clone(DEFAULT_BASE);

assess.assessment_type_id = this.assessments.length > 1 ? 2 : 1;
assess.assessment_type_id = this.assessments.length > 0 ? 2 : 1;
assess.funding_request_id = this.fundingRequest.id;
assess.classes_start_date = this.application.classes_start_date;
assess.classes_end_date = this.application.classes_end_date;
Expand Down Expand Up @@ -916,7 +912,8 @@ parent_contribution
} else {
const weekly_student_contrib =
(this.cslLookup.low_income_student_contrib_amount ?? 0) / e_month +
((family_income - income_threshold) / e_month) * (this.cslLookup.student_contrib_percent ?? 0);
((family_income - income_threshold) / e_month) * ((this.cslLookup.student_contrib_percent ?? 0) / 100);

const weekly_calc = weekly_student_contrib * Math.min(assess.study_weeks ?? 0, max_weeks) ?? 0;
assess.student_expected_contribution = Math.min(weekly_calc, this.cslLookup.student_contrib_max_amount ?? 0);
}
Expand Down Expand Up @@ -950,7 +947,8 @@ parent_contribution
assess.student_contribution =
assess.student_contrib_exempt === "YES"
? 0
: (assess.student_expected_contribution ?? 0) - assess.student_previous_contribution + student_other_resources;
: (assess.student_expected_contribution ?? 0) /* - assess.student_previous_contribution */ +
student_other_resources;

// if spouse is not employed or full time student
if (this.application.spouse_study_emp_status_id != 4 || this.spouseIsFullTimeStudent())
Expand All @@ -961,15 +959,16 @@ parent_contribution

if (assess.csl_classification == 3 && family_income > income_threshold) {
const weekly_spouse_contrib =
this.cslLookup.spouse_contrib_percent * ((family_income - income_threshold) / e_month);
(this.cslLookup.spouse_contrib_percent / 100) * ((family_income - income_threshold) / e_month);

assess.spouse_expected_contribution = Math.round(
weekly_spouse_contrib * Math.min(assess.study_weeks ?? 0, max_weeks)
);

assess.spouse_contribution =
assess.spouse_contrib_exempt === "YES"
? 0
: Math.round((assess.spouse_expected_contribution ?? 0) - assess.spouse_previous_contribution);
: Math.round(assess.spouse_expected_contribution ?? 0 /* - assess.spouse_previous_contribution */);
} else {
assess.spouse_expected_contribution = 0;
assess.spouse_previous_contribution = 0;
Expand Down Expand Up @@ -1032,11 +1031,8 @@ parent_contribution
}

determineCategoryId(cslClassification: number, accomodationCode: number): number {
console.log("FINDING CATE", cslClassification, accomodationCode);

cslClassification = 1;
accomodationCode = 2;
console.log("FINDING CATE22", cslClassification, accomodationCode);

if (cslClassification == 1 && accomodationCode == 1) {
return this.studentCategories.find((c: any) => c.code == "SDH")?.id || -1;
Expand Down
2 changes: 1 addition & 1 deletion src/api/routes/admin/catalog/catalog-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ catalogRouter.post("/rate_tables/:academic_year_id", async (req: Request, res: R
quarter_tuition_amount: 0,
quarter_book_amount: 0,
weekly_amount: 0,
allowed_percent: 0,
allowed_percent: 100,
});

const incomeRanges = [
Expand Down
4 changes: 3 additions & 1 deletion src/api/routes/admin/csg-threshold-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,9 @@ csgThresholdRouter.get(
.orderBy("issue_date")
.orderBy("id");

return res.json({ data: { funding_request, assessment, disbursements } });
let msfaa = await db("sfa.msfaa").where({ application_id }).first();

return res.json({ data: { funding_request, assessment, disbursements, msfaa } });
}

res.status(404).send("Funding Request not found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,14 @@ const actions = {
});
},

async createAssessment({ state }) {
async createAssessment({ state, dispatch }) {
let url = `${CSG_THRESHOLD_URL}/cslft/${state.application.id}/funding-request/${state.fundingRequest.id}/assessment`;

axios.post(url).then(async (resp) => {
console.log("RESP", resp);
axios.post(url).then((resp) => {
dispatch("loadCSLFTAssessment", {
applicationId: state.fundingRequest.application_id,
assessmentId: state.assessment.id,
});
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
outlined
hide-details
:background-color="determineColor(header.text)"

:readonly="determineColor(header.text) != 'white'"
:append-icon="determineColor(header.text) == 'white' ? '' : 'mdi-lock'"
/>
</v-col>
</v-row>
Expand All @@ -77,6 +78,9 @@ export default {
"quarter_living_amount",
"quarter_tuition_amount",
"quarter_book_amount",
"student_exempt_amount",
"csg_pt_yearly_amount",
"allowed_percent",
],
}),
computed: {
Expand Down Expand Up @@ -110,6 +114,7 @@ export default {
},
determineColor(text) {
if (this.deprecatedFields.includes(text)) return "warning lighten-3";
if (this.tableName == "csl_lookup" && text == "csg_8_month_amount") return "warning lighten-3";
return "white";
},
Expand Down

0 comments on commit e21586c

Please sign in to comment.