refs #5327 ordernar por columnas
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
fcd422eb49
commit
0579c563b9
|
@ -3,13 +3,20 @@ module.exports = Self => {
|
|||
Self.remoteMethod('getSales', {
|
||||
description: 'New filter',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The ticket id',
|
||||
http: {source: 'path'}
|
||||
}],
|
||||
accepts: [
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The ticket id',
|
||||
http: {source: 'path'}
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
|
@ -20,14 +27,24 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.getSales = async(id, options) => {
|
||||
Self.getSales = async(filter, id, options) => {
|
||||
const models = Self.app.models;
|
||||
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
// let newFilter;
|
||||
// if (filter && filter.order) {
|
||||
// const filterOrder = filter.order;
|
||||
// const saleColumns = ['itemFk', 'quantity', 'concept', 'price', 'discount'];
|
||||
|
||||
// for (const saleColum of saleColumns) {
|
||||
// if (filterOrder.includes(saleColum)) return newFilter = filter.order;
|
||||
// else newFilter = 'concept';
|
||||
// }
|
||||
// }
|
||||
// console.log(newFilter);
|
||||
const sales = await models.Sale.find({
|
||||
include: {
|
||||
relation: 'item',
|
||||
|
@ -53,7 +70,7 @@ module.exports = Self => {
|
|||
}
|
||||
},
|
||||
where: {ticketFk: id},
|
||||
order: 'concept'
|
||||
order: newFilter
|
||||
}, myOptions);
|
||||
|
||||
// Get items available
|
||||
|
|
|
@ -60,15 +60,15 @@
|
|||
</vn-th>
|
||||
<vn-th shrink></vn-th>
|
||||
<vn-th shrink></vn-th>
|
||||
<vn-th shrink>Visible</vn-th>
|
||||
<vn-th shrink>Available</vn-th>
|
||||
<vn-th>Id</vn-th>
|
||||
<vn-th shrink>Quantity</vn-th>
|
||||
<vn-th expand>Item</vn-th>
|
||||
<vn-th number>Price</vn-th>
|
||||
<vn-th number>Disc</vn-th>
|
||||
<vn-th number>Amount</vn-th>
|
||||
<vn-th shrink>Packaging</vn-th>
|
||||
<vn-th field="visible" shrink>Visible</vn-th>
|
||||
<vn-th field="available" shrink>Available</vn-th>
|
||||
<vn-th field="itemFk">Id</vn-th>
|
||||
<vn-th field="quantity" shrink>Quantity</vn-th>
|
||||
<vn-th field="concept" expand>Item</vn-th>
|
||||
<vn-th field="price" number>Price</vn-th>
|
||||
<vn-th field="discount" number>Disc</vn-th>
|
||||
<vn-th field="amount" number>Amount</vn-th>
|
||||
<vn-th field="itemPackingTypeFk" shrink>Packaging</vn-th>
|
||||
<vn-th shrink></vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
|
|
Loading…
Reference in New Issue