7525-devToTest #2542

Merged
alexm merged 231 commits from 7525-devToTest into test 2024-06-04 07:59:34 +00:00
3 changed files with 32 additions and 1 deletions
Showing only changes of commit 885aa5208a - Show all commits

View File

@ -1,6 +1,16 @@
{
"name": "Collection",
"base": "VnModel",
"properties": {
"id": {
"id": true,
"type": "number",
"required": true
},
"workerFk": {
"type": "number"
}
},
"options": {
"mysql": {
"table": "collection"

View File

@ -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';

View File

@ -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;