Merge branch 'dev' into 5660-changeRolDeliveryAssistant
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
f92acdfe6f
|
@ -1013,7 +1013,7 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
|
||||||
(4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
(4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
||||||
(5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
(5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
||||||
(6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
|
(6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
|
||||||
(7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.44, 0, 0, 0, util.VN_CURDATE()),
|
(7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE()),
|
||||||
(8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE()),
|
(8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE()),
|
||||||
(9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
|
(9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
|
||||||
(10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE()),
|
(10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE()),
|
||||||
|
@ -2974,5 +2974,3 @@ INSERT INTO vn.XDiario (id, ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EU
|
||||||
(4, 2.0, util.VN_CURDATE(), '4300001104', NULL, 'n/fra T4444444', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0),
|
(4, 2.0, util.VN_CURDATE(), '4300001104', NULL, 'n/fra T4444444', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0),
|
||||||
(5, 2.0, util.VN_CURDATE(), '2000000000', '4300001104', 'n/fra T4444444 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0),
|
(5, 2.0, util.VN_CURDATE(), '2000000000', '4300001104', 'n/fra T4444444 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0),
|
||||||
(6, 2.0, util.VN_CURDATE(), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T4444444 Tony Stark', NULL, 0.81, 8.07, 'T', '4444444', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0);
|
(6, 2.0, util.VN_CURDATE(), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T4444444 Tony Stark', NULL, 0.81, 8.07, 'T', '4444444', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0);
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@ describe('item_getBalance()', () => {
|
||||||
let stmts = [];
|
let stmts = [];
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
warehouseFk: 1,
|
itemFk: 1,
|
||||||
itemFk: 1
|
warehouseFk: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
const conn = await app.models.Item.dataSource.connector;
|
const conn = await app.models.Item.dataSource.connector;
|
||||||
|
|
||||||
stmts.push(new ParameterizedSQL('CALL vn.item_getBalance(?, ?)', [
|
stmts.push(new ParameterizedSQL('CALL vn.item_getBalance(?, ?, NULL)', [
|
||||||
params.warehouseFk,
|
params.warehouseFk,
|
||||||
params.itemFk
|
params.itemFk
|
||||||
]));
|
]));
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
const app = require('vn-loopback/server/server');
|
|
||||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
|
||||||
|
|
||||||
describe('logAddWithUser()', () => {
|
|
||||||
it('should log any action taken by the user in a table ending in Log', async() => {
|
|
||||||
let stmts = [];
|
|
||||||
let stmt;
|
|
||||||
|
|
||||||
stmts.push('START TRANSACTION');
|
|
||||||
|
|
||||||
let params = {
|
|
||||||
ticketFk: 1,
|
|
||||||
userId: 9,
|
|
||||||
actionCode: 'update',
|
|
||||||
targetEntity: 'ticket',
|
|
||||||
description: 'we are testing stuff'
|
|
||||||
};
|
|
||||||
|
|
||||||
stmt = new ParameterizedSQL('CALL vn.logAddWithUser(?, ?, ?, ?, ?)', [
|
|
||||||
params.ticketFk,
|
|
||||||
params.userId,
|
|
||||||
params.actionCode,
|
|
||||||
params.targetEntity,
|
|
||||||
params.description
|
|
||||||
]);
|
|
||||||
stmts.push(stmt);
|
|
||||||
|
|
||||||
stmt = new ParameterizedSQL('SELECT * FROM vn.ticketLog WHERE description = ?', [
|
|
||||||
params.description
|
|
||||||
]);
|
|
||||||
let ticketLogIndex = stmts.push(stmt) - 1;
|
|
||||||
|
|
||||||
stmts.push('ROLLBACK');
|
|
||||||
|
|
||||||
let sql = ParameterizedSQL.join(stmts, ';');
|
|
||||||
let result = await app.models.Ticket.rawStmt(sql);
|
|
||||||
|
|
||||||
savedDescription = result[ticketLogIndex][0].description;
|
|
||||||
|
|
||||||
expect(savedDescription).toEqual(params.description);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -14,14 +14,6 @@ describe('timeControl_calculateByUser()', () => {
|
||||||
let stmts = [];
|
let stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
|
|
||||||
stmts.push('START TRANSACTION');
|
|
||||||
|
|
||||||
stmts.push(`
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS
|
|
||||||
tmp.timeControlCalculate,
|
|
||||||
tmp.timeBusinessCalculate
|
|
||||||
`);
|
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
workerID: 1106,
|
workerID: 1106,
|
||||||
start: start,
|
start: start,
|
||||||
|
@ -37,17 +29,15 @@ describe('timeControl_calculateByUser()', () => {
|
||||||
|
|
||||||
let tableIndex = stmts.push('SELECT * FROM tmp.timeControlCalculate') - 1;
|
let tableIndex = stmts.push('SELECT * FROM tmp.timeControlCalculate') - 1;
|
||||||
|
|
||||||
stmts.push('ROLLBACK');
|
|
||||||
|
|
||||||
let sql = ParameterizedSQL.join(stmts, ';');
|
let sql = ParameterizedSQL.join(stmts, ';');
|
||||||
let result = await app.models.Ticket.rawStmt(sql);
|
let result = await app.models.Ticket.rawStmt(sql);
|
||||||
|
|
||||||
let [timeControlCalculateTable] = result[tableIndex];
|
let [timeControlCalculateTable] = result[tableIndex];
|
||||||
|
|
||||||
expect(timeControlCalculateTable.timeWorkSeconds).toEqual(29400);
|
expect(timeControlCalculateTable.timeWorkSeconds).toEqual(28200);
|
||||||
});
|
});
|
||||||
|
// #2261
|
||||||
it(`should return the worked hours between last sunday and monday`, async() => {
|
xit(`should return the worked hours between last sunday and monday`, async() => {
|
||||||
let lastSunday = Date.vnNew();
|
let lastSunday = Date.vnNew();
|
||||||
let daysSinceSunday = lastSunday.getDay();
|
let daysSinceSunday = lastSunday.getDay();
|
||||||
if (daysSinceSunday === 0) // this means today is sunday but you need the previous sunday :)
|
if (daysSinceSunday === 0) // this means today is sunday but you need the previous sunday :)
|
||||||
|
@ -65,13 +55,7 @@ describe('timeControl_calculateByUser()', () => {
|
||||||
|
|
||||||
stmts.push('START TRANSACTION');
|
stmts.push('START TRANSACTION');
|
||||||
|
|
||||||
stmts.push(`
|
const workerID = 1108;
|
||||||
DROP TEMPORARY TABLE IF EXISTS
|
|
||||||
tmp.timeControlCalculate,
|
|
||||||
tmp.timeBusinessCalculate
|
|
||||||
`);
|
|
||||||
|
|
||||||
const workerID = 1107;
|
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`
|
||||||
INSERT INTO vn.workerTimeControl(userFk, timed, manual, direction)
|
INSERT INTO vn.workerTimeControl(userFk, timed, manual, direction)
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe('zone zone_getFromGeo()', () => {
|
||||||
let stmt;
|
let stmt;
|
||||||
|
|
||||||
stmts.push('START TRANSACTION');
|
stmts.push('START TRANSACTION');
|
||||||
let geoFk = 17;
|
let geoFk = 16;
|
||||||
|
|
||||||
stmt = new ParameterizedSQL('CALL zone_getFromGeo(?)', [
|
stmt = new ParameterizedSQL('CALL zone_getFromGeo(?)', [
|
||||||
geoFk,
|
geoFk,
|
||||||
|
|
|
@ -75,7 +75,7 @@ describe('Ticket Edit basic data path', () => {
|
||||||
const result = await page
|
const result = await page
|
||||||
.waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText');
|
.waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText');
|
||||||
|
|
||||||
expect(result).toContain('-€232.75');
|
expect(result).toContain('-€228.25');
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should select a new reason for the changes made then click on finalize`, async() => {
|
it(`should select a new reason for the changes made then click on finalize`, async() => {
|
||||||
|
|
|
@ -316,5 +316,6 @@
|
||||||
"The ticket doesn't exist.": "No existe el ticket.",
|
"The ticket doesn't exist.": "No existe el ticket.",
|
||||||
"Social name should be uppercase": "La razón social debe ir en mayúscula",
|
"Social name should be uppercase": "La razón social debe ir en mayúscula",
|
||||||
"Street should be uppercase": "La dirección fiscal debe ir en mayúscula",
|
"Street should be uppercase": "La dirección fiscal debe ir en mayúscula",
|
||||||
|
"The response is not a PDF": "La respuesta no es un PDF",
|
||||||
"Ticket without Route": "Ticket sin ruta"
|
"Ticket without Route": "Ticket sin ruta"
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,10 +80,15 @@ module.exports = Self => {
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
if (args.zoneFk) {
|
if (args.zoneFk) {
|
||||||
query = `CALL vn.zone_getPostalCode(?)`;
|
let stmts = [];
|
||||||
const [geos] = await Self.rawSql(query, [args.zoneFk]);
|
stmts.push(new ParameterizedSQL('CALL vn.zone_getPostalCode(?)', [args.zoneFk]));
|
||||||
for (let geo of geos)
|
stmts.push(`SELECT name FROM tmp.zoneNodes`);
|
||||||
postalCode.push(geo.name);
|
stmts.push(`DROP TEMPORARY TABLE tmp.zoneNodes`);
|
||||||
|
const sql = ParameterizedSQL.join(stmts, ';');
|
||||||
|
const [results] = await conn.executeStmt(sql);
|
||||||
|
|
||||||
|
for (let result of results)
|
||||||
|
postalCode.push(result.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const where = buildFilter(ctx.args, (param, value) => {
|
const where = buildFilter(ctx.args, (param, value) => {
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
const JSZip = require('jszip');
|
||||||
|
const axios = require('axios');
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('downloadCmrsZip', {
|
||||||
|
description: 'Download a zip file with multiple cmrs pdfs',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'ids',
|
||||||
|
type: 'string',
|
||||||
|
description: 'The cmrs ids',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: [
|
||||||
|
{
|
||||||
|
arg: 'body',
|
||||||
|
type: 'file',
|
||||||
|
root: true
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Type',
|
||||||
|
type: 'string',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Disposition',
|
||||||
|
type: 'string',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
http: {
|
||||||
|
path: '/downloadCmrsZip',
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.downloadCmrsZip = async function(ctx, ids, options) {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const myOptions = {};
|
||||||
|
const token = ctx.req.accessToken;
|
||||||
|
const zip = new JSZip();
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const zipConfig = await models.ZipConfig.findOne(null, myOptions);
|
||||||
|
let totalSize = 0;
|
||||||
|
ids = ids.split(',');
|
||||||
|
try {
|
||||||
|
for (let id of ids) {
|
||||||
|
if (zipConfig && totalSize > zipConfig.maxSize) throw new UserError('Files are too large');
|
||||||
|
const response = await axios.get(
|
||||||
|
`${ctx.req.headers.referer}api/Routes/${id}/cmr?access_token=${token.id}`, {
|
||||||
|
...myOptions,
|
||||||
|
responseType: 'arraybuffer',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.headers['content-type'] !== 'application/pdf')
|
||||||
|
throw new UserError(`The response is not a PDF`);
|
||||||
|
|
||||||
|
zip.file(`${id}.pdf`, response.data, { binary: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const zipStream = zip.generateNodeStream({ streamFiles: true });
|
||||||
|
|
||||||
|
return [zipStream, 'application/zip', `filename="cmrs.zip"`];
|
||||||
|
} catch (e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -22,6 +22,11 @@ module.exports = Self => {
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
description: 'The worker id',
|
description: 'The worker id',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'routeFk',
|
||||||
|
type: 'integer',
|
||||||
|
description: 'The route id',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
arg: 'country',
|
arg: 'country',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
@ -57,6 +62,7 @@ module.exports = Self => {
|
||||||
filter,
|
filter,
|
||||||
cmrFk,
|
cmrFk,
|
||||||
ticketFk,
|
ticketFk,
|
||||||
|
routeFk,
|
||||||
country,
|
country,
|
||||||
clientFk,
|
clientFk,
|
||||||
hasCmrDms,
|
hasCmrDms,
|
||||||
|
@ -66,6 +72,7 @@ module.exports = Self => {
|
||||||
const params = {
|
const params = {
|
||||||
cmrFk,
|
cmrFk,
|
||||||
ticketFk,
|
ticketFk,
|
||||||
|
routeFk,
|
||||||
country,
|
country,
|
||||||
clientFk,
|
clientFk,
|
||||||
hasCmrDms,
|
hasCmrDms,
|
||||||
|
@ -93,6 +100,7 @@ module.exports = Self => {
|
||||||
FROM (
|
FROM (
|
||||||
SELECT t.cmrFk,
|
SELECT t.cmrFk,
|
||||||
t.id ticketFk,
|
t.id ticketFk,
|
||||||
|
t.routeFk,
|
||||||
co.country,
|
co.country,
|
||||||
t.clientFk,
|
t.clientFk,
|
||||||
IF(sub.id, TRUE, FALSE) hasCmrDms,
|
IF(sub.id, TRUE, FALSE) hasCmrDms,
|
||||||
|
|
|
@ -16,6 +16,7 @@ module.exports = Self => {
|
||||||
require('../methods/route/downloadZip')(Self);
|
require('../methods/route/downloadZip')(Self);
|
||||||
require('../methods/route/cmr')(Self);
|
require('../methods/route/cmr')(Self);
|
||||||
require('../methods/route/getExternalCmrs')(Self);
|
require('../methods/route/getExternalCmrs')(Self);
|
||||||
|
require('../methods/route/downloadCmrsZip')(Self);
|
||||||
|
|
||||||
Self.validate('kmStart', validateDistance, {
|
Self.validate('kmStart', validateDistance, {
|
||||||
message: 'Distance must be lesser than 1000'
|
message: 'Distance must be lesser than 1000'
|
||||||
|
|
|
@ -108,7 +108,7 @@ describe('sale updatePrice()', () => {
|
||||||
}}, options);
|
}}, options);
|
||||||
|
|
||||||
expect(updatedSale.price).toBe(price);
|
expect(updatedSale.price).toBe(price);
|
||||||
expect(createdSaleComponent.value).toEqual(-2.04);
|
expect(createdSaleComponent.value).toEqual(-2.34);
|
||||||
|
|
||||||
const updatedSalesPersonMana = await models.WorkerMana.findById(18, null, options);
|
const updatedSalesPersonMana = await models.WorkerMana.findById(18, null, options);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue