test(ticket_volume): backTest
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2022-01-12 14:55:20 +01:00
parent c9564e817a
commit 757fe73ecd
3 changed files with 16 additions and 6 deletions

View File

@ -1,3 +1,6 @@
USE vn;
DELIMITER $$
$$
CREATE OR REPLACE CREATE OR REPLACE
ALGORITHM = UNDEFINED VIEW `vn`.`saleVolume` AS ALGORITHM = UNDEFINED VIEW `vn`.`saleVolume` AS
select select
@ -31,5 +34,5 @@ join `itemCost` `ic` on
and `ic`.`warehouseFk` = `t`.`warehouseFk`)) and `ic`.`warehouseFk` = `t`.`warehouseFk`))
where where
`s`.`quantity` > 0; `s`.`quantity` > 0;
$$
-- NO FUNCIONA DELIMITER ;

View File

@ -29,11 +29,15 @@ module.exports = Self => {
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
const saleVolume = await Self.rawSql(`SELECT * FROM vn.saleVolume const saleVolume = await Self.rawSql(`
WHERE ticketFk = ?`, [ticketFk], myOptions); SELECT saleFk, volume
FROM vn.saleVolume
WHERE ticketFk = ?`, [ticketFk], myOptions);
const packingTypeVolume = await Self.rawSql(` const packingTypeVolume = await Self.rawSql(`
SELECT s.itemPackingTypeFk code, i.description, SUM(s.volume) volume SELECT s.itemPackingTypeFk code,
i.description,
SUM(s.volume) volume
FROM vn.saleVolume s FROM vn.saleVolume s
LEFT JOIN vn.itemPackingType i LEFT JOIN vn.itemPackingType i
ON i.code = s.itemPackingTypeFk ON i.code = s.itemPackingTypeFk

View File

@ -9,8 +9,11 @@ describe('ticket getVolume()', () => {
const ticketId = 1; const ticketId = 1;
const result = await models.Ticket.getVolume(ticketId, options); const result = await models.Ticket.getVolume(ticketId, options);
const saleVolume = result[0];
const packingTypeVolume = result[1];
expect(result[0].volume).toEqual(1.09); expect(saleVolume).toBeDefined;
expect(packingTypeVolume).toBeDefined;
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {