8032-devToTest_2440 #3009
|
@ -1,4 +1,3 @@
|
||||||
-- Place your SQL code here
|
|
||||||
DROP TABLE IF EXISTS vn.wagonTypeTray;
|
DROP TABLE IF EXISTS vn.wagonTypeTray;
|
||||||
|
|
||||||
CREATE TABLE vn.wagonTypeTray (
|
CREATE TABLE vn.wagonTypeTray (
|
||||||
|
@ -20,7 +19,3 @@ ALTER TABLE vn.wagonConfig ADD CONSTRAINT wagonConfig_wagonTypeColor_FK FOREIGN
|
||||||
|
|
||||||
ALTER TABLE vn.wagonTypeTray DROP FOREIGN KEY wagonTypeTray_wagonType_FK;
|
ALTER TABLE vn.wagonTypeTray DROP FOREIGN KEY wagonTypeTray_wagonType_FK;
|
||||||
ALTER TABLE vn.wagonTypeTray ADD CONSTRAINT wagonTypeTray_wagonType_FK FOREIGN KEY (wagonTypeFk) REFERENCES vn.wagonType(id) ON DELETE CASCADE ON UPDATE RESTRICT;
|
ALTER TABLE vn.wagonTypeTray ADD CONSTRAINT wagonTypeTray_wagonType_FK FOREIGN KEY (wagonTypeFk) REFERENCES vn.wagonType(id) ON DELETE CASCADE ON UPDATE RESTRICT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- insertar datos por defecto
|
|
|
@ -367,5 +367,9 @@
|
||||||
"It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono",
|
"It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono",
|
||||||
"Payment method is required": "El método de pago es obligatorio",
|
"Payment method is required": "El método de pago es obligatorio",
|
||||||
"Cannot send mail": "Não é possível enviar o email",
|
"Cannot send mail": "Não é possível enviar o email",
|
||||||
"CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos"
|
"CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos",
|
||||||
|
"There is already a tray with the same height": "Ya existe una bandeja con la misma altura",
|
||||||
|
"You must define wagon and height": "Debes definir un tipo de vagón y la altura",
|
||||||
|
"The maximum height of the wagon is": "La altura máxima es %d",
|
||||||
|
"The height must be greater than": "The height must be greater than %d"
|
||||||
}
|
}
|
|
@ -1,16 +1,28 @@
|
||||||
// module.exports = Self => {
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
// Self.observe('before save', async ctx => {
|
|
||||||
// if (ctx.isNewInstance) {
|
|
||||||
// const models = Self.app.models;
|
|
||||||
// const config = await models.WagonConfig.findOne();
|
|
||||||
|
|
||||||
// await models.WagonTypeTray.create({
|
module.exports = Self => {
|
||||||
// wagonTypeFk: config.wagonTypeFk,
|
Self.observe('before save', async ctx => {
|
||||||
// height: config.height,
|
if (ctx.isNewInstance) {
|
||||||
// wagonTypeColorFk: config.wagonTypeColorFk
|
const models = Self.app.models;
|
||||||
// }, ctx.options);
|
const {wagonTypeFk, height} = ctx.instance;
|
||||||
// }
|
const trays = await models.WagonTypeTray.find({where: {wagonTypeFk}});
|
||||||
// if (ctx.instance < config.minHeightBetweenTrays)
|
|
||||||
// throw new Error('Height must be greater than ' + config.minHeightBetweenTrays);
|
const config = await models.WagonConfig.findOne();
|
||||||
// });
|
const tray = await models.WagonTypeTray.find({where: {wagonTypeFk, height}});
|
||||||
// };
|
|
||||||
|
if (!trays.length) return;
|
||||||
|
|
||||||
|
if (tray.length)
|
||||||
|
throw new UserError('There is already a tray with the same height');
|
||||||
|
|
||||||
|
if (!wagonTypeFk && !height)
|
||||||
|
throw new UserError('You must define wagon and height');
|
||||||
|
|
||||||
|
if (height < config.minHeightBetweenTrays)
|
||||||
|
throw new UserError('The height must be greater than', 'HEIGHT_GREATER_THAN', config.minHeightBetweenTrays);
|
||||||
|
|
||||||
|
if (height > config.maxWagonHeight)
|
||||||
|
throw new UserError('The maximum height of the wagon is', 'MAX_WAGON_HEIGHT', config.maxWagonHeight);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue