fix: test back
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-10-21 09:01:08 +02:00
parent 2d0cb60b50
commit c33cab7b10
2 changed files with 11 additions and 1 deletions

View File

@ -110,6 +110,11 @@ describe('sale updateDiscount()', () => {
const componentId = manaDiscount.id;
const manaCode = 'mana';
const teamCLopez = 96;
const userId = ctx.req.accessToken.userId;
const business = await models.Business.findOne({where: {workerFk: userId}}, options);
await business.updateAttribute('departmentFk', teamCLopez, options);
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options);
const updatedSale = await models.Sale.findById(originalSaleId, null, options);
@ -150,6 +155,11 @@ describe('sale updateDiscount()', () => {
const componentId = manaDiscount.id;
const manaCode = 'manaClaim';
const teamCLopez = 96;
const userId = ctx.req.accessToken.userId;
const business = await models.Business.findOne({where: {workerFk: userId}}, options);
await business.updateAttribute('departmentFk', teamCLopez, options);
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options);
const updatedSale = await models.Sale.findById(originalSaleId, null, options);

View File

@ -98,7 +98,7 @@ module.exports = Self => {
if (isLocked || (!hasAllowedRoles && alertLevel > 0))
throw new UserError(`The sales of this ticket can't be modified`);
const usesMana = await models.Sale.usesMana(ctx);
const usesMana = await models.Sale.usesMana(ctx, myOptions);
const componentCode = usesMana ? manaCode : 'buyerDiscount';
const discountComponent = await models.Component.findOne({
where: {code: componentCode}}, myOptions);