diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql index af5d0e2de..56e68c3b0 100644 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -12,13 +12,15 @@ proc: BEGIN * @param vDateTo Fecha hasta * @param vCampaign Código de la campaña */ - DECLARE vYesterday INT; + DECLARE vCurdate DATE; + DECLARE vYesterday DATE; DECLARE vDefaultCampaign VARCHAR(100); DECLARE vPreviousDaysToInsert INT; DECLARE vDateSumFrom DATE; DECLARE vDateSumTo DATE; DECLARE vScopeDays DATE; + SET vCurdate = util.VN_CURDATE(); SET vYesterday = util.yesterday(); IF vDateFrom IS NULL THEN @@ -47,7 +49,7 @@ proc: BEGIN SELECT dated, scopeDays INTO vDateSumTo, vScopeDays FROM campaign - WHERE dated > util.VN_CURDATE() + WHERE dated > vCurdate AND code = vCampaign ORDER BY dated LIMIT 1; @@ -56,7 +58,7 @@ proc: BEGIN CALL util.throw('Missing data in campaign table'); END IF; - IF NOT util.VN_CURDATE() BETWEEN vDateSumTo - INTERVAL vPreviousDaysToInsert DAY + IF NOT vCurdate BETWEEN vDateSumTo - INTERVAL vPreviousDaysToInsert DAY AND vDateSumTo THEN LEAVE proc; END IF;