refs #4823 Changes in offerRefresh
This commit is contained in:
parent
b3628cd2f1
commit
d2b4eb4925
|
@ -8,7 +8,6 @@ const warehouseConfig = {
|
|||
},
|
||||
entryFk: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
travellingDays: {
|
||||
type: Sequelize.INTEGER,
|
||||
|
@ -24,7 +23,7 @@ const warehouseConfig = {
|
|||
|
||||
export default (sequelize) => {
|
||||
return sequelize.define(
|
||||
'vnWarehouseConfig',
|
||||
'warehouseConfig',
|
||||
warehouseConfig,
|
||||
{
|
||||
timestamps: false,
|
||||
|
|
|
@ -55,15 +55,14 @@ BEGIN
|
|||
LEFT JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
AND t.shipped > (util.VN_CURDATE() - INTERVAL 1 WEEK)
|
||||
LEFT JOIN supplyLine sl ON sl.supplyLineId = i.supplyLineFk
|
||||
#LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk
|
||||
#AND po.OrderTradeLineDateTime > (util.VN_CURDATE() - INTERVAL 1 WEEK)
|
||||
AND sl.orderPeriodStartDateTime > (util.VN_CURDATE() - INTERVAL 1 WEEK)
|
||||
SET i.supplyLineFk = o.supplyLineId
|
||||
WHERE (sl.supplyLineId IS NULL
|
||||
OR sl.numberOfPieces = 0
|
||||
OR sl.orderPeriodEndDateTime < util.VN_NOW())
|
||||
AND it.isInventory
|
||||
AND t.id IS NULL;
|
||||
#AND po.id IS NULL;
|
||||
AND t.id IS NULL
|
||||
AND sl.supplyLineId IS NULL;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
|
@ -82,7 +81,7 @@ BEGIN
|
|||
typeFk,
|
||||
intrastatFk,
|
||||
originFk,
|
||||
supplyResponseFk,
|
||||
supplyLineFk,
|
||||
numberOfItemsPerCask,
|
||||
embalageCode,
|
||||
isFloriday) # NO le ponemos quality
|
||||
|
@ -145,45 +144,45 @@ BEGIN
|
|||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , ii.value1, 5
|
||||
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
|
||||
WHERE NOT ii.value1 IS NULL;
|
||||
|
||||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , ii.value2, 6
|
||||
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
|
||||
WHERE NOT ii.value2 IS NULL;
|
||||
|
||||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , ii.value3, 7
|
||||
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
|
||||
WHERE NOT ii.value3 IS NULL;
|
||||
|
||||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , ii.value4, 8
|
||||
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
|
||||
WHERE NOT ii.value4 IS NULL;
|
||||
|
||||
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
|
||||
JOIN vn.tag t ON t.ediTypeFk = ii.ef5
|
||||
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.tag t ON t.ediTypeFk = ii.tag5
|
||||
JOIN vn.item i ON i.supplyLineFk = ii.supplyLineId
|
||||
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)
|
||||
SELECT i.id, t.id, IFNULL(ink.name, ik.color), 11
|
||||
FROM itemToInsert ii
|
||||
|
@ -207,13 +206,11 @@ BEGIN
|
|||
|
||||
DROP TEMPORARY TABLE tmp.item;
|
||||
|
||||
SELECT MIN(LatestDeliveryDateTime) INTO vLanded
|
||||
SELECT MIN(sl.deliveryPeriodEndDateTime) INTO vLanded
|
||||
FROM supplyLine sl
|
||||
JOIN organization o ON o.organizationId = sl.organizationId
|
||||
JOIN edi.marketPlace mp ON mp.id = o.companyGln
|
||||
JOIN vn.floramondoConfig fc
|
||||
WHERE mp.isLatestOrderDateTimeRelevant
|
||||
AND di.LatestOrderDateTime > IF(
|
||||
WHERE sl.orderPeriodEndDateTime > IF(
|
||||
fc.MaxLatestOrderHour > HOUR(util.VN_NOW()),
|
||||
util.VN_CURDATE(),
|
||||
util.VN_CURDATE() + INTERVAL 1 DAY
|
||||
|
@ -278,18 +275,18 @@ BEGIN
|
|||
o.packageVbnPackageCode,
|
||||
NULL # o.diId No tenemos delivery information
|
||||
FROM offer o
|
||||
JOIN vn.item i ON i.supplyResponseFk = o.srId
|
||||
JOIN edi.warehouseFloramondo wf # warehouseFloriday?
|
||||
JOIN vn.item i ON i.supplyLineFk = o.supplyLineId
|
||||
JOIN warehouseConfig
|
||||
JOIN vn.packaging p ON p.id
|
||||
LIKE o.packageVbnPackageCode
|
||||
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
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.buyRecalc
|
||||
SELECT b.id
|
||||
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;
|
||||
|
||||
CALL vn.buy_recalcPrices();
|
||||
|
|
Loading…
Reference in New Issue