From 3dd0c79629d6fd1958d64fe4d168659cc72f011b Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 27 Dec 2022 15:00:49 +0100 Subject: [PATCH] feat: add ItemShelvingSales/filter --- .../back/methods/item-shelving-sale/filter.js | 48 +++++++++++++++++++ .../item/back/models/item-shelving-sale.js | 3 ++ modules/ticket/front/sale-checked/index.html | 21 ++++---- modules/ticket/front/sale-checked/index.js | 21 -------- 4 files changed, 62 insertions(+), 31 deletions(-) create mode 100644 modules/item/back/methods/item-shelving-sale/filter.js create mode 100644 modules/item/back/models/item-shelving-sale.js diff --git a/modules/item/back/methods/item-shelving-sale/filter.js b/modules/item/back/methods/item-shelving-sale/filter.js new file mode 100644 index 000000000..a91ae7c86 --- /dev/null +++ b/modules/item/back/methods/item-shelving-sale/filter.js @@ -0,0 +1,48 @@ + +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +module.exports = Self => { + Self.remoteMethod('filter', { + description: 'Returns all ticket sale trackings', + accessType: 'READ', + accepts: [{ + arg: 'filter', + type: 'object', + description: 'Filter defining where and paginated data' + }], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/filter`, + verb: 'GET' + } + }); + + Self.filter = async(filter, options) => { + const conn = Self.dataSource.connector; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const stmt = new ParameterizedSQL(` + SELECT iss.created, + iss.saleFk, + iss.quantity, + ish.shelvingFk, + p.code, + u.name + FROM itemShelvingSale iss + LEFT JOIN itemShelving ish ON iss.itemShelvingFk = ish.id + LEFT JOIN shelving s ON ish.shelvingFk = s.code + LEFT JOIN parking p ON s.parkingFk = p.id + LEFT JOIN account.user u ON u.id = iss.userFk` + ); + + stmt.merge(conn.makeSuffix(filter)); + + return conn.executeStmt(stmt); + }; +}; diff --git a/modules/item/back/models/item-shelving-sale.js b/modules/item/back/models/item-shelving-sale.js new file mode 100644 index 000000000..b89be9f00 --- /dev/null +++ b/modules/item/back/models/item-shelving-sale.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/item-shelving-sale/filter')(Self); +}; diff --git a/modules/ticket/front/sale-checked/index.html b/modules/ticket/front/sale-checked/index.html index 3e1d3d2d0..2a7b53a8f 100644 --- a/modules/ticket/front/sale-checked/index.html +++ b/modules/ticket/front/sale-checked/index.html @@ -128,8 +128,7 @@ Quantity - Worker + Worker Shelving Parking Created @@ -150,19 +149,21 @@ {{::itemShelvingSale.quantity}} - {{::itemShelvingSale.userFk}} - {{::itemShelvingSale.itemShelving.shelvingFk}} - {{::itemShelvingSale.itemShelving.shelving.parking.code}} + + + {{::itemShelvingSale.name | dashIfEmpty}} + + + {{::itemShelvingSale.shelvingFk}} + {{::itemShelvingSale.code}} {{::itemShelvingSale.created | date: 'dd/MM/yyyy HH:mm'}} - - diff --git a/modules/ticket/front/sale-checked/index.js b/modules/ticket/front/sale-checked/index.js index 04196c313..382225ad8 100644 --- a/modules/ticket/front/sale-checked/index.js +++ b/modules/ticket/front/sale-checked/index.js @@ -17,27 +17,6 @@ class Controller extends Section { } ] }; - - this.filterItemShelvingSale = { - include: { - relation: 'itemShelving', - scope: { - fields: ['shelvingFk'], - include: { - relation: 'shelving', - scope: { - fields: ['parkingFk'], - include: { - relation: 'parking', - scope: { - fields: ['id', 'code'] - } - } - } - } - } - } - }; } $onInit() {