Merge branch 'dev' into 6213-supplierFixCreateErrors
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Pablo Natek 2023-09-21 05:21:06 +00:00
commit 324b3ed8ee
34 changed files with 5359 additions and 5315 deletions

View File

@ -3,11 +3,11 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `pri
('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'), ('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'),
('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'salesPerson'), ('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'salesPerson'),
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'salesAssistant'), ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'salesAssistant'),
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'deliveryBoss'), ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'deliveryAssistant'),
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'buyer'), ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'buyer'),
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'claimManager'), ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'claimManager'),
('Ticket', 'deleteTicketWithPartPrepared', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'), ('Ticket', 'deleteTicketWithPartPrepared', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'),
('Ticket', 'editZone', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'), ('Ticket', 'editZone', 'WRITE', 'ALLOW', 'ROLE', 'deliveryAssistant'),
('State', 'editableStates', 'READ', 'ALLOW', 'ROLE', 'employee'), ('State', 'editableStates', 'READ', 'ALLOW', 'ROLE', 'employee'),
('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'administrative'), ('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'administrative'),
('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'production'), ('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'production'),

View File

@ -0,0 +1,16 @@
-- Auto-generated SQL script. Actual values for binary/complex data types may differ - what you see is the default string representation of values.
INSERT INTO `account`.`role` (name,description)
VALUES ('deliveryAssistant','Jefe auxiliar repartos');
INSERT INTO `account`.`roleInherit` (role, inheritsFrom)
SELECT (SELECT id FROM account.role r1 WHERE r1.name = 'deliveryAssistant'), ri.inheritsFrom
FROM account.roleInherit ri
JOIN account.role r2 ON r2.id = ri.`role`
WHERE r2.name = 'deliveryBoss';
INSERT INTO `account`.`roleInherit` (role, inheritsFrom)
SELECT (SELECT id FROM account.role WHERE name = 'deliveryBoss') role,
(SELECT id FROM account.role WHERE name = 'deliveryAssistant') roleInherit;
CALL `account`.`role_syncPrivileges`();

File diff suppressed because one or more lines are too long

View File

@ -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);

File diff suppressed because it is too large Load Diff

View File

@ -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
])); ]));

View File

@ -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);
});
});

View File

@ -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)

View File

@ -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,

View File

@ -8,7 +8,7 @@ describe('Client create path', () => {
beforeAll(async() => { beforeAll(async() => {
browser = await getBrowser(); browser = await getBrowser();
page = browser.page; page = browser.page;
await page.loginAndModule(' deliveryBoss', 'client'); await page.loginAndModule('deliveryAssistant', 'client');
}); });
afterAll(async() => { afterAll(async() => {

View File

@ -45,7 +45,7 @@ describe('Worker create path', () => {
// should create a new worker and go to worker basic data' // should create a new worker and go to worker basic data'
await page.pickDate(selectors.workerCreate.birth, new Date(1962, 8, 5)); await page.pickDate(selectors.workerCreate.birth, new Date(1962, 8, 5));
await page.autocompleteSearch(selectors.workerCreate.boss, 'deliveryBoss'); await page.autocompleteSearch(selectors.workerCreate.boss, 'deliveryAssistant');
await page.waitToClick(selectors.workerCreate.createButton); await page.waitToClick(selectors.workerCreate.createButton);
message = await page.waitForSnackbar(); message = await page.waitForSnackbar();
await page.waitForState('worker.card.basicData'); await page.waitForState('worker.card.basicData');

View File

@ -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() => {

View File

@ -8,7 +8,9 @@ describe('Zone basic data path', () => {
beforeAll(async() => { beforeAll(async() => {
browser = await getBrowser(); browser = await getBrowser();
page = browser.page; page = browser.page;
await page.loginAndModule('deliveryBoss', 'zone'); // turns up the zone module name and route aint the same lol
await page.loginAndModule('deliveryAssistant',
'zone'); // turns up the zone module name and route aint the same lol
await page.accessToSearchResult('10'); await page.accessToSearchResult('10');
await page.accessToSection('zone.card.basicData'); await page.accessToSection('zone.card.basicData');
}); });

View File

@ -8,7 +8,7 @@ describe('Zone descriptor path', () => {
beforeAll(async() => { beforeAll(async() => {
browser = await getBrowser(); browser = await getBrowser();
page = browser.page; page = browser.page;
await page.loginAndModule('deliveryBoss', 'zone'); await page.loginAndModule('deliveryAssistant', 'zone');
await page.accessToSearchResult('13'); await page.accessToSearchResult('13');
}); });

View File

@ -317,5 +317,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"
} }

View File

@ -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) => {

View File

@ -31,7 +31,7 @@
<vn-check <vn-check
vn-one vn-one
label="Default" ng-model="$ctrl.address.isDefaultAddress"> label="Default" ng-model="$ctrl.address.isDefaultAddress">
</vn-check> </vn-check>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield <vn-textfield
@ -60,7 +60,7 @@
show-field="code" show-field="code"
rule> rule>
<tpl-item> <tpl-item>
{{code}} - {{town.name}} ({{town.province.name}}, {{code}} - {{town.name}} ({{town.province.name}},
{{town.province.country.country}}) {{town.province.country.country}})
</tpl-item> </tpl-item>
<append> <append>
@ -68,12 +68,12 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>
</vn-datalist> </vn-datalist>
<vn-datalist vn-id="town" vn-one <vn-datalist vn-id="town" vn-one
label="City" label="City"
ng-model="$ctrl.address.city" ng-model="$ctrl.address.city"
selection="$ctrl.town" selection="$ctrl.town"
@ -158,7 +158,7 @@
</vn-geo-postcode> </vn-geo-postcode>
<!-- Create custom agent dialog --> <!-- Create custom agent dialog -->
<vn-dialog class="edit" <vn-dialog class="edit"
vn-id="customAgent" vn-id="customAgent"
on-accept="$ctrl.onCustomAgentAccept()" on-accept="$ctrl.onCustomAgentAccept()"
message="New customs agent"> message="New customs agent">
@ -190,4 +190,4 @@
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/> <input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Create</button> <button response="accept" translate>Create</button>
</tpl-buttons> </tpl-buttons>
</vn-dialog> </vn-dialog>

View File

@ -73,20 +73,20 @@
show-field="code" show-field="code"
rule> rule>
<tpl-item> <tpl-item>
{{code}} - {{town.name}} ({{town.province.name}}, {{code}} - {{town.name}} ({{town.province.name}},
{{town.province.country.country}}) {{town.province.country.country}})
</tpl-item> </tpl-item>
<append> <append>
<vn-icon-button <vn-icon-button
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>
</vn-datalist> </vn-datalist>
<vn-datalist vn-id="town" vn-one <vn-datalist vn-id="town" vn-one
label="City" label="City"
ng-model="$ctrl.address.city" ng-model="$ctrl.address.city"
selection="$ctrl.town" selection="$ctrl.town"
@ -178,14 +178,14 @@
icon="delete" icon="delete"
ng-click="$ctrl.removeObservation($index)" ng-click="$ctrl.removeObservation($index)"
tabindex="-1"> tabindex="-1">
</vn-icon-button> </vn-icon-button>
</vn-none> </vn-none>
</vn-horizontal> </vn-horizontal>
<vn-icon-button <vn-icon-button
vn-bind="+" vn-bind="+"
vn-tooltip="Add note" vn-tooltip="Add note"
icon="add_circle" icon="add_circle"
ng-if="types.length > observations.length" ng-if="types.length > observations.length"
ng-click="model.insert()"> ng-click="model.insert()">
</vn-icon-button> </vn-icon-button>
</div> </div>
@ -197,12 +197,12 @@
</form> </form>
<!-- New postcode dialog --> <!-- New postcode dialog -->
<vn-geo-postcode vn-id="postcode" <vn-geo-postcode vn-id="postcode"
on-response="$ctrl.onResponse($response)"> on-response="$ctrl.onResponse($response)">
</vn-geo-postcode> </vn-geo-postcode>
<!-- Create custom agent dialog --> <!-- Create custom agent dialog -->
<vn-dialog class="edit" <vn-dialog class="edit"
vn-id="customAgent" vn-id="customAgent"
on-accept="$ctrl.onCustomAgentAccept()" on-accept="$ctrl.onCustomAgentAccept()"
message="New customs agent"> message="New customs agent">
@ -234,4 +234,4 @@
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/> <input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Create</button> <button response="accept" translate>Create</button>
</tpl-buttons> </tpl-buttons>
</vn-dialog> </vn-dialog>

View File

@ -73,7 +73,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -94,7 +94,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -27,7 +27,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New city" vn-tooltip="New city"
ng-click="city.open($event)" ng-click="city.open($event)"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>
@ -45,7 +45,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New province" vn-tooltip="New province"
ng-click="province.open($event)" ng-click="province.open($event)"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>
@ -73,4 +73,4 @@
<vn-geo-city <vn-geo-city
vn-id="city" vn-id="city"
on-response="$ctrl.onCityResponse($response)"> on-response="$ctrl.onCityResponse($response)">
</vn-geo-city> </vn-geo-city>

View File

@ -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;
}
};
};

View File

@ -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,
@ -89,37 +96,38 @@ module.exports = Self => {
let stmts = []; let stmts = [];
const stmt = new ParameterizedSQL(` const stmt = new ParameterizedSQL(`
SELECT * SELECT *
FROM ( FROM (
SELECT t.cmrFk, SELECT t.cmrFk,
t.id ticketFk, t.id ticketFk,
co.country, t.routeFk,
t.clientFk, co.country,
IF(sub.id, TRUE, FALSE) hasCmrDms, t.clientFk,
DATE(t.shipped) shipped IF(sub.id, TRUE, FALSE) hasCmrDms,
FROM ticket t DATE(t.shipped) shipped
JOIN ticketState ts ON ts.ticketFk = t.id FROM ticket t
JOIN state s ON s.id = ts.stateFk JOIN ticketState ts ON ts.ticketFk = t.id
JOIN alertLevel al ON al.id = s.alertLevel JOIN state s ON s.id = ts.stateFk
JOIN client c ON c.id = t.clientFk JOIN alertLevel al ON al.id = s.alertLevel
JOIN address a ON a.id = t.addressFk JOIN client c ON c.id = t.clientFk
JOIN province p ON p.id = a.provinceFk JOIN address a ON a.id = t.addressFk
JOIN country co ON co.id = p.countryFk JOIN province p ON p.id = a.provinceFk
JOIN agencyMode am ON am.id = t.agencyModeFk JOIN country co ON co.id = p.countryFk
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk JOIN agencyMode am ON am.id = t.agencyModeFk
JOIN warehouse w ON w.id = t.warehouseFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
LEFT JOIN ( JOIN warehouse w ON w.id = t.warehouseFk
SELECT td.ticketFk, d.id LEFT JOIN (
FROM ticketDms td SELECT td.ticketFk, d.id
JOIN dms d ON d.id = td.dmsFk FROM ticketDms td
JOIN dmsType dt ON dt.id = d.dmsTypeFk JOIN dms d ON d.id = td.dmsFk
WHERE dt.name = 'cmr' JOIN dmsType dt ON dt.id = d.dmsTypeFk
) sub ON sub.ticketFk = t.id WHERE dt.name = 'cmr'
WHERE co.code <> 'ES' ) sub ON sub.ticketFk = t.id
AND am.name <> 'ABONO' WHERE co.code <> 'ES'
AND w.code = 'ALG' AND am.name <> 'ABONO'
AND dm.code = 'DELIVERY' AND w.code = 'ALG'
AND t.cmrFk AND dm.code = 'DELIVERY'
AND t.cmrFk
) sub ) sub
`); `);

View File

@ -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'

View File

@ -15,14 +15,14 @@
</vn-item> </vn-item>
<vn-item <vn-item
ng-click="updateVolumeConfirmation.show()" ng-click="updateVolumeConfirmation.show()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove" vn-acl-action="remove"
translate> translate>
Update volume Update volume
</vn-item> </vn-item>
<vn-item <vn-item
ng-click="$ctrl.deleteCurrentRoute()" ng-click="$ctrl.deleteCurrentRoute()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove" vn-acl-action="remove"
translate> translate>
Delete route Delete route
@ -31,23 +31,23 @@
<slot-body> <slot-body>
<div class="attributes"> <div class="attributes">
<vn-label-value <vn-label-value
label="Date" label="Date"
value="{{$ctrl.route.created | date: 'dd/MM/yyyy'}}"> value="{{$ctrl.route.created | date: 'dd/MM/yyyy'}}">
</vn-label-value> </vn-label-value>
<vn-label-value <vn-label-value
label="Agency" label="Agency"
value="{{$ctrl.route.agencyMode.name}}"> value="{{$ctrl.route.agencyMode.name}}">
</vn-label-value> </vn-label-value>
<vn-label-value <vn-label-value
label="Zone" label="Zone"
value="{{$ctrl.route.zone.name}}"> value="{{$ctrl.route.zone.name}}">
</vn-label-value> </vn-label-value>
<vn-label-value <vn-label-value
label="Volume" label="Volume"
value="{{$ctrl.route.m3 | dashIfEmpty}} / {{$ctrl.route.vehicle.m3 | dashIfEmpty}} m³"> value="{{$ctrl.route.m3 | dashIfEmpty}} / {{$ctrl.route.vehicle.m3 | dashIfEmpty}} m³">
</vn-label-value> </vn-label-value>
<vn-label-value <vn-label-value
label="Description" label="Description"
value="{{$ctrl.route.description}}"> value="{{$ctrl.route.description}}">
</vn-label-value> </vn-label-value>
</div> </div>
@ -72,4 +72,4 @@
</vn-confirm> </vn-confirm>
<vn-popup vn-id="summary"> <vn-popup vn-id="summary">
<vn-route-summary route="$ctrl.route"></vn-route-summary> <vn-route-summary route="$ctrl.route"></vn-route-summary>
</vn-popup> </vn-popup>

View File

@ -37,7 +37,7 @@
icon="format_list_numbered"> icon="format_list_numbered">
</vn-button> </vn-button>
<vn-button <vn-button
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove" vn-acl-action="remove"
disabled="!$ctrl.isChecked" disabled="!$ctrl.isChecked"
icon="sms" icon="sms"

View File

@ -42,7 +42,7 @@
show-field="code" show-field="code"
rule> rule>
<tpl-item> <tpl-item>
{{code}} - {{town.name}} ({{town.province.name}}, {{code}} - {{town.name}} ({{town.province.name}},
{{town.province.country.country}}) {{town.province.country.country}})
</tpl-item> </tpl-item>
<append> <append>
@ -50,12 +50,12 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>
</vn-datalist> </vn-datalist>
<vn-datalist vn-id="town" vn-one <vn-datalist vn-id="town" vn-one
label="City" label="City"
ng-model="$ctrl.address.city" ng-model="$ctrl.address.city"
selection="$ctrl.town" selection="$ctrl.town"
@ -106,4 +106,4 @@
<!-- New postcode dialog --> <!-- New postcode dialog -->
<vn-geo-postcode vn-id="postcode" <vn-geo-postcode vn-id="postcode"
on-response="$ctrl.onResponse($response)"> on-response="$ctrl.onResponse($response)">
</vn-geo-postcode> </vn-geo-postcode>

View File

@ -40,20 +40,20 @@
show-field="code" show-field="code"
rule> rule>
<tpl-item> <tpl-item>
{{code}} - {{town.name}} ({{town.province.name}}, {{code}} - {{town.name}} ({{town.province.name}},
{{town.province.country.country}}) {{town.province.country.country}})
</tpl-item> </tpl-item>
<append> <append>
<vn-icon-button <vn-icon-button
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>
</vn-datalist> </vn-datalist>
<vn-datalist vn-id="town" vn-one <vn-datalist vn-id="town" vn-one
label="City" label="City"
ng-model="$ctrl.address.city" ng-model="$ctrl.address.city"
selection="$ctrl.town" selection="$ctrl.town"
@ -99,6 +99,6 @@
</form> </form>
<!-- New postcode dialog --> <!-- New postcode dialog -->
<vn-geo-postcode vn-id="postcode" <vn-geo-postcode vn-id="postcode"
on-response="$ctrl.onResponse($response)"> on-response="$ctrl.onResponse($response)">
</vn-geo-postcode> </vn-geo-postcode>

View File

@ -150,7 +150,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -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);

View File

@ -72,7 +72,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -12,9 +12,9 @@
<vn-card class="vn-pa-lg"> <vn-card class="vn-pa-lg">
<vn-horizontal> <vn-horizontal>
<vn-textfield <vn-textfield
label="Name" label="Name"
ng-model="$ctrl.zone.name" ng-model="$ctrl.zone.name"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-textfield> </vn-textfield>
</vn-horizontal> </vn-horizontal>
@ -26,7 +26,7 @@
show-field="name" show-field="name"
value-field="id" value-field="id"
label="Agency" label="Agency"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-autocomplete> </vn-autocomplete>
<vn-input-number <vn-input-number
@ -34,7 +34,7 @@
label="Max m³" label="Max m³"
ng-model="$ctrl.zone.itemMaxSize" ng-model="$ctrl.zone.itemMaxSize"
min="0" min="0"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-number> </vn-input-number>
<vn-input-number <vn-input-number
@ -42,7 +42,7 @@
label="Maximum m³" label="Maximum m³"
ng-model="$ctrl.zone.m3Max" ng-model="$ctrl.zone.m3Max"
min="0" min="0"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-number> </vn-input-number>
</vn-horizontal> </vn-horizontal>
@ -52,13 +52,13 @@
ng-model="$ctrl.zone.travelingDays" ng-model="$ctrl.zone.travelingDays"
min="0" min="0"
step="1" step="1"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-number> </vn-input-number>
<vn-input-time <vn-input-time
label="Closing" label="Closing"
ng-model="$ctrl.zone.hour" ng-model="$ctrl.zone.hour"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-time> </vn-input-time>
</vn-horizontal> </vn-horizontal>
@ -68,16 +68,16 @@
ng-model="$ctrl.zone.price" ng-model="$ctrl.zone.price"
min="0" min="0"
step="0.01" step="0.01"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-number> </vn-input-number>
<vn-input-number <vn-input-number
label="Bonus" label="Bonus"
ng-model="$ctrl.zone.bonus" ng-model="$ctrl.zone.bonus"
step="0.01" step="0.01"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-number> </vn-input-number>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-input-number <vn-input-number
@ -86,14 +86,14 @@
ng-model="$ctrl.zone.inflation" ng-model="$ctrl.zone.inflation"
min="0" min="0"
step="0.01" step="0.01"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-number> </vn-input-number>
<vn-check <vn-check
vn-one vn-one
label="Volumetric" label="Volumetric"
ng-model="$ctrl.zone.isVolumetric" ng-model="$ctrl.zone.isVolumetric"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-check> </vn-check>
</vn-horizontal> </vn-horizontal>
@ -101,7 +101,7 @@
<vn-button-bar> <vn-button-bar>
<vn-submit <vn-submit
disabled="!watcher.dataChanged()" disabled="!watcher.dataChanged()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
label="Save"> label="Save">
</vn-submit> </vn-submit>
<vn-button <vn-button

View File

@ -32,7 +32,7 @@
vn-click-stop="clone.show(zone)" vn-click-stop="clone.show(zone)"
vn-tooltip="Clone" vn-tooltip="Clone"
icon="icon-clone" icon="icon-clone"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
<vn-icon-button <vn-icon-button
@ -50,7 +50,7 @@
<vn-popup vn-id="summary"> <vn-popup vn-id="summary">
<vn-zone-summary zone="$ctrl.selectedZone"></vn-zone-summary> <vn-zone-summary zone="$ctrl.selectedZone"></vn-zone-summary>
</vn-popup> </vn-popup>
<vn-confirm <vn-confirm
vn-id="clone" vn-id="clone"
on-accept="$ctrl.onCloneAccept($data)" on-accept="$ctrl.onCloneAccept($data)"
question="Do you want to clone this zone?" question="Do you want to clone this zone?"
@ -62,7 +62,7 @@
fixed-bottom-right> fixed-bottom-right>
<vn-float-button <vn-float-button
icon="add" icon="add"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-float-button> </vn-float-button>
</a> </a>

View File

@ -16,12 +16,12 @@
root-label="Locations" root-label="Locations"
fetch-func="$ctrl.onFetch($item)" fetch-func="$ctrl.onFetch($item)"
sort-func="$ctrl.onSort($a, $b)"> sort-func="$ctrl.onSort($a, $b)">
<vn-check acl-role="deliveryBoss" <vn-check acl-role="deliveryAssistant"
ng-model="item.selected" ng-model="item.selected"
on-change="$ctrl.onSelection(value, item)" on-change="$ctrl.onSelection(value, item)"
triple-state="true" triple-state="true"
ng-click="$event.preventDefault()" ng-click="$event.preventDefault()"
label="{{::item.name}}"> label="{{::item.name}}">
</vn-check> </vn-check>
</vn-treeview> </vn-treeview>
</vn-card> </vn-card>