diff --git a/back/models/production-config.json b/back/models/production-config.json index 048264e8c..4796089d7 100644 --- a/back/models/production-config.json +++ b/back/models/production-config.json @@ -12,12 +12,6 @@ "required": true, "id": true }, - "sectorFromCode": { - "type": "string" - }, - "sectorToCode": { - "type": "string" - }, "backupPrinterNotificationDelay": { "type": "string" }, diff --git a/db/versions/11395-greenIvy/00-firstScript.sql b/db/versions/11395-greenIvy/00-firstScript.sql new file mode 100644 index 000000000..ebfb06b9d --- /dev/null +++ b/db/versions/11395-greenIvy/00-firstScript.sql @@ -0,0 +1,16 @@ + +DELETE FROM salix.ACL + WHERE property ='hasItemOlder'; + +ALTER TABLE vn.productionConfig DROP FOREIGN KEY productionConfig_sector_FK; +ALTER TABLE vn.productionConfig DROP FOREIGN KEY productionConfig_sector_FK_1; + +ALTER TABLE vn.productionConfig DROP COLUMN sectorToCode; +ALTER TABLE vn.productionConfig DROP COLUMN sectorFromCode; + + + + + + + diff --git a/modules/item/back/methods/item-shelving/getListItemNewer.js b/modules/item/back/methods/item-shelving/getListItemNewer.js deleted file mode 100644 index c806c0a7e..000000000 --- a/modules/item/back/methods/item-shelving/getListItemNewer.js +++ /dev/null @@ -1,70 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('getListItemNewer', { - description: - 'Get boolean if any or specific item of the shelving has older created in another shelving or parking', - accessType: 'READ', - accepts: [{ - arg: 'shelvingFk', - type: 'string', - required: true, - description: 'Shelving code' - }, - { - arg: 'parking', - type: 'string', - required: true, - description: 'Parking code' - }, - ], - returns: { - type: 'Array', - root: true - }, - http: { - path: `/getListItemNewer`, - verb: 'GET' - } - }); - - Self.getListItemNewer = async(shelvingFk, parking, options) => { - const myOptions = {}; - if (typeof options == 'object') - Object.assign(myOptions, options); - - const [isParkingToReview] = await Self.rawSql(` - SELECT COUNT(p.id) parkingToReview - FROM vn.parking p - JOIN vn.sector s ON s.id = p.sectorFk - JOIN vn.productionConfig pc - WHERE p.code = ? AND s.code = pc.sectorToCode;`, - [parking], myOptions); - - if (isParkingToReview['parkingToReview'] < 1) return []; - - const result = await Self.rawSql(` - WITH tItemShelving AS( - SELECT is2.itemFk, is2.created, p.sectorFK, is2.id - FROM vn.itemShelving is2 - JOIN vn.shelving sh ON sh.id = is2.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk - JOIN vn.productionConfig pc - WHERE sh.code = ? AND s.code = pc.sectorFromCode - ), tItemInSector AS ( - SELECT is2.itemFk, is2.created, sh.code - FROM vn.itemShelving is2 - JOIN vn.shelving sh ON sh.id = is2.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk - JOIN vn.productionConfig pc - WHERE sh.code <> ? - AND s.code = pc.sectorFromCode) - SELECT ti.itemFK, tis.code shelvingFk - FROM tItemShelving ti - JOIN tItemInSector tis ON tis.itemFk = ti.itemFk - JOIN vn.productionConfig pc - WHERE ti.created + INTERVAL pc.itemOlderReviewHours HOUR < tis.created;`, - [shelvingFk, shelvingFk], myOptions); - return result; - }; -}; diff --git a/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js b/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js deleted file mode 100644 index 962863095..000000000 --- a/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js +++ /dev/null @@ -1,32 +0,0 @@ - -const {models} = require('vn-loopback/server/server'); - -describe('itemShelving getListItemNewer()', () => { - it('should return true because there is an older item', async() => { - const shelving = 'NBB'; - const parking = '700-01'; - - const sectorCamHighCode = 'FIRST'; - const sectorCamCode = 'NS'; - - const tx = await models.Sector.beginTransaction({}); - const myOptions = {transaction: tx}; - - try { - const config = await models.ProductionConfig.findOne(); - - await config.updateAttributes({ - sectorToCode: sectorCamHighCode, - sectorFromCode: sectorCamCode - }); - - const result = await models.ItemShelving.getListItemNewer(shelving, parking, myOptions); - - expect(result.length).toEqual(3); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); -}); diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index 34e18f23f..4a6895512 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -4,6 +4,5 @@ module.exports = Self => { require('../methods/item-shelving/getInventory')(Self); require('../methods/item-shelving/getAlternative')(Self); require('../methods/item-shelving/updateFromSale')(Self); - require('../methods/item-shelving/getListItemNewer')(Self); require('../methods/item-shelving/getItemsByReviewOrder')(Self); };