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

This commit is contained in:
Joan Sanchez 2021-09-17 07:47:25 +00:00
commit 01db0f6ece
13 changed files with 114 additions and 50 deletions

View File

@ -6,6 +6,11 @@ ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1;
ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1;
ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1;
INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`)
VALUES
('TOTALLY_SECURE_TOKEN', '1209600', CURDATE(), 66);
INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
VALUES VALUES
('1', '6'); ('1', '6');
@ -125,14 +130,14 @@ INSERT INTO `vn`.`warehouseAlias`(`id`, `name`)
(1, 'Main Warehouse'), (1, 'Main Warehouse'),
(2, 'Silla'); (2, 'Silla');
INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`) INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`)
VALUES VALUES
(1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 2, 1), (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 2, 1, 1),
(2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 0, 1, 2, 13), (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 0, 1, 2, 13, 1),
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1), (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1),
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1), (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1),
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1), (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1),
(13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 0, 2, 1); (13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 0, 2, 1, 0);
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `pickingPlacement`, `path`) INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `pickingPlacement`, `path`)
VALUES VALUES
@ -208,7 +213,7 @@ UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 8;
UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 4 WHERE `id` = 23; UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 4 WHERE `id` = 23;
UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 10; UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 10;
UPDATE `vn`.`agencyMode` SET `web` = 1; UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com';
UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23;
@ -845,7 +850,7 @@ INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `create
(7, 2, 4, 71, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL, 1, 1, 18, NULL, 94), (7, 2, 4, 71, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL, 1, 1, 18, NULL, 94),
(8, 3, 5, 71, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), NULL, 1, 1, 18, NULL, 94), (8, 3, 5, 71, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), NULL, 1, 1, 18, NULL, 94),
(9, 3, 6, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94), (9, 3, 6, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94),
(10, 7, 7, 71, CURDATE(), NULL, 1, 1, 18, NULL, 94); (10, 7, 7, 71, NOW(), NULL, 1, 1, 18, NULL, 94);
INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp`) INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp`)
VALUES VALUES
@ -2409,3 +2414,5 @@ INSERT INTO `vn`.`expeditionScan` (`id`, `expeditionFk`, `scanned`, `palletFk`)
(8, 8, CURDATE(), 1), (8, 8, CURDATE(), 1),
(9, 9, CURDATE(), 1), (9, 9, CURDATE(), 1),
(10, 10, CURDATE(), 1); (10, 10, CURDATE(), 1);
CALL `cache`.`last_buy_refresh`(FALSE);

View File

@ -3,22 +3,18 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('last_buy_refresh()', () => { describe('last_buy_refresh()', () => {
it(`should store some data on cache.last_buy`, async() => { it(`should store some data on cache.last_buy`, async() => {
let stmts = []; const stmts = [];
let stmt;
stmts.push('START TRANSACTION'); stmts.push('START TRANSACTION');
stmt = new ParameterizedSQL('CALL cache.last_buy_refresh(true)'); const lastBuyTableIndex = stmts.push(`SELECT * FROM cache.last_buy ORDER BY item_id ASC`) - 1;
stmts.push(stmt);
let lastBuyTableIndex = stmts.push(`SELECT * FROM cache.last_buy ORDER BY item_id ASC`) - 1;
stmts.push('ROLLBACK'); stmts.push('ROLLBACK');
let sql = ParameterizedSQL.join(stmts, ';'); const sql = ParameterizedSQL.join(stmts, ';');
let result = await app.models.Ticket.rawStmt(sql); const result = await app.models.Ticket.rawStmt(sql);
let lastBuyTable = result[lastBuyTableIndex]; const lastBuyTable = result[lastBuyTableIndex];
expect(lastBuyTable.length).toEqual(12); expect(lastBuyTable.length).toEqual(12);

View File

@ -4,7 +4,7 @@
message="Edit photo"> message="Edit photo">
<tpl-body class="upload-photo"> <tpl-body class="upload-photo">
<vn-horizontal> <vn-horizontal>
<vn-one ng-if="file.value"> <vn-one ng-if="file.value || $ctrl.newPhoto.url">
<vn-horizontal> <vn-horizontal>
<vn-icon-button vn-none <vn-icon-button vn-none
icon="rotate_left" icon="rotate_left"
@ -20,12 +20,26 @@
</vn-horizontal> </vn-horizontal>
</vn-one> </vn-one>
<vn-one> <vn-one>
<vn-horizontal> <vn-vertical class="vn-mb-sm">
<vn-radio
label="Select file from computer"
val="computer"
ng-model="$ctrl.uploadMethod"
tabindex="-1">
</vn-radio>
<vn-radio
label="Import from external URL"
val="URL"
ng-model="$ctrl.uploadMethod"
tabindex="-1">
</vn-radio>
</vn-vertical>
<vn-horizontal ng-if="$ctrl.uploadMethod == 'computer'">
<vn-input-file vn-id="file" <vn-input-file vn-id="file"
vn-one vn-one
label="File" label="File"
ng-model="$ctrl.newPhoto.files" ng-model="$ctrl.newPhoto.files"
on-change="$ctrl.updatePhotoPreview(value)" on-change="$ctrl.updatePhotoPreview(value[0])"
accept="{{$ctrl.allowedContentTypes}}" accept="{{$ctrl.allowedContentTypes}}"
required="true"> required="true">
<append> <append>
@ -37,6 +51,14 @@
</append> </append>
</vn-input-file> </vn-input-file>
</vn-horizontal> </vn-horizontal>
<vn-horizontal ng-if="$ctrl.uploadMethod == 'URL'">
<vn-textfield
vn-one
ng-model="$ctrl.newPhoto.url"
on-change="$ctrl.updatePhotoPreview(value)"
placeholder="https://">
</vn-textfield>
</vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-autocomplete <vn-autocomplete
label="Type" label="Type"

View File

@ -39,6 +39,7 @@ export default class UploadPhoto extends Component {
} }
]; ];
this.viewportType = 'normal'; this.viewportType = 'normal';
this.uploadMethod = 'computer';
this.getAllowedContentTypes(); this.getAllowedContentTypes();
} }
@ -64,11 +65,16 @@ export default class UploadPhoto extends Component {
set viewportSelection(value) { set viewportSelection(value) {
this._viewportSelection = value; this._viewportSelection = value;
if (value && this.newPhoto.files) { const hasFile = this.newPhoto.files || this.newPhoto.url;
this.displayEditor(); if (!value || !hasFile) return;
const files = this.newPhoto.files;
this.updatePhotoPreview(files); let file;
} if (this.uploadMethod == 'computer')
file = this.newPhoto.files[0];
else if (this.uploadMethod == 'URL')
file = this.newPhoto.url;
this.updatePhotoPreview(file);
} }
getAllowedContentTypes() { getAllowedContentTypes() {
@ -90,13 +96,15 @@ export default class UploadPhoto extends Component {
* @param {string} value * @param {string} value
*/ */
updatePhotoPreview(value) { updatePhotoPreview(value) {
if (value && value[0]) { if (value) {
if (!this.editor) this.displayEditor();
this.displayEditor();
const reader = new FileReader(); if (this.uploadMethod == 'computer') {
reader.onload = e => this.editor.bind({url: e.target.result}); const reader = new FileReader();
reader.readAsDataURL(value[0]); reader.onload = e => this.editor.bind({url: e.target.result});
reader.readAsDataURL(value);
} else if (this.uploadMethod == 'URL')
this.editor.bind({url: value});
} }
} }

View File

@ -24,17 +24,30 @@ describe('Salix', () => {
}); });
describe('viewportSelection()', () => { describe('viewportSelection()', () => {
it('should call to displayEditor() and updatePhotoPreview() methods', () => { it('should call to the updatePhotoPreview() method when uploadMethod property is set to "computer"', () => {
controller.displayEditor = jest.fn();
controller.updatePhotoPreview = jest.fn(); controller.updatePhotoPreview = jest.fn();
const files = [{name: 'test.jpg'}]; const files = [{name: 'test.jpg'}];
controller.newPhoto.files = files; controller.newPhoto.files = files;
controller.uploadMethod = 'computer';
controller.viewportSelection = {code: 'normal'}; controller.viewportSelection = {code: 'normal'};
expect(controller.displayEditor).toHaveBeenCalledWith(); const firstFile = files[0];
expect(controller.updatePhotoPreview).toHaveBeenCalledWith(files);
expect(controller.updatePhotoPreview).toHaveBeenCalledWith(firstFile);
});
it('should call to the updatePhotoPreview() method when uploadMethod property is set to "URL"', () => {
controller.updatePhotoPreview = jest.fn();
const url = 'http://gothamcity.com/batman.png';
controller.newPhoto.url = url;
controller.uploadMethod = 'URL';
controller.viewportSelection = {code: 'normal'};
expect(controller.updatePhotoPreview).toHaveBeenCalledWith(url);
}); });
}); });

View File

@ -4,3 +4,5 @@ File name: Nombre del fichero
Rotate left: Girar a la izquierda Rotate left: Girar a la izquierda
Rotate right: Girar a la derecha Rotate right: Girar a la derecha
Panoramic: Panorámico Panoramic: Panorámico
Select from computer: Seleccionar foto desde ordenador
Import from external URL: Importar desde URL externa

View File

@ -115,7 +115,6 @@ module.exports = Self => {
const stmts = []; const stmts = [];
let stmt; let stmt;
stmts.push('CALL cache.last_buy_refresh(FALSE)');
stmts.push('CALL cache.visible_refresh(@calc_id, FALSE, 1)'); stmts.push('CALL cache.visible_refresh(@calc_id, FALSE, 1)');
stmt = new ParameterizedSQL(` stmt = new ParameterizedSQL(`

View File

@ -127,7 +127,6 @@ module.exports = Self => {
filter = mergeFilters(filter, {where}); filter = mergeFilters(filter, {where});
const stmts = []; const stmts = [];
stmts.push('CALL cache.last_buy_refresh(FALSE)');
const stmt = new ParameterizedSQL( const stmt = new ParameterizedSQL(
`SELECT `SELECT
i.id, i.id,

View File

@ -223,7 +223,8 @@ module.exports = Self => {
MINUTE(z.hour) AS zoneMinute, MINUTE(z.hour) AS zoneMinute,
z.name AS zoneName, z.name AS zoneName,
z.id AS zoneFk, z.id AS zoneFk,
CAST(z.hour AS CHAR) AS hour CAST(z.hour AS CHAR) AS hour,
TIME_FORMAT(zed.etc, '%H:%i') AS practicalHour
FROM ticket t FROM ticket t
LEFT JOIN invoiceOut io ON t.refFk = io.ref LEFT JOIN invoiceOut io ON t.refFk = io.ref
LEFT JOIN zone z ON z.id = t.zoneFk LEFT JOIN zone z ON z.id = t.zoneFk
@ -235,7 +236,8 @@ module.exports = Self => {
LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN state st ON st.id = ts.stateFk
LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk
LEFT JOIN account.user u ON u.id = wk.userFk`); LEFT JOIN account.user u ON u.id = wk.userFk
LEFT JOIN zoneEstimatedDelivery zed ON zed.zoneFk = t.zoneFk`);
if (args.orderFk) { if (args.orderFk) {
stmt.merge({ stmt.merge({

View File

@ -7,3 +7,5 @@ All the selected elements will be deleted. Are you sure you want to continue?: T
Component lack: Faltan componentes Component lack: Faltan componentes
Minimize/Maximize: Minimizar/Maximizar Minimize/Maximize: Minimizar/Maximizar
Problems: Problemas Problems: Problemas
Theoretical: Teórica
Practical: Práctica

View File

@ -37,8 +37,9 @@
<vn-th field="nickname">Client</vn-th> <vn-th field="nickname">Client</vn-th>
<vn-th field="salesPersonFk" class="expendable" shrink>Salesperson</vn-th> <vn-th field="salesPersonFk" class="expendable" shrink>Salesperson</vn-th>
<vn-th field="shipped" shrink-date>Date</vn-th> <vn-th field="shipped" shrink-date>Date</vn-th>
<vn-th>Hour</vn-th> <vn-th>Prep.</vn-th>
<vn-th field="zoneHour" shrink>Closure</vn-th> <vn-th field="hour" shrink>Theoretical</vn-th>
<vn-th field="practicalHour">Practical</vn-th>
<vn-th field="provinceFk" class="expendable">Province</vn-th> <vn-th field="provinceFk" class="expendable">Province</vn-th>
<vn-th field="stateFk">State</vn-th> <vn-th field="stateFk">State</vn-th>
<vn-th field="zoneFk">Zone</vn-th> <vn-th field="zoneFk">Zone</vn-th>
@ -112,6 +113,7 @@
</vn-td> </vn-td>
<vn-td shrink>{{::ticket.shipped | date: 'HH:mm'}}</vn-td> <vn-td shrink>{{::ticket.shipped | date: 'HH:mm'}}</vn-td>
<vn-td shrink>{{::ticket.zoneLanding | date: 'HH:mm'}}</vn-td> <vn-td shrink>{{::ticket.zoneLanding | date: 'HH:mm'}}</vn-td>
<vn-td shrink>{{::ticket.practicalHour | date: 'HH:mm'}}</vn-td>
<vn-td class="expendable">{{::ticket.province}}</vn-td> <vn-td class="expendable">{{::ticket.province}}</vn-td>
<vn-td class="expendable"> <vn-td class="expendable">
<span <span

View File

@ -74,12 +74,8 @@ export default class Controller extends Section {
return {'t.shipped': { return {'t.shipped': {
between: this.dateRange(value)} between: this.dateRange(value)}
}; };
case 'id':
case 'refFk':
case 'zoneFk': case 'zoneFk':
case 'nickname': case 'nickname':
case 'agencyModeFk':
case 'warehouseFk':
return {[`t.${param}`]: value}; return {[`t.${param}`]: value};
} }
} }

View File

@ -143,8 +143,24 @@ module.exports = app => {
AND t.refFk IS NULL AND t.refFk IS NULL
GROUP BY e.ticketFk`, [reqArgs.routeId]); GROUP BY e.ticketFk`, [reqArgs.routeId]);
const ticketIds = tickets.map(ticket => ticket.id); const ticketIds = tickets.map(ticket => ticket.id);
await closeAll(ticketIds, reqArgs); await closeAll(ticketIds, reqArgs);
// Send route report to the agency
const agencyMail = await db.findValue(`
SELECT am.reportMail
FROM route r
JOIN agencyMode am ON am.id = r.agencyModeFk
WHERE r.id = ?`, [reqArgs.routeId]);
if (agencyMail) {
const args = Object.assign({
routeId: reqArgs.routeId,
recipient: agencyMail
}, reqArgs);
const email = new Email('driver-route', args);
await email.send();
}
} catch (error) { } catch (error) {
next(error); next(error);
} }