Commit 2265cbc9 authored by Mahdi Sellami's avatar Mahdi Sellami

more logic in POST Application

parent 31b28ac0
......@@ -7,16 +7,16 @@ var DataObjectSchema = require('./dataObject').schema
var Schema = mongoose.Schema;
var ApplicationSchema = new Schema({
verfahrensId : String,
leikaId : String,
responsibleAuthority : String,
statusId : String,
statusDescription : String,
statusLastChangeDate : String,
decisionDate : String,
decisionJustification : String,
applicant : PersonSchema,
dataObjects : [DataObjectSchema]
verfahrensId : String,
leikaId : String,
responsibleAuthority : String,
statusId : String,
statusDescription : String,
statusLastChangeDate : String,
decisionDate : String,
decisionJustification : String,
applicant : PersonSchema,
dataObjects : [DataObjectSchema]
});
//Export function to create "Application" model class
......
......@@ -18,6 +18,17 @@ exports.postCaseApplication = function(body) {
} else {
var applicationRecord = Application.create(body).then(function(doc) {
doc.verfahrensId = doc.id
doc.responsibleAuthority = serviceRecord.responsibleAuthority
doc.statusId = 'eingereicht'
doc.statusDescription = 'Ihr Antrag wird in den nächsten Tagen bearbeitet.'
doc.statusLastChangeDate = new Date().toLocaleDateString('de-DE')
doc.decisionDate = ''
doc.decisionJustification = ''
for (const dataObject of doc.dataObjects) {
dataObject.dataObjectId = dataObject.id
dataObject.leikaId = doc.leikaId
dataObject.verfahrensId = doc.verfahrensId
}
doc.save()
return doc
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment