fixed update discount
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
parent
8771098045
commit
4aff31a165
|
@ -26,24 +26,20 @@ module.exports = Self => {
|
|||
throw new UserError(`The value should be a number`);
|
||||
|
||||
let model = Self.app.models;
|
||||
let ticket = await model.Ticket.find({
|
||||
where: {
|
||||
id: params.editLines[0].ticketFk
|
||||
},
|
||||
include: [{
|
||||
let ticket = await model.Ticket.findById(params.editLines[0].ticketFk, {
|
||||
include: {
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['salesPersonFk']
|
||||
}
|
||||
}],
|
||||
fields: ['id', 'clientFk', 'refFk']
|
||||
},
|
||||
});
|
||||
|
||||
if (ticket.refFk)
|
||||
throw new UserError(`The sales of this ticket can't be modified`);
|
||||
|
||||
let componentToUse;
|
||||
let usesMana = await model.WorkerMana.findOne({where: {workerFk: ticket[0].client().salesPersonFk}, fields: 'amount'});
|
||||
let usesMana = await model.WorkerMana.findOne({where: {workerFk: ticket.client().salesPersonFk}, fields: 'amount'});
|
||||
|
||||
if (usesMana)
|
||||
componentToUse = 37;
|
||||
|
@ -61,7 +57,7 @@ module.exports = Self => {
|
|||
if (usesMana) {
|
||||
query = `
|
||||
call vn.manaSpellersRequery(?)`;
|
||||
await Self.rawSql(query, [ticket[0].client().salesPersonFk]);
|
||||
await Self.rawSql(query, [ticket.client().salesPersonFk]);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -44,13 +44,14 @@ class Controller {
|
|||
}
|
||||
if (modified) {
|
||||
this.$http.post(`/ticket/api/Sales/updateDiscount`, {editLines}).then(() => {
|
||||
this.onHide();
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
this.clear();
|
||||
modified = false;
|
||||
}).catch(e => {
|
||||
this.vnApp.showError(e.data.error.message);
|
||||
});
|
||||
|
||||
this.onHide();
|
||||
} else
|
||||
this.vnApp.showError(this.$translate.instant('There is no changes to save'));
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@
|
|||
<vn-td number ng-if="!$ctrl.isEditable">
|
||||
{{sale.price | currency: 'EUR':2}}
|
||||
</vn-td>
|
||||
<vn-td number ng-if="$ctrl.isEditable">
|
||||
<vn-td number ng-if="!$ctrl.ticket.refFk">
|
||||
<span class="link"
|
||||
vn-tooltip="Edit discount"
|
||||
ng-click="$ctrl.showEditPopover($event, sale)">
|
||||
|
|
|
@ -14,7 +14,7 @@ class Controller {
|
|||
this.moreOptions = [
|
||||
{callback: this.markAsReserved, name: 'Mark as reserved'},
|
||||
{callback: this.unmarkAsReserved, name: 'Unmark as reserved'},
|
||||
{callback: this.showEditDialog, name: 'Update discount'},
|
||||
{callback: this.showEditDialog, name: 'Update discount', show: () => !this.hasInvoice()},
|
||||
{callback: this.createClaim, name: 'Add claim'},
|
||||
{callback: this.showSMSDialog, name: 'Send SMS'}
|
||||
];
|
||||
|
@ -60,7 +60,13 @@ class Controller {
|
|||
}
|
||||
|
||||
onMoreOpen() {
|
||||
let options = this.moreOptions.filter(o => o.always || this.isChecked);
|
||||
let options = this.moreOptions.filter(option => {
|
||||
const hasShowProperty = Object.hasOwnProperty.call(option, 'show');
|
||||
const shouldShow = !hasShowProperty || option.show === true ||
|
||||
typeof option.show === 'function' && option.show();
|
||||
|
||||
return (shouldShow && (option.always || this.isChecked));
|
||||
});
|
||||
this.$scope.moreButton.data = options;
|
||||
}
|
||||
|
||||
|
@ -337,6 +343,15 @@ class Controller {
|
|||
};
|
||||
this.$scope.sms.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the current ticket
|
||||
* is already invoiced
|
||||
* @return {Boolean} - True if invoiced
|
||||
*/
|
||||
hasInvoice() {
|
||||
return this.ticket.refFk !== null;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate'];
|
||||
|
|
Loading…
Reference in New Issue