diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql index 1d411cfd0..76618ce50 100644 --- a/db/routines/sage/procedures/invoiceIn_add.sql +++ b/db/routines/sage/procedures/invoiceIn_add.sql @@ -25,7 +25,7 @@ BEGIN DECLARE vIsInformativeExportation BOOL DEFAULT FALSE; DECLARE vCursor CURSOR FOR - SELECT it.taxableBase, + SELECT SUM(it.taxableBase), CAST(SUM((( it.taxableBase / 100) * t.PorcentajeIva)) AS DECIMAL (10,2)), t.PorcentajeIva, it.transactionTypeSageFk, @@ -204,17 +204,17 @@ BEGIN FROM vn.invoiceInCorrection WHERE correctingFk = vInvoiceInFk; - IF vInvoiceInOriginalFk THEN + IF vInvoiceInOriginalFk THEN UPDATE movContaIVA mci JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk JOIN (SELECT issued, - SUM(sub.taxableBase) taxableBase, + SUM(sub.taxableBase) taxableBase, SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat FROM(SELECT issued, - SUM(iit.taxableBase) taxableBase, + SUM(iit.taxableBase) taxableBase, ti.PorcentajeIva - FROM vn.invoiceIn i + FROM vn.invoiceIn i JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk WHERE i.id = vInvoiceInOriginalFk @@ -222,7 +222,7 @@ BEGIN )invoiceInOriginal JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' SET mci.TipoRectificativa = iir.refundCategoryFk, - mci.ClaseAbonoRectificativas = iir.refundType, + mci.ClaseAbonoRectificativas = iir.refundType, mci.FechaFacturaOriginal = invoiceInOriginal.issued, mci.FechaOperacion = invoiceInOriginal.issued, mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase, @@ -232,4 +232,4 @@ BEGIN END IF; END$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; diff --git a/db/routines/vn/procedures/claimRatio_add.sql b/db/routines/vn/procedures/claimRatio_add.sql index 8c3213644..5e2e66a8e 100644 --- a/db/routines/vn/procedures/claimRatio_add.sql +++ b/db/routines/vn/procedures/claimRatio_add.sql @@ -46,7 +46,7 @@ BEGIN JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk - WHERE cd.description NOT IN ('Bueno', 'Corregido') + WHERE cd.code NOT IN ('good', 'corrected', 'supplierClaim') AND NOT ce.isGreuge AND cs.code = 'resolved'; @@ -71,7 +71,7 @@ BEGIN JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk - WHERE cd.description NOT IN ('Bueno', 'Corregido') + WHERE cd.code NOT IN ('good', 'corrected', 'supplierClaim') AND NOT ce.isGreuge AND cs.code = 'resolved' AND c.isChargedToMana; @@ -82,7 +82,7 @@ BEGIN JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk SET ce.isGreuge = TRUE - WHERE cd.description NOT IN ('Bueno', 'Corregido') + WHERE cd.code NOT IN ('good', 'corrected', 'supplierClaim') AND NOT ce.isGreuge AND cs.code = 'resolved'; @@ -161,7 +161,7 @@ BEGIN JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk - WHERE cd.description NOT IN ('Bueno', 'Corregido') + WHERE cd.code NOT IN ('good', 'corrected', 'supplierClaim') AND cs.code = 'resolved' AND c.ticketCreated >= util.VN_CURDATE() - INTERVAL 1 YEAR GROUP BY c.clientFk diff --git a/db/routines/vn/procedures/travel_checkRaid.sql b/db/routines/vn/procedures/travel_checkRaid.sql index 64f3355e2..885fc718a 100644 --- a/db/routines/vn/procedures/travel_checkRaid.sql +++ b/db/routines/vn/procedures/travel_checkRaid.sql @@ -10,8 +10,8 @@ BEGIN * @param vIsRaid idRaid value * @param vDaysInForward daysInForward value */ - IF (NOT vIsRaid AND vDaysInForward IS NOT NULL) OR (vIsRaid AND vDaysInForward IS NULL) THEN - CALL util.throw('The raid information is not correct'); + IF NOT vIsRaid AND vDaysInForward THEN + CALL util.throw('If daysInForward has a value, the raid cannot be unchecked'); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/travel_moveRaids.sql b/db/routines/vn/procedures/travel_moveRaids.sql index cf0fce23c..17d7ecc4c 100644 --- a/db/routines/vn/procedures/travel_moveRaids.sql +++ b/db/routines/vn/procedures/travel_moveRaids.sql @@ -8,22 +8,15 @@ BEGIN DECLARE vDone BOOL DEFAULT FALSE; DECLARE vBuyerEmail VARCHAR(40); DECLARE vTravelLink TEXT; - DECLARE vMailBody TEXT DEFAULT ''; + DECLARE vMailBody TEXT; + DECLARE vDaysBetweenDates INT; + DECLARE vSubject VARCHAR(30); - DECLARE vCur CURSOR FOR - SELECT GROUP_CONCAT(DISTINCT - CONCAT('https://salix.verdnatura.es/#!/travel/', - ttm.travelFk, - '/summary ') - ORDER BY ttm.travelFk SEPARATOR '\n\r') travelLink, - CONCAT(u.name, '@verdnatura.es') buyerEmail - FROM tTravelToMove ttm - JOIN entry e ON e.travelFk = ttm.travelFk - JOIN buy b ON b.entryFk = e.id - JOIN item i ON i.id = b.itemFk - JOIN itemType it ON it.id = i.typeFk - JOIN account.user u ON u.id = it.workerFk - GROUP BY u.name; + DECLARE vTravels CURSOR FOR + SELECT GROUP_CONCAT(DISTINCT travelLink ORDER BY id SEPARATOR '\n\r'), + buyerEmail + FROM tTravelToMove + GROUP BY buyerEmail; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -34,35 +27,50 @@ BEGIN END; CREATE OR REPLACE TEMPORARY TABLE tTravelToMove - SELECT id travelFk, - util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded - FROM travel + WITH travels AS ( + SELECT id, + CONCAT('https://salix.verdnatura.es/#!/travel/', id,'/summary') travelLink, + util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded, + util.VN_CURDATE() - INTERVAL DATEDIFF(landed, shipped) + daysInForward DAY newShipped + FROM vn.travel WHERE isRaid - AND daysInForward; + AND daysInForward + )SELECT t.id, + t.travelLink, + t.newLanded, + t.newShipped, + CONCAT(u.name, '@verdnatura.es') buyerEmail + FROM travels t + STRAIGHT_JOIN vn.entry e ON e.travelFk = t.id + JOIN vn.buy b ON b.entryFk = e.id + JOIN vn.item i ON i.id = b.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN account.user u ON u.id = it.workerFk + GROUP BY t.id; START TRANSACTION; UPDATE travel tr - JOIN tTravelToMove ttm ON ttm.travelFk = tr.id - SET tr.landed = ttm.newLanded; + JOIN tTravelToMove ttm ON ttm.id = tr.id + SET tr.landed = ttm.newLanded, + tr.shipped = ttm.newShipped; - OPEN vCur; + OPEN vTravels; l: LOOP SET vDone = FALSE; - FETCH vCur INTO vTravelLink, vBuyerEmail; + FETCH vTravels INTO vTravelLink, vBuyerEmail; IF vDone THEN LEAVE l; END IF; - CALL `vn`.`mail_insert`( - vBuyerEmail, - 'noreply@verdnatura.es', - 'Cambio de fecha en Redadas', - CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink)); + SET vSubject = 'Cambio de fecha en Redadas', + vMailBody = CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink); + + CALL mail_insert(vBuyerEmail, 'noreply@verdnatura.es', vSubject, vMailBody); END LOOP; - CLOSE vCur; + CLOSE vTravels; COMMIT; DROP TEMPORARY TABLE tTravelToMove; END$$ diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql index 256dd35f8..5a27b43b4 100644 --- a/db/routines/vn/triggers/travel_beforeUpdate.sql +++ b/db/routines/vn/triggers/travel_beforeUpdate.sql @@ -20,6 +20,10 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); END IF; + IF NOT (NEW.isRaid <=> OLD.isRaid) OR NOT (NEW.daysInForward <=> OLD.daysInForward) THEN + CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward); + END IF; + IF NOT (NEW.awbFk <=> OLD.awbFk)THEN SELECT COUNT(*) INTO vHasAnyInvoiceBooked FROM travel t diff --git a/modules/ticket/back/methods/sale/updateQuantity.js b/modules/ticket/back/methods/sale/updateQuantity.js index 36d75ffed..4de1bcbd6 100644 --- a/modules/ticket/back/methods/sale/updateQuantity.js +++ b/modules/ticket/back/methods/sale/updateQuantity.js @@ -82,7 +82,7 @@ module.exports = Self => { const message = $t('Changed sale quantity', { ticketId: sale.ticket().id, - changes: change, + changes: JSON.stringify(change), ticketUrl: `${url}ticket/${sale.ticket().id}/sale`, }); diff --git a/modules/ticket/back/methods/ticket-request/filter.js b/modules/ticket/back/methods/ticket-request/filter.js index 53f90b98f..c2edcae81 100644 --- a/modules/ticket/back/methods/ticket-request/filter.js +++ b/modules/ticket/back/methods/ticket-request/filter.js @@ -64,6 +64,11 @@ module.exports = Self => { arg: 'myTeam', type: 'boolean', description: `Team partners` + }, + { + arg: 'daysOnward', + type: 'number', + description: 'The days onward' } ], returns: { @@ -104,6 +109,9 @@ module.exports = Self => { teamMembersId.push(userId); } + const today = Date.vnNew(); + const future = Date.vnNew(); + let where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': @@ -140,9 +148,13 @@ module.exports = Self => { return {'tr.requesterFk': {inq: teamMembersId}}; else return {'tr.requesterFk': {nin: teamMembersId}}; + case 'daysOnward': + today.setHours(0, 0, 0, 0); + future.setDate(today.getDate() + value); + future.setHours(23, 59, 59, 999); + return {'t.shipped': {between: [today, future]}}; } }); - if (!where) where = {}; where['tw.ticketFk'] = null; diff --git a/modules/worker/back/models/worker-irpf.json b/modules/worker/back/models/worker-irpf.json index 65f72a1fd..eafda0596 100644 --- a/modules/worker/back/models/worker-irpf.json +++ b/modules/worker/back/models/worker-irpf.json @@ -23,7 +23,7 @@ "type" : "number" }, "isDependend": { - "type" : "number" + "type" : "boolean" }, "familySituation": { "type" : "number" @@ -35,15 +35,17 @@ "type" : "number" }, "hasHousingPaymentBefore": { - "type" : "number" + "type" : "boolean" }, "hasHousingPaymentAfter": { - "type" : "number" + "type" : "boolean" }, "updated": { "type" : "date" + }, + "hasExtendedWorking": { + "type" : "boolean" } - }, "relations": { "disabilityGrade": {