feat: refs #6629 refs # 6629 updateAddress

This commit is contained in:
Robert Ferrús 2024-11-27 13:08:14 +01:00
parent e62553630c
commit 01537d410c
1 changed files with 15 additions and 0 deletions

View File

@ -72,6 +72,10 @@ module.exports = function(Self) {
{
arg: 'isLogifloraAllowed',
type: 'boolean'
},
{
arg: 'updateObservations',
type: 'boolean'
}
],
returns: {
@ -127,6 +131,17 @@ module.exports = function(Self) {
delete args.ctx; // Remove unwanted properties
const updatedAddress = await address.updateAttributes(ctx.args, myOptions);
if (args.updateObservations) {
const ticket = await Self.rawSql(`
UPDATE ticketObservation to2
JOIN ticket t ON t.id = to2.ticketFk
JOIN address a ON a.id = t.addressFk
JOIN addressObservation ao ON ao.addressFk = a.id
SET to2.description = ao.description
WHERE ao.observationTypeFk = to2.observationTypeFk
AND a.id = ?
AND t.shipped >= util.VN_CURDATE()`, [addressId]);
}
return updatedAddress;
};