refs #4823 Changes in offerRefresh

This commit is contained in:
Guillermo Bonet 2023-07-04 15:03:08 +02:00
parent b3628cd2f1
commit d2b4eb4925
2 changed files with 28 additions and 32 deletions

View File

@ -8,7 +8,6 @@ const warehouseConfig = {
}, },
entryFk: { entryFk: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
allowNull: false,
}, },
travellingDays: { travellingDays: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
@ -24,7 +23,7 @@ const warehouseConfig = {
export default (sequelize) => { export default (sequelize) => {
return sequelize.define( return sequelize.define(
'vnWarehouseConfig', 'warehouseConfig',
warehouseConfig, warehouseConfig,
{ {
timestamps: false, timestamps: false,

View File

@ -55,15 +55,14 @@ BEGIN
LEFT JOIN vn.ticket t ON t.id = s.ticketFk LEFT JOIN vn.ticket t ON t.id = s.ticketFk
AND t.shipped > (util.VN_CURDATE() - INTERVAL 1 WEEK) AND t.shipped > (util.VN_CURDATE() - INTERVAL 1 WEEK)
LEFT JOIN supplyLine sl ON sl.supplyLineId = i.supplyLineFk LEFT JOIN supplyLine sl ON sl.supplyLineId = i.supplyLineFk
#LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk AND sl.orderPeriodStartDateTime > (util.VN_CURDATE() - INTERVAL 1 WEEK)
#AND po.OrderTradeLineDateTime > (util.VN_CURDATE() - INTERVAL 1 WEEK)
SET i.supplyLineFk = o.supplyLineId SET i.supplyLineFk = o.supplyLineId
WHERE (sl.supplyLineId IS NULL WHERE (sl.supplyLineId IS NULL
OR sl.numberOfPieces = 0 OR sl.numberOfPieces = 0
OR sl.orderPeriodEndDateTime < util.VN_NOW()) OR sl.orderPeriodEndDateTime < util.VN_NOW())
AND it.isInventory AND it.isInventory
AND t.id IS NULL; AND t.id IS NULL
#AND po.id IS NULL; AND sl.supplyLineId IS NULL;
START TRANSACTION; START TRANSACTION;
@ -82,7 +81,7 @@ BEGIN
typeFk, typeFk,
intrastatFk, intrastatFk,
originFk, originFk,
supplyResponseFk, supplyLineFk,
numberOfItemsPerCask, numberOfItemsPerCask,
embalageCode, embalageCode,
isFloriday) # NO le ponemos quality isFloriday) # NO le ponemos quality
@ -145,45 +144,45 @@ BEGIN
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id , ii.value1, 5 SELECT i.id, t.id , ii.value1, 5
FROM itemToInsert ii FROM itemToInsert ii
JOIN vn.tag t ON t.ediTypeFk = ii.ef1 JOIN vn.tag t ON t.ediTypeFk = ii.tag1
JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId
WHERE NOT ii.value1 IS NULL; WHERE NOT ii.value1 IS NULL;
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id , ii.value2, 6 SELECT i.id, t.id , ii.value2, 6
FROM itemToInsert ii FROM itemToInsert ii
JOIN vn.tag t ON t.ediTypeFk = ii.ef2 JOIN vn.tag t ON t.ediTypeFk = ii.tag2
JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId
WHERE NOT ii.value2 IS NULL; WHERE NOT ii.value2 IS NULL;
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id , ii.value3, 7 SELECT i.id, t.id , ii.value3, 7
FROM itemToInsert ii FROM itemToInsert ii
JOIN vn.tag t ON t.ediTypeFk = ii.ef3 JOIN vn.tag t ON t.ediTypeFk = ii.tag3
JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId
WHERE NOT ii.value3 IS NULL; WHERE NOT ii.value3 IS NULL;
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id , ii.value4, 8 SELECT i.id, t.id , ii.value4, 8
FROM itemToInsert ii FROM itemToInsert ii
JOIN vn.tag t ON t.ediTypeFk = ii.ef4 JOIN vn.tag t ON t.ediTypeFk = ii.tag4
JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId
WHERE NOT ii.value4 IS NULL; WHERE NOT ii.value4 IS NULL;
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id , s5Value, 9 SELECT i.id, t.id , ii.value5, 9
FROM itemToInsert ii FROM itemToInsert ii
JOIN vn.tag t ON t.ediTypeFk = ii.ef5 JOIN vn.tag t ON t.ediTypeFk = ii.tag5
JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId
WHERE NOT s5Value IS NULL;
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id , ii.value5, 10
FROM itemToInsert ii
JOIN vn.tag t ON t.ediTypeFk = ii.ef6
JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId
WHERE NOT ii.value5 IS NULL; WHERE NOT ii.value5 IS NULL;
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id , ii.value6, 10
FROM itemToInsert ii
JOIN vn.tag t ON t.ediTypeFk = ii.tag6
JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId
WHERE NOT ii.value6 IS NULL;
INSERT IGNORE INTO vn.itemTag(itemFk, tagFk, value, priority) INSERT IGNORE INTO vn.itemTag(itemFk, tagFk, value, priority)
SELECT i.id, t.id, IFNULL(ink.name, ik.color), 11 SELECT i.id, t.id, IFNULL(ink.name, ik.color), 11
FROM itemToInsert ii FROM itemToInsert ii
@ -207,13 +206,11 @@ BEGIN
DROP TEMPORARY TABLE tmp.item; DROP TEMPORARY TABLE tmp.item;
SELECT MIN(LatestDeliveryDateTime) INTO vLanded SELECT MIN(sl.deliveryPeriodEndDateTime) INTO vLanded
FROM supplyLine sl FROM supplyLine sl
JOIN organization o ON o.organizationId = sl.organizationId JOIN organization o ON o.organizationId = sl.organizationId
JOIN edi.marketPlace mp ON mp.id = o.companyGln
JOIN vn.floramondoConfig fc JOIN vn.floramondoConfig fc
WHERE mp.isLatestOrderDateTimeRelevant WHERE sl.orderPeriodEndDateTime > IF(
AND di.LatestOrderDateTime > IF(
fc.MaxLatestOrderHour > HOUR(util.VN_NOW()), fc.MaxLatestOrderHour > HOUR(util.VN_NOW()),
util.VN_CURDATE(), util.VN_CURDATE(),
util.VN_CURDATE() + INTERVAL 1 DAY util.VN_CURDATE() + INTERVAL 1 DAY
@ -278,18 +275,18 @@ BEGIN
o.packageVbnPackageCode, o.packageVbnPackageCode,
NULL # o.diId No tenemos delivery information NULL # o.diId No tenemos delivery information
FROM offer o FROM offer o
JOIN vn.item i ON i.supplyResponseFk = o.srId JOIN vn.item i ON i.supplyLineFk = o.supplyLineId
JOIN edi.warehouseFloramondo wf # warehouseFloriday? JOIN warehouseConfig
JOIN vn.packaging p ON p.id JOIN vn.packaging p ON p.id
LIKE o.packageVbnPackageCode LIKE o.packageVbnPackageCode
LEFT JOIN vn.buy b ON b.itemFk = i.id LEFT JOIN vn.buy b ON b.itemFk = i.id
AND b.entryFk = wf.entryFk AND b.entryFk = wc.entryFk
WHERE b.id IS NULL; # Quitar esta linea y mirar de crear los packages a tiempo REAL WHERE b.id IS NULL; # Quitar esta linea y mirar de crear los packages a tiempo REAL
CREATE OR REPLACE TEMPORARY TABLE tmp.buyRecalc CREATE OR REPLACE TEMPORARY TABLE tmp.buyRecalc
SELECT b.id SELECT b.id
FROM vn.buy b FROM vn.buy b
JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk # warehouseFloriday? JOIN warehouseConfig wc ON wc.entryFk = b.entryFk
WHERE b.created >= vLastInserted; WHERE b.created >= vLastInserted;
CALL vn.buy_recalcPrices(); CALL vn.buy_recalcPrices();