-
Notifications
You must be signed in to change notification settings - Fork 0
/
varsel-fag.js
133 lines (132 loc) · 4.51 KB
/
varsel-fag.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const description = 'Oppretter, arkiverer, og sender et varsel i fag. Sendes svarut til eleven, og foresatte dersom under 18. E-post på kopi til kontaktlærere'
const getSchoolData = require('../lib/get-school-data')
const { ARCHIVE: { ROBOT_RECNO } } = require('../config')
const { readFileSync } = require('fs')
const mailContactTeachers = require('../shared-mappers/mail-contact-teachers')
module.exports = {
enabled: true,
krr: {
// Trenger denne for foretrukket språk på pdf
enabled: true,
mapper: (documentData) => {
return {
ssn: documentData.student.personalIdNumber
}
}
},
freg: {
// Vi trenger ikke freg her - brukes for å hente foreldre
enabled: true,
mapper: (documentData) => {
return {
ssn: documentData.student.personalIdNumber
}
}
},
syncElevmappe: {
// Denne trenger vi - oppdaterer/lager elevmappe
enabled: true,
mapper: (documentData) => {
return {
ssn: documentData.student.personalIdNumber
}
}
},
addParentsIfUnder18: {
enabled: true // Kun varsel som har dette
},
syncEnterprise: {
// Trengs kun hvis bedriften skal ha dokumentet på svarut
enabled: false,
mapper: (documentData) => {
return {
enterpriseNumber: documentData.content.utplassering.bedriftsData.organisasjonsNummer
}
}
},
createPdf: {
enabled: true,
mapper: (documentData) => {
const privatePerson = documentData.flowStatus.syncElevmappe.result.privatePerson
return {
recipient: {
fullname: documentData.student.name,
streetAddress: privatePerson.streetAddress,
zipCode: privatePerson.zipCode,
zipPlace: privatePerson.zipPlace
},
student: documentData.student,
created: {
timestamp: documentData.created.timestamp
},
school: documentData.school,
teacher: documentData.teacher,
content: documentData.content
}
}
},
archive: {
enabled: true,
mapper: (documentData) => {
/*
"base64": "fhdjfhdjkfjsdf",
"title": "dokument",
"unofficialTitle": "dokument huhuhu",
"ssn": "12345678910",
"documentDate": "2021-09-27",
"caseNumber": "30/00000",
"schoolEnterpriseNumber": "202002",
"accessGroup": "elev belev",
"responsiblePersonRecno": "12345"
*/
const privatePerson = documentData.flowStatus.syncElevmappe.result.privatePerson
if (!privatePerson || !privatePerson.ssn) throw new Error('Missing data from job "syncElevmappe", please verify that the job has run successfully')
const schoolYear = documentData.content.year
if (!schoolYear) throw new Error('Missing property "year" from documentData.content, please check.')
const schoolData = getSchoolData(documentData.school.id)
const period = documentData.content.period.nb
if (!period) throw new Error('Missing property "documentData.content.period.nb", please check.')
const courses = documentData.content.classes
const courseTitle = courses.length === 1 ? `fag - ${courses[0].name}` : 'flere fag'
const courseFileTitle = courseTitle.replaceAll('/', '').replaceAll(':', '')
return {
title: `Varsel - ${courseTitle} - ${documentData.student.basisgruppe} - ${period} - ${schoolYear}`,
unofficialTitle: `Varsel - ${courseTitle} - ${documentData.student.name} - ${documentData.student.basisgruppe} - ${period} - ${schoolYear}`,
fileTitle: `Varsel - ${courseFileTitle} - ${documentData.student.basisgruppe.replace(':', '')} - ${period} - ${schoolYear}`,
ssn: privatePerson.ssn,
documentDate: new Date(documentData.created.timestamp).toISOString(),
caseNumber: documentData.flowStatus.syncElevmappe.result.elevmappe.CaseNumber,
schoolEnterpriseNumber: schoolData.organizationNumber,
accessGroup: schoolData.accessGroup,
responsiblePersonRecno: ROBOT_RECNO,
base64: readFileSync(documentData.flowStatus.createPdf.result.path, 'utf-8')
}
}
},
svarut: {
enabled: true
},
getContactTeachers: {
enabled: true
},
sendEmail: {
// Sender e-post varsel til kontaklærere (unntatt den som opprettet varselet)
enabled: true,
mapper: mailContactTeachers
},
updateDocumentStatus: {
enabled: true
},
statistics: {
enabled: true,
mapper: (documentData) => {
return {
description,
schoolYear: documentData.content.year
}
}
},
failOnPurpose: {
enabled: false
}
}