refs #4764 remake refund, back front
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Satorres 2023-06-09 14:19:17 +02:00
parent a34519f6d0
commit 61d9e2dcd3
3 changed files with 30 additions and 25 deletions

View File

@ -97,7 +97,6 @@ module.exports = Self => {
const [firstTicketId] = ticketsIds;
refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, myOptions);
return refundTicket;
}
if (servicesIds && servicesIds.length > 0) {
@ -130,6 +129,7 @@ module.exports = Self => {
};
async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, myOptions) {
console.log(ticketId, now, refundAgencyMode, refoundZoneId);
const models = Self.app.models;
const filter = {include: {relation: 'address'}};

View File

@ -1,4 +1,4 @@
<vn-crud-model
<vn-crud-model
vn-id="model"
url="TicketServices"
link="{ticketFk: $ctrl.$params.id}"
@ -23,16 +23,16 @@
data="$ctrl.services">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
<vn-card class="vn-pa-lg">
<vn-button-bar>
<vn-submit
disabled="!watcher.dataChanged()"
<vn-button
disabled="!watcher.dataChanged() || !$ctrl.hasSelectedServices()"
label="Pay"
ng-click="$ctrl.createRefund()"
vn-acl="invoicing, claimManager, salesAssistant"
vn-acl-action="remove">
</vn-submit>
</vn-button>
</vn-button-bar>
<vn-horizontal ng-repeat="service in $ctrl.services">
<vn-check tabindex="1"
@ -56,7 +56,7 @@
</vn-autocomplete>
<vn-input-number
vn-one
step="1"
step="1"
label="Quantity"
info="To create services with negative amounts mark the service on the source ticket and press the pay button."
ng-model="service.quantity"
@ -74,7 +74,7 @@
vn-tooltip="Remove service"
icon="delete"
ng-click="model.remove($index)">
</vn-icon-button>
</vn-icon-button>
</vn-auto>
</vn-horizontal>
<vn-icon-button
@ -101,7 +101,7 @@
</form>
<!-- Create service type dialog -->
<vn-dialog class="edit"
<vn-dialog class="edit"
vn-id="newServiceTypeDialog"
on-accept="$ctrl.onNewServiceTypeAccept($data)"
on-close="newServiceType = null"
@ -120,4 +120,4 @@
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Create</button>
</tpl-buttons>
</vn-dialog>
</vn-dialog>

View File

@ -67,23 +67,28 @@ class Controller extends Section {
});
}
hasSelectedServices() {
const selected = this.selectedServices() || [];
return selected.length > 0;
}
createRefund() {
const services = this.selectedValidServices();
if (!services) return;
this.$.model.save()
.then(() => {
const services = this.selectedValidServices();
if (!services) return;
const servicesIds = services.map(service => service.id);
const servicesIds = services.map(service => service.id);
const params = {servicesIds: servicesIds};
const query = 'Sales/refund';
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.sale', {id: refundTicket.id});
this.resetChanges();
});
const params = {servicesIds: servicesIds};
const query = 'Sales/refund';
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.sale', {id: refundTicket.id});
});
});
}
}