Merge branch '1773-1774-travel_summary' of verdnatura/salix into dev
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
LGTM
This commit is contained in:
commit
e11faa1132
|
@ -0,0 +1,6 @@
|
|||
CREATE TABLE `vn`.`packagingConfig` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`upperGap` INT NOT NULL,
|
||||
PRIMARY KEY (`id`));
|
||||
|
||||
INSERT INTO `vn`.`packagingConfig` (`upperGap`) VALUES ('10');
|
|
@ -649,7 +649,9 @@ INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `d
|
|||
(12, 3, 30, 'GRE', 1, 2, NULL, 2, 06021010, 1, 4751000000, 0, NULL, 0, 67350, 2, NULL),
|
||||
(13, 5, 30, 'GRE', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL),
|
||||
(14, 5, 90, 'AZL', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL),
|
||||
(71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, NULL, 2, NULL);
|
||||
(15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL),
|
||||
(16, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL),
|
||||
(71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, 67350, 2, NULL);
|
||||
|
||||
INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `checked`, `workerFk`)
|
||||
VALUES
|
||||
|
@ -666,12 +668,14 @@ INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `create
|
|||
|
||||
INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPackageReturnable`, `created`, `itemFk`, `price`)
|
||||
VALUES
|
||||
(1, 0.00, 10, 10, 0, 0, CURDATE(), 6, 1.50),
|
||||
(2, 100.00, 20, 20, 0, 0, CURDATE(), 7, 1.00),
|
||||
(3, 14000.00, 0, 0, 0, 0, CURDATE(), NULL, 0),
|
||||
(4, 218000.00, 0, 0, 0, 0, CURDATE(), NULL, 0),
|
||||
(5, 292000.00, 0, 0, 0, 0, CURDATE(), NULL, 0),
|
||||
(94, 140875.00, 49.00, 115.00, 25.00, 0, CURDATE(), 71, 0.00);
|
||||
(1, 0.00, 10, 10, 0, 1, CURDATE(), 6, 1.50),
|
||||
(2, 100.00, 20, 20, 0, 1, CURDATE(), 7, 1.00),
|
||||
(3, 14000.00, 0, 0, 0, 1, CURDATE(), NULL, 0),
|
||||
(4, 218000.00, 0, 0, 0, 0, CURDATE(), NULL, 0),
|
||||
(5, 292000.00, 0, 0, 0, 0, CURDATE(), NULL, 0),
|
||||
(94, 140875.00, 49.00, 115.00, 25.00, 0, CURDATE(), 71, 0.00),
|
||||
('cc', 1640038.00, 56.00, 220.00, 128.00, 1, CURDATE(), 15, 90.00),
|
||||
('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, CURDATE(), 16, 0.00);
|
||||
|
||||
INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp`)
|
||||
VALUES
|
||||
|
@ -1047,50 +1051,50 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`)
|
|||
(4, 4),
|
||||
(5, 6);
|
||||
|
||||
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`)
|
||||
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`,`ref`, `totalEntries`)
|
||||
VALUES
|
||||
(1, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000),
|
||||
(2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000),
|
||||
(3, CURDATE(), CURDATE(), 1, 2, 1, 0.00, 0.00),
|
||||
(4, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 50.00, 500),
|
||||
(5, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 2, 1, 50.00, 500),
|
||||
(6, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 2, 1, 50.00, 500),
|
||||
(7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500);
|
||||
(1, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1),
|
||||
(2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 1),
|
||||
(3, CURDATE(), CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1),
|
||||
(4, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 50.00, 500, 'fourth travel', 1),
|
||||
(5, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 2, 1, 50.00, 500, 'fifth travel', 1),
|
||||
(6, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 2, 1, 50.00, 500, 'sixth travel', 1),
|
||||
(7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500, 'seventh travel', 1);
|
||||
|
||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`,`ref`)
|
||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`, `ref`, `notes`, `evaNotes`)
|
||||
VALUES
|
||||
(1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 442, 'Movimiento 1'),
|
||||
(2, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 442, 'Movimiento 2'),
|
||||
(3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 442, 'Movimiento 3'),
|
||||
(4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 69, 'Movimiento 4'),
|
||||
(5, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 442, 'Movimiento 5'),
|
||||
(6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 442, 'Movimiento 6'),
|
||||
(7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movimiento 7');
|
||||
(1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 442, 'Movement 1', 'this is the note one', 'observation one'),
|
||||
(2, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 442, 'Movement 2', 'this is the note two', 'observation two'),
|
||||
(3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 442, 'Movement 3', 'this is the note three', 'observation three'),
|
||||
(4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 69, 'Movement 4', 'this is the note four', 'observation four'),
|
||||
(5, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 442, 'Movement 5', 'this is the note five', 'observation five'),
|
||||
(6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 442, 'Movement 6', 'this is the note six', 'observation six'),
|
||||
(7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movement 7', 'this is the note seven', 'observation seven');
|
||||
|
||||
INSERT INTO `bi`.`claims_ratio`(`id_Cliente`, `Consumo`, `Reclamaciones`, `Ratio`, `recobro`, `inflacion`)
|
||||
VALUES
|
||||
(101, 500, NULL, 0.00, 0.00, 1.00),
|
||||
(102, 1000, 2.00, 0.01, 0.05, 1.00),
|
||||
(102, 1000, 2.00, 0.01, 0.05, 1.00),
|
||||
(103, 2000, 0.00, 0.00, 0.02, 1.00),
|
||||
(104, 2500, 150.00, 0.02, 0.10, 1.00);
|
||||
|
||||
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packageFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`,`minPrice`,`producer`,`printedStickers`,`isChecked`,`isIgnored`, `created`)
|
||||
VALUES
|
||||
(1, 1, 1, 50, 5000, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)),
|
||||
(2, 2, 1, 50, 100, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
|
||||
(3, 3, 1, 50, 100, 4, 1, 0.000, 0.000, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(4, 2, 2, 5, 450, 3, 1, 0.000, 0.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(5, 3, 3, 55, 500, 5, 1, 0.000, 0.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(6, 4, 8, 50, 1000, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(7, 4, 9, 20, 1000, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(8, 4, 4, 1.25, 1000, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(9, 4, 4, 1.25, 1000, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(10, 5, 1, 50, 10, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(11, 5, 4, 1.25, 10, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(12, 6, 4, 1.25, 0, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(13, 7, 1, 50, 0, 3, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(14, 7, 2, 5, 0, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(15, 7, 4, 1.25, 0, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE());
|
||||
(1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)),
|
||||
(2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
|
||||
(3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()),
|
||||
(15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE());
|
||||
|
||||
INSERT INTO `vn2008`.`tblContadores`(`id`,`FechaInventario`)
|
||||
VALUES
|
||||
|
|
|
@ -29,7 +29,7 @@ module.exports = Self => {
|
|||
FROM (SELECT i.name, i.id itemFk, p.id packagingFk
|
||||
FROM item i
|
||||
JOIN packaging p ON i.id = p.itemFk
|
||||
WHERE i.name <> '') p`
|
||||
WHERE i.name <> '' AND p.isPackageReturnable) p`
|
||||
);
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getEntries', {
|
||||
description: 'Return the entries of a travel',
|
||||
accessType: 'READ',
|
||||
accepts: {
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The travel id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/getEntries`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getEntries = async id => {
|
||||
let stmt;
|
||||
|
||||
stmt = new ParameterizedSQL(`
|
||||
SELECT e.travelFk, e.id, e.isConfirmed, e.ref, e.notes, e.evaNotes,
|
||||
s.name AS supplierName,
|
||||
CAST((SUM(IF(p.volume > 0,p.volume,p.width * p.depth * IF(p.height, p.height, i.size + pconfig.upperGap))
|
||||
* b.stickers)/1000000)/((pcc.width*pcc.depth*pcc.height)/1000000) AS DECIMAL(10,2)) cc,
|
||||
CAST((SUM(IF(p.volume > 0,p.volume,p.width * p.depth * IF(p.height, p.height, i.size + pconfig.upperGap))
|
||||
* b.stickers)/1000000)/((ppallet.width*ppallet.depth*ppallet.height)/1000000) AS DECIMAL(10,2)) pallet,
|
||||
CAST((SUM(IF(p.volume > 0,p.volume,p.width * p.depth * IF(p.height, p.height, i.size + pconfig.upperGap))
|
||||
* b.stickers)/1000000) AS DECIMAL(10,2)) m3,
|
||||
TRUNCATE(SUM(b.stickers)/(COUNT( b.id) / COUNT( DISTINCT b.id)),0) hb,
|
||||
CAST(SUM(b.freightValue*b.quantity) AS DECIMAL(10,2)) freightValue,
|
||||
CAST(SUM(b.packageValue*b.quantity) AS DECIMAL(10,2)) packageValue
|
||||
FROM vn.travel t
|
||||
LEFT JOIN vn.entry e ON t.id = e.travelFk
|
||||
LEFT JOIN vn.buy b ON b.entryFk = e.id
|
||||
LEFT JOIN vn.supplier s ON e.supplierFk = s.id
|
||||
JOIN vn.item i ON i.id = b.itemFk
|
||||
LEFT JOIN vn.packaging p ON p.id = b.packageFk
|
||||
JOIN vn.packaging pcc ON pcc.id = 'cc'
|
||||
JOIN vn.packaging ppallet ON ppallet.id = 'pallet 100'
|
||||
JOIN vn.packagingConfig pconfig
|
||||
WHERE t.id = ?
|
||||
GROUP BY e.id;`, [
|
||||
id
|
||||
]);
|
||||
|
||||
let result = await Self.rawStmt(stmt);
|
||||
|
||||
return result;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,50 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getTravel', {
|
||||
description: 'Returns the travel',
|
||||
accessType: 'READ',
|
||||
accepts: {
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The travel id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/getTravel`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getTravel = async id => {
|
||||
let filter = {
|
||||
where: {id: id},
|
||||
include: [
|
||||
{
|
||||
relation: 'agency',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'warehouseIn',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'warehouseOut',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
let travel = await Self.app.models.Travel.findOne(filter);
|
||||
return travel;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,29 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('travel getEntries()', () => {
|
||||
const travelId = 1;
|
||||
it('should check the response contains the id', async() => {
|
||||
const entries = await app.models.Travel.getEntries(travelId);
|
||||
|
||||
expect(entries.length).toEqual(1);
|
||||
expect(entries[0].id).toEqual(1);
|
||||
});
|
||||
|
||||
it('should check the response contains the travelFk', async() => {
|
||||
const entries = await app.models.Travel.getEntries(travelId);
|
||||
|
||||
expect(entries[0].travelFk).toEqual(1);
|
||||
});
|
||||
|
||||
it('should check the response contains the ref', async() => {
|
||||
const entries = await app.models.Travel.getEntries(travelId);
|
||||
|
||||
expect(entries[0].ref).toEqual('Movement 1');
|
||||
});
|
||||
|
||||
it('should check the response contains the m3', async() => {
|
||||
const entries = await app.models.Travel.getEntries(travelId);
|
||||
|
||||
expect(entries[0].m3).toEqual(0.22);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,30 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('travel getTravel()', () => {
|
||||
const travelId = 1;
|
||||
it('should check travel contains the id', async() => {
|
||||
const travel = await app.models.Travel.getTravel(travelId);
|
||||
|
||||
expect(travel.id).toEqual(1);
|
||||
});
|
||||
|
||||
it('should check travel contains the agency', async() => {
|
||||
const travel = await app.models.Travel.getTravel(travelId);
|
||||
const agencyName = travel.agency().name;
|
||||
|
||||
expect(agencyName).toEqual('inhouse pickup');
|
||||
});
|
||||
|
||||
it('should check travel contains the receiver warehouse name', async() => {
|
||||
const travel = await app.models.Travel.getTravel(travelId);
|
||||
const receiverWarehouseName = travel.warehouseIn().name;
|
||||
|
||||
expect(receiverWarehouseName).toEqual('Warehouse One');
|
||||
});
|
||||
|
||||
it('should check travel contains the totalEntries', async() => {
|
||||
const travel = await app.models.Travel.getTravel(travelId);
|
||||
|
||||
expect(travel.totalEntries).toEqual(1);
|
||||
});
|
||||
});
|
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"Travel": {
|
||||
"dataSource": "vn"
|
||||
},"Entry": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"name": "Entry",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "entry"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"dated": {
|
||||
"type": "date"
|
||||
},
|
||||
"ref": {
|
||||
"type": "String"
|
||||
},
|
||||
"isBooked": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"isInventory": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"notes": {
|
||||
"type": "Number"
|
||||
},
|
||||
"isConfirmed": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"isRaid": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"commission": {
|
||||
"type": "Number"
|
||||
},
|
||||
"created": {
|
||||
"type": "date"
|
||||
},
|
||||
"evaNotes": {
|
||||
"type": "String",
|
||||
"mysql": {
|
||||
"columnName": "observation"
|
||||
}
|
||||
},
|
||||
"isBlocked": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"loadPriority": {
|
||||
"type": "Number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"supplier": {
|
||||
"type": "belongsTo",
|
||||
"model": "Supplier",
|
||||
"foreignKey": "supplierFk"
|
||||
},
|
||||
"travel": {
|
||||
"type": "belongsTo",
|
||||
"model": "Travel",
|
||||
"foreignKey": "travelFk"
|
||||
},
|
||||
"company": {
|
||||
"type": "belongsTo",
|
||||
"model": "Company",
|
||||
"foreignKey": "companyFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/travel/getTravel')(Self);
|
||||
require('../methods/travel/getEntries')(Self);
|
||||
};
|
|
@ -29,6 +29,9 @@
|
|||
},
|
||||
"totalEntries": {
|
||||
"type": "Number"
|
||||
},
|
||||
"m3": {
|
||||
"type": "Number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<vn-main-block>
|
||||
<vn-side-menu side="left">
|
||||
<vn-travel-descriptor travel="$ctrl.travel"></vn-travel-descriptor>
|
||||
<vn-left-menu></vn-left-menu>
|
||||
</vn-side-menu>
|
||||
<div class="content-block" ui-view></div>
|
||||
</vn-main-block>
|
|
@ -0,0 +1,58 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
export default class Controller {
|
||||
constructor($stateParams, $http) {
|
||||
this.$http = $http;
|
||||
this.$stateParams = $stateParams;
|
||||
this.travel = null;
|
||||
this.filter = {
|
||||
fields: [
|
||||
'id',
|
||||
'ref',
|
||||
'warehouseInFk',
|
||||
'warehouseOutFk',
|
||||
'shipped',
|
||||
'landed',
|
||||
'totalEntries'
|
||||
],
|
||||
|
||||
where: {id: $stateParams.id},
|
||||
include: [
|
||||
{
|
||||
relation: 'warehouseIn',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'warehouseOut',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
this.getCard();
|
||||
}
|
||||
|
||||
getCard() {
|
||||
const params = {filter: this.filter};
|
||||
this.$http.get(`/api/Travels/${this.$stateParams.id}`, {params}).then(response => {
|
||||
this.travel = response.data;
|
||||
});
|
||||
}
|
||||
|
||||
reload() {
|
||||
this.getCard();
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$stateParams', '$http'];
|
||||
|
||||
ngModule.component('vnTravelCard', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<div class="vn-descriptor">
|
||||
<div class="header">
|
||||
<a translate-attr="{title: 'Return to module index'}" ui-sref="travel.index">
|
||||
<vn-icon icon="chevron_left"></vn-icon>
|
||||
</a>
|
||||
<a translate-attr="{title: 'Preview'}" ui-sref="travel.card.summary({id: $ctrl.travel.id})">
|
||||
<vn-icon icon="desktop_windows"></vn-icon>
|
||||
</a>
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="attributes">
|
||||
<vn-label-value label="Id"
|
||||
value="{{$ctrl.travel.id}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Reference"
|
||||
value="{{$ctrl.travel.ref}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Wh. In"
|
||||
value="{{$ctrl.travel.warehouseOut.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Wh. Out"
|
||||
value="{{$ctrl.travel.warehouseIn.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Shipped"
|
||||
value="{{$ctrl.travel.shipped | date: 'dd/MM/yyyy'}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Landed"
|
||||
value="{{$ctrl.travel.landed | date: 'dd/MM/yyyy'}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Total entries"
|
||||
value="{{$ctrl.travel.totalEntries}}">
|
||||
</vn-label-value>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,24 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class Controller {
|
||||
constructor($, $http, vnApp, $translate, aclService) {
|
||||
this.$http = $http;
|
||||
this.vnApp = vnApp;
|
||||
this.$translate = $translate;
|
||||
this.$ = $;
|
||||
this.aclService = aclService;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$http', 'vnApp', '$translate', 'aclService'];
|
||||
|
||||
ngModule.component('vnTravelDescriptor', {
|
||||
template: require('./index.html'),
|
||||
bindings: {
|
||||
travel: '<'
|
||||
},
|
||||
require: {
|
||||
card: '^vnTravelCard'
|
||||
},
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,6 @@
|
|||
Reference: Referencia
|
||||
Wh. In: Warehouse entrada
|
||||
Wh. Out: Warehouse salida
|
||||
Shipped: F. envío
|
||||
Landed: F. entrega
|
||||
Total entries: Entradas totales
|
|
@ -2,3 +2,6 @@ export * from './module';
|
|||
|
||||
import './index/';
|
||||
import './search-panel';
|
||||
import './descriptor';
|
||||
import './card';
|
||||
import './summary';
|
||||
|
|
|
@ -31,11 +31,13 @@
|
|||
<vn-th field="warehouseInFk">Warehouse In</vn-th>
|
||||
<vn-th field="landed" center>Landed</vn-th>
|
||||
<vn-th field="isReceived" center>Received</vn-th>
|
||||
<vn-th></vn-th>
|
||||
<vn-th shrink></vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="travel in travels" class="clickable searchResult">
|
||||
<a ng-repeat="travel in travels"
|
||||
class="clickable vn-tr searchResult"
|
||||
ui-sref="travel.card.summary({id: {{::travel.id}}})">
|
||||
<vn-td number>{{::travel.id}}</vn-td>
|
||||
<vn-td expand>{{::travel.ref}}</vn-td>
|
||||
<vn-td expand>{{::travel.agency.name}}</vn-td>
|
||||
|
@ -45,11 +47,26 @@
|
|||
<vn-td>{{::travel.warehouseIn.name}}</vn-td>
|
||||
<vn-td center>{{::travel.landed | date:'dd/MM/yyyy'}}</vn-td>
|
||||
<vn-td center><vn-check ng-model="travel.isReceived" disabled="true"></vn-check></vn-td>
|
||||
<vn-td></vn-td>
|
||||
</vn-tr>
|
||||
<vn-td>
|
||||
<vn-icon-button
|
||||
ng-click="$ctrl.preview($event, travel)"
|
||||
vn-tooltip="Preview"
|
||||
icon="desktop_windows">
|
||||
</vn-icon-button>
|
||||
</vn-td>
|
||||
</a>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
</vn-card>
|
||||
</vn-data-viewer>
|
||||
</div>
|
||||
<vn-dialog
|
||||
vn-id="summary"
|
||||
class="dialog-summary">
|
||||
<tpl-body>
|
||||
<vn-travel-summary
|
||||
travel="$ctrl.travelSelected">
|
||||
</vn-travel-summary>
|
||||
</tpl-body>
|
||||
</vn-dialog>
|
||||
<vn-scroll-up></vn-scroll-up>
|
|
@ -2,7 +2,7 @@ import ngModule from '../module';
|
|||
|
||||
export default class Controller {
|
||||
constructor($scope) {
|
||||
this.$scope = $scope;
|
||||
this.$ = $scope;
|
||||
this.ticketSelected = null;
|
||||
|
||||
this.filter = {
|
||||
|
@ -47,6 +47,13 @@ export default class Controller {
|
|||
return {[param]: value};
|
||||
}
|
||||
}
|
||||
|
||||
preview(event, travel) {
|
||||
this.travelSelected = travel;
|
||||
this.$.summary.show();
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope'];
|
||||
|
|
|
@ -16,6 +16,19 @@
|
|||
"component": "vn-travel-index",
|
||||
"description": "Travels",
|
||||
"acl": ["developer"]
|
||||
}, {
|
||||
"url": "/:id",
|
||||
"state": "travel.card",
|
||||
"abstract": true,
|
||||
"component": "vn-travel-card"
|
||||
}, {
|
||||
"url": "/summary",
|
||||
"state": "travel.card.summary",
|
||||
"component": "vn-travel-summary",
|
||||
"description": "Summary",
|
||||
"params": {
|
||||
"travel": "$ctrl.travel"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
<vn-card class="summary">
|
||||
<h5>{{$ctrl.travelData.id}} - {{$ctrl.travelData.ref}}</h5>
|
||||
<vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-label-value label="Shipped"
|
||||
value="{{$ctrl.travelData.shipped | date: 'dd/MM/yyyy'}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Warehouse Out"
|
||||
value="{{$ctrl.travelData.warehouseOut.name}}">
|
||||
</vn-label-value>
|
||||
<vn-check
|
||||
label="Delivered"
|
||||
value="{{$ctrl.travelData.isDelivered}}"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
</vn-one>
|
||||
<vn-one>
|
||||
<vn-label-value label="Landed"
|
||||
value="{{$ctrl.travelData.landed | date: 'dd/MM/yyyy'}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Warehouse In"
|
||||
value="{{$ctrl.travelData.warehouseIn.name}}">
|
||||
</vn-label-value>
|
||||
<vn-check
|
||||
label="Received"
|
||||
value="{{$ctrl.travelData.isReceived}}"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
</vn-one>
|
||||
<vn-one>
|
||||
<vn-label-value label="Agency"
|
||||
value="{{$ctrl.travelData.agency.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Reference"
|
||||
value="{{$ctrl.travelData.ref}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="m3"
|
||||
value="{{$ctrl.travelData.m3}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Total entries"
|
||||
value="{{$ctrl.travelData.totalEntries}}">
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
<vn-auto>
|
||||
<h4 translate>Entries</h4>
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th shrink>Confirmed</vn-th>
|
||||
<vn-th shrink>Entry Id</vn-th>
|
||||
<vn-th shrink>Supplier</vn-th>
|
||||
<vn-th shrink>Reference</vn-th>
|
||||
<vn-th shrink title="Half box">HB</vn-th>
|
||||
<vn-th shrink>Freight cost</vn-th>
|
||||
<vn-th shrink>Package cost</vn-th>
|
||||
<vn-th shrink>CC</vn-th>
|
||||
<vn-th shrink>Pallet</vn-th>
|
||||
<vn-th shrink>m3</vn-th>
|
||||
<vn-th shrink></vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="entry in $ctrl.entries">
|
||||
<vn-check
|
||||
value="{{entry.isConfirmed}}"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
<vn-td shrink>{{entry.id}} </vn-td>
|
||||
<vn-td shrink>{{entry.supplierName}}</vn-td>
|
||||
<vn-td shrink>{{entry.ref}}</vn-td>
|
||||
<vn-td shrink>{{entry.hb}}</vn-td>
|
||||
<vn-td shrink>{{entry.freightValue}}</vn-td>
|
||||
<vn-td shrink>{{entry.packageValue}}</vn-td>
|
||||
<vn-td shrink>{{entry.cc}}</vn-td>
|
||||
<vn-td shrink>{{entry.pallet}}</vn-td>
|
||||
<vn-td shrink>{{entry.m3}}</vn-td>
|
||||
<vn-td shrink>
|
||||
<vn-icon
|
||||
ng-if="entry.notes.length"
|
||||
vn-tooltip="{{entry.notes}}"
|
||||
icon="insert_drive_file">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
ng-if="entry.notes.length"
|
||||
vn-tooltip="{{entry.evaNotes}}"
|
||||
icon="insert_drive_file">
|
||||
</vn-icon>
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
</vn-auto>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-ticket-descriptor-popover
|
||||
vn-id="ticketDescriptor">
|
||||
</vn-ticket-descriptor-popover>
|
||||
<vn-client-descriptor-popover
|
||||
vn-id="clientDescriptor">
|
||||
</vn-client-descriptor-popover>
|
|
@ -0,0 +1,44 @@
|
|||
import ngModule from '../module';
|
||||
import './style.scss';
|
||||
|
||||
class Controller {
|
||||
constructor($scope, $http) {
|
||||
this.$ = $scope;
|
||||
this.$http = $http;
|
||||
}
|
||||
|
||||
get travel() {
|
||||
return this._travel;
|
||||
}
|
||||
|
||||
set travel(value) {
|
||||
this._travel = value;
|
||||
|
||||
if (value && value.id) {
|
||||
this.getTravel();
|
||||
this.getEntries();
|
||||
}
|
||||
}
|
||||
|
||||
getTravel() {
|
||||
return this.$http.get(`/api/Travels/${this.travel.id}/getTravel`).then(response => {
|
||||
this.travelData = response.data;
|
||||
});
|
||||
}
|
||||
|
||||
getEntries() {
|
||||
return this.$http.get(`/api/Travels/${this.travel.id}/getEntries`).then(response => {
|
||||
this.entries = response.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$http'];
|
||||
|
||||
ngModule.component('vnTravelSummary', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
travel: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,61 @@
|
|||
import './index';
|
||||
|
||||
describe('component vnTravelSummary', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
|
||||
beforeEach(angular.mock.module('travel', $translateProvider => {
|
||||
$translateProvider.translations('en', {});
|
||||
}));
|
||||
|
||||
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
controller = $componentController('vnTravelSummary');
|
||||
}));
|
||||
|
||||
describe('travel setter/getter', () => {
|
||||
it('should return the travel', () => {
|
||||
controller.travel = {id: null};
|
||||
|
||||
expect(controller.travel).toEqual(jasmine.any(Object));
|
||||
});
|
||||
|
||||
it('should return the travel and then call both getTravel() and getEntries()', () => {
|
||||
spyOn(controller, 'getTravel');
|
||||
spyOn(controller, 'getEntries');
|
||||
controller.travel = {id: 99};
|
||||
|
||||
|
||||
expect(controller._travel.id).toEqual(99);
|
||||
expect(controller.getTravel).toHaveBeenCalledWith();
|
||||
expect(controller.getEntries).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getTravel()', () => {
|
||||
it('should perform a get and then store data on the controller', () => {
|
||||
controller._travel = {id: 999};
|
||||
|
||||
const query = `/api/Travels/${controller._travel.id}/getTravel`;
|
||||
$httpBackend.expectGET(query).respond('I am the travelData');
|
||||
controller.getTravel();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.travelData).toEqual('I am the travelData');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getEntries()', () => {
|
||||
it('should call the getEntries method to get the entries data', () => {
|
||||
controller._travel = {id: 999};
|
||||
|
||||
const query = `/api/Travels/${controller._travel.id}/getEntries`;
|
||||
$httpBackend.expectGET(query).respond('I am the entries');
|
||||
controller.getEntries();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.entries).toEqual('I am the entries');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
Reference: Referencia
|
||||
Warehouse In: Almacen entrada
|
||||
Warehouse Out: Almacen salida
|
||||
Shipped: F. envío
|
||||
Landed: F. entrega
|
||||
Total entries: Entradas totales
|
||||
Delivered: Enviada
|
||||
Received: Recibida
|
||||
Agency: Agencia
|
||||
Entries: Entradas
|
||||
Confirmed: Confirmada
|
||||
Entry Id: Entrada Id
|
||||
Supplier: Proveedor
|
||||
Pallet: Pallet
|
||||
Freight cost: Coste porte
|
||||
Package cost: Coste embalaje
|
||||
Half box: Media caja
|
|
@ -0,0 +1,10 @@
|
|||
@import "variables";
|
||||
|
||||
|
||||
vn-travel-summary .summary {
|
||||
max-width: $width-lg;
|
||||
|
||||
vn-icon[icon=insert_drive_file]{
|
||||
color: $color-font-secondary;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue