feat hasItemOlder refs#6964
This commit is contained in:
parent
46cd20a1fd
commit
239814e6b4
|
@ -3,17 +3,23 @@
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "productionConfig"
|
"table": "productionConfig"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"required": true,
|
"required": true,
|
||||||
"id": true
|
"id": true
|
||||||
},
|
},
|
||||||
|
"sectorFromCode": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"sectorToCode": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"backupPrinterNotificationDelay": {
|
"backupPrinterNotificationDelay": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
USE vn;
|
USE vn;
|
||||||
|
|
||||||
ALTER TABLE vn.productionConfig ADD sectorFromCode varchar(11) NULL COMMENT 'Sector origen que se revisa ítems más nuevos al parkinear';
|
ALTER TABLE vn.productionConfig ADD sectorFromCode varchar(15) NULL COMMENT 'Sector origen que se revisa ítems más nuevos al parkinear';
|
||||||
ALTER TABLE vn.productionConfig ADD sectorToCode varchar(11) NULL COMMENT 'Sector destino que se revisa ítems más nuevos al parkinear';
|
ALTER TABLE vn.productionConfig ADD sectorToCode varchar(15) NULL COMMENT 'Sector destino que se revisa ítems más nuevos al parkinear';
|
||||||
|
|
||||||
ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK FOREIGN KEY (sectorFromCode) REFERENCES vn.sector(code) ON DELETE CASCADE ON UPDATE CASCADE;
|
ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK FOREIGN KEY (sectorFromCode) REFERENCES vn.sector(code) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK_1 FOREIGN KEY (sectorToCode) REFERENCES vn.sector(code) ON DELETE CASCADE ON UPDATE CASCADE;
|
ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK_1 FOREIGN KEY (sectorToCode) REFERENCES vn.sector(code) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
|
@ -49,7 +49,7 @@ module.exports = Self => {
|
||||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||||
JOIN vn.sector s ON s.id = p.sectorFk
|
JOIN vn.sector s ON s.id = p.sectorFk
|
||||||
JOIN vn.productionConfig pc
|
JOIN vn.productionConfig pc
|
||||||
WHERE is2.shelvingFk = ? AND s.code = c.sectorFromCode
|
WHERE is2.shelvingFk = ? AND s.code = pc.sectorFromCode
|
||||||
), tItemInSector AS (
|
), tItemInSector AS (
|
||||||
SELECT is2.itemFk, is2.created, is2.shelvingFk
|
SELECT is2.itemFk, is2.created, is2.shelvingFk
|
||||||
FROM vn.itemShelving is2
|
FROM vn.itemShelving is2
|
||||||
|
@ -58,7 +58,7 @@ module.exports = Self => {
|
||||||
JOIN vn.sector s ON s.id = p.sectorFk
|
JOIN vn.sector s ON s.id = p.sectorFk
|
||||||
JOIN vn.productionConfig pc
|
JOIN vn.productionConfig pc
|
||||||
WHERE is2.shelvingFk <> ?
|
WHERE is2.shelvingFk <> ?
|
||||||
AND s.code = c.sectorFromCode)
|
AND s.code = pc.sectorFromCode)
|
||||||
SELECT ti.itemFK, tis.shelvingFk
|
SELECT ti.itemFK, tis.shelvingFk
|
||||||
FROM tItemShelving ti
|
FROM tItemShelving ti
|
||||||
JOIN tItemInSector tis ON tis.itemFk = ti.itemFk
|
JOIN tItemInSector tis ON tis.itemFk = ti.itemFk
|
||||||
|
|
|
@ -2,31 +2,36 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('itemShelving getListItemNewer()', () => {
|
describe('itemShelving getListItemNewer()', () => {
|
||||||
fit('should return true because there is an older item', async() => {
|
it('should return true because there is an older item', async() => {
|
||||||
const shelving = 'NCC';
|
const shelving = 'NCC';
|
||||||
const parking = 'A-47-1';
|
const parking = 'A-47-1';
|
||||||
const sectorCam = 1;
|
|
||||||
const sectorCamCode = 'CAMARA SECTOR D';
|
const sectorCamHighCode = 'CAMARA SECTOR D';
|
||||||
const sectorCamHigh = 9991;
|
const sectorCamCode = 'NAVE ALGEMESI';
|
||||||
const sectorCamHighCode = 'NAVE ALGEMESI';
|
|
||||||
|
const sectorCamCodeHighId = 1;
|
||||||
|
const sectorCamCodeId = 9991;
|
||||||
|
|
||||||
const tx = await models.Sector.beginTransaction({});
|
const tx = await models.Sector.beginTransaction({});
|
||||||
const myOptions = {transaction: tx};
|
const myOptions = {transaction: tx};
|
||||||
|
|
||||||
const filter = {where: {id: sectorCam}};
|
|
||||||
const filterHigh = {where: {id: sectorCamHigh}};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const sectorCamBefore = await models.Sector.findOne(filter, myOptions);
|
const sectorHighCam = await models.Sector.findById(sectorCamCodeHighId, null, myOptions);
|
||||||
|
await sectorHighCam.updateAttributes({
|
||||||
await sectorCamBefore.updateAttributes({
|
|
||||||
code: sectorCamCode
|
|
||||||
}, myOptions);
|
|
||||||
|
|
||||||
const sectorCamHighBefore = await models.Sector.findOne(filterHigh, myOptions);
|
|
||||||
await sectorCamHighBefore.updateAttributes({
|
|
||||||
code: sectorCamHighCode
|
code: sectorCamHighCode
|
||||||
}, myOptions);
|
});
|
||||||
|
|
||||||
|
const sectorCam = await models.Sector.findById(sectorCamCodeId, null, myOptions);
|
||||||
|
await sectorCam.updateAttributes({
|
||||||
|
code: sectorCamCode
|
||||||
|
});
|
||||||
|
|
||||||
|
const config = await models.ProductionConfig.findOne();
|
||||||
|
|
||||||
|
await config.updateAttributes({
|
||||||
|
sectorToCode: sectorCamHighCode,
|
||||||
|
sectorFromCode: sectorCamCode
|
||||||
|
});
|
||||||
|
|
||||||
const result = await models.ItemShelving.getListItemNewer(shelving, parking, myOptions);
|
const result = await models.ItemShelving.getListItemNewer(shelving, parking, myOptions);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue