Merge pull request '4299-travel.agencyModeFk' (#1026) from 4299-travel.agencyModeFk into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #1026
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Joan Sanchez 2022-08-04 12:51:41 +00:00
commit 624428212b
25 changed files with 74 additions and 56 deletions

View File

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

View File

@ -38648,26 +38648,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 */ ;
@ -38683,6 +38686,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 */ ;
@ -38706,6 +38718,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 */ ;
@ -46803,7 +46824,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),
@ -72292,7 +72313,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;

View File

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

View File

@ -43,7 +43,7 @@ module.exports = Self => {
'name',
'shipped',
'landed',
'agencyFk',
'agencyModeFk',
'warehouseOutFk',
'warehouseInFk',
'isReceived',

View File

@ -137,7 +137,7 @@
<vn-horizontal>
<vn-autocomplete
label="Agency"
ng-model="$ctrl.travelFilterParams.agencyFk"
ng-model="$ctrl.travelFilterParams.agencyModeFk"
url="AgencyModes"
show-field="name"
value-field="id">

View File

@ -46,7 +46,7 @@ class Controller extends Section {
if (!value) continue;
switch (key) {
case 'agencyFk':
case 'agencyModeFk':
case 'warehouseInFk':
case 'warehouseOutFk':
case 'shipped':

View File

@ -14,7 +14,7 @@ class Controller extends ModuleCard {
{
relation: 'travel',
scope: {
fields: ['id', 'landed', 'agencyFk', 'warehouseOutFk'],
fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'],
include: [
{
relation: 'agency',

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,7 +29,7 @@
</vn-textfield>
<vn-autocomplete vn-one
label="Agency"
ng-model="filter.agencyFk"
ng-model="filter.agencyModeFk"
url="AgencyModes"
show-field="name"
value-field="id">

View File

@ -11,7 +11,7 @@
<vn-tr>
<vn-th field="id" number filter-enabled="false">Id</vn-th>
<vn-th field="ref">Reference</vn-th>
<vn-th field="agencyFk">Agency</vn-th>
<vn-th field="agencyModeFk">Agency</vn-th>
<vn-th field="warehouseOutFk">Warehouse Out</vn-th>
<vn-th field="shipped" center shrink-date>Shipped</vn-th>
<vn-th field="isDelivered" center>Delivered</vn-th>

View File

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

View File

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

View File

@ -29,7 +29,7 @@
</vn-textfield>
<vn-autocomplete vn-one
label="Agency"
ng-model="filter.agencyFk"
ng-model="filter.agencyModeFk"
url="AgencyModes"
show-field="name"
value-field="id">

View File

@ -12,7 +12,7 @@ module.exports = {
shippedFrom: this.shippedStart,
continent: this.continent,
id: this.id,
agencyFk: this.agencyFk,
agencyModeFk: this.agencyModeFk,
warehouseInFk: this.warehouseInFk,
warehouseOutFk: this.warehouseOutFk,
totalEntries: this.totalEntries,
@ -68,7 +68,7 @@ module.exports = {
return {'t.ref': {like: `%${value}%`}};
case 'id':
return `t.id = ${value}`;
case 'agencyFk':
case 'agencyModeFk':
return `am.id = ${value}`;
case 'warehouseOutFk':
return `wo.id = ${value}`;
@ -101,7 +101,7 @@ module.exports = {
'continent',
'ref',
'id',
'agencyFk',
'agencyModeFk',
'warehouseOutFk',
'warehouseInFk',
'totalEntries',

View File

@ -19,4 +19,4 @@ FROM travel t
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