7167-testToMaster_2414 #2244

Merged
alexm merged 643 commits from 7167-testToMaster_2414 into master 2024-04-04 05:32:41 +00:00
5 changed files with 109 additions and 3 deletions
Showing only changes of commit 3109f7722e - Show all commits

View File

@ -6,4 +6,5 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
('MachineWorker','add','READ','ALLOW','ROLE','employee'),
('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','employee'),
('SaleTracking','deleteTracking','WRITE','ALLOW','ROLE','employee'),
('SaleTracking','updateTracking','WRITE','ALLOW','ROLE','employee');
('SaleTracking','updateTracking','WRITE','ALLOW','ROLE','employee'),
('SaleTracking','mark','WRITE','ALLOW','ROLE','employee');

View File

@ -200,5 +200,6 @@
"Try again": "Try again",
"keepPrice": "keepPrice",
"Cannot past travels with entries": "Cannot past travels with entries",
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}"
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}",
"The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified"
}

View File

@ -329,5 +329,6 @@
"The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mínima",
"quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima",
"Cannot past travels with entries": "No se pueden pasar envíos con entradas",
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}"
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
"The line could not be marked": "The line could not be marked"
}

View File

@ -0,0 +1,102 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('mark', {
description: 'Insert an itemShelvingSale and Modify a saleTracking record',
accessType: 'WRITE',
accepts: [
{
arg: 'saleFk',
type: 'number',
required: true
},
{
arg: 'originalQuantity',
type: 'number',
required: true
},
{
arg: 'code',
type: 'string',
required: true
},
{
arg: 'isChecked',
type: 'number',
required: true
},
{
arg: 'buyFk',
type: 'number',
required: true
},
{
arg: 'isScanned',
type: 'number',
},
{
arg: 'quantity',
type: 'number',
required: true
},
{
arg: 'itemShelvingFk',
type: 'number',
required: true
}
],
http: {
path: `/mark`,
verb: 'POST'
}
});
Self.mark = async(ctx, saleFk, originalQuantity, code, isChecked, buyFk, isScanned, quantity, itemShelvingFk, options) => {
const userId = ctx.req.accessToken.userId;
const models = Self.app.models;
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
await models.ItemShelvingSale.create({
itemShelvingFk,
saleFk,
quantity,
userFk: userId
}, myOptions);
const itemShelving = await models.ItemShelving.findOne({
where: {
id: itemShelvingFk
}
}, myOptions);
if (itemShelving.visible) {
await itemShelving.updateAttributes({
visible: itemShelving.visible - quantity}
, myOptions);
}
await Self.updateAll(
{saleFk},
{isChecked: 1},
myOptions
);
await Self.updateTracking(ctx, saleFk, originalQuantity, code, isChecked, buyFk, isScanned, myOptions);
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
throw new UserError('The line could not be marked');
}
};
};

View File

@ -4,4 +4,5 @@ module.exports = Self => {
require('../methods/sale-tracking/new')(Self);
require('../methods/sale-tracking/delete')(Self);
require('../methods/sale-tracking/updateTracking')(Self);
require('../methods/sale-tracking/mark')(Self);
};