refs #5115 transfer_sales
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Robert Ferrús 2023-01-30 11:44:14 +01:00
parent ce1bdaec17
commit 7614b48c9a
2 changed files with 1 additions and 30 deletions

View File

@ -80,34 +80,6 @@ describe('sale transferSales()', () => {
expect(error.message).toEqual(`Can't transfer claimed sales`);
});
it('should be able to transfer claimed sales if the role is claimManager', async() => {
const tx = await models.Ticket.beginTransaction({});
let error;
try {
const options = {transaction: tx};
const claimManagerId = 72;
const myActiveCtx = {
accessToken: {userId: claimManagerId},
};
const myCtx = {req: myActiveCtx};
const ticketId = 11;
const receiverTicketId = null;
const sales = await models.Ticket.getSales(ticketId, options);
await models.Ticket.transferSales(myCtx, ticketId, receiverTicketId, sales, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error).toBeUndefined();
});
it('should transfer the sales from a ticket to a new one', async() => {
const tx = await models.Ticket.beginTransaction({});

View File

@ -77,9 +77,8 @@ module.exports = Self => {
const saleIds = sales.map(sale => sale.id);
const isClaimManager = await models.Account.hasRole(userId, 'claimManager');
const hasClaimedSales = await models.ClaimBeginning.findOne({where: {saleFk: {inq: saleIds}}});
if (hasClaimedSales && !isClaimManager)
if (hasClaimedSales)
throw new UserError(`Can't transfer claimed sales`);
for (const sale of sales) {