#1719 claim.detail cambiar descuento falla
This commit is contained in:
parent
156c9ec3ab
commit
2a2c5ae3c4
|
@ -26,7 +26,7 @@ module.exports = Self => {
|
|||
where: {ticketFk: id}
|
||||
});
|
||||
|
||||
let isProductionBoss = await Self.app.models.Account.hasRole(userId, 'productionBoss');
|
||||
let isProductionBoss = await Self.app.models.Account.hasRole(userId, 'salesAssistant');
|
||||
let alertLevel = state ? state.alertLevel : null;
|
||||
let ticket = await Self.app.models.Ticket.findById(id, {
|
||||
fields: ['isDeleted', 'clientFk', 'refFk'],
|
||||
|
@ -42,10 +42,10 @@ module.exports = Self => {
|
|||
|
||||
const isDeleted = ticket && ticket.isDeleted;
|
||||
const isOnDelivery = (alertLevel && alertLevel > 0);
|
||||
const isNotNormalClient = ticket && ticket.client().type().code != 'normal';
|
||||
const isNormalClient = ticket && ticket.client().type().code == 'normal';
|
||||
const isInvoiced = ticket && ticket.refFk;
|
||||
|
||||
if (!ticket || (isOnDelivery && isNotNormalClient && !isProductionBoss) || isInvoiced || isDeleted)
|
||||
if (!ticket || isInvoiced || isDeleted || (isOnDelivery && isNormalClient && !isProductionBoss))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -29,15 +29,14 @@ describe('ticket isEditable()', () => {
|
|||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
it('should be able to edit a not deleted or invoiced ticket if the role is productionBoss', async() => {
|
||||
it('should be able to edit a deleted or invoiced ticket if the role is productionBoss', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 50}}};
|
||||
let result = await app.models.Ticket.isEditable(ctx, 8);
|
||||
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
// #1719 claim.detail cambiar descuento falla con usuario nacho
|
||||
xit('should not be able to edit a not deleted or invoiced ticket if the role is salesPerson', async() => {
|
||||
it('should not be able to edit a deleted or invoiced ticket if the role is salesPerson', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 18}}};
|
||||
let result = await app.models.Ticket.isEditable(ctx, 8);
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ module.exports = Self => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
const filter = {
|
||||
fields: ['id', 'ticketFk', 'price'],
|
||||
where: {
|
||||
id: {inq: salesIds}
|
||||
},
|
||||
|
@ -102,8 +101,7 @@ module.exports = Self => {
|
|||
value: value,
|
||||
componentFk: componentId}, options);
|
||||
|
||||
const updatedSale = models.Sale.updateAll({id: sale.id},
|
||||
{discount: newDiscount}, options);
|
||||
const updatedSale = sale.updateAttribute('discount', newDiscount, options);
|
||||
|
||||
promises.push(newComponent, updatedSale);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue