From 47d689ae509db96842e0e646a27eb9636e07232c Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 21 Oct 2019 08:31:14 +0200 Subject: [PATCH] Uploadfile parameters are now required + fixed date filters --- back/methods/dms/uploadFile.js | 18 ++++++---- .../back/methods/claim/regularizeClaim.js | 11 +++--- .../claim/back/methods/claim/uploadFile.js | 34 +++++++++---------- .../client/back/methods/client/uploadFile.js | 34 +++++++++---------- modules/item/back/methods/item/regularize.js | 11 +++--- .../ticket/back/methods/ticket/uploadFile.js | 34 +++++++++---------- 6 files changed, 74 insertions(+), 68 deletions(-) diff --git a/back/methods/dms/uploadFile.js b/back/methods/dms/uploadFile.js index 41d551f2b..e077eea30 100644 --- a/back/methods/dms/uploadFile.js +++ b/back/methods/dms/uploadFile.js @@ -9,25 +9,31 @@ module.exports = Self => { { arg: 'warehouseId', type: 'Number', - description: 'The warehouse id' + description: 'The warehouse id', + required: true }, { arg: 'companyId', type: 'Number', - description: 'The company id' + description: 'The company id', + required: true }, { arg: 'dmsTypeId', type: 'Number', - description: 'The dms type id' + description: 'The dms type id', + required: true }, { arg: 'reference', - type: 'String' + type: 'String', + required: true }, { arg: 'description', - type: 'String' + type: 'String', + required: true }, { arg: 'hasFile', type: 'Boolean', - description: 'True if has an attached file' + description: 'True if has an attached file', + required: true }], returns: { type: 'Object', diff --git a/modules/claim/back/methods/claim/regularizeClaim.js b/modules/claim/back/methods/claim/regularizeClaim.js index a2896174e..136016b1e 100644 --- a/modules/claim/back/methods/claim/regularizeClaim.js +++ b/modules/claim/back/methods/claim/regularizeClaim.js @@ -120,16 +120,19 @@ module.exports = Self => { } async function getTicketId(params, options) { - const currentDate = new Date(); - currentDate.setHours(null, null, null); + const minDate = new Date(); + minDate.setHours(0, 0, 0, 0); + + const maxDate = new Date(); + maxDate.setHours(23, 59, 59, 59); let ticket = await Self.app.models.Ticket.findOne({ where: { addressFk: params.addressFk, companyFk: params.companyFk, warehouseFk: params.warehouseFk, - shipped: currentDate, - landed: currentDate + shipped: {between: [minDate, maxDate]}, + landed: {between: [minDate, maxDate]} } }, options); diff --git a/modules/claim/back/methods/claim/uploadFile.js b/modules/claim/back/methods/claim/uploadFile.js index f6dad3477..c7565701d 100644 --- a/modules/claim/back/methods/claim/uploadFile.js +++ b/modules/claim/back/methods/claim/uploadFile.js @@ -7,36 +7,34 @@ module.exports = Self => { type: 'Number', description: 'The claim id', http: {source: 'path'} - }, - { + }, { arg: 'warehouseId', type: 'Number', - description: '' - }, - { + description: 'The warehouse id', + required: true + }, { arg: 'companyId', type: 'Number', - description: '' - }, - { + description: 'The company id', + required: true + }, { arg: 'dmsTypeId', type: 'Number', - description: '' - }, - { + description: 'The dms type id', + required: true + }, { arg: 'reference', type: 'String', - description: '' - }, - { + required: true + }, { arg: 'description', type: 'String', - description: '' - }, - { + required: true + }, { arg: 'hasFile', type: 'Boolean', - description: '' + description: 'True if has an attached file', + required: true }], returns: { type: 'Object', diff --git a/modules/client/back/methods/client/uploadFile.js b/modules/client/back/methods/client/uploadFile.js index 6b7a49459..6ec96e301 100644 --- a/modules/client/back/methods/client/uploadFile.js +++ b/modules/client/back/methods/client/uploadFile.js @@ -7,36 +7,34 @@ module.exports = Self => { type: 'Number', description: 'The client id', http: {source: 'path'} - }, - { + }, { arg: 'warehouseId', type: 'Number', - description: '' - }, - { + description: 'The warehouse id', + required: true + }, { arg: 'companyId', type: 'Number', - description: '' - }, - { + description: 'The company id', + required: true + }, { arg: 'dmsTypeId', type: 'Number', - description: '' - }, - { + description: 'The dms type id', + required: true + }, { arg: 'reference', type: 'String', - description: '' - }, - { + required: true + }, { arg: 'description', type: 'String', - description: '' - }, - { + required: true + }, { arg: 'hasFile', type: 'Boolean', - description: '' + description: 'True if has an attached file', + required: true }], returns: { type: 'Object', diff --git a/modules/item/back/methods/item/regularize.js b/modules/item/back/methods/item/regularize.js index 17f1dbe1e..b9aa0d85f 100644 --- a/modules/item/back/methods/item/regularize.js +++ b/modules/item/back/methods/item/regularize.js @@ -105,15 +105,18 @@ module.exports = Self => { async function getTicketId(params, options) { - const currentDate = new Date(); - currentDate.setHours(null, null, null); + const minDate = new Date(); + minDate.setHours(0, 0, 0, 0); + + const maxDate = new Date(); + maxDate.setHours(23, 59, 59, 59); let ticket = await Self.app.models.Ticket.findOne({ where: { addressFk: params.addressFk, warehouseFk: params.warehouseFk, - shipped: currentDate, - landed: currentDate + shipped: {between: [minDate, maxDate]}, + landed: {between: [minDate, maxDate]} } }, options); diff --git a/modules/ticket/back/methods/ticket/uploadFile.js b/modules/ticket/back/methods/ticket/uploadFile.js index 7c968f5c9..e5ea465cb 100644 --- a/modules/ticket/back/methods/ticket/uploadFile.js +++ b/modules/ticket/back/methods/ticket/uploadFile.js @@ -7,36 +7,34 @@ module.exports = Self => { type: 'Number', description: 'The ticket id', http: {source: 'path'} - }, - { + }, { arg: 'warehouseId', type: 'Number', - description: '' - }, - { + description: 'The warehouse id', + required: true + }, { arg: 'companyId', type: 'Number', - description: '' - }, - { + description: 'The company id', + required: true + }, { arg: 'dmsTypeId', type: 'Number', - description: '' - }, - { + description: 'The dms type id', + required: true + }, { arg: 'reference', type: 'String', - description: '' - }, - { + required: true + }, { arg: 'description', type: 'String', - description: '' - }, - { + required: true + }, { arg: 'hasFile', type: 'Boolean', - description: '' + description: 'True if has an attached file', + required: true }], returns: { type: 'Object',