dev #1731
|
@ -31,23 +31,25 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
// const [itemShelvingSale] = await models.ItemShelvingSale.find({saleFk: saleFk}, myOptions);
|
||||
// if (itemShelvingSale) await itemShelvingSale.destroy(myOptions);
|
||||
const itemShelvingSales = await models.ItemShelvingSale.find({saleFk: saleFk}, myOptions);
|
||||
for (let itemShelvingSale of itemShelvingSales)
|
||||
await itemShelvingSale.destroy(myOptions);
|
||||
|
||||
// const filter = {
|
||||
// where: {
|
||||
// saleFk: saleFk,
|
||||
// code: stateCode
|
||||
// }
|
||||
// };
|
||||
// const [saleTracking] = await models.SaleTracking.find(filter, myOptions);
|
||||
// return saleTracking.destroy(myOptions);
|
||||
const filter = {
|
||||
where: {
|
||||
saleFk: saleFk,
|
||||
code: stateCode
|
||||
}
|
||||
};
|
||||
const saleTrackings = await models.SaleTracking.find(filter, myOptions);
|
||||
for (let saleTracking of saleTrackings)
|
||||
await saleTracking.destroy(myOptions);
|
||||
|
||||
query = `CALL vn.saleTracking_del(?, ?)`;
|
||||
return Self.rawSql(query,
|
||||
[
|
||||
saleFk,
|
||||
stateCode,
|
||||
], myOptions);
|
||||
// query = `CALL vn.saleTracking_del(?, ?)`;
|
||||
// return Self.rawSql(query,
|
||||
// [
|
||||
// saleFk,
|
||||
// stateCode,
|
||||
// ], myOptions);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -40,30 +40,31 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
// const state = await models.State.findOne({
|
||||
// where: {code: stateCode}
|
||||
// }, myOptions);
|
||||
const state = await models.State.findOne({
|
||||
where: {code: stateCode}
|
||||
}, myOptions);
|
||||
|
||||
// if (!state) return;
|
||||
if (!state) return;
|
||||
|
||||
// const data = {
|
||||
// saleFk: saleFk,
|
||||
// isChecked: isChecked,
|
||||
// originalQuantity: quantity,
|
||||
// workerFk: userId,
|
||||
// stateFk: state.id
|
||||
// };
|
||||
// return models.SaleTracking.replaceOrCreate(data, myOptions);
|
||||
const data = {
|
||||
saleFk: saleFk,
|
||||
isChecked: isChecked,
|
||||
originalQuantity: quantity,
|
||||
workerFk: userId,
|
||||
stateFk: state.id
|
||||
};
|
||||
return models.SaleTracking.replaceOrCreate(data, myOptions);
|
||||
|
||||
query = `CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?)`;
|
||||
return Self.rawSql(query,
|
||||
[
|
||||
saleFk,
|
||||
isChecked,
|
||||
quantity,
|
||||
userId,
|
||||
stateCode,
|
||||
null
|
||||
], myOptions);
|
||||
// query = `CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?, ?)`;
|
||||
// return Self.rawSql(query,
|
||||
// [
|
||||
// saleFk,
|
||||
// isChecked,
|
||||
// quantity,
|
||||
// userId,
|
||||
// stateCode,
|
||||
// 'parameterToDelete',
|
||||
// null
|
||||
// ], myOptions);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('salePreparingList', {
|
||||
description: 'Returns a list with the lines of a ticket and its different states of preparation',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The ticket id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
description: 'Filter defining where and paginated data'
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/salePreparingList`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.salePreparingList = async(id, filter, options) => {
|
||||
const conn = Self.dataSource.connector;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const stmts = [];
|
||||
let stmt;
|
||||
|
||||
stmts.push('CALL cache.last_buy_refresh(FALSE)');
|
||||
|
||||
stmt = new ParameterizedSQL(
|
||||
`SELECT t.clientFk,
|
||||
t.shipped,
|
||||
a.nickname,
|
||||
s.ticketFk,
|
||||
s.itemFk,
|
||||
s.quantity,
|
||||
s.concept,
|
||||
s.reserved,
|
||||
s.id saleFk,
|
||||
i.size,
|
||||
i.inkFk,
|
||||
i.stems,
|
||||
i.image,
|
||||
i.subName,
|
||||
b.grouping,
|
||||
IF(stPrevious.saleFk,TRUE,FALSE) as isPreviousSelected,
|
||||
stPrevious.isChecked as isPrevious,
|
||||
stPrepared.isChecked as isPrepared,
|
||||
stControled.isChecked as isControled,
|
||||
ib.code as barcode,
|
||||
(MAX(sgd.id) IS NOT NULL) AS hasSaleGroupDetail,
|
||||
p.code AS parkingCode,
|
||||
i.value5,
|
||||
i.value6,
|
||||
i.value7,
|
||||
i.value8,
|
||||
i.value9,
|
||||
i.value10
|
||||
FROM vn.ticket t
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = t.warehouseFk
|
||||
LEFT JOIN vn.buy b ON b.id = lb.buy_id
|
||||
LEFT JOIN vn.saleTracking stPrevious ON stPrevious.saleFk = s.id AND stPrevious.stateFk = 26
|
||||
LEFT JOIN vn.saleTracking stPrepared ON stPrepared.saleFk = s.id AND stPrepared.stateFk = 14
|
||||
LEFT JOIN vn.saleTracking stControled ON stControled.saleFk = s.id AND stControled.stateFk = 8
|
||||
LEFT JOIN vn.itemBarcode ib ON ib.itemFk = i.id
|
||||
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
|
||||
LEFT JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk
|
||||
LEFT JOIN vn.parking p ON p.id = sg.parkingFk
|
||||
WHERE t.id = ?
|
||||
GROUP BY s.id`, [id]);
|
||||
|
||||
stmts.push(stmt);
|
||||
|
||||
stmt.merge(Self.makeSuffix(filter));
|
||||
|
||||
const index = stmts.push(stmt) - 1;
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
const result = await conn.executeStmt(sql, myOptions);
|
||||
|
||||
return result[index];
|
||||
};
|
||||
};
|
|
@ -1,33 +0,0 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('salePreparingList', {
|
||||
description: 'Returns a list with the lines of a ticket and its different states of preparation',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The ticket id',
|
||||
http: {source: 'path'}
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/salePreparingList`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.salePreparingList = async(ctx, id, options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
query = `CALL vn.salePreparingList(?)`;
|
||||
const [sales] = await Self.rawSql(query, [id], myOptions);
|
||||
|
||||
return sales;
|
||||
};
|
||||
};
|
|
@ -1,4 +1,5 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/sale-tracking/salePreparingList')(Self);
|
||||
require('../methods/sale-tracking/listSaleTracking')(Self);
|
||||
require('../methods/sale-tracking/replace')(Self);
|
||||
require('../methods/sale-tracking/delete')(Self);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/sale/getClaimableFromTicket')(Self);
|
||||
require('../methods/sale/salePreparingList')(Self);
|
||||
require('../methods/sale/reserve')(Self);
|
||||
require('../methods/sale/deleteSales')(Self);
|
||||
require('../methods/sale/updatePrice')(Self);
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Sales"
|
||||
filter="::$ctrl.filter"
|
||||
link="{ticketFk: $ctrl.$params.id}"
|
||||
url="SaleTrackings/{{$ctrl.$params.id}}/salePreparingList"
|
||||
limit="20"
|
||||
data="$ctrl.sales"
|
||||
order="concept ASC"
|
||||
|
@ -26,8 +24,8 @@
|
|||
<vn-td center>
|
||||
<vn-chip
|
||||
ng-class="{
|
||||
'pink': sale.preparingList.hasSaleGroupDetail,
|
||||
'none': !sale.preparingList.hasSaleGroupDetail,
|
||||
'pink': sale.hasSaleGroupDetail,
|
||||
'none': !sale.hasSaleGroupDetail,
|
||||
}"
|
||||
class="circleState"
|
||||
vn-tooltip="has saleGroupDetail"
|
||||
|
@ -35,8 +33,8 @@
|
|||
</vn-chip>
|
||||
<vn-chip
|
||||
ng-class="{
|
||||
'notice': sale.preparingList.isPreviousSelected,
|
||||
'none': !sale.preparingList.isPreviousSelected,
|
||||
'notice': sale.isPreviousSelected,
|
||||
'none': !sale.isPreviousSelected,
|
||||
}"
|
||||
class="circleState"
|
||||
vn-tooltip="is previousSelected"
|
||||
|
@ -44,24 +42,24 @@
|
|||
</vn-chip>
|
||||
<vn-chip
|
||||
ng-class="{
|
||||
'dark-notice': sale.preparingList.isPrevious,
|
||||
'none': !sale.preparingList.isPrevious,
|
||||
'dark-notice': sale.isPrevious,
|
||||
'none': !sale.isPrevious,
|
||||
}"
|
||||
class="circleState"
|
||||
vn-tooltip="is previous">
|
||||
</vn-chip>
|
||||
<vn-chip
|
||||
ng-class="{
|
||||
'warning': sale.preparingList.isPrepared,
|
||||
'none': !sale.preparingList.isPrepared,
|
||||
'warning': sale.isPrepared,
|
||||
'none': !sale.isPrepared,
|
||||
}"
|
||||
class="circleState"
|
||||
vn-tooltip="is prepared">
|
||||
</vn-chip>
|
||||
<vn-chip
|
||||
ng-class="{
|
||||
'yellow': sale.preparingList.isControled,
|
||||
'none': !sale.preparingList.isControled,
|
||||
'yellow': sale.isControled,
|
||||
'none': !sale.isControled,
|
||||
}"
|
||||
class="circleState"
|
||||
vn-tooltip="is controled">
|
||||
|
@ -69,26 +67,26 @@
|
|||
</vn-td>
|
||||
<vn-td number>
|
||||
<span
|
||||
ng-click="itemDescriptor.show($event, sale.item.id)"
|
||||
ng-click="itemDescriptor.show($event, sale.itemFk)"
|
||||
class="link">
|
||||
{{::sale.item.id}}
|
||||
{{::sale.itemFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td vn-fetched-tags>
|
||||
<div>
|
||||
<vn-one title="{{::sale.item.name}}">{{::sale.item.name}}</vn-one>
|
||||
<vn-one ng-if="::sale.item.subName">
|
||||
<h3 title="{{::sale.item.subName}}">{{::sale.item.subName}}</h3>
|
||||
<vn-one title="{{::sale.concept}}">{{::sale.concept}}</vn-one>
|
||||
<vn-one ng-if="::sale.subName">
|
||||
<h3 title="{{::sale.subName}}">{{::sale.subName}}</h3>
|
||||
</vn-one>
|
||||
</div>
|
||||
<vn-fetched-tags
|
||||
max-length="6"
|
||||
item="::sale.item"
|
||||
item="::sale"
|
||||
tabindex="-1">
|
||||
</vn-fetched-tags>
|
||||
</vn-td>
|
||||
<vn-td number>{{::sale.quantity}}</vn-td>
|
||||
<vn-td center>{{::sale.saleGroupDetail.saleGroup.parking.code | dashIfEmpty}}</vn-td>
|
||||
<vn-td center>{{::sale.parkingCode | dashIfEmpty}}</vn-td>
|
||||
<vn-td actions>
|
||||
<vn-icon-button
|
||||
vn-click-stop="$ctrl.showSaleTracking(sale)"
|
||||
|
|
|
@ -38,24 +38,6 @@ class Controller extends Section {
|
|||
};
|
||||
}
|
||||
|
||||
get sales() {
|
||||
return this._sales;
|
||||
}
|
||||
|
||||
set sales(value) {
|
||||
this._sales = value;
|
||||
if (value) {
|
||||
const query = `Sales/${this.$params.id}/salePreparingList`;
|
||||
this.$http.get(query)
|
||||
.then(res => {
|
||||
res.data.forEach(salePreparing => {
|
||||
const sale = this.sales.find(sale => salePreparing.saleFk === sale.id);
|
||||
if (sale) sale.preparingList = salePreparing;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
showItemDescriptor(event, sale) {
|
||||
this.quicklinks = {
|
||||
btnThree: {
|
||||
|
@ -72,29 +54,29 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
showSaleTracking(sale) {
|
||||
this.saleId = sale.id;
|
||||
this.saleId = sale.saleFk;
|
||||
this.$.saleTracking.show();
|
||||
}
|
||||
|
||||
showItemShelvingSale(sale) {
|
||||
this.saleId = sale.id;
|
||||
this.saleId = sale.saleFk;
|
||||
this.$.itemShelvingSale.show();
|
||||
}
|
||||
|
||||
clickPreviousSelected(index) {
|
||||
const sale = this.sales[index];
|
||||
if (!sale.preparingList.isPreviousSelected) {
|
||||
if (!sale.isPreviousSelected) {
|
||||
this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false);
|
||||
sale.preparingList.isPreviousSelected = true;
|
||||
sale.isPreviousSelected = true;
|
||||
} else {
|
||||
this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION');
|
||||
sale.preparingList.isPreviousSelected = false;
|
||||
sale.isPreviousSelected = false;
|
||||
}
|
||||
}
|
||||
|
||||
saleTrackingNew(sale, stateCode, isChecked) {
|
||||
const params = {
|
||||
saleFk: sale.id,
|
||||
saleFk: sale.saleFk,
|
||||
isChecked: isChecked,
|
||||
quantity: sale.quantity,
|
||||
stateCode: stateCode
|
||||
|
@ -106,7 +88,7 @@ class Controller extends Section {
|
|||
|
||||
saleTrackingDel(sale, stateCode) {
|
||||
const params = {
|
||||
saleFk: sale.id,
|
||||
saleFk: sale.saleFk,
|
||||
stateCode: stateCode
|
||||
};
|
||||
this.$http.post(`SaleTrackings/delete`, params).then(() => {
|
||||
|
|
Loading…
Reference in New Issue