8032-devToTest_2440 #3009
|
@ -1523,23 +1523,23 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed
|
|||
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
|
||||
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
|
||||
('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), 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), 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), 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), 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), 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), 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), 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), 9, 1, '7268', '59', '12.02', '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), 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), 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), 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), 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), 7, 1, '277', '0', '53.12', '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', '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', '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', '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', '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', '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', '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', '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', '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', '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', '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', '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', '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', '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', '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`)
|
||||
VALUES
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`()
|
||||
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;
|
||||
|
||||
CALL cache.last_buy_refresh(FALSE);
|
||||
|
@ -14,16 +14,32 @@ BEGIN
|
|||
s.itemFk,
|
||||
SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity),
|
||||
SUM(IF(aw.`type`, s.quantity, 0)),
|
||||
SUM(
|
||||
IF(
|
||||
aw.`type` = 'internal',
|
||||
SUM(IF(
|
||||
aw.`type` = 'external',
|
||||
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||
0
|
||||
)
|
||||
),
|
||||
SUM(
|
||||
IF(
|
||||
aw.`type` = 'external',
|
||||
),
|
||||
SUM(IF(
|
||||
aw.`type` = 'fault',
|
||||
(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,
|
||||
0
|
||||
)
|
||||
|
|
|
@ -75,6 +75,9 @@ proc: BEGIN
|
|||
WHERE saleFk = vSaleFk;
|
||||
|
||||
IF vTotalReservedQuantity <> vSaleQuantity THEN
|
||||
CALL util.debugAdd('itemShelvingSale_addBySale',
|
||||
CONCAT(vSaleFk, ' - ', vSaleQuantity,' - ', vTotalReservedQuantity,'-', vOutStanding,'-', account.myUser_getId()));
|
||||
|
||||
UPDATE sale
|
||||
SET quantity = vTotalReservedQuantity
|
||||
WHERE id = vSaleFk;
|
||||
|
@ -93,7 +96,8 @@ proc: BEGIN
|
|||
SET vOutStanding = vOutStanding - vReservedQuantity;
|
||||
|
||||
IF vReservedQuantity > 0 THEN
|
||||
|
||||
CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity',
|
||||
CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId()));
|
||||
INSERT INTO itemShelvingSale(
|
||||
itemShelvingFk,
|
||||
saleFk,
|
||||
|
|
|
@ -276,7 +276,8 @@ proc: BEGIN
|
|||
JOIN productionConfig pc
|
||||
SET hasPlantTray = TRUE
|
||||
WHERE ic.code = 'plant'
|
||||
AND p.`depth` >= pc.minPlantTrayLength;
|
||||
AND p.`depth` >= pc.minPlantTrayLength
|
||||
AND pb.isOwn;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.productionTicket,
|
||||
|
|
|
@ -10,6 +10,7 @@ BEGIN
|
|||
*
|
||||
* @param vSelf Id ticket
|
||||
* @param vOriginalItemPackingTypeFk Tipo empaquetado al que se mantiene el ticket original
|
||||
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
||||
*/
|
||||
DECLARE vDone INT DEFAULT FALSE;
|
||||
DECLARE vHasItemPackingType BOOL;
|
||||
|
@ -73,5 +74,13 @@ BEGIN
|
|||
WHERE stm.ticketFk;
|
||||
|
||||
DROP TEMPORARY TABLE tSalesToMove;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT(
|
||||
ticketFk INT,
|
||||
itemPackingTypeFk VARCHAR(1)
|
||||
) ENGINE=MEMORY;
|
||||
SELECT ticketFk, itemPackingTypeFk
|
||||
FROM tSalesToMove
|
||||
GROUP BY ticketFk;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,3 +1,2 @@
|
|||
-- Place your SQL code here
|
||||
ALTER TABLE vn.productionConfig ADD minPlantTrayLength INT DEFAULT 53 NOT NULL
|
||||
ALTER TABLE vn.productionConfig ADD IF NOT EXISTS minPlantTrayLength INT DEFAULT 53 NOT NULL
|
||||
COMMENT 'minimum length for plant tray restriction. Avoid to make collection of the ticket with this kind of item';
|
||||
|
|
|
@ -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,
|
||||
w.itemFk,
|
||||
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
|
||||
JOIN account.user u ON u.id = w.buyerFk
|
||||
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||
|
|
|
@ -28,7 +28,13 @@ module.exports = Self => {
|
|||
it.name family,
|
||||
w.itemFk,
|
||||
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
|
||||
JOIN account.user u ON u.id = w.buyerFk
|
||||
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||
|
@ -44,7 +50,13 @@ module.exports = Self => {
|
|||
FROM (
|
||||
SELECT u.name buyer,
|
||||
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
|
||||
JOIN account.user u ON u.id = w.buyerFk
|
||||
WHERE w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?))
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
SELECT *, 100 * dwindle / total `percentage`
|
||||
FROM (
|
||||
SELECT u.name buyer,
|
||||
SUM(saleTotal) total,
|
||||
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
||||
SUM(w.saleTotal) total,
|
||||
SUM(
|
||||
w.saleExternalWaste +
|
||||
w.saleFaultWaste +
|
||||
w.saleContainerWaste +
|
||||
w.saleBreakWaste +
|
||||
w.saleOtherWaste
|
||||
) dwindle
|
||||
FROM bs.waste w
|
||||
JOIN account.user u ON u.id = w.buyerFk
|
||||
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||
|
|
Loading…
Reference in New Issue