Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 3047-order_basicdata_valid_agencies

This commit is contained in:
Carlos Jimenez Ruiz 2021-08-31 13:02:24 +02:00
commit 88aada2895
4 changed files with 48 additions and 23 deletions

View File

@ -0,0 +1,33 @@
DROP TRIGGER IF EXISTS vn.ticket_afterUpdate;
DELIMITER $$
$$
CREATE DEFINER=`root`@`%` TRIGGER vn.`ticket_afterUpdate`
AFTER UPDATE ON `ticket`
FOR EACH ROW
BEGIN
IF !(NEW.id <=> OLD.id)
OR !(NEW.warehouseFk <=> OLD.warehouseFk)
OR !(NEW.shipped <=> OLD.shipped) THEN
CALL stock.log_add('ticket', NEW.id, OLD.id);
END IF;
IF !(NEW.clientFk <=> OLD.clientFk)
OR !(NEW.addressFk <=> OLD.addressFk)
OR !(NEW.companyFk <=> OLD.companyFk) THEN
CALL ticket_requestRecalc(NEW.id);
END IF;
IF NEW.clientFk = 2067 AND !(NEW.clientFk <=> OLD.clientFk) THEN
-- Fallo que se insertan no se sabe como tickets en este cliente
INSERT INTO vn.mail SET
`sender` = 'jgallego@verdnatura.es',
`replyTo` = 'jgallego@verdnatura.es',
`subject` = 'Modificado ticket al cliente 2067',
`body` = CONCAT(account.myUserGetName(), ' ha modificado el ticket ',
NEW.id);
END IF;
END$$
DELIMITER ;

View File

@ -195,6 +195,7 @@
"This document already exists on this ticket": "Este documento ya existe en el ticket",
"Some of the selected tickets are not billable": "Algunos de los tickets seleccionados no son facturables",
"You can't invoice tickets from multiple clients": "No puedes facturar tickets de multiples clientes",
"nickname": "nickname",
"INACTIVE_PROVIDER": "Proveedor inactivo",
"This client is not invoiceable": "Este cliente no es facturable",
"serial non editable": "Esta serie no permite asignar la referencia",

View File

@ -18,7 +18,7 @@ module.exports = Self => {
}
});
Self.deleteOrders = async(deletes, options) => {
Self.deleteOrders = async(deletes = [], options) => {
const models = Self.app.models;
let myOptions = {};

View File

@ -167,35 +167,26 @@ module.exports = Self => {
args.option
], myOptions);
if (originalTicket.addressFk != updatedTicket.addressFk) {
const ticketObservation = await models.TicketObservation.findOne({
where: {
ticketFk: args.id,
observationTypeFk: observationTypeDelivery.id}
if (originalTicket.addressFk != updatedTicket.addressFk && args.id) {
await models.TicketObservation.destroyAll({
ticketFk: args.id
}, myOptions);
if (ticketObservation)
await ticketObservation.destroy(myOptions);
const address = await models.Address.findOne({
where: {id: args.addressFk},
include: {
relation: 'observations',
scope: {
where: {observationTypeFk: observationTypeDelivery.id},
include: {
relation: 'observationType'
}
}
relation: 'observations'
}
}, myOptions);
const [observation] = address.observations();
if (observation) {
await models.TicketObservation.create({
ticketFk: args.id,
observationTypeFk: observation.observationTypeFk,
description: observation.description
}, myOptions);
const observations = address.observations();
if (observations.length) {
const clonedObservations = observations.map(observation => {
observation.ticketFk = args.id;
observation.id = undefined;
return observation;
});
await models.TicketObservation.create(clonedObservations, myOptions);
}
}