dev #1731

Merged
jgallego merged 105 commits from dev into test 2023-08-31 09:13:29 +00:00
5 changed files with 200 additions and 40 deletions
Showing only changes of commit 0d85069e0f - Show all commits

View File

@ -0,0 +1,53 @@
module.exports = Self => {
Self.remoteMethod('delete', {
description: 'Elimina el registro (si se cumple la condición) y inserta uno nuevo',
accessType: 'READ',
accepts: [
{
arg: 'saleFk',
type: 'number',
description: 'The sale id'
},
{
arg: 'stateCode',
type: 'string'
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: `/delete`,
verb: 'POST'
}
});
Self.delete = async(saleFk, stateCode, options) => {
const models = Self.app.models;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
// const [itemShelvingSale] = await models.ItemShelvingSale.find({saleFk: saleFk}, myOptions);
// if (itemShelvingSale) await itemShelvingSale.destroy(myOptions);
// const filter = {
// where: {
// saleFk: saleFk,
// code: stateCode
// }
// };
// const [saleTracking] = await models.SaleTracking.find(filter, myOptions);
// return saleTracking.destroy(myOptions);
query = `CALL vn.saleTracking_del(?, ?)`;
return Self.rawSql(query,
[
saleFk,
stateCode,
], myOptions);
};
};

View File

@ -0,0 +1,69 @@
module.exports = Self => {
Self.remoteMethodCtx('replace', {
description: 'Remplaza el registro o lo crea si no existe',
accessType: 'READ',
accepts: [
{
arg: 'saleFk',
type: 'number',
description: 'The sale id'
},
{
arg: 'isChecked',
type: 'boolean'
},
{
arg: 'quantity',
type: 'number'
},
{
arg: 'stateCode',
type: 'string'
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: `/replace`,
verb: 'POST'
}
});
Self.replace = async(ctx, saleFk, isChecked, quantity, stateCode, options) => {
const models = Self.app.models;
const myOptions = {};
const userId = ctx.req.accessToken.userId;
if (typeof options == 'object')
Object.assign(myOptions, options);
// const state = await models.State.findOne({
// where: {code: stateCode}
// }, myOptions);
// if (!state) return;
// 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);
};
};

View File

@ -1,3 +1,5 @@
module.exports = Self => {
require('../methods/sale-tracking/listSaleTracking')(Self);
require('../methods/sale-tracking/replace')(Self);
require('../methods/sale-tracking/delete')(Self);
};

View File

@ -1,6 +1,6 @@
<vn-crud-model
vn-id="model"
url="sales"
url="Sales"
filter="::$ctrl.filter"
link="{ticketFk: $ctrl.$params.id}"
limit="20"
@ -25,43 +25,48 @@
<vn-tr ng-repeat="sale in $ctrl.sales">
<vn-td center>
<vn-chip
ng-class="::{
'pink': sale.preparingList.hasSaleGroupDetail,
'none': !sale.preparingList.hasSaleGroupDetail,
}"
class="circleState"
vn-tooltip="has saleGroupDetail"
ng-class="{
'pink': sale.preparingList.hasSaleGroupDetail,
'none': !sale.preparingList.hasSaleGroupDetail,
}"
class="circleState"
vn-tooltip="has saleGroupDetail"
>
</vn-chip>
<vn-chip ng-class="::{
'notice': sale.preparingList.isPreviousSelected,
'none': !sale.preparingList.isPreviousSelected,
}"
class="circleState"
vn-tooltip="is previousSelected">
<vn-chip
ng-class="{
'notice': sale.preparingList.isPreviousSelected,
'none': !sale.preparingList.isPreviousSelected,
}"
class="circleState"
vn-tooltip="is previousSelected"
vn-click-stop="$ctrl.clickPreviousSelected($index)">
</vn-chip>
<vn-chip ng-class="::{
'dark-notice': sale.preparingList.isPrevious,
'none': !sale.preparingList.isPrevious,
}"
class="circleState"
vn-tooltip="is previous">
<vn-chip
ng-class="{
'dark-notice': sale.preparingList.isPrevious,
'none': !sale.preparingList.isPrevious,
}"
class="circleState"
vn-tooltip="is previous">
</vn-chip>
<vn-chip ng-class="::{
'warning': sale.preparingList.isPrepared,
'none': !sale.preparingList.isPrepared,
}"
class="circleState"
vn-tooltip="is prepared">
<vn-chip
ng-class="{
'warning': sale.preparingList.isPrepared,
'none': !sale.preparingList.isPrepared,
}"
class="circleState"
vn-tooltip="is prepared">
</vn-chip>
<vn-chip ng-class="::{
'yellow': sale.preparingList.isControled,
'none': !sale.preparingList.isControled,
}"
class="circleState"
vn-tooltip="is controled">
<vn-chip
ng-class="{
'yellow': sale.preparingList.isControled,
'none': !sale.preparingList.isControled,
}"
class="circleState"
vn-tooltip="is controled">
</vn-chip>
</vn-td>
</vn-td>
<vn-td number>
<span
ng-click="itemDescriptor.show($event, sale.item.id)"

View File

@ -48,13 +48,10 @@ class Controller extends Section {
const query = `Sales/${this.$params.id}/salePreparingList`;
this.$http.get(query)
.then(res => {
this.salePreparingList = res.data;
for (const salePreparing of this.salePreparingList) {
for (const sale of this.sales) {
if (salePreparing.saleFk == sale.id)
sale.preparingList = salePreparing;
}
}
res.data.forEach(salePreparing => {
const sale = this.sales.find(sale => salePreparing.saleFk === sale.id);
if (sale) sale.preparingList = salePreparing;
});
});
}
}
@ -83,12 +80,46 @@ class Controller extends Section {
this.saleId = sale.id;
this.$.itemShelvingSale.show();
}
clickPreviousSelected(index) {
const sale = this.sales[index];
if (!sale.preparingList.isPreviousSelected) {
this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false);
sale.preparingList.isPreviousSelected = true;
} else {
this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION');
sale.preparingList.isPreviousSelected = false;
}
}
saleTrackingNew(sale, stateCode, isChecked) {
const params = {
saleFk: sale.id,
isChecked: isChecked,
quantity: sale.quantity,
stateCode: stateCode
};
this.$http.post(`SaleTrackings/replace`, params).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
saleTrackingDel(sale, stateCode) {
const params = {
saleFk: sale.id,
stateCode: stateCode
};
this.$http.post(`SaleTrackings/delete`, params).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
}
ngModule.vnComponent('vnTicketSaleTracking', {
template: require('./index.html'),
controller: Controller,
bindings: {
ticket: '<'
ticket: '<',
model: '<?'
}
});