#1656 ticket.regularizar eliminar ticket
This commit is contained in:
parent
d93974f481
commit
e1b5b449ce
|
@ -0,0 +1,14 @@
|
|||
DROP TRIGGER IF EXISTS `vn2008`.`ticket_afterUpdate`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` TRIGGER `vn2008`.`ticket_afterUpdate`
|
||||
AFTER UPDATE ON `Tickets`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF !(NEW.Id_Ticket <=> OLD.Id_Ticket)
|
||||
OR !(NEW.warehouse_id <=> OLD.warehouse_id)
|
||||
OR !(NEW.Fecha <=> OLD.Fecha) THEN
|
||||
CALL stock.log_add('ticket', NEW.Id_Ticket, OLD.Id_Ticket);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,8 +1,8 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('delete', {
|
||||
description: 'Sets the isDeleted value of a ticket to 1',
|
||||
Self.remoteMethod('delete', {
|
||||
description: 'Sets true the isDeleted value of a ticket',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'ticketFk',
|
||||
|
@ -21,24 +21,15 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.delete = async(ctx, params) => {
|
||||
const transaction = await Self.beginTransaction({});
|
||||
Self.delete = async params => {
|
||||
try {
|
||||
let claimOfATicket = await Self.app.models.Claim.findOne({where: {ticketFk: params.id}});
|
||||
if (claimOfATicket)
|
||||
throw new UserError('You must delete the claim id %d first', 'DELETE_CLAIM_FIRST', claimOfATicket.id);
|
||||
|
||||
let currentTicket = await Self.app.models.Ticket.findById(params.id);
|
||||
await currentTicket.updateAttributes({isDeleted: true});
|
||||
|
||||
let userId = ctx.req.accessToken.userId;
|
||||
let worker = await Self.app.models.Worker.findOne({where: {userFk: userId}});
|
||||
params.workerFk = worker.id;
|
||||
let state = await Self.app.models.State.findOne({where: {code: 'ERASED'}});
|
||||
|
||||
return await Self.app.models.TicketTracking.create({ticketFk: params.id, stateFk: state.id, workerFk: params.workerFk});
|
||||
return await currentTicket.updateAttributes({isDeleted: true});
|
||||
} catch (e) {
|
||||
await transaction.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -77,11 +77,5 @@
|
|||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-check vn-one
|
||||
label="Deleted"
|
||||
field="$ctrl.ticket.isDeleted">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
</form>
|
||||
|
|
|
@ -66,6 +66,11 @@
|
|||
icon="icon-no036"
|
||||
ng-class="{bright: $ctrl.ticket.client.isTaxDataChecked == false}">
|
||||
</vn-icon>
|
||||
<vn-icon vn-one
|
||||
vn-tooltip="Deleted ticket"
|
||||
icon="warning"
|
||||
ng-class="{bright: $ctrl.ticket.isDeleted == true}">
|
||||
</vn-icon>
|
||||
</div>
|
||||
<div class="quicklinks">
|
||||
<a ng-if="$ctrl.quicklinks.btnOne"
|
||||
|
|
|
@ -127,7 +127,7 @@ class Controller {
|
|||
deleteTicket(response) {
|
||||
if (response === 'ACCEPT') {
|
||||
let params = {id: this.ticket.id};
|
||||
this.$http.post(`/ticket/api/Tickets/delete`, params).then(() => {
|
||||
this.$http.post(`/api/Tickets/delete`, params).then(() => {
|
||||
this.$state.go('ticket.index');
|
||||
this.vnApp.showSuccess(this.$translate.instant('Ticket deleted'));
|
||||
});
|
||||
|
|
|
@ -22,4 +22,5 @@ Are you sure you want to invoice this ticket?: ¿Seguro que quieres facturar est
|
|||
You are going to regenerate the invoice: Vas a regenerar la factura
|
||||
Are you sure you want to regenerate the invoice?: ¿Seguro que quieres regenerar la factura?
|
||||
Invoice sent for a regeneration, will be available in a few minutes: La factura ha sido enviada para ser regenerada, estará disponible en unos minutos
|
||||
Shipped hour updated: Hora de envio modificada
|
||||
Shipped hour updated: Hora de envio modificada
|
||||
Deleted ticket: Ticket eliminado
|
Loading…
Reference in New Issue