4108-mdb_backend #987
|
@ -123,19 +123,19 @@ describe('Client lock verified data path', () => {
|
||||||
await page.accessToSection('client.card.fiscalData');
|
await page.accessToSection('client.card.fiscalData');
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
it('should confirm verified data button is disabled for salesAssistant', async() => {
|
it('should confirm verified data button is enabled for salesAssistant', async() => {
|
||||||
const isDisabled = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
|
const isDisabled = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
|
||||||
|
|
||||||
expect(isDisabled).toBeTrue();
|
expect(isDisabled).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return error when edit the social name', async() => {
|
it('should now edit the social name', async() => {
|
||||||
await page.clearInput(selectors.clientFiscalData.socialName);
|
await page.clearInput(selectors.clientFiscalData.socialName);
|
||||||
await page.write(selectors.clientFiscalData.socialName, 'new social name edition');
|
await page.write(selectors.clientFiscalData.socialName, 'new social name edition');
|
||||||
await page.waitToClick(selectors.clientFiscalData.saveButton);
|
await page.waitToClick(selectors.clientFiscalData.saveButton);
|
||||||
const message = await page.waitForSnackbar();
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
expect(message.text).toContain(`Not enough privileges to edit a client with verified data`);
|
expect(message.text).toContain(`Data saved!`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should now confirm the social name have been edited once and for all', async() => {
|
it('should now confirm the social name have been edited once and for all', async() => {
|
||||||
|
|
|
@ -86,7 +86,6 @@ module.exports = Self => {
|
||||||
};
|
};
|
||||||
ticketFk = await createTicket(ctx, myOptions);
|
ticketFk = await createTicket(ctx, myOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
await models.Sale.create({
|
await models.Sale.create({
|
||||||
ticketFk: ticketFk,
|
ticketFk: ticketFk,
|
||||||
itemFk: sale.itemFk,
|
itemFk: sale.itemFk,
|
||||||
|
|
|
@ -125,10 +125,10 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const isAdministrative = await models.Account.hasRole(userId, 'administrative', myOptions);
|
const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', myOptions);
|
||||||
const client = await models.Client.findById(clientId, null, myOptions);
|
const client = await models.Client.findById(clientId, null, myOptions);
|
||||||
|
|
||||||
if (!isAdministrative && client.isTaxDataChecked)
|
if (!isSalesAssistant && client.isTaxDataChecked)
|
||||||
throw new UserError(`Not enough privileges to edit a client with verified data`);
|
throw new UserError(`Not enough privileges to edit a client with verified data`);
|
||||||
|
|
||||||
// Sage data validation
|
// Sage data validation
|
||||||
|
|
|
@ -232,7 +232,6 @@ module.exports = Self => {
|
||||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||||
const userId = loopBackContext.active.accessToken.userId;
|
const userId = loopBackContext.active.accessToken.userId;
|
||||||
|
|
||||||
const isAdministrative = await models.Account.hasRole(userId, 'administrative', ctx.options);
|
|
||||||
const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', ctx.options);
|
const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', ctx.options);
|
||||||
const hasChanges = orgData && changes;
|
const hasChanges = orgData && changes;
|
||||||
|
|
||||||
|
@ -245,7 +244,7 @@ module.exports = Self => {
|
||||||
const sageTransactionType = hasChanges && (changes.sageTransactionTypeFk || orgData.sageTransactionTypeFk);
|
const sageTransactionType = hasChanges && (changes.sageTransactionTypeFk || orgData.sageTransactionTypeFk);
|
||||||
const sageTransactionTypeChanged = hasChanges && orgData.sageTransactionTypeFk != sageTransactionType;
|
const sageTransactionTypeChanged = hasChanges && orgData.sageTransactionTypeFk != sageTransactionType;
|
||||||
|
|
||||||
const cantEditVerifiedData = isTaxDataCheckedChanged && !isAdministrative;
|
const cantEditVerifiedData = isTaxDataCheckedChanged && !isSalesAssistant;
|
||||||
const cantChangeSageData = (sageTaxTypeChanged || sageTransactionTypeChanged) && !isSalesAssistant;
|
const cantChangeSageData = (sageTaxTypeChanged || sageTransactionTypeChanged) && !isSalesAssistant;
|
||||||
|
|
||||||
if (cantEditVerifiedData || cantChangeSageData)
|
if (cantEditVerifiedData || cantChangeSageData)
|
||||||
|
|
|
@ -182,7 +182,7 @@
|
||||||
vn-one
|
vn-one
|
||||||
label="Verified data"
|
label="Verified data"
|
||||||
ng-model="$ctrl.client.isTaxDataChecked"
|
ng-model="$ctrl.client.isTaxDataChecked"
|
||||||
vn-acl="administrative">
|
vn-acl="salesAssistant">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
|
|
@ -304,7 +304,8 @@ module.exports = Self => {
|
||||||
{'tp.hasTicketRequest': true},
|
{'tp.hasTicketRequest': true},
|
||||||
{'tp.hasComponentLack': true},
|
{'tp.hasComponentLack': true},
|
||||||
{'tp.isTaxDataChecked': false},
|
{'tp.isTaxDataChecked': false},
|
||||||
{'tp.itemShortage': {neq: null}}
|
{'tp.itemShortage': {neq: null}},
|
||||||
|
{'tp.isTooLittle': true}
|
||||||
]};
|
]};
|
||||||
} else if (hasProblems === false) {
|
} else if (hasProblems === false) {
|
||||||
whereProblems = {and: [
|
whereProblems = {and: [
|
||||||
|
@ -313,7 +314,8 @@ module.exports = Self => {
|
||||||
{'tp.hasTicketRequest': false},
|
{'tp.hasTicketRequest': false},
|
||||||
{'tp.hasComponentLack': false},
|
{'tp.hasComponentLack': false},
|
||||||
{'tp.isTaxDataChecked': true},
|
{'tp.isTaxDataChecked': true},
|
||||||
{'tp.itemShortage': null}
|
{'tp.itemShortage': null},
|
||||||
|
{'tp.isTooLittle': false}
|
||||||
]};
|
]};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue