#6889 drop addSaleByCode #2470

Merged
jorgep merged 27 commits from 6889-dropAddSaleByCode into dev 2024-06-03 10:09:07 +00:00
1 changed files with 3 additions and 4 deletions
Showing only changes of commit 39dcb7d6a8 - Show all commits

View File

@ -27,17 +27,16 @@ module.exports = Self => {
const ticketCollection = await models.TicketCollection.findOne({
include: {relation: 'collection'}, where: {ticketFk: id}
}, myOptions);
let workerId = ticketCollection?.collection()?.workerFk;
let isOwner = ticketCollection?.collection()?.workerFk === ctx.req.accessToken.userId;
if (!workerId) {
if (!isOwner) {
const saleGroup = await models.SaleGroup.findOne({fields: ['id'], where: {ticketFk: id}}, myOptions);
const sectorCollectionSaleGroup = saleGroup && await models.SectorCollectionSaleGroup.findOne({
include: {relation: 'sectorCollection'}, where: {saleGroupFk: saleGroup.id}
}, myOptions);
workerId = sectorCollectionSaleGroup?.sectorCollection()?.userFk;
isOwner = sectorCollectionSaleGroup?.sectorCollection()?.userFk === ctx.req.accessToken.userId;
}
const isOwner = workerId === ctx.req.accessToken.userId;
jorgep marked this conversation as resolved
Review

aqui hay un caso no contemplado, si la coleccion la tiene otro, pero llega el que tiene el salegroup asociado sí debe poder editarlo, por tanto, no tienen que ser excluyentes esas dos opciones

aqui hay un caso no contemplado, si la coleccion la tiene otro, pero llega el que tiene el salegroup asociado sí debe poder editarlo, por tanto, no tienen que ser excluyentes esas dos opciones
if (!ticket)
throw new ForbiddenError(`The ticket doesn't exist.`);