feat: refs #8381 add agencyModeFk to travel thermograph and create AgencyModeIncoming model #3369

Open
jgallego wants to merge 4 commits from 8381-thermographTravel into dev
9 changed files with 74 additions and 2 deletions

View File

@ -321,6 +321,11 @@ UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com'
UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23;
INSERT INTO `vn`.`agencyIncoming`(`agencyModeFk`)
VALUES
(1),
(2);
INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`, `hasVerified`)
VALUES
(1, NULL, 'PayMethod one', 0, 001, 0, 0, 0),

View File

@ -0,0 +1,9 @@
CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`agencyModeIncoming` AS
SELECT
am.id,
am.name
FROM `vn`.`agencyMode` AS am
JOIN `vn`.`agencyIncoming` AS ai
ON am.id = ai.agencyModeFk;

View File

@ -0,0 +1,6 @@
ALTER TABLE `vn`.`agencyIncoming`
ADD CONSTRAINT `fk_agencyIncoming_agencyMode`
FOREIGN KEY (`agencyModeFk`)
REFERENCES `agencyMode`(`id`)
ON DELETE CASCADE
ON UPDATE CASCADE;

View File

@ -0,0 +1,7 @@
ALTER TABLE `vn`.`travelThermograph`
ADD COLUMN `agencyModeFk` INT(11) NULL AFTER `editorFk`,
ADD CONSTRAINT `travelThermograph_agencyIncoming_fk`
FOREIGN KEY (`agencyModeFk`)
REFERENCES `agencyIncoming`(`agencyModeFk`)
ON DELETE RESTRICT
ON UPDATE CASCADE;

View File

@ -57,6 +57,10 @@ module.exports = Self => {
arg: 'hasFileAttached',
type: 'Boolean',
description: 'True if has an attached file'
}, {
arg: 'agencyModeFk',
type: 'Number',
description: 'Carrier'
}],
returns: {type: 'object', root: true},
http: {path: `/:id/saveThermograph`, verb: 'POST'}
@ -76,6 +80,7 @@ module.exports = Self => {
reference,
description,
hasFileAttached,
agencyModeFk,
options
) => {
const models = Self.app.models;
@ -119,6 +124,7 @@ module.exports = Self => {
minTemperature,
temperatureFk,
warehouseFk: warehouseId,
agencyModeFk,
}, myOptions);
if (tx) await tx.commit();

View File

@ -9,6 +9,7 @@ describe('Thermograph saveThermograph()', () => {
const maxTemperature = 30;
const minTemperature = 10;
const temperatureFk = 'COOL';
const agencyModeFk = 1;
let tx;
let options;
@ -46,13 +47,16 @@ describe('Thermograph saveThermograph()', () => {
null,
null,
null,
null, options
null,
agencyModeFk,
options
);
expect(updatedThermograph.result).toEqual(state);
expect(updatedThermograph.maxTemperature).toEqual(maxTemperature);
expect(updatedThermograph.minTemperature).toEqual(minTemperature);
expect(updatedThermograph.temperatureFk).toEqual(temperatureFk);
expect(updatedThermograph.agencyModeFk).toEqual(agencyModeFk);
expect(updatedThermograph.dmsFk).toEqual(dmsFk);
});

View File

@ -22,5 +22,8 @@
},
"Temperature": {
"dataSource": "vn"
},
"AgencyModeIncoming": {
"dataSource": "vn"
}
}
}

View File

@ -0,0 +1,27 @@
{
"name": "AgencyModeIncoming",
"base": "VnModel",
"options": {
"mysql": {
"table": "agencyModeIncoming"
}
},
"properties": {
"id": {
"type": "number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -58,6 +58,11 @@
"type": "belongsTo",
"model": "Thermograph",
"foreignKey": "thermographFk"
},
"agencyMode": {
"type": "belongsTo",
"model": "AgencyMode",
"foreignKey": "agencyModeFk"
}
}
}