This commit is contained in:
parent
89d18e29f0
commit
f04724a61f
|
@ -209,5 +209,7 @@
|
|||
"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",
|
||||
"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"
|
||||
|
||||
}
|
|
@ -346,5 +346,6 @@
|
|||
"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.",
|
||||
"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"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
fdescribe('saleTracking updateTracking()', () => {
|
||||
describe('saleTracking updateTracking()', () => {
|
||||
const saleFk = 1;
|
||||
const originalQuantity = 10;
|
||||
const code = 'PREPARED';
|
||||
|
@ -13,10 +13,36 @@ fdescribe('saleTracking updateTracking()', () => {
|
|||
req: {
|
||||
accessToken: {userId: 104},
|
||||
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() => {
|
||||
const tx = await models.SaleTracking.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('updateTracking', {
|
||||
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) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const models = Self.app.models;
|
||||
const $t = ctx.req.__;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
|
@ -58,6 +60,7 @@ module.exports = Self => {
|
|||
where: {code},
|
||||
}, myOptions);
|
||||
|
||||
if (!state) throw new UserError($t('this state does not exist'));
|
||||
const uniqueAttributes = {
|
||||
saleFk,
|
||||
workerFk: userId,
|
||||
|
|
Loading…
Reference in New Issue