Skip to content

Commit

Permalink
Merge pull request #296 from icefoganalytics/test
Browse files Browse the repository at this point in the history
Vendor PDF Formatting
  • Loading branch information
datajohnson authored Aug 21, 2024
2 parents 3d0cb31 + 785108c commit 8d1dbf3
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { StandardOfLivingRepository } from "../standard_of_living";
import { ParentRepository } from "../parent";
import { CsgLookupRepository } from "../csg_lookup";
import { CsgThresholdRepository } from "../csg_threshold";
import { weeksBetween } from "@/utils/date-utils";

export class AssessmentCsgftRepository extends AssessmentBaseRepository {

Expand Down Expand Up @@ -340,8 +341,7 @@ export class AssessmentCsgftRepository extends AssessmentBaseRepository {
this.assessment.classes_start_date = this.application.classes_start_date;
this.assessment.classes_end_date = this.application.classes_end_date;
this.assessment.csl_classification = this.application.csl_classification;
const daysDiff = moment.utc(this.assessment.classes_end_date).diff(moment(this.assessment.classes_start_date), "day");
this.assessment.study_weeks = Math.trunc((daysDiff + 1)/7 + .9999);
this.assessment.study_weeks = weeksBetween(this.assessment.classes_start_date, this.assessment.classes_end_date)

this.assessment.parent1_income = this.application.parent1_income;
this.assessment.parent2_income = this.application.parent2_income;
Expand Down
23 changes: 19 additions & 4 deletions src/api/repositories/assessment/assessment-cslft-repository-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,13 +621,28 @@ export class AssessmentCslftRepositoryV2 {
.first();

if (!this.childcareCeiling) {
console.log("Using empty childcareCeiling");
this.childcareCeiling = { max_amount: 0 };
const yukonChildcareCeiling = await this.db("sfa.child_care_ceiling")
.where({
academic_year_id: this.application.academic_year_id,
province_id: 3,
})
.first();

console.log("Using Yukon childcareCeiling");
this.childcareCeiling = yukonChildcareCeiling;
}

if (!this.livingAllowance) {
console.log("Using empty livingAllowance");
this.livingAllowance = { shelter_amount: 0, food_amount: 0, misc_amount: 0, public_tranport_amount: 0 };
const yukonLivingAllowance = await this.db("sfa.student_living_allowance")
.where({
academic_year_id: this.application.academic_year_id,
province_id: 3,
student_category_id: this.application.category_id,
})
.first();

console.log("Using Yukon livingAllowance");
this.livingAllowance = yukonLivingAllowance;
}
}

Expand Down
16 changes: 4 additions & 12 deletions src/api/repositories/assessment/assessment-sta-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import moment from "moment";
import { AssessmentBaseRepository } from "./assessment-base-repository";
import { ApplicationRepository } from "../application";
import { ApplicationDTO, assessmentColumns, AssessmentDTO, DisbursementDTO, AssessmentTable } from "../../models";
import { weeksBetween } from "@/utils/date-utils";

export class AssessmentSTA extends AssessmentBaseRepository {
private applicationRepo: ApplicationRepository;
Expand Down Expand Up @@ -77,10 +78,7 @@ export class AssessmentSTA extends AssessmentBaseRepository {
this.application.student_id || 0,
this.application.id || 0,
]);
initValues.assessed_weeks = await this.getScalarValue<number>("fn_get_allowed_weeks", [
`'${moment(this.application.classes_start_date).format("YYYY-MM-DD")}'`,
`'${moment(this.application.classes_end_date).format("YYYY-MM-DD")}'`,
]);
initValues.assessed_weeks = weeksBetween(this.application.classes_start_date, this.application.classes_end_date);

let prev_weeks_curr_yr = await this.getScalarValue<number>("fn_get_prev_weeks_curr_year_sta", [
`'Normal'`,
Expand Down Expand Up @@ -136,10 +134,7 @@ export class AssessmentSTA extends AssessmentBaseRepository {
this.application.student_id || 0,
this.application.id || 0,
]);
values.assessed_weeks = await this.getScalarValue<number>("fn_get_allowed_weeks", [
`'${moment(values.effective_rate_date).format("YYYY-MM-DD")}'`,
`'${moment(values.classes_end_date).format("YYYY-MM-DD")}'`,
]);
values.assessed_weeks = weeksBetween(this.application.classes_start_date, this.application.classes_end_date);
values.previous_upgrade_weeks = await this.getScalarValue<number>("fn_get_previous_weeks_sfa", [
"'Upgrade'",
this.application.student_id || 0,
Expand Down Expand Up @@ -200,10 +195,7 @@ export class AssessmentSTA extends AssessmentBaseRepository {
this.application.id || 0,
]);

refreshData.assessed_weeks = await this.getScalarValue<number>("fn_get_allowed_weeks", [
`'${moment(refreshData.effective_rate_date).format("YYYY-MM-DD")}'`,
`'${moment(refreshData.classes_end_date).format("YYYY-MM-DD")}'`,
]);
refreshData.assessed_weeks = weeksBetween(this.application.classes_start_date, this.application.classes_end_date);

let prev_weeks_curr_yr = await this.getScalarValue<number>("fn_get_prev_weeks_curr_year_sta", [
`'Normal'`,
Expand Down
20 changes: 13 additions & 7 deletions src/api/routes/admin/student-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,13 @@ studentRouter.get(
.where({ "vendor_update.id": id, student_id })
.leftOuterJoin("sfa.city", "city.id", "vendor_update.city_id")
.leftOuterJoin("sfa.province", "province.id", "vendor_update.province_id")
.select("vendor_update.*", "city.description as city", "province.description as province")
.leftOuterJoin("sfa.country", "country.id", "vendor_update.country_id")
.select(
"vendor_update.*",
"city.description as city",
"province.description as province",
"country.description as country"
)
.first();
const student = await db("sfa.student")
.innerJoin("sfa.person", "person.id", "student.person_id")
Expand All @@ -1129,16 +1135,16 @@ studentRouter.get(
if (!update) return res.status(404).send("Vendor Update not found");
if (!student) return res.status(404).send("Student not found");

student.vendor_id = student.vendor_id ?? "____________________";
//student.vendor_id = student.vendor_id ?? "____________________";

const pdfData = {
API_PORT: API_PORT,
update,
student,
user: req.user,
department: "Department: E-13A",
date: moment().format("D MMM YYYY"),
isCreate: student.vendor_id.startsWith("_"),
department: "E-13A",
date: moment().format("YYYY/MM/DD"),
isCreate: student.vendor_id && student.vendor_id.length > 1,
};
const h = create({ defaultLayout: "./templates/layouts/pdf-layout" });
const data = await h.renderView(__dirname + "/../../templates/admin/vendor/vendor-request.handlebars", {
Expand All @@ -1149,8 +1155,8 @@ studentRouter.get(

let name = `VendorRequest-${student.first_name}${student.last_name}`.replace(/\s/g, "");

const footerTemplate = `<div style="width: 100%; text-align: left; font-size: 11px; padding: 5px 0; border-top: 1px solid #ccc; margin: 0 40px 10px; font-family: Calibri;">
<div style="float:left">${moment().format("MMMM D, YYYY")}</div><div style="float:right">Page 1 of 1</div>
const footerTemplate = `<div style="width: 100%; text-align: left; font-size: 9px; padding: 5px 0; margin: 0 40px 10px; font-family: Calibri;">
<div style="float:left">YG(486FIN) Rev.03/2024</div><div style="float:right">Page 1 of 1</div>
</div>`;

let pdf = await generatePDF(data, "letter", false, footerTemplate);
Expand Down
4 changes: 3 additions & 1 deletion src/api/services/admin/reporting-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default class ReportingService {
institution.name 'Institution Name',
application.academic_year_id 'Application Year',
status_date 'Status Change Date',
funding_request.received_date 'Received Date'
funding_request.received_date 'Received Date',
status_reason.description 'Status Reason'
FROM sfa.funding_request
INNER JOIN sfa.status ON funding_request.status_id = status.id
INNER JOIN sfa.request_type ON request_type.id = funding_request.request_type_id
Expand All @@ -31,6 +32,7 @@ export default class ReportingService {
INNER JOIN sfa.institution_campus ON application.institution_campus_id = institution_campus.id
INNER JOIN sfa.institution ON institution_campus.institution_id = institution.id
INNER JOIN sfa.marital_status ON application.marital_status_id = marital_status.id
LEFT OUTER JOIN sfa.status_reason ON funding_request.status_reason_id = status_reason.id
WHERE application.academic_year_id IN (` +
years.join(",") +
`)
Expand Down
Loading

0 comments on commit 8d1dbf3

Please sign in to comment.