1+ import { DB_CONFIG } from "@/config" ;
12import AgencyAssistance from "@/models/agency-assistance" ;
23import Attendance from "@/models/attendance" ;
34import Expense from "@/models/expense" ;
@@ -12,8 +13,11 @@ import PrestudyEmploymentStatus from "@/models/prestudy-employment-status";
1213import Program from "@/models/program" ;
1314import Student from "@/models/student" ;
1415import StudyArea from "@/models/study-area" ;
16+ import knex from "knex" ;
1517import { isEmpty , isInteger , isNaN , isNull , isNumber , isUndefined } from "lodash" ;
1618
19+ const db = knex ( DB_CONFIG ) ;
20+
1721// Application with standard JS naming conventions
1822// trailing underscore to avoid conflicting with legacy Application format
1923export default interface Application_ {
@@ -547,7 +551,7 @@ export function DependantsFromDraft(draft: any): any[] {
547551 return dependants ;
548552}
549553
550- export function FundingFromDraft ( draft : any ) : any [ ] {
554+ export async function FundingFromDraft ( draft : any ) : Promise < any [ ] > {
551555 let funding = new Array < any > ( ) ;
552556 let hasDependents =
553557 draft . student_dependants && draft . student_dependants . has_dependants && draft . student_dependants . dependants ;
@@ -569,7 +573,18 @@ export function FundingFromDraft(draft: any): any[] {
569573 request_type_id = 2 ;
570574 break ;
571575 case "Student Training Allowance" :
572- request_type_id = 1 ;
576+ request_type_id = 46 ;
577+
578+ const institution = await db ( "sfa.institution" )
579+ . innerJoin ( "sfa.institution_campus" , "institution.id" , "institution_campus.institution_id" )
580+ . where ( "institution_campus.id" , draft . program_details . institution_id )
581+ . select ( "institution.*" )
582+ . first ( ) ;
583+
584+ if ( institution && institution . name . startsWith ( "Yukon University" ) ) {
585+ request_type_id = 1 ;
586+ }
587+
573588 break ;
574589 case "Yukon Excellence Awards" :
575590 request_type_id = 3 ;
0 commit comments