4492-item.create-same-as-item.isLaid #1125

Merged
pau merged 10 commits from 4492-item.create-same-as-item.isLaid into dev 2022-11-16 08:04:56 +00:00
4 changed files with 20 additions and 0 deletions

View File

@ -49,6 +49,10 @@ module.exports = Self => {
const provisionalName = params.provisionalName;
delete params.provisionalName;
const itemType = await models.ItemType.findById(params.typeFk, myOptions);
params.isLaid = itemType.isLaid;
pau marked this conversation as resolved Outdated
Outdated
Review

Mover esta linea arriba del create para poder crearlo directamente con el valor de la propiedad isLaid

Mover esta linea arriba del create para poder crearlo directamente con el valor de la propiedad isLaid
const item = await models.Item.create(params, myOptions);
const typeTags = await models.ItemTypeTag.find({
pau marked this conversation as resolved Outdated
Outdated
Review

Evitar el save para no hacer dos consultas a la bd

Evitar el save para no hacer dos consultas a la bd

View File

@ -15,6 +15,11 @@ describe('item new()', () => {
};
let item = await models.Item.new(itemParams, options);
let itemType = await models.ItemType.findById(item.typeFk, options);
item.isLaid = itemType.isLaid;
const temporalNameTag = await models.Tag.findOne({where: {name: 'Nombre temporal'}}, options);
const temporalName = await models.ItemTag.findOne({
@ -26,9 +31,14 @@ describe('item new()', () => {
item = await models.Item.findById(item.id, null, options);
itemType = await models.ItemType.findById(item.typeFk, options);
item.isLaid = itemType.isLaid;
expect(item.intrastatFk).toEqual(5080000);
expect(item.originFk).toEqual(1);
expect(item.typeFk).toEqual(2);
expect(item.isLaid).toBeFalse();
expect(item.name).toEqual('planta');
expect(temporalName.value).toEqual('planta');

View File

@ -26,6 +26,9 @@
},
"isUnconventionalSize": {
"type": "number"
},
"isLaid": {
"type": "boolean"
pau marked this conversation as resolved Outdated
Outdated
Review

boolean

boolean
}
},
"relations": {

View File

@ -143,6 +143,9 @@
},
"packingShelve": {
"type": "number"
},
"isLaid": {
"type": "boolean"
}
},
"relations": {