7152-devToTest_2414 #2228

Merged
alexm merged 636 commits from 7152-devToTest_2414 into test 2024-03-28 08:26:34 +00:00
4 changed files with 35 additions and 3 deletions
Showing only changes of commit f04724a61f - Show all commits

View File

@ -209,5 +209,7 @@
"This pallet does not exist": "This pallet does not exist", "This pallet does not exist": "This pallet does not exist",
"We do not have availability for the selected item": "We do not have availability for the selected item", "We do not have availability for the selected item": "We do not have availability for the selected item",
"You are already using a machine": "You are already using a machine", "You are already using a machine": "You are already using a machine",
"This worker does not exist": "This worker does not exist" "This worker does not exist": "This worker does not exist",
"this state does not exist": "This state does not exist"
} }

View File

@ -346,5 +346,6 @@
"We do not have availability for the selected item": "No tenemos disponible el item seleccionado", "We do not have availability for the selected item": "No tenemos disponible el item seleccionado",
"You are already using a machine": "Ya estás usando una máquina.", "You are already using a machine": "Ya estás usando una máquina.",
"This worker does not exist": "Este trabajador no existe", "This worker does not exist": "Este trabajador no existe",
"Este trabajador no existe": "Este trabajador no existe" "this state does not exist": "Este estado no existe",
"Este estado no existe": "Este estado no existe"
} }

View File

@ -1,6 +1,6 @@
const {models} = require('vn-loopback/server/server'); const {models} = require('vn-loopback/server/server');
fdescribe('saleTracking updateTracking()', () => { describe('saleTracking updateTracking()', () => {
const saleFk = 1; const saleFk = 1;
const originalQuantity = 10; const originalQuantity = 10;
const code = 'PREPARED'; const code = 'PREPARED';
@ -13,10 +13,36 @@ fdescribe('saleTracking updateTracking()', () => {
req: { req: {
accessToken: {userId: 104}, accessToken: {userId: 104},
headers: {origin: 'http://localhost'}, headers: {origin: 'http://localhost'},
__: value => value
} }
}; };
}); });
it('should add a new saleTracking and saleBuy', async() => {
const tx = await models.SaleTracking.beginTransaction({});
const options = {transaction: tx};
const code = 'FAKESTATE';
try {
await models.SaleTracking.updateTracking(
ctx,
saleFk,
originalQuantity,
code,
isChecked,
buyFk,
isScanned,
options
);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toEqual('this state does not exist');
await tx.rollback();
}
});
it('should add a new saleTracking and saleBuy', async() => { it('should add a new saleTracking and saleBuy', async() => {
const tx = await models.SaleTracking.beginTransaction({}); const tx = await models.SaleTracking.beginTransaction({});
const options = {transaction: tx}; const options = {transaction: tx};

View File

@ -1,3 +1,4 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('updateTracking', { Self.remoteMethodCtx('updateTracking', {
description: 'Modify a saleTracking record and, if applicable, add a corresponding record in saleBuy.', description: 'Modify a saleTracking record and, if applicable, add a corresponding record in saleBuy.',
@ -42,6 +43,7 @@ module.exports = Self => {
Self.updateTracking = async(ctx, saleFk, originalQuantity, code, isChecked, buyFk, isScanned = null, options) => { Self.updateTracking = async(ctx, saleFk, originalQuantity, code, isChecked, buyFk, isScanned = null, options) => {
const userId = ctx.req.accessToken.userId; const userId = ctx.req.accessToken.userId;
const models = Self.app.models; const models = Self.app.models;
const $t = ctx.req.__;
const myOptions = {}; const myOptions = {};
let tx; let tx;
@ -58,6 +60,7 @@ module.exports = Self => {
where: {code}, where: {code},
}, myOptions); }, myOptions);
if (!state) throw new UserError($t('this state does not exist'));
const uniqueAttributes = { const uniqueAttributes = {
saleFk, saleFk,
workerFk: userId, workerFk: userId,