fix pass dates
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2022-06-09 14:39:51 +02:00
parent eb9bd66ddb
commit f786cdd33d
10 changed files with 29 additions and 61 deletions

View File

@ -332,7 +332,7 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr
(2, 'Petter Parker', '20 Ingram Street', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1),
(3, 'Clark Kent', '344 Clinton Street', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1),
(4, 'Tony Stark', '10880 Malibu Point', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 1),
(5, 'Max Eisenhardt', 'Unkutil.VN_NOWn Whereabouts', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1),
(5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1),
(6, 'DavidCharlesHaller', 'Evil hideout', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1),
(7, 'Hank Pym', 'Anthill', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1),
(8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1),
@ -425,7 +425,7 @@ INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`)
INSERT INTO `vn`.`clientObservation`(`id`, `clientFk`, `workerFk`, `text`, `created`)
VALUES
(1, 1101, 1, 'Madness, as you kutil.VN_NOW, is like gravity, all it takes is a little push', util.VN_CURDATE()),
(1, 1101, 1, 'Madness, as you know, is like gravity, all it takes is a little push', util.VN_CURDATE()),
(2, 1102, 1, 'With great power, comes great responsibility', util.VN_CURDATE()),
(3, 1103, 3, 'this is a job for Super-Man!', util.VN_CURDATE()),
(4, 1104, 3, 'yes... I am Iron-Man', util.VN_CURDATE()),

View File

@ -24835,45 +24835,6 @@ CREATE SCHEMA IF NOT EXISTS `util`;
USE `util`;
DELIMITER ;;
DROP FUNCTION IF EXISTS `util`.`mockedDate`;
CREATE FUNCTION `util`.`mockedDate`()
RETURNS DATETIME
DETERMINISTIC
BEGIN
RETURN NOW();
END ;;
DELIMITER ;
DELIMITER ;;
DROP FUNCTION IF EXISTS `util`.`VN_CURDATE`;
CREATE FUNCTION `util`.`VN_CURDATE`()
RETURNS DATE
DETERMINISTIC
BEGIN
RETURN DATE(mockedDate());
END ;;
DELIMITER ;
DELIMITER ;;
DROP FUNCTION IF EXISTS `util`.`VN_CURTIME`;
CREATE FUNCTION `util`.`VN_CURTIME`()
RETURNS TIME
DETERMINISTIC
BEGIN
RETURN TIME(mockedDate());
END ;;
DELIMITER ;
DELIMITER ;;
DROP FUNCTION IF EXISTS `util`.`VN_NOW`;
CREATE FUNCTION `util`.`VN_NOW`()
RETURNS DATETIME
DETERMINISTIC
BEGIN
RETURN mockedDate();
END ;;
DELIMITER ;
--
-- Table structure for table `config`
--

View File

@ -74,10 +74,10 @@ module.exports = Self => {
LEFT JOIN account.user u ON u.id = c.salesPersonFk
LEFT JOIN account.user uw ON uw.id = co.workerFk
WHERE
d.created = ${date}
d.created = ?
AND d.amount > 0
ORDER BY co.created DESC) d`
);
, [date]);
stmt.merge(conn.makeWhere(filter.where));
stmt.merge(`GROUP BY d.clientFk`);

View File

@ -204,9 +204,9 @@ module.exports = Self => {
LEFT JOIN itemType t ON t.id = i.typeFk
LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
LEFT JOIN origin ori ON ori.id = i.originFk
LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(${date},INTERVAL 1 YEAR)
LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(? ,INTERVAL 1 YEAR)
LEFT JOIN supplier s ON s.id = e.supplierFk`
);
, [date]);
if (ctx.args.tags) {
let i = 1;

View File

@ -49,9 +49,10 @@ module.exports = Self => {
JOIN client c ON c.id = v.userFk
JOIN account.user u ON c.salesPersonFk = u.id
LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk
AND ${date} BETWEEN sc.started AND sc.ended
AND ? BETWEEN sc.started AND sc.ended
LEFT JOIN workerTeamCollegues wtc
ON wtc.collegueFk = IFNULL(sc.workerSubstitute, c.salesPersonFk)`);
ON wtc.collegueFk = IFNULL(sc.workerSubstitute, c.salesPersonFk)`,
[date]);
if (!filter.where) filter.where = {};

View File

@ -266,15 +266,18 @@ module.exports = Self => {
`);
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems');
stmts.push(`
stmt = new ParameterizedSQL(`
CREATE TEMPORARY TABLE tmp.sale_getProblems
(INDEX (ticketFk))
ENGINE = MEMORY
SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped
FROM tmp.filter f
LEFT JOIN alertLevel al ON al.id = f.alertLevel
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)
AND f.shipped >= ${date}`);
(INDEX (ticketFk))
ENGINE = MEMORY
SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped
FROM tmp.filter f
LEFT JOIN alertLevel al ON al.id = f.alertLevel
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)
AND f.shipped >= ?`, [date]);
stmts.push(stmt);
stmts.push('CALL ticket_getProblems(FALSE)');
stmts.push(`

View File

@ -103,10 +103,10 @@ module.exports = Self => {
LEFT JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.supplierAgencyTerm sat ON sat.agencyFk = a.id
LEFT JOIN vn.supplier s ON s.id = sat.supplierFk
WHERE r.created > DATE_ADD(${date}, INTERVAL -2 MONTH) AND sat.supplierFk IS NOT NULL
WHERE r.created > DATE_ADD(?, INTERVAL -2 MONTH) AND sat.supplierFk IS NOT NULL
GROUP BY r.id
) a`
);
, [date]);
stmt.merge(conn.makeWhere(filter.where));
stmt.merge(conn.makePagination(filter));

View File

@ -45,7 +45,7 @@ module.exports = Self => {
AND t.id = ? AND cb.id IS NULL
ORDER BY t.landed DESC, t.id DESC`;
const claimableSales = await Self.rawSql(query, [ticketFk, date], myOptions);
const claimableSales = await Self.rawSql(query, [date, ticketFk], myOptions);
return claimableSales;
};

View File

@ -299,7 +299,8 @@ module.exports = Self => {
stmts.push(stmt);
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems');
stmts.push(`
stmt = new ParameterizedSQL(`
CREATE TEMPORARY TABLE tmp.sale_getProblems
(INDEX (ticketFk))
ENGINE = MEMORY
@ -307,7 +308,9 @@ module.exports = Self => {
FROM tmp.filter f
LEFT JOIN alertLevel al ON al.id = f.alertLevel
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)
AND f.shipped >= ${date}`);
AND f.shipped >= ?`, [date]);
stmts.push(stmt);
stmts.push('CALL ticket_getProblems(FALSE)');
stmt = new ParameterizedSQL(`

View File

@ -92,7 +92,7 @@ module.exports = Self => {
WHERE c.dayOffTypeFk = 6
AND pe.workerFk = ?
AND c.dated BETWEEN util.firstDayOfYear(?)
AND LAST_DAY(DATE_ADD(?, INTERVAL 12-MONTH(?) MONTH))`, [id, date, now]);
AND LAST_DAY(DATE_ADD(?, INTERVAL 12 - MONTH(?) MONTH))`, [id, date, now, now]);
const hasHalfHoliday = result.halfHolidayCounter > 0;
const isHalfHoliday = absenceType.code === 'halfHoliday';