Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 4185-secure_client_pass_changes
This commit is contained in:
commit
aa6ec3f770
|
@ -0,0 +1,5 @@
|
||||||
|
const baseTime = null; // new Date(2022, 0, 19, 8, 0, 0, 0);
|
||||||
|
if (baseTime) {
|
||||||
|
jasmine.clock().install();
|
||||||
|
jasmine.clock().mockDate(baseTime);
|
||||||
|
}
|
|
@ -31,11 +31,13 @@ COPY \
|
||||||
import-changes.sh \
|
import-changes.sh \
|
||||||
config.ini \
|
config.ini \
|
||||||
dump/mysqlPlugins.sql \
|
dump/mysqlPlugins.sql \
|
||||||
|
dump/mockDate.sql \
|
||||||
dump/structure.sql \
|
dump/structure.sql \
|
||||||
dump/dumpedFixtures.sql \
|
dump/dumpedFixtures.sql \
|
||||||
./
|
./
|
||||||
RUN gosu mysql docker-init.sh \
|
RUN gosu mysql docker-init.sh \
|
||||||
&& docker-dump.sh mysqlPlugins \
|
&& docker-dump.sh mysqlPlugins \
|
||||||
|
&& docker-dump.sh mockDate \
|
||||||
&& docker-dump.sh structure \
|
&& docker-dump.sh structure \
|
||||||
&& docker-dump.sh dumpedFixtures \
|
&& docker-dump.sh dumpedFixtures \
|
||||||
&& gosu mysql docker-temp-stop.sh
|
&& gosu mysql docker-temp-stop.sh
|
||||||
|
|
1468
db/dump/fixtures.sql
1468
db/dump/fixtures.sql
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,43 @@
|
||||||
|
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();
|
||||||
|
-- '2022-01-19 08:00:00'
|
||||||
|
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 ;
|
File diff suppressed because it is too large
Load Diff
|
@ -96,5 +96,12 @@ mysqldump \
|
||||||
--databases \
|
--databases \
|
||||||
${SCHEMAS[@]} \
|
${SCHEMAS[@]} \
|
||||||
${IGNORETABLES[@]} \
|
${IGNORETABLES[@]} \
|
||||||
|
| sed 's/\bCURDATE\b/vn.VN_CURDATE/ig'\
|
||||||
|
| sed 's/\bCURTIME\b/vn.VN_CURTIME/ig' \
|
||||||
|
| sed 's/\bNOW\b/vn.VN_NOW/ig' \
|
||||||
|
| sed 's/\bCURRENT_DATE\b/vn.VN_CURDATE/ig' \
|
||||||
|
| sed 's/\bCURRENT_TIME\b/vn.VN_CURTIME/ig' \
|
||||||
|
| sed 's/\bLOCALTIME\b/vn.VN_NOW/ig' \
|
||||||
|
| sed 's/\bLOCALTIMESTAMP\b/vn.VN_NOW/ig' \
|
||||||
| sed 's/ AUTO_INCREMENT=[0-9]* //g' \
|
| sed 's/ AUTO_INCREMENT=[0-9]* //g' \
|
||||||
> dump/structure.sql
|
> dump/structure.sql
|
|
@ -5,8 +5,9 @@ describe('zone zone_getLanded()', () => {
|
||||||
it(`should return data for a shipped in the past`, async() => {
|
it(`should return data for a shipped in the past`, async() => {
|
||||||
let stmts = [];
|
let stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
|
|
||||||
stmts.push('START TRANSACTION');
|
stmts.push('START TRANSACTION');
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
addressFk: 121,
|
addressFk: 121,
|
||||||
|
@ -14,7 +15,8 @@ describe('zone zone_getLanded()', () => {
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
showExpiredZones: true};
|
showExpiredZones: true};
|
||||||
|
|
||||||
stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(CURDATE(), INTERVAL -1 DAY), ?, ?, ?, ?)', [
|
stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(?, INTERVAL -1 DAY), ?, ?, ?, ?)', [
|
||||||
|
date,
|
||||||
params.addressFk,
|
params.addressFk,
|
||||||
params.agencyModeFk,
|
params.agencyModeFk,
|
||||||
params.warehouseFk,
|
params.warehouseFk,
|
||||||
|
@ -38,6 +40,8 @@ describe('zone zone_getLanded()', () => {
|
||||||
it(`should return data for a shipped tomorrow`, async() => {
|
it(`should return data for a shipped tomorrow`, async() => {
|
||||||
let stmts = [];
|
let stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
stmts.push('START TRANSACTION');
|
stmts.push('START TRANSACTION');
|
||||||
|
|
||||||
|
@ -47,7 +51,8 @@ describe('zone zone_getLanded()', () => {
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
showExpiredZones: false};
|
showExpiredZones: false};
|
||||||
|
|
||||||
stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(CURDATE(), INTERVAL +2 DAY), ?, ?, ?, ?)', [
|
stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(?, INTERVAL +2 DAY), ?, ?, ?, ?)', [
|
||||||
|
date,
|
||||||
params.addressFk,
|
params.addressFk,
|
||||||
params.agencyModeFk,
|
params.agencyModeFk,
|
||||||
params.warehouseFk,
|
params.warehouseFk,
|
||||||
|
|
|
@ -51,6 +51,9 @@ module.exports = function(Self) {
|
||||||
Self.createReceipt = async(ctx, options) => {
|
Self.createReceipt = async(ctx, options) => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const args = ctx.args;
|
const args = ctx.args;
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
let tx;
|
let tx;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
|
@ -92,8 +95,9 @@ module.exports = function(Self) {
|
||||||
throw new UserError('Invalid account');
|
throw new UserError('Invalid account');
|
||||||
|
|
||||||
await Self.rawSql(
|
await Self.rawSql(
|
||||||
`CALL vn.ledger_doCompensation(CURDATE(), ?, ?, ?, ?, ?, ?)`,
|
`CALL vn.ledger_doCompensation(?, ?, ?, ?, ?, ?, ?)`,
|
||||||
[
|
[
|
||||||
|
date,
|
||||||
args.compensationAccount,
|
args.compensationAccount,
|
||||||
args.bankFk,
|
args.bankFk,
|
||||||
accountingType.receiptDescription + originalClient.accountingAccount,
|
accountingType.receiptDescription + originalClient.accountingAccount,
|
||||||
|
@ -106,9 +110,10 @@ module.exports = function(Self) {
|
||||||
} else if (accountingType.isAutoConciliated == true) {
|
} else if (accountingType.isAutoConciliated == true) {
|
||||||
const description = `${originalClient.id} : ${originalClient.socialName} - ${accountingType.receiptDescription}`;
|
const description = `${originalClient.id} : ${originalClient.socialName} - ${accountingType.receiptDescription}`;
|
||||||
const [xdiarioNew] = await Self.rawSql(
|
const [xdiarioNew] = await Self.rawSql(
|
||||||
`SELECT xdiario_new(?, CURDATE(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`,
|
`SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`,
|
||||||
[
|
[
|
||||||
null,
|
null,
|
||||||
|
date,
|
||||||
bank.account,
|
bank.account,
|
||||||
originalClient.accountingAccount,
|
originalClient.accountingAccount,
|
||||||
description,
|
description,
|
||||||
|
@ -126,9 +131,10 @@ module.exports = function(Self) {
|
||||||
);
|
);
|
||||||
|
|
||||||
await Self.rawSql(
|
await Self.rawSql(
|
||||||
`SELECT xdiario_new(?, CURDATE(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`,
|
`SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`,
|
||||||
[
|
[
|
||||||
xdiarioNew.ledger,
|
xdiarioNew.ledger,
|
||||||
|
date,
|
||||||
originalClient.accountingAccount,
|
originalClient.accountingAccount,
|
||||||
bank.account,
|
bank.account,
|
||||||
description,
|
description,
|
||||||
|
|
|
@ -74,8 +74,10 @@ module.exports = function(Self) {
|
||||||
]
|
]
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`;
|
const date = new Date();
|
||||||
const data = await Self.rawSql(query, [id], myOptions);
|
date.setHours(0, 0, 0, 0);
|
||||||
|
const query = `SELECT vn.clientGetDebt(?, ?) AS debt`;
|
||||||
|
const data = await Self.rawSql(query, [id, date], myOptions);
|
||||||
|
|
||||||
client.debt = data[0].debt;
|
client.debt = data[0].debt;
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,10 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`;
|
const date = new Date();
|
||||||
const [debt] = await Self.rawSql(query, [clientFk], myOptions);
|
date.setHours(0, 0, 0, 0);
|
||||||
|
const query = `SELECT vn.clientGetDebt(?, ?) AS debt`;
|
||||||
|
const [debt] = await Self.rawSql(query, [clientFk, date], myOptions);
|
||||||
|
|
||||||
return debt;
|
return debt;
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,6 +32,8 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
const ticket = await Self.app.models.Ticket.findById(ticketId, null, myOptions);
|
const ticket = await Self.app.models.Ticket.findById(ticketId, null, myOptions);
|
||||||
const query = `
|
const query = `
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -50,12 +52,12 @@ module.exports = Self => {
|
||||||
JOIN vn.warehouse w ON t.warehouseFk = w.id
|
JOIN vn.warehouse w ON t.warehouseFk = w.id
|
||||||
JOIN vn.address ad ON t.addressFk = ad.id
|
JOIN vn.address ad ON t.addressFk = ad.id
|
||||||
JOIN vn.province pr ON ad.provinceFk = pr.id
|
JOIN vn.province pr ON ad.provinceFk = pr.id
|
||||||
WHERE t.shipped >= CURDATE() AND t.clientFk = ? AND ts.alertLevel = 0
|
WHERE t.shipped >= ? AND t.clientFk = ? AND ts.alertLevel = 0
|
||||||
AND t.id <> ? AND t.warehouseFk = ?
|
AND t.id <> ? AND t.warehouseFk = ?
|
||||||
ORDER BY t.shipped
|
ORDER BY t.shipped
|
||||||
LIMIT 10`;
|
LIMIT 10`;
|
||||||
|
|
||||||
return Self.rawSql(query, [id, ticketId, ticket.warehouseFk], myOptions);
|
return Self.rawSql(query, [date, id, ticketId, ticket.warehouseFk], myOptions);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,6 @@ describe('client summary()', () => {
|
||||||
const result = await models.Client.summary(clientId, options);
|
const result = await models.Client.summary(clientId, options);
|
||||||
|
|
||||||
expect(result.recovery.id).toEqual(3);
|
expect(result.recovery.id).toEqual(3);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
|
@ -122,7 +122,6 @@ module.exports = Self => {
|
||||||
|
|
||||||
return clientModel.findOne(filter, options);
|
return clientModel.findOne(filter, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getRecoveries(recoveryModel, clientId, options) {
|
async function getRecoveries(recoveryModel, clientId, options) {
|
||||||
const filter = {
|
const filter = {
|
||||||
where: {
|
where: {
|
||||||
|
|
|
@ -51,6 +51,8 @@ module.exports = Self => {
|
||||||
|
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
|
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
const stmt = new ParameterizedSQL(
|
const stmt = new ParameterizedSQL(
|
||||||
`SELECT *
|
`SELECT *
|
||||||
FROM (
|
FROM (
|
||||||
|
@ -72,10 +74,10 @@ module.exports = Self => {
|
||||||
LEFT JOIN account.user u ON u.id = c.salesPersonFk
|
LEFT JOIN account.user u ON u.id = c.salesPersonFk
|
||||||
LEFT JOIN account.user uw ON uw.id = co.workerFk
|
LEFT JOIN account.user uw ON uw.id = co.workerFk
|
||||||
WHERE
|
WHERE
|
||||||
d.created = CURDATE()
|
d.created = ?
|
||||||
AND d.amount > 0
|
AND d.amount > 0
|
||||||
ORDER BY co.created DESC) d`
|
ORDER BY co.created DESC) d`
|
||||||
);
|
, [date]);
|
||||||
|
|
||||||
stmt.merge(conn.makeWhere(filter.where));
|
stmt.merge(conn.makeWhere(filter.where));
|
||||||
stmt.merge(`GROUP BY d.clientFk`);
|
stmt.merge(`GROUP BY d.clientFk`);
|
||||||
|
|
|
@ -27,13 +27,15 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
const query = `
|
const query = `
|
||||||
SELECT count(*) AS hasActiveRecovery
|
SELECT count(*) AS hasActiveRecovery
|
||||||
FROM vn.recovery
|
FROM vn.recovery
|
||||||
WHERE clientFk = ?
|
WHERE clientFk = ?
|
||||||
AND IFNULL(finished,CURDATE()) >= CURDATE();
|
AND IFNULL(finished, ?) >= ?;
|
||||||
`;
|
`;
|
||||||
const [result] = await Self.rawSql(query, [id], myOptions);
|
const [result] = await Self.rawSql(query, [id, date, date], myOptions);
|
||||||
|
|
||||||
return result.hasActiveRecovery != 0;
|
return result.hasActiveRecovery != 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -145,6 +145,8 @@ module.exports = Self => {
|
||||||
|
|
||||||
stmts.push('CALL cache.visible_refresh(@calc_id, FALSE, 1)');
|
stmts.push('CALL cache.visible_refresh(@calc_id, FALSE, 1)');
|
||||||
|
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`
|
||||||
SELECT
|
SELECT
|
||||||
i.image,
|
i.image,
|
||||||
|
@ -202,9 +204,9 @@ module.exports = Self => {
|
||||||
LEFT JOIN itemType t ON t.id = i.typeFk
|
LEFT JOIN itemType t ON t.id = i.typeFk
|
||||||
LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
|
LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
|
||||||
LEFT JOIN origin ori ON ori.id = i.originFk
|
LEFT JOIN origin ori ON ori.id = i.originFk
|
||||||
LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(CURDATE(),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`
|
LEFT JOIN supplier s ON s.id = e.supplierFk`
|
||||||
);
|
, [date]);
|
||||||
|
|
||||||
if (ctx.args.tags) {
|
if (ctx.args.tags) {
|
||||||
let i = 1;
|
let i = 1;
|
||||||
|
|
|
@ -32,6 +32,8 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
const wastes = await Self.rawSql(`
|
const wastes = await Self.rawSql(`
|
||||||
SELECT *, 100 * dwindle / total AS percentage
|
SELECT *, 100 * dwindle / total AS percentage
|
||||||
FROM (
|
FROM (
|
||||||
|
@ -42,11 +44,11 @@ module.exports = Self => {
|
||||||
sum(ws.saleWaste) AS dwindle
|
sum(ws.saleWaste) AS dwindle
|
||||||
FROM bs.waste ws
|
FROM bs.waste ws
|
||||||
WHERE buyer = ? AND family = ?
|
WHERE buyer = ? AND family = ?
|
||||||
AND year = YEAR(TIMESTAMPADD(WEEK,-1,CURDATE()))
|
AND year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
|
||||||
AND week = WEEK(TIMESTAMPADD(WEEK,-1,CURDATE()), 1)
|
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
|
||||||
GROUP BY buyer, itemFk
|
GROUP BY buyer, itemFk
|
||||||
) sub
|
) sub
|
||||||
ORDER BY family, percentage DESC`, [buyer, family], myOptions);
|
ORDER BY family, percentage DESC`, [buyer, family, date, date], myOptions);
|
||||||
|
|
||||||
const details = [];
|
const details = [];
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
const wastes = await Self.rawSql(`
|
const wastes = await Self.rawSql(`
|
||||||
SELECT *, 100 * dwindle / total AS percentage
|
SELECT *, 100 * dwindle / total AS percentage
|
||||||
FROM (
|
FROM (
|
||||||
|
@ -27,11 +29,11 @@ module.exports = Self => {
|
||||||
sum(ws.saleTotal) AS total,
|
sum(ws.saleTotal) AS total,
|
||||||
sum(ws.saleWaste) AS dwindle
|
sum(ws.saleWaste) AS dwindle
|
||||||
FROM bs.waste ws
|
FROM bs.waste ws
|
||||||
WHERE year = YEAR(TIMESTAMPADD(WEEK,-1,CURDATE()))
|
WHERE year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
|
||||||
AND week = WEEK(TIMESTAMPADD(WEEK,-1,CURDATE()), 1)
|
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
|
||||||
GROUP BY buyer, family
|
GROUP BY buyer, family
|
||||||
) sub
|
) sub
|
||||||
ORDER BY percentage DESC`, null, myOptions);
|
ORDER BY percentage DESC`, [date, date], myOptions);
|
||||||
|
|
||||||
const details = [];
|
const details = [];
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
const stmt = new ParameterizedSQL(`
|
const stmt = new ParameterizedSQL(`
|
||||||
SELECT
|
SELECT
|
||||||
u.name AS salesPerson,
|
u.name AS salesPerson,
|
||||||
|
@ -47,9 +49,10 @@ module.exports = Self => {
|
||||||
JOIN client c ON c.id = v.userFk
|
JOIN client c ON c.id = v.userFk
|
||||||
JOIN account.user u ON c.salesPersonFk = u.id
|
JOIN account.user u ON c.salesPersonFk = u.id
|
||||||
LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk
|
LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk
|
||||||
AND CURDATE() BETWEEN sc.started AND sc.ended
|
AND ? BETWEEN sc.started AND sc.ended
|
||||||
LEFT JOIN workerTeamCollegues wtc
|
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 = {};
|
if (!filter.where) filter.where = {};
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,8 @@ module.exports = Self => {
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
const conn = Self.dataSource.connector;
|
const conn = Self.dataSource.connector;
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
const args = ctx.args;
|
const args = ctx.args;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
|
@ -264,15 +266,18 @@ module.exports = Self => {
|
||||||
`);
|
`);
|
||||||
|
|
||||||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems');
|
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems');
|
||||||
stmts.push(`
|
|
||||||
|
stmt = new ParameterizedSQL(`
|
||||||
CREATE TEMPORARY TABLE tmp.sale_getProblems
|
CREATE TEMPORARY TABLE tmp.sale_getProblems
|
||||||
(INDEX (ticketFk))
|
(INDEX (ticketFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped
|
SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped
|
||||||
FROM tmp.filter f
|
FROM tmp.filter f
|
||||||
LEFT JOIN alertLevel al ON al.id = f.alertLevel
|
LEFT JOIN alertLevel al ON al.id = f.alertLevel
|
||||||
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)
|
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)
|
||||||
AND f.shipped >= CURDATE()`);
|
AND f.shipped >= ?`, [date]);
|
||||||
|
stmts.push(stmt);
|
||||||
|
|
||||||
stmts.push('CALL ticket_getProblems(FALSE)');
|
stmts.push('CALL ticket_getProblems(FALSE)');
|
||||||
|
|
||||||
stmts.push(`
|
stmts.push(`
|
||||||
|
|
|
@ -74,6 +74,8 @@ module.exports = Self => {
|
||||||
|
|
||||||
filter = mergeFilters(filter, {where});
|
filter = mergeFilters(filter, {where});
|
||||||
|
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
const stmt = new ParameterizedSQL(
|
const stmt = new ParameterizedSQL(
|
||||||
`SELECT *
|
`SELECT *
|
||||||
|
@ -101,10 +103,10 @@ module.exports = Self => {
|
||||||
LEFT JOIN vn.ticket t ON t.routeFk = r.id
|
LEFT JOIN vn.ticket t ON t.routeFk = r.id
|
||||||
LEFT JOIN vn.supplierAgencyTerm sat ON sat.agencyFk = a.id
|
LEFT JOIN vn.supplierAgencyTerm sat ON sat.agencyFk = a.id
|
||||||
LEFT JOIN vn.supplier s ON s.id = sat.supplierFk
|
LEFT JOIN vn.supplier s ON s.id = sat.supplierFk
|
||||||
WHERE r.created > DATE_ADD(CURDATE(), 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
|
GROUP BY r.id
|
||||||
) a`
|
) a`
|
||||||
);
|
, [date]);
|
||||||
|
|
||||||
stmt.merge(conn.makeWhere(filter.where));
|
stmt.merge(conn.makeWhere(filter.where));
|
||||||
stmt.merge(conn.makePagination(filter));
|
stmt.merge(conn.makePagination(filter));
|
||||||
|
|
|
@ -2,17 +2,17 @@ const app = require('vn-loopback/server/server');
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('Route filter()', () => {
|
describe('Route filter()', () => {
|
||||||
let today = new Date();
|
const today = new Date();
|
||||||
today.setHours(2, 0, 0, 0);
|
today.setHours(2, 0, 0, 0);
|
||||||
|
|
||||||
it('should return the routes matching "search"', async() => {
|
it('should return the routes matching "search"', async() => {
|
||||||
let ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
search: 1,
|
search: 1,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = await app.models.Route.filter(ctx);
|
const result = await app.models.Route.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
expect(result[0].id).toEqual(1);
|
expect(result[0].id).toEqual(1);
|
||||||
|
@ -28,7 +28,6 @@ describe('Route filter()', () => {
|
||||||
|
|
||||||
const to = new Date();
|
const to = new Date();
|
||||||
to.setHours(23, 59, 59, 999);
|
to.setHours(23, 59, 59, 999);
|
||||||
|
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
from: from,
|
from: from,
|
||||||
|
@ -48,43 +47,43 @@ describe('Route filter()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the routes matching "m3"', async() => {
|
it('should return the routes matching "m3"', async() => {
|
||||||
let ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
m3: 0.1,
|
m3: 0.1,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = await app.models.Route.filter(ctx);
|
const result = await app.models.Route.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the routes matching "description"', async() => {
|
it('should return the routes matching "description"', async() => {
|
||||||
let ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
description: 'third route',
|
description: 'third route',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = await app.models.Route.filter(ctx);
|
const result = await app.models.Route.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the routes matching "workerFk"', async() => {
|
it('should return the routes matching "workerFk"', async() => {
|
||||||
let ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
workerFk: 56,
|
workerFk: 56,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = await app.models.Route.filter(ctx);
|
const result = await app.models.Route.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(5);
|
expect(result.length).toEqual(5);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the routes matching "warehouseFk"', async() => {
|
it('should return the routes matching "warehouseFk"', async() => {
|
||||||
let ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
}
|
}
|
||||||
|
@ -102,25 +101,25 @@ describe('Route filter()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the routes matching "vehicleFk"', async() => {
|
it('should return the routes matching "vehicleFk"', async() => {
|
||||||
let ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
vehicleFk: 2,
|
vehicleFk: 2,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = await app.models.Route.filter(ctx);
|
const result = await app.models.Route.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the routes matching "agencyModeFk"', async() => {
|
it('should return the routes matching "agencyModeFk"', async() => {
|
||||||
let ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
agencyModeFk: 7,
|
agencyModeFk: 7,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = await app.models.Route.filter(ctx);
|
const result = await app.models.Route.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,30 +1,32 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('route getSuggestedTickets()', () => {
|
describe('route getSuggestedTickets()', () => {
|
||||||
const routeID = 1;
|
const routeID = 1;
|
||||||
const ticketId = 12;
|
const ticketId = 12;
|
||||||
|
|
||||||
it('should return an array of suggested tickets', async() => {
|
it('should return an array of suggested tickets', async() => {
|
||||||
const activeCtx = {
|
const activeCtx = {
|
||||||
accessToken: {userId: 19},
|
accessToken: {userId: 19},
|
||||||
headers: {origin: 'http://localhost'}
|
headers: {origin: 'http://localhost'}
|
||||||
};
|
};
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
active: activeCtx
|
active: activeCtx
|
||||||
});
|
});
|
||||||
|
|
||||||
const tx = await app.models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const ticketInRoute = await app.models.Ticket.findById(ticketId, null, options);
|
const ticketInRoute = await models.Ticket.findById(ticketId, null, options);
|
||||||
|
|
||||||
await ticketInRoute.updateAttributes({
|
await ticketInRoute.updateAttributes({
|
||||||
routeFk: null,
|
routeFk: null,
|
||||||
landed: new Date()
|
landed: new Date()
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
const result = await app.models.Route.getSuggestedTickets(routeID, options);
|
const result = await models.Route.getSuggestedTickets(routeID, options);
|
||||||
|
|
||||||
const length = result.length;
|
const length = result.length;
|
||||||
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
||||||
|
|
|
@ -24,6 +24,8 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
const query = `
|
const query = `
|
||||||
SELECT
|
SELECT
|
||||||
s.id AS saleFk,
|
s.id AS saleFk,
|
||||||
|
@ -39,11 +41,11 @@ module.exports = Self => {
|
||||||
INNER JOIN vn.sale s ON s.ticketFk = t.id
|
INNER JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
LEFT JOIN vn.claimBeginning cb ON cb.saleFk = s.id
|
LEFT JOIN vn.claimBeginning cb ON cb.saleFk = s.id
|
||||||
|
|
||||||
WHERE (t.landed) >= TIMESTAMPADD(DAY, -7, CURDATE())
|
WHERE (t.landed) >= TIMESTAMPADD(DAY, -7, ?)
|
||||||
AND t.id = ? AND cb.id IS NULL
|
AND t.id = ? AND cb.id IS NULL
|
||||||
ORDER BY t.landed DESC, t.id DESC`;
|
ORDER BY t.landed DESC, t.id DESC`;
|
||||||
|
|
||||||
const claimableSales = await Self.rawSql(query, [ticketFk], myOptions);
|
const claimableSales = await Self.rawSql(query, [date, ticketFk], myOptions);
|
||||||
|
|
||||||
return claimableSales;
|
return claimableSales;
|
||||||
};
|
};
|
||||||
|
|
|
@ -132,6 +132,8 @@ module.exports = Self => {
|
||||||
Self.filter = async(ctx, filter, options) => {
|
Self.filter = async(ctx, filter, options) => {
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
const conn = Self.dataSource.connector;
|
const conn = Self.dataSource.connector;
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const args = ctx.args;
|
const args = ctx.args;
|
||||||
|
|
||||||
|
@ -297,7 +299,8 @@ module.exports = Self => {
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
|
||||||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems');
|
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems');
|
||||||
stmts.push(`
|
|
||||||
|
stmt = new ParameterizedSQL(`
|
||||||
CREATE TEMPORARY TABLE tmp.sale_getProblems
|
CREATE TEMPORARY TABLE tmp.sale_getProblems
|
||||||
(INDEX (ticketFk))
|
(INDEX (ticketFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
|
@ -305,7 +308,9 @@ module.exports = Self => {
|
||||||
FROM tmp.filter f
|
FROM tmp.filter f
|
||||||
LEFT JOIN alertLevel al ON al.id = f.alertLevel
|
LEFT JOIN alertLevel al ON al.id = f.alertLevel
|
||||||
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)
|
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)
|
||||||
AND f.shipped >= CURDATE()`);
|
AND f.shipped >= ?`, [date]);
|
||||||
|
stmts.push(stmt);
|
||||||
|
|
||||||
stmts.push('CALL ticket_getProblems(FALSE)');
|
stmts.push('CALL ticket_getProblems(FALSE)');
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`
|
||||||
|
|
|
@ -26,6 +26,8 @@ module.exports = function(Self) {
|
||||||
Self.makeInvoice = async(ctx, ticketsIds, options) => {
|
Self.makeInvoice = async(ctx, ticketsIds, options) => {
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
const date = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
let tx;
|
let tx;
|
||||||
|
@ -81,7 +83,7 @@ module.exports = function(Self) {
|
||||||
WHERE id IN(?) AND refFk IS NULL
|
WHERE id IN(?) AND refFk IS NULL
|
||||||
`, [ticketsIds], myOptions);
|
`, [ticketsIds], myOptions);
|
||||||
|
|
||||||
await Self.rawSql('CALL invoiceOut_new(?, CURDATE(), null, @invoiceId)', [serial], myOptions);
|
await Self.rawSql('CALL invoiceOut_new(?, ?, null, @invoiceId)', [serial, date], myOptions);
|
||||||
|
|
||||||
const [resultInvoice] = await Self.rawSql('SELECT @invoiceId id', [], myOptions);
|
const [resultInvoice] = await Self.rawSql('SELECT @invoiceId id', [], myOptions);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@ describe('ticket canBeInvoiced()', () => {
|
||||||
|
|
||||||
it('should return falsy for a ticket shipping in future', async() => {
|
it('should return falsy for a ticket shipping in future', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ module.exports = Self => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
let tx;
|
let tx;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
const date = new Date();
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
@ -57,8 +58,8 @@ module.exports = Self => {
|
||||||
|
|
||||||
await Self.rawSql(`
|
await Self.rawSql(`
|
||||||
INSERT INTO travelThermograph(thermographFk, warehouseFk, temperatureFk, created)
|
INSERT INTO travelThermograph(thermographFk, warehouseFk, temperatureFk, created)
|
||||||
VALUES (?, ?, ?, NOW())
|
VALUES (?, ?, ?, ?)
|
||||||
`, [thermograph.id, warehouseId, temperatureFk], myOptions);
|
`, [thermograph.id, warehouseId, temperatureFk, date], myOptions);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('workerTimeControl filter()', () => {
|
describe('workerTimeControl filter()', () => {
|
||||||
it('should return 1 result filtering by id', async() => {
|
it('should return 1 result filtering by id', async() => {
|
||||||
let ctx = {req: {accessToken: {userId: 1106}}, args: {workerFk: 1106}};
|
const ctx = {req: {accessToken: {userId: 1106}}, args: {workerFk: 1106}};
|
||||||
const firstHour = new Date();
|
const firstHour = new Date();
|
||||||
firstHour.setHours(7, 0, 0, 0);
|
firstHour.setHours(7, 0, 0, 0);
|
||||||
const lastHour = new Date();
|
const lastHour = new Date();
|
||||||
|
@ -14,13 +14,13 @@ describe('workerTimeControl filter()', () => {
|
||||||
timed: {between: [firstHour, lastHour]}
|
timed: {between: [firstHour, lastHour]}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let result = await app.models.WorkerTimeControl.filter(ctx, filter);
|
const result = await models.WorkerTimeControl.filter(ctx, filter);
|
||||||
|
|
||||||
expect(result.length).toEqual(4);
|
expect(result.length).toEqual(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a privilege error for a non subordinate worker', async() => {
|
it('should return a privilege error for a non subordinate worker', async() => {
|
||||||
let ctx = {req: {accessToken: {userId: 1107}}, args: {workerFk: 1106}};
|
const ctx = {req: {accessToken: {userId: 1107}}, args: {workerFk: 1106}};
|
||||||
const firstHour = new Date();
|
const firstHour = new Date();
|
||||||
firstHour.setHours(7, 0, 0, 0);
|
firstHour.setHours(7, 0, 0, 0);
|
||||||
const lastHour = new Date();
|
const lastHour = new Date();
|
||||||
|
@ -34,7 +34,7 @@ describe('workerTimeControl filter()', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
await app.models.WorkerTimeControl.filter(ctx, filter).catch(e => {
|
await models.WorkerTimeControl.filter(ctx, filter).catch(e => {
|
||||||
error = e;
|
error = e;
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
expect(error.message).toEqual(`You don't have enough privileges`);
|
expect(error.message).toEqual(`You don't have enough privileges`);
|
||||||
|
|
|
@ -8,10 +8,10 @@ describe('workerTimeControl add/delete timeEntry()', () => {
|
||||||
const employeeId = 1;
|
const employeeId = 1;
|
||||||
const salesPersonId = 1106;
|
const salesPersonId = 1106;
|
||||||
const salesBossId = 19;
|
const salesBossId = 19;
|
||||||
let activeCtx = {
|
const activeCtx = {
|
||||||
accessToken: {userId: 50},
|
accessToken: {userId: 50},
|
||||||
};
|
};
|
||||||
let ctx = {req: activeCtx};
|
const ctx = {req: activeCtx};
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
@ -82,7 +82,7 @@ describe('workerTimeControl add/delete timeEntry()', () => {
|
||||||
const workerId = salesPersonId;
|
const workerId = salesPersonId;
|
||||||
let error;
|
let error;
|
||||||
|
|
||||||
let calendar = await app.models.Calendar.findById(3);
|
const calendar = await app.models.Calendar.findById(3);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ctx.args = {timed: new Date(calendar.dated), direction: 'in'};
|
ctx.args = {timed: new Date(calendar.dated), direction: 'in'};
|
||||||
|
|
|
@ -80,6 +80,9 @@ module.exports = Self => {
|
||||||
if (hasHoursRecorded && isNotHalfAbsence)
|
if (hasHoursRecorded && isNotHalfAbsence)
|
||||||
throw new UserError(`The worker has hours recorded that day`);
|
throw new UserError(`The worker has hours recorded that day`);
|
||||||
|
|
||||||
|
const date = new Date();
|
||||||
|
const now = new Date();
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
const [result] = await Self.rawSql(
|
const [result] = await Self.rawSql(
|
||||||
`SELECT COUNT(*) halfHolidayCounter
|
`SELECT COUNT(*) halfHolidayCounter
|
||||||
FROM vn.calendar c
|
FROM vn.calendar c
|
||||||
|
@ -88,8 +91,8 @@ module.exports = Self => {
|
||||||
JOIN vn.person pe ON pe.id = p.person_id
|
JOIN vn.person pe ON pe.id = p.person_id
|
||||||
WHERE c.dayOffTypeFk = 6
|
WHERE c.dayOffTypeFk = 6
|
||||||
AND pe.workerFk = ?
|
AND pe.workerFk = ?
|
||||||
AND c.dated BETWEEN util.firstDayOfYear(CURDATE())
|
AND c.dated BETWEEN util.firstDayOfYear(?)
|
||||||
AND LAST_DAY(DATE_ADD(NOW(), INTERVAL 12-MONTH(NOW()) MONTH))`, [id]);
|
AND LAST_DAY(DATE_ADD(?, INTERVAL 12 - MONTH(?) MONTH))`, [id, date, now, now]);
|
||||||
|
|
||||||
const hasHalfHoliday = result.halfHolidayCounter > 0;
|
const hasHalfHoliday = result.halfHolidayCounter > 0;
|
||||||
const isHalfHoliday = absenceType.code === 'halfHoliday';
|
const isHalfHoliday = absenceType.code === 'halfHoliday';
|
||||||
|
|
|
@ -8,7 +8,6 @@ describe('zone getZoneClosing()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const today = date.toISOString().split('T')[0];
|
const today = date.toISOString().split('T')[0];
|
||||||
|
|
||||||
const result = await models.Zone.getZoneClosing([1, 2, 3], today, options);
|
const result = await models.Zone.getZoneClosing([1, 2, 3], today, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(3);
|
expect(result.length).toEqual(3);
|
||||||
|
|
|
@ -93,11 +93,12 @@ module.exports = async function(request, response, next) {
|
||||||
await email.send(mailOptions);
|
await email.send(mailOptions);
|
||||||
}
|
}
|
||||||
// Update queue status
|
// Update queue status
|
||||||
|
const date = new Date();
|
||||||
sql = `UPDATE invoiceOut_queue
|
sql = `UPDATE invoiceOut_queue
|
||||||
SET status = "printed",
|
SET status = "printed",
|
||||||
printed = NOW()
|
printed = ?
|
||||||
WHERE invoiceFk = ?`;
|
WHERE invoiceFk = ?`;
|
||||||
connection.query(sql, [invoiceOut.id]);
|
connection.query(sql, [date, invoiceOut.id]);
|
||||||
connection.query('COMMIT');
|
connection.query('COMMIT');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
connection.query('ROLLBACK');
|
connection.query('ROLLBACK');
|
||||||
|
|
Loading…
Reference in New Issue