8032-devToTest_2440 #3009
|
@ -30,6 +30,8 @@ BEGIN
|
|||
FROM operator
|
||||
WHERE workerFk = account.myUser_getId();
|
||||
|
||||
CALL util.debugAdd('itemShelvingSale_addBySectorCollection',CONCAT(vSectorCollectionFk,' - ', account.myUser_getId()));
|
||||
|
||||
OPEN vSales;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
|
|
|
@ -51,7 +51,6 @@ BEGIN
|
|||
hasTicketRequest,
|
||||
isTaxDataChecked,
|
||||
hasComponentLack,
|
||||
hasRounding,
|
||||
isTooLittle)
|
||||
SELECT sgp.ticketFk,
|
||||
s.id,
|
||||
|
@ -62,10 +61,6 @@ BEGIN
|
|||
IF(FIND_IN_SET('hasTicketRequest', t.problem), TRUE, FALSE) hasTicketRequest,
|
||||
IF(FIND_IN_SET('isTaxDataChecked', t.problem), FALSE, TRUE) isTaxDataChecked,
|
||||
IF(FIND_IN_SET('hasComponentLack', s.problem), TRUE, FALSE) hasComponentLack,
|
||||
IF(FIND_IN_SET('hasRounding', s.problem),
|
||||
LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250),
|
||||
NULL
|
||||
) hasRounding,
|
||||
IF(FIND_IN_SET('isTooLittle', t.problem)
|
||||
AND util.VN_NOW() < (util.VN_CURDATE() + INTERVAL HOUR(zc.`hour`) HOUR) + INTERVAL MINUTE(zc.`hour`) MINUTE,
|
||||
TRUE, FALSE) isTooLittle
|
||||
|
@ -208,24 +203,31 @@ BEGIN
|
|||
GROUP BY sgp.ticketFk
|
||||
) sub
|
||||
ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk;
|
||||
END LOOP;
|
||||
CLOSE vCursor;
|
||||
|
||||
-- Redondeo: cantidad incorrecta con respecto al grouping
|
||||
CALL buy_getUltimate(NULL, vWarehouseFk, vDate);
|
||||
INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk)
|
||||
SELECT ticketFk, problem, saleFk
|
||||
FROM (
|
||||
SELECT sgp.ticketFk,
|
||||
s.id saleFk,
|
||||
LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem
|
||||
LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem
|
||||
FROM tmp.sale_getProblems sgp
|
||||
JOIN ticket t ON t.id = sgp.ticketFk
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
JOIN sale s ON s.ticketFk = sgp.ticketFk
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
WHERE FIND_IN_SET('hasRounding', s.problem)
|
||||
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
||||
JOIN buy b ON b.id = bu.buyFk
|
||||
WHERE MOD(s.quantity, b.`grouping`)
|
||||
GROUP BY sgp.ticketFk
|
||||
) sub
|
||||
)sub
|
||||
ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||
END LOOP;
|
||||
CLOSE vCursor;
|
||||
|
||||
DROP TEMPORARY TABLE tItemShelvingStock_byWarehouse;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_setProblemRounding`(
|
||||
vSelf INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Update the rounding problem for a sales line
|
||||
* @param vSelf Id sale
|
||||
*/
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vShipped DATE;
|
||||
DECLARE vQuantity INT;
|
||||
DECLARE vIsProblemCalcNeeded BOOL;
|
||||
|
||||
SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity, ticket_isProblemCalcNeeded(t.id)
|
||||
INTO vItemFk, vWarehouseFk, vShipped, vQuantity, vIsProblemCalcNeeded
|
||||
FROM sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
WHERE s.id = vSelf;
|
||||
|
||||
CALL buy_getUltimate(vItemFk, vWarehouseFk, vShipped);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
SELECT vSelf saleFk,
|
||||
MOD(vQuantity, b.`grouping`) hasProblem,
|
||||
vIsProblemCalcNeeded isProblemCalcNeeded
|
||||
FROM tmp.buyUltimate bu
|
||||
JOIN buy b ON b.id = bu.buyFk
|
||||
WHERE bu.itemFk = vItemFk;
|
||||
|
||||
CALL sale_setProblem('hasRounding');
|
||||
|
||||
DROP TEMPORARY TABLE tmp.sale;
|
||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,75 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemRoundingByBuy`(
|
||||
vBuyFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Update rounding problem for all sales related to a buy.
|
||||
*
|
||||
* @param vBuyFk Buy id
|
||||
*/
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vMaxDated DATE;
|
||||
DECLARE vMinDated DATE;
|
||||
DECLARE vLanding DATE;
|
||||
DECLARE vLastBuy INT;
|
||||
DECLARE vCurrentBuy INT;
|
||||
DECLARE vGrouping INT;
|
||||
|
||||
SELECT b.itemFk, t.warehouseInFk
|
||||
INTO vItemFk, vWarehouseFk
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE b.id = vBuyFk;
|
||||
|
||||
IF vItemFk AND vWarehouseFk THEN
|
||||
SELECT DATE(MAX(t.shipped)) + INTERVAL 1 DAY, DATE(MIN(t.shipped))
|
||||
INTO vMaxDated, vMinDated
|
||||
FROM sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
WHERE t.shipped >= util.VN_CURDATE()
|
||||
AND s.itemFk = vItemFk
|
||||
AND s.quantity > 0;
|
||||
|
||||
CALL buy_getUltimate(vItemFk, vWarehouseFk, vMinDated);
|
||||
|
||||
SELECT bu.buyFk, b.grouping INTO vLastBuy, vGrouping
|
||||
FROM tmp.buyUltimate bu
|
||||
JOIN buy b ON b.id = bu.buyFk;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||
|
||||
SET vLanding = vMaxDated;
|
||||
|
||||
WHILE vCurrentBuy <> vLastBuy OR vLanding > vMinDated DO
|
||||
SET vMaxDated = vLanding - INTERVAL 1 DAY;
|
||||
|
||||
CALL buy_getUltimate(vItemFk, vWarehouseFk, vMaxDated);
|
||||
|
||||
SELECT buyFk, landing
|
||||
INTO vCurrentBuy, vLanding
|
||||
FROM tmp.buyUltimate;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||
END WHILE;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
(INDEX(saleFk, isProblemCalcNeeded))
|
||||
ENGINE = MEMORY
|
||||
SELECT s.id saleFk,
|
||||
MOD(s.quantity, vGrouping) hasProblem,
|
||||
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
||||
FROM sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
WHERE s.itemFk = vItemFk
|
||||
AND s.quantity > 0
|
||||
AND t.shipped BETWEEN vMinDated AND util.dayEnd(vMaxDated);
|
||||
|
||||
CALL sale_setProblem('hasRounding');
|
||||
|
||||
DROP TEMPORARY TABLE tmp.sale;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,37 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setProblemRounding`(
|
||||
vSelf INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Update the rounding problem for the sales lines of a ticket
|
||||
*
|
||||
* @param vSelf Id de ticket
|
||||
*/
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vDated DATE;
|
||||
|
||||
SELECT warehouseFk, shipped
|
||||
INTO vWarehouseFk, vDated
|
||||
FROM ticket
|
||||
WHERE id = vSelf;
|
||||
|
||||
CALL buy_getUltimate(NULL, vWarehouseFk, vDated);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
(INDEX(saleFk, isProblemCalcNeeded))
|
||||
SELECT s.id saleFk ,
|
||||
MOD(s.quantity, b.`grouping`) hasProblem,
|
||||
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
||||
JOIN buy b ON b.id = bu.buyFk
|
||||
WHERE t.id = vSelf;
|
||||
|
||||
CALL sale_setProblem('hasRounding');
|
||||
|
||||
DROP TEMPORARY TABLE tmp.sale;
|
||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -33,7 +33,7 @@ module.exports = function(Self) {
|
|||
const defaultLimit = this.app.orm.selectLimit;
|
||||
const filter = ctx.args.filter || {limit: defaultLimit};
|
||||
|
||||
if (filter.limit > defaultLimit) {
|
||||
if (!filter.limit || filter.limit > defaultLimit) {
|
||||
filter.limit = defaultLimit;
|
||||
ctx.args.filter = filter;
|
||||
}
|
||||
|
@ -349,9 +349,10 @@ module.exports = function(Self) {
|
|||
},
|
||||
|
||||
hasFilter(ctx) {
|
||||
return ctx.req.method.toUpperCase() === 'GET' &&
|
||||
ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object');
|
||||
}
|
||||
|
||||
const {method, req} = ctx;
|
||||
if (method.noLimit) return false;
|
||||
return req.method.toUpperCase() === 'GET' &&
|
||||
method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object');
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
|
@ -16,7 +16,8 @@ module.exports = Self => {
|
|||
http: {
|
||||
path: `/getBalance`,
|
||||
verb: 'GET'
|
||||
}
|
||||
},
|
||||
noLimit: true
|
||||
});
|
||||
|
||||
Self.getBalance = async(ctx, filter, options) => {
|
||||
|
|
|
@ -138,7 +138,7 @@ module.exports = Self => {
|
|||
id: id,
|
||||
url: `${url}ticket/${id}/summary`
|
||||
});
|
||||
await models.Chat.send(ctx, `@${salesPersonUser.name}`, message);
|
||||
await models.Chat.sendCheckingPresence(ctx, salesPersonUser.id, message);
|
||||
}
|
||||
|
||||
const updatedTicket = await ticket.updateAttribute('isDeleted', true, myOptions);
|
||||
|
|
Loading…
Reference in New Issue