refs #5669 fix: permite ordenar por 'Encajado'
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
69e998ced5
commit
87351a9f5b
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
|
||||
VALUES
|
||||
('Ticket','volume','READ','ALLOW','employee');
|
|
@ -0,0 +1,11 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
fdescribe('ticket volume()', () => {
|
||||
it('should return the tickets matching the filter', async() => {
|
||||
const ticketId = 1;
|
||||
const filter = {order: ['concept']};
|
||||
const result = await models.Ticket.volume(ticketId, filter);
|
||||
|
||||
expect(result.length).toBe(4);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,63 @@
|
|||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('volume', {
|
||||
description: 'Return the volume of a ticket',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The ticket id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object'
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: '/:id/volume',
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.volume = async(id, filter) => {
|
||||
const conn = Self.dataSource.connector;
|
||||
|
||||
const stmt = new ParameterizedSQL(
|
||||
`SELECT
|
||||
s.id,
|
||||
s.itemFk,
|
||||
s.quantity,
|
||||
i.name,
|
||||
i.subName,
|
||||
i.itemPackingTypeFk,
|
||||
i.value5,
|
||||
i.value6,
|
||||
i.value7,
|
||||
i.value8,
|
||||
i.value9,
|
||||
i.value10
|
||||
FROM vn.sale s
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
WHERE s.ticketFk = ?`
|
||||
, [id]
|
||||
);
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
||||
const result = await conn.executeStmt(stmt);
|
||||
|
||||
const outputArray = result.map(({name, subName, itemPackingTypeFk, ...rest}) => ({
|
||||
...rest,
|
||||
item: {name, subName, itemPackingTypeFk},
|
||||
}));
|
||||
|
||||
return outputArray;
|
||||
};
|
||||
};
|
|
@ -42,4 +42,5 @@ module.exports = function(Self) {
|
|||
require('../methods/ticket/expeditionPalletLabel')(Self);
|
||||
require('../methods/ticket/saveSign')(Self);
|
||||
require('../methods/ticket/invoiceTickets')(Self);
|
||||
require('../methods/ticket/volume')(Self);
|
||||
};
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<vn-crud-model
|
||||
auto-load="true"
|
||||
vn-id="model"
|
||||
url="sales"
|
||||
filter="::$ctrl.filter"
|
||||
link="{ticketFk: $ctrl.$params.id}"
|
||||
url="Tickets/{{$ctrl.$params.id}}/volume"
|
||||
data="$ctrl.sales"
|
||||
order="concept"
|
||||
limit="20">
|
||||
</vn-crud-model>
|
||||
<vn-vertical>
|
||||
|
|
|
@ -4,12 +4,6 @@ import Section from 'salix/components/section';
|
|||
class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.filter = {
|
||||
include: {
|
||||
relation: 'item'
|
||||
},
|
||||
order: 'concept'
|
||||
};
|
||||
|
||||
this.ticketVolumes = [];
|
||||
}
|
||||
|
@ -25,8 +19,7 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
applyVolumes() {
|
||||
const ticket = this.sales[0].ticketFk;
|
||||
this.$http.get(`Tickets/${ticket}/getVolume`).then(res => {
|
||||
this.$http.get(`Tickets/${this.$params.id}/getVolume`).then(res => {
|
||||
const saleVolume = res.data.saleVolume;
|
||||
|
||||
const volumes = new Map();
|
||||
|
|
Loading…
Reference in New Issue