8032-devToTest_2440 #3009

Merged
alexm merged 262 commits from 8032-devToTest_2440 into test 2024-09-24 09:34:49 +00:00
11 changed files with 111 additions and 33 deletions
Showing only changes of commit 06efa8be94 - Show all commits

View File

@ -1523,23 +1523,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

View File

@ -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
) )

View File

@ -75,6 +75,9 @@ proc: BEGIN
WHERE saleFk = vSaleFk; WHERE saleFk = vSaleFk;
IF vTotalReservedQuantity <> vSaleQuantity THEN IF vTotalReservedQuantity <> vSaleQuantity THEN
CALL util.debugAdd('itemShelvingSale_addBySale',
CONCAT(vSaleFk, ' - ', vSaleQuantity,' - ', vTotalReservedQuantity,'-', vOutStanding,'-', account.myUser_getId()));
UPDATE sale UPDATE sale
SET quantity = vTotalReservedQuantity SET quantity = vTotalReservedQuantity
WHERE id = vSaleFk; WHERE id = vSaleFk;
@ -93,7 +96,8 @@ proc: BEGIN
SET vOutStanding = vOutStanding - vReservedQuantity; SET vOutStanding = vOutStanding - vReservedQuantity;
IF vReservedQuantity > 0 THEN IF vReservedQuantity > 0 THEN
CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity',
CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId()));
INSERT INTO itemShelvingSale( INSERT INTO itemShelvingSale(
itemShelvingFk, itemShelvingFk,
saleFk, saleFk,

View File

@ -276,7 +276,8 @@ proc: BEGIN
JOIN productionConfig pc JOIN productionConfig pc
SET hasPlantTray = TRUE SET hasPlantTray = TRUE
WHERE ic.code = 'plant' WHERE ic.code = 'plant'
AND p.`depth` >= pc.minPlantTrayLength; AND p.`depth` >= pc.minPlantTrayLength
AND pb.isOwn;
DROP TEMPORARY TABLE DROP TEMPORARY TABLE
tmp.productionTicket, tmp.productionTicket,

View File

@ -10,6 +10,7 @@ BEGIN
* *
* @param vSelf Id ticket * @param vSelf Id ticket
* @param vOriginalItemPackingTypeFk Tipo empaquetado al que se mantiene el ticket original * @param vOriginalItemPackingTypeFk Tipo empaquetado al que se mantiene el ticket original
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
*/ */
DECLARE vDone INT DEFAULT FALSE; DECLARE vDone INT DEFAULT FALSE;
DECLARE vHasItemPackingType BOOL; DECLARE vHasItemPackingType BOOL;
@ -73,5 +74,13 @@ BEGIN
WHERE stm.ticketFk; WHERE stm.ticketFk;
DROP TEMPORARY TABLE tSalesToMove; 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$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,3 +1,2 @@
-- Place your SQL code here ALTER TABLE vn.productionConfig ADD IF NOT EXISTS minPlantTrayLength INT DEFAULT 53 NOT NULL
ALTER TABLE vn.productionConfig ADD 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'; COMMENT 'minimum length for plant tray restriction. Avoid to make collection of the ticket with this kind of item';

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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, ?))

View File

@ -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