Merge branch '1719-claim-detail' of verdnatura/salix into dev
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
commit
51a9ad951f
|
@ -26,7 +26,10 @@ module.exports = Self => {
|
|||
where: {ticketFk: id}
|
||||
});
|
||||
|
||||
let isProductionBoss = await Self.app.models.Account.hasRole(userId, 'salesAssistant');
|
||||
const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant');
|
||||
const isProductionBoss = await Self.app.models.Account.hasRole(userId, 'productionBoss');
|
||||
const isValidRole = isSalesAssistant || isProductionBoss;
|
||||
|
||||
let alertLevel = state ? state.alertLevel : null;
|
||||
let ticket = await Self.app.models.Ticket.findById(id, {
|
||||
fields: ['isDeleted', 'clientFk', 'refFk'],
|
||||
|
@ -45,7 +48,7 @@ module.exports = Self => {
|
|||
const isNormalClient = ticket && ticket.client().type().code == 'normal';
|
||||
const isInvoiced = ticket && ticket.refFk;
|
||||
|
||||
if (!ticket || isInvoiced || isDeleted || (isOnDelivery && isNormalClient && !isProductionBoss))
|
||||
if (!ticket || isInvoiced || isDeleted || (isOnDelivery && isNormalClient && !isValidRole))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -29,6 +29,13 @@ describe('ticket isEditable()', () => {
|
|||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
it('should be able to edit a deleted or invoiced ticket if the role is salesAssistant', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 21}}};
|
||||
let result = await app.models.Ticket.isEditable(ctx, 8);
|
||||
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue