Tarea #1518 route.tickets al eliminar un ticket de la ruta, tiene que logearse

This commit is contained in:
Bernat 2019-07-03 08:29:40 +02:00
parent 39ffec686a
commit 65ec629221
3 changed files with 34 additions and 13 deletions

View File

@ -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

View File

@ -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);
});
});

View File

@ -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);
}
});
};