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

This commit is contained in:
Carlos Jimenez Ruiz 2022-06-10 07:21:54 +00:00
commit 096f225656
8 changed files with 25 additions and 6 deletions

View File

@ -0,0 +1,8 @@
ALTER TABLE `vn`.`creditInsurance` ADD creditClassificationFk int(11) NULL;
UPDATE `vn`.`creditInsurance` AS `destiny`
SET `destiny`.`creditClassificationFk`= (SELECT creditClassification FROM `vn`.`creditInsurance` AS `origin` WHERE `origin`.id = `destiny`.id);
ALTER TABLE `vn`.`creditInsurance`
ADD CONSTRAINT `creditInsurance_creditClassificationFk` FOREIGN KEY (`creditClassificationFk`)
REFERENCES `vn`.`creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -0,0 +1,11 @@
DELIMITER $$
$$
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`creditInsurance_beforeInsert`
BEFORE INSERT ON `creditInsurance`
FOR EACH ROW
BEGIN
IF NEW.creditClassificationFk THEN
SET NEW.creditClassification = NEW.creditClassificationFk;
END IF;
END$$
DELIMITER ;

View File

@ -458,7 +458,7 @@ INSERT INTO `vn`.`creditClassification`(`id`, `client`, `dateStart`, `dateEnd`)
(4, 1104, CURDATE(), CURDATE()),
(5, 1105, CURDATE(), CURDATE());
INSERT INTO `vn`.`creditInsurance`(`id`, `creditClassification`, `credit`, `creationDate`, `grade`)
INSERT INTO `vn`.`creditInsurance`(`id`, `creditClassificationFk`, `credit`, `creationDate`, `grade`)
VALUES
(1, 1, 3000, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL),
(2, 2, 6000, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), NULL),

View File

@ -38,7 +38,7 @@ module.exports = Self => {
}, myOptions);
await models.CreditInsurance.create({
creditClassification: newClassification.id,
creditClassificationFk: newClassification.id,
credit: data.credit,
grade: data.grade
}, myOptions);

View File

@ -36,7 +36,7 @@
"insurances": {
"type": "hasMany",
"model": "CreditInsurance",
"foreignKey": "creditClassification"
"foreignKey": "creditClassificationFk"
}
}
}

View File

@ -24,7 +24,7 @@ module.exports = function(Self) {
let filter = {
fields: ['grade'],
where: {
creditClassification: this.creditClassification
creditClassificationFk: this.creditClassificationFk
},
order: 'created DESC'
};

View File

@ -30,7 +30,7 @@
"classification": {
"type": "belongsTo",
"model": "CreditClassification",
"foreignKey": "creditClassification"
"foreignKey": "creditClassificationFk"
}
},
"scope": {

View File

@ -1,7 +1,7 @@
<vn-crud-model
vn-id="model"
url="CreditInsurances"
link="{creditClassification: $ctrl.$params.classificationId}"
link="{creditClassificationFk: $ctrl.$params.classificationId}"
limit="20"
data="insurances"
auto-load="true">