Merge branch 'dev' of http://git.verdnatura.es/salix into dev
This commit is contained in:
commit
b43f8d2d58
|
@ -21,6 +21,7 @@
|
|||
label="Package"
|
||||
show-field="name"
|
||||
value-field="packagingFk"
|
||||
where="{or: [{id: {like: '%search%'}}, {name: {like: '%search%'}}]}"
|
||||
field="package.packagingFk">
|
||||
<tpl-item>{{id}} : {{name}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './index';
|
||||
|
||||
fdescribe('Ticket', () => {
|
||||
describe('Ticket', () => {
|
||||
describe('Component vnTicketSummary', () => {
|
||||
let $componentController;
|
||||
let controller;
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
const app = require(`${servicesDir}/ticket/server/server`);
|
||||
|
||||
describe('ticket componentUpdate()', () => {
|
||||
xdescribe('ticket componentUpdate()', () => {
|
||||
it('should call the componentUpdate method and receive an error', async() => {
|
||||
let data = {
|
||||
clientFk: 101,
|
||||
agencyModeFk: 1,
|
||||
addressFk: 121,
|
||||
warehouseFk: 1,
|
||||
shipped: Date.now(),
|
||||
landed: Date.now(),
|
||||
hasToBeUnrouted: true,
|
||||
shipped: new Date(),
|
||||
landed: new Date(),
|
||||
isDeleted: false,
|
||||
hasToBeUnrouted: false,
|
||||
option: 1
|
||||
};
|
||||
let ctx = {req: {accessToken: {userId: 101}}};
|
||||
await app.models.Ticket.componentUpdate(1, data, ctx)
|
||||
.catch(response => {
|
||||
expect(response).toEqual(new Error('ER_SIGNAL_EXCEPTION: NO_AGENCY_AVAILABLE'));
|
||||
});
|
||||
let result = await app.models.Ticket.componentUpdate(1, data, ctx);
|
||||
|
||||
expect(result.constructor.name).toEqual('OkPacket');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
|
||||
const ParameterizedSQL = require('vn-loopback/node_modules/loopback-connector').ParameterizedSQL;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('listPackaging', {
|
||||
description: 'Returns all packages including item',
|
||||
|
@ -20,30 +23,12 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.listPackaging = async filter => {
|
||||
let where = '';
|
||||
let limit = '';
|
||||
let order = '';
|
||||
let params;
|
||||
let stmt = new ParameterizedSQL(
|
||||
`SELECT i.name, i.id, p.id packagingFk
|
||||
FROM item i JOIN packaging p ON i.id = p.itemFk`
|
||||
);
|
||||
|
||||
if (filter) {
|
||||
let connector = Self.dataSource.connector;
|
||||
if (filter.where) {
|
||||
if (filter.where.packagingFk) {
|
||||
where = 'WHERE p.id = ?';
|
||||
params = [filter.where.packagingFk];
|
||||
} else {
|
||||
let search = filter.where.name.regexp;
|
||||
where = 'WHERE i.id REGEXP ? OR i.name REGEXP ?';
|
||||
params = [search, search];
|
||||
}
|
||||
}
|
||||
|
||||
limit = connector._buildLimit(null, filter.limit, filter.offset);
|
||||
order = connector.buildOrderBy('Item', filter.order);
|
||||
}
|
||||
|
||||
let query = `SELECT i.name, i.id, p.id packagingFk FROM
|
||||
item i JOIN packaging p ON i.id = p.itemFk ${where} ${order} ${limit}`;
|
||||
return await Self.rawSql(query, params);
|
||||
stmt.merge(Self.buildSuffix(filter, 'i'));
|
||||
return Self.rawStmt(stmt);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
const app = require(`${servicesDir}/ticket/server/server`);
|
||||
|
||||
describe('ticket listPackaging()', () => {
|
||||
it('should call the listPackaging method and return the response', async () => {
|
||||
let filter = {where: {packagingFk: 1}};
|
||||
let response = await app.models.Packaging.listPackaging(filter);
|
||||
|
||||
expect(response[0].name).toBeDefined();
|
||||
expect(response[0].name).toEqual('Gem of Time');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue