Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 1982-travel_add_thermograph

This commit is contained in:
Joan Sanchez 2020-01-21 12:23:10 +01:00
commit 77f6333aba
5 changed files with 50 additions and 26 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

View File

@ -14,18 +14,7 @@ module.exports = Self => {
});
Self.getWasteDetail = async() => {
const wastes = await Self.rawSql(`
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 = YEAR(CURDATE()) AND week = WEEK(CURDATE(), 1)
GROUP BY buyer, family
) sub
ORDER BY percentage DESC;`);
const [wastes] = await Self.rawSql(`CALL bs.weekWaste_getDetail()`);
const details = [];

View File

@ -12,16 +12,16 @@
<vn-table>
<vn-thead>
<vn-tr>
<vn-th>Family</vn-th>
<vn-th shrink>Percentage</vn-th>
<vn-th class="waste-family">Family</vn-th>
<vn-th number>Percentage</vn-th>
<vn-th number>Dwindle</vn-th>
<vn-th number>Total</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="waste in detail.lines">
<vn-td>{{::waste.family}}</vn-td>
<vn-td shrink>{{::(waste.percentage / 100) | percentage: 2}}</vn-td>
<vn-td class="waste-family">{{::waste.family}}</vn-td>
<vn-td number>{{::(waste.percentage / 100) | percentage: 2}}</vn-td>
<vn-td number>{{::waste.dwindle | currency: 'EUR'}}</vn-td>
<vn-td number>{{::waste.total | currency: 'EUR'}}</vn-td>
</vn-tr>

View File

@ -16,4 +16,10 @@ vn-item-waste {
overflow: hidden;
text-overflow: ellipsis;
}
vn-table vn-th.waste-family,
vn-table vn-td.waste-family {
max-width: 4em;
width: 4em
}
}