feat : refs #6889 wip: check if is productionReviewer or owner
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
56407e12a3
commit
885aa5208a
|
@ -1,6 +1,16 @@
|
|||
{
|
||||
"name": "Collection",
|
||||
"base": "VnModel",
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"workerFk": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "collection"
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
INSERT INTO account.role
|
||||
SET name = 'productionReviewer',
|
||||
description = 'Revisor de producción',
|
||||
hasLogin = TRUE,
|
||||
created = util.VN_CURDATE(),
|
||||
modified = util.VN_CURDATE(),
|
||||
editorFk = NULL;
|
||||
|
||||
UPDATE salix.ACL
|
||||
SET principalId = 'productionReviewer'
|
||||
WHERE property = 'isInPreparing';
|
|
@ -68,6 +68,7 @@ module.exports = Self => {
|
|||
fields: ['family', 'minQuantity'],
|
||||
where: {id: itemId},
|
||||
}, ctx.options);
|
||||
|
||||
if (item.family == 'EMB') return;
|
||||
|
||||
if (await models.ACL.checkAccessAcl(ctx, 'Sale', 'isInPreparing', '*')) return;
|
||||
|
@ -88,7 +89,16 @@ module.exports = Self => {
|
|||
|
||||
if (await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*')) return;
|
||||
|
||||
if (newQuantity < item.minQuantity && newQuantity != available)
|
||||
// WIP: Check if is owner
|
||||
const ticketCollection = await models.TicketCollection.findOne({
|
||||
include: {relation: 'collection', fields: ['workerFk']},
|
||||
where: {ticketFk: ticketId}
|
||||
}, ctx.options);
|
||||
|
||||
// if(!res) look in SaleGroup.(ask for Sergio to make fixtures for this case)
|
||||
const isOwner = res.collection.workerFk === ctx.req.accessToken.userId;
|
||||
|
||||
if (newQuantity < item.minQuantity && newQuantity != available && !isOwner)
|
||||
throw new UserError('The amount cannot be less than the minimum');
|
||||
|
||||
if (ctx.isNewInstance || isReduction) return;
|
||||
|
|
Loading…
Reference in New Issue