feat: refs #7363 changes
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
cb9cacc1ea
commit
9163d3db74
|
@ -41,7 +41,7 @@ BEGIN
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO tItemDiary
|
INSERT INTO tItemDiary
|
||||||
WITH entries AS (
|
WITH entriesIn AS (
|
||||||
SELECT tr.landed shipped,
|
SELECT tr.landed shipped,
|
||||||
b.quantity `in`,
|
b.quantity `in`,
|
||||||
NULL `out`,
|
NULL `out`,
|
||||||
|
@ -58,86 +58,84 @@ BEGIN
|
||||||
NULL clientType,
|
NULL clientType,
|
||||||
NULL claimFk,
|
NULL claimFk,
|
||||||
ec.inventorySupplierFk
|
ec.inventorySupplierFk
|
||||||
FROM buy b
|
FROM vn.buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN vn.entry e ON e.id = b.entryFk
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN vn.travel tr ON tr.id = e.travelFk
|
||||||
JOIN supplier s ON s.id = e.supplierFk
|
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||||
JOIN state st ON st.`code` = IF( tr.landed < util.VN_CURDATE()
|
JOIN vn.state st ON st.`code` = IF( tr.landed < util.VN_CURDATE()
|
||||||
OR (util.VN_CURDATE() AND tr.isReceived),
|
OR (util.VN_CURDATE() AND tr.isReceived),
|
||||||
'DELIVERED',
|
'DELIVERED',
|
||||||
'FREE')
|
'FREE')
|
||||||
JOIN entryConfig ec
|
JOIN vn.entryConfig ec
|
||||||
WHERE tr.landed >= vDateInventory
|
WHERE tr.landed >= vDateInventory
|
||||||
AND vWarehouseFk = tr.warehouseInFk
|
AND vWarehouseFk = tr.warehouseInFk
|
||||||
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
|
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
|
||||||
AND b.itemFk = vItemFk
|
AND b.itemFk = vItemFk
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT e.isRaid
|
||||||
),
|
), entriesOut AS (
|
||||||
deliveried AS (
|
SELECT tr.shipped,
|
||||||
SELECT tr.shipped,
|
NULL,
|
||||||
NULL,
|
b.quantity,
|
||||||
b.quantity,
|
st.alertLevel,
|
||||||
st.alertLevel,
|
st.name stateName,
|
||||||
st.name stateName,
|
s.name ,
|
||||||
s.name ,
|
e.invoiceNumber,
|
||||||
e.invoiceNumber,
|
e.id entryFk,
|
||||||
e.id entryFk,
|
s.id supplierFk,
|
||||||
s.id supplierFk,
|
IF(st.`code` = 'DELIVERED' , TRUE, FALSE),
|
||||||
IF(st.`code` = 'DELIVERED' , TRUE, FALSE),
|
FALSE isTicket,
|
||||||
FALSE isTicket,
|
b.id,
|
||||||
b.id,
|
NULL `order`,
|
||||||
NULL `order`,
|
NULL clientType,
|
||||||
NULL clientType,
|
NULL claimFk,
|
||||||
NULL claimFk,
|
ec.inventorySupplierFk
|
||||||
ec.inventorySupplierFk
|
FROM vn.buy b
|
||||||
FROM buy b
|
JOIN vn.entry e ON e.id = b.entryFk
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN vn.travel tr ON tr.id = e.travelFk
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN vn.warehouse w ON w.id = tr.warehouseOutFk
|
||||||
JOIN warehouse w ON w.id = tr.warehouseOutFk
|
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||||
JOIN supplier s ON s.id = e.supplierFk
|
JOIN vn.state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE()
|
||||||
JOIN state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE()
|
OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived),
|
||||||
OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived),
|
|
||||||
'DELIVERED',
|
'DELIVERED',
|
||||||
'FREE')
|
'FREE')
|
||||||
JOIN entryConfig ec
|
JOIN vn.entryConfig ec
|
||||||
WHERE tr.shipped >= vDateInventory
|
WHERE tr.shipped >= vDateInventory
|
||||||
AND vWarehouseFk = tr.warehouseOutFk
|
AND vWarehouseFk = tr.warehouseOutFk
|
||||||
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
|
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
|
||||||
AND b.itemFk = vItemFk
|
AND b.itemFk = vItemFk
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT w.isFeedStock
|
AND NOT w.isFeedStock
|
||||||
AND NOT e.isRaid
|
AND NOT e.isRaid
|
||||||
),
|
), sales AS (
|
||||||
sales AS (
|
SELECT DATE(t.shipped) shipped,
|
||||||
SELECT DATE(t.shipped) shipped,
|
s.quantity,
|
||||||
s.quantity,
|
st2.alertLevel,
|
||||||
st2.alertLevel,
|
st2.name,
|
||||||
st2.name,
|
t.nickname,
|
||||||
t.nickname,
|
t.refFk,
|
||||||
t.refFk,
|
t.id ticketFk,
|
||||||
t.id ticketFk,
|
t.clientFk,
|
||||||
t.clientFk,
|
s.id saleFk,
|
||||||
s.id saleFk,
|
st.`order`,
|
||||||
st.`order`,
|
c.typeFk,
|
||||||
c.typeFk,
|
cb.claimFk
|
||||||
cb.claimFk
|
FROM vn.sale s
|
||||||
FROM sale s
|
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
LEFT JOIN vn.state st ON st.`code` = ts.`code`
|
||||||
LEFT JOIN state st ON st.`code` = ts.`code`
|
JOIN vn.client c ON c.id = t.clientFk
|
||||||
JOIN client c ON c.id = t.clientFk
|
JOIN vn.state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
|
||||||
JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
|
'DELIVERED',
|
||||||
'DELIVERED',
|
IF (t.shipped > util.dayEnd(util.VN_CURDATE()),
|
||||||
IF (t.shipped > util.dayEnd(util.VN_CURDATE()),
|
'FREE',
|
||||||
'FREE',
|
IFNULL(ts.code, 'FREE')))
|
||||||
IFNULL(ts.code, 'FREE')))
|
LEFT JOIN vn.claimBeginning cb ON s.id = cb.saleFk
|
||||||
LEFT JOIN claimBeginning cb ON s.id = cb.saleFk
|
WHERE t.shipped >= vDateInventory
|
||||||
WHERE t.shipped >= vDateInventory
|
AND s.itemFk = vItemFk
|
||||||
AND s.itemFk = vItemFk
|
AND vWarehouseFk = t.warehouseFk
|
||||||
AND vWarehouseFk = t.warehouseFk
|
),sale AS (
|
||||||
),sale AS (
|
SELECT s.shipped,
|
||||||
SELECT s.shipped,
|
|
||||||
NULL `in`,
|
NULL `in`,
|
||||||
s.quantity,
|
s.quantity,
|
||||||
s.alertLevel,
|
s.alertLevel,
|
||||||
|
@ -153,40 +151,40 @@ BEGIN
|
||||||
s.typeFk,
|
s.typeFk,
|
||||||
s.claimFk,
|
s.claimFk,
|
||||||
NULL
|
NULL
|
||||||
FROM sales s
|
FROM vn.sales s
|
||||||
LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED'
|
LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED'
|
||||||
LEFT JOIN saleTracking stk ON stk.saleFk = s.saleFk
|
LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk
|
||||||
AND stk.stateFk = stPrep.id
|
AND stk.stateFk = stPrep.id
|
||||||
GROUP BY s.saleFk
|
GROUP BY s.saleFk
|
||||||
) SELECT shipped,
|
) SELECT shipped,
|
||||||
`in`,
|
`in`,
|
||||||
`out`,
|
`out`,
|
||||||
alertLevel,
|
alertLevel,
|
||||||
stateName,
|
stateName,
|
||||||
`name`,
|
`name`,
|
||||||
reference,
|
reference,
|
||||||
origin,
|
origin,
|
||||||
clientFk,
|
clientFk,
|
||||||
isPicked,
|
isPicked,
|
||||||
isTicket,
|
isTicket,
|
||||||
lineFk,
|
lineFk,
|
||||||
`order`,
|
`order`,
|
||||||
clientType,
|
clientType,
|
||||||
claimFk,
|
claimFk,
|
||||||
inventorySupplierFk
|
inventorySupplierFk
|
||||||
FROM entries
|
FROM entriesIn
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT * FROM deliveried
|
SELECT * FROM entriesOut
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT * FROM sale
|
SELECT * FROM sale
|
||||||
ORDER BY shipped,
|
ORDER BY shipped,
|
||||||
(inventorySupplierFk = clientFk) DESC,
|
(inventorySupplierFk = clientFk) DESC,
|
||||||
alertLevel DESC,
|
alertLevel DESC,
|
||||||
isTicket,
|
isTicket,
|
||||||
`order` DESC,
|
`order` DESC,
|
||||||
isPicked DESC,
|
isPicked DESC,
|
||||||
`in` DESC,
|
`in` DESC,
|
||||||
`out` DESC;
|
`out` DESC;
|
||||||
|
|
||||||
IF vDate IS NULL THEN
|
IF vDate IS NULL THEN
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue