diff --git a/back/methods/workerActivity/add.js b/back/methods/workerActivity/add.js index 89131491d1..b5b1bd65de 100644 --- a/back/methods/workerActivity/add.js +++ b/back/methods/workerActivity/add.js @@ -13,6 +13,11 @@ module.exports = Self => { type: 'string', description: 'Origin model from insert' }, + { + arg: 'description', + type: 'string', + description: 'Action description' + }, ], http: { @@ -21,7 +26,7 @@ module.exports = Self => { } }); - Self.add = async(ctx, code, model, options) => { + Self.add = async(ctx, code, model, description, options) => { const userId = ctx.req.accessToken.userId; const myOptions = {}; @@ -29,8 +34,8 @@ module.exports = Self => { Object.assign(myOptions, options); return await Self.rawSql(` - INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model) - SELECT ?, ?, ? + INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model, description) + SELECT ?, ?, ?, ? FROM workerTimeControlConfig wtcc LEFT JOIN ( SELECT wa.workerFk, @@ -43,8 +48,8 @@ module.exports = Self => { LIMIT 1 ) sub ON TRUE WHERE sub.workerFk IS NULL - OR sub.code <> ? + OR sub.code <> ? OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcc.dayBreak;` - , [userId, code, model, userId, code], myOptions); + , [userId, code, model, description, userId, code], myOptions); }; }; diff --git a/back/methods/workerActivity/specs/add.spec.js b/back/methods/workerActivity/specs/add.spec.js index 751cce009e..ad6cc7fa70 100644 --- a/back/methods/workerActivity/specs/add.spec.js +++ b/back/methods/workerActivity/specs/add.spec.js @@ -13,7 +13,7 @@ describe('workerActivity insert()', () => { {'code': 'TEST', 'description': 'TEST'}, options ); - await models.WorkerActivity.add(ctx, 'TEST', 'APP', options); + await models.WorkerActivity.add(ctx, 'TEST', 'APP', 'description', options); count = await models.WorkerActivity.count( {'workerFK': 1106}, options diff --git a/db/versions/11455-orangeTulip/00-firstScript.sql b/db/versions/11455-orangeTulip/00-firstScript.sql new file mode 100644 index 0000000000..d64c8e324e --- /dev/null +++ b/db/versions/11455-orangeTulip/00-firstScript.sql @@ -0,0 +1,9 @@ + + +USE vn; + +INSERT INTO vn.workerActivityType (code, description) +VALUES('SHELVING_CLEAN_START', 'SE INICIA LIMPIEZA CARRO'), + ('SHELVING_CLEAN_STOP', 'SE FINALIZA LIMPIEZA CARRO'); + +