Merge branch 'test' into dev
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
commit
35d4c99e53
|
@ -16,10 +16,6 @@ vn-check {
|
|||
}
|
||||
|
||||
md-checkbox {
|
||||
margin-bottom: 0
|
||||
}
|
||||
|
||||
md-checkbox .md-label {
|
||||
margin-bottom: .5em;
|
||||
margin-bottom: 0.8em
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,4 +174,7 @@ vn-table {
|
|||
float: right;
|
||||
margin: 0!important;
|
||||
}
|
||||
md-checkbox {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('item-barcode toItem()', () => {
|
||||
it('should return the same number if there is a barcode and a item with the same ID', async() => {
|
||||
let barcode = 3;
|
||||
let result = await app.models.ItemBarcode.toItem(barcode);
|
||||
|
||||
expect(result).toBe(3);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,28 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('toItem', {
|
||||
description: 'Returns last entries',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'barcode',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'barcode'
|
||||
}],
|
||||
returns: {
|
||||
type: 'Number',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:barcode/toItem`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.toItem = async barcode => {
|
||||
let query = `SELECT vn.barcodeToItem(?)`;
|
||||
let [item] = await Self.rawSql(query, [barcode]);
|
||||
if (item)
|
||||
item = Object.values(item);
|
||||
return item[0];
|
||||
};
|
||||
};
|
|
@ -1,4 +1,6 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/item-barcode/toItem')(Self);
|
||||
|
||||
Self.validatesUniquenessOf('code', {
|
||||
message: `Barcode must be unique`
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue