Sale tracking get state from saleTracking instead of ticket. #695
This commit is contained in:
parent
12824b1564
commit
1e604d92b4
|
@ -15,9 +15,9 @@
|
|||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th></vn-th>
|
||||
<vn-th field="id" default-order="DESC">Id</vn-th>
|
||||
<vn-th field="id">Id</vn-th>
|
||||
<vn-th field="amount" number>Amount</vn-th>
|
||||
<vn-th field="created">Payed</vn-th>
|
||||
<vn-th field="created" default-order="DESC">Payed</vn-th>
|
||||
<vn-th></vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
filter="{}"
|
||||
link="{ticketFk: $ctrl.$stateParams.id}"
|
||||
limit="20"
|
||||
data="sales"
|
||||
on-data-change="$ctrl.getTags()">
|
||||
data="sales">
|
||||
</vn-crud-model>
|
||||
<vn-vertical>
|
||||
<vn-card pad-large>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
|
||||
const ParameterizedSQL = require('vn-loopback/node_modules/loopback-connector').ParameterizedSQL;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('listSaleTracking', {
|
||||
description: 'Returns all ticket sale trackings',
|
||||
|
@ -20,24 +23,10 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.listSaleTracking = async filter => {
|
||||
let where = '';
|
||||
let limit = '';
|
||||
let order = '';
|
||||
let params;
|
||||
|
||||
if (filter) {
|
||||
let connector = Self.dataSource.connector;
|
||||
if (filter.where) {
|
||||
where = 'WHERE s.ticketFk = ?';
|
||||
params = [filter.where.ticketFk];
|
||||
}
|
||||
|
||||
limit = connector._buildLimit(null, filter.limit, filter.skip);
|
||||
order = connector.buildOrderBy('Item', filter.order);
|
||||
}
|
||||
|
||||
let query = `SELECT
|
||||
let stmt = new ParameterizedSQL(`
|
||||
SELECT
|
||||
st.id,
|
||||
s.ticketFk,
|
||||
s.quantity,
|
||||
s.concept,
|
||||
s.itemFk,
|
||||
|
@ -48,12 +37,13 @@ module.exports = Self => {
|
|||
w.name,
|
||||
ste.name AS state
|
||||
FROM saleTracking st
|
||||
JOIN sale s ON s.id = st.saleFK
|
||||
JOIN sale s ON s.id = st.saleFk
|
||||
JOIN worker w ON w.id = st.workerFk
|
||||
JOIN ticketState ts ON ts.ticketFk = s.ticketFk
|
||||
JOIN state ste ON ste.id = ts.stateFK ${where} ${order} ${limit}`;
|
||||
JOIN state ste ON ste.id = st.stateFk`);
|
||||
|
||||
let trackings = await Self.rawSql(query, params);
|
||||
stmt.merge(Self.buildSuffix(filter));
|
||||
|
||||
let trackings = await Self.rawStmt(stmt);
|
||||
|
||||
let salesFilter = {
|
||||
include: [
|
||||
|
|
Loading…
Reference in New Issue