5983_inventory_parking #1677
|
@ -0,0 +1,52 @@
|
|||
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_inventory`(vParkingFromFk INT, vParkingToFk INT)
|
||||
/**
|
||||
* Devuelve un listado de ubicaciones a revisar
|
||||
*
|
||||
* @param vParkingFromFk Parking de partida, identificador de vn.parking
|
||||
* @param vParkingToFk Parking de llegada, identificador de vn.parking
|
||||
*/
|
||||
|
||||
DECLARE vSectorFk INT;
|
||||
DECLARE vPickingOrderFrom INT;
|
||||
DECLARE vPickingOrderTo INT;
|
||||
|
||||
SELECT ish.id,
|
||||
p.pickingOrder,
|
||||
p.code parking,
|
||||
|
||||
ish.shelvingFk,
|
||||
ish.itemFk,
|
||||
i.longName,
|
||||
ish.visible,
|
||||
p.sectorFk,
|
||||
it.workerFk buyer,
|
||||
CONCAT('http:',ic.url, '/catalog/1600x900/',i.image) urlImage,
|
||||
ish.isChecked,
|
||||
CASE
|
||||
WHEN s.notPrepared > sm.parked THEN 0
|
||||
WHEN sm.visible > sm.parked THEN 1
|
||||
ELSE 2
|
||||
END
|
||||
FROM vn.itemShelving ish
|
||||
JOIN vn.item i ON i.id = ish.itemFk
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
JOIN (SELECT s.itemFk, sum(s.quantity) notPrepared
|
||||
FROM vn.sale s
|
||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
JOIN vn.warehouse w ON w.id = t.warehouseFk
|
||||
WHERE t.shipped BETWEEN CURDATE()
|
||||
AND CURDATE() + INTERVAL 23 HOUR
|
||||
AND s.isPicked = FALSE
|
||||
AND w.name = 'Algemesi'
|
||||
GROUP BY s.itemFk) s ON s.itemFk = i.id
|
||||
JOIN hedera.imageConfig ic
|
||||
WHERE p.pickingOrder BETWEEN vParkingFrom AND vPickingOrderTo
|
||||
AND p.sectorFk = vSectorFk
|
||||
ORDER BY p.pickingOrder;
|
||||
|
||||
END ;;
|
||||
DELIMITER ;
|
|
@ -0,0 +1,37 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getInventory', {
|
||||
description: 'Get list of itemShelving to review between two parking code',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'parkingFrom',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Parking code from'
|
||||
},
|
||||
{
|
||||
arg: 'parkingTo',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Parking code to'
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getInventory`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getInventory = async(parkingFrom, parkingTo, options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const [result] = await Self.rawSql(`CALL vn.itemShelving_inventory(?, ?)`, [parkingFrom, parkingTo], myOptions);
|
||||
|
||||
return result;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('itemShelving getInventory()', () => {
|
||||
it('should return a list of itemShelvings', async() => {
|
||||
const tx = await models.ItemShelving.beginTransaction({});
|
||||
|
||||
let response;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
response = await models.ItemShelving.getInventory(1, 2, options);
|
||||
jgallego
commented
gastar funcions natives de loopback gastar funcions natives de loopback
alexm
commented
Si, ho vaig pensar, pero no tenim el model config en salix. Per no ficarlo per un camp(id i mainWarehouseFk) Si, ho vaig pensar, pero no tenim el model config en salix. Per no ficarlo per un camp(id i mainWarehouseFk)
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
expect(response.length).toEqual(2);
|
||||
});
|
||||
});
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/item-shelving/deleteItemShelvings')(Self);
|
||||
require('../methods/item-shelving/getInventory')(Self);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
sin vn
Fet