This commit is contained in:
parent
8cecff36ef
commit
69acebb43c
|
@ -1,5 +1,5 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('makeMulti', {
|
Self.remoteMethodCtx('addListByItem', {
|
||||||
description: 'Add a record or update it if it already exists.',
|
description: 'Add a record or update it if it already exists.',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
|
@ -20,12 +20,12 @@ module.exports = Self => {
|
||||||
}],
|
}],
|
||||||
|
|
||||||
http: {
|
http: {
|
||||||
path: `/makeMulti`,
|
path: `/addListByItem`,
|
||||||
verb: 'POST'
|
verb: 'POST'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.makeMulti = async(ctx, shelvingFk, items, warehouseFk, options) => {
|
Self.addListByItem = async(ctx, shelvingFk, items, warehouseFk, options) => {
|
||||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||||
let tx;
|
let tx;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('ItemShelving makeMulti()', () => {
|
describe('ItemShelving addListByItem()', () => {
|
||||||
const warehouseFk = 1;
|
const warehouseFk = 1;
|
||||||
let ctx;
|
let ctx;
|
||||||
let options;
|
let options;
|
||||||
|
@ -33,7 +33,7 @@ describe('ItemShelving makeMulti()', () => {
|
||||||
const shelvingFk = 'ZPP';
|
const shelvingFk = 'ZPP';
|
||||||
const items = [1, 1, 1, 2];
|
const items = [1, 1, 1, 2];
|
||||||
|
|
||||||
await models.ItemShelving.makeMulti(ctx, shelvingFk, items, warehouseFk, options);
|
await models.ItemShelving.addListByItem(ctx, shelvingFk, items, warehouseFk, options);
|
||||||
const itemShelvings = await models.ItemShelving.find({where: {shelvingFk}}, options);
|
const itemShelvings = await models.ItemShelving.find({where: {shelvingFk}}, options);
|
||||||
|
|
||||||
expect(itemShelvings.length).toEqual(2);
|
expect(itemShelvings.length).toEqual(2);
|
||||||
|
@ -45,7 +45,7 @@ describe('ItemShelving makeMulti()', () => {
|
||||||
const {visible: itemsBefore} = await models.ItemShelving.findOne({
|
const {visible: itemsBefore} = await models.ItemShelving.findOne({
|
||||||
where: {shelvingFk, itemFk: items[0]}
|
where: {shelvingFk, itemFk: items[0]}
|
||||||
}, options);
|
}, options);
|
||||||
await models.ItemShelving.makeMulti(ctx, shelvingFk, items, warehouseFk, options);
|
await models.ItemShelving.addListByItem(ctx, shelvingFk, items, warehouseFk, options);
|
||||||
const {visible: itemsAfter} = await models.ItemShelving.findOne({
|
const {visible: itemsAfter} = await models.ItemShelving.findOne({
|
||||||
where: {shelvingFk, itemFk: items[0]}
|
where: {shelvingFk, itemFk: items[0]}
|
||||||
}, options);
|
}, options);
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/item-shelving/deleteItemShelvings')(Self);
|
require('../methods/item-shelving/deleteItemShelvings')(Self);
|
||||||
require('../methods/item-shelving/makeMulti')(Self);
|
require('../methods/item-shelving/addListByItem')(Self);
|
||||||
require('../methods/item-shelving/getInventory')(Self);
|
require('../methods/item-shelving/getInventory')(Self);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue