updated tests
gitea/salix/dev This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-01-21 09:33:26 +01:00
parent 1d6edabb10
commit 20b4f6ec74
2 changed files with 39 additions and 10 deletions

View File

@ -0,0 +1,29 @@
USE `bs`;
DROP procedure IF EXISTS `weekWaste_getDetail`;
DELIMITER $$
USE `bs`$$
CREATE DEFINER=`root`@`%` PROCEDURE `weekWaste_getDetail`()
BEGIN
DECLARE vLastWeek DATE;
DECLARE vWeek INT;
DECLARE vYear INT;
SET vLastWeek = TIMESTAMPADD(WEEK,-1,CURDATE());
SET vYear = YEAR(vLastWeek);
SET vWeek = WEEK(vLastWeek, 1);
SELECT *, 100 * dwindle / total AS percentage
FROM (
SELECT buyer,
ws.family,
sum(ws.saleTotal) AS total,
sum(ws.saleWaste) AS dwindle
FROM bs.waste ws
WHERE year = vYear AND week = vWeek
GROUP BY buyer, family
) sub
ORDER BY percentage DESC;
END$$
DELIMITER ;

View File

@ -1136,16 +1136,16 @@ INSERT INTO `bi`.`claims_ratio`(`id_Cliente`, `Consumo`, `Reclamaciones`, `Ratio
INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `saleTotal`, `saleWaste`, `rate`)
VALUES
('CharlesXavier', YEAR(CURDATE()), WEEK(CURDATE(), 1), 'Carnation', '1062', '51', '4.8'),
('CharlesXavier', YEAR(CURDATE()), WEEK(CURDATE(), 1), 'Carnation Colombia', '35074', '687', '2.0'),
('CharlesXavier', YEAR(CURDATE()), WEEK(CURDATE(), 1), 'Carnation Mini', '1777', '13', '0.7'),
('CharlesXavier', YEAR(CURDATE()), WEEK(CURDATE(), 1), 'Carnation Short', '9182', '59', '0.6'),
('DavidCharlesHaller', YEAR(CURDATE()), WEEK(CURDATE(), 1), 'Containers', '-74', '0', '0.0'),
('DavidCharlesHaller', YEAR(CURDATE()), WEEK(CURDATE(), 1), 'Packagings', '-7', '0', '0.0'),
('DavidCharlesHaller', YEAR(CURDATE()), WEEK(CURDATE(), 1), 'Freight', '1100', '0', '0.0'),
('HankPym', YEAR(CURDATE()), WEEK(CURDATE(), 1), 'Funeral Accessories', '848', '-187', '-22.1'),
('HankPym', YEAR(CURDATE()), WEEK(CURDATE(), 1), 'Miscellaneous Accessories', '186', '0', '0.0'),
('HankPym', YEAR(CURDATE()), WEEK(CURDATE(), 1), 'Adhesives', '277', '0', '0.0');
('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', '1062', '51', '4.8'),
('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Colombia', '35074', '687', '2.0'),
('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Mini', '1777', '13', '0.7'),
('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Short', '9182', '59', '0.6'),
('DavidCharlesHaller', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Containers', '-74', '0', '0.0'),
('DavidCharlesHaller', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Packagings', '-7', '0', '0.0'),
('DavidCharlesHaller', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Freight', '1100', '0', '0.0'),
('HankPym', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Funeral Accessories', '848', '-187', '-22.1'),
('HankPym', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', '186', '0', '0.0'),
('HankPym', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', '277', '0', '0.0');
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packageFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`,`minPrice`,`producer`,`printedStickers`,`isChecked`,`isIgnored`, `created`)
VALUES