Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2843-claim_pickup_order

This commit is contained in:
jorgebl 2021-03-16 11:23:49 +01:00
commit 37c29584af
14 changed files with 48996 additions and 3567 deletions

View File

@ -1,5 +1,5 @@
module.exports = {
presets: [
'@babel/preset-env',
'@babel/env',
],
};

View File

@ -1,21 +1,21 @@
const request = require('request-promise-native');
const got = require('got');
module.exports = Self => {
Self.remoteMethodCtx('send', {
description: 'Send a RocketChat message',
accessType: 'WRITE',
accepts: [{
arg: 'to',
type: 'String',
type: 'string',
required: true,
description: 'User (@) or channel (#) to send the message'
}, {
arg: 'message',
type: 'String',
type: 'string',
required: true,
description: 'The message'
}],
returns: {
type: 'Object',
type: 'object',
root: true
},
http: {
@ -30,8 +30,15 @@ module.exports = Self => {
const sender = await models.Account.findById(accessToken.userId);
const recipient = to.replace('@', '');
if (sender.name != recipient)
return sendMessage(sender, to, message);
if (sender.name != recipient) {
let {body} = await sendMessage(sender, to, message);
if (body)
body = JSON.parse(body);
else
body = false;
return body;
}
return false;
};
@ -65,12 +72,15 @@ module.exports = Self => {
if (!this.auth || this.auth && !this.auth.authToken) {
const config = await getConfig();
const uri = `${config.api}/login`;
const res = await send(uri, {
let {body} = await send(uri, {
user: config.user,
password: config.password
});
this.auth = res.data;
if (body) {
body = JSON.parse(body);
this.auth = body.data;
}
}
return this.auth;
@ -93,29 +103,29 @@ module.exports = Self => {
/**
* Send unauthenticated request
* @param {*} uri - Request uri
* @param {*} body - Request params
* @param {*} params - Request params
* @param {*} options - Request options
*
* @return {Object} Request response
*/
async function send(uri, body, options) {
async function send(uri, params, options = {}) {
if (process.env.NODE_ENV !== 'production') {
return new Promise(resolve => {
return resolve({statusCode: 200, message: 'Fake notification sent'});
return resolve({
body: JSON.stringify(
{statusCode: 200, message: 'Fake notification sent'}
)
});
});
}
const defaultOptions = {
method: 'POST',
uri: uri,
body: body,
headers: {'content-type': 'application/json'},
json: true
body: params
};
if (options) Object.assign(defaultOptions, options);
return request(defaultOptions);
return got.post(uri, defaultOptions);
}
/**
@ -128,7 +138,7 @@ module.exports = Self => {
async function sendAuth(uri, body) {
const login = await getAuthToken();
const options = {
headers: {'content-type': 'application/json'}
headers: {}
};
if (login) {

View File

@ -7,7 +7,8 @@ module.exports = Self => {
type: 'Number',
required: true,
description: 'The worker id of the destinatary'
}, {
},
{
arg: 'message',
type: 'String',
required: true,

View File

@ -1,7 +1,7 @@
import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer';
describe('Client Edit billing data path', () => {
fdescribe('Client Edit billing data path', () => {
let browser;
let page;
beforeAll(async() => {

View File

@ -1,4 +1,5 @@
import '@babel/polyfill';
import 'core-js/stable';
import 'regenerator-runtime/runtime';
import * as ng from 'angular';
export {ng};

3297
front/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,6 @@
"url": "https://gitea.verdnatura.es/verdnatura/salix"
},
"dependencies": {
"@babel/polyfill": "^7.2.5",
"@uirouter/angularjs": "^1.0.20",
"angular": "^1.7.5",
"angular-animate": "^1.7.8",
@ -17,7 +16,6 @@
"angular-translate-loader-partial": "^2.18.1",
"js-yaml": "^3.13.1",
"mg-crud": "^1.1.2",
"npm": "^6.11.3",
"oclazyload": "^0.6.3",
"require-yaml": "0.0.1",
"validator": "^6.3.0"

View File

@ -3,7 +3,7 @@ const gulp = require('gulp');
const PluginError = require('plugin-error');
const argv = require('minimist')(process.argv.slice(2));
const log = require('fancy-log');
const request = require('request');
const got = require('got');
const e2eConfig = require('./e2e/helpers/config.js');
const Docker = require('./db/docker.js');
@ -143,8 +143,9 @@ backTest.description = `Watches for changes in modules to execute backTest task`
// End to end tests
function e2eSingleRun() {
require('@babel/register')({presets: ['@babel/preset-env']});
require('@babel/polyfill');
require('@babel/register')({presets: ['@babel/env']});
require('core-js/stable');
require('regenerator-runtime/runtime');
const jasmine = require('gulp-jasmine');
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
@ -224,17 +225,20 @@ async function backendStatus() {
return new Promise(resolve => {
let timer;
let attempts = 1;
timer = setInterval(() => {
const url = `${e2eConfig.url}/api/Applications/status`;
request.get(url, (err, res) => {
if (err || attempts > 100) // 250ms * 100 => 25s timeout
throw new Error('Could not connect to backend');
else if (res && res.body == 'true') {
timer = setInterval(async() => {
try {
const url = `${e2eConfig.url}/api/Applications/status`;
const {body} = await got.get(url);
if (body == 'true') {
clearInterval(timer);
resolve(attempts);
} else
attempts++;
});
} catch (error) {
if (error || attempts > 100) // 250ms * 100 => 25s timeout
throw new Error('Could not connect to backend');
}
}, milliseconds);
});
}

View File

@ -1,4 +1,4 @@
const request = require('request-promise-native');
const got = require('got');
const UserError = require('vn-loopback/util/user-error');
const getFinalState = require('vn-loopback/util/hook').getFinalState;
const isMultiple = require('vn-loopback/util/hook').isMultiple;
@ -299,8 +299,8 @@ module.exports = Self => {
recipientId: instance.id,
recipient: instance.email
};
await request.get(`${origin}/api/email/payment-update`, {
qs: params
await got.get(`${origin}/api/email/payment-update`, {
query: params
});
}
});

46249
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -15,15 +15,16 @@
"bmp-js": "^0.1.0",
"compression": "^1.7.3",
"fs-extra": "^5.0.0",
"got": "^6.7.1",
"helmet": "^3.21.2",
"i18n": "^0.8.4",
"image-type": "^4.1.0",
"imap": "^0.8.19",
"ldapjs": "^2.2.0",
"loopback": "^3.26.0",
"loopback-boot": "^2.27.1",
"loopback-boot": "3.3.1",
"loopback-component-explorer": "^6.5.0",
"loopback-component-storage": "^3.6.1",
"loopback-component-storage": "3.6.1",
"loopback-connector-mysql": "^5.4.3",
"loopback-connector-remote": "^3.4.1",
"loopback-context": "^3.4.0",
@ -34,8 +35,6 @@
"object.pick": "^1.3.0",
"puppeteer": "^7.1.0",
"read-chunk": "^3.2.0",
"request": "^2.88.0",
"request-promise-native": "^1.0.8",
"require-yaml": "0.0.1",
"sharp": "^0.27.1",
"smbhash": "0.0.1",
@ -48,13 +47,12 @@
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
"@babel/polyfill": "^7.7.0",
"@babel/preset-env": "^7.11.0",
"@babel/register": "^7.7.7",
"angular-mocks": "^1.7.9",
"babel-jest": "^26.0.1",
"babel-loader": "^8.0.6",
"babel-preset-es2015": "^6.24.1",
"core-js": "^3.9.1",
"css-loader": "^2.1.0",
"del": "^2.2.2",
"eslint": "^7.11.0",
@ -90,6 +88,7 @@
"nodemon": "^1.19.4",
"plugin-error": "^1.0.1",
"raw-loader": "^1.0.0",
"regenerator-runtime": "^0.13.7",
"sass-loader": "^7.3.1",
"style-loader": "^0.23.1",
"webpack": "^4.41.5",

View File

@ -6,6 +6,10 @@ const config = require('../core/config');
module.exports = app => {
app.get('/api/closure/all', async function(req, res, next) {
try {
const reqArgs = req.args;
if (!reqArgs.to)
throw new Error('The argument to is required');
res.status(200).json({
message: 'Task executed successfully'
});
@ -19,9 +23,12 @@ module.exports = app => {
JOIN ticketState ts ON ts.ticketFk = t.id
JOIN alertLevel al ON al.alertLevel = ts.alertLevel
WHERE al.code = 'PACKED'
AND DATE(t.shipped) BETWEEN DATE_ADD(CURDATE(), INTERVAL -2 DAY) AND CURDATE()
AND DATE(t.shipped) BETWEEN DATE_ADD(:to, INTERVAL -2 DAY)
AND util.dayEnd(:to)
AND t.refFk IS NULL
GROUP BY e.ticketFk`);
GROUP BY e.ticketFk`, {
to: reqArgs.to
});
const ticketIds = tickets.map(ticket => ticket.id);
await closeAll(ticketIds, req.args);
@ -33,10 +40,13 @@ module.exports = app => {
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
JOIN zone z ON z.id = t.zoneFk
SET t.routeFk = NULL
WHERE shipped BETWEEN CURDATE() AND util.dayEnd(CURDATE())
WHERE DATE(t.shipped) BETWEEN DATE_ADD(:to, INTERVAL -2 DAY)
AND util.dayEnd(:to)
AND al.code NOT IN('DELIVERED','PACKED')
AND t.routeFk
AND z.name LIKE '%MADRID%'`);
AND z.name LIKE '%MADRID%'`, {
to: reqArgs.to
});
} catch (error) {
next(error);
}
@ -100,7 +110,8 @@ module.exports = app => {
WHERE al.code = 'PACKED'
AND t.agencyModeFk IN(:agencyModeId)
AND t.warehouseFk = :warehouseId
AND DATE(t.shipped) BETWEEN DATE_ADD(:to, INTERVAL -2 DAY) AND :to
AND DATE(t.shipped) BETWEEN DATE_ADD(:to, INTERVAL -2 DAY)
AND util.dayEnd(:to)
AND t.refFk IS NULL
GROUP BY e.ticketFk`, {
agencyModeId: agenciesId,

2896
print/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,6 @@
"license": "GPL-3.0",
"dependencies": {
"fs-extra": "^7.0.1",
"html-pdf": "^2.2.0",
"intl": "^1.2.5",
"js-yaml": "^3.13.1",
"juice": "^5.2.0",