Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6321_negative_tickets

This commit is contained in:
Javier Segarra 2024-09-13 08:51:28 +02:00
commit 09a7918ab3
28 changed files with 195 additions and 255 deletions

View File

@ -3057,9 +3057,6 @@ INSERT INTO `vn`.`workerTimeControlMail` (`id`, `workerFk`, `year`, `week`, `sta
(3, 9, 2000, 51, 'CONFIRMED', util.VN_NOW(), 1, NULL), (3, 9, 2000, 51, 'CONFIRMED', util.VN_NOW(), 1, NULL),
(4, 9, 2001, 1, 'SENDED', util.VN_NOW(), 1, NULL); (4, 9, 2001, 1, 'SENDED', util.VN_NOW(), 1, NULL);
INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `maxWagonHeight`, `minHeightBetweenTrays`, `maxTrays`)
VALUES
(1, 1350, 1900, 200, 50, 6);
INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`) INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`)
VALUES VALUES
@ -3068,15 +3065,19 @@ INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`)
(3, 'green', '#00ff00'), (3, 'green', '#00ff00'),
(4, 'blue', '#0000ff'); (4, 'blue', '#0000ff');
INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `maxWagonHeight`, `minHeightBetweenTrays`, `maxTrays`, `defaultTrayColorFk`)
VALUES
(1, 1350, 1900, 200, 50, 6, 1);
INSERT INTO `vn`.`wagonType` (`id`, `name`, `divisible`) INSERT INTO `vn`.`wagonType` (`id`, `name`, `divisible`)
VALUES VALUES
(1, 'Wagon Type #1', 1); (1, 'Wagon Type #1', 1);
INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`) INSERT INTO `vn`.`wagonTypeTray` (`id`, `wagonTypeFk`, `height`, `wagonTypeColorFk`)
VALUES VALUES
(1, 1, 100, 1), (1, 1, 0, 1),
(2, 1, 50, 2), (2, 1, 50, 2),
(3, 1, 0, 3); (3, 1, 100, 3);
INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `courtesyTime`, `renewInterval`) INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `courtesyTime`, `renewInterval`)
VALUES VALUES

View File

@ -167,7 +167,8 @@ BEGIN
OR LENGTH(pb.problem) OR LENGTH(pb.problem)
OR pb.lines > vLinesLimit OR pb.lines > vLinesLimit
OR pb.m3 > vVolumeLimit OR pb.m3 > vVolumeLimit
OR sub.maxSize > vSizeLimit; OR sub.maxSize > vSizeLimit
OR pb.hasPlantTray;
END IF; END IF;
-- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede

View File

@ -10,7 +10,7 @@ BEGIN
SELECT * FROM ( SELECT * FROM (
SELECT cc.client clientFk, ci.grade SELECT cc.client clientFk, ci.grade
FROM creditClassification cc FROM creditClassification cc
JOIN creditInsurance ci ON cc.id = ci.creditClassification JOIN creditInsurance ci ON cc.id = ci.creditClassificationFk
WHERE dateEnd IS NULL WHERE dateEnd IS NULL
ORDER BY ci.creationDate DESC ORDER BY ci.creationDate DESC
LIMIT 10000000000000000000) t1 LIMIT 10000000000000000000) t1

View File

@ -46,7 +46,8 @@ BEGIN
AND buyFk = vBuyFk) THEN AND buyFk = vBuyFk) THEN
UPDATE itemShelving UPDATE itemShelving
SET visible = visible + vQuantity SET visible = visible + vQuantity,
available = available + vQuantity
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
ELSE ELSE

View File

@ -211,8 +211,6 @@ proc: BEGIN
salesInParkingCount INT DEFAULT 0) salesInParkingCount INT DEFAULT 0)
ENGINE = MEMORY; ENGINE = MEMORY;
-- Insertamos todos los tickets que tienen productos parkineados
-- en sectores de previa, segun el sector
CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock
(PRIMARY KEY(itemFk, sectorFk)) (PRIMARY KEY(itemFk, sectorFk))
ENGINE = MEMORY ENGINE = MEMORY
@ -245,7 +243,6 @@ proc: BEGIN
AND s.quantity > 0 AND s.quantity > 0
GROUP BY pb.ticketFk; GROUP BY pb.ticketFk;
-- Se calcula la cantidad de productos que estan ya preparados porque su saleGroup está aparcado
UPDATE tmp.ticketWithPrevia twp UPDATE tmp.ticketWithPrevia twp
JOIN ( JOIN (
SELECT pb.ticketFk, COUNT(DISTINCT s.id) salesInParkingCount SELECT pb.ticketFk, COUNT(DISTINCT s.id) salesInParkingCount
@ -259,12 +256,28 @@ proc: BEGIN
) sub ON twp.ticketFk = sub.ticketFk ) sub ON twp.ticketFk = sub.ticketFk
SET twp.salesInParkingCount = sub.salesInParkingCount; SET twp.salesInParkingCount = sub.salesInParkingCount;
-- Marcamos como pendientes aquellos que no coinciden las cantidades
UPDATE tmp.productionBuffer pb UPDATE tmp.productionBuffer pb
JOIN tmp.ticketWithPrevia twp ON twp.ticketFk = pb.ticketFk JOIN tmp.ticketWithPrevia twp ON twp.ticketFk = pb.ticketFk
SET pb.previousWithoutParking = TRUE SET pb.previousWithoutParking = TRUE
WHERE twp.salesCount > twp.salesInParkingCount; WHERE twp.salesCount > twp.salesInParkingCount;
-- hasPlantTray
ALTER TABLE tmp.productionBuffer
ADD hasPlantTray BOOL DEFAULT FALSE;
UPDATE tmp.productionBuffer pb
JOIN sale s ON s.ticketFk = pb.ticketFk
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN itemCategory ic ON ic.id = it.categoryFk
JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk AND lb.item_id = s.itemFk
JOIN buy b ON b.id = lb.buy_id
JOIN packaging p ON p.id = b.packagingFk
JOIN productionConfig pc
SET hasPlantTray = TRUE
WHERE ic.code = 'plant'
AND p.`depth` >= pc.minPlantTrayLength;
DROP TEMPORARY TABLE DROP TEMPORARY TABLE
tmp.productionTicket, tmp.productionTicket,
tmp.ticket, tmp.ticket,

View File

@ -160,7 +160,10 @@ w1: WHILE vQuantity >= vPacking DO
UPDATE sale SET quantity = quantity - vPacking WHERE id = vSaleFk; UPDATE sale SET quantity = quantity - vPacking WHERE id = vSaleFk;
UPDATE itemShelving SET visible = visible - vPacking WHERE id = vItemShelvingFk; UPDATE itemShelving
SET visible = visible - vPacking,
available = available - vPacking
WHERE id = vItemShelvingFk;
SET vNewSaleFk = NULL; SET vNewSaleFk = NULL;

View File

@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`creditInsurance_afterIn
BEGIN BEGIN
UPDATE `client` c UPDATE `client` c
JOIN vn.creditClassification cc ON cc.client = c.id JOIN vn.creditClassification cc ON cc.client = c.id
SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassification; SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassificationFk;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,10 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`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

@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`solunionCAP_afterInsert
BEGIN BEGIN
UPDATE client c UPDATE client c
JOIN creditClassification cc ON cc.client = c.id JOIN creditClassification cc ON cc.client = c.id
JOIN creditInsurance ci ON ci.creditClassification = cc.id JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id
SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance; SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -6,12 +6,12 @@ BEGIN
IF NEW.dateLeaving IS NOT NULL THEN IF NEW.dateLeaving IS NOT NULL THEN
UPDATE client c UPDATE client c
JOIN creditClassification cc ON cc.client = c.id JOIN creditClassification cc ON cc.client = c.id
JOIN creditInsurance ci ON ci.creditClassification = cc.id JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id
SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance;
ELSE ELSE
UPDATE client c UPDATE client c
JOIN creditClassification cc ON cc.client = c.id JOIN creditClassification cc ON cc.client = c.id
JOIN creditInsurance ci ON ci.creditClassification = cc.id JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id
SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance; SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance;
END IF; END IF;
END$$ END$$

View File

@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`solunionCAP_beforeDelet
BEGIN BEGIN
UPDATE client c UPDATE client c
JOIN creditClassification cc ON cc.client = c.id JOIN creditClassification cc ON cc.client = c.id
JOIN creditInsurance ci ON ci.creditClassification = cc.id JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id
SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -0,0 +1,17 @@
CREATE OR REPLACE TABLE vn.wagonTypeTray (
id INT UNSIGNED auto_increment NULL,
wagonTypeFk int(11) unsigned NULL,
height INT UNSIGNED NULL,
wagonTypeColorFk int(11) unsigned NULL,
CONSTRAINT wagonTypeTray_pk PRIMARY KEY (id),
CONSTRAINT wagonTypeTray_wagonType_FK FOREIGN KEY (wagonTypeFk) REFERENCES vn.wagonType(id) ON DELETE CASCADE ON UPDATE RESTRICT,
CONSTRAINT wagonTypeTray_wagonTypeColor_FK FOREIGN KEY (wagonTypeColorFk) REFERENCES vn.wagonTypeColor(id)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8mb3
COLLATE=utf8mb3_unicode_ci;
ALTER TABLE vn.wagonConfig ADD IF NOT EXISTS defaultHeight INT UNSIGNED DEFAULT 0 NULL COMMENT 'Default height in cm for a base tray';
ALTER TABLE vn.wagonConfig ADD IF NOT EXISTS defaultTrayColorFk int(11) unsigned NULL COMMENT 'Default color for a base tray';
ALTER TABLE vn.wagonConfig ADD CONSTRAINT wagonConfig_wagonTypeColor_FK FOREIGN KEY (defaultTrayColorFk) REFERENCES vn.wagonTypeColor(id);

View File

@ -0,0 +1,3 @@
ALTER TABLE vn.creditInsurance DROP FOREIGN KEY CreditInsurance_Fk1;
ALTER TABLE vn.creditInsurance
CHANGE creditClassification creditClassification__ int(11) DEFAULT NULL COMMENT '@deprecated 2024-09-11';

View File

@ -0,0 +1,3 @@
-- Place your SQL code here
ALTER TABLE vn.productionConfig ADD minPlantTrayLength INT DEFAULT 53 NOT NULL
COMMENT 'minimum length for plant tray restriction. Avoid to make collection of the ticket with this kind of item';

View File

@ -237,6 +237,8 @@
"This worker already exists": "This worker already exists", "This worker already exists": "This worker already exists",
"CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`", "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`",
"This postcode already exists": "This postcode already exists", "This postcode already exists": "This postcode already exists",
"Original invoice not found": "Original invoice not found" "Original invoice not found": "Original invoice not found",
"There is already a tray with the same height": "There is already a tray with the same height",
"The height must be greater than 50cm": "The height must be greater than 50cm",
"The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm"
} }

View File

@ -374,5 +374,8 @@
"Original invoice not found": "Factura original no encontrada", "Original invoice not found": "Factura original no encontrada",
"The entry has no lines or does not exist": "La entrada no tiene lineas o no existe", "The entry has no lines or does not exist": "La entrada no tiene lineas o no existe",
"Weight already set": "El peso ya está establecido", "Weight already set": "El peso ya está establecido",
"This ticket is not allocated to your department": "Este ticket no está asignado a tu departamento" "This ticket is not allocated to your department": "Este ticket no está asignado a tu departamento",
"There is already a tray with the same height": "Ya existe una bandeja con la misma altura",
"The height must be greater than 50cm": "La altura debe ser superior a 50cm",
"The maximum height of the wagon is 200cm": "La altura máxima es 200cm"
} }

View File

@ -1,57 +0,0 @@
module.exports = Self => {
Self.remoteMethodCtx('createWagonType', {
description: 'Creates a new wagon type',
accessType: 'WRITE',
accepts: [
{
arg: 'name',
type: 'String',
required: true
},
{
arg: 'divisible',
type: 'boolean',
required: true
}, {
arg: 'trays',
type: 'any',
required: true
}
],
http: {
path: `/createWagonType`,
verb: 'PATCH'
}
});
Self.createWagonType = async(ctx, options) => {
const args = ctx.args;
const models = Self.app.models;
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const newWagonType = await models.WagonType.create({name: args.name, divisible: args.divisible}, myOptions);
args.trays.forEach(async tray => {
await models.WagonTypeTray.create({
typeFk: newWagonType.id,
height: tray.position,
colorFk: tray.color.id
}, myOptions);
});
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -1,43 +0,0 @@
module.exports = Self => {
Self.remoteMethodCtx('deleteWagonType', {
description: 'Deletes a wagon type',
accessType: 'WRITE',
accepts: [
{
arg: 'id',
type: 'Number',
required: true
}
],
http: {
path: `/deleteWagonType`,
verb: 'DELETE'
}
});
Self.deleteWagonType = async(ctx, options) => {
const args = ctx.args;
const models = Self.app.models;
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
await models.Wagon.destroyAll({typeFk: args.id}, myOptions);
await models.WagonTypeTray.destroyAll({typeFk: args.id}, myOptions);
await models.WagonType.destroyAll({id: args.id}, myOptions);
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -1,64 +0,0 @@
module.exports = Self => {
Self.remoteMethodCtx('editWagonType', {
description: 'Edits a new wagon type',
accessType: 'WRITE',
accepts: [
{
arg: 'id',
type: 'String',
required: true
},
{
arg: 'name',
type: 'String',
required: true
},
{
arg: 'divisible',
type: 'boolean',
required: true
}, {
arg: 'trays',
type: 'any',
required: true
}
],
http: {
path: `/editWagonType`,
verb: 'PATCH'
}
});
Self.editWagonType = async(ctx, options) => {
const args = ctx.args;
const models = Self.app.models;
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const wagonType = await models.WagonType.findById(args.id, null, myOptions);
wagonType.updateAttributes({name: args.name, divisible: args.divisible}, myOptions);
models.WagonTypeTray.destroyAll({typeFk: args.id}, myOptions);
args.trays.forEach(async tray => {
await models.WagonTypeTray.create({
typeFk: args.id,
height: tray.position,
colorFk: tray.color.id
}, myOptions);
});
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -1,58 +1,16 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
describe('WagonType crudWagonType()', () => { describe('WagonType crudWagonType()', () => {
const ctx = {
args: {
name: 'Mock wagon type',
divisible: true,
trays: [{position: 0, color: {id: 1}},
{position: 50, color: {id: 2}},
{position: 100, color: {id: 3}}]
}
};
it(`should create, edit and delete a new wagon type and its trays`, async() => { it(`should create, edit and delete a new wagon type and its trays`, async() => {
const tx = await models.WagonType.beginTransaction({}); const tx = await models.WagonType.beginTransaction({});
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
// create const wagonType = await models.WagonType.create({name: 'Mock wagon type'}, options);
await models.WagonType.createWagonType(ctx, options); const newWagonTrays = await models.WagonTypeTray.findOne({where: {typeFk: wagonType.id}}, options);
const newWagonType = await models.WagonType.findOne({where: {name: ctx.args.name}}, options); expect(newWagonTrays).toBeDefined();
const newWagonTrays = await models.WagonTypeTray.find({where: {typeFk: newWagonType.id}}, options);
expect(newWagonType).not.toEqual(null);
expect(newWagonType.name).toEqual(ctx.args.name);
expect(newWagonType.divisible).toEqual(ctx.args.divisible);
expect(newWagonTrays.length).toEqual(ctx.args.trays.length);
ctx.args = {
id: newWagonType.id,
name: 'Edited wagon type',
divisible: false,
trays: [{position: 0, color: {id: 1}}]
};
// edit
await models.WagonType.editWagonType(ctx, options);
const editedWagonType = await models.WagonType.findById(newWagonType.id, null, options);
const editedWagonTrays = await models.WagonTypeTray.find({where: {typeFk: newWagonType.id}}, options);
expect(editedWagonType.name).toEqual(ctx.args.name);
expect(editedWagonType.divisible).toEqual(ctx.args.divisible);
expect(editedWagonTrays.length).toEqual(ctx.args.trays.length);
// delete
await models.WagonType.deleteWagonType(ctx, options);
const deletedWagonType = await models.WagonType.findById(newWagonType.id, null, options);
const deletedWagonTrays = await models.WagonTypeTray.find({where: {typeFk: newWagonType.id}}, options);
expect(deletedWagonType).toEqual(null);
expect(deletedWagonTrays).toEqual([]);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -0,0 +1,58 @@
const models = require('vn-loopback/server/server').models;
describe('WagonTray max height()', () => {
it(`should throw an error if the tray's height is above the maximum of the wagon`, async() => {
const tx = await models.WagonTypeTray.beginTransaction({});
let error;
try {
const options = {transaction: tx};
await models.WagonTypeTray.create({height: 210, wagonTypeFk: 1, wagonTypeColorFk: 4}, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error.message).toBe('The maximum height of the wagon is 200cm');
});
it(`should throw an error if the tray's height is already in the wagon`, async() => {
const tx = await models.WagonTypeTray.beginTransaction({});
let error;
try {
const options = {transaction: tx};
await models.WagonTypeTray.create({height: 50, wagonTypeFk: 1, wagonTypeColorFk: 2}, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error.message).toBe('There is already a tray with the same height');
});
it(`should throw an error if the tray's height is below the minimum between the trays`, async() => {
const tx = await models.WagonTypeTray.beginTransaction({});
let error;
try {
const options = {transaction: tx};
await models.WagonTypeTray.create({height: 40, wagonTypeFk: 1, wagonTypeColorFk: 4}, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error.message).toBe('The height must be greater than 50cm');
});
});

View File

@ -25,6 +25,19 @@
}, },
"maxTrays": { "maxTrays": {
"type": "number" "type": "number"
},
"defaultHeight": {
"type": "number"
},
"defaultTrayColorFk": {
"type": "number"
} }
},
"relations": {
"WagonTypeColor": {
"type": "belongsTo",
"model": "WagonTypeColor",
"foreignKey": "defaultTrayColorFk"
}
} }
} }

View File

@ -0,0 +1,25 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.observe('before save', async ctx => {
if (ctx.isNewInstance) {
const models = Self.app.models;
const {wagonTypeFk, height} = ctx.instance;
const trays = await models.WagonTypeTray.find({where: {wagonTypeFk}});
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 (height < config.minHeightBetweenTrays)
throw new UserError('The height must be greater than 50cm');
if (height > config.maxWagonHeight)
throw new UserError('The maximum height of the wagon is 200cm');
}
});
};

View File

@ -11,13 +11,13 @@
"id": true, "id": true,
"type": "number" "type": "number"
}, },
"typeFk": { "wagonTypeFk": {
"type": "number" "type": "number"
}, },
"height": { "height": {
"type": "number" "type": "number"
}, },
"colorFk": { "wagonTypeColorFk": {
"type": "number" "type": "number"
} }
}, },
@ -25,12 +25,12 @@
"type": { "type": {
"type": "belongsTo", "type": "belongsTo",
"model": "WagonType", "model": "WagonType",
"foreignKey": "typeFk" "foreignKey": "wagonTypeFk"
}, },
"color": { "color": {
"type": "belongsTo", "type": "belongsTo",
"model": "WagonTypeColor", "model": "WagonTypeColor",
"foreignKey": "colorFk" "foreignKey": "wagonTypeColorFk"
} }
} }
} }

View File

@ -1,5 +1,14 @@
module.exports = Self => { module.exports = Self => {
require('../methods/wagonType/createWagonType')(Self); Self.observe('after save', async ctx => {
require('../methods/wagonType/editWagonType')(Self); if (ctx.isNewInstance) {
require('../methods/wagonType/deleteWagonType')(Self); const models = Self.app.models;
const config = await models.WagonConfig.findOne();
await models.WagonTypeTray.create({
wagonTypeFk: ctx.instance.id,
height: config.defaultHeight,
wagonTypeColorFk: config.defaultTrayColorFk
}, ctx.options);
}
});
}; };

View File

@ -50,7 +50,7 @@ module.exports = Self => {
or: [ or: [
{and: [ {and: [
{isReadableByWorker: true}, {isReadableByWorker: true},
{worker: userId} {'wd.workerFk': userId}
]}, ]},
{ {
role: { role: {

View File

@ -60,7 +60,7 @@
"@babel/register": "^7.7.7", "@babel/register": "^7.7.7",
"@commitlint/cli": "^19.2.1", "@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0", "@commitlint/config-conventional": "^19.1.0",
"@verdnatura/myt": "^1.6.9", "@verdnatura/myt": "^1.6.11",
"angular-mocks": "^1.7.9", "angular-mocks": "^1.7.9",
"babel-jest": "^26.0.1", "babel-jest": "^26.0.1",
"babel-loader": "^8.2.4", "babel-loader": "^8.2.4",

View File

@ -143,8 +143,8 @@ devDependencies:
specifier: ^19.1.0 specifier: ^19.1.0
version: 19.1.0 version: 19.1.0
'@verdnatura/myt': '@verdnatura/myt':
specifier: ^1.6.9 specifier: ^1.6.11
version: 1.6.9 version: 1.6.11
angular-mocks: angular-mocks:
specifier: ^1.7.9 specifier: ^1.7.9
version: 1.8.3 version: 1.8.3
@ -2846,8 +2846,8 @@ packages:
dev: false dev: false
optional: true optional: true
/@verdnatura/myt@1.6.9: /@verdnatura/myt@1.6.11:
resolution: {integrity: sha512-29IauYra9igfdPWwV4+pVV/tBXvIg0fkVHEpSz8Zz3G3lRtzm286FN2Kv6hZkxmD/F1n52O37jN9WLiLHDTW1Q==} resolution: {integrity: sha512-uqdbSJSznBBzAoRkvBt600nUMEPL1PJ2v73eWMZbaoGUMiZiNAehYjs4gIrObP1cxC85JOx97XoLpG0BzPsaig==}
hasBin: true hasBin: true
dependencies: dependencies:
'@sqltools/formatter': 1.2.5 '@sqltools/formatter': 1.2.5
@ -3306,6 +3306,7 @@ packages:
/are-we-there-yet@1.1.7: /are-we-there-yet@1.1.7:
resolution: {integrity: sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==} resolution: {integrity: sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==}
deprecated: This package is no longer supported.
dependencies: dependencies:
delegates: 1.0.0 delegates: 1.0.0
readable-stream: 2.3.8 readable-stream: 2.3.8
@ -6593,6 +6594,7 @@ packages:
/gauge@2.7.4: /gauge@2.7.4:
resolution: {integrity: sha512-14x4kjc6lkD3ltw589k0NrPD6cCNTD6CWoVUNpB85+DrtONoZn+Rug6xZU5RvSC4+TZPxA5AnBibQYAvZn41Hg==} resolution: {integrity: sha512-14x4kjc6lkD3ltw589k0NrPD6cCNTD6CWoVUNpB85+DrtONoZn+Rug6xZU5RvSC4+TZPxA5AnBibQYAvZn41Hg==}
deprecated: This package is no longer supported.
dependencies: dependencies:
aproba: 1.2.0 aproba: 1.2.0
console-control-strings: 1.1.0 console-control-strings: 1.1.0
@ -10814,6 +10816,7 @@ packages:
/npmlog@4.1.2: /npmlog@4.1.2:
resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==} resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==}
deprecated: This package is no longer supported.
dependencies: dependencies:
are-we-there-yet: 1.1.7 are-we-there-yet: 1.1.7
console-control-strings: 1.1.0 console-control-strings: 1.1.0
@ -11055,6 +11058,7 @@ packages:
/osenv@0.1.5: /osenv@0.1.5:
resolution: {integrity: sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==} resolution: {integrity: sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==}
deprecated: This package is no longer supported.
dependencies: dependencies:
os-homedir: 1.0.2 os-homedir: 1.0.2
os-tmpdir: 1.0.2 os-tmpdir: 1.0.2