diff --git a/db/changes/10031-zone/01-ticketGetVolume.sql b/db/changes/10031-zone/01-ticketGetVolume.sql new file mode 100644 index 000000000..e8443fb8e --- /dev/null +++ b/db/changes/10031-zone/01-ticketGetVolume.sql @@ -0,0 +1,19 @@ + +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`ticketGetVolume` AS + SELECT + `s`.`ticketFk` AS `ticketFk`, + `t`.`routeFk` AS `routeFk`, + `s`.`id` AS `saleFk`, + `t`.`shipped` AS `Fecha`, + (((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `volume` + FROM + (((`vn`.`sale` `s` + JOIN `vn`.`item` `i` ON ((`i`.`id` = `s`.`itemFk`))) + JOIN `vn`.`ticket` `t` ON ((`t`.`id` = `s`.`ticketFk`))) + JOIN `bi`.`rotacion` `r` ON (((`r`.`Id_Article` = `s`.`itemFk`) + AND (`r`.`warehouse_id` = `t`.`warehouseFk`)))); + diff --git a/db/changes/10031-zone/02-ticketTotalVolume.sql b/db/changes/10031-zone/02-ticketTotalVolume.sql new file mode 100644 index 000000000..ff4b5c080 --- /dev/null +++ b/db/changes/10031-zone/02-ticketTotalVolume.sql @@ -0,0 +1,30 @@ + +DROP function IF EXISTS `vn`.`ticketTotalVolume`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` FUNCTION `ticketTotalVolume`(vTicketId INT) RETURNS decimal(10,3) + READS SQL DATA +BEGIN + -- Devuelte el volumen total del ticket sumado + -- DECLARE vWarehouseId INTEGER; + -- DECLARE vShippedDate DATE; + DECLARE vVolume DECIMAL(10,3); + /* + SELECT warehouseFk, shipped INTO vWarehouseId,vShippedDate FROM vn.ticket WHERE id = vTicketId; + + SELECT IFNULL(SUM(s.quantity * i.compression * r.cm3)/1000000,0) INTO vVolume + FROM sale s + JOIN vn.item i ON i.id = s.itemFk + JOIN bi.rotacion r on r.Id_Article = s.itemFk AND r.warehouse_id = vWarehouseId + WHERE s.ticketFk = vTicketId; + */ + SELECT sum(volume) INTO vVolume + FROM ticketGetVolume + WHERE ticketFk = vTicketId; + RETURN vVolume; + +END$$ + +DELIMITER ; + diff --git a/modules/worker/back/methods/worker-calendar/specs/absences.spec.js b/modules/worker/back/methods/worker-calendar/specs/absences.spec.js index 336f55636..d5a89c9ab 100644 --- a/modules/worker/back/methods/worker-calendar/specs/absences.spec.js +++ b/modules/worker/back/methods/worker-calendar/specs/absences.spec.js @@ -71,7 +71,7 @@ describe('Worker absences()', () => { let calendar = result[0]; let absences = result[1]; - expect(calendar.totalHolidays).toEqual(13.5); + expect(calendar.totalHolidays).toEqual(15.5); expect(calendar.holidaysEnjoyed).toEqual(5); let firstType = absences[0].absenceType().name;