Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
This commit is contained in:
commit
f2de7ddab4
|
@ -26,7 +26,9 @@ BEGIN
|
|||
zo.zoneFk
|
||||
FROM tmp.zoneOption zo
|
||||
JOIN zone z ON z.id = zo.zoneFk
|
||||
WHERE agencyModeFk = vAgencyModeFk;
|
||||
JOIN zoneWarehouse zw ON zw.zoneFk = z.id
|
||||
WHERE agencyModeFk = vAgencyModeFk
|
||||
AND warehouseFk = vWarehouseFk;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.zone,
|
||||
|
@ -35,3 +37,4 @@ BEGIN
|
|||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
|
|
|
@ -23,9 +23,12 @@ BEGIN
|
|||
SELECT * FROM (
|
||||
SELECT zo.zoneFk,
|
||||
TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped,
|
||||
zw.warehouseFk
|
||||
zw.warehouseFk,
|
||||
z.agencyModeFk
|
||||
FROM tmp.zoneOption zo
|
||||
JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
|
||||
JOIN zone z ON z.id = zo.zoneFk
|
||||
WHERE z.agencyModeFk = vAgencyModeFk
|
||||
ORDER BY shipped) t
|
||||
GROUP BY warehouseFk;
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
USE `vn`;
|
||||
DROP procedure IF EXISTS `zoneGetShipped`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* OBSOLETO usar zone_getShippedWarehouse
|
||||
* Devuelve la mínima fecha de envía para cada warehouse
|
||||
*
|
||||
* @param vLanded La fecha de recepcion
|
||||
* @param vAddressFk Id del consignatario
|
||||
* @param vAgencyModeFk Id de la agencia
|
||||
* @return tmp.zoneGetShipped
|
||||
*/
|
||||
CALL zone_getShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk);
|
||||
|
||||
SELECT * FROM tmp.zoneGetShipped WHERE warehouseFk <> vWarehouseFk;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
|
||||
USE `vn`;
|
||||
DROP procedure IF EXISTS `vn`.`zoneGetShipped__`;
|
||||
DROP procedure IF EXISTS `vn`.`zoneGetShipped`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetShipped__`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve la mínima fecha de envía para cada warehouse
|
||||
*
|
||||
* @param vLanded La fecha de recepcion
|
||||
* @param vAddressFk Id del consignatario
|
||||
* @param vAgencyModeFk Id de la agencia
|
||||
* @return tmp.zoneGetShipped
|
||||
*/
|
||||
|
||||
DECLARE vGeoFk INT;
|
||||
|
||||
SELECT p.geoFk INTO vGeoFk
|
||||
FROM address a
|
||||
JOIN town t ON t.provinceFk = a.provinceFk
|
||||
JOIN postCode p ON p.townFk = t.id AND p.code = a.postalCode
|
||||
WHERE a.id = vAddressFk
|
||||
ORDER BY (a.city SOUNDS LIKE t.`name`) DESC
|
||||
LIMIT 1;
|
||||
|
||||
SELECT * FROM (
|
||||
SELECT * FROM (
|
||||
SELECT z.id zoneFk,
|
||||
TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped,
|
||||
vLanded landed,
|
||||
vWarehouseFk warehouseFk,
|
||||
z.agencyModeFk,
|
||||
zi.isIncluded
|
||||
FROM zoneGeo zgSon
|
||||
JOIN zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt
|
||||
JOIN zoneIncluded zi ON zi.geoFk = zgFather.id
|
||||
JOIN zone z ON z.id = zi.zoneFk
|
||||
JOIN zoneCalendar zc ON zc.zoneFk = z.id
|
||||
WHERE zgSon.`id` = vGeoFk
|
||||
AND zc.delivered = vLanded
|
||||
AND z.agencyModeFk = vAgencyModeFk
|
||||
AND z.warehouseFk = vWarehouseFk
|
||||
AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE)
|
||||
ORDER BY z.id, zgFather.depth DESC, isIncluded DESC) t
|
||||
GROUP BY zoneFk
|
||||
HAVING isIncluded > 0
|
||||
ORDER BY shipped)
|
||||
t
|
||||
GROUP BY agencyModeFk;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
|
@ -17,32 +17,42 @@ BEGIN
|
|||
DECLARE vAddress INT;
|
||||
DECLARE vLanded DATE;
|
||||
DECLARE vAgency INT;
|
||||
DECLARE vZoneFk INT;
|
||||
|
||||
REPLACE INTO orderTicket(orderFk,ticketFk)
|
||||
SELECT orderFk, vTicketNew
|
||||
FROM orderTicket
|
||||
WHERE ticketFk = vTicketOld;
|
||||
|
||||
SELECT t.clientFk, t.warehouseFk, date(t.shipped), t.addressFk, t.agencyModeFk, t.landed, a.agencyFk
|
||||
INTO vClient, vWarehouse, vShipped, vAddress, vAgencyMode, vLanded, vAgency
|
||||
|
||||
SELECT t.clientFk, t.warehouseFk, date(t.shipped), t.addressFk, t.agencyModeFk, t.landed, a.agencyFk, t.zoneFk
|
||||
INTO vClient, vWarehouse, vShipped, vAddress, vAgencyMode, vLanded, vAgency, vZoneFk
|
||||
FROM vn.agencyMode a
|
||||
JOIN vn.ticket t ON t.agencyModeFk = a.id
|
||||
WHERE t.id = vTicketNew;
|
||||
|
||||
IF vLanded IS NULL THEN
|
||||
CALL zone_getLanded(vShipped, vAddress, vAgency, vWarehouse);
|
||||
UPDATE ticket t
|
||||
JOIN tmp.zoneGetLanded zgl ON t.warehouseFk = zgl.warehouseFk
|
||||
SET t.landed = zgl.landed,
|
||||
t.zone = zgl.zoneFk
|
||||
WHERE t.id = vTicketNew;
|
||||
|
||||
SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetLanded LIMIT 1;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded;
|
||||
END IF;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped;
|
||||
CALL zone_getShippedWarehouse(vLanded, vAddress, vAgencyMode);
|
||||
DELETE FROM tmp.zoneGetShipped WHERE warehouseFk <> vWarehouse;
|
||||
|
||||
CALL buyUltimate(vWarehouse, vShipped); -- rellena la tabla tmp.buyUltimate con la ultima compra
|
||||
-- rellena la tabla tmp.buyUltimate con la ultima compra
|
||||
CALL buyUltimate(vWarehouse, vShipped);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
|
||||
CREATE TEMPORARY TABLE tmp.ticketLot
|
||||
SELECT vWarehouse warehouseFk, NULL available, s.itemFk, bu.buyFk
|
||||
FROM sale s
|
||||
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
||||
WHERE s.ticketFk = vTicketOld GROUP BY s.itemFk;
|
||||
SELECT vWarehouse warehouseFk, NULL available, s.itemFk, bu.buyFk
|
||||
FROM sale s
|
||||
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
||||
WHERE s.ticketFk = vTicketOld GROUP BY s.itemFk;
|
||||
|
||||
CALL catalog_componentCalculate(vAddress,vAgencyMode);
|
||||
CALL catalog_componentCalculate(vZoneFk, vAddress, vAgencyMode);
|
||||
|
||||
-- Bionizamos lineas con Preu = 0
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
|
||||
|
@ -64,14 +74,6 @@ BEGIN
|
|||
AND s.price > 0;
|
||||
|
||||
CALL ticketComponentUpdateSale(6);
|
||||
|
||||
IF vLanded IS NULL THEN
|
||||
CALL zone_getLanded(vShipped, vAddress, vAgency,vWarehouse);
|
||||
UPDATE ticket t
|
||||
JOIN tmp.zoneGetLanded zgl ON t.warehouseFk = zgl.warehouseFk
|
||||
SET t.landed = zgl.landed
|
||||
WHERE t.id = vTicketNew;
|
||||
END IF;
|
||||
|
||||
-- Log
|
||||
CALL `logAdd`(vTicketNew, 'update', ' ticket' , 'Bioniza Ticket');
|
||||
|
@ -83,4 +85,4 @@ BEGIN
|
|||
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<vn-crud-model
|
||||
url="Zones"
|
||||
include="{relation: 'warehouse'}"
|
||||
data="zones"
|
||||
order="name"
|
||||
auto-load="true">
|
||||
|
@ -86,7 +85,7 @@
|
|||
ng-model="$ctrl.zoneId"
|
||||
vn-acl="productionBoss">
|
||||
<tpl-item>
|
||||
<span>{{::name}} - {{::warehouse.name}} - Max. {{::hour | date: 'HH:mm'}} h.</span>
|
||||
<span>{{::name}} - Max. {{::hour | date: 'HH:mm'}} h.</span>
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
|
|
Loading…
Reference in New Issue