8032-devToTest_2440 #3009
|
@ -1521,23 +1521,23 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed
|
||||||
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
|
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
|
||||||
VALUES (2, 4, 1);
|
VALUES (2, 4, 1);
|
||||||
|
|
||||||
INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWasteQuantity`, `saleInternalWaste`, `saleExternalWaste`)
|
INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWasteQuantity`, `saleExternalWaste`, `saleFaultWaste`, `saleContainerWaste`, `saleBreakWaste`, `saleOtherWaste`)
|
||||||
VALUES
|
VALUES
|
||||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 1, 1, '1062', '51', '56.20', '56.20'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 1, 1, '1062', '51', '56.20', '56.20', '56.20', '56.20', '56.20'),
|
||||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '35074', '687', '53.12', '89.69'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '35074', '687', '53.12', '89.69', '56.20', '56.20', '56.20'),
|
||||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '1777', '13', '12.02', '53.12'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '1777', '13', '12.02', '53.12', '56.20', '56.20', '56.20'),
|
||||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '3182', '59', '51', '56.20'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '3182', '59', '51', '56.20', '56.20', '56.20', '56.20'),
|
||||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '1747', '13', '53.12', '53.12'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '1747', '13', '53.12', '53.12', '56.20', '56.20', '56.20'),
|
||||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '7182', '59', '51', '53.12'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '7182', '59', '51', '53.12', '56.20', '56.20', '56.20'),
|
||||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '1777', '13', '89.69', '89.69'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '1777', '13', '89.69', '89.69', '56.20', '56.20', '56.20'),
|
||||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 8, 1, '4181', '59', '53.12', '53.12'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 8, 1, '4181', '59', '53.12', '53.12', '56.20', '56.20', '56.20'),
|
||||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 9, 1, '7268', '59', '12.02', '56.20'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 9, 1, '7268', '59', '12.02', '56.20', '56.20', '56.20', '56.20'),
|
||||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '-74', '0', '51', '89.69'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '-74', '0', '51', '89.69', '56.20', '56.20', '56.20'),
|
||||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '-7', '0', '12.02', '53.12'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '-7', '0', '12.02', '53.12', '56.20', '56.20', '56.20'),
|
||||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '1100', '0', '51', '56.20'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '1100', '0', '51', '56.20', '56.20', '56.20', '56.20'),
|
||||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '848', '-187', '12.02', '89.69'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '848', '-187', '12.02', '89.69', '56.20', '56.20', '56.20'),
|
||||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12', '56.20', '56.20', '56.20'),
|
||||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20');
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20', '56.20', '56.20', '56.20');
|
||||||
|
|
||||||
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
|
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`()
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`()
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY;
|
DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY;
|
||||||
DECLARE vDateTo DATE DEFAULT vDateFrom + INTERVAL 6 DAY;
|
DECLARE vDateTo DATE DEFAULT vDateFrom + INTERVAL 6 DAY;
|
||||||
|
|
||||||
CALL cache.last_buy_refresh(FALSE);
|
CALL cache.last_buy_refresh(FALSE);
|
||||||
|
@ -14,16 +14,32 @@ BEGIN
|
||||||
s.itemFk,
|
s.itemFk,
|
||||||
SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity),
|
SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity),
|
||||||
SUM(IF(aw.`type`, s.quantity, 0)),
|
SUM(IF(aw.`type`, s.quantity, 0)),
|
||||||
SUM(
|
SUM(IF(
|
||||||
IF(
|
aw.`type` = 'external',
|
||||||
aw.`type` = 'internal',
|
|
||||||
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
SUM(
|
SUM(IF(
|
||||||
IF(
|
aw.`type` = 'fault',
|
||||||
aw.`type` = 'external',
|
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
),
|
||||||
|
SUM(IF(
|
||||||
|
aw.`type` = 'container',
|
||||||
|
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
),
|
||||||
|
SUM(IF(
|
||||||
|
aw.`type` = 'break',
|
||||||
|
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
),
|
||||||
|
SUM(IF(
|
||||||
|
aw.`type` = 'other',
|
||||||
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
ALTER TABLE vn.addressWaste
|
||||||
|
MODIFY COLUMN `type` enum('external', 'fault', 'container', 'break', 'other')
|
||||||
|
CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
|
||||||
|
|
||||||
|
UPDATE vn.addressWaste
|
||||||
|
SET `type`='container'
|
||||||
|
WHERE addressFk=77;
|
||||||
|
|
||||||
|
UPDATE vn.addressWaste
|
||||||
|
SET `type`='fault'
|
||||||
|
WHERE addressFk=317;
|
||||||
|
|
||||||
|
UPDATE vn.addressWaste
|
||||||
|
SET `type`='break'
|
||||||
|
WHERE addressFk=57702;
|
||||||
|
|
||||||
|
UPDATE vn.addressWaste
|
||||||
|
SET `type`='other'
|
||||||
|
WHERE addressFk=43432;
|
|
@ -0,0 +1,6 @@
|
||||||
|
ALTER TABLE bs.waste
|
||||||
|
DROP COLUMN saleInternalWaste,
|
||||||
|
ADD saleFaultWaste decimal(10,2) DEFAULT NULL NULL,
|
||||||
|
ADD saleContainerWaste decimal(10,2) DEFAULT NULL NULL,
|
||||||
|
ADD saleBreakWaste decimal(10,2) DEFAULT NULL NULL,
|
||||||
|
ADD saleOtherWaste decimal(10,2) DEFAULT NULL NULL;
|
|
@ -52,7 +52,13 @@ module.exports = Self => {
|
||||||
it.name family,
|
it.name family,
|
||||||
w.itemFk,
|
w.itemFk,
|
||||||
SUM(w.saleTotal) total,
|
SUM(w.saleTotal) total,
|
||||||
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
SUM(
|
||||||
|
w.saleExternalWaste +
|
||||||
|
w.saleFaultWaste +
|
||||||
|
w.saleContainerWaste +
|
||||||
|
w.saleBreakWaste +
|
||||||
|
w.saleOtherWaste
|
||||||
|
) dwindle
|
||||||
FROM bs.waste w
|
FROM bs.waste w
|
||||||
JOIN account.user u ON u.id = w.buyerFk
|
JOIN account.user u ON u.id = w.buyerFk
|
||||||
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||||
|
|
|
@ -28,7 +28,13 @@ module.exports = Self => {
|
||||||
it.name family,
|
it.name family,
|
||||||
w.itemFk,
|
w.itemFk,
|
||||||
SUM(w.saleTotal) total,
|
SUM(w.saleTotal) total,
|
||||||
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
SUM(
|
||||||
|
w.saleExternalWaste +
|
||||||
|
w.saleFaultWaste +
|
||||||
|
w.saleContainerWaste +
|
||||||
|
w.saleBreakWaste +
|
||||||
|
w.saleOtherWaste
|
||||||
|
) dwindle
|
||||||
FROM bs.waste w
|
FROM bs.waste w
|
||||||
JOIN account.user u ON u.id = w.buyerFk
|
JOIN account.user u ON u.id = w.buyerFk
|
||||||
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||||
|
@ -44,7 +50,13 @@ module.exports = Self => {
|
||||||
FROM (
|
FROM (
|
||||||
SELECT u.name buyer,
|
SELECT u.name buyer,
|
||||||
SUM(w.saleTotal) total,
|
SUM(w.saleTotal) total,
|
||||||
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
SUM(
|
||||||
|
w.saleExternalWaste +
|
||||||
|
w.saleFaultWaste +
|
||||||
|
w.saleContainerWaste +
|
||||||
|
w.saleBreakWaste +
|
||||||
|
w.saleOtherWaste
|
||||||
|
) dwindle
|
||||||
FROM bs.waste w
|
FROM bs.waste w
|
||||||
JOIN account.user u ON u.id = w.buyerFk
|
JOIN account.user u ON u.id = w.buyerFk
|
||||||
WHERE w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?))
|
WHERE w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?))
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
SELECT *, 100 * dwindle / total `percentage`
|
SELECT *, 100 * dwindle / total `percentage`
|
||||||
FROM (
|
FROM (
|
||||||
SELECT u.name buyer,
|
SELECT u.name buyer,
|
||||||
SUM(saleTotal) total,
|
SUM(w.saleTotal) total,
|
||||||
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
SUM(
|
||||||
|
w.saleExternalWaste +
|
||||||
|
w.saleFaultWaste +
|
||||||
|
w.saleContainerWaste +
|
||||||
|
w.saleBreakWaste +
|
||||||
|
w.saleOtherWaste
|
||||||
|
) dwindle
|
||||||
FROM bs.waste w
|
FROM bs.waste w
|
||||||
JOIN account.user u ON u.id = w.buyerFk
|
JOIN account.user u ON u.id = w.buyerFk
|
||||||
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||||
|
|
Loading…
Reference in New Issue