Merge branch 'test' into dev
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-07-24 07:11:56 +02:00
commit fdef84f78d
3 changed files with 30 additions and 21 deletions

View File

@ -53,7 +53,7 @@ module.exports = Self => {
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference, CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth, '0') serviceType, LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth, '0') serviceType,
IF(mw.weekdays, 'S', 'N') weekDays, IF(mw.weekdays, 'S', 'N') weekDays,
oa.description deliveryObservation ta.description deliveryObservation
FROM expedition e FROM expedition e
JOIN ticket t ON e.ticketFk = t.id JOIN ticket t ON e.ticketFk = t.id
JOIN agencyMode am ON am.id = t.agencyModeFk JOIN agencyMode am ON am.id = t.agencyModeFk
@ -62,8 +62,8 @@ module.exports = Self => {
AND mw.weekDays & (1 << WEEKDAY(t.landed)) AND mw.weekDays & (1 << WEEKDAY(t.landed))
JOIN client c ON t.clientFk = c.id JOIN client c ON t.clientFk = c.id
JOIN address a ON t.addressFk = a.id JOIN address a ON t.addressFk = a.id
LEFT JOIN addressObservation oa ON oa.addressFk = a.id LEFT JOIN ticketObservation ta ON ta.ticketFk = t.id
AND oa.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'delivery') AND ta.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'agency')
JOIN province p ON a.provinceFk = p.id JOIN province p ON a.provinceFk = p.id
JOIN country co ON co.id = p.countryFk JOIN country co ON co.id = p.countryFk
JOIN mrwConfig mc JOIN mrwConfig mc

View File

@ -20,9 +20,12 @@ proc:BEGIN
CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible
(PRIMARY KEY (item_id)) (PRIMARY KEY (item_id))
ENGINE = MEMORY ENGINE = MEMORY
SELECT item_id, amount stock, amount visible SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible
FROM cache.stock FROM stock s
WHERE warehouse_id = v_warehouse; JOIN vn.warehouse w ON w.id = s.warehouse_id
WHERE (v_warehouse IS NULL OR s.warehouse_id = v_warehouse)
AND w.isComparative
GROUP BY s.item_id;
-- Calculamos los movimientos confirmados de hoy -- Calculamos los movimientos confirmados de hoy
CALL vn.item_calcVisible(NULL, v_warehouse); CALL vn.item_calcVisible(NULL, v_warehouse);

View File

@ -21,6 +21,7 @@ BEGIN
FROM itemTicketOut i FROM itemTicketOut i
LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk
JOIN `state` s ON s.id = ts.stateFk JOIN `state` s ON s.id = ts.stateFk
JOIN warehouse w ON w.id = i.warehouseFk
LEFT JOIN ( LEFT JOIN (
SELECT DISTINCT st.saleFk SELECT DISTINCT st.saleFk
FROM saleTracking st FROM saleTracking st
@ -28,26 +29,31 @@ BEGIN
WHERE st.created > vDated WHERE st.created > vDated
AND (s.isPicked OR st.isChecked) AND (s.isPicked OR st.isChecked)
) stPrevious ON `stPrevious`.`saleFk` = i.saleFk ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk
WHERE IFNULL(vWarehouseFk, i.warehouseFk) = i.warehouseFk WHERE (vWarehouseFk IS NULL OR i.warehouseFk = vWarehouseFk)
AND (vSelf IS NULL OR i.itemFk = vSelf) AND (vSelf IS NULL OR i.itemFk = vSelf)
AND (s.isPicked OR i.reserved OR stPrevious.saleFk) AND (s.isPicked OR i.reserved OR stPrevious.saleFk)
AND i.shipped >= vDated AND i.shipped < vTomorrow AND i.shipped >= vDated AND i.shipped < vTomorrow
AND w.isComparative
UNION ALL UNION ALL
SELECT itemFk, quantity SELECT iei.itemFk, iei.quantity
FROM itemEntryIn FROM itemEntryIn iei
WHERE isReceived JOIN warehouse w ON w.id = iei.warehouseInFk
AND landed >= vDated AND landed < vTomorrow WHERE iei.isReceived
AND IFNULL(vWarehouseFk, warehouseInFk) = warehouseInFk AND iei.landed >= vDated AND iei.landed < vTomorrow
AND (vSelf IS NULL OR itemFk = vSelf) AND (vWarehouseFk IS NULL OR iei.warehouseInFk = vWarehouseFk)
AND NOT isVirtualStock AND (vSelf IS NULL OR iei.itemFk = vSelf)
AND NOT iei.isVirtualStock
AND w.isComparative
UNION ALL UNION ALL
SELECT itemFk, quantity SELECT ieo.itemFk, ieo.quantity
FROM itemEntryOut FROM itemEntryOut ieo
WHERE isDelivered JOIN warehouse w ON w.id = ieo.warehouseOutFk
AND shipped >= vDated WHERE ieo.isDelivered
AND shipped < vTomorrow AND ieo.shipped >= vDated
AND IFNULL(vWarehouseFk, warehouseOutFk) = warehouseOutFk AND ieo.shipped < vTomorrow
AND (vSelf IS NULL OR itemFk = vSelf) AND (vWarehouseFk IS NULL OR ieo.warehouseOutFk = vWarehouseFk)
AND (vSelf IS NULL OR ieo.itemFk = vSelf)
AND w.isComparative
) t ) t
GROUP BY itemFk GROUP BY itemFk
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE