Compare commits

...

32 Commits

Author SHA1 Message Date
Robert Ferrús 1a5e473656 Merge branch 'dev' into 7731-clientViesCode
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-10-22 06:18:51 +00:00
Carlos Satorres 56cba385cf Merge pull request 'fix: refs #6850 remove notifyPickUp' (!3132) from 6850-removeChandgeUpdateClaim into dev
gitea/salix/pipeline/head This commit looks good Details
gitea/salix/pipeline/pr-test This commit looks good Details
Reviewed-on: #3132
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-10-21 12:31:30 +00:00
Carlos Satorres aad616ff83 Merge branch 'dev' into 6850-removeChandgeUpdateClaim
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-21 12:26:53 +00:00
Carlos Satorres f8c83c8f68 Merge pull request 'fix: refs #6831 filter observation' (!3131) from 6831-observationDefaulterEmail into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3131
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-10-21 12:26:04 +00:00
Carlos Satorres c3ffb31348 Merge branch 'dev' into 6831-observationDefaulterEmail
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-21 12:23:39 +00:00
Jorge Penadés b76b1c6d50 Merge pull request '#7919 delete if ticketRefund' (!3091) from 7919-deleteTicketRefund into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3091
Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-10-21 11:21:34 +00:00
Jorge Penadés 2f77359892 Merge branch 'dev' into 7919-deleteTicketRefund
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-21 11:00:31 +00:00
Pablo Natek 69a34ab0fa Merge pull request 'fix: add date format on insert data' (!3135) from fixNightProc into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3135
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-10-21 10:25:41 +00:00
Pablo Natek 1731af13ea Merge branch 'fixNightProc' of https://gitea.verdnatura.es/verdnatura/salix into fixNightProc
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-21 12:19:22 +02:00
Pablo Natek e479873547 fix: restore cursor 2024-10-21 12:19:20 +02:00
Pablo Natek 92f699aac3 Merge branch 'dev' into fixNightProc
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-10-21 09:37:07 +00:00
Pablo Natek e38c061deb fix: add date format on insert data
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-10-21 11:36:44 +02:00
Jon Elias d75a032d75 Merge pull request 'Added new filter param in item request' (!3094) from Fix-ItemRequest into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3094
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-10-21 09:34:53 +00:00
Jon Elias 158f701f1e Merge branch 'dev' into Fix-ItemRequest
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-21 09:31:29 +00:00
Carlos Satorres bf0cc687e1 Merge branch 'dev' into 6850-removeChandgeUpdateClaim
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-21 07:27:46 +00:00
Carlos Satorres eea09a9d4a fix: refs #6850 add code
gitea/salix/pipeline/pr-dev Build queued... Details
2024-10-21 09:24:53 +02:00
Carlos Satorres 19fbb836a6 fix: refs #6850 fix model
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-21 08:30:39 +02:00
Carlos Satorres b88dc1c70f fix: refs #6850 remove notifyPickUp
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-10-20 16:23:24 +02:00
Carlos Satorres b8e782d3a5 fix: refs #6831 filter observation
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-20 15:59:24 +02:00
Jon Elias 9e9773578a Merge branch 'dev' into Fix-ItemRequest
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-18 11:22:35 +00:00
Jon Elias f68584b3fa Merge branch 'dev' into Fix-ItemRequest
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-18 06:53:38 +00:00
Jorge Penadés 8ca097d4a9 chore: refs #7919 change var name
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-16 09:23:39 +02:00
Jorge Penadés d57f4fc44a chore: refs #7919 refactor, drop relation on back
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-15 17:24:14 +02:00
Jorge Penadés 6f8a005726 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 7919-deleteTicketRefund
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-10-15 17:01:29 +02:00
Jon Elias e334152acc refactor: deleted comment
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-10-15 09:03:15 +02:00
Jorge Penadés 6d4c71d465 feat: refs #7919 test
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-14 17:14:40 +02:00
Jorge Penadés a35208d903 feat: refs #7919 test 2024-10-14 17:14:01 +02:00
Jorge Penadés ccf9dbde8e feat: refs #7919 test
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-10-14 17:11:12 +02:00
Jorge Penadés 32756dabae Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 7919-deleteTicketRefund
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-14 16:49:11 +02:00
Jon Elias 07849ebeb8 fix: myTeam param
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-14 13:25:09 +02:00
Jon Elias 4ee6a46bd5 feat: added new filter param
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-10-14 11:29:49 +02:00
Jorge Penadés 770c604d6b chore: refs #7919 delete if ticketRefund
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-10-10 16:30:04 +02:00
7 changed files with 75 additions and 39 deletions

View File

@ -6,25 +6,27 @@ BLOCK1: BEGIN
DECLARE vShipped DATE;
DECLARE vPreviousShipped DATE;
DECLARE vDone boolean;
DECLARE cur cursor for
SELECT clientFk, firstShipped
FROM bs.clientNewBorn;
DECLARE cur CURSOR FOR
SELECT clientFk, firstShipped
FROM bs.clientNewBorn;
DECLARE continue HANDLER FOR NOT FOUND SET vDone = TRUE;
SET vDone := FALSE;
DELETE FROM bs.clientNewBorn WHERE isModified = FALSE;
INSERT INTO clientNewBorn(clientFk, firstShipped, lastShipped)
SELECT c.id, MAX(t.shipped), MAX(t.shipped)
FROM vn.client c
JOIN vn.ticket t on t.clientFk = c.id
LEFT JOIN clientNewBorn cb on cb.clientFk = c.id
WHERE t.shipped BETWEEN TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) AND util.VN_CURDATE() AND cb.isModified is null
GROUP BY c.id;
INSERT INTO clientNewBorn(clientFk, firstShipped, lastShipped)
SELECT c.id, DATE(MAX(t.shipped)), DATE(MAX(t.shipped))
FROM vn.client c
JOIN vn.ticket t ON t.clientFk = c.id
LEFT JOIN clientNewBorn cb ON cb.clientFk = c.id
WHERE t.shipped BETWEEN util.VN_CURDATE() - INTERVAL 1 YEAR
AND util.VN_CURDATE()
AND cb.isModified IS NULL
GROUP BY c.id;
OPEN cur;
LOOP1: LOOP
SET vDone := FALSE;
FETCH cur INTO vClientFk, vShipped;

View File

@ -85,16 +85,11 @@ module.exports = Self => {
const updatedClaim = await claim.updateAttributes(args, myOptions);
const salesPerson = claim.client().salesPersonUser();
if (salesPerson) {
if (changedPickup && updatedClaim.pickup)
await notifyPickUp(ctx, salesPerson.id, claim);
if (args.claimStateFk) {
const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions);
await notifyStateChange(ctx, salesPerson.id, claim, newState.description);
if (newState.code == 'canceled')
await notifyStateChange(ctx, claim.workerFk, claim, newState.description);
}
if (salesPerson && args.claimStateFk) {
const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions);
await notifyStateChange(ctx, salesPerson.id, claim, newState.description);
if (newState.code == 'canceled')
await notifyStateChange(ctx, claim.workerFk, claim, newState.description);
}
if (tx) await tx.commit();
@ -119,18 +114,4 @@ module.exports = Self => {
});
await models.Chat.sendCheckingPresence(ctx, workerId, message);
}
async function notifyPickUp(ctx, workerId, claim) {
const models = Self.app.models;
const url = await models.Url.getUrl();
const $t = ctx.req.__; // $translate
const message = $t('Claim will be picked', {
claimId: claim.id,
clientName: claim.client().name,
claimUrl: `${url}claim/${claim.id}/summary`,
claimPickup: $t(claim.pickup)
});
await models.Chat.sendCheckingPresence(ctx, workerId, message);
}
};

View File

@ -74,7 +74,8 @@ module.exports = Self => {
pm.name payMethod,
r.finished IS NULL hasRecovery,
dp.id departmentFk,
dp.name departmentName
dp.name departmentName,
dp.notificationEmail departmentEmail
FROM defaulter d
JOIN client c ON c.id = d.clientFk
JOIN country cn ON cn.id = c.countryFk

View File

@ -47,7 +47,7 @@ module.exports = Self => {
await models.Mail.create({
subject: $t('Comment added to client', {clientFk: defaulter.clientFk}),
body: body,
receiver: `${defaulter.salesPersonName}@verdnatura.es`,
receiver: `${defaulter.departmentEmail}`,
replyTo: `${user.name}@verdnatura.es`
}, myOptions);
}

View File

@ -59,6 +59,11 @@ module.exports = Self => {
arg: 'state',
type: 'string',
description: `Search request by request state`
},
{
arg: 'myTeam',
type: 'boolean',
description: `Team partners`
}
],
returns: {
@ -75,6 +80,8 @@ module.exports = Self => {
const conn = Self.dataSource.connector;
const userId = ctx.req.accessToken.userId;
const myOptions = {};
const models = Self.app.models;
const args = ctx.args;
if (typeof options == 'object')
Object.assign(myOptions, options);
@ -82,6 +89,21 @@ module.exports = Self => {
if (ctx.args.mine)
ctx.args.attenderFk = userId;
const teamMembersId = [];
if (args.myTeam != null) {
const worker = await models.Worker.findById(userId, {
include: {
relation: 'collegues'
}
}, myOptions);
const collegues = worker.collegues() || [];
for (let collegue of collegues)
teamMembersId.push(collegue.collegueFk);
if (teamMembersId.length == 0)
teamMembersId.push(userId);
}
let where = buildFilter(ctx.args, (param, value) => {
switch (param) {
case 'search':
@ -113,6 +135,11 @@ module.exports = Self => {
return {'w.id': value};
case 'salesPersonFk':
return {'c.salesPersonFk': value};
case 'myTeam':
if (value)
return {'tr.requesterFk': {inq: teamMembersId}};
else
return {'tr.requesterFk': {nin: teamMembersId}};
}
});

View File

@ -49,9 +49,12 @@ module.exports = Self => {
where: {originalTicketFk: id}
}, myOptions);
const hasRefund = !!ticketRefunds?.length;
const allDeleted = ticketRefunds.every(refund => refund.refundTicket().isDeleted);
if (ticketRefunds?.length && !allDeleted) {
if (!hasRefund) await models.TicketRefund.destroyAll({refundTicketFk: id}, myOptions);
if (hasRefund && !allDeleted) {
const notDeleted = [];
for (const refund of ticketRefunds)
if (!refund.refundTicket().isDeleted) notDeleted.push(refund.refundTicket().id);

View File

@ -113,5 +113,27 @@ describe('ticket setDeleted()', () => {
expect(error.message).not.toContain('Tickets with associated refunds');
});
it('should delete the refund - original ticket relation', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const ticketId = 24;
const refundTicket = await models.TicketRefund.findOne({where: {refundTicketFk: ticketId}}, options);
expect(refundTicket).toBeTruthy();
await models.Ticket.setDeleted(ctx, ticketId, options);
const removedRefundTicket = await models.TicketRefund.findOne({
where: {refundTicketFk: ticketId}},
options);
expect(removedRefundTicket).toBeNull();
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
});
});