diff --git a/backend/web/server/plugins/entreprisedufutur/functions.js b/backend/web/server/plugins/entreprisedufutur/functions.js index 80ab464a1..5ac7e22ac 100644 --- a/backend/web/server/plugins/entreprisedufutur/functions.js +++ b/backend/web/server/plugins/entreprisedufutur/functions.js @@ -524,7 +524,7 @@ declareVirtualField({model: 'order', field: 'order_tickets', multiple: true, ins } }) declareVirtualField({model: 'order', field: 'order_tickets_count', instance: 'Number'}) -declareComputedField({model: 'order', field: 'unknown_emails', getterFn: getUnknownEmails}) +declareComputedField({model: 'order', field: 'unknown_tickets', getterFn: getUnknownEmails}) declareComputedField({model: 'order', field: 'are_inputs_valid', getterFn: getInputsValid}) //OrderTicket declarations diff --git a/backend/web/server/plugins/entreprisedufutur/order.js b/backend/web/server/plugins/entreprisedufutur/order.js index 1e3d966cb..f207d9a8f 100644 --- a/backend/web/server/plugins/entreprisedufutur/order.js +++ b/backend/web/server/plugins/entreprisedufutur/order.js @@ -12,7 +12,8 @@ const getUnknownEmails = async (userId, params, data) => { const exist = await User.exists({email:t.email}) return !exist }) - return unknownEmailTickets.map(ticket => ticket.email) + + return unknownEmailTickets.map(ticket => new OrderTicket(ticket)) } const getInputsValid = async (userId, params, data) => { diff --git a/backend/web/server/plugins/entreprisedufutur/schemas/OrderSchema.js b/backend/web/server/plugins/entreprisedufutur/schemas/OrderSchema.js index b51217df1..8ef76a6d1 100644 --- a/backend/web/server/plugins/entreprisedufutur/schemas/OrderSchema.js +++ b/backend/web/server/plugins/entreprisedufutur/schemas/OrderSchema.js @@ -15,10 +15,11 @@ const OrderSchema = new Schema({ enum:Object.keys(ORDER_STATUSES), required: [true, `Le statut de la commande est obligatoire`] }, - unknown_emails: { + unknown_tickets: { //computed type: [{ - type: String, + type: Schema.Types.ObjectId, + ref: 'userTicket', required: true }], default: []