refs #4823 Now offerRefresh works

This commit is contained in:
Guillermo Bonet 2023-07-05 14:05:44 +02:00
parent d2b4eb4925
commit dc4a50e9f3
2 changed files with 21 additions and 13 deletions

View File

@ -4,6 +4,11 @@ BEGIN
DECLARE vLanded DATETIME;
DECLARE vLastInserted DATETIME;
DECLARE vDayRange INT;
DECLARE EXIT HANDLER FOR SQLSTATE '45000'
BEGIN
ROLLBACK;
RESIGNAL;
END;
SELECT dayRange INTO vDayRange
FROM edi.offerRefreshConfig;
@ -183,6 +188,10 @@ BEGIN
JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId
WHERE NOT ii.value6 IS NULL;
UPDATE vn.config
SET ochoa=5
WHERE id=1;
INSERT IGNORE INTO vn.itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id, IFNULL(ink.name, ik.color), 11
FROM itemToInsert ii
@ -229,9 +238,9 @@ BEGIN
JOIN vn.item i ON i.id = b.itemFk
LEFT JOIN supplyLine sl ON i.supplyLineFk = sl.supplyLineId
SET b.quantity = 0
WHERE (IFNULL(di.LatestOrderDateTime, util.VN_NOW()) <= util.VN_NOW()
WHERE (IFNULL(sl.orderPeriodEndDateTime, util.VN_NOW()) <= util.VN_NOW()
OR i.supplyLineFk IS NULL
OR sl.numberOfPieces = 0)
OR NOT sl.numberOfPieces)
AND am.name = 'LOGIFLORA' # Crear agencia floriday
AND e.isRaid;
@ -242,7 +251,7 @@ BEGIN
IF vLanded IS NOT NULL THEN
# Actualiza la oferta existente
UPDATE vn.buy b
JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk # warehouseFloriday?
JOIN warehouseConfig wc ON wc.entryFk = b.entryFk # warehouseFloriday?
JOIN vn.item i ON i.id = b.itemFk
JOIN offer o ON i.supplyLineFk = o.supplyLineId
SET b.quantity = o.numberOfPieces * o.piecesPerPackage,
@ -262,21 +271,19 @@ BEGIN
packing,
`grouping`,
groupingMode,
packageFk,
deliveryFk)
SELECT wf.entryFk,
packageFk)
SELECT wc.entryFk,
i.id,
o.numberOfPieces * o.piecesPerPackage,
o.Price,
o.numberOfPieces,
o.pricePerPiece,
o.piecesPerPackage, # MinimumQuantity NO está: GREATEST(1, IFNULL(o.MinimumQuantity, 0)) * o.piecesPerPackage,
o.piecesPerPackage,
o.packagesPerLayer,
o.layersPerLoadCarrier,
2, # Obliga al Packing
o.packageVbnPackageCode,
NULL # o.diId No tenemos delivery information
o.packageVbnPackageCode
FROM offer o
JOIN vn.item i ON i.supplyLineFk = o.supplyLineId
JOIN warehouseConfig
JOIN warehouseConfig wc
JOIN vn.packaging p ON p.id
LIKE o.packageVbnPackageCode
LEFT JOIN vn.buy b ON b.itemFk = i.id

View File

@ -172,4 +172,5 @@ AS SELECT sl.supplyLineId,
AND NOT ti.isDeleted
AND NOW() BETWEEN sl.orderPeriodStartDateTime AND sl.orderPeriodEndDateTime
AND sl.numberOfPieces > 0
GROUP BY sl.supplyLineId
GROUP BY ti.tradeItemId
ORDER BY sl.lastSync DESC