From 6605e5ae4cbbde79e568544b710b8b1730765b25 Mon Sep 17 00:00:00 2001 From: bernat Date: Wed, 2 Dec 2020 12:05:47 +0100 Subject: [PATCH 01/23] zoneLog --- db/changes/10260-december/00-zoneLog.sql | 18 ++++++ modules/zone/back/model-config.json | 3 + modules/zone/back/models/zone-log.json | 58 ++++++++++++++++++++ modules/zone/back/models/zone-warehouse.json | 6 +- modules/zone/back/models/zone.json | 6 +- modules/zone/front/index.js | 1 + modules/zone/front/log/index.html | 1 + modules/zone/front/log/index.js | 7 +++ modules/zone/front/routes.json | 6 ++ 9 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 db/changes/10260-december/00-zoneLog.sql create mode 100644 modules/zone/back/models/zone-log.json create mode 100644 modules/zone/front/log/index.html create mode 100644 modules/zone/front/log/index.js diff --git a/db/changes/10260-december/00-zoneLog.sql b/db/changes/10260-december/00-zoneLog.sql new file mode 100644 index 000000000..13d81bc92 --- /dev/null +++ b/db/changes/10260-december/00-zoneLog.sql @@ -0,0 +1,18 @@ +CREATE TABLE `vn`.`zoneLog` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `originFk` int(10) NOT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelId` int(11) DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `originFk` (`originFk`), + KEY `userFk` (`userFk`), + CONSTRAINT `zoneLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn`.`zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `zoneLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; \ No newline at end of file diff --git a/modules/zone/back/model-config.json b/modules/zone/back/model-config.json index f353be088..05da8b2c3 100644 --- a/modules/zone/back/model-config.json +++ b/modules/zone/back/model-config.json @@ -31,5 +31,8 @@ }, "ZoneEstimatedDelivery": { "dataSource": "vn" + }, + "ZoneLog": { + "dataSource": "vn" } } diff --git a/modules/zone/back/models/zone-log.json b/modules/zone/back/models/zone-log.json new file mode 100644 index 000000000..ddca9261b --- /dev/null +++ b/modules/zone/back/models/zone-log.json @@ -0,0 +1,58 @@ +{ + "name": "ZoneLog", + "base": "VnModel", + "options": { + "mysql": { + "table": "zoneLog" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "forceId": false + }, + "originFk": { + "type": "Number", + "required": true + }, + "userFk": { + "type": "Number" + }, + "action": { + "type": "String", + "required": true + }, + "changedModel": { + "type": "String" + }, + "oldInstance": { + "type": "Object" + }, + "newInstance": { + "type": "Object" + }, + "creationDate": { + "type": "Date" + }, + "changedModelId": { + "type": "String" + }, + "changedModelValue": { + "type": "String" + }, + "description": { + "type": "String" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] + } +} diff --git a/modules/zone/back/models/zone-warehouse.json b/modules/zone/back/models/zone-warehouse.json index 14c4e84a4..0f0e43f4a 100644 --- a/modules/zone/back/models/zone-warehouse.json +++ b/modules/zone/back/models/zone-warehouse.json @@ -1,6 +1,10 @@ { "name": "ZoneWarehouse", - "base": "VnModel", + "base": "Loggable", + "log": { + "model":"ZoneLog", + "relation": "zone" + }, "options": { "mysql": { "table": "zoneWarehouse" diff --git a/modules/zone/back/models/zone.json b/modules/zone/back/models/zone.json index e94146946..1d1ccfd90 100644 --- a/modules/zone/back/models/zone.json +++ b/modules/zone/back/models/zone.json @@ -1,6 +1,10 @@ { "name": "Zone", - "base": "VnModel", + "base": "Loggable", + "log": { + "model":"ZoneLog", + "showField": "name" + }, "options": { "mysql": { "table": "zone" diff --git a/modules/zone/front/index.js b/modules/zone/front/index.js index 26c491709..dc20eea47 100644 --- a/modules/zone/front/index.js +++ b/modules/zone/front/index.js @@ -16,3 +16,4 @@ import './calendar'; import './location'; import './calendar'; import './upcoming-deliveries'; +import './log'; diff --git a/modules/zone/front/log/index.html b/modules/zone/front/log/index.html new file mode 100644 index 000000000..539afda82 --- /dev/null +++ b/modules/zone/front/log/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/modules/zone/front/log/index.js b/modules/zone/front/log/index.js new file mode 100644 index 000000000..8c3be2423 --- /dev/null +++ b/modules/zone/front/log/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +ngModule.vnComponent('vnZoneLog', { + template: require('./index.html'), + controller: Section, +}); diff --git a/modules/zone/front/routes.json b/modules/zone/front/routes.json index 6c799dcc8..0134c3b78 100644 --- a/modules/zone/front/routes.json +++ b/modules/zone/front/routes.json @@ -14,6 +14,7 @@ {"state": "zone.card.basicData", "icon": "settings"}, {"state": "zone.card.location", "icon": "my_location"}, {"state": "zone.card.warehouses", "icon": "home"}, + {"state": "zone.card.log", "icon": "history"}, {"state": "zone.card.events", "icon": "today"} ] }, @@ -84,6 +85,11 @@ "params": { "zone": "$ctrl.zone" } + }, { + "url" : "/log", + "state": "zone.card.log", + "component": "vn-zone-log", + "description": "Log" } ] } \ No newline at end of file From 6eeecc553ba9fc301104dfa213a14946a419d6d9 Mon Sep 17 00:00:00 2001 From: bernat Date: Wed, 2 Dec 2020 12:49:50 +0100 Subject: [PATCH 02/23] zoneLog calendar --- modules/zone/back/models/zone-event.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/zone/back/models/zone-event.json b/modules/zone/back/models/zone-event.json index 9ac1007b5..54c9c4a7d 100644 --- a/modules/zone/back/models/zone-event.json +++ b/modules/zone/back/models/zone-event.json @@ -1,6 +1,10 @@ { "name": "ZoneEvent", - "base": "VnModel", + "base": "Loggable", + "log": { + "model":"ZoneLog", + "relation": "zone" + }, "options": { "mysql": { "table": "zoneEvent" From 910caf5689944a118988c26d17a53a0a733f6d81 Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 28 Dec 2020 14:53:26 +0100 Subject: [PATCH 03/23] 2661 - Added clone options --- .../00-travel_cloneWithEntries.sql | 135 ++++++++++++++++++ loopback/util/log.js | 12 +- modules/ticket/back/methods/ticket/new.js | 2 +- .../back/methods/travel/cloneWithEntries.js | 87 +++++++++++ .../travel/specs/cloneWithEntries.spec.js | 79 ++++++++++ modules/travel/back/models/travel.js | 1 + modules/travel/front/create/index.js | 2 +- modules/travel/front/create/index.spec.js | 3 +- .../travel/front/descriptor-menu/index.html | 14 ++ modules/travel/front/descriptor-menu/index.js | 5 + .../front/descriptor-menu/index.spec.js | 19 ++- .../front/descriptor-menu/locale/es.yml | 4 +- modules/travel/front/locale/es.yml | 2 +- modules/travel/front/summary/index.html | 1 + 14 files changed, 355 insertions(+), 11 deletions(-) create mode 100644 db/changes/10260-holidays/00-travel_cloneWithEntries.sql create mode 100644 modules/travel/back/methods/travel/cloneWithEntries.js create mode 100644 modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js diff --git a/db/changes/10260-holidays/00-travel_cloneWithEntries.sql b/db/changes/10260-holidays/00-travel_cloneWithEntries.sql new file mode 100644 index 000000000..1302a78ca --- /dev/null +++ b/db/changes/10260-holidays/00-travel_cloneWithEntries.sql @@ -0,0 +1,135 @@ +-- DROP PROCEDURE `vn`.`clonTravelComplete`; + +DELIMITER $$ +USE `vn`$$ +CREATE + DEFINER = root@`%` PROCEDURE `vn`.`travel_cloneWithEntries`(IN vTravelFk INT, IN vDateStart DATE, IN vDateEnd DATE, + IN vRef VARCHAR(255), OUT vNewTravelFk INT) +BEGIN + DECLARE vEntryNew INT; + DECLARE vDone BOOLEAN DEFAULT FALSE; + DECLARE vAuxEntryFk INT; + DECLARE vRsEntry CURSOR FOR + SELECT e.id + FROM entry e + JOIN travel t + ON t.id = e.travelFk + WHERE e.travelFk = vTravelFk; + + DECLARE vRsBuy CURSOR FOR + SELECT b.* + FROM buy b + JOIN entry e + ON b.entryFk = e.id + WHERE e.travelFk = vNewTravelFk and b.entryFk=vNewTravelFk + ORDER BY e.id; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + INSERT INTO travel (shipped,landed, warehouseInFk, warehouseOutFk, agencyFk, ref, isDelivered, isReceived, m3, kg) + SELECT vDateStart, vDateEnd,warehouseInFk, warehouseOutFk, agencyFk, vRef, isDelivered, isReceived, m3, kg + FROM travel + WHERE id = vTravelFk; + + SET vNewTravelFk = LAST_INSERT_ID(); + SET vDone = FALSE; + OPEN vRsEntry ; + FETCH vRsEntry INTO vAuxEntryFk; + + WHILE NOT vDone DO + INSERT INTO entry (supplierFk, + ref, + isInventory, + isConfirmed, + isOrdered, + isRaid, + commission, + created, + evaNotes, + travelFk, + currencyFk, + companyFk, + gestDocFk, + invoiceInFk) + SELECT supplierFk, + ref, + isInventory, + isConfirmed, + isOrdered, + isRaid, + commission, + created, + evaNotes, + vNewTravelFk, + currencyFk, + companyFk, + gestDocFk, + invoiceInFk + FROM entry + WHERE id = vAuxEntryFk; + + SET vEntryNew = LAST_INSERT_ID(); + + + INSERT INTO buy (entryFk, + itemFk, + quantity, + buyingValue, + packageFk, + stickers, + freightValue, + packageValue, + comissionValue, + packing, + `grouping`, + groupingMode, + location, + price1, + price2, + price3, + minPrice, + producer, + printedStickers, + isChecked, + weight) + SELECT vEntryNew, + itemFk, + quantity, + buyingValue, + packageFk, + stickers, + freightValue, + packageValue, + comissionValue, + packing, + `grouping`, + groupingMode, + location, + price1, + price2, + price3, + minPrice, + producer, + printedStickers, + isChecked, + weight + FROM buy + WHERE entryFk = vAuxEntryFk; + + + FETCH vRsEntry INTO vAuxEntryFk; + END WHILE; + CLOSE vRsEntry; + COMMIT; +END;$$ +DELIMITER ; + + diff --git a/loopback/util/log.js b/loopback/util/log.js index baba3e827..d81fc39a0 100644 --- a/loopback/util/log.js +++ b/loopback/util/log.js @@ -33,6 +33,9 @@ exports.translateValues = async(instance, changes) => { }).format(date); } + if (changes instanceof instance) + changes = changes.__data; + const properties = Object.assign({}, changes); for (let property in properties) { const relation = getRelation(instance, property); @@ -41,13 +44,14 @@ exports.translateValues = async(instance, changes) => { if (relation) { let fieldsToShow = ['alias', 'name', 'code', 'description']; - const log = instance.definition.settings.log; + const modelName = relation.model; + const model = models[modelName]; + const log = model.definition.settings.log; if (log && log.showField) - fieldsToShow = log.showField; + fieldsToShow = [log.showField]; - const model = relation.model; - const row = await models[model].findById(value, { + const row = await model.findById(value, { fields: fieldsToShow }); const newValue = getValue(row); diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index 2763f1bd0..8bafe5403 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -130,7 +130,7 @@ module.exports = Self => { let logRecord = { originFk: cleanInstance.id, userFk: myUserId, - action: 'create', + action: 'insert', changedModel: 'Ticket', changedModelId: cleanInstance.id, oldInstance: {}, diff --git a/modules/travel/back/methods/travel/cloneWithEntries.js b/modules/travel/back/methods/travel/cloneWithEntries.js new file mode 100644 index 000000000..82d6b40e2 --- /dev/null +++ b/modules/travel/back/methods/travel/cloneWithEntries.js @@ -0,0 +1,87 @@ +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +const UserError = require('vn-loopback/util/user-error'); +const loggable = require('vn-loopback/util/log'); + +module.exports = Self => { + Self.remoteMethodCtx('cloneWithEntries', { + description: 'Clone travel', + accessType: 'WRITE', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The original travel id', + http: {source: 'path'} + }], + returns: { + type: 'Object', + description: 'The new cloned travel id', + root: true, + }, + http: { + path: `/:id/cloneWithEntries`, + verb: 'post' + } + }); + + Self.cloneWithEntries = async(ctx, id) => { + const userId = ctx.req.accessToken.userId; + const conn = Self.dataSource.connector; + const models = Self.app.models; + const travel = await Self.findById(id, { + fields: [ + 'id', + 'shipped', + 'landed', + 'warehouseInFk', + 'warehouseOutFk', + 'agencyFk', + 'ref' + ] + }); + const started = new Date(); + const ended = new Date(); + + if (!travel) + throw new UserError('Travel not found'); + + let stmts = []; + let stmt; + + stmt = new ParameterizedSQL( + `CALL travel_cloneWithEntries(?, ?, ?, ?, @vTravelFk)`, [ + id, started, ended, travel.ref]); + + stmts.push(stmt); + const index = stmts.push('SELECT @vTravelFk AS id') - 1; + + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await conn.executeStmt(sql); + const [lastInsert] = result[index]; + const newTravel = await Self.findById(lastInsert.id, { + fields: [ + 'id', + 'shipped', + 'landed', + 'warehouseInFk', + 'warehouseOutFk', + 'agencyFk', + 'ref' + ] + }); + + const oldProperties = await loggable.translateValues(Self, travel); + const newProperties = await loggable.translateValues(Self, newTravel); + await models.TravelLog.create({ + originFk: newTravel.id, + userFk: userId, + action: 'insert', + changedModel: 'Travel', + changedModelId: newTravel.id, + oldInstance: oldProperties, + newInstance: newProperties + }); + + return newTravel.id; + }; +}; diff --git a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js new file mode 100644 index 000000000..ab7d3aa1d --- /dev/null +++ b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js @@ -0,0 +1,79 @@ +const app = require('vn-loopback/server/server'); + +// #2687 - Cannot make a data rollback because of the triggers +xdescribe('Travel cloneWithEntries()', () => { + const models = app.models; + const travelId = 5; + const currentUserId = 102; + const ctx = {req: {accessToken: {userId: currentUserId}}}; + let travelBefore; + let newTravelId; + + afterAll(async done => { + try { + const entries = await models.Entry.find({ + where: { + travelFk: newTravelId + } + }); + const entriesId = entries.map(entry => entry.id); + + // Destroy all entries buys + await models.Buy.destroyAll({ + where: { + entryFk: {inq: entriesId} + } + }); + + // Destroy travel entries + await models.Entry.destroyAll({ + where: { + travelFk: newTravelId + } + }); + + // Destroy new travel + await models.Travel.destroyById(newTravelId); + + // Restore original travel shipped & landed + const travel = await models.Travel.findById(travelId); + await travel.updateAttributes({ + shipped: travelBefore.shipped, + landed: travelBefore.landed + }); + } catch (error) { + console.error(error); + } + + done(); + }); + + it(`should clone the travel and the containing entries`, async() => { + const warehouseThree = 3; + const agencyModeOne = 1; + const yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + + travelBefore = await models.Travel.findById(travelId); + await travelBefore.updateAttributes({ + shipped: yesterday, + landed: yesterday + }); + + newTravelId = await models.Travel.cloneWithEntries(ctx, travelId); + const travelEntries = await models.Entry.find({ + where: { + travelFk: newTravelId + } + }); + + const newTravel = await models.Travel.findById(travelId); + + expect(newTravelId).not.toEqual(travelId); + expect(newTravel.ref).toEqual('fifth travel'); + expect(newTravel.warehouseInFk).toEqual(warehouseThree); + expect(newTravel.warehouseOutFk).toEqual(warehouseThree); + expect(newTravel.agencyFk).toEqual(agencyModeOne); + expect(travelEntries.length).toBeGreaterThan(0); + }); +}); diff --git a/modules/travel/back/models/travel.js b/modules/travel/back/models/travel.js index b8a1a24b3..46d33b305 100644 --- a/modules/travel/back/models/travel.js +++ b/modules/travel/back/models/travel.js @@ -8,6 +8,7 @@ module.exports = Self => { require('../methods/travel/deleteThermograph')(Self); require('../methods/travel/updateThermograph')(Self); require('../methods/travel/extraCommunityFilter')(Self); + require('../methods/travel/cloneWithEntries')(Self); Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') diff --git a/modules/travel/front/create/index.js b/modules/travel/front/create/index.js index 7d0020034..9a9c5ce9d 100644 --- a/modules/travel/front/create/index.js +++ b/modules/travel/front/create/index.js @@ -9,7 +9,7 @@ class Controller extends Section { onSubmit() { return this.$.watcher.submit().then( - res => this.$state.go('travel.card.summary', {id: res.data.id}) + res => this.$state.go('travel.card.basicData', {id: res.data.id}) ); } } diff --git a/modules/travel/front/create/index.spec.js b/modules/travel/front/create/index.spec.js index 4bde7747e..99f52b322 100644 --- a/modules/travel/front/create/index.spec.js +++ b/modules/travel/front/create/index.spec.js @@ -22,7 +22,7 @@ describe('Travel Component vnTravelCreate', () => { controller.onSubmit(); - expect(controller.$state.go).toHaveBeenCalledWith('travel.card.summary', {id: 1234}); + expect(controller.$state.go).toHaveBeenCalledWith('travel.card.basicData', {id: 1234}); }); }); @@ -39,4 +39,3 @@ describe('Travel Component vnTravelCreate', () => { }); }); }); - diff --git a/modules/travel/front/descriptor-menu/index.html b/modules/travel/front/descriptor-menu/index.html index 1eb558008..714d3ce3f 100644 --- a/modules/travel/front/descriptor-menu/index.html +++ b/modules/travel/front/descriptor-menu/index.html @@ -10,6 +10,12 @@ translate> Clone travel + + Clone travel and his entries + @@ -20,3 +26,11 @@ question="Do you want to clone this travel?" message="All it's properties will be copied"> + + + + diff --git a/modules/travel/front/descriptor-menu/index.js b/modules/travel/front/descriptor-menu/index.js index 975cd9134..e83a90b97 100644 --- a/modules/travel/front/descriptor-menu/index.js +++ b/modules/travel/front/descriptor-menu/index.js @@ -59,6 +59,11 @@ class Controller extends Section { }); this.$state.go('travel.create', {q: params}); } + + onCloneWithEntriesAccept() { + this.$http.post(`Travels/${this.travelId}/cloneWithEntries`) + .then(res => this.$state.go('travel.card.basicData', {id: res.data})); + } } Controller.$inject = ['$element', '$scope']; diff --git a/modules/travel/front/descriptor-menu/index.spec.js b/modules/travel/front/descriptor-menu/index.spec.js index d66f3a435..3d94a0963 100644 --- a/modules/travel/front/descriptor-menu/index.spec.js +++ b/modules/travel/front/descriptor-menu/index.spec.js @@ -2,11 +2,14 @@ import './index.js'; describe('Travel Component vnTravelDescriptorMenu', () => { let controller; + let $httpBackend; beforeEach(ngModule('travel')); - beforeEach(inject(($componentController, $state,) => { + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; const $element = angular.element(''); controller = $componentController('vnTravelDescriptorMenu', {$element}); + controller._travelId = 5; })); describe('onCloneAccept()', () => { @@ -36,4 +39,18 @@ describe('Travel Component vnTravelDescriptorMenu', () => { expect(controller.$state.go).toHaveBeenCalledWith('travel.create', {'q': params}); }); }); + + describe('onCloneWithEntriesAccept()', () => { + it('should make an HTTP query and then call to the $state.go method with the returned id', () => { + jest.spyOn(controller.$state, 'go').mockReturnValue('ok'); + + $httpBackend.expect('POST', `Travels/${controller.travelId}/cloneWithEntries`).respond(200, 9); + controller.onCloneWithEntriesAccept(); + $httpBackend.flush(); + + expect(controller.$state.go).toHaveBeenCalledWith('travel.card.basicData', { + id: jasmine.any(Number) + }); + }); + }); }); diff --git a/modules/travel/front/descriptor-menu/locale/es.yml b/modules/travel/front/descriptor-menu/locale/es.yml index 117611660..ca61c4e01 100644 --- a/modules/travel/front/descriptor-menu/locale/es.yml +++ b/modules/travel/front/descriptor-menu/locale/es.yml @@ -1 +1,3 @@ -Clone travel: Clonar envío \ No newline at end of file +Clone travel: Clonar envío +Clone travel and his entries: Clonar travel y sus entradas +Do you want to clone this travel and all containing entries?: ¿Quieres clonar este travel y todas las entradas que contiene? \ No newline at end of file diff --git a/modules/travel/front/locale/es.yml b/modules/travel/front/locale/es.yml index 06fc80601..7231d37cd 100644 --- a/modules/travel/front/locale/es.yml +++ b/modules/travel/front/locale/es.yml @@ -13,7 +13,7 @@ Received: Recibido Travel id: Id envío Search travels by id: Buscar envíos por identificador New travel: Nuevo envío -travel: envio +travel: envío # Sections Travels: Envíos diff --git a/modules/travel/front/summary/index.html b/modules/travel/front/summary/index.html index 8815c09e2..de6f6e979 100644 --- a/modules/travel/front/summary/index.html +++ b/modules/travel/front/summary/index.html @@ -7,6 +7,7 @@ {{$ctrl.travelData.id}} - {{$ctrl.travelData.ref}} + From f29840b37b368f878dc4b4c9453eed94946091f0 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 29 Dec 2020 07:52:36 +0100 Subject: [PATCH 04/23] Buyer ACL --- modules/travel/front/descriptor-menu/index.html | 2 ++ modules/travel/front/descriptor-menu/index.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/modules/travel/front/descriptor-menu/index.html b/modules/travel/front/descriptor-menu/index.html index 714d3ce3f..171aa89ec 100644 --- a/modules/travel/front/descriptor-menu/index.html +++ b/modules/travel/front/descriptor-menu/index.html @@ -7,12 +7,14 @@ Clone travel Clone travel and his entries diff --git a/modules/travel/front/descriptor-menu/index.js b/modules/travel/front/descriptor-menu/index.js index e83a90b97..d34c5495b 100644 --- a/modules/travel/front/descriptor-menu/index.js +++ b/modules/travel/front/descriptor-menu/index.js @@ -48,6 +48,10 @@ class Controller extends Section { .then(res => this.travel = res.data); } + get isBuyer() { + return this.aclService.hasAny(['buyer']); + } + onCloneAccept() { const params = JSON.stringify({ ref: this.travel.ref, From 2886e02328db37fea4dc01fa39bed770a984a6f7 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 29 Dec 2020 08:50:12 +0100 Subject: [PATCH 05/23] Enabled loggable for locations --- .../{10260-december => 10260-holidays}/00-zoneLog.sql | 0 modules/zone/back/models/zone-included.json | 7 ++++++- modules/zone/back/models/zone.json | 5 ----- 3 files changed, 6 insertions(+), 6 deletions(-) rename db/changes/{10260-december => 10260-holidays}/00-zoneLog.sql (100%) diff --git a/db/changes/10260-december/00-zoneLog.sql b/db/changes/10260-holidays/00-zoneLog.sql similarity index 100% rename from db/changes/10260-december/00-zoneLog.sql rename to db/changes/10260-holidays/00-zoneLog.sql diff --git a/modules/zone/back/models/zone-included.json b/modules/zone/back/models/zone-included.json index 9f9508824..e462b7a65 100644 --- a/modules/zone/back/models/zone-included.json +++ b/modules/zone/back/models/zone-included.json @@ -1,6 +1,11 @@ { "name": "ZoneIncluded", - "base": "VnModel", + "base": "Loggable", + "log": { + "model": "ZoneLog", + "relation": "zone", + "showField": "isIncluded" + }, "options": { "mysql": { "table": "zoneIncluded" diff --git a/modules/zone/back/models/zone.json b/modules/zone/back/models/zone.json index 1d1ccfd90..bafef0a95 100644 --- a/modules/zone/back/models/zone.json +++ b/modules/zone/back/models/zone.json @@ -43,11 +43,6 @@ } }, "relations": { - "geolocations": { - "type": "hasMany", - "model": "ZoneGeo", - "foreignKey": "zoneFk" - }, "agencyMode": { "type": "belongsTo", "model": "AgencyMode", From 20862db8546bae63d37f037917430982fef9ecaf Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 29 Dec 2020 13:39:10 +0100 Subject: [PATCH 06/23] 2690 - Duplicated foreign key fix --- loopback/common/models/vn-model.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index f56183df2..56fb7e656 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -146,8 +146,14 @@ module.exports = function(Self) { function replaceErr(err, replaceErrFunc) { if (Array.isArray(err)) { let errs = []; - for (let e of err) - errs.push(replaceErrFunc(e)); + const errors = err.filter(error => { + return error != undefined && error != null; + }); + for (let e of errors) { + if (!(e instanceof UserError)) + errs.push(replaceErrFunc(e)); + else errs.push(e); + } return errs; } return replaceErrFunc(err); From edd25a347bd6c04806f84767b57f1983bd9cf3db Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 29 Dec 2020 13:44:12 +0100 Subject: [PATCH 07/23] Moved line --- loopback/common/models/vn-model.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 56fb7e656..cc3eede8e 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -145,10 +145,10 @@ module.exports = function(Self) { rewriteDbError(replaceErrFunc) { function replaceErr(err, replaceErrFunc) { if (Array.isArray(err)) { - let errs = []; const errors = err.filter(error => { return error != undefined && error != null; }); + let errs = []; for (let e of errors) { if (!(e instanceof UserError)) errs.push(replaceErrFunc(e)); From c2d50c6044cb160acaf7df5af0ab5b72cc93e92b Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 29 Dec 2020 14:02:26 +0100 Subject: [PATCH 08/23] Dup entry error handler --- .../back/methods/travel/cloneWithEntries.js | 68 ++++++++++--------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/modules/travel/back/methods/travel/cloneWithEntries.js b/modules/travel/back/methods/travel/cloneWithEntries.js index 82d6b40e2..ef385f1e0 100644 --- a/modules/travel/back/methods/travel/cloneWithEntries.js +++ b/modules/travel/back/methods/travel/cloneWithEntries.js @@ -48,40 +48,46 @@ module.exports = Self => { let stmts = []; let stmt; - stmt = new ParameterizedSQL( - `CALL travel_cloneWithEntries(?, ?, ?, ?, @vTravelFk)`, [ - id, started, ended, travel.ref]); + try { + stmt = new ParameterizedSQL( + `CALL travel_cloneWithEntries(?, ?, ?, ?, @vTravelFk)`, [ + id, started, ended, travel.ref]); - stmts.push(stmt); - const index = stmts.push('SELECT @vTravelFk AS id') - 1; + stmts.push(stmt); + const index = stmts.push('SELECT @vTravelFk AS id') - 1; - const sql = ParameterizedSQL.join(stmts, ';'); - const result = await conn.executeStmt(sql); - const [lastInsert] = result[index]; - const newTravel = await Self.findById(lastInsert.id, { - fields: [ - 'id', - 'shipped', - 'landed', - 'warehouseInFk', - 'warehouseOutFk', - 'agencyFk', - 'ref' - ] - }); + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await conn.executeStmt(sql); + const [lastInsert] = result[index]; + const newTravel = await Self.findById(lastInsert.id, { + fields: [ + 'id', + 'shipped', + 'landed', + 'warehouseInFk', + 'warehouseOutFk', + 'agencyFk', + 'ref' + ] + }); - const oldProperties = await loggable.translateValues(Self, travel); - const newProperties = await loggable.translateValues(Self, newTravel); - await models.TravelLog.create({ - originFk: newTravel.id, - userFk: userId, - action: 'insert', - changedModel: 'Travel', - changedModelId: newTravel.id, - oldInstance: oldProperties, - newInstance: newProperties - }); + const oldProperties = await loggable.translateValues(Self, travel); + const newProperties = await loggable.translateValues(Self, newTravel); + await models.TravelLog.create({ + originFk: newTravel.id, + userFk: userId, + action: 'insert', + changedModel: 'Travel', + changedModelId: newTravel.id, + oldInstance: oldProperties, + newInstance: newProperties + }); - return newTravel.id; + return newTravel.id; + } catch (error) { + if (error.code === 'ER_DUP_ENTRY') + throw new UserError('A travel with this data already exists'); + throw error; + } }; }; From 23a1494fdd2dab6c9d79adb41466f8f20d0f3db2 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Tue, 29 Dec 2020 14:05:43 +0100 Subject: [PATCH 09/23] selectors for create travel --- e2e/helpers/selectors.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 11087d2d4..78efd6ecc 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -858,6 +858,15 @@ export default { dotMenu: 'vn-travel-descriptor vn-icon-button[icon="more_vert"]', dotMenuClone: '#clone' }, + travelCreate: { + reference: 'vn-travel-create vn-textfield[ng-model="$ctrl.travel.ref"]', + agency: 'vn-travel-create vn-autocomplete[ng-model="$ctrl.travel.agencyModeFk"]', + shipped: 'vn-travel-create vn-date-picker[ng-model="$ctrl.travel.shipped"]', + landed: 'vn-travel-create vn-date-picker[ng-model="$ctrl.travel.landed"]', + warehouseOut: 'vn-travel-create vn-autocomplete[ng-model="$ctrl.travel.warehouseOutFk"]', + warehouseIn: 'vn-travel-create vn-autocomplete[ng-model="$ctrl.travel.warehouseInFk"]', + saveButton: 'vn-travel-create vn-submit[label="Save"]' + }, zoneIndex: { searchResult: 'vn-zone-index a.vn-tr', }, From c9ae5989f9b2652f59637c00ef25ba37bd9e5b22 Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Wed, 30 Dec 2020 10:49:02 +0100 Subject: [PATCH 10/23] Add id on description of typeTransiction on client and supplier --- modules/client/front/fiscal-data/index.html | 11 ++++------- modules/supplier/front/fiscal-data/index.html | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html index 2b671c69a..a03bcfdd4 100644 --- a/modules/client/front/fiscal-data/index.html +++ b/modules/client/front/fiscal-data/index.html @@ -24,12 +24,6 @@ data="sageTaxTypes" order="vat"> - -
@@ -69,12 +63,15 @@ + {{id}}: {{transaction}} - - + {{id}}: {{transaction}} From 77e3ae9fee1f58f9711b7001018956a042c276cf Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Wed, 30 Dec 2020 10:49:42 +0100 Subject: [PATCH 11/23] Modificated the e2e of fiscal data on client --- e2e/paths/02-client/03_edit_fiscal_data.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/02-client/03_edit_fiscal_data.spec.js b/e2e/paths/02-client/03_edit_fiscal_data.spec.js index da04c813a..614ede0f0 100644 --- a/e2e/paths/02-client/03_edit_fiscal_data.spec.js +++ b/e2e/paths/02-client/03_edit_fiscal_data.spec.js @@ -200,7 +200,7 @@ describe('Client Edit fiscalData path', () => { it('should confirm the sageTransaction have been edited', async() => { const result = await page.waitToGetProperty(selectors.clientFiscalData.sageTransaction, 'value'); - expect(result).toEqual('Regularización de inversiones'); + expect(result).toEqual('36: Regularización de inversiones'); }); it('should confirm the transferor have been edited', async() => { From 52cb6c076c5b55cfe06fb9499f72a8db54c65ba5 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 30 Dec 2020 14:54:51 +0100 Subject: [PATCH 12/23] travel cloneWithEntries path + e2e fix --- e2e/helpers/selectors.js | 7 ++- e2e/paths/10-travel/03_descriptor.spec.js | 43 +++++++++++++++++++ .../10-travel/04_extra_community.spec.js | 1 + 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 2260e0bd8..066d432c8 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -831,7 +831,8 @@ export default { firstSearchResult: 'vn-travel-index vn-tbody > a:nth-child(1)' }, travelExtraCommunity: { - firstTravelReference: 'vn-travel-extra-community > vn-data-viewer div > vn-tbody > vn-tr > vn-td-editable', + anySearchResult: 'vn-travel-extra-community > vn-data-viewer div > vn-tbody > vn-tr', + firstTravelReference: 'vn-travel-extra-community vn-card:nth-child(1) vn-td-editable', removeContinentFilter: 'vn-searchbar > form > vn-textfield > div.container > div.prepend > prepend > div > span:nth-child(3) > vn-icon > i' }, travelBasicData: { @@ -863,7 +864,9 @@ export default { travelDescriptor: { filterByAgencyButton: 'vn-descriptor-content .quicklinks > div:nth-child(1) > vn-quick-link > a[vn-tooltip="All travels with current agency"]', dotMenu: 'vn-travel-descriptor vn-icon-button[icon="more_vert"]', - dotMenuClone: '#clone' + dotMenuClone: '#clone', + dotMenuCloneWithEntries: '#cloneWithEntries', + acceptClonation: 'tpl-buttons > button[response="accept"]' }, travelCreate: { reference: 'vn-travel-create vn-textfield[ng-model="$ctrl.travel.ref"]', diff --git a/e2e/paths/10-travel/03_descriptor.spec.js b/e2e/paths/10-travel/03_descriptor.spec.js index 3f79bea06..bf6c3a02e 100644 --- a/e2e/paths/10-travel/03_descriptor.spec.js +++ b/e2e/paths/10-travel/03_descriptor.spec.js @@ -42,4 +42,47 @@ describe('Travel descriptor path', () => { expect(state).toBe('travel.create'); }); + + it('should edit the data to clone and then get redirected to the cloned travel basic data', async() => { + await page.clearInput(selectors.travelCreate.reference); + await page.write(selectors.travelCreate.reference, 'reference'); + await page.autocompleteSearch(selectors.travelCreate.agency, 'entanglement'); + await page.pickDate(selectors.travelCreate.shipped); + await page.pickDate(selectors.travelCreate.landed); + await page.autocompleteSearch(selectors.travelCreate.warehouseOut, 'warehouse one'); + await page.autocompleteSearch(selectors.travelCreate.warehouseIn, 'warehouse two'); + await page.waitToClick(selectors.travelCreate.saveButton); + await page.waitForState('travel.card.basicData'); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should atempt to clone the travel and its entries using the descriptor menu but receive an error', async() => { + await page.waitToClick(selectors.travelDescriptor.dotMenu); + await page.waitToClick(selectors.travelDescriptor.dotMenuCloneWithEntries); + await page.waitToClick(selectors.travelDescriptor.acceptClonation); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('A travel with this data already exists'); + }); + + it('should update the landed date to a future date to enable cloneWithEntries', async() => { + const nextMonth = new Date(); + nextMonth.setMonth(nextMonth.getMonth() + 1); + await page.pickDate(selectors.travelBasicData.deliveryDate, nextMonth); + await page.waitToClick(selectors.travelBasicData.save); + await page.waitForState('travel.card.basicData'); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should navigate to the summary and then clone the travel and its entries using the descriptor menu to get redirected to the cloned travel basic data', async() => { + await page.waitToClick('vn-icon[icon="preview"]'); // summary icon + await page.waitToClick(selectors.travelDescriptor.dotMenu); + await page.waitToClick(selectors.travelDescriptor.dotMenuCloneWithEntries); + await page.waitToClick(selectors.travelDescriptor.acceptClonation); + await page.waitForState('travel.card.basicData'); + }); }); diff --git a/e2e/paths/10-travel/04_extra_community.spec.js b/e2e/paths/10-travel/04_extra_community.spec.js index bc81c086c..7a37b89e4 100644 --- a/e2e/paths/10-travel/04_extra_community.spec.js +++ b/e2e/paths/10-travel/04_extra_community.spec.js @@ -18,6 +18,7 @@ describe('Travel extra community path', () => { it('should edit the travel reference', async() => { await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter); + await page.waitForSpinnerLoad(); await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelReference, 'edited reference'); }); From b4038990723a8d27db8d7fa3b1b03ff2e87a7ac2 Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Wed, 30 Dec 2020 15:39:27 +0100 Subject: [PATCH 13/23] modificated value of "order" on client and supplier --- modules/client/front/fiscal-data/index.html | 2 +- modules/supplier/front/fiscal-data/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html index a03bcfdd4..2ae9e0475 100644 --- a/modules/client/front/fiscal-data/index.html +++ b/modules/client/front/fiscal-data/index.html @@ -69,7 +69,7 @@ label="Sage transaction type" search-function="{or: [{id: $search}, {transaction: {like: '%'+ $search +'%'}}]}" vn-acl="salesAssistant" - order="id" + order="transaction" rule> {{id}}: {{transaction}} diff --git a/modules/supplier/front/fiscal-data/index.html b/modules/supplier/front/fiscal-data/index.html index 2c7b09f95..fc44468f4 100644 --- a/modules/supplier/front/fiscal-data/index.html +++ b/modules/supplier/front/fiscal-data/index.html @@ -82,7 +82,7 @@ value-field="id" label="Sage transaction type" search-function="{or: [{id: $search}, {transaction: {like: '%'+ $search +'%'}}]}" - order="id" + order="transaction" rule> {{id}}: {{transaction}} From 12d6948c0e53ae39a72eff7562e95e68c4337e68 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 31 Dec 2020 09:17:55 +0100 Subject: [PATCH 14/23] Route.index e2e path needs time to load results --- e2e/paths/08-route/03_create_and_clone.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/paths/08-route/03_create_and_clone.spec.js b/e2e/paths/08-route/03_create_and_clone.spec.js index be758f788..c0132362f 100644 --- a/e2e/paths/08-route/03_create_and_clone.spec.js +++ b/e2e/paths/08-route/03_create_and_clone.spec.js @@ -74,6 +74,7 @@ describe('Route create path', () => { }); it(`should clone the first route`, async() => { + await page.waitForTimeout(1000); // needs time for the index to show all items await page.waitToClick(selectors.routeIndex.firstRouteCheckbox); await page.waitToClick(selectors.routeIndex.cloneButton); await page.waitToClick(selectors.routeIndex.submitClonationButton); From 4754d5481b244b12fd222868d958646c3c70cb1e Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 31 Dec 2020 10:13:42 +0100 Subject: [PATCH 15/23] added street arg to updateFiscalData method --- modules/supplier/back/methods/supplier/updateFiscalData.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/supplier/back/methods/supplier/updateFiscalData.js b/modules/supplier/back/methods/supplier/updateFiscalData.js index be031a18a..bbbb658b2 100644 --- a/modules/supplier/back/methods/supplier/updateFiscalData.js +++ b/modules/supplier/back/methods/supplier/updateFiscalData.js @@ -41,6 +41,10 @@ module.exports = Self => { arg: 'postCode', type: 'string' }, + { + arg: 'street', + type: 'string' + }, { arg: 'city', type: 'string' From 3b73e1bee244887902af90592eeb8c30be9f6f4b Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 31 Dec 2020 10:28:35 +0100 Subject: [PATCH 16/23] supplier updateFiscalData changed to table config --- .../back/methods/supplier/updateFiscalData.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/supplier/back/methods/supplier/updateFiscalData.js b/modules/supplier/back/methods/supplier/updateFiscalData.js index bbbb658b2..daa602af0 100644 --- a/modules/supplier/back/methods/supplier/updateFiscalData.js +++ b/modules/supplier/back/methods/supplier/updateFiscalData.js @@ -23,27 +23,27 @@ module.exports = Self => { }, { arg: 'account', - type: 'string' + type: 'any' }, { arg: 'sageTaxTypeFk', - type: 'number' + type: 'any' }, { arg: 'sageWithholdingFk', - type: 'number' + type: 'any' }, { arg: 'sageTransactionTypeFk', - type: 'number' + type: 'any' }, { arg: 'postCode', - type: 'string' + type: 'any' }, { arg: 'street', - type: 'string' + type: 'any' }, { arg: 'city', @@ -51,11 +51,11 @@ module.exports = Self => { }, { arg: 'provinceFk', - type: 'number' + type: 'any' }, { arg: 'countryFk', - type: 'number' + type: 'any' }], returns: { arg: 'res', From 6bbe33433d0ec82c99bdc2f3c785c4709eefbeeb Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 31 Dec 2020 10:30:51 +0100 Subject: [PATCH 17/23] 2696 - Geo autocompletion fix --- e2e/paths/06-claim/05_summary.spec.js | 2 +- e2e/paths/06-claim/06_descriptor.spec.js | 2 +- e2e/paths/13-supplier/03_fiscal_data.spec.js | 2 +- modules/client/front/address/edit/index.js | 6 ++++-- modules/client/front/fiscal-data/index.js | 6 ++++-- modules/supplier/front/fiscal-data/index.js | 6 ++++-- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/e2e/paths/06-claim/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js index c63e686cb..cea5edb55 100644 --- a/e2e/paths/06-claim/05_summary.spec.js +++ b/e2e/paths/06-claim/05_summary.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -describe('claim Summary path', () => { +describe('Claim summary path', () => { let browser; let page; const claimId = '4'; diff --git a/e2e/paths/06-claim/06_descriptor.spec.js b/e2e/paths/06-claim/06_descriptor.spec.js index c0affb3cc..0826bad63 100644 --- a/e2e/paths/06-claim/06_descriptor.spec.js +++ b/e2e/paths/06-claim/06_descriptor.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -describe('claim Descriptor path', () => { +describe('Claim descriptor path', () => { let browser; let page; const claimId = '1'; diff --git a/e2e/paths/13-supplier/03_fiscal_data.spec.js b/e2e/paths/13-supplier/03_fiscal_data.spec.js index d929288d4..06fd2605b 100644 --- a/e2e/paths/13-supplier/03_fiscal_data.spec.js +++ b/e2e/paths/13-supplier/03_fiscal_data.spec.js @@ -26,7 +26,7 @@ describe('Supplier fiscal data path', () => { await page.clearInput(selectors.supplierFiscalData.socialName); await page.write(selectors.supplierFiscalData.socialName, 'Farmer King SL'); await page.clearInput(selectors.supplierFiscalData.taxNumber); - await page.write(selectors.supplierFiscalData.taxNumber, 'invalid tax number'); + await page.write(selectors.supplierFiscalData.taxNumber, 'Wrong tax number'); await page.clearInput(selectors.supplierFiscalData.account); await page.write(selectors.supplierFiscalData.account, 'edited account number'); await page.autocompleteSearch(selectors.supplierFiscalData.sageWihholding, 'retencion estimacion objetiva'); diff --git a/modules/client/front/address/edit/index.js b/modules/client/front/address/edit/index.js index 30201b880..b8d2e28a4 100644 --- a/modules/client/front/address/edit/index.js +++ b/modules/client/front/address/edit/index.js @@ -42,9 +42,10 @@ export default class Controller extends Section { // Town auto complete set town(selection) { + const oldValue = this._town; this._town = selection; - if (!selection) return; + if (!selection || !oldValue) return; const province = selection.province; const postcodes = selection.postcodes; @@ -62,9 +63,10 @@ export default class Controller extends Section { // Postcode auto complete set postcode(selection) { + const oldValue = this._postcode; this._postcode = selection; - if (!selection) return; + if (!selection || !oldValue) return; const town = selection.town; const province = town.province; diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index 397bb20e1..73580af43 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -106,9 +106,10 @@ export default class Controller extends Section { // Province auto complete set province(selection) { + const oldValue = this._province; this._province = selection; - if (!selection) return; + if (!selection || !oldValue) return; const country = selection.country; @@ -122,9 +123,10 @@ export default class Controller extends Section { // Town auto complete set town(selection) { + const oldValue = this._town; this._town = selection; - if (!selection) return; + if (!selection || !oldValue) return; const province = selection.province; const country = province.country; diff --git a/modules/supplier/front/fiscal-data/index.js b/modules/supplier/front/fiscal-data/index.js index f2929c91f..8a6a51249 100644 --- a/modules/supplier/front/fiscal-data/index.js +++ b/modules/supplier/front/fiscal-data/index.js @@ -8,9 +8,10 @@ export default class Controller extends Section { // Province auto complete set province(selection) { + const oldValue = this._province; this._province = selection; - if (!selection) return; + if (!selection || !oldValue) return; const country = selection.country; @@ -24,9 +25,10 @@ export default class Controller extends Section { // Town auto complete set town(selection) { + const oldValue = this._town; this._town = selection; - if (!selection) return; + if (!selection || !oldValue) return; const province = selection.province; const country = province.country; From 7711367e357d9acd4c9b1774d7315a1e81bbed19 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 31 Dec 2020 10:39:09 +0100 Subject: [PATCH 18/23] added summary state check to e2e path --- e2e/paths/10-travel/03_descriptor.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/paths/10-travel/03_descriptor.spec.js b/e2e/paths/10-travel/03_descriptor.spec.js index bf6c3a02e..cdca379ad 100644 --- a/e2e/paths/10-travel/03_descriptor.spec.js +++ b/e2e/paths/10-travel/03_descriptor.spec.js @@ -80,6 +80,7 @@ describe('Travel descriptor path', () => { it('should navigate to the summary and then clone the travel and its entries using the descriptor menu to get redirected to the cloned travel basic data', async() => { await page.waitToClick('vn-icon[icon="preview"]'); // summary icon + await page.waitForState('travel.card.summary'); await page.waitToClick(selectors.travelDescriptor.dotMenu); await page.waitToClick(selectors.travelDescriptor.dotMenuCloneWithEntries); await page.waitToClick(selectors.travelDescriptor.acceptClonation); From 5dd7db23ecd1d0f235bdc6f8da061e9bb9f9ca18 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 31 Dec 2020 10:39:37 +0100 Subject: [PATCH 19/23] submit should always be enabled for creation forms --- modules/travel/front/create/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/travel/front/create/index.html b/modules/travel/front/create/index.html index 1400ef6d7..0931c322e 100644 --- a/modules/travel/front/create/index.html +++ b/modules/travel/front/create/index.html @@ -43,7 +43,6 @@ Date: Thu, 31 Dec 2020 11:17:42 +0100 Subject: [PATCH 20/23] re-enabled working unit test --- modules/client/back/methods/client/specs/sendSms.spec.js | 3 +-- modules/client/back/methods/sms/send.spec.js | 3 +-- modules/ticket/back/methods/ticket/specs/sendSms.spec.js | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/client/back/methods/client/specs/sendSms.spec.js b/modules/client/back/methods/client/specs/sendSms.spec.js index 673a95cae..b299ac3c1 100644 --- a/modules/client/back/methods/client/specs/sendSms.spec.js +++ b/modules/client/back/methods/client/specs/sendSms.spec.js @@ -1,7 +1,6 @@ const app = require('vn-loopback/server/server'); -// Issue #2471 -xdescribe('client sendSms()', () => { +describe('client sendSms()', () => { let createdLog; afterAll(async done => { diff --git a/modules/client/back/methods/sms/send.spec.js b/modules/client/back/methods/sms/send.spec.js index 06288ffb5..612a16cf1 100644 --- a/modules/client/back/methods/sms/send.spec.js +++ b/modules/client/back/methods/sms/send.spec.js @@ -1,8 +1,7 @@ const app = require('vn-loopback/server/server'); const soap = require('soap'); -// Issue #2471 -xdescribe('sms send()', () => { +describe('sms send()', () => { it('should return the expected message and status code', async() => { const code = 200; const smsConfig = await app.models.SmsConfig.findOne(); diff --git a/modules/ticket/back/methods/ticket/specs/sendSms.spec.js b/modules/ticket/back/methods/ticket/specs/sendSms.spec.js index a08e7555a..20066a5ba 100644 --- a/modules/ticket/back/methods/ticket/specs/sendSms.spec.js +++ b/modules/ticket/back/methods/ticket/specs/sendSms.spec.js @@ -1,7 +1,6 @@ const app = require('vn-loopback/server/server'); -// Issue #2471 -xdescribe('ticket sendSms()', () => { +describe('ticket sendSms()', () => { let logId; afterAll(async done => { From bf53bff017f38317952588b7e32637651ec347bd Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 31 Dec 2020 12:25:20 +0100 Subject: [PATCH 21/23] e2e amends --- e2e/paths/13-supplier/03_fiscal_data.spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/e2e/paths/13-supplier/03_fiscal_data.spec.js b/e2e/paths/13-supplier/03_fiscal_data.spec.js index 06fd2605b..2ef52f7af 100644 --- a/e2e/paths/13-supplier/03_fiscal_data.spec.js +++ b/e2e/paths/13-supplier/03_fiscal_data.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -describe('Supplier fiscal data path', () => { +fdescribe('Supplier fiscal data path', () => { let browser; let page; @@ -23,6 +23,9 @@ describe('Supplier fiscal data path', () => { await page.clearInput(selectors.supplierFiscalData.country); await page.clearInput(selectors.supplierFiscalData.postCode); await page.write(selectors.supplierFiscalData.city, 'Valencia'); + await page.waitForTimeout(1000); // must repeat this action twice or fails. also #2699 may be a cool solution to this. + await page.clearInput(selectors.supplierFiscalData.city); + await page.write(selectors.supplierFiscalData.city, 'Valencia'); await page.clearInput(selectors.supplierFiscalData.socialName); await page.write(selectors.supplierFiscalData.socialName, 'Farmer King SL'); await page.clearInput(selectors.supplierFiscalData.taxNumber); From a867df7085226382c1f5d83f35bc530736052fbc Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 31 Dec 2020 12:38:54 +0100 Subject: [PATCH 22/23] removed focus on describe and added translation --- e2e/paths/13-supplier/03_fiscal_data.spec.js | 2 +- loopback/locale/en.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/e2e/paths/13-supplier/03_fiscal_data.spec.js b/e2e/paths/13-supplier/03_fiscal_data.spec.js index 2ef52f7af..0238c8704 100644 --- a/e2e/paths/13-supplier/03_fiscal_data.spec.js +++ b/e2e/paths/13-supplier/03_fiscal_data.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -fdescribe('Supplier fiscal data path', () => { +describe('Supplier fiscal data path', () => { let browser; let page; diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 0081af429..2e22f828b 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -84,5 +84,6 @@ "companyFk": "Company", "You need to fill sage information before you check verified data": "You need to fill sage information before you check verified data", "The social name cannot be empty": "The social name cannot be empty", - "The nif cannot be empty": "The nif cannot be empty" + "The nif cannot be empty": "The nif cannot be empty", + "A travel with this data already exists": "A travel with this data already exists" } \ No newline at end of file From a521ad426274e7c7ac39e7eab27a320b288211c6 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 31 Dec 2020 14:18:06 +0100 Subject: [PATCH 23/23] Fixed claim basicData back error --- modules/claim/front/basic-data/index.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html index eb3c3b9e3..064a9d4f5 100644 --- a/modules/claim/front/basic-data/index.html +++ b/modules/claim/front/basic-data/index.html @@ -1,8 +1,9 @@ + + form="form" + save="patch">