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-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-th></vn-th>
|
<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="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-th></vn-th>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
filter="{}"
|
filter="{}"
|
||||||
link="{ticketFk: $ctrl.$stateParams.id}"
|
link="{ticketFk: $ctrl.$stateParams.id}"
|
||||||
limit="20"
|
limit="20"
|
||||||
data="sales"
|
data="sales">
|
||||||
on-data-change="$ctrl.getTags()">
|
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-card pad-large>
|
<vn-card pad-large>
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
|
||||||
|
const ParameterizedSQL = require('vn-loopback/node_modules/loopback-connector').ParameterizedSQL;
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('listSaleTracking', {
|
Self.remoteMethod('listSaleTracking', {
|
||||||
description: 'Returns all ticket sale trackings',
|
description: 'Returns all ticket sale trackings',
|
||||||
|
@ -20,40 +23,27 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.listSaleTracking = async filter => {
|
Self.listSaleTracking = async filter => {
|
||||||
let where = '';
|
let stmt = new ParameterizedSQL(`
|
||||||
let limit = '';
|
SELECT
|
||||||
let order = '';
|
st.id,
|
||||||
let params;
|
s.ticketFk,
|
||||||
|
s.quantity,
|
||||||
|
s.concept,
|
||||||
|
s.itemFk,
|
||||||
|
st.originalQuantity,
|
||||||
|
st.created,
|
||||||
|
st.workerFk,
|
||||||
|
w.firstName,
|
||||||
|
w.name,
|
||||||
|
ste.name AS state
|
||||||
|
FROM saleTracking st
|
||||||
|
JOIN sale s ON s.id = st.saleFk
|
||||||
|
JOIN worker w ON w.id = st.workerFk
|
||||||
|
JOIN state ste ON ste.id = st.stateFk`);
|
||||||
|
|
||||||
if (filter) {
|
stmt.merge(Self.buildSuffix(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);
|
let trackings = await Self.rawStmt(stmt);
|
||||||
order = connector.buildOrderBy('Item', filter.order);
|
|
||||||
}
|
|
||||||
|
|
||||||
let query = `SELECT
|
|
||||||
st.id,
|
|
||||||
s.quantity,
|
|
||||||
s.concept,
|
|
||||||
s.itemFk,
|
|
||||||
st.originalQuantity,
|
|
||||||
st.created,
|
|
||||||
st.workerFk,
|
|
||||||
w.firstName,
|
|
||||||
w.name,
|
|
||||||
ste.name AS state
|
|
||||||
FROM saleTracking st
|
|
||||||
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}`;
|
|
||||||
|
|
||||||
let trackings = await Self.rawSql(query, params);
|
|
||||||
|
|
||||||
let salesFilter = {
|
let salesFilter = {
|
||||||
include: [
|
include: [
|
||||||
|
|
Loading…
Reference in New Issue