Merge branch 'dev' into 7774-ticket_cloneWeekly
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Robert Ferrús 2024-07-24 05:27:34 +00:00
commit 49888cc3b9
4 changed files with 31 additions and 21 deletions

View File

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

View File

@ -20,9 +20,12 @@ proc:BEGIN
CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible
(PRIMARY KEY (item_id))
ENGINE = MEMORY
SELECT item_id, amount stock, amount visible
FROM cache.stock
WHERE warehouse_id = v_warehouse;
SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible
FROM stock s
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
CALL vn.item_calcVisible(NULL, v_warehouse);

View File

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

View File

@ -85,6 +85,7 @@ module.exports = Self => {
LEFT JOIN (
SELECT MAX(started), clientFk, finished
FROM recovery
GROUP BY clientFk
) r ON r.clientFk = c.id
LEFT JOIN workerDepartment wd ON wd.workerFk = u.id
JOIN department dp ON dp.id = wd.departmentFk