From b6abcbe0907eb78e28feab73800ac5abebb064e0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 10:14:20 +0200 Subject: [PATCH] feat: refs #6453 Requested changes --- .../procedures/order_confirmWithUser.sql | 65 +++---------------- 1 file changed, 8 insertions(+), 57 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 4fcee91f7..17798caf8 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -11,11 +11,11 @@ BEGIN * @param vSelf The order identifier * @param vUser The user identifier */ - DECLARE vIsOk BOOL; + DECLARE vHasRows BOOL; DECLARE vDone BOOL; DECLARE vWarehouseFk INT; DECLARE vShipment DATE; - DECLARE vShipmentDayEnd DATE; + DECLARE vShipmentDayEnd DATETIME; DECLARE vTicketFk INT; DECLARE vNotes VARCHAR(255); DECLARE vItemFk INT; @@ -32,7 +32,6 @@ BEGIN DECLARE vCompanyFk INT; DECLARE vAgencyModeFk INT; DECLARE vCalcFk INT; - DECLARE vIsLogifloraItem BOOL; DECLARE vIsTaxDataChecked BOOL; DECLARE vDates CURSOR FOR @@ -49,8 +48,7 @@ BEGIN r.itemFk, i.name, r.amount, - r.price, - i.isFloramondo + r.price FROM orderRow r JOIN vn.item i ON i.id = r.itemFk WHERE r.amount @@ -104,12 +102,12 @@ BEGIN CALL order_checkEditable(vSelf); -- Check order is not empty - SELECT COUNT(*) > 0 INTO vIsOk + SELECT COUNT(*) > 0 INTO vHasRows FROM orderRow WHERE orderFk = vSelf AND amount > 0; - IF NOT vIsOk THEN + IF NOT vHasRows THEN CALL util.throw('ORDER_EMPTY'); END IF; @@ -209,8 +207,8 @@ BEGIN -- AƱade las notas IF vNotes IS NOT NULL AND vNotes <> '' THEN - INSERT INTO vn.ticketObservation SET - ticketFk = vTicketFk, + INSERT INTO vn.ticketObservation + SET ticketFk = vTicketFk, observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), `description` = vNotes ON DUPLICATE KEY UPDATE @@ -222,12 +220,7 @@ BEGIN lRows: LOOP SET vSaleFk = NULL; SET vDone = FALSE; - FETCH vRows INTO vRowFk, - vItemFk, - vConcept, - vAmount, - vPrice, - vIsLogifloraItem; + FETCH vRows INTO vRowFk, vItemFk, vConcept, vAmount, vPrice; IF vDone THEN LEAVE lRows; @@ -277,48 +270,6 @@ BEGIN UPDATE orderRow SET saleFk = vSaleFk WHERE id = vRowFk; - - -- Inserta en putOrder si la compra es de Floramondo - IF vIsLogifloraItem THEN - CALL cache.availableNoRaids_refresh(vCalcFk, FALSE,vWarehouseFk, vShipment); - - SELECT GREATEST(0, available) INTO vAvailable - FROM cache.availableNoRaids - WHERE calc_id = vCalcFk - AND item_id = vItemFk; - - UPDATE cache.availableNoRaids - SET available = GREATEST(0, available - vAmount) - WHERE item_id = vItemFk - AND calc_id = vCalcFk; - - INSERT INTO edi.putOrder ( - deliveryInformationID, - supplyResponseId, - quantity , - EndUserPartyId, - EndUserPartyGLN, - FHAdminNumber, - saleFk - ) - SELECT di.ID, - i.supplyResponseFk, - CEIL((vAmount - vAvailable)/ sr.NumberOfItemsPerCask), - o.address_id , - vClientFk, - IFNULL(ca.fhAdminNumber, fhc.defaultAdminNumber), - vSaleFk - FROM edi.deliveryInformation di - JOIN vn.item i ON i.supplyResponseFk = di.supplyResponseID - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientFk - JOIN edi.floraHollandConfig fhc - JOIN `order` o ON o.id = vSelf - WHERE i.id = vItemFk - AND di.LatestOrderDateTime > util.VN_NOW() - AND vAmount > vAvailable - LIMIT 1; - END IF; END LOOP; CLOSE vRows; END LOOP;