diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index d060e1953..76ce2f412 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -58,11 +58,11 @@ INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`) VALUES - (1, 'Warehouse One', 0, 1, 1, 1), - (2, 'Warehouse Two', 0, 1, 1, 1), + (1, 'Warehouse One', 1, 1, 1, 1), + (2, 'Warehouse Two', 1, 1, 1, 1), (3, 'Warehouse Three', 1, 1, 1, 1), (4, 'Warehouse Four', 1, 1, 1, 1), - (5, 'Warehouse Five', 1, 0, 1, 0); + (5, 'Warehouse Five', 1, 1, 1, 1); INSERT INTO `vn`.`warehouseAlias`(`id`, `name`) VALUES @@ -566,9 +566,9 @@ INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`,`workerFk INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`) VALUES - ('YEL', 'Yellow', 1 , 1), - ('BLU', 'Blue', 1 , 2), - ('RED', 'Red', 1 , 3); + ('YEL', 'Yellow', 1, 1), + ('BLU', 'Blue', 1, 2), + ('RED', 'Red', 1, 3); INSERT INTO `vn`.`origin`(`id`,`code`, `name`) VALUES @@ -1062,10 +1062,10 @@ INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`package (9, 4, 4, 1.25, 1000, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), (10, 5, 1, 50, 10, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), (11, 5, 4, 1.25, 10, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), - (12, 6, 4, 1.25, 1, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), - (13, 7, 1, 50, 1, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), - (14, 7, 2, 5, 100, 1, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()), - (15, 7, 4, 1.25, 10, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()); + (12, 6, 4, 1.25, 0, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), + (13, 7, 1, 50, 0, 3, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), + (14, 7, 2, 5, 0, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()), + (15, 7, 4, 1.25, 0, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()); INSERT INTO `vn2008`.`tblContadores`(`id`,`FechaInventario`) VALUES @@ -1459,7 +1459,7 @@ INSERT INTO `postgresql`.`person`(`person_id`, `name`, `nickname`, `nif`, `first INSERT INTO `postgresql`.`person`(`person_id`, `name`, `nickname`, `nif`, `firstname`, `id_trabajador`) VALUES - (1000, 'VERDNATURA LEVANTE SL', 'VNL', 'B78945612', NULL, NULL); + (1000, 'VERDNATURA LEVANTE SL', 'VNL', 'B78945612', NULL, NULL); INSERT INTO `postgresql`.`profile`(`profile_id`, `person_id`, `profile_type_id`) SELECT p.person_id, p.person_id, 1 diff --git a/modules/item/back/methods/item/specs/getDiary.spec.js b/modules/item/back/methods/item/specs/getDiary.spec.js index d5a75fcd1..d47ac1d7d 100644 --- a/modules/item/back/methods/item/specs/getDiary.spec.js +++ b/modules/item/back/methods/item/specs/getDiary.spec.js @@ -8,7 +8,7 @@ describe('item getDiary()', () => { expect(result.length).toBe(4); expect(result[0].balance).toBe(-100); expect(result[1].balance).toBe(-110); - expect(result[2].balance).toBe(-111); - expect(result[3].balance).toBe(-211); + expect(result[2].balance).toBe(-110); + expect(result[3].balance).toBe(-210); }); }); diff --git a/modules/ticket/back/models/ticket.js b/modules/ticket/back/models/ticket.js index 608a0b4b4..a058bbd89 100644 --- a/modules/ticket/back/models/ticket.js +++ b/modules/ticket/back/models/ticket.js @@ -1,3 +1,4 @@ + module.exports = Self => { require('../methods/ticket/changeWorker')(Self); require('../methods/ticket/getVolume')(Self); @@ -23,4 +24,24 @@ module.exports = Self => { require('../methods/ticket/updateDiscount')(Self); require('../methods/ticket/uploadFile')(Self); require('../methods/ticket/addSale')(Self); + + Self.observe('before save', async function(ctx) { + if (ctx.isNewInstance) return; + + let changes = ctx.data || ctx.instance; + + if (changes.routeFk === null && ctx.currentInstance.routeFk != null) { + let instance = JSON.parse(JSON.stringify(ctx.currentInstance)); + let userId = ctx.options.accessToken.userId; + let logRecord = { + originFk: ctx.currentInstance.routeFk, + userFk: userId, + action: 'delete', + changedModel: 'Route', + oldInstance: {ticket: instance.id}, + newInstance: null + }; + await Self.app.models.RouteLog.create(logRecord); + } + }); };