diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 5a2188cb5..09eb8af55 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1340,7 +1340,7 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`) (4, 4), (5, 6); -INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`) +INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`) VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1), (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2), diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 2c0e8231a..372a40e9a 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -38642,26 +38642,29 @@ CREATE TABLE `travel` ( `warehouseInFk` smallint(6) unsigned DEFAULT NULL, `warehouseOutFk` smallint(6) unsigned DEFAULT NULL, `agencyFk` int(11) DEFAULT NULL, - `ref` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `isDelivered` tinyint(1) NOT NULL DEFAULT '0', - `isReceived` tinyint(1) NOT NULL DEFAULT '0', + `agencyModeFk` int(11) DEFAULT NULL, + `ref` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isDelivered` tinyint(1) NOT NULL DEFAULT 0, + `isReceived` tinyint(1) NOT NULL DEFAULT 0, `m3` decimal(10,2) unsigned DEFAULT NULL, `kg` decimal(10,0) unsigned DEFAULT NULL, `cargoSupplierFk` int(11) DEFAULT NULL, - `totalEntries` tinyint(4) unsigned DEFAULT '0', + `totalEntries` tinyint(4) unsigned DEFAULT 0, `appointment` datetime DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `shipment_2` (`shipped`,`landed`,`warehouseInFk`,`warehouseOutFk`,`agencyFk`,`ref`), + UNIQUE KEY `shipment_1` (`shipped`,`landed`,`warehouseInFk`,`warehouseOutFk`,`agencyFk`,`agencyModeFk`,`ref`), KEY `agency_id` (`agencyFk`), KEY `shipment` (`shipped`), KEY `landing` (`landed`), KEY `warehouse_landing` (`warehouseInFk`,`landed`), KEY `warehouse_out_shipment` (`warehouseOutFk`,`shipped`), KEY `travel_ibfk_4_idx` (`cargoSupplierFk`), + KEY `travel_FK` (`agencyModeFk`), + CONSTRAINT `travel_FK` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_1` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_2` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_3` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=195614 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -38677,6 +38680,15 @@ DELIMITER ;; FOR EACH ROW BEGIN CALL travel_checkDates(NEW.shipped, NEW.landed); + + -- Actualizar agencyFk y agencyModeFk + IF NEW.agencyFk THEN + SET NEW.agencyModeFk = NEW.agencyFk; + END IF; + + IF NEW.agencyModeFk THEN + SET NEW.agencyFk = NEW.agencyModeFk; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -38700,6 +38712,15 @@ BEGIN OR !(NEW.shipped <=> OLD.shipped) THEN CALL travel_checkDates(NEW.shipped, NEW.landed); END IF; + + -- Actualizar agencyFk y agencyModeFk + IF !(NEW.agencyFk <=> OLD.agencyFk)THEN + SET NEW.agencyModeFk = NEW.agencyFk; + END IF; + + IF !(NEW.agencyModeFk <=> OLD.agencyModeFk) THEN + SET NEW.agencyFk = NEW.agencyModeFk; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -46762,7 +46783,7 @@ BEGIN JOIN entry e ON e.id = b.entryFk JOIN itemType it ON it.id = i.typeFk JOIN travel tr ON tr.id = e.travelFk - JOIN agencyMode am ON am.id = tr.agencyFk + JOIN agencyMode am ON am.id = tr.agencyModeFk JOIN tmp.rate r SET b.freightValue = @PF:= ROUND(IFNULL(((am.m3 * @cm3:= item_getVolume(b.itemFk, b.packageFk)) / 1000000) / b.packing,0),3), @@ -72251,7 +72272,7 @@ BEGIN END; START TRANSACTION; - INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyFk, `ref`, isDelivered, isReceived, m3, kg) + INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, kg) SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3, kg FROM travel WHERE id = vTravelFk; diff --git a/e2e/paths/12-entry/02_descriptor.spec.js b/e2e/paths/12-entry/02_descriptor.spec.js index 699d00517..997a6065c 100644 --- a/e2e/paths/12-entry/02_descriptor.spec.js +++ b/e2e/paths/12-entry/02_descriptor.spec.js @@ -29,7 +29,7 @@ describe('Entry descriptor path', () => { it('should click the travels button to be redirected to the travels index filtered by the current agency', async() => { await page.waitToClick(selectors.entryDescriptor.travelsQuicklink); await page.expectURL('/travel/index'); - await page.expectURL('agencyFk'); + await page.expectURL('agencyModeFk'); }); it('should go back to the entry summary', async() => { diff --git a/modules/entry/back/methods/entry/getEntry.js b/modules/entry/back/methods/entry/getEntry.js index 66238d0dc..cac3c65f8 100644 --- a/modules/entry/back/methods/entry/getEntry.js +++ b/modules/entry/back/methods/entry/getEntry.js @@ -43,7 +43,7 @@ module.exports = Self => { 'name', 'shipped', 'landed', - 'agencyFk', + 'agencyModeFk', 'warehouseOutFk', 'warehouseInFk', 'isReceived', diff --git a/modules/entry/front/basic-data/index.html b/modules/entry/front/basic-data/index.html index a05630dd6..48cd82474 100644 --- a/modules/entry/front/basic-data/index.html +++ b/modules/entry/front/basic-data/index.html @@ -137,7 +137,7 @@ diff --git a/modules/entry/front/basic-data/index.js b/modules/entry/front/basic-data/index.js index 80870c3f3..564a3df5c 100644 --- a/modules/entry/front/basic-data/index.js +++ b/modules/entry/front/basic-data/index.js @@ -46,7 +46,7 @@ class Controller extends Section { if (!value) continue; switch (key) { - case 'agencyFk': + case 'agencyModeFk': case 'warehouseInFk': case 'warehouseOutFk': case 'shipped': diff --git a/modules/entry/front/card/index.js b/modules/entry/front/card/index.js index eafed171b..96f4702e2 100644 --- a/modules/entry/front/card/index.js +++ b/modules/entry/front/card/index.js @@ -14,7 +14,7 @@ class Controller extends ModuleCard { { relation: 'travel', scope: { - fields: ['id', 'landed', 'agencyFk', 'warehouseOutFk'], + fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'], include: [ { relation: 'agency', diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js index fed3787d4..34aa162f9 100644 --- a/modules/entry/front/descriptor/index.js +++ b/modules/entry/front/descriptor/index.js @@ -14,9 +14,9 @@ class Controller extends Descriptor { let travelFilter; const entryTravel = this.entry && this.entry.travel; - if (entryTravel && entryTravel.agencyFk) { + if (entryTravel && entryTravel.agencyModeFk) { travelFilter = this.entry && JSON.stringify({ - agencyFk: entryTravel.agencyFk + agencyModeFk: entryTravel.agencyModeFk }); } return travelFilter; @@ -49,7 +49,7 @@ class Controller extends Descriptor { { relation: 'travel', scope: { - fields: ['id', 'landed', 'agencyFk', 'warehouseOutFk'], + fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'], include: [ { relation: 'agency', diff --git a/modules/travel/back/methods/travel/cloneWithEntries.js b/modules/travel/back/methods/travel/cloneWithEntries.js index 393194f06..611f4e429 100644 --- a/modules/travel/back/methods/travel/cloneWithEntries.js +++ b/modules/travel/back/methods/travel/cloneWithEntries.js @@ -35,7 +35,7 @@ module.exports = Self => { 'landed', 'warehouseInFk', 'warehouseOutFk', - 'agencyFk', + 'agencyModeFk', 'ref' ] }); @@ -56,7 +56,7 @@ module.exports = Self => { travel.warehouseOutFk, travel.warehouseInFk, travel.ref, - travel.agencyFk + travel.agencyModeFk ] ); stmts.push(stmt); @@ -76,7 +76,7 @@ module.exports = Self => { 'landed', 'warehouseInFk', 'warehouseOutFk', - 'agencyFk', + 'agencyModeFk', 'ref' ] }); diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index af6e1ec0a..7769b7f21 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -34,7 +34,7 @@ module.exports = Self => { description: 'The landed to date filter' }, { - arg: 'agencyFk', + arg: 'agencyModeFk', type: 'number', description: 'The agencyModeFk id' }, @@ -96,7 +96,7 @@ module.exports = Self => { case 'continent': return {'cnt.code': value}; case 'id': - case 'agencyFk': + case 'agencyModeFk': case 'warehouseOutFk': case 'warehouseInFk': case 'totalEntries': @@ -143,7 +143,7 @@ module.exports = Self => { JOIN warehouse wo ON wo.id = t.warehouseOutFk JOIN country c ON c.id = wo.countryFk LEFT JOIN continent cnt ON cnt.id = c.continentFk - JOIN agencyMode am ON am.id = t.agencyFk` + JOIN agencyMode am ON am.id = t.agencyModeFk` ); stmt.merge(conn.makeWhere(filter.where)); diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index 586b4e5aa..3fa1d65f9 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -44,7 +44,7 @@ module.exports = Self => { description: 'The landed to date filter', http: {source: 'query'} }, { - arg: 'agencyFk', + arg: 'agencyModeFk', type: 'number', description: 'The agencyModeFk id', http: {source: 'query'} @@ -102,7 +102,7 @@ module.exports = Self => { case 'landedTo': return {'t.landed': {lte: value}}; case 'id': - case 'agencyFk': + case 'agencyModeFk': case 'warehouseOutFk': case 'warehouseInFk': case 'totalEntries': @@ -124,7 +124,7 @@ module.exports = Self => { t.landed, t.warehouseInFk, t.warehouseOutFk, - t.agencyFk, + t.agencyModeFk, t.ref, t.isDelivered, t.isReceived, @@ -137,7 +137,7 @@ module.exports = Self => { wout.name warehouseOutName, cnt.code continent FROM vn.travel t - JOIN vn.agencyMode am ON am.id = t.agencyFk + JOIN vn.agencyMode am ON am.id = t.agencyModeFk JOIN vn.warehouse win ON win.id = t.warehouseInFk JOIN vn.warehouse wout ON wout.id = t.warehouseOutFk JOIN warehouse wo ON wo.id = t.warehouseOutFk diff --git a/modules/travel/back/methods/travel/getAverageDays.js b/modules/travel/back/methods/travel/getAverageDays.js index 9a9649d84..d888d80c1 100644 --- a/modules/travel/back/methods/travel/getAverageDays.js +++ b/modules/travel/back/methods/travel/getAverageDays.js @@ -32,9 +32,9 @@ module.exports = Self => { t.warehouseOutFk, t.landed, t.shipped, - t.agencyFk + t.agencyModeFk FROM travel t - WHERE t.agencyFk = ? LIMIT 50)`, [agencyModeFk]); + WHERE t.agencyModeFk = ? LIMIT 50)`, [agencyModeFk]); stmts.push(stmt); stmt = new ParameterizedSQL(` @@ -44,10 +44,10 @@ module.exports = Self => { t.warehouseOutFk, (SELECT ROUND(AVG(DATEDIFF(t.landed, t.shipped ))) FROM tmp.travel t - WHERE t.agencyFk + WHERE t.agencyModeFk ORDER BY id DESC LIMIT 50) AS dayDuration FROM tmp.travel t - WHERE t.agencyFk + WHERE t.agencyModeFk ORDER BY t.id DESC LIMIT 1`); const avgDaysIndex = stmts.push(stmt) - 1; diff --git a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js index aa92fa308..2e79ff193 100644 --- a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js +++ b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js @@ -71,7 +71,7 @@ describe('Travel cloneWithEntries()', () => { expect(newTravel.ref).toEqual('fifth travel'); expect(newTravel.warehouseInFk).toEqual(warehouseThree); expect(newTravel.warehouseOutFk).toEqual(warehouseThree); - expect(newTravel.agencyFk).toEqual(agencyModeOne); + expect(newTravel.agencyModeFk).toEqual(agencyModeOne); expect(travelEntries.length).toBeGreaterThan(0); }); }); diff --git a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js index b74160efe..3693aae82 100644 --- a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js +++ b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js @@ -70,10 +70,10 @@ describe('Travel extraCommunityFilter()', () => { expect(result.length).toEqual(3); }); - it('should return the travel matching "agencyFk"', async() => { + it('should return the travel matching "agencyModeFk"', async() => { const ctx = { args: { - agencyFk: 1 + agencyModeFk: 1 } }; diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json index 95330e263..c20b7b0bf 100644 --- a/modules/travel/back/models/travel.json +++ b/modules/travel/back/models/travel.json @@ -44,17 +44,14 @@ "type": "number" }, "agencyModeFk": { - "type": "number", - "mysql": { - "columnName": "agencyFk" - } + "type": "number" } }, "relations": { "agency": { "type": "belongsTo", "model": "AgencyMode", - "foreignKey": "agencyFk" + "foreignKey": "agencyModeFk" }, "warehouseIn": { "type": "belongsTo", diff --git a/modules/travel/front/descriptor-menu/index.js b/modules/travel/front/descriptor-menu/index.js index 25922815e..0630bb618 100644 --- a/modules/travel/front/descriptor-menu/index.js +++ b/modules/travel/front/descriptor-menu/index.js @@ -25,7 +25,7 @@ class Controller extends Section { 'shipped', 'landed', 'totalEntries', - 'agencyFk', + 'agencyModeFk', 'warehouseInFk', 'warehouseOutFk', 'cargoSupplierFk' @@ -64,7 +64,7 @@ class Controller extends Section { onCloneAccept() { const params = JSON.stringify({ ref: this.travel.ref, - agencyModeFk: this.travel.agencyFk, + agencyModeFk: this.travel.agencyModeFk, shipped: this.travel.shipped, landed: this.travel.landed, warehouseInFk: this.travel.warehouseInFk, diff --git a/modules/travel/front/descriptor-menu/index.spec.js b/modules/travel/front/descriptor-menu/index.spec.js index 4ca93a6d6..40319e8e2 100644 --- a/modules/travel/front/descriptor-menu/index.spec.js +++ b/modules/travel/front/descriptor-menu/index.spec.js @@ -18,7 +18,7 @@ describe('Travel Component vnTravelDescriptorMenu', () => { controller.travel = { ref: 'the ref', - agencyFk: 'the agency', + agencyModeFk: 'the agency', shipped: 'the shipped date', landed: 'the landing date', warehouseInFk: 'the receiver warehouse', @@ -29,7 +29,7 @@ describe('Travel Component vnTravelDescriptorMenu', () => { const params = JSON.stringify({ ref: controller.travel.ref, - agencyModeFk: controller.travel.agencyFk, + agencyModeFk: controller.travel.agencyModeFk, shipped: controller.travel.shipped, landed: controller.travel.landed, warehouseInFk: controller.travel.warehouseInFk, diff --git a/modules/travel/front/descriptor/index.js b/modules/travel/front/descriptor/index.js index dc19f68af..b1f2f53be 100644 --- a/modules/travel/front/descriptor/index.js +++ b/modules/travel/front/descriptor/index.js @@ -14,9 +14,9 @@ class Controller extends Descriptor { let travelFilter; const travel = this.travel; - if (travel && travel.agencyFk) { + if (travel && travel.agencyModeFk) { travelFilter = this.travel && JSON.stringify({ - agencyFk: this.travel.agencyFk + agencyModeFk: this.travel.agencyModeFk }); } return travelFilter; diff --git a/modules/travel/front/extra-community-search-panel/index.html b/modules/travel/front/extra-community-search-panel/index.html index 8e51acc15..ab1e88891 100644 --- a/modules/travel/front/extra-community-search-panel/index.html +++ b/modules/travel/front/extra-community-search-panel/index.html @@ -29,7 +29,7 @@ diff --git a/modules/travel/front/index/index.html b/modules/travel/front/index/index.html index 8510cf328..27a700083 100644 --- a/modules/travel/front/index/index.html +++ b/modules/travel/front/index/index.html @@ -11,7 +11,7 @@ Id Reference - Agency + Agency Warehouse Out Shipped Delivered diff --git a/modules/travel/front/index/index.js b/modules/travel/front/index/index.js index 5cae6fa06..50036831f 100644 --- a/modules/travel/front/index/index.js +++ b/modules/travel/front/index/index.js @@ -10,7 +10,7 @@ export default class Controller extends Section { onCloneAccept(travel) { const params = JSON.stringify({ ref: travel.ref, - agencyModeFk: travel.agencyFk, + agencyModeFk: travel.agencyModeFk, shipped: travel.shipped, landed: travel.landed, warehouseInFk: travel.warehouseInFk, @@ -44,7 +44,7 @@ export default class Controller extends Section { case 'landed': return {'t.landed': {between: this.dateRange(value)}}; case 'id': - case 'agencyFk': + case 'agencyModeFk': case 'warehouseOutFk': case 'warehouseInFk': case 'totalEntries': diff --git a/modules/travel/front/index/index.spec.js b/modules/travel/front/index/index.spec.js index 1b2ab0a87..9abe46a64 100644 --- a/modules/travel/front/index/index.spec.js +++ b/modules/travel/front/index/index.spec.js @@ -35,11 +35,11 @@ describe('Travel Component vnTravelIndex', () => { const travel = { ref: 1, - agencyFk: 1 + agencyModeFk: 1 }; const travelParams = { ref: travel.ref, - agencyModeFk: travel.agencyFk + agencyModeFk: travel.agencyModeFk }; const queryParams = JSON.stringify(travelParams); controller.onCloneAccept(travel); diff --git a/modules/travel/front/search-panel/index.html b/modules/travel/front/search-panel/index.html index 8d4edec1a..2e9c796c3 100644 --- a/modules/travel/front/search-panel/index.html +++ b/modules/travel/front/search-panel/index.html @@ -29,7 +29,7 @@