Merge branch 'dev' into 5416-supplierAccount_isPayMethodChecked
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
commit
14f64e8efa
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- (Monitor tickets) Muestra un icono al lado de la zona, si el ticket es frágil y se envía por agencia
|
- (Monitor tickets) Muestra un icono al lado de la zona, si el ticket es frágil y se envía por agencia
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
- (Monitor tickets) Cuando se filtra por 'Pendiente' ya no muestra los estados de 'Previa'
|
||||||
- (Envíos -> Extra comunitarios) Se agrupan las entradas del mismo travel. Añadidos campos Referencia y Importe.
|
- (Envíos -> Extra comunitarios) Se agrupan las entradas del mismo travel. Añadidos campos Referencia y Importe.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -69,15 +69,15 @@ module.exports = Self => {
|
||||||
|
|
||||||
const result = response.headers.get('set-cookie');
|
const result = response.headers.get('set-cookie');
|
||||||
const [firtHeader] = result.split(' ');
|
const [firtHeader] = result.split(' ');
|
||||||
const firtCookie = firtHeader.substring(0, firtHeader.length - 1);
|
const cookie = firtHeader.substring(0, firtHeader.length - 1);
|
||||||
const body = await response.text();
|
const body = await response.text();
|
||||||
const dom = new jsdom.JSDOM(body);
|
const dom = new jsdom.JSDOM(body);
|
||||||
const token = dom.window.document.querySelector('[name="__CSRFToken__"]').value;
|
const token = dom.window.document.querySelector('[name="__CSRFToken__"]').value;
|
||||||
|
|
||||||
await login(token, firtCookie);
|
await login(token, cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function login(token, firtCookie) {
|
async function login(token, cookie) {
|
||||||
const data = {
|
const data = {
|
||||||
__CSRFToken__: token,
|
__CSRFToken__: token,
|
||||||
do: 'scplogin',
|
do: 'scplogin',
|
||||||
|
@ -90,21 +90,18 @@ module.exports = Self => {
|
||||||
body: new URLSearchParams(data),
|
body: new URLSearchParams(data),
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||||
'Cookie': firtCookie
|
'Cookie': cookie
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const response = await fetch(ostUri, params);
|
await fetch(ostUri, params);
|
||||||
const result = response.headers.get('set-cookie');
|
|
||||||
const [firtHeader] = result.split(' ');
|
|
||||||
const secondCookie = firtHeader.substring(0, firtHeader.length - 1);
|
|
||||||
|
|
||||||
await close(token, secondCookie);
|
await close(token, cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function close(token, secondCookie) {
|
async function close(token, cookie) {
|
||||||
for (const ticketId of ticketsId) {
|
for (const ticketId of ticketsId) {
|
||||||
try {
|
try {
|
||||||
const lock = await getLockCode(token, secondCookie, ticketId);
|
const lock = await getLockCode(token, cookie, ticketId);
|
||||||
if (!lock.code) {
|
if (!lock.code) {
|
||||||
let error = `Can't get lock code`;
|
let error = `Can't get lock code`;
|
||||||
if (lock.msg) error += `: ${lock.msg}`;
|
if (lock.msg) error += `: ${lock.msg}`;
|
||||||
|
@ -127,7 +124,7 @@ module.exports = Self => {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: form,
|
body: form,
|
||||||
headers: {
|
headers: {
|
||||||
'Cookie': secondCookie
|
'Cookie': cookie
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
await fetch(ostUri, params);
|
await fetch(ostUri, params);
|
||||||
|
@ -139,13 +136,13 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getLockCode(token, secondCookie, ticketId) {
|
async function getLockCode(token, cookie, ticketId) {
|
||||||
const ostUri = `${config.host}/ajax.php/lock/ticket/${ticketId}`;
|
const ostUri = `${config.host}/ajax.php/lock/ticket/${ticketId}`;
|
||||||
const params = {
|
const params = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRFToken': token,
|
'X-CSRFToken': token,
|
||||||
'Cookie': secondCookie
|
'Cookie': cookie
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const response = await fetch(ostUri, params);
|
const response = await fetch(ostUri, params);
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
const mysql = require('mysql');
|
const mysql = require('mysql');
|
||||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
|
||||||
const MySQL = require('loopback-connector-mysql').MySQL;
|
const MySQL = require('loopback-connector-mysql').MySQL;
|
||||||
const EnumFactory = require('loopback-connector-mysql').EnumFactory;
|
const EnumFactory = require('loopback-connector-mysql').EnumFactory;
|
||||||
const Transaction = require('loopback-connector').Transaction;
|
const { Transaction, SQLConnector, ParameterizedSQL } = require('loopback-connector');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const limitSet = new Set([
|
const limitSet = new Set([
|
||||||
|
@ -254,49 +253,49 @@ class VnMySQL extends MySQL {
|
||||||
}
|
}
|
||||||
|
|
||||||
create(model, data, opts, cb) {
|
create(model, data, opts, cb) {
|
||||||
const ctx = {data};
|
const ctx = { data };
|
||||||
this.invokeMethod('create',
|
this.invokeMethod('create',
|
||||||
arguments, model, ctx, opts, cb);
|
arguments, model, ctx, opts, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
createAll(model, data, opts, cb) {
|
createAll(model, data, opts, cb) {
|
||||||
const ctx = {data};
|
const ctx = { data };
|
||||||
this.invokeMethod('createAll',
|
this.invokeMethod('createAll',
|
||||||
arguments, model, ctx, opts, cb);
|
arguments, model, ctx, opts, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
save(model, data, opts, cb) {
|
save(model, data, opts, cb) {
|
||||||
const ctx = {data};
|
const ctx = { data };
|
||||||
this.invokeMethod('save',
|
this.invokeMethod('save',
|
||||||
arguments, model, ctx, opts, cb);
|
arguments, model, ctx, opts, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateOrCreate(model, data, opts, cb) {
|
updateOrCreate(model, data, opts, cb) {
|
||||||
const ctx = {data};
|
const ctx = { data };
|
||||||
this.invokeMethod('updateOrCreate',
|
this.invokeMethod('updateOrCreate',
|
||||||
arguments, model, ctx, opts, cb);
|
arguments, model, ctx, opts, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceOrCreate(model, data, opts, cb) {
|
replaceOrCreate(model, data, opts, cb) {
|
||||||
const ctx = {data};
|
const ctx = { data };
|
||||||
this.invokeMethod('replaceOrCreate',
|
this.invokeMethod('replaceOrCreate',
|
||||||
arguments, model, ctx, opts, cb);
|
arguments, model, ctx, opts, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyAll(model, where, opts, cb) {
|
destroyAll(model, where, opts, cb) {
|
||||||
const ctx = {where};
|
const ctx = { where };
|
||||||
this.invokeMethod('destroyAll',
|
this.invokeMethod('destroyAll',
|
||||||
arguments, model, ctx, opts, cb);
|
arguments, model, ctx, opts, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
update(model, where, data, opts, cb) {
|
update(model, where, data, opts, cb) {
|
||||||
const ctx = {where, data};
|
const ctx = { where, data };
|
||||||
this.invokeMethod('update',
|
this.invokeMethod('update',
|
||||||
arguments, model, ctx, opts, cb);
|
arguments, model, ctx, opts, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceById(model, id, data, opts, cb) {
|
replaceById(model, id, data, opts, cb) {
|
||||||
const ctx = {id, data};
|
const ctx = { id, data };
|
||||||
this.invokeMethod('replaceById',
|
this.invokeMethod('replaceById',
|
||||||
arguments, model, ctx, opts, cb);
|
arguments, model, ctx, opts, cb);
|
||||||
}
|
}
|
||||||
|
@ -321,16 +320,16 @@ class VnMySQL extends MySQL {
|
||||||
let tx;
|
let tx;
|
||||||
if (!opts.transaction) {
|
if (!opts.transaction) {
|
||||||
tx = await Transaction.begin(this, {});
|
tx = await Transaction.begin(this, {});
|
||||||
opts = Object.assign({transaction: tx, httpCtx: opts.httpCtx}, opts);
|
opts = Object.assign({ transaction: tx, httpCtx: opts.httpCtx }, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fetch old values (update|delete) or login
|
// Fetch old values (update|delete) or login
|
||||||
let where, id, data, idName, limit, op, oldInstances, newInstances;
|
let where, id, data, idName, limit, op, oldInstances, newInstances;
|
||||||
const hasGrabUser = settings.log && settings.log.grabUser;
|
const hasGrabUser = settings.log && settings.log.grabUser;
|
||||||
if(hasGrabUser){
|
if (hasGrabUser) {
|
||||||
const userId = opts.httpCtx && opts.httpCtx.active.accessToken.userId;
|
const userId = opts.httpCtx && opts.httpCtx.active.accessToken.userId;
|
||||||
const user = await Model.app.models.Account.findById(userId, {fields: ['name']}, opts);
|
const user = await Model.app.models.Account.findById(userId, { fields: ['name'] }, opts);
|
||||||
await this.executeP(`CALL account.myUser_loginWithName(?)`, [user.name], opts);
|
await this.executeP(`CALL account.myUser_loginWithName(?)`, [user.name], opts);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -344,18 +343,18 @@ class VnMySQL extends MySQL {
|
||||||
op = opMap.get(method);
|
op = opMap.get(method);
|
||||||
|
|
||||||
if (!where) {
|
if (!where) {
|
||||||
if (id) where = {[idName]: id};
|
if (id) where = { [idName]: id };
|
||||||
else where = {[idName]: data[idName]};
|
else where = { [idName]: data[idName] };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch old values
|
// Fetch old values
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case 'update':
|
case 'update':
|
||||||
case 'delete':
|
case 'delete':
|
||||||
// Single entity operation
|
// Single entity operation
|
||||||
const stmt = this.buildSelectStmt(op, data, idName, model, where, limit);
|
const stmt = this.buildSelectStmt(op, data, idName, model, where, limit);
|
||||||
stmt.merge(`FOR UPDATE`);
|
stmt.merge(`FOR UPDATE`);
|
||||||
oldInstances = await this.executeStmt(stmt, opts);
|
oldInstances = await this.executeStmt(stmt, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,30 +364,30 @@ class VnMySQL extends MySQL {
|
||||||
super[method].apply(this, fnArgs);
|
super[method].apply(this, fnArgs);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(hasGrabUser)
|
if (hasGrabUser)
|
||||||
await this.executeP(`CALL account.myUser_logout()`, null, opts);
|
await this.executeP(`CALL account.myUser_logout()`, null, opts);
|
||||||
else {
|
else {
|
||||||
// Fetch new values
|
// Fetch new values
|
||||||
const ids = [];
|
const ids = [];
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case 'insert':
|
case 'insert':
|
||||||
case 'update': {
|
case 'update': {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case 'createAll':
|
case 'createAll':
|
||||||
for (const row of res[1])
|
for (const row of res[1])
|
||||||
ids.push(row[idName]);
|
ids.push(row[idName]);
|
||||||
break;
|
break;
|
||||||
case 'create':
|
case 'create':
|
||||||
ids.push(res[1]);
|
ids.push(res[1]);
|
||||||
break;
|
break;
|
||||||
case 'update':
|
case 'update':
|
||||||
if (data[idName] != null)
|
if (data[idName] != null)
|
||||||
ids.push(data[idName]);
|
ids.push(data[idName]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newWhere = ids.length ? {[idName]: ids} : where;
|
const newWhere = ids.length ? { [idName]: ids } : where;
|
||||||
|
|
||||||
const stmt = this.buildSelectStmt(op, data, idName, model, newWhere, limit);
|
const stmt = this.buildSelectStmt(op, data, idName, model, newWhere, limit);
|
||||||
newInstances = await this.executeStmt(stmt, opts);
|
newInstances = await this.executeStmt(stmt, opts);
|
||||||
|
@ -431,9 +430,9 @@ class VnMySQL extends MySQL {
|
||||||
|
|
||||||
const stmt = new ParameterizedSQL(
|
const stmt = new ParameterizedSQL(
|
||||||
'SELECT ' +
|
'SELECT ' +
|
||||||
this.buildColumnNames(model, {fields}) +
|
this.buildColumnNames(model, { fields }) +
|
||||||
' FROM ' +
|
' FROM ' +
|
||||||
this.tableEscaped(model)
|
this.tableEscaped(model)
|
||||||
);
|
);
|
||||||
stmt.merge(this.buildWhere(model, where));
|
stmt.merge(this.buildWhere(model, where));
|
||||||
if (limit) stmt.merge(`LIMIT 1`);
|
if (limit) stmt.merge(`LIMIT 1`);
|
||||||
|
@ -505,8 +504,8 @@ class VnMySQL extends MySQL {
|
||||||
if (oldI) {
|
if (oldI) {
|
||||||
Object.keys(oldI).forEach(prop => {
|
Object.keys(oldI).forEach(prop => {
|
||||||
const hasChanges = oldI[prop] instanceof Date ?
|
const hasChanges = oldI[prop] instanceof Date ?
|
||||||
oldI[prop]?.getTime() != newI[prop]?.getTime() :
|
oldI[prop]?.getTime() != newI[prop]?.getTime() :
|
||||||
oldI[prop] != newI[prop];
|
oldI[prop] != newI[prop];
|
||||||
|
|
||||||
if (!hasChanges) {
|
if (!hasChanges) {
|
||||||
delete oldI[prop];
|
delete oldI[prop];
|
||||||
|
@ -537,13 +536,13 @@ exports.initialize = function initialize(dataSource, callback) {
|
||||||
modelBuilder.defineValueType.bind(modelBuilder) :
|
modelBuilder.defineValueType.bind(modelBuilder) :
|
||||||
modelBuilder.constructor.registerType.bind(modelBuilder.constructor);
|
modelBuilder.constructor.registerType.bind(modelBuilder.constructor);
|
||||||
|
|
||||||
defineType(function Point() {});
|
defineType(function Point() { });
|
||||||
|
|
||||||
dataSource.EnumFactory = EnumFactory;
|
dataSource.EnumFactory = EnumFactory;
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
if (dataSource.settings.lazyConnect) {
|
if (dataSource.settings.lazyConnect) {
|
||||||
process.nextTick(function() {
|
process.nextTick(function () {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
} else
|
} else
|
||||||
|
@ -551,13 +550,13 @@ exports.initialize = function initialize(dataSource, callback) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MySQL.prototype.connect = function(callback) {
|
MySQL.prototype.connect = function (callback) {
|
||||||
const self = this;
|
const self = this;
|
||||||
const options = generateOptions(this.settings);
|
const options = generateOptions(this.settings);
|
||||||
|
|
||||||
if (this.client) {
|
if (this.client) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
process.nextTick(function() {
|
process.nextTick(function () {
|
||||||
callback(null, self.client);
|
callback(null, self.client);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -566,7 +565,7 @@ MySQL.prototype.connect = function(callback) {
|
||||||
|
|
||||||
function connectionHandler(options, callback) {
|
function connectionHandler(options, callback) {
|
||||||
const client = mysql.createPool(options);
|
const client = mysql.createPool(options);
|
||||||
client.getConnection(function(err, connection) {
|
client.getConnection(function (err, connection) {
|
||||||
const conn = connection;
|
const conn = connection;
|
||||||
if (!err) {
|
if (!err) {
|
||||||
if (self.debug)
|
if (self.debug)
|
||||||
|
@ -645,3 +644,31 @@ function generateOptions(settings) {
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SQLConnector.prototype.all = function find(model, filter, options, cb) {
|
||||||
|
const self = this;
|
||||||
|
// Order by id if no order is specified
|
||||||
|
filter = filter || {};
|
||||||
|
const stmt = this.buildSelect(model, filter, options);
|
||||||
|
this.execute(stmt.sql, stmt.params, options, function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
return cb(err, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const objs = data.map(function (obj) {
|
||||||
|
return self.fromRow(model, obj);
|
||||||
|
});
|
||||||
|
if (filter && filter.include) {
|
||||||
|
self.getModelDefinition(model).model.include(
|
||||||
|
objs, filter.include, options, cb,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
cb(null, objs);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
cb(error, [])
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
|
@ -367,20 +367,37 @@ module.exports = Self => {
|
||||||
return {'t.alertLevel': value};
|
return {'t.alertLevel': value};
|
||||||
case 'pending':
|
case 'pending':
|
||||||
if (value) {
|
if (value) {
|
||||||
return {and: [
|
return {'t.alertLevelCode': {inq: [
|
||||||
{'t.alertLevel': 0},
|
'FIXING',
|
||||||
{'t.alertLevelCode': {nin: [
|
'FREE',
|
||||||
'OK',
|
'NOT_READY',
|
||||||
'BOARDING',
|
'BLOCKED',
|
||||||
'PRINTED',
|
'EXPANDABLE',
|
||||||
'PRINTED_AUTO',
|
'CHAINED',
|
||||||
'PICKER_DESIGNED'
|
'WAITING_FOR_PAYMENT'
|
||||||
]}}
|
]}};
|
||||||
]};
|
|
||||||
} else {
|
} else {
|
||||||
return {and: [
|
return {'t.alertLevelCode': {inq: [
|
||||||
{'t.alertLevel': {gt: 0}}
|
'ON_PREPARATION',
|
||||||
]};
|
'ON_CHECKING',
|
||||||
|
'CHECKED',
|
||||||
|
'PACKING',
|
||||||
|
'PACKED',
|
||||||
|
'INVOICED',
|
||||||
|
'ON_DELIVERY',
|
||||||
|
'PREPARED',
|
||||||
|
'WAITING_FOR_PICKUP',
|
||||||
|
'DELIVERED',
|
||||||
|
'PRINTED_BACK',
|
||||||
|
'LAST_CALL',
|
||||||
|
'PREVIOUS_PREPARATION',
|
||||||
|
'ASSISTED_PREPARATION',
|
||||||
|
'BOARD',
|
||||||
|
'PRINTED STOWAWAY',
|
||||||
|
'OK STOWAWAY',
|
||||||
|
'HALF_PACKED',
|
||||||
|
'COOLER_PREPARATION'
|
||||||
|
]}};
|
||||||
}
|
}
|
||||||
case 'agencyModeFk':
|
case 'agencyModeFk':
|
||||||
case 'warehouseFk':
|
case 'warehouseFk':
|
||||||
|
|
Loading…
Reference in New Issue