2018-11-30 06:57:41 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-18 07:35:59 +00:00
|
|
|
import Section from 'salix/components/section';
|
2019-05-29 11:06:42 +00:00
|
|
|
import UserError from 'core/lib/user-error';
|
2018-11-30 06:57:41 +00:00
|
|
|
|
2020-03-18 07:35:59 +00:00
|
|
|
class Controller extends Section {
|
2019-05-16 12:07:16 +00:00
|
|
|
$onInit() {
|
2020-03-18 07:35:59 +00:00
|
|
|
this.services = [];
|
2019-05-16 12:07:16 +00:00
|
|
|
this.getDefaultTaxClass();
|
|
|
|
}
|
|
|
|
|
|
|
|
getDefaultTaxClass() {
|
2019-11-11 15:32:03 +00:00
|
|
|
let filter = {
|
|
|
|
where: {code: 'G'}
|
|
|
|
};
|
|
|
|
this.$http.get('TaxClasses/findOne', {filter})
|
|
|
|
.then(res => this.defaultTaxClass = res.data);
|
2018-11-30 06:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
add() {
|
2020-03-30 15:30:03 +00:00
|
|
|
this.$.model.insert({
|
|
|
|
taxClassFk: this.defaultTaxClass.id,
|
|
|
|
quantity: 1,
|
|
|
|
ticketFk: this.$params.id
|
|
|
|
});
|
2019-05-16 12:07:16 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 15:30:03 +00:00
|
|
|
onNewServiceTypeClick(service, event) {
|
2019-10-18 19:36:30 +00:00
|
|
|
event.preventDefault();
|
2020-03-30 15:30:03 +00:00
|
|
|
this.$.newServiceType = {};
|
|
|
|
this.$.newServiceTypeDialog.show(service);
|
2019-05-16 12:07:16 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 15:30:03 +00:00
|
|
|
onNewServiceTypeAccept(service) {
|
|
|
|
if (!this.$.newServiceType.name)
|
|
|
|
throw new UserError(`Name can't be empty`);
|
2019-05-16 12:07:16 +00:00
|
|
|
|
2020-03-30 15:30:03 +00:00
|
|
|
return this.$http.post(`TicketServiceTypes`, this.$.newServiceType)
|
2021-01-18 07:55:57 +00:00
|
|
|
.then(res => {
|
|
|
|
this.$.typesModel.refresh();
|
|
|
|
return res;
|
|
|
|
})
|
2020-03-30 15:30:03 +00:00
|
|
|
.then(res => service.ticketServiceTypeFk = res.data.id);
|
2019-05-16 12:07:16 +00:00
|
|
|
}
|
|
|
|
|
2018-11-30 06:57:41 +00:00
|
|
|
onSubmit() {
|
2020-03-18 07:35:59 +00:00
|
|
|
this.$.watcher.check();
|
2019-05-29 11:06:42 +00:00
|
|
|
|
2020-03-30 15:30:03 +00:00
|
|
|
this.$.model.save()
|
|
|
|
.then(() => this.$.model.refresh())
|
|
|
|
.then(() => this.$.watcher.notifySaved());
|
2018-11-30 06:57:41 +00:00
|
|
|
}
|
2023-05-05 08:01:15 +00:00
|
|
|
|
|
|
|
selectedServices() {
|
|
|
|
if (!this.services) return;
|
|
|
|
|
|
|
|
return this.services.filter(service => {
|
|
|
|
return service.checked;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
createRefund() {
|
2023-05-09 12:56:32 +00:00
|
|
|
const services = this.selectedServices();
|
2023-05-05 08:01:15 +00:00
|
|
|
if (!services) return;
|
|
|
|
|
|
|
|
const servicesIds = services.map(service => service.id);
|
|
|
|
|
|
|
|
const params = {servicesIds: servicesIds};
|
2023-05-08 09:36:52 +00:00
|
|
|
const query = 'Tickets/refund';
|
2023-05-05 08:01:15 +00:00
|
|
|
this.$http.post(query, params).then(res => {
|
|
|
|
const refundTicket = res.data;
|
|
|
|
this.vnApp.showSuccess(this.$t('The following refund ticket have been created', {
|
|
|
|
ticketId: refundTicket.id
|
|
|
|
}));
|
|
|
|
this.$state.go('ticket.card.service', {id: refundTicket.id});
|
|
|
|
|
|
|
|
this.resetChanges();
|
|
|
|
});
|
|
|
|
}
|
2018-11-30 06:57:41 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnTicketService', {
|
2018-11-30 06:57:41 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|