Compare commits

...

8 Commits

Author SHA1 Message Date
Pablo Natek 8c5d2d5903 refs #3126
gitea/salix/pipeline/head This commit looks good Details
2023-08-21 13:54:21 +02:00
Pablo Natek b8aceba31d refs #3126 endtest
gitea/salix/pipeline/head This commit looks good Details
2023-08-18 14:19:30 +02:00
Pablo Natek dc41288123 refs #3126 test
gitea/salix/pipeline/head Build queued... Details
2023-08-18 14:15:50 +02:00
Pablo Natek 3f40a1b41c Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 3126-packageFkToPackagingFk
gitea/salix/pipeline/head This commit looks good Details
2023-08-18 12:57:37 +02:00
Pablo Natek 380de18134 refs #3126 fixerror
gitea/salix/pipeline/head This commit looks good Details
2023-08-16 21:19:50 +02:00
Pablo Natek a8cbe0d6e3 refs #3126 structerPackagingFk
gitea/salix/pipeline/head This commit looks good Details
2023-08-16 20:46:45 +02:00
Pablo Natek 756f93a5c6 refs #3126 test
gitea/salix/pipeline/head There was a failure building this commit Details
2023-08-16 20:05:06 +02:00
Pablo Natek ec121190df refs #3126
gitea/salix/pipeline/head There was a failure building this commit Details
2023-07-24 13:34:38 +02:00
31 changed files with 988 additions and 112 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.buy CHANGE packageFk packagingFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT '--' NULL;

View File

@ -0,0 +1,146 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Compres`
AS SELECT `c`.`id` AS `Id_Compra`,
`c`.`entryFk` AS `Id_Entrada`,
`c`.`itemFk` AS `Id_Article`,
`c`.`buyingValue` AS `Costefijo`,
`c`.`quantity` AS `Cantidad`,
`c`.`packagingFk` AS `Id_Cubo`,
`c`.`stickers` AS `Etiquetas`,
`c`.`freightValue` AS `Portefijo`,
`c`.`packageValue` AS `Embalajefijo`,
`c`.`comissionValue` AS `Comisionfija`,
`c`.`packing` AS `Packing`,
`c`.`grouping` AS `grouping`,
`c`.`groupingMode` AS `caja`,
`c`.`location` AS `Nicho`,
`c`.`price1` AS `Tarifa1`,
`c`.`price2` AS `Tarifa2`,
`c`.`price3` AS `Tarifa3`,
`c`.`minPrice` AS `PVP`,
`c`.`printedStickers` AS `Vida`,
`c`.`isChecked` AS `punteo`,
`c`.`ektFk` AS `buy_edi_id`,
`c`.`created` AS `odbc_date`,
`c`.`isIgnored` AS `Novincular`,
`c`.`isPickedOff` AS `isPickedOff`,
`c`.`workerFk` AS `Id_Trabajador`,
`c`.`weight` AS `weight`,
`c`.`dispatched` AS `dispatched`,
`c`.`containerFk` AS `container_id`,
`c`.`itemOriginalFk` AS `itemOriginalFk`
FROM `vn`.`buy` `c`;
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`buySource`
AS SELECT `b`.`entryFk` AS `Id_Entrada`,
`b`.`isPickedOff` AS `isPickedOff`,
NULL AS `tarifa0`,
`e`.`kop` AS `kop`,
`b`.`id` AS `Id_Compra`,
`i`.`typeFk` AS `tipo_id`,
`b`.`itemFk` AS `Id_Article`,
`i`.`size` AS `Medida`,
`i`.`stems` AS `Tallos`,
`b`.`stickers` AS `Etiquetas`,
`b`.`packagingFk` AS `Id_Cubo`,
`b`.`buyingValue` AS `Costefijo`,
`b`.`packing` AS `Packing`,
`b`.`grouping` AS `Grouping`,
`b`.`quantity` AS `Cantidad`,
`b`.`price2` AS `Tarifa2`,
`b`.`price3` AS `Tarifa3`,
`b`.`isChecked` AS `Punteo`,
`b`.`groupingMode` AS `Caja`,
`i`.`isToPrint` AS `Imprimir`,
`i`.`name` AS `Article`,
`vn`.`ink`.`picture` AS `Tinta`,
`i`.`originFk` AS `id_origen`,
`i`.`minPrice` AS `PVP`,
NULL AS `Id_Accion`,
`s`.`company_name` AS `pro`,
`i`.`hasMinPrice` AS `Min`,
`b`.`isIgnored` AS `Novincular`,
`b`.`freightValue` AS `Portefijo`,
round(`b`.`buyingValue` * `b`.`quantity`, 2) AS `Importe`,
`b`.`printedStickers` AS `Vida`,
`i`.`comment` AS `reference`,
`b`.`workerFk` AS `Id_Trabajador`,
`e`.`s1` AS `S1`,
`e`.`s2` AS `S2`,
`e`.`s3` AS `S3`,
`e`.`s4` AS `S4`,
`e`.`s5` AS `S5`,
`e`.`s6` AS `S6`,
0 AS `price_fixed`,
`i`.`producerFk` AS `producer_id`,
`i`.`subName` AS `tag1`,
`i`.`value5` AS `tag2`,
`i`.`value6` AS `tag3`,
`i`.`value7` AS `tag4`,
`i`.`value8` AS `tag5`,
`i`.`value9` AS `tag6`,
`s`.`company_name` AS `company_name`,
`b`.`weight` AS `weightPacking`,
`i`.`packingOut` AS `packingOut`,
`b`.`itemOriginalFk` AS `itemOriginalFk`,
`io`.`longName` AS `itemOriginalName`,
`it`.`gramsMax` AS `gramsMax`
FROM (
(
(
(
(
(
`vn`.`item` `i`
JOIN `vn`.`itemType` `it` ON(`it`.`id` = `i`.`typeFk`)
)
LEFT JOIN `vn`.`ink` ON(`vn`.`ink`.`id` = `i`.`inkFk`)
)
LEFT JOIN `vn`.`buy` `b` ON(`b`.`itemFk` = `i`.`id`)
)
LEFT JOIN `vn`.`item` `io` ON(`io`.`id` = `b`.`itemOriginalFk`)
)
LEFT JOIN `edi`.`ekt` `e` ON(`e`.`id` = `b`.`ektFk`)
)
LEFT JOIN `edi`.`supplier` `s` ON(`e`.`pro` = `s`.`supplier_id`)
);
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`awbVolume`
AS SELECT `d`.`awbFk` AS `awbFk`,
`b`.`stickers` * `i`.`density` * IF(
`p`.`volume` > 0,
`p`.`volume`,
`p`.`width` * `p`.`depth` * IF(`p`.`height` = 0, `i`.`size` + 10, `p`.`height`)
) / (`vc`.`aerealVolumetricDensity` * 1000) AS `volume`,
`b`.`id` AS `buyFk`
FROM (
(
(
(
(
(
(
(
`vn`.`buy` `b`
JOIN `vn`.`item` `i` ON(`b`.`itemFk` = `i`.`id`)
)
JOIN `vn`.`itemType` `it` ON(`i`.`typeFk` = `it`.`id`)
)
JOIN `vn`.`packaging` `p` ON(`p`.`id` = `b`.`packagingFk`)
)
JOIN `vn`.`entry` `e` ON(`b`.`entryFk` = `e`.`id`)
)
JOIN `vn`.`travel` `t` ON(`t`.`id` = `e`.`travelFk`)
)
JOIN `vn`.`duaEntry` `de` ON(`de`.`entryFk` = `e`.`id`)
)
JOIN `vn`.`dua` `d` ON(`d`.`id` = `de`.`duaFk`)
)
JOIN `vn`.`volumeConfig` `vc`
)
WHERE `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1, 1);

View File

@ -0,0 +1,57 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_afterUpdate`
AFTER UPDATE ON `buy`
FOR EACH ROW
trig: BEGIN
DECLARE vLanded DATE;
DECLARE vBuyerFk INT;
DECLARE vIsBuyerToBeEmailed BOOL;
DECLARE vItemName VARCHAR(50);
IF @isModeInventory OR @isTriggerDisabled THEN
LEAVE trig;
END IF;
IF !(NEW.id <=> OLD.id)
OR !(NEW.entryFk <=> OLD.entryFk)
OR !(NEW.itemFk <=> OLD.itemFk)
OR !(NEW.quantity <=> OLD.quantity)
OR !(NEW.created <=> OLD.created) THEN
CALL stock.log_add('buy', NEW.id, OLD.id);
END IF;
CALL buy_afterUpsert(NEW.id);
SELECT w.isBuyerToBeEmailed, t.landed
INTO vIsBuyerToBeEmailed, vLanded
FROM entry e
JOIN travel t ON t.id = e.travelFk
JOIN warehouse w ON w.id = t.warehouseInFk
WHERE e.id = NEW.entryFk;
SELECT it.workerFk, i.longName
INTO vBuyerFk, vItemName
FROM itemCategory k
JOIN itemType it ON it.categoryFk = k.id
JOIN item i ON i.typeFk = it.id
WHERE i.id = OLD.itemFk;
IF vIsBuyerToBeEmailed AND
vBuyerFk != account.myUser_getId() AND
vLanded = util.VN_CURDATE() THEN
IF !(NEW.itemFk <=> OLD.itemFk) OR
!(NEW.quantity <=> OLD.quantity) OR
!(NEW.packing <=> OLD.packing) OR
!(NEW.grouping <=> OLD.grouping) OR
!(NEW.packagingFk <=> OLD.packagingFk) OR
!(NEW.weight <=> OLD.weight) THEN
CALL vn.mail_insert(
CONCAT(account.user_getNameFromId(vBuyerFk),'@verdnatura.es'),
CONCAT(account.myUser_getName(),'@verdnatura.es'),
CONCAT('E ', NEW.entryFk ,' Se ha modificado item ', NEW.itemFk, ' ', vItemName),
'Este email se ha generado automáticamente'
);
END IF;
END IF;
END$$
DELIMITER ;

View File

@ -0,0 +1,669 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travelVolume`(vTravelFk INT)
BEGIN
SELECT w1.name AS ORI,
w2.name AS DES,
tr.shipped shipment,
tr.landed landing,
a.name Agencia,
s.name Proveedor,
e.id Id_Entrada,
e.invoiceNumber Referencia,
CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
vn.item_getVolume(b.itemFk ,b.packagingFk)) / vc.trolleyM3 / 1000000 ,1) AS DECIMAL(10,2)) AS CC,
CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
vn.item_getVolume(b.itemFk ,b.packagingFk)) / vc.palletM3 / 1000000,1) AS DECIMAL(10,2)) AS espais
FROM vn.buy b
JOIN vn.entry e ON e.id = b.entryFk
JOIN vn.supplier s ON s.id = e.supplierFk
JOIN vn.travel tr ON tr.id = e.travelFk
JOIN vn.agencyMode a ON a.id = tr.agencyModeFk
JOIN vn.warehouse w1 ON w1.id = tr.warehouseInFk
JOIN vn.warehouse w2 ON w2.id = tr.warehouseOutFk
JOIN vn.volumeConfig vc
JOIN vn.item i ON i.id = b.itemFk
JOIN vn.itemType it ON it.id = i.typeFk
WHERE tr.id = vTravelFk;
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travelVolume_get`(vFromDated DATE, vToDated DATE, vWarehouseFk INT)
BEGIN
SELECT tr.landed Fecha,
a.name Agencia,
count(DISTINCT e.id) numEntradas,
FLOOR(sum(item_getVolume(b.itemFk, b.packagingFk) * b.stickers / 1000000 )) AS m3
FROM vn.travel tr
JOIN vn.agencyMode a ON a.id = tr.agencyModeFk
JOIN vn.entry e ON e.travelFk = tr.id
JOIN vn.buy b ON b.entryFk = e.id
WHERE tr.landed BETWEEN vFromDated AND vToDated
AND e.isRaid = FALSE
AND tr.warehouseInFk = vWarehouseFk
GROUP BY tr.landed , a.name ;
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_getEntriesMissingPackage`(vSelf INT)
BEGIN
DECLARE vpackageOrPackingNull INT;
DECLARE vTravelFk INT;
SELECT travelfk INTO vTravelFk
FROM entry
WHERE id = vSelf;
SELECT e.id entryFk
FROM travel t
JOIN entry e ON e.travelFk = t.id
JOIN buy b ON b.entryFk = e.id
WHERE t.id = vTravelFk
AND (b.packing IS NULL OR b.packagingFk IS NULL);
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketBoxesView`(IN vTicketFk INT)
BEGIN
SELECT s.id,
s.itemFk,
s.concept,
floor(s.quantity / b.packing) as Cajas,
b.packing,
s.isPicked,
i.size
FROM ticket t
JOIN sale s ON s.ticketFk = t.id
JOIN item i ON i.id = s.itemFk
JOIN cache.last_buy lb on lb.warehouse_id = t.warehouseFk AND lb.item_id = s.itemFk
JOIN buy b on b.id = lb.buy_id
JOIN packaging p on p.id = b.packagingFk
WHERE s.quantity >= b.packing
AND t.id = vTicketFk
AND p.isBox
GROUP BY s.itemFk;
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBuyedByWorker`(
vDate DATE,
vWorker INT)
BEGIN
/**
* Calculates the space reserved by buyers of the same container
*
* @param vdate date of container delivery
* @param vWorker buyer reserving space in the container
*/
DECLARE vVolume DECIMAL(10, 2);
DECLARE vWarehouseFk INT;
DECLARE vCompressionRatio DECIMAL(1, 1);
CALL stockTraslation(vDate);
SELECT warehouseFk, conversionCoefficient INTO vWarehouseFk, vCompressionRatio
FROM auctionConfig;
SELECT volume INTO vVolume
FROM vn.packaging WHERE id = 'cc';
SELECT b.entryFk Id_Entrada,
i.id Id_Article,
i.name Article,
ti.amount Cantidad,
(vCompressionRatio * (ti.amount / b.packing) * vn.buy_getVolume(b.id))
/ vVolume buyed,
b.packagingFk id_cubo,
b.packing
FROM tmp.item ti
JOIN item i ON i.id = ti.item_id
JOIN itemType it ON i.typeFk = it.id
JOIN itemCategory ic ON ic.id = it.categoryFk
JOIN worker w ON w.id = it.workerFk
JOIN tmp.buyUltimate bu ON bu.itemFk = i.id
AND bu.warehouseFk = vWarehouseFk
JOIN buy b ON b.id = bu.buyFk
WHERE ic.display AND w.id = vWorker;
DROP TEMPORARY TABLE
tmp.buyUltimate,
tmp.item;
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, `vCreated` VARCHAR(22))
BEGIN
DECLARE vItemFk INT;
SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
SELECT itemFk INTO vItemFk
FROM vn.buy b
WHERE b.id = vItemFk;
IF (SELECT COUNT(*) FROM vn.shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
INSERT IGNORE INTO vn.parking(`code`) VALUES(vShelvingFk);
INSERT INTO vn.shelving(`code`, parkingFk)
SELECT vShelvingFk, id
FROM vn.parking
WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci;
END IF;
IF (SELECT COUNT(*) FROM vn.itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking) = 1 THEN
UPDATE vn.itemShelving
SET visible = visible+vQuantity,
created = vCreated
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking;
ELSE
CALL cache.last_buy_refresh(FALSE);
INSERT INTO itemShelving( itemFk,
shelvingFk,
visible,
created,
`grouping`,
packing,
packagingFk)
SELECT vItemFk,
vShelvingFk,
vQuantity,
vCreated,
IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) `grouping`,
IF(vPacking = 0, b.packing, vPacking) packing,
IF(vPackagingFk = '', b.packagingFk, vPackagingFk) packaging
FROM vn.item i
LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
LEFT JOIN vn.buy b ON b.id = lb.buy_id
WHERE i.id = vItemFk;
END IF;
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT)
BEGIN
/**
* Añade registro o lo actualiza si ya existe.
*
* @param vShelvingFk matrícula del carro
* @param vBarcode el id del registro
* @param vQuantity indica la cantidad del producto
* @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra
* @param vGrouping el grouping del producto en itemShelving, NULL para coger el de la ultima compra
* @param vPacking el packing del producto, NULL para coger el de la ultima compra
* @param vWarehouseFk indica el sector
*
**/
DECLARE vItemFk INT;
SELECT barcodeToItem(vBarcode) INTO vItemFk;
IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
INSERT IGNORE INTO parking(code) VALUES(vShelvingFk);
INSERT INTO shelving(code, parkingFk)
SELECT vShelvingFk, id
FROM parking
WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci;
END IF;
IF (SELECT COUNT(*) FROM itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking) = 1 THEN
UPDATE itemShelving
SET visible = visible+vQuantity
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
ELSE
CALL cache.last_buy_refresh(FALSE);
INSERT INTO itemShelving( itemFk,
shelvingFk,
visible,
grouping,
packing,
packagingFk)
SELECT vItemFk,
vShelvingFk,
vQuantity,
IFNULL(vGrouping, b.grouping),
IFNULL(vPacking, b.packing),
IFNULL(vPackagingFk, b.packagingFk)
FROM item i
LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
LEFT JOIN buy b ON b.id = lb.buy_id
WHERE i.id = vItemFk;
END IF;
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemFreight_Show`(vItemFk INT, vWarehouseFk INT)
BEGIN
SELECT cm3 Volumen_Entrada,
cm3delivery Volumen_Salida,
p.volume Volumen_del_embalaje,
p.width Ancho_del_embalaje,
p.`depth` Largo_del_embalaje,
b.packagingFk ,
IFNULL(p.height, i.`size`) + 10 Altura,
b.packing Packing_Entrada,
i.packingOut Packing_Salida,
i.id itemFk,
b.id buyFk,
b.entryFk,
w.name warehouseFk
FROM vn.itemCost ic
JOIN vn.item i ON i.id = ic.itemFk
LEFT JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk
LEFT JOIN vn.buy b ON b.id = lb.buy_id
LEFT JOIN vn.packaging p ON p.id = b.packagingFk
LEFT JOIN vn.warehouse w ON w.id = ic.warehouseFk
WHERE ic.itemFk = vItemFk
AND ic.warehouseFk = vWarehouseFk;
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`inventoryMake`(vDate DATE, vWh INT)
proc: BEGIN
/**
* Recalcula los inventarios de todos los almacenes, si vWh = 0
*
* @param vDate Fecha de los nuevos inventarios
* @param vWh almacen al cual hacer el inventario
*/
DECLARE vDone BOOL;
DECLARE vEntryFk INT;
DECLARE vTravelFk INT;
DECLARE vDateLastInventory DATE;
DECLARE vDateYesterday DATETIME DEFAULT vDate - INTERVAL 1 SECOND;
DECLARE vWarehouseOutFkInventory INT;
DECLARE vInventorySupplierFk INT;
DECLARE vAgencyModeFkInventory INT;
DECLARE cWarehouses CURSOR FOR
SELECT id
FROM warehouse
WHERE isInventory
AND vWh IN (0,id);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
OPEN cWarehouses;
SET @isModeInventory := TRUE;
l: LOOP
SET vDone = FALSE;
FETCH cWarehouses INTO vWh;
IF vDone THEN
LEAVE l;
END IF;
SELECT w.id INTO vWarehouseOutFkInventory
FROM warehouse w
WHERE w.code = 'inv';
SELECT inventorySupplierFk INTO vInventorySupplierFk
FROM entryConfig;
SELECT am.id INTO vAgencyModeFkInventory
FROM agencyMode am
where code = 'inv';
SELECT MAX(landed) INTO vDateLastInventory
FROM travel tr
JOIN entry e ON e.travelFk = tr.id
JOIN buy b ON b.entryFk = e.id
WHERE warehouseOutFk = vWarehouseOutFkInventory
AND landed < vDate
AND e.supplierFk = vInventorySupplierFk
AND warehouseInFk = vWh
AND NOT isRaid;
IF vDateLastInventory IS NULL THEN
SELECT inventoried INTO vDateLastInventory FROM config;
END IF;
-- Generamos travel, si no existe.
SET vTravelFK = 0;
SELECT id INTO vTravelFk
FROM travel
WHERE warehouseOutFk = vWarehouseOutFkInventory
AND warehouseInFk = vWh
AND landed = vDate
AND agencyModeFk = vAgencyModeFkInventory
AND ref = 'inventario'
LIMIT 1;
IF NOT vTravelFK THEN
INSERT INTO travel SET
warehouseOutFk = vWarehouseOutFkInventory,
warehouseInFk = vWh,
shipped = vDate,
landed = vDate,
agencyModeFk = vAgencyModeFkInventory,
ref = 'inventario',
isDelivered = TRUE,
isReceived = TRUE;
SELECT LAST_INSERT_ID() INTO vTravelFk;
END IF;
-- Generamos entrada si no existe, o la vaciamos.
SET vEntryFk = 0;
SELECT id INTO vEntryFk
FROM entry
WHERE supplierFk = vInventorySupplierFk
AND travelFk = vTravelFk;
IF NOT vEntryFk THEN
INSERT INTO entry SET
supplierFk = vInventorySupplierFk,
isConfirmed = TRUE,
isOrdered = TRUE,
travelFk = vTravelFk;
SELECT LAST_INSERT_ID() INTO vEntryFk;
ELSE
DELETE FROM buy WHERE entryFk = vEntryFk;
END IF;
-- Preparamos tabla auxilar
CREATE OR REPLACE TEMPORARY TABLE tmp.inventory (
itemFk INT(11) NOT NULL PRIMARY KEY,
quantity int(11) DEFAULT '0',
buyingValue decimal(10,3) DEFAULT '0.000',
freightValue decimal(10,3) DEFAULT '0.000',
packing int(11) DEFAULT '0',
`grouping` smallint(5) unsigned NOT NULL DEFAULT '1',
groupingMode tinyint(4) NOT NULL DEFAULT 0 ,
comissionValue decimal(10,3) DEFAULT '0.000',
packageValue decimal(10,3) DEFAULT '0.000',
packageFk varchar(10) COLLATE utf8_unicode_ci DEFAULT '--',
price1 decimal(10,2) DEFAULT '0.00',
price2 decimal(10,2) DEFAULT '0.00',
price3 decimal(10,2) DEFAULT '0.00',
minPrice decimal(10,2) DEFAULT '0.00',
producer varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
INDEX (itemFK)) ENGINE = MEMORY;
-- Compras
INSERT INTO tmp.inventory(itemFk,quantity)
SELECT b.itemFk, SUM(b.quantity)
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.warehouseInFk = vWh
AND tr.landed BETWEEN vDateLastInventory
AND vDateYesterday
AND NOT isRaid
GROUP BY b.itemFk;
SELECT vDateLastInventory , vDateYesterday;
-- Traslados
INSERT INTO tmp.inventory(itemFk, quantity)
SELECT itemFk, quantityOut
FROM (
SELECT b.itemFk,- SUM(b.quantity) quantityOut
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.warehouseOutFk = vWh
AND tr.shipped BETWEEN vDateLastInventory
AND vDateYesterday
AND NOT isRaid
GROUP BY b.itemFk
) sub
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut;
-- Ventas
INSERT INTO tmp.inventory(itemFk,quantity)
SELECT itemFk, saleOut
FROM (
SELECT s.itemFk, - SUM(s.quantity) saleOut
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
WHERE t.warehouseFk = vWh
AND t.shipped BETWEEN vDateLastInventory AND vDateYesterday
GROUP BY s.itemFk
) sub
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity,0) + sub.saleOut;
-- Actualiza valores de la ultima compra
UPDATE tmp.inventory inv
JOIN cache.last_buy lb ON lb.item_id = inv.itemFk AND lb.warehouse_id = vWh
JOIN buy b ON b.id = lb.buy_id
JOIN item i ON i.id = b.itemFk
LEFT JOIN producer p ON p.id = i.producerFk
SET inv.buyingValue = b.buyingValue,
inv.freightValue = b.freightValue,
inv.packing = b.packing,
inv.`grouping`= b.`grouping`,
inv.groupingMode = b.groupingMode,
inv.comissionValue = b.comissionValue,
inv.packageValue = b.packageValue,
inv.packageFk = b.packagingFk,
inv.price1 = b.price1,
inv.price2 = b.price2,
inv.price3 = b.price3,
inv.minPrice = b.minPrice,
inv.producer = p.name;
INSERT INTO buy( itemFk,
quantity,
buyingValue,
freightValue,
packing,
`grouping`,
groupingMode,
comissionValue,
packageValue,
packagingFk,
price1,
price2,
price3,
minPrice,
entryFk)
SELECT itemFk,
GREATEST(quantity, 0),
buyingValue,
freightValue,
packing,
`grouping`,
groupingMode,
comissionValue,
packageValue,
packagingFk,
price1,
price2,
price3,
minPrice,
vEntryFk
FROM tmp.inventory;
SELECT vWh, COUNT(*), util.VN_NOW() FROM tmp.inventory;
-- Actualizamos el campo lastUsed de item
UPDATE item i
JOIN tmp.inventory i2 ON i2.itemFk = i.id
SET i.lastUsed = NOW()
WHERE i2.quantity;
-- DROP TEMPORARY TABLE tmp.inventory;
END LOOP;
CLOSE cWarehouses;
UPDATE config SET inventoried = vDate;
SET @isModeInventory := FALSE;
DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
CREATE TEMPORARY TABLE tmp.entryToDelete
(INDEX(entryId) USING BTREE) ENGINE = MEMORY
SELECT e.id as entryId,
t.id as travelId
FROM travel t
JOIN `entry` e ON e.travelFk = t.id
WHERE e.supplierFk = vInventorySupplierFk
AND t.shipped <= util.VN_CURDATE() - INTERVAL 12 DAY
AND (DAY(t.shipped) <> 1 OR shipped < util.VN_CURDATE() - INTERVAL 12 DAY);
DELETE e
FROM `entry` e
JOIN tmp.entryToDelete tmp ON tmp.entryId = e.id;
DELETE IGNORE t
FROM travel t
JOIN tmp.entryToDelete tmp ON tmp.travelId = t.id;
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`inventory_repair`()
BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.lastEntry;
CREATE TEMPORARY TABLE tmp.lastEntry
(PRIMARY KEY (buyFk))
SELECT
i.id AS itemFk,
w.id AS warehouseFk,
w.name AS warehouse,
tr.landed,
b.id AS buyFk,
b.entryFk,
b.isIgnored,
b.price2,
b.price3,
b.stickers,
b.packing,
b.grouping,
b.groupingMode,
b.weight,
i.stems,
b.quantity,
b.buyingValue,
b.packagingFk ,
s.id AS supplierFk,
s.name AS supplier
FROM itemType it
RIGHT JOIN (entry e
LEFT JOIN supplier s ON s.id = e.supplierFk
RIGHT JOIN buy b ON b.entryFk = e.id
LEFT JOIN item i ON i.id = b.itemFk
LEFT JOIN ink ON ink.id = i.inkFk
LEFT JOIN travel tr ON tr.id = e.travelFk
LEFT JOIN warehouse w ON w.id = tr.warehouseInFk
LEFT JOIN origin o ON o.id = i.originFk
) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
WHERE (b.packagingFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO';
DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk;
CREATE TEMPORARY TABLE tmp.lastEntryOk
(PRIMARY KEY (buyFk))
SELECT
i.id AS itemFk,
w.id AS warehouseFk,
w.name AS warehouse,
tr.landed,
b.id AS buyFk,
b.entryFk,
b.isIgnored,
b.price2,
b.price3,
b.stickers,
b.packing,
b.grouping,
b.groupingMode,
b.weight,
i.stems,
b.quantity,
b.buyingValue,
b.packagingFk,
s.id AS supplierFk,
s.name AS supplier
FROM itemType it
RIGHT JOIN (entry e
LEFT JOIN supplier s ON s.id = e.supplierFk
RIGHT JOIN buy b ON b.entryFk = e.id
LEFT JOIN item i ON i.id = b.itemFk
LEFT JOIN ink ON ink.id = i.inkFk
LEFT JOIN travel tr ON tr.id = e.travelFk
LEFT JOIN warehouse w ON w.id = tr.warehouseInFk
LEFT JOIN origin o ON o.id = i.originFk
) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
WHERE b.packagingFk != "--" AND b.price2 != 0 AND b.packing != 0 AND b.buyingValue > 0 AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-2,util.VN_CURDATE()))
ORDER BY tr.landed DESC;
DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOkGroup;
CREATE TEMPORARY TABLE tmp.lastEntryOkGroup
(INDEX (warehouseFk,itemFk))
SELECT *
FROM tmp.lastEntryOk tmp
GROUP BY tmp.itemFk,tmp.warehouseFk;
UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
SET b.packagingFk = eo.packagingFk WHERE b.packagingFk = "--";
UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
SET b.price2 = eo.price2 WHERE b.price2 = 0 ;
UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
SET b.packing = eo.packing WHERE b.packing = 0;
UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
SET b.buyingValue = eo.buyingValue WHERE b.buyingValue = 0;
DROP TEMPORARY TABLE tmp.lastEntry;
DROP TEMPORARY TABLE tmp.lastEntryOk;
DROP TEMPORARY TABLE tmp.lastEntryOkGroup;
END$$
DELIMITER ;

View File

@ -1454,7 +1454,7 @@ INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeF
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'),
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '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`, `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
(1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
(2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),

View File

@ -8637,7 +8637,7 @@ proc:BEGIN
,`grouping`
,quantity
,groupingMode
,packageFk
,packagingFk
,weight
)
SELECT
@ -8650,7 +8650,7 @@ proc:BEGIN
,IFNULL(b.`grouping`, e.pac)
,@pac * e.qty
,vForceToPacking
,IF(vHasToChangePackagingFk OR ISNULL(b.packageFk), vPackage, b.packageFk)
,IF(vHasToChangePackagingFk OR ISNULL(b.packagingFk), vPackage, b.packagingFk)
,(IFNULL(i.weightByPiece,0) * @pac)/1000
FROM edi.ekt e
LEFT JOIN vn.buy b ON b.id = vBuy
@ -9449,7 +9449,7 @@ proc: BEGIN
packing,
`grouping`,
groupingMode,
packageFk,
packagingFk,
deliveryFk)
SELECT wf.entryFk,
i.id,
@ -11768,14 +11768,14 @@ BEGIN
ENGINE = MEMORY
SELECT *
FROM (
SELECT b.itemFk, b.packageFk, b.packing
SELECT b.itemFk, b.packagingFk, b.packing
FROM vn.buy b
JOIN vn.entry e ON e.id = b.entryFk
JOIN vn.travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vDateInv AND vDate
AND NOT b.isIgnored
AND b.price2 >= 0
AND b.packageFk IS NOT NULL
AND b.packagingFk IS NOT NULL
ORDER BY t.warehouseInFk = vWarehouse DESC, t.landed DESC
LIMIT 10000000000000000000
) t GROUP BY itemFk;
@ -11792,7 +11792,7 @@ BEGIN
JOIN `filter` f ON f.itemFk = i.id
JOIN currentStock s ON s.itemFk = i.id
LEFT JOIN tmp t ON t.itemFk = i.id
LEFT JOIN vn.packaging p ON p.id = t.packageFk
LEFT JOIN vn.packaging p ON p.id = t.packagingFk
WHERE CEIL(s.quantity / t.packing) > 0
-- FIXME: Column Cubos.box not included in view vn.packaging
/* AND p.box */;
@ -22837,7 +22837,7 @@ CREATE TABLE `buy` (
`comissionValue` decimal(10,3) NOT NULL DEFAULT 0.000,
`packageValue` decimal(10,3) NOT NULL DEFAULT 0.000,
`location` varchar(5) DEFAULT NULL,
`packageFk` varchar(10) DEFAULT '--',
`packagingFk` varchar(10) DEFAULT '--',
`price1` decimal(10,2) DEFAULT 0.00,
`price2` decimal(10,2) DEFAULT 0.00,
`price3` decimal(10,2) DEFAULT 0.00,
@ -22855,7 +22855,7 @@ CREATE TABLE `buy` (
`editorFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `CompresId_Trabajador` (`workerFk`),
KEY `Id_Cubo` (`packageFk`),
KEY `Id_Cubo` (`packagingFk`),
KEY `Id_Entrada` (`entryFk`),
KEY `container_id` (`containerFk`),
KEY `buy_edi_id` (`ektFk`),
@ -22870,7 +22870,7 @@ CREATE TABLE `buy` (
CONSTRAINT `buy_fk_4` FOREIGN KEY (`deliveryFk`) REFERENCES `edi`.`deliveryInformation` (`ID`) ON DELETE SET NULL ON UPDATE SET NULL,
CONSTRAINT `buy_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`),
CONSTRAINT `buy_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE,
CONSTRAINT `buy_ibfk_2` FOREIGN KEY (`packageFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE,
CONSTRAINT `buy_ibfk_2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE,
CONSTRAINT `buy_id` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `buy_itemfk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci ROW_FORMAT=DYNAMIC;
@ -23091,7 +23091,7 @@ trig: BEGIN
!(NEW.quantity <=> OLD.quantity) OR
!(NEW.packing <=> OLD.packing) OR
!(NEW.grouping <=> OLD.grouping) OR
!(NEW.packageFk <=> OLD.packageFk) OR
!(NEW.packagingFk <=> OLD.packagingFk) OR
!(NEW.weight <=> OLD.weight) THEN
CALL vn.mail_insert(
CONCAT(account.user_getNameFromId(vBuyerFk),'@verdnatura.es'),
@ -43988,7 +43988,7 @@ BEGIN
DECLARE vPackaging VARCHAR(10);
DECLARE vPacking INT;
SELECT itemFk, packageFk, packing
SELECT itemFk, packagingFk, packing
INTO vItem, vPackaging, vPacking
FROM buy
WHERE id = vSelf;
@ -44022,7 +44022,7 @@ BEGIN
DECLARE vItem INT;
DECLARE vPackaging VARCHAR(10);
SELECT itemFk, packageFk INTO vItem, vPackaging
SELECT itemFk, packagingFk INTO vItem, vPackaging
FROM buy
WHERE id = vSelf;
@ -49098,7 +49098,7 @@ BEGIN
LEFT JOIN item i ON i.id = b.itemFk
LEFT JOIN itemType it ON it.id = i.typeFk
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN packaging p ON p.id = b.packageFk AND NOT p.isBox
LEFT JOIN packaging p ON p.id = b.packagingFk AND NOT p.isBox
JOIN volumeConfig vc ON TRUE
WHERE b.id = vSelf;
@ -49329,9 +49329,9 @@ BEGIN
*/
SELECT t.name Temp,
CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
item_getVolume(b.itemFk, b.packageFk)) / vc.trolleyM3 / 1000000 ,1) AS DECIMAL(10,2)) carros ,
item_getVolume(b.itemFk, b.packagingFk)) / vc.trolleyM3 / 1000000 ,1) AS DECIMAL(10,2)) carros ,
CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
item_getVolume(b.itemFk, b.packageFk)) / vc.palletM3 / 1000000,1) AS DECIMAL(10,2)) espais
item_getVolume(b.itemFk, b.packagingFk)) / vc.palletM3 / 1000000,1) AS DECIMAL(10,2)) espais
FROM buy b
JOIN tmp.buy tb ON tb.buyFk = b.id
JOIN volumeConfig vc
@ -49446,7 +49446,7 @@ BEGIN
UPDATE buy b
JOIN tmp.buyRecalc br ON br.id = b.id AND (@buyId := b.id)
LEFT JOIN packaging p ON p.id = b.packageFk
LEFT JOIN packaging p ON p.id = b.packagingFk
JOIN item i ON i.id = b.itemFk
JOIN entry e ON e.id = b.entryFk
JOIN itemType it ON it.id = i.typeFk
@ -49454,7 +49454,7 @@ BEGIN
JOIN agencyMode am ON am.id = tr.agencyModeFk
JOIN tmp.rate r
JOIN volumeConfig vc
SET b.freightValue = @PF:= IFNULL(((am.m3 * @m3:= item_getVolume(b.itemFk, b.packageFk) / 1000000)
SET b.freightValue = @PF:= IFNULL(((am.m3 * @m3:= item_getVolume(b.itemFk, b.packagingFk) / 1000000)
/ b.packing) * IF(am.hasWeightVolumetric, GREATEST(b.weight / @m3 / vc.aerealVolumetricDensity, 1), 1), 0),
b.comissionValue = @CF:= ROUND(IFNULL(e.commission * b.buyingValue / 100, 0), 3),
b.packageValue = @EF:= IF(vIsWarehouseFloramondo, 0, IFNULL(ROUND(IF(p.isPackageReturnable, p.returnCost / b.packing , p.`value` / b.packing), 3),0)),
@ -49462,7 +49462,7 @@ BEGIN
b.price2 = @t2:= round(@t3 * (1 + ((r.rate2 - r.rate3)/100)),2),
b.price2 = @t2:= IF(@t2 <= @t3,@t3 , @t2);
SELECT (b.buyingValue = b.price2), b.buyingValue, b.packageFk
SELECT (b.buyingValue = b.price2), b.buyingValue, b.packagingFk
INTO vHasNotPrice, vBuyingValue, vPackageFk
FROM vn.buy b
WHERE b.id = @buyId AND b.buyingValue <> 0.01;
@ -54112,7 +54112,7 @@ BEGIN
SELECT id INTO vBucket FROM packaging WHERE volume = vVolume LIMIT 1;
END IF;
INSERT INTO buy(itemFk,quantity, entryFk, packageFk, packing, stickers, buyingValue, price2, price3)
INSERT INTO buy(itemFk,quantity, entryFk, packagingFk, packing, stickers, buyingValue, price2, price3)
SELECT itemFk,
quantity,
vEntry,
@ -54152,7 +54152,7 @@ BEGIN
SELECT count(*) INTO vpackageOrPackingNull
FROM buy b
WHERE b.entryFk = vEntryFk
AND (b.packing IS NULL OR b.packageFk IS NULL);
AND (b.packing IS NULL OR b.packagingFk IS NULL);
IF vpackageOrPackingNull THEN
CALL util.throw("packageOrPackingNull");
@ -54316,7 +54316,7 @@ BEGIN
containerFk,
comissionValue,
packageValue,
packageFk,
packagingFk,
price1,
price2,
price3,
@ -54339,7 +54339,7 @@ BEGIN
containerFk,
comissionValue,
packageValue,
packageFk,
packagingFk,
price1,
price2,
price3,
@ -54397,7 +54397,7 @@ BEGIN
comissionValue,
packageValue,
location,
packageFk,
packagingFk,
price1,
price2,
price3,
@ -54417,7 +54417,7 @@ BEGIN
comissionValue,
packageValue,
location,
packageFk,
packagingFk,
price1,
price2,
price3,
@ -54545,7 +54545,7 @@ BEGIN
containerFk,
comissionValue,
packageValue,
packageFk,
packagingFk,
price1,
price2,
price3,
@ -54566,7 +54566,7 @@ BEGIN
containerFk,
comissionValue,
packageValue,
packageFk,
packagingFk,
price1,
price2,
price3,
@ -54604,7 +54604,7 @@ BEGIN
comissionValue,
packageValue,
location,
packageFk,
packagingFk,
price1,
price2,
price3,
@ -54623,7 +54623,7 @@ BEGIN
comissionValue,
packageValue,
location,
packageFk,
packagingFk,
price1,
price2,
price3,
@ -54848,7 +54848,7 @@ BEGIN
comissionValue,
packageValue,
location,
packageFk,
packagingFk,
price1,
price2,
price3,
@ -54876,7 +54876,7 @@ BEGIN
comissionValue,
packageValue,
location,
packageFk,
packagingFk,
price1,
price2,
price3,
@ -56122,14 +56122,14 @@ BEGIN
LEFT JOIN (
SELECT FustCode, sum(fustQuantity) stucks
FROM (
SELECT IFNULL(pe.equivalentFk ,b.packageFk) FustCode, s.quantity / b.packing AS fustQuantity
SELECT IFNULL(pe.equivalentFk ,b.packagingFk) FustCode, s.quantity / b.packing AS fustQuantity
FROM vn.sale s
JOIN vn.ticket t ON t.id = s.ticketFk
JOIN vn.warehouse w ON w.id = t.warehouseFk
JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk
JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND lb.warehouse_id = t.warehouseFk
JOIN vn.buy b ON b.id = lb.buy_id
JOIN vn.packaging p ON p.id = b.packageFk
JOIN vn.packaging p ON p.id = b.packagingFk
LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id
JOIN vn.address a ON a.id = t.addressFk
JOIN vn.province p2 ON p2.id = a.provinceFk
@ -56792,7 +56792,7 @@ proc: BEGIN
inv.groupingMode = b.groupingMode,
inv.comissionValue = b.comissionValue,
inv.packageValue = b.packageValue,
inv.packageFk = b.packageFk,
inv.packageFk = b.packagingFk,
inv.price1 = b.price1,
inv.price2 = b.price2,
inv.price3 = b.price3,
@ -56808,7 +56808,7 @@ proc: BEGIN
groupingMode,
comissionValue,
packageValue,
packageFk,
packagingFk,
price1,
price2,
price3,
@ -56930,7 +56930,7 @@ BEGIN
i.stems,
b.quantity,
b.buyingValue,
b.packageFk ,
b.packagingFk ,
s.id AS supplierFk,
s.name AS supplier
FROM itemType it
@ -56944,7 +56944,7 @@ BEGIN
LEFT JOIN origin o ON o.id = i.originFk
) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
WHERE (b.packageFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO';
WHERE (b.packagingFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO';
DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk;
CREATE TEMPORARY TABLE tmp.lastEntryOk
@ -56967,7 +56967,7 @@ BEGIN
i.stems,
b.quantity,
b.buyingValue,
b.packageFk ,
b.packagingFk ,
s.id AS supplierFk,
s.name AS supplier
FROM itemType it
@ -56981,7 +56981,7 @@ BEGIN
LEFT JOIN origin o ON o.id = i.originFk
) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
WHERE b.packageFk != "--" AND b.price2 != 0 AND b.packing != 0 AND b.buyingValue > 0 AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-2,util.VN_CURDATE()))
WHERE b.packagingFk != "--" AND b.price2 != 0 AND b.packing != 0 AND b.buyingValue > 0 AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-2,util.VN_CURDATE()))
ORDER BY tr.landed DESC;
DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOkGroup;
@ -56994,7 +56994,7 @@ BEGIN
UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
SET b.packageFk = eo.packageFk WHERE b.packageFk = "--";
SET b.packagingFk = eo.packageFk WHERE b.packagingFk = "--";
UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id
@ -58767,7 +58767,7 @@ BEGIN
p.volume Volumen_del_embalaje,
p.width Ancho_del_embalaje,
p.`depth` Largo_del_embalaje,
b.packageFk ,
b.packagingFk ,
IFNULL(p.height, i.`size`) + 10 Altura,
b.packing Packing_Entrada,
i.packingOut Packing_Salida,
@ -58779,7 +58779,7 @@ BEGIN
JOIN vn.item i ON i.id = ic.itemFk
LEFT JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk
LEFT JOIN vn.buy b ON b.id = lb.buy_id
LEFT JOIN vn.packaging p ON p.id = b.packageFk
LEFT JOIN vn.packaging p ON p.id = b.packagingFk
LEFT JOIN vn.warehouse w ON w.id = ic.warehouseFk
WHERE ic.itemFk = vItemFk
AND ic.warehouseFk = vWarehouseFk;
@ -59610,7 +59610,7 @@ BEGIN
vCreated,
IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) `grouping`,
IF(vPacking = 0, b.packing, vPacking) packing,
IF(vPackagingFk = '', b.packageFk, vPackagingFk) packaging
IF(vPackagingFk = '', b.packagingFk, vPackagingFk) packaging
FROM vn.item i
LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
LEFT JOIN vn.buy b ON b.id = lb.buy_id
@ -60254,7 +60254,7 @@ BEGIN
vQuantity,
IFNULL(vGrouping, b.grouping),
IFNULL(vPacking, b.packing),
IFNULL(vPackagingFk, b.packageFk)
IFNULL(vPackagingFk, b.packagingFk)
FROM item i
LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
LEFT JOIN buy b ON b.id = lb.buy_id
@ -65013,8 +65013,8 @@ BEGIN
END IF;
INSERT INTO vn.buy(entryFk, itemFk, quantity, buyingValue, packageFk, packing, grouping)
SELECT vEntryFk, b.itemFk, vQuantity, b.buyingValue, b.packageFk, b.packing, b.grouping
INSERT INTO vn.buy(entryFk, itemFk, quantity, buyingValue, packagingFk, packing, grouping)
SELECT vEntryFk, b.itemFk, vQuantity, b.buyingValue, b.packagingFk, b.packing, b.grouping
FROM cache.last_buy lb
JOIN vn.buy b ON b.id = lb.buy_id
WHERE lb.item_id = vItemFk
@ -67921,7 +67921,7 @@ BEGIN
ti.amount Cantidad,
(vCompressionRatio * (ti.amount / b.packing) * vn.buy_getVolume(b.id))
/ vVolume buyed,
b.packageFk id_cubo,
b.packagingFk id_cubo,
b.packing
FROM tmp.item ti
JOIN item i ON i.id = ti.item_id
@ -68573,7 +68573,7 @@ BEGIN
JOIN item i ON i.id = s.itemFk
JOIN cache.last_buy lb on lb.warehouse_id = t.warehouseFk AND lb.item_id = s.itemFk
JOIN buy b on b.id = lb.buy_id
JOIN packaging p on p.id = b.packageFk
JOIN packaging p on p.id = b.packagingFk
WHERE s.quantity >= b.packing
AND t.id = vTicketFk
AND p.isBox
@ -73566,9 +73566,9 @@ BEGIN
e.id Id_Entrada,
e.invoiceNumber Referencia,
CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.trolleyM3 / 1000000 ,1) AS DECIMAL(10,2)) AS CC,
vn.item_getVolume(b.itemFk ,b.packagingFk)) / vc.trolleyM3 / 1000000 ,1) AS DECIMAL(10,2)) AS CC,
CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.palletM3 / 1000000,1) AS DECIMAL(10,2)) AS espais
vn.item_getVolume(b.itemFk ,b.packagingFk)) / vc.palletM3 / 1000000,1) AS DECIMAL(10,2)) AS espais
FROM vn.buy b
JOIN vn.entry e ON e.id = b.entryFk
JOIN vn.supplier s ON s.id = e.supplierFk
@ -73602,7 +73602,7 @@ BEGIN
SELECT tr.landed Fecha,
a.name Agencia,
count(DISTINCT e.id) numEntradas,
FLOOR(sum(item_getVolume(b.itemFk, b.packageFk) * b.stickers / 1000000 )) AS m3
FLOOR(sum(item_getVolume(b.itemFk, b.packagingFk) * b.stickers / 1000000 )) AS m3
FROM vn.travel tr
JOIN vn.agencyMode a ON a.id = tr.agencyModeFk
JOIN vn.entry e ON e.travelFk = tr.id
@ -73952,7 +73952,7 @@ BEGIN
JOIN entry e ON e.travelFk = t.id
JOIN buy b ON b.entryFk = e.id
WHERE t.id = vTravelFk
AND (b.packing IS NULL OR b.packageFk IS NULL);
AND (b.packing IS NULL OR b.packagingFk IS NULL);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -79867,7 +79867,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `awbVolume` AS select `d`.`awbFk` AS `awbFk`,`b`.`stickers` * `i`.`density` * if(`p`.`volume` > 0,`p`.`volume`,`p`.`width` * `p`.`depth` * if(`p`.`height` = 0,`i`.`size` + 10,`p`.`height`)) / (`vc`.`aerealVolumetricDensity` * 1000) AS `volume`,`b`.`id` AS `buyFk` from ((((((((`buy` `b` join `item` `i` on(`b`.`itemFk` = `i`.`id`)) join `itemType` `it` on(`i`.`typeFk` = `it`.`id`)) join `packaging` `p` on(`p`.`id` = `b`.`packageFk`)) join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`t`.`id` = `e`.`travelFk`)) join `duaEntry` `de` on(`de`.`entryFk` = `e`.`id`)) join `dua` `d` on(`d`.`id` = `de`.`duaFk`)) join `volumeConfig` `vc`) where `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1,1) */;
/*!50001 VIEW `awbVolume` AS select `d`.`awbFk` AS `awbFk`,`b`.`stickers` * `i`.`density` * if(`p`.`volume` > 0,`p`.`volume`,`p`.`width` * `p`.`depth` * if(`p`.`height` = 0,`i`.`size` + 10,`p`.`height`)) / (`vc`.`aerealVolumetricDensity` * 1000) AS `volume`,`b`.`id` AS `buyFk` from ((((((((`buy` `b` join `item` `i` on(`b`.`itemFk` = `i`.`id`)) join `itemType` `it` on(`i`.`typeFk` = `it`.`id`)) join `packaging` `p` on(`p`.`id` = `b`.`packagingFk`)) join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`t`.`id` = `e`.`travelFk`)) join `duaEntry` `de` on(`de`.`entryFk` = `e`.`id`)) join `dua` `d` on(`d`.`id` = `de`.`duaFk`)) join `volumeConfig` `vc`) where `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1,1) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;

View File

@ -620,6 +620,7 @@ let actions = {
},
async setInput(selector, value) {
await this.waitForSelector(selector);
const input = await this.$(selector);
const tagName = (await input.evaluate(e => e.tagName)).toLowerCase();

View File

@ -1193,7 +1193,7 @@ export default {
secondBuyPacking: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.packing"]',
secondBuyWeight: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.weight"]',
secondBuyStickers: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.stickers"]',
secondBuyPackage: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-autocomplete[ng-model="buy.packageFk"]',
secondBuyPackage: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-autocomplete[ng-model="buy.packagingFk"]',
secondBuyQuantity: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.quantity"]',
secondBuyItem: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-autocomplete[ng-model="buy.itemFk"]',
importButton: 'vn-entry-buy-index vn-icon[icon="publish"]',

View File

@ -1,20 +1,5 @@
import getBrowser from '../../helpers/puppeteer';
const $ = {
saveButton: 'vn-supplier-fiscal-data button[type="submit"]',
};
const $inputs = {
province: 'vn-supplier-fiscal-data [name="province"]',
country: 'vn-supplier-fiscal-data [name="country"]',
postcode: 'vn-supplier-fiscal-data [name="postcode"]',
city: 'vn-supplier-fiscal-data [name="city"]',
socialName: 'vn-supplier-fiscal-data [name="socialName"]',
taxNumber: 'vn-supplier-fiscal-data [name="taxNumber"]',
account: 'vn-supplier-fiscal-data [name="account"]',
sageWithholding: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageWithholdingFk"]',
sageTaxType: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageTaxTypeFk"]'
};
describe('Supplier fiscal data path', () => {
let browser;
let page;
@ -30,7 +15,7 @@ describe('Supplier fiscal data path', () => {
await browser.close();
});
it('should attempt to edit the fiscal data and check data is saved', async() => {
it('should attempt to edit the fiscal data and check data iss saved', async() => {
await page.accessToSection('supplier.card.fiscalData');
const form = 'vn-supplier-fiscal-data form';
@ -40,16 +25,16 @@ describe('Supplier fiscal data path', () => {
postcode: null,
city: 'Valencia',
socialName: 'Farmer King SL',
taxNumber: 'Wrong tax number',
taxNumber: '12345678Z',
account: '0123456789',
sageWithholding: 'retencion estimacion objetiva',
sageTaxType: 'operaciones no sujetas'
};
const errorMessage = await page.sendForm(form, values);
const message = await page.sendForm(form, {
taxNumber: '12345678Z'
const errorMessage = await page.sendForm(form, {
taxNumber: 'Wrong tax number'
});
const message = await page.sendForm(form, values);
await page.reloadSection('supplier.card.fiscalData');
const formValues = await page.fetchForm(form, Object.keys(values));

View File

@ -15,4 +15,4 @@ columns:
weight: weight
entryFk: entry
itemFk: item
packageFk: package
packagingFk: package

View File

@ -15,4 +15,4 @@ columns:
weight: peso
entryFk: entrada
itemFk: artículo
packageFk: paquete
packagingFk: paquete

View File

@ -80,7 +80,7 @@ module.exports = Self => {
comissionValue: buyUltimate.comissionValue,
packageValue: buyUltimate.packageValue,
location: buyUltimate.location,
packageFk: buyUltimate.packageFk,
packagingFk: buyUltimate.packagingFk,
price1: buyUltimate.price1,
price2: buyUltimate.price2,
price3: buyUltimate.price3,

View File

@ -44,7 +44,7 @@ module.exports = Self => {
'grouping',
'groupingMode',
'quantity',
'packageFk',
'packagingFk',
'weight',
'buyingValue',
'price2',

View File

@ -108,7 +108,7 @@ module.exports = Self => {
packing: buy.packing,
grouping: buy.grouping,
buyingValue: buy.buyingValue,
packageFk: buy.packageFk,
packagingFk: buy.packagingFk,
groupingMode: lastBuy.groupingMode,
weight: lastBuy.weight
});

View File

@ -39,7 +39,7 @@ module.exports = Self => {
}, myOptions);
if (packaging)
buy.packageFk = packaging.id;
buy.packagingFk = packaging.id;
const reference = await models.ItemMatchProperties.findOne({
fields: ['itemFk'],

View File

@ -153,8 +153,7 @@ module.exports = Self => {
const date = Date.vnNew();
date.setHours(0, 0, 0, 0);
stmt = new ParameterizedSQL(`
SELECT
i.image,
SELECT i.image,
i.id AS itemFk,
i.size,
i.weightByPiece,
@ -197,7 +196,7 @@ module.exports = Self => {
b.price3,
b.ektFk,
b.weight,
b.packageFk,
b.packagingFk,
lb.landing
FROM cache.last_buy lb
LEFT JOIN cache.visible v ON v.item_id = lb.item_id

View File

@ -33,7 +33,7 @@ describe('entry import()', () => {
packing: 1,
size: 1,
volume: 1200,
packageFk: '94'
packagingFk: '94'
},
{
itemFk: 4,
@ -43,7 +43,7 @@ describe('entry import()', () => {
packing: 1,
size: 25,
volume: 1125,
packageFk: '94'
packagingFk: '94'
}
]
}

View File

@ -10,12 +10,12 @@ describe('entry importBuysPreview()', () => {
});
});
it('should return the buys with the calculated packageFk', async() => {
it('should return the buys with the calculated packagingFk', async() => {
const tx = await models.Entry.beginTransaction({});
const options = {transaction: tx};
try {
const expectedPackageFk = '3';
const expectedPackagingFk = '3';
const buys = [
{
itemFk: 1,
@ -39,7 +39,7 @@ describe('entry importBuysPreview()', () => {
const randomIndex = Math.floor(Math.random() * result.length);
const buy = result[randomIndex];
expect(buy.packageFk).toEqual(expectedPackageFk);
expect(buy.packagingFk).toEqual(expectedPackagingFk);
await tx.rollback();
} catch (e) {

View File

@ -103,7 +103,7 @@
"package": {
"type": "belongsTo",
"model": "Packaging",
"foreignKey": "packageFk"
"foreignKey": "packagingFk"
},
"worker": {
"type": "belongsTo",

View File

@ -83,14 +83,14 @@
<td center>{{::buy.packing | dashIfEmpty}}</td>
<td center>{{::buy.grouping | dashIfEmpty}}</td>
<td>{{::buy.buyingValue | currency: 'EUR':2}}</td>
<td center title="{{::buy.packageFk | dashIfEmpty}}">
<td center title="{{::buy.packagingFk | dashIfEmpty}}">
<vn-autocomplete
vn-one
url="Packagings"
show-field="id"
value-field="id"
where="{isBox: true}"
ng-model="buy.packageFk">
ng-model="buy.packagingFk">
</vn-autocomplete>
</td>
</tr>

View File

@ -88,12 +88,12 @@
<td center>
<vn-autocomplete
vn-one
title="{{::buy.packageFk | dashIfEmpty}}"
title="{{::buy.packagingFk | dashIfEmpty}}"
url="Packagings"
show-field="id"
value-field="id"
where="{freightItemFk: true}"
ng-model="buy.packageFk"
ng-model="buy.packagingFk"
on-change="$ctrl.saveBuy(buy)">
</vn-autocomplete>
</td>

View File

@ -4,7 +4,7 @@ import Section from 'salix/components/section';
export default class Controller extends Section {
saveBuy(buy) {
const missingData = !buy.itemFk || !buy.quantity || !buy.packageFk;
const missingData = !buy.itemFk || !buy.quantity || !buy.packagingFk;
if (missingData) return;
let options;

View File

@ -17,7 +17,7 @@ describe('Entry buy', () => {
describe('saveBuy()', () => {
it(`should call the buys patch route if the received buy has an ID`, () => {
const buy = {id: 1, itemFk: 1, quantity: 1, packageFk: 1};
const buy = {id: 1, itemFk: 1, quantity: 1, packagingFk: 1};
const query = `Buys/${buy.id}`;

View File

@ -104,7 +104,7 @@
<th field="weight">
<span translate>Weight</span>
</th>
<th field="packageFk">
<th field="packagingFk">
<span translate>Package</span>
</th>
<th field="packingOut">
@ -207,7 +207,7 @@
<td number>{{::buy.minPrice | currency: 'EUR':3}}</td>
<td>{{::buy.ektFk | dashIfEmpty}}</td>
<td>{{::buy.weight}}</td>
<td>{{::buy.packageFk}}</td>
<td>{{::buy.packagingFk}}</td>
<td>{{::buy.packingOut}}</td>
<td>{{::buy.landing | date: 'dd/MM/yyyy'}}</td>
</tr>

View File

@ -48,7 +48,7 @@ export default class Controller extends Section {
}
},
{
field: 'packageFk',
field: 'packagingFk',
autocomplete: {
url: 'Packagings',
showField: 'id'
@ -133,7 +133,7 @@ export default class Controller extends Section {
case 'price3':
case 'ektFk':
case 'weight':
case 'packageFk':
case 'packagingFk':
return {[`b.${param}`]: value};
}
}

View File

@ -105,7 +105,7 @@
<tr>
<th translate center field="quantity">Quantity</th>
<th translate center field="sticker">Stickers</th>
<th translate center field="packageFk">Package</th>
<th translate center field="packagingFk">Package</th>
<th translate center field="weight">Weight</th>
<th translate center field="packing">Packing</th>
<th translate center field="grouping">Grouping</th>
@ -118,7 +118,7 @@
<tr>
<td center title="{{::line.quantity}}">{{::line.quantity}}</td>
<td center title="{{::line.stickers | dashIfEmpty}}">{{::line.stickers | dashIfEmpty}}</td>
<td center title="{{::line.packageFk | dashIfEmpty}}">{{::line.packageFk | dashIfEmpty}}</td>
<td center title="{{::line.packagingFk | dashIfEmpty}}">{{::line.packagingFk | dashIfEmpty}}</td>
<td center title="{{::line.weight}}">{{::line.weight}}</td>
<td center>
<vn-chip class="transparent" translate-attr="line.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': line.groupingMode == 2}">

View File

@ -45,15 +45,17 @@ module.exports = Self => {
b.weight,
i.stems,
b.quantity,
b.buyingValue +
(
b.buyingValue +
b.freightValue +
b.comissionValue +
b.packageValue AS cost,
b.packageValue
) cost,
b.buyingValue,
b.freightValue,
b.comissionValue,
b.packageValue,
b.packageFk ,
b.packagingFk,
s.id AS supplierFk,
s.name AS supplier
FROM itemType it

View File

@ -45,7 +45,7 @@
<vn-th field="quantity" number>Quantity</vn-th>
<vn-th number class="expendable">Cost</vn-th>
<vn-th number>Kg.</vn-th>
<vn-th field="packageFk" number>Cube</vn-th>
<vn-th field="packagingFk" number>Cube</vn-th>
<vn-th field="supplierFk" class="expendable">Provider</vn-th>
</vn-tr>
</vn-thead>
@ -94,7 +94,7 @@
</span>
</vn-td>
<vn-td number>{{::entry.weight | dashIfEmpty}}</vn-td>
<vn-td number>{{::entry.packageFk | dashIfEmpty}}</vn-td>
<vn-td number>{{::entry.packagingFk | dashIfEmpty}}</vn-td>
<vn-td class="expendable" title="{{::entry.supplier | dashIfEmpty}}">{{::entry.supplier | dashIfEmpty}}</vn-td>
</vn-tr>
</vn-tbody>

View File

@ -71,7 +71,7 @@ class Controller extends Section {
switch (param) {
case 'id':
case 'quantity':
case 'packageFk':
case 'packagingFk':
return {[`b.${param}`]: value};
case 'supplierFk':
return {[`s.id`]: value};

View File

@ -132,12 +132,19 @@ module.exports = Self => {
s.nickname AS cargoSupplierNickname,
s.name AS supplierName,
CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg,
CAST(SUM(vc.aerealVolumetricDensity * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000) as DECIMAL(10,0)) as volumeKg
CAST(
SUM(
vc.aerealVolumetricDensity *
b.stickers *
IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) /
1000000
)
AS DECIMAL(10,0)) volumeKg
FROM travel t
LEFT JOIN supplier s ON s.id = t.cargoSupplierFk
LEFT JOIN entry e ON e.travelFk = t.id
LEFT JOIN buy b ON b.entryFk = e.id
LEFT JOIN packaging pkg ON pkg.id = b.packageFk
LEFT JOIN packaging pkg ON pkg.id = b.packagingFk
LEFT JOIN item i ON i.id = b.itemFk
LEFT JOIN itemType it ON it.id = i.typeFk
JOIN warehouse w ON w.id = t.warehouseInFk
@ -169,11 +176,19 @@ module.exports = Self => {
e.evaNotes,
e.invoiceAmount,
CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) as loadedkg,
CAST(SUM(vc.aerealVolumetricDensity * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000) AS DECIMAL(10,0)) as volumeKg
CAST(
SUM(
vc.aerealVolumetricDensity *
b.stickers *
IF(pkg.volume,
pkg.volume,
pkg.width * pkg.depth * pkg.height
) / 1000000)
AS DECIMAL(10,0)) volumeKg
FROM tmp.travel tr
JOIN entry e ON e.travelFk = tr.id
JOIN buy b ON b.entryFk = e.id
JOIN packaging pkg ON pkg.id = b.packageFk
JOIN packaging pkg ON pkg.id = b.packagingFk
JOIN item i ON i.id = b.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN supplier s ON s.id = e.supplierFk

View File

@ -47,7 +47,7 @@ module.exports = Self => {
LEFT JOIN vn.buy b ON b.entryFk = e.id
LEFT JOIN vn.supplier s ON e.supplierFk = s.id
JOIN vn.item i ON i.id = b.itemFk
LEFT JOIN vn.packaging p ON p.id = b.packageFk
LEFT JOIN vn.packaging p ON p.id = b.packagingFk
JOIN vn.packaging pcc ON pcc.id = 'cc'
JOIN vn.packaging ppallet ON ppallet.id = 'pallet 100'
JOIN vn.packagingConfig pconfig