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
|
||||
|
||||
### 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.
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -69,15 +69,15 @@ module.exports = Self => {
|
|||
|
||||
const result = response.headers.get('set-cookie');
|
||||
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 dom = new jsdom.JSDOM(body);
|
||||
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 = {
|
||||
__CSRFToken__: token,
|
||||
do: 'scplogin',
|
||||
|
@ -90,21 +90,18 @@ module.exports = Self => {
|
|||
body: new URLSearchParams(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Cookie': firtCookie
|
||||
'Cookie': cookie
|
||||
}
|
||||
};
|
||||
const response = await fetch(ostUri, params);
|
||||
const result = response.headers.get('set-cookie');
|
||||
const [firtHeader] = result.split(' ');
|
||||
const secondCookie = firtHeader.substring(0, firtHeader.length - 1);
|
||||
await fetch(ostUri, params);
|
||||
|
||||
await close(token, secondCookie);
|
||||
await close(token, cookie);
|
||||
}
|
||||
|
||||
async function close(token, secondCookie) {
|
||||
async function close(token, cookie) {
|
||||
for (const ticketId of ticketsId) {
|
||||
try {
|
||||
const lock = await getLockCode(token, secondCookie, ticketId);
|
||||
const lock = await getLockCode(token, cookie, ticketId);
|
||||
if (!lock.code) {
|
||||
let error = `Can't get lock code`;
|
||||
if (lock.msg) error += `: ${lock.msg}`;
|
||||
|
@ -127,7 +124,7 @@ module.exports = Self => {
|
|||
method: 'POST',
|
||||
body: form,
|
||||
headers: {
|
||||
'Cookie': secondCookie
|
||||
'Cookie': cookie
|
||||
}
|
||||
};
|
||||
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 params = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRFToken': token,
|
||||
'Cookie': secondCookie
|
||||
'Cookie': cookie
|
||||
}
|
||||
};
|
||||
const response = await fetch(ostUri, params);
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
const mysql = require('mysql');
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const MySQL = require('loopback-connector-mysql').MySQL;
|
||||
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 limitSet = new Set([
|
||||
|
@ -254,49 +253,49 @@ class VnMySQL extends MySQL {
|
|||
}
|
||||
|
||||
create(model, data, opts, cb) {
|
||||
const ctx = {data};
|
||||
const ctx = { data };
|
||||
this.invokeMethod('create',
|
||||
arguments, model, ctx, opts, cb);
|
||||
}
|
||||
|
||||
createAll(model, data, opts, cb) {
|
||||
const ctx = {data};
|
||||
const ctx = { data };
|
||||
this.invokeMethod('createAll',
|
||||
arguments, model, ctx, opts, cb);
|
||||
}
|
||||
|
||||
save(model, data, opts, cb) {
|
||||
const ctx = {data};
|
||||
const ctx = { data };
|
||||
this.invokeMethod('save',
|
||||
arguments, model, ctx, opts, cb);
|
||||
}
|
||||
|
||||
updateOrCreate(model, data, opts, cb) {
|
||||
const ctx = {data};
|
||||
const ctx = { data };
|
||||
this.invokeMethod('updateOrCreate',
|
||||
arguments, model, ctx, opts, cb);
|
||||
}
|
||||
|
||||
replaceOrCreate(model, data, opts, cb) {
|
||||
const ctx = {data};
|
||||
const ctx = { data };
|
||||
this.invokeMethod('replaceOrCreate',
|
||||
arguments, model, ctx, opts, cb);
|
||||
}
|
||||
|
||||
destroyAll(model, where, opts, cb) {
|
||||
const ctx = {where};
|
||||
const ctx = { where };
|
||||
this.invokeMethod('destroyAll',
|
||||
arguments, model, ctx, opts, cb);
|
||||
}
|
||||
|
||||
update(model, where, data, opts, cb) {
|
||||
const ctx = {where, data};
|
||||
const ctx = { where, data };
|
||||
this.invokeMethod('update',
|
||||
arguments, model, ctx, opts, cb);
|
||||
}
|
||||
|
||||
replaceById(model, id, data, opts, cb) {
|
||||
const ctx = {id, data};
|
||||
const ctx = { id, data };
|
||||
this.invokeMethod('replaceById',
|
||||
arguments, model, ctx, opts, cb);
|
||||
}
|
||||
|
@ -321,16 +320,16 @@ class VnMySQL extends MySQL {
|
|||
let tx;
|
||||
if (!opts.transaction) {
|
||||
tx = await Transaction.begin(this, {});
|
||||
opts = Object.assign({transaction: tx, httpCtx: opts.httpCtx}, opts);
|
||||
opts = Object.assign({ transaction: tx, httpCtx: opts.httpCtx }, opts);
|
||||
}
|
||||
|
||||
try {
|
||||
// Fetch old values (update|delete) or login
|
||||
let where, id, data, idName, limit, op, oldInstances, newInstances;
|
||||
const hasGrabUser = settings.log && settings.log.grabUser;
|
||||
if(hasGrabUser){
|
||||
if (hasGrabUser) {
|
||||
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);
|
||||
}
|
||||
else {
|
||||
|
@ -344,18 +343,18 @@ class VnMySQL extends MySQL {
|
|||
op = opMap.get(method);
|
||||
|
||||
if (!where) {
|
||||
if (id) where = {[idName]: id};
|
||||
else where = {[idName]: data[idName]};
|
||||
if (id) where = { [idName]: id };
|
||||
else where = { [idName]: data[idName] };
|
||||
}
|
||||
|
||||
// Fetch old values
|
||||
switch (op) {
|
||||
case 'update':
|
||||
case 'delete':
|
||||
// Single entity operation
|
||||
const stmt = this.buildSelectStmt(op, data, idName, model, where, limit);
|
||||
stmt.merge(`FOR UPDATE`);
|
||||
oldInstances = await this.executeStmt(stmt, opts);
|
||||
case 'update':
|
||||
case 'delete':
|
||||
// Single entity operation
|
||||
const stmt = this.buildSelectStmt(op, data, idName, model, where, limit);
|
||||
stmt.merge(`FOR UPDATE`);
|
||||
oldInstances = await this.executeStmt(stmt, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,30 +364,30 @@ class VnMySQL extends MySQL {
|
|||
super[method].apply(this, fnArgs);
|
||||
});
|
||||
|
||||
if(hasGrabUser)
|
||||
if (hasGrabUser)
|
||||
await this.executeP(`CALL account.myUser_logout()`, null, opts);
|
||||
else {
|
||||
// Fetch new values
|
||||
const ids = [];
|
||||
|
||||
switch (op) {
|
||||
case 'insert':
|
||||
case 'update': {
|
||||
case 'insert':
|
||||
case 'update': {
|
||||
switch (method) {
|
||||
case 'createAll':
|
||||
for (const row of res[1])
|
||||
ids.push(row[idName]);
|
||||
break;
|
||||
case 'create':
|
||||
ids.push(res[1]);
|
||||
break;
|
||||
case 'update':
|
||||
if (data[idName] != null)
|
||||
ids.push(data[idName]);
|
||||
break;
|
||||
case 'createAll':
|
||||
for (const row of res[1])
|
||||
ids.push(row[idName]);
|
||||
break;
|
||||
case 'create':
|
||||
ids.push(res[1]);
|
||||
break;
|
||||
case 'update':
|
||||
if (data[idName] != null)
|
||||
ids.push(data[idName]);
|
||||
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);
|
||||
newInstances = await this.executeStmt(stmt, opts);
|
||||
|
@ -431,9 +430,9 @@ class VnMySQL extends MySQL {
|
|||
|
||||
const stmt = new ParameterizedSQL(
|
||||
'SELECT ' +
|
||||
this.buildColumnNames(model, {fields}) +
|
||||
' FROM ' +
|
||||
this.tableEscaped(model)
|
||||
this.buildColumnNames(model, { fields }) +
|
||||
' FROM ' +
|
||||
this.tableEscaped(model)
|
||||
);
|
||||
stmt.merge(this.buildWhere(model, where));
|
||||
if (limit) stmt.merge(`LIMIT 1`);
|
||||
|
@ -505,8 +504,8 @@ class VnMySQL extends MySQL {
|
|||
if (oldI) {
|
||||
Object.keys(oldI).forEach(prop => {
|
||||
const hasChanges = oldI[prop] instanceof Date ?
|
||||
oldI[prop]?.getTime() != newI[prop]?.getTime() :
|
||||
oldI[prop] != newI[prop];
|
||||
oldI[prop]?.getTime() != newI[prop]?.getTime() :
|
||||
oldI[prop] != newI[prop];
|
||||
|
||||
if (!hasChanges) {
|
||||
delete oldI[prop];
|
||||
|
@ -537,13 +536,13 @@ exports.initialize = function initialize(dataSource, callback) {
|
|||
modelBuilder.defineValueType.bind(modelBuilder) :
|
||||
modelBuilder.constructor.registerType.bind(modelBuilder.constructor);
|
||||
|
||||
defineType(function Point() {});
|
||||
defineType(function Point() { });
|
||||
|
||||
dataSource.EnumFactory = EnumFactory;
|
||||
|
||||
if (callback) {
|
||||
if (dataSource.settings.lazyConnect) {
|
||||
process.nextTick(function() {
|
||||
process.nextTick(function () {
|
||||
callback();
|
||||
});
|
||||
} 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 options = generateOptions(this.settings);
|
||||
|
||||
if (this.client) {
|
||||
if (callback) {
|
||||
process.nextTick(function() {
|
||||
process.nextTick(function () {
|
||||
callback(null, self.client);
|
||||
});
|
||||
}
|
||||
|
@ -566,7 +565,7 @@ MySQL.prototype.connect = function(callback) {
|
|||
|
||||
function connectionHandler(options, callback) {
|
||||
const client = mysql.createPool(options);
|
||||
client.getConnection(function(err, connection) {
|
||||
client.getConnection(function (err, connection) {
|
||||
const conn = connection;
|
||||
if (!err) {
|
||||
if (self.debug)
|
||||
|
@ -645,3 +644,31 @@ function generateOptions(settings) {
|
|||
}
|
||||
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};
|
||||
case 'pending':
|
||||
if (value) {
|
||||
return {and: [
|
||||
{'t.alertLevel': 0},
|
||||
{'t.alertLevelCode': {nin: [
|
||||
'OK',
|
||||
'BOARDING',
|
||||
'PRINTED',
|
||||
'PRINTED_AUTO',
|
||||
'PICKER_DESIGNED'
|
||||
]}}
|
||||
]};
|
||||
return {'t.alertLevelCode': {inq: [
|
||||
'FIXING',
|
||||
'FREE',
|
||||
'NOT_READY',
|
||||
'BLOCKED',
|
||||
'EXPANDABLE',
|
||||
'CHAINED',
|
||||
'WAITING_FOR_PAYMENT'
|
||||
]}};
|
||||
} else {
|
||||
return {and: [
|
||||
{'t.alertLevel': {gt: 0}}
|
||||
]};
|
||||
return {'t.alertLevelCode': {inq: [
|
||||
'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 'warehouseFk':
|
||||
|
|
Loading…
Reference in New Issue