Skip to content

Commit

Permalink
Error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
datajohnson committed Jun 12, 2024
1 parent 889e016 commit be35692
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions src/api/repositories/assessment/assessment-cslft-repository-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,33 @@ export class AssessmentCslftRepositoryV2 {

console.log("CONRIB", contribution);

input.parent_weekly_contrib =
(contribution.add_amount +
(input.parent_discretionary_income - contribution.subtract_amount) * (contribution.percentage / 100)) /
contribution.divide_by;

input.parent_contribution = input.parent_weekly_contrib * input.study_weeks;
if (contribution) {
input.parent_weekly_contrib =
(contribution.add_amount +
(input.parent_discretionary_income - contribution.subtract_amount) * (contribution.percentage / 100)) /
contribution.divide_by;

input.parent_contribution = input.parent_weekly_contrib * input.study_weeks;
} else {
console.log(
"Contribution Formula not found for ",
this.application.academic_year_id,
input.parent_discretionary_income
);

contribution = await this.db("sfa.parent_contribution_formula")
.where({ academic_year_id: this.application.academic_year_id })
.first();

input.parent_weekly_contrib =
(contribution.add_amount +
(input.parent_discretionary_income - contribution.subtract_amount) * (contribution.percentage / 100)) /
contribution.divide_by;

input.parent_contribution = input.parent_weekly_contrib * input.study_weeks;

console.log("INSTEAD USING BASIC: ", contribution);
}
}
}
}
Expand Down Expand Up @@ -560,6 +581,8 @@ parent_contribution
this.application.csl_classification,
this.application.study_accom_code
);

console.log("CAT IS", this.application.category_id);
}

async loadLookups() {
Expand Down Expand Up @@ -1011,6 +1034,10 @@ 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;
} else if (cslClassification == 1 && accomodationCode == 2) {
Expand Down

0 comments on commit be35692

Please sign in to comment.