Enter a new search
diff --git a/front/core/components/table/index.js b/front/core/components/table/index.js
index d28ece3a4..b905212e5 100644
--- a/front/core/components/table/index.js
+++ b/front/core/components/table/index.js
@@ -10,7 +10,7 @@ export default class Table {
this.autoLoad = true;
$transclude($scope.$parent, clone => {
- angular.element($element[0].querySelector('div')).append(clone);
+ angular.element($element[0].querySelector('.table')).append(clone);
});
}
diff --git a/front/core/directives/index.js b/front/core/directives/index.js
index a97c88b3c..9aed1aea3 100644
--- a/front/core/directives/index.js
+++ b/front/core/directives/index.js
@@ -10,3 +10,4 @@ import './visible-by';
import './bind';
import './repeat-last';
import './title';
+import './uvc';
diff --git a/front/core/directives/uvc.html b/front/core/directives/uvc.html
new file mode 100644
index 000000000..be96cb35e
--- /dev/null
+++ b/front/core/directives/uvc.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/front/core/directives/uvc.js b/front/core/directives/uvc.js
new file mode 100644
index 000000000..d880162ee
--- /dev/null
+++ b/front/core/directives/uvc.js
@@ -0,0 +1,95 @@
+import ngModule from '../module';
+import template from './uvc.html';
+
+directive.$inject = ['$http', '$compile', 'vnApp', '$translate'];
+export function directive($http, $compile, vnApp, $translate) {
+ function getHeaderList($element, $scope) {
+ let allHeaders = $element[0].querySelectorAll(`vn-th[field], vn-th[th-id]`);
+ let headerList = Array.from(allHeaders);
+ let ids = [];
+
+ headerList.forEach(header => {
+ ids.push(header.getAttribute('th-id') || header.getAttribute('field'));
+ });
+
+ $scope.fields = ids;
+
+ return headerList;
+ }
+
+ function getTableConfig(tableCode) {
+ return $http.get(`/api/UserConfigViews/getConfig?tableCode=${tableCode}`);
+ }
+
+ function createViewConfig(config, fields) {
+ fields.forEach(field => {
+ if (config.configuration[field] == null)
+ config.configuration[field] = true;
+ });
+ }
+
+ function addHideClass($scope, headerList, userConfig) {
+ let selectors = [];
+ Object.keys(userConfig.configuration).forEach(key => {
+ let index;
+ if (userConfig.configuration[key] === false) {
+ index = headerList.findIndex(el => {
+ return (el.getAttribute('th-id') == key || el.getAttribute('field') == key);
+ });
+
+ let baseSelector = `vn-table[vn-uvc=${userConfig.tableCode}] > div`;
+ selectors.push(`${baseSelector} vn-thead > vn-tr > vn-th:nth-child(${index + 1})`);
+ selectors.push(`${baseSelector} vn-tbody > vn-tr > vn-td:nth-child(${index + 1})`);
+ selectors.push(`${baseSelector} vn-tbody > .vn-tr > vn-td:nth-child(${index + 1})`);
+ }
+ });
+
+ let rule = selectors.join(', ') + '{display: none;}';
+ if ($scope.css)
+ document.head.removeChild($scope.css);
+
+ $scope.css = document.createElement('style');
+ document.head.appendChild($scope.css);
+ $scope.css.appendChild(document.createTextNode(rule));
+ }
+
+ function saveConfiguration(tableConfiguration) {
+ tableConfiguration.configuration = JSON.parse(JSON.stringify(tableConfiguration.configuration));
+ return $http.post(`/api/UserConfigViews/save`, tableConfiguration);
+ }
+
+ return {
+ restrict: 'A',
+ link: async function($scope, $element, $attrs) {
+ let cTemplate = $compile(template)($scope)[0];
+ $scope.$ctrl.showUvc = event => {
+ event.preventDefault();
+ event.stopImmediatePropagation();
+ $scope.uvc.show();
+ };
+
+ let tableCode = $attrs.vnUvc.trim();
+ let headerList = getHeaderList($element, $scope);
+
+ let defaultConfigView = {tableCode: tableCode, configuration: {}};
+ let userView = await getTableConfig(tableCode);
+ let config = userView.data || defaultConfigView;
+
+ $scope.tableConfiguration = config;
+ createViewConfig(config, $scope.fields);
+
+ addHideClass($scope, headerList, config);
+
+ let table = document.querySelector(`vn-table[vn-uvc=${tableCode}]`);
+
+ table.insertBefore(cTemplate, table.firstChild);
+ $scope.$ctrl.saveConfiguration = async tableConfiguration => {
+ let newConfig = await saveConfiguration(tableConfiguration);
+ vnApp.showSuccess($translate.instant('Data saved!'));
+ addHideClass($scope, headerList, newConfig.data);
+ $scope.uvc.hide();
+ };
+ }
+ };
+}
+ngModule.directive('vnUvc', directive);
diff --git a/front/core/lib/module-loader.js b/front/core/lib/module-loader.js
index 163d103bb..477b1c943 100644
--- a/front/core/lib/module-loader.js
+++ b/front/core/lib/module-loader.js
@@ -19,7 +19,7 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t
if (loaded[moduleName] instanceof Promise)
return loaded[moduleName];
if (loaded[moduleName] === false)
- return $q.reject(new Error(`Module dependency loop detected: ${moduleName}`));
+ return Promise.resolve(true);
loaded[moduleName] = false;
@@ -37,10 +37,7 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t
$translatePartialLoader.addPart(moduleName);
promises.push(new Promise(resolve => {
- $translate.refresh().then(
- () => resolve(),
- () => resolve()
- );
+ $translate.refresh().then(resolve, resolve);
}));
if (validations) {
diff --git a/front/core/lib/specs/module-loader.spec.js b/front/core/lib/specs/module-loader.spec.js
index c8def1634..bc705f40f 100644
--- a/front/core/lib/specs/module-loader.spec.js
+++ b/front/core/lib/specs/module-loader.spec.js
@@ -28,19 +28,5 @@ describe('factory vnModuleLoader', () => {
expect(result).toEqual(jasmine.any(Promise));
});
-
- it('should return an error if the module wasnt loaded', done => {
- vnModuleLoader._loaded.myModule = false;
-
- vnModuleLoader.load('myModule', {myValidations: () => {}})
- .then(() => {
- done.fail('this must fail');
- })
- .catch(error => {
- expect(error.toString()).toEqual(`Error: Module dependency loop detected: myModule`);
- done();
- });
- $scope.$apply();
- });
});
});
diff --git a/front/core/locale/es.yml b/front/core/locale/es.yml
index 3cd6428f3..2a5af89ce 100644
--- a/front/core/locale/es.yml
+++ b/front/core/locale/es.yml
@@ -38,4 +38,5 @@ October: Octubre
November: Noviembre
December: Diciembre
Has delivery: Hay reparto
-Loading: Cargando
\ No newline at end of file
+Loading: Cargando
+Fields to show: Campos a mostrar
\ No newline at end of file
diff --git a/front/salix/components/user-configuration-popover/index.js b/front/salix/components/user-configuration-popover/index.js
index 18a8aae7e..5f8eeb330 100644
--- a/front/salix/components/user-configuration-popover/index.js
+++ b/front/salix/components/user-configuration-popover/index.js
@@ -92,7 +92,7 @@ class Controller {
this.company = value;
if (value &&
(!window.localStorage.localCompanyFk || window.localStorage.localCompanyFk === 'null'))
- window.localStorage.defaultCompanyFk = value;
+ window.localStorage.setItem('localCompanyFk', value);
this.setUserConfig('companyFk', value);
}
@@ -118,13 +118,13 @@ class Controller {
if (res.data && res.data.warehouseFk) {
this.warehouse = res.data.warehouseFk;
if (res.data.warehouseFk && !window.localStorage.localWarehouseFk)
- window.localStorage.defaultWarehouseFk = res.data.warehouseFk;
+ window.localStorage.setItem('localWarehouseFk', res.data.warehouseFk);
}
if (res.data && res.data.companyFk) {
this.company = res.data.companyFk;
if (res.data.companyFk && !window.localStorage.localCompanyFk)
- window.localStorage.defaultCompanyFk = res.data.companyFk;
+ window.localStorage.setItem('defaultCompanyFk', res.data.companyFk);
}
});
}
diff --git a/gulpfile.js b/gulpfile.js
index d668b98ae..b8394b8fb 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -74,7 +74,7 @@ defaultTask.description = `Starts all application services`;
// Backend tests
-async function backTestOnly() {
+async function backTestOnce() {
let bootOptions;
if (argv['random'])
@@ -107,11 +107,19 @@ async function backTestOnly() {
await app.disconnect();
}
-backTestOnly.description = `Runs the backend tests only, can receive --junit arg to save reports on a xml file`;
+backTestOnce.description = `Runs the backend tests once, can receive --junit arg to save reports on a xml file`;
+
+async function backTestDockerOnce() {
+ let containerId = await docker();
+ await backTestOnce();
+ if (argv['random'])
+ await execP(`docker rm -fv ${containerId}`);
+}
+backTestDockerOnce.description = `Runs backend tests using in site container once`;
async function backTestDocker() {
let containerId = await docker();
- await backTestOnly();
+ await backTest();
if (argv['random'])
await execP(`docker rm -fv ${containerId}`);
}
@@ -122,7 +130,7 @@ function backTest(done) {
nodemon({
exec: ['node ./node_modules/gulp/bin/gulp.js'],
- args: ['backTestOnly'],
+ args: ['backTestOnce'],
watch: backSources,
done: done
});
@@ -484,8 +492,9 @@ module.exports = {
back,
backOnly,
backWatch,
+ backTestOnce,
+ backTestDockerOnce,
backTest,
- backTestOnly,
backTestDocker,
e2e,
e2eOnly,
diff --git a/modules/agency/front/location/index.js b/modules/agency/front/location/index.js
index cdb89829a..92e893297 100644
--- a/modules/agency/front/location/index.js
+++ b/modules/agency/front/location/index.js
@@ -10,7 +10,7 @@ class Controller {
}
onSearch() {
- this.$scope.$$postDigest(() => {
+ this.$scope.$applyAsync(() => {
this.$scope.treeview.refresh();
});
}
diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js
index 316fd2ef6..cc047c608 100644
--- a/modules/item/back/methods/item/filter.js
+++ b/modules/item/back/methods/item/filter.js
@@ -32,12 +32,19 @@ module.exports = Self => {
let stmt = new ParameterizedSQL(
`SELECT i.id, i.image, i.name, i.description,
i.size, i.tag5, i.value5, i.tag6, i.value6,
- i.tag7, i.value7, i.tag8, i.value8,
- t.name type, u.nickname userNickname
+ i.tag7, i.value7, i.tag8, i.value8, i.isActive,
+ t.name type, u.nickname userNickname,
+ intr.description AS intrastat, i.stems,
+ ori.code AS origin, t.name AS type,
+ ic.name AS category
FROM item i
JOIN itemType t ON t.id = i.typeFk
+ LEFT JOIN itemCategory ic ON ic.id = t.categoryFk
JOIN worker w ON w.id = t.workerFk
- JOIN account.user u ON u.id = w.userFk`
+ JOIN account.user u ON u.id = w.userFk
+ LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
+ LEFT JOIN producer pr ON pr.id = i.producerFk
+ LEFT JOIN origin ori ON ori.id = i.originFk`
);
if (tags) {
diff --git a/modules/item/front/descriptor/index.html b/modules/item/front/descriptor/index.html
index 56f64c3aa..02e1267dc 100644
--- a/modules/item/front/descriptor/index.html
+++ b/modules/item/front/descriptor/index.html
@@ -92,7 +92,7 @@
- Regularize
+ Regularize stock
{
+ this.$scope.$applyAsync(() => {
if (this.$stateParams.warehouseFk)
this.warehouseFk = this.$stateParams.warehouseFk;
else if (value)
diff --git a/modules/item/front/diary/index.spec.js b/modules/item/front/diary/index.spec.js
index 454a8b25f..9286f2863 100644
--- a/modules/item/front/diary/index.spec.js
+++ b/modules/item/front/diary/index.spec.js
@@ -69,23 +69,23 @@ describe('Item', () => {
describe('set item()', () => {
it(`should set warehouseFk property based on itemType warehouseFk`, () => {
- spyOn(controller.$scope, '$$postDigest').and.callThrough();
+ spyOn(controller.$scope, '$applyAsync').and.callThrough();
controller.item = {id: 1, itemType: {warehouseFk: 1}};
- expect(controller.$scope.$$postDigest).toHaveBeenCalledWith(jasmine.any(Function));
- $scope.$digest();
+ expect(controller.$scope.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
+ $scope.$apply();
expect(controller.warehouseFk).toEqual(1);
expect(controller.item.id).toEqual(1);
});
it(`should set warehouseFk property based on url query warehouseFk`, () => {
- spyOn(controller.$scope, '$$postDigest').and.callThrough();
+ spyOn(controller.$scope, '$applyAsync').and.callThrough();
controller.$stateParams.warehouseFk = 4;
controller.item = {id: 1, itemType: {warehouseFk: 1}};
- expect(controller.$scope.$$postDigest).toHaveBeenCalledWith(jasmine.any(Function));
- $scope.$digest();
+ expect(controller.$scope.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
+ $scope.$apply();
expect(controller.warehouseFk).toEqual(4);
expect(controller.item.id).toEqual(1);
diff --git a/modules/item/front/index.js b/modules/item/front/index.js
index c2f9a66f6..3bb2942a8 100644
--- a/modules/item/front/index.js
+++ b/modules/item/front/index.js
@@ -7,10 +7,6 @@ import './create';
import './card';
import './descriptor';
import './descriptor-popover';
-import './ticket-descriptor';
-import './ticket-descriptor/addStowaway';
-import './ticket-descriptor/removeStowaway';
-import './ticket-descriptor-popover';
import './data';
import './tags';
import './tax';
diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html
index e2d2df6e5..d4def30a2 100644
--- a/modules/item/front/index/index.html
+++ b/modules/item/front/index/index.html
@@ -1,10 +1,10 @@
+ auto-load="true">
@@ -17,23 +17,76 @@
vn-focus>
-
-
-
-
+
+
+
+
+
+
+ Id
+ Description
+ Stems
+ Type
+ Category
+ Intrastat
+ Origin
+ Sales person
+ Active
+
+
+
+
+
+
+
+
+ {{::item.id | zeroFill:6}}
+
+
+
+
+ {{::item.stems}}
+ {{::item.type}}
+ {{::item.category}}
+ {{::item.intrastat}}
+ {{::item.origin}}
+ {{::item.userNickname}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
No results
-
- Enter a new search
-
-
-
-
+
+
+
diff --git a/modules/item/front/index/index.js b/modules/item/front/index/index.js
index 7926c33c6..e2decd07b 100644
--- a/modules/item/front/index/index.js
+++ b/modules/item/front/index/index.js
@@ -8,6 +8,12 @@ class Controller {
this.$state = $state;
this.$ = $scope;
this.itemSelected = null;
+ this.imagesPath = '//verdnatura.es/vn-image-data/catalog';
+
+ this.showFields = {
+ id: false,
+ actions: false
+ };
}
exprBuilder(param, value) {
@@ -25,6 +31,23 @@ class Controller {
}
}
+ showDescriptor(event, itemFk) {
+ this.quicklinks = {
+ btnThree: {
+ icon: 'icon-transaction',
+ state: `item.card.diary({
+ id: ${itemFk},
+ warehouseFk: ${this.ticket.warehouseFk},
+ ticketFk: ${this.ticket.id}
+ })`,
+ tooltip: 'Item diary'
+ }
+ };
+ this.$scope.descriptor.itemFk = itemFk;
+ this.$scope.descriptor.parent = event.target;
+ this.$scope.descriptor.show();
+ }
+
paramBuilder(param, value) {
switch (param) {
case 'tags':
@@ -32,7 +55,9 @@ class Controller {
}
}
- cloneItem(item) {
+ cloneItem(event, item) {
+ event.preventDefault();
+ event.stopImmediatePropagation();
this.itemSelected = item;
this.$.clone.show();
}
@@ -49,7 +74,9 @@ class Controller {
this.itemSelected = null;
}
- showItemPreview(item) {
+ preview(event, item) {
+ event.preventDefault();
+ event.stopImmediatePropagation();
this.itemSelected = item;
this.$.preview.show();
}
diff --git a/modules/item/front/index/style.scss b/modules/item/front/index/style.scss
index d360f8337..a349e1f8e 100644
--- a/modules/item/front/index/style.scss
+++ b/modules/item/front/index/style.scss
@@ -25,3 +25,10 @@ vn-item-product {
margin-top: 0.9em;
}
}
+
+vn-table {
+ img {
+ border-radius: 50%;
+ max-width: 50px;
+ }
+}
\ No newline at end of file
diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json
index b81625e06..35651ef5b 100644
--- a/modules/item/front/routes.json
+++ b/modules/item/front/routes.json
@@ -3,7 +3,7 @@
"name": "Items",
"icon": "inbox",
"validations" : true,
- "dependencies": ["client"],
+ "dependencies": ["client", "ticket"],
"menu": [
{"state": "item.card.data", "icon": "settings"},
{"state": "item.card.tags", "icon": "icon-tags"},
diff --git a/modules/item/front/ticket-descriptor-popover/index.spec.js b/modules/item/front/ticket-descriptor-popover/index.spec.js
deleted file mode 100644
index 9e3d39e4b..000000000
--- a/modules/item/front/ticket-descriptor-popover/index.spec.js
+++ /dev/null
@@ -1,126 +0,0 @@
-import './index.js';
-
-describe('Item', () => {
- describe('Component vnTicketDescriptorPopover', () => {
- let $httpBackend;
- let $scope;
- let controller;
- let $element;
- let $timeout;
-
- beforeEach(ngModule('item'));
-
- beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$timeout_) => {
- $httpBackend = _$httpBackend_;
- $timeout = _$timeout_;
- $element = angular.element(``);
- $scope = $rootScope.$new();
- $scope.popover = {relocate: () => {}, show: () => {}};
- controller = $componentController('vnTicketDescriptorPopover', {$scope, $element});
- }));
-
- describe('ticketFk()', () => {
- it(`should not apply any changes if the received id is the same stored in _ticketFk`, () => {
- controller.ticket = 'I exist!';
- controller._ticketFk = 1;
- spyOn(controller, 'getCard');
- controller.ticketFk = 1;
-
- expect(controller.ticket).toEqual('I exist!');
- expect(controller._ticketFk).toEqual(1);
- expect(controller.getCard).not.toHaveBeenCalled();
- });
-
- it(`should set the received id into _ticketFk, set the ticket to null and then call getCard()`, () => {
- controller.ticket = `Please don't`;
- controller._ticketFk = 1;
- spyOn(controller, 'getCard');
- controller.ticketFk = 999;
-
- expect(controller.ticket).toBeNull();
- expect(controller._ticketFk).toEqual(999);
- expect(controller.getCard).toHaveBeenCalledWith();
- });
- });
-
- describe('ticket()', () => {
- it(`should save the ticket into _ticket and then call relocate()`, () => {
- spyOn(controller.$.popover, 'relocate');
- controller.ticket = `i'm the ticket!`;
- $timeout.flush();
-
- expect(controller._ticket).toEqual(`i'm the ticket!`);
- expect(controller.$.popover.relocate).toHaveBeenCalledWith();
- });
- });
-
- describe('show()', () => {
- it(`should call the show()`, () => {
- spyOn(controller.$.popover, 'show');
- controller.show();
-
- expect(controller.$.popover.show).toHaveBeenCalledWith();
- });
- });
-
- describe('getCard()', () => {
- it(`should perform a get query to store the ticket data into the controller`, () => {
- controller.ticketFk = 1;
- controller.canceler = null;
- let response = {};
-
- let filter = {
- include: [
- {
- relation: 'warehouse',
- scope: {
- fields: ['name']
- }
- },
- {
- relation: 'agencyMode',
- scope: {
- fields: ['name']
- }
- },
- {
- relation: 'client',
- scope: {
- fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'],
- include: {
- relation: 'salesPerson',
- scope: {
- fields: ['userFk'],
- include: {
- relation: 'user',
- scope: {
- fields: ['nickname']
- }
- }
- }
- }
- }
- },
- {
- relation: 'state',
- scope: {
- fields: ['stateFk'],
- include: {
- relation: 'state',
- fields: ['id', 'name'],
- }
- }
- }
- ]
- };
- let json = encodeURIComponent(JSON.stringify(filter));
- $httpBackend.when('GET', `/ticket/api/Tickets/${controller._ticketFk}?filter=${json}`).respond(response);
- $httpBackend.expect('GET', `/ticket/api/Tickets/${controller._ticketFk}?filter=${json}`);
- controller.getCard();
- $httpBackend.flush();
-
- expect(controller.ticket).toEqual(response);
- });
- });
- });
-});
diff --git a/modules/order/back/methods/order-row/specs/addToOrder.spec.js b/modules/order/back/methods/order-row/specs/addToOrder.spec.js
index e938cb859..13dfe26fb 100644
--- a/modules/order/back/methods/order-row/specs/addToOrder.spec.js
+++ b/modules/order/back/methods/order-row/specs/addToOrder.spec.js
@@ -3,16 +3,16 @@ const app = require('vn-loopback/server/server');
describe('order addToOrder()', () => {
let rowToDelete;
afterAll(async() => {
- await app.models.OrderRow.removes({rows: [rowToDelete], actualOrderId: 16});
+ await app.models.OrderRow.removes({rows: [rowToDelete], actualOrderId: 20});
});
it('should add a row to a given order', async() => {
- let unmodifiedRows = await app.models.OrderRow.find({where: {orderFk: 16}});
+ let unmodifiedRows = await app.models.OrderRow.find({where: {orderFk: 20}});
- expect(unmodifiedRows.length).toBe(4);
+ expect(unmodifiedRows.length).toBe(1);
let params = {
- orderFk: 16,
+ orderFk: 20,
items: [{
itemFk: 1,
quantity: 1,
@@ -22,10 +22,10 @@ describe('order addToOrder()', () => {
await app.models.OrderRow.addToOrder(params);
- let modifiedRows = await app.models.OrderRow.find({where: {orderFk: 16}});
+ let modifiedRows = await app.models.OrderRow.find({where: {orderFk: 20}});
rowToDelete = modifiedRows[modifiedRows.length - 1].id;
- expect(modifiedRows.length).toBe(5);
+ expect(modifiedRows.length).toBe(2);
});
});
diff --git a/modules/order/front/filter/index.js b/modules/order/front/filter/index.js
index 9f1013b35..c2bfb8e4b 100644
--- a/modules/order/front/filter/index.js
+++ b/modules/order/front/filter/index.js
@@ -28,7 +28,7 @@ class Controller {
this._order = value;
- this.$scope.$$postDigest(() => {
+ this.$scope.$applyAsync(() => {
let category;
let type;
diff --git a/modules/order/front/filter/index.spec.js b/modules/order/front/filter/index.spec.js
index 3d9888c57..c31e87500 100644
--- a/modules/order/front/filter/index.spec.js
+++ b/modules/order/front/filter/index.spec.js
@@ -6,10 +6,12 @@ describe('Order', () => {
let $scope;
let $state;
let controller;
+ let $httpBackend;
beforeEach(ngModule('order'));
- beforeEach(angular.mock.inject(($componentController, _$state_, $rootScope) => {
+ beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_, $rootScope) => {
+ $httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
$scope.model = crudModel;
$scope.search = {};
@@ -27,12 +29,14 @@ describe('Order', () => {
}));
describe('order() setter', () => {
- it(`should call scope $$postDigest() method and apply filters from state params`, () => {
- spyOn(controller.$scope, '$$postDigest').and.callThrough();
+ it(`should call scope $applyAsync() method and apply filters from state params`, () => {
+ $httpBackend.expect('GET', `/item/api/ItemCategories/1/itemTypes`).respond();
+ spyOn(controller.$scope, '$applyAsync').and.callThrough();
controller.order = {id: 4};
- expect(controller.$scope.$$postDigest).toHaveBeenCalledWith(jasmine.any(Function));
- $scope.$digest();
+ expect(controller.$scope.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
+ $scope.$apply();
+
expect(controller.category).toEqual({id: 1, value: 'My Category'});
expect(controller.type).toEqual({id: 1, value: 'My type'});
@@ -96,28 +100,38 @@ describe('Order', () => {
});
describe('applyFilters()', () => {
- it(`should set type property to null, call updateStateParams() method and not call applyFilters()`, () => {
- spyOn(controller.catalog.$scope.model, 'applyFilter');
- controller.order = {id: 4};
- $scope.$digest();
+ it(`should call model applyFilter() method with a new filter`, () => {
+ let model = controller.catalog.$scope.model;
+ spyOn(model, 'applyFilter');
+ controller._category = {id: 1, value: 'My Category'};
+ controller._type = {id: 1, value: 'My type'};
+ controller._order = {id: 4};
+
controller.applyFilters();
- expect(controller.catalog.$scope.model.applyFilter).toHaveBeenCalledWith(
+ expect(model.applyFilter).toHaveBeenCalledWith(
{where: {categoryFk: 1, typeFk: 1}},
{orderFk: 4, orderBy: controller.catalog.getOrderBy(), tags: []});
});
});
describe('remove()', () => {
- it(`should remove a filter from tags property and then call applyFilters()`, () => {
- spyOn(controller, 'applyFilters');
- controller.order = {id: 4};
+ it(`should remove a tag from tags property`, () => {
controller.tags = [{tagFk: 1, value: 'Blue'}, {tagFk: 2, value: '70'}];
- $scope.$digest();
controller.remove(0);
expect(controller.tags.length).toEqual(1);
expect(controller.tags[0].tagFk).toEqual(2);
+ });
+
+ it(`should remove a tag from tags property and call applyFilters() if there's no more tags`, () => {
+ spyOn(controller, 'applyFilters');
+ controller._category = {id: 1, value: 'My Category'};
+ controller._type = {id: 1, value: 'My type'};
+ controller.tags = [{tagFk: 1, value: 'Blue'}];
+ controller.remove(0);
+
+ expect(controller.tags.length).toEqual(0);
expect(controller.applyFilters).toHaveBeenCalledWith();
});
});
@@ -125,10 +139,10 @@ describe('Order', () => {
describe('updateStateParams()', () => {
it(`should call state go() method passing category and type state params`, () => {
spyOn(controller.$state, 'go');
- controller.order = {id: 4};
- $scope.$digest();
-
+ controller._category = {id: 1, value: 'My Category'};
+ controller._type = {id: 1, value: 'My type'};
let result = {category: '{"id":1,"value":"My Category"}', type: '{"id":1,"value":"My type"}'};
+ controller.updateStateParams();
expect(controller.$state.go).toHaveBeenCalledWith('my.current.state', result);
});
diff --git a/modules/order/front/prices-popover/index.js b/modules/order/front/prices-popover/index.js
index c44ff7109..e89f04774 100644
--- a/modules/order/front/prices-popover/index.js
+++ b/modules/order/front/prices-popover/index.js
@@ -35,6 +35,9 @@ class Controller {
};
this.$http.get(`/item/api/ItemTags?filter=${JSON.stringify(filter)}`).then(response => {
this.tags = response.data;
+ this.$.$applyAsync(() => {
+ this.$.popover.relocate();
+ });
});
}
show(event, item) {
@@ -42,8 +45,8 @@ class Controller {
this.prices = this.item.prices;
this.getTags();
this.$.popover.parent = event.target;
- this.$.popover.relocate();
this.$.popover.show();
+ this.$.popover.relocate();
}
clear() {
this.item = {};
diff --git a/modules/ticket/back/methods/ticket/specs/getSales.spec.js b/modules/ticket/back/methods/ticket/specs/getSales.spec.js
index 121b02195..da44716cf 100644
--- a/modules/ticket/back/methods/ticket/specs/getSales.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/getSales.spec.js
@@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server');
describe('ticket getSales()', () => {
- it('should return the sales of a ticket', async () => {
+ it('should return the sales of a ticket', async() => {
let sales = await app.models.Ticket.getSales(16);
expect(sales.length).toEqual(4);
diff --git a/modules/item/front/ticket-descriptor-popover/index.html b/modules/ticket/front/descriptor-popover/index.html
similarity index 100%
rename from modules/item/front/ticket-descriptor-popover/index.html
rename to modules/ticket/front/descriptor-popover/index.html
diff --git a/modules/item/front/ticket-descriptor-popover/index.js b/modules/ticket/front/descriptor-popover/index.js
similarity index 100%
rename from modules/item/front/ticket-descriptor-popover/index.js
rename to modules/ticket/front/descriptor-popover/index.js
diff --git a/modules/ticket/front/descriptor-popover/index.spec.js b/modules/ticket/front/descriptor-popover/index.spec.js
new file mode 100644
index 000000000..499ca5413
--- /dev/null
+++ b/modules/ticket/front/descriptor-popover/index.spec.js
@@ -0,0 +1,125 @@
+import './index.js';
+
+describe('ticket Component vnTicketDescriptorPopover', () => {
+ let $httpBackend;
+ let $scope;
+ let controller;
+ let $element;
+ let $timeout;
+
+ beforeEach(ngModule('ticket'));
+
+ beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$timeout_) => {
+ $httpBackend = _$httpBackend_;
+ $timeout = _$timeout_;
+ $element = angular.element(``);
+ $scope = $rootScope.$new();
+ $scope.popover = {relocate: () => {}, show: () => {}};
+ controller = $componentController('vnTicketDescriptorPopover', {$scope, $element});
+ }));
+
+ describe('ticketFk()', () => {
+ it(`should not apply any changes if the received id is the same stored in _ticketFk`, () => {
+ controller.ticket = 'I exist!';
+ controller._ticketFk = 1;
+ spyOn(controller, 'getCard');
+ controller.ticketFk = 1;
+
+ expect(controller.ticket).toEqual('I exist!');
+ expect(controller._ticketFk).toEqual(1);
+ expect(controller.getCard).not.toHaveBeenCalled();
+ });
+
+ it(`should set the received id into _ticketFk, set the ticket to null and then call getCard()`, () => {
+ controller.ticket = `Please don't`;
+ controller._ticketFk = 1;
+ spyOn(controller, 'getCard');
+ controller.ticketFk = 999;
+
+ expect(controller.ticket).toBeNull();
+ expect(controller._ticketFk).toEqual(999);
+ expect(controller.getCard).toHaveBeenCalledWith();
+ });
+ });
+
+ describe('ticket()', () => {
+ it(`should save the ticket into _ticket and then call relocate()`, () => {
+ spyOn(controller.$.popover, 'relocate');
+ controller.ticket = `i'm the ticket!`;
+ $timeout.flush();
+
+ expect(controller._ticket).toEqual(`i'm the ticket!`);
+ expect(controller.$.popover.relocate).toHaveBeenCalledWith();
+ });
+ });
+
+ describe('show()', () => {
+ it(`should call the show()`, () => {
+ spyOn(controller.$.popover, 'show');
+ controller.show();
+
+ expect(controller.$.popover.show).toHaveBeenCalledWith();
+ });
+ });
+
+ describe('getCard()', () => {
+ it(`should perform a get query to store the ticket data into the controller`, () => {
+ controller.ticketFk = 1;
+ controller.canceler = null;
+ let response = {};
+
+ let filter = {
+ include: [
+ {
+ relation: 'warehouse',
+ scope: {
+ fields: ['name']
+ }
+ },
+ {
+ relation: 'agencyMode',
+ scope: {
+ fields: ['name']
+ }
+ },
+ {
+ relation: 'client',
+ scope: {
+ fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'],
+ include: {
+ relation: 'salesPerson',
+ scope: {
+ fields: ['userFk'],
+ include: {
+ relation: 'user',
+ scope: {
+ fields: ['nickname']
+ }
+ }
+ }
+ }
+ }
+ },
+ {
+ relation: 'state',
+ scope: {
+ fields: ['stateFk'],
+ include: {
+ relation: 'state',
+ fields: ['id', 'name'],
+ }
+ }
+ }
+ ]
+ };
+ let json = encodeURIComponent(JSON.stringify(filter));
+ $httpBackend.when('GET', `/ticket/api/Tickets/${controller._ticketFk}?filter=${json}`).respond(response);
+ $httpBackend.expect('GET', `/ticket/api/Tickets/${controller._ticketFk}?filter=${json}`);
+ controller.getCard();
+ $httpBackend.flush();
+
+ expect(controller.ticket).toEqual(response);
+ });
+ });
+});
+
diff --git a/modules/item/front/ticket-descriptor-popover/style.scss b/modules/ticket/front/descriptor-popover/style.scss
similarity index 100%
rename from modules/item/front/ticket-descriptor-popover/style.scss
rename to modules/ticket/front/descriptor-popover/style.scss
diff --git a/modules/item/front/ticket-descriptor/addStowaway.html b/modules/ticket/front/descriptor/addStowaway.html
similarity index 100%
rename from modules/item/front/ticket-descriptor/addStowaway.html
rename to modules/ticket/front/descriptor/addStowaway.html
diff --git a/modules/item/front/ticket-descriptor/addStowaway.js b/modules/ticket/front/descriptor/addStowaway.js
similarity index 100%
rename from modules/item/front/ticket-descriptor/addStowaway.js
rename to modules/ticket/front/descriptor/addStowaway.js
diff --git a/modules/item/front/ticket-descriptor/index.html b/modules/ticket/front/descriptor/index.html
similarity index 100%
rename from modules/item/front/ticket-descriptor/index.html
rename to modules/ticket/front/descriptor/index.html
diff --git a/modules/item/front/ticket-descriptor/index.js b/modules/ticket/front/descriptor/index.js
similarity index 100%
rename from modules/item/front/ticket-descriptor/index.js
rename to modules/ticket/front/descriptor/index.js
diff --git a/modules/item/front/ticket-descriptor/index.spec.js b/modules/ticket/front/descriptor/index.spec.js
similarity index 96%
rename from modules/item/front/ticket-descriptor/index.spec.js
rename to modules/ticket/front/descriptor/index.spec.js
index 51293f462..2c2359299 100644
--- a/modules/item/front/ticket-descriptor/index.spec.js
+++ b/modules/ticket/front/descriptor/index.spec.js
@@ -1,12 +1,10 @@
import './index.js';
-describe('Item Component vnTicketDescriptor', () => {
+describe('Ticket Component vnTicketDescriptor', () => {
let $httpBackend;
let controller;
- beforeEach(() => {
- ngModule('item');
- });
+ beforeEach(ngModule('ticket'));
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
diff --git a/modules/item/front/ticket-descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml
similarity index 100%
rename from modules/item/front/ticket-descriptor/locale/es.yml
rename to modules/ticket/front/descriptor/locale/es.yml
diff --git a/modules/item/front/ticket-descriptor/removeStowaway.html b/modules/ticket/front/descriptor/removeStowaway.html
similarity index 100%
rename from modules/item/front/ticket-descriptor/removeStowaway.html
rename to modules/ticket/front/descriptor/removeStowaway.html
diff --git a/modules/item/front/ticket-descriptor/removeStowaway.js b/modules/ticket/front/descriptor/removeStowaway.js
similarity index 100%
rename from modules/item/front/ticket-descriptor/removeStowaway.js
rename to modules/ticket/front/descriptor/removeStowaway.js
diff --git a/modules/item/front/ticket-descriptor/style.scss b/modules/ticket/front/descriptor/style.scss
similarity index 100%
rename from modules/item/front/ticket-descriptor/style.scss
rename to modules/ticket/front/descriptor/style.scss
diff --git a/modules/ticket/front/index.js b/modules/ticket/front/index.js
index 325dc11d8..1269a60db 100644
--- a/modules/ticket/front/index.js
+++ b/modules/ticket/front/index.js
@@ -3,6 +3,10 @@ export * from './module';
import './index/';
import './search-panel';
import './card';
+import './descriptor';
+import './descriptor/addStowaway';
+import './descriptor/removeStowaway';
+import './descriptor-popover';
import './create/card';
import './create/index';
import './summary';
diff --git a/package.json b/package.json
index cea470bbc..3a587e8e0 100644
--- a/package.json
+++ b/package.json
@@ -83,7 +83,6 @@
"yaml-loader": "^0.5.0"
},
"scripts": {
- "test": "nodemon -q back/tests.js -w modules",
"dbtest": "nodemon -q services/db/tests.js -w services/db/tests",
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",
"lint": "eslint ./ --cache --ignore-pattern .gitignore",
diff --git a/services/db/install/changes/1.2-CHECK/01-workerDepartment.sql b/services/db/install/changes/1.2-CHECK/01-workerDepartment.sql
new file mode 100644
index 000000000..b52f29182
--- /dev/null
+++ b/services/db/install/changes/1.2-CHECK/01-workerDepartment.sql
@@ -0,0 +1,18 @@
+USE `vn`;
+CREATE
+ OR REPLACE ALGORITHM = UNDEFINED
+ DEFINER = `root`@`%`
+ SQL SECURITY DEFINER
+VIEW `vn`.`workerDepartment` AS
+ SELECT
+ `p`.`id_trabajador` AS `workerFk`,
+ `d`.`id` AS `departmentFk`
+ FROM
+ (((`postgresql`.`person` `p`
+ JOIN `postgresql`.`profile` `pr` ON ((`pr`.`person_id` = `p`.`person_id`)))
+ LEFT JOIN (`postgresql`.`business` `b`
+ LEFT JOIN `postgresql`.`business_labour` `bl` ON ((`b`.`business_id` = `bl`.`business_id`))) ON ((`pr`.`profile_id` = `b`.`client_id`)))
+ JOIN `vn`.`department` `d` ON ((`d`.`id` = `bl`.`department_id`)))
+ WHERE
+ (ISNULL(`b`.`date_end`)
+ OR (`b`.`date_end` > CURDATE()));
diff --git a/services/db/install/changes/1.2-CHECK/02-orderAddItem.sql b/services/db/install/changes/1.2-CHECK/02-orderAddItem.sql
new file mode 100644
index 000000000..35bee1117
--- /dev/null
+++ b/services/db/install/changes/1.2-CHECK/02-orderAddItem.sql
@@ -0,0 +1,108 @@
+USE `hedera`;
+DROP procedure IF EXISTS `orderAddItem`;
+
+DELIMITER $$
+USE `hedera`$$
+CREATE DEFINER=`root`@`%` PROCEDURE `orderAddItem`(IN `vOrder` INT, IN `vWarehouse` INT, IN `vItem` INT, IN `vAmount` INT)
+BEGIN
+ DECLARE vRow INT;
+ DECLARE vAdd INT;
+ DECLARE vAvailable INT;
+ DECLARE vDone BOOL;
+ DECLARE vGrouping INT;
+ DECLARE vRate INT;
+ DECLARE vShipment DATE;
+ DECLARE vPrice DECIMAL(10,2);
+ DECLARE vDate DATE;
+ DECLARE vAddress INT;
+ DECLARE vAgencyMode INT;
+ DECLARE cur CURSOR FOR
+ SELECT grouping, price, rate
+ FROM tmp.bionic_price
+ WHERE warehouse_id = vWarehouse
+ AND item_id = vItem
+ ORDER BY grouping DESC;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
+ SET vDone = TRUE;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ SELECT date_send, address_id, agency_id
+ INTO vDate, vAddress, vAgencyMode
+ FROM `order`
+ WHERE id = vOrder;
+
+ CALL vn2008.bionic_from_item(vDate, vAddress, vAgencyMode, vItem);
+
+ START TRANSACTION;
+
+ SELECT shipped INTO vShipment
+ FROM tmp.travel_tree
+ WHERE warehouseFk = vWarehouse;
+
+ SELECT available INTO vAvailable
+ FROM tmp.bionic_lot
+ WHERE warehouse_id = vWarehouse
+ AND item_id = vItem;
+
+ IF vAmount > IFNULL(vAvailable, 0)
+ THEN
+ CALL util.throw ('ORDER_ROW_UNAVAILABLE');
+ END IF;
+
+ OPEN cur;
+
+ l: LOOP
+ SET vDone = FALSE;
+ FETCH cur INTO vGrouping, vPrice, vRate;
+
+ IF vDone THEN
+ LEAVE l;
+ END IF;
+
+ SET vAdd = vAmount - MOD(vAmount, vGrouping);
+ SET vAmount = vAmount - vAdd;
+
+ IF vAdd = 0 THEN
+ ITERATE l;
+ END IF;
+
+ INSERT INTO order_row SET
+ order_id = vOrder,
+ item_id = vItem,
+ warehouse_id = vWarehouse,
+ shipment = vShipment,
+ rate = vRate,
+ amount = vAdd,
+ price = vPrice;
+
+ SET vRow = LAST_INSERT_ID();
+
+ INSERT INTO order_component (order_row_id, component_id, price)
+ SELECT vRow, c.component_id, c.cost
+ FROM tmp.bionic_component c
+ JOIN bi.tarifa_componentes t
+ ON t.Id_Componente = c.component_id
+ AND (t.tarifa_class IS NULL OR t.tarifa_class = vRate)
+ WHERE c.warehouse_id = vWarehouse
+ AND c.item_id = vItem;
+ END LOOP;
+
+ CLOSE cur;
+
+ IF vAmount > 0
+ THEN
+ CALL util.throw ('AMOUNT_NOT_MATCH_GROUPING');
+ END IF;
+
+ COMMIT;
+ CALL vn2008.bionic_free ();
+END$$
+
+DELIMITER ;
+
diff --git a/services/db/install/changes/1.2-CHECK/03-acl.sql b/services/db/install/changes/1.2-CHECK/03-acl.sql
new file mode 100644
index 000000000..32ec03b5c
--- /dev/null
+++ b/services/db/install/changes/1.2-CHECK/03-acl.sql
@@ -0,0 +1 @@
+INSERT INTO salix.ACL(id,model, property, accessType, permission, principalType, principalId)VALUES(147,'UserConfigView', '*', '*', 'ALLOW', 'ROLE', 'employee');
\ No newline at end of file
diff --git a/services/db/install/dump/fixtures.sql b/services/db/install/dump/fixtures.sql
index 8ebe1bab9..d0ca86a36 100644
--- a/services/db/install/dump/fixtures.sql
+++ b/services/db/install/dump/fixtures.sql
@@ -860,103 +860,109 @@ INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`)
INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`, `date_make`, `first_row_stamp`, `confirm_date`)
VALUES
- (1 , DATE_ADD(CURDATE(), INTERVAL -15 DAY) , 101, 1, 1, 121, 442, NULL, 'TPV', 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY) , DATE_ADD(CURDATE(), INTERVAL -15 DAY) , DATE_ADD(CURDATE(), INTERVAL -15 DAY) ),
- (2 , DATE_ADD(CURDATE(), INTERVAL -10 DAY) , 101, 2, 1, 121, 442, NULL, 'WEB', 1, DATE_ADD(CURDATE(), INTERVAL -10 DAY) , DATE_ADD(CURDATE(), INTERVAL -10 DAY) , DATE_ADD(CURDATE(), INTERVAL -10 DAY) ),
- (3 , DATE_ADD(CURDATE(), INTERVAL -5 DAY) , 102, 3, 2, 122, 442, NULL, 'ANDROID', 1, DATE_ADD(CURDATE(), INTERVAL -5 DAY) , DATE_ADD(CURDATE(), INTERVAL -5 DAY) , DATE_ADD(CURDATE(), INTERVAL -5 DAY) ),
- (4 , DATE_ADD(CURDATE(), INTERVAL -4 DAY) , 102, 1, 2, 122, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -4 DAY) , DATE_ADD(CURDATE(), INTERVAL -4 DAY) , DATE_ADD(CURDATE(), INTERVAL -4 DAY) ),
- (5 , DATE_ADD(CURDATE(), INTERVAL -3 DAY) , 103, 2, 3, 123, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -3 DAY) , DATE_ADD(CURDATE(), INTERVAL -3 DAY) , DATE_ADD(CURDATE(), INTERVAL -3 DAY) ),
- (6 , DATE_ADD(CURDATE(), INTERVAL -2 DAY) , 103, 3, 3, 123, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -2 DAY) , DATE_ADD(CURDATE(), INTERVAL -2 DAY) , DATE_ADD(CURDATE(), INTERVAL -2 DAY) ),
- (7 , DATE_ADD(CURDATE(), INTERVAL -1 DAY) , 104, 1, 4, 124, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -1 DAY) , DATE_ADD(CURDATE(), INTERVAL -1 DAY) , DATE_ADD(CURDATE(), INTERVAL -1 DAY) ),
+ (1 , DATE_ADD(CURDATE(), INTERVAL -15 DAY), 101, 1, 1, 121, 442, NULL, 'TPV', 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY) , DATE_ADD(CURDATE(), INTERVAL -15 DAY) , DATE_ADD(CURDATE(), INTERVAL -15 DAY) ),
+ (2 , DATE_ADD(CURDATE(), INTERVAL -10 DAY), 101, 2, 1, 121, 442, NULL, 'WEB', 1, DATE_ADD(CURDATE(), INTERVAL -10 DAY) , DATE_ADD(CURDATE(), INTERVAL -10 DAY) , DATE_ADD(CURDATE(), INTERVAL -10 DAY) ),
+ (3 , DATE_ADD(CURDATE(), INTERVAL -5 DAY), 102, 3, 2, 122, 442, NULL, 'ANDROID', 1, DATE_ADD(CURDATE(), INTERVAL -5 DAY) , DATE_ADD(CURDATE(), INTERVAL -5 DAY) , DATE_ADD(CURDATE(), INTERVAL -5 DAY) ),
+ (4 , DATE_ADD(CURDATE(), INTERVAL -4 DAY), 102, 1, 2, 122, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -4 DAY) , DATE_ADD(CURDATE(), INTERVAL -4 DAY) , DATE_ADD(CURDATE(), INTERVAL -4 DAY) ),
+ (5 , DATE_ADD(CURDATE(), INTERVAL -3 DAY), 103, 2, 3, 123, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -3 DAY) , DATE_ADD(CURDATE(), INTERVAL -3 DAY) , DATE_ADD(CURDATE(), INTERVAL -3 DAY) ),
+ (6 , DATE_ADD(CURDATE(), INTERVAL -2 DAY), 103, 3, 3, 123, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -2 DAY) , DATE_ADD(CURDATE(), INTERVAL -2 DAY) , DATE_ADD(CURDATE(), INTERVAL -2 DAY) ),
+ (7 , DATE_ADD(CURDATE(), INTERVAL -1 DAY), 104, 1, 4, 124, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -1 DAY) , DATE_ADD(CURDATE(), INTERVAL -1 DAY) , DATE_ADD(CURDATE(), INTERVAL -1 DAY) ),
(8 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 104, 2, 4, 124, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
(9 , DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 105, 3, 5, 125, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH)),
(10, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), 105, 1, 6, 125, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH)),
- (11, CURDATE() , 101, 2, 7, 121, 442, NULL, 'SALIX', 1, CURDATE() , CURDATE() , CURDATE() ),
+ (11, CURDATE(), 101, 2, 7, 121, 442, NULL, 'SALIX', 1, CURDATE() , CURDATE() , CURDATE() ),
(12, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 101, 3, 1, 121, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
(13, DATE_ADD(CURDATE(), INTERVAL +2 MONTH), 101, 1, 2, 121, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL +2 MONTH), DATE_ADD(CURDATE(), INTERVAL +2 MONTH), DATE_ADD(CURDATE(), INTERVAL +2 MONTH)),
(14, DATE_ADD(CURDATE(), INTERVAL +3 MONTH), 101, 2, 2, 121, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL +3 MONTH), DATE_ADD(CURDATE(), INTERVAL +3 MONTH), DATE_ADD(CURDATE(), INTERVAL +3 MONTH)),
(15, DATE_ADD(CURDATE(), INTERVAL +4 MONTH), 101, 3, 3, 121, 442, NULL, 'SALIX', 1, DATE_ADD(CURDATE(), INTERVAL +4 MONTH), DATE_ADD(CURDATE(), INTERVAL +4 MONTH), DATE_ADD(CURDATE(), INTERVAL +4 MONTH)),
- (16, DATE_ADD(CURDATE(), INTERVAL +4 DAY) , 101, 1, 1, 121, 442, NULL, 'SALIX', 0, CURDATE() , CURDATE() , CURDATE() ),
- (17, CURDATE() , 106, 2, 4, 126, 442, NULL, 'SALIX', 0, CURDATE() , CURDATE() , CURDATE() ),
- (18, CURDATE() , 107, 3, 4, 127, 442, NULL, 'SALIX', 0, CURDATE() , CURDATE() , CURDATE() ),
- (19, CURDATE() , 108, 1, 5, 128, 442, NULL, 'SALIX', 0, CURDATE() , CURDATE() , CURDATE() ),
- (20, CURDATE() , 109, 2, 5, 119, 442, NULL, 'SALIX', 0, CURDATE() , CURDATE() , CURDATE() ),
- (21, CURDATE() , 110, 3, 5, 129, 442, NULL, 'SALIX', 0, CURDATE() , CURDATE() , CURDATE() );
+ (16, DATE_ADD(CURDATE(), INTERVAL +4 DAY), 101, 1, 1, 121, 442, NULL, 'SALIX', 0, CURDATE() , CURDATE() , CURDATE() ),
+ (17, CURDATE(), 106, 2, 4, 126, 442, NULL, 'SALIX', 0, CURDATE() , CURDATE() , CURDATE() ),
+ (18, CURDATE(), 107, 3, 4, 127, 442, NULL, 'SALIX', 0, CURDATE() , CURDATE() , CURDATE() ),
+ (19, CURDATE(), 108, 1, 5, 128, 442, NULL, 'SALIX', 0, CURDATE() , CURDATE() , CURDATE() ),
+ (20, CURDATE(), 109, 2, 1, 119, 442, NULL, 'SALIX', 0, CURDATE() , CURDATE() , CURDATE() ),
+ (21, CURDATE(), 110, 3, 5, 129, 442, NULL, 'SALIX', 0, CURDATE() , CURDATE() , CURDATE() );
INSERT INTO `hedera`.`orderRow`(`id`, `orderFk`, `itemFk`, `warehouseFk`, `shipment`, `amount`, `price`, `rate`, `created`, `saleFk`)
VALUES
- ( 1, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 5, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 1),
- ( 2, 1, 2, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 10, 1.07, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 2),
- ( 3, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 2, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 3),
- ( 4, 1, 4, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 20, 3.06, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 4),
- ( 5, 2, 1, 1, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 10, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 5),
- ( 6, 3, 1, 2, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 15, 6.50, 0, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 6),
- ( 7, 11, 2, 1, CURDATE(), 15, 1.30, 0, CURDATE(), 7),
- ( 8, 11, 4, 1, CURDATE(), 10, 3.26, 0, CURDATE(), 8),
- ( 9, 16, 1, 1, CURDATE(), 5, 9.10, 0, CURDATE(), 9),
- ( 10, 16, 2, 1, CURDATE(), 10, 1.07, 0, CURDATE(), 10),
- ( 11, 16, 1, 1, CURDATE(), 2, 9.10, 0, CURDATE(), 11),
- ( 12, 16, 4, 1, CURDATE(), 20, 3.06, 0, CURDATE(), 12);
+ (1, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 5, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 1),
+ (2, 1, 2, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 10, 1.07, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 2),
+ (3, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 2, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 3),
+ (4, 1, 4, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 20, 3.06, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 4),
+ (5, 2, 1, 1, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 10, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 5),
+ (6, 3, 1, 2, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 15, 6.50, 0, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 6),
+ (7, 11, 2, 1, CURDATE(), 15, 1.30, 0, CURDATE(), 7),
+ (8, 11, 4, 1, CURDATE(), 10, 3.26, 0, CURDATE(), 8),
+ (9, 16, 1, 1, CURDATE(), 5, 9.10, 0, CURDATE(), 9),
+ (10, 16, 2, 1, CURDATE(), 10, 1.07, 0, CURDATE(), 10),
+ (11, 16, 1, 1, CURDATE(), 2, 9.10, 0, CURDATE(), 11),
+ (12, 16, 4, 1, CURDATE(), 20, 3.06, 0, CURDATE(), 12),
+ (13, 20, 1, 1, CURDATE(), 2, 9.10, 0, CURDATE(), NULL);
INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`)
VALUES
- ( 1, 15, 0.58),
- ( 1, 23, 6.5),
- ( 1, 28, 20.72),
- ( 1, 29, -18.72),
- ( 1, 39, 0.02),
- ( 2, 15, 0.058),
- ( 2, 21, 0.002),
- ( 2, 28, 5.6),
- ( 2, 29, -4.6),
- ( 2, 39, 0.01),
- ( 3, 15, 0.58),
- ( 3, 23, 6.5),
- ( 3, 28, 20.72),
- ( 3, 29, -18.72),
- ( 3, 39, 0.02),
- ( 4, 15, 0.051),
- ( 4, 21, -0.001),
- ( 4, 28, 20.72),
- ( 4, 29, -19.72),
- ( 4, 37, 2),
- ( 4, 39, 0.01),
- ( 5, 15, 0.58),
- ( 5, 23, 6.5),
- ( 5, 28, 20.72),
- ( 5, 29, -18.72),
- ( 5, 39, 0.02),
- ( 6, 23, 6.5),
- ( 7, 15, 0.29),
- ( 7, 28, 5.6),
- ( 7, 29, -4.6),
- ( 7, 39, 0.01),
- ( 8, 15, 0.254),
- ( 8, 21, -0.004),
- ( 8, 28, 20.72),
- ( 8, 29, -19.72),
- ( 8, 37, 2),
- ( 8, 39, 0.01),
- ( 9, 15, 0.58),
- ( 9, 23, 6.5),
- ( 9, 28, 20.72),
- ( 9, 29, -18.72),
- ( 9, 39, 0.02),
- ( 10, 15, 0.058),
- ( 10, 21, 0.002),
- ( 10, 28, 5.6),
- ( 10, 29, -4.6),
- ( 10, 39, 0.01),
- ( 11, 15, 0.58),
- ( 11, 23, 6.5),
- ( 11, 28, 20.72),
- ( 11, 29, -18.72),
- ( 11, 39, 0.02),
- ( 12, 15, 0.051),
- ( 12, 22, -0.001),
- ( 12, 28, 20.72),
- ( 12, 29, -19.72),
- ( 12, 37, 2),
- ( 12, 39, 0.01);
+ (1, 15, 0.58),
+ (1, 23, 6.5),
+ (1, 28, 20.72),
+ (1, 29, -18.72),
+ (1, 39, 0.02),
+ (2, 15, 0.058),
+ (2, 21, 0.002),
+ (2, 28, 5.6),
+ (2, 29, -4.6),
+ (2, 39, 0.01),
+ (3, 15, 0.58),
+ (3, 23, 6.5),
+ (3, 28, 20.72),
+ (3, 29, -18.72),
+ (3, 39, 0.02),
+ (4, 15, 0.051),
+ (4, 21, -0.001),
+ (4, 28, 20.72),
+ (4, 29, -19.72),
+ (4, 37, 2),
+ (4, 39, 0.01),
+ (5, 15, 0.58),
+ (5, 23, 6.5),
+ (5, 28, 20.72),
+ (5, 29, -18.72),
+ (5, 39, 0.02),
+ (6, 23, 6.5),
+ (7, 15, 0.29),
+ (7, 28, 5.6),
+ (7, 29, -4.6),
+ (7, 39, 0.01),
+ (8, 15, 0.254),
+ (8, 21, -0.004),
+ (8, 28, 20.72),
+ (8, 29, -19.72),
+ (8, 37, 2),
+ (8, 39, 0.01),
+ (9, 15, 0.58),
+ (9, 23, 6.5),
+ (9, 28, 20.72),
+ (9, 29, -18.72),
+ (9, 39, 0.02),
+ (10, 15, 0.058),
+ (10, 21, 0.002),
+ (10, 28, 5.6),
+ (10, 29, -4.6),
+ (10, 39, 0.01),
+ (11, 15, 0.58),
+ (11, 23, 6.5),
+ (11, 28, 20.72),
+ (11, 29, -18.72),
+ (11, 39, 0.02),
+ (12, 15, 0.051),
+ (12, 22, -0.001),
+ (12, 28, 20.72),
+ (12, 29, -19.72),
+ (12, 37, 2),
+ (12, 39, 0.01),
+ (13, 15, 0.58),
+ (13, 23, 6.5),
+ (13, 28, 20.72),
+ (13, 29, -18.72),
+ (13, 39, 0.02);
INSERT INTO `vn`.`clientContact`(`id`, `clientFk`, `name`, `phone`)
VALUES
@@ -1042,13 +1048,7 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`)
(12, 12),
(13, 13),
(14, 14),
- (15, 15),
- (16, 16),
- (17, 17),
- (18, 18),
- (19, 19),
- (20, 20),
- (21, 21);
+ (15, 15);
INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`)
VALUES
diff --git a/services/db/tests.js b/services/db/tests.js
index 88afa942e..bf2f45b2e 100644
--- a/services/db/tests.js
+++ b/services/db/tests.js
@@ -9,7 +9,9 @@ let verbose = false;
if (process.argv[2] === '--v')
verbose = true;
-loopbackApp = `vn-loopback/server/server`;
+let app = require(`vn-loopback/server/server`);
+app.boot();
+loopbackApp = 'vn-loopback/server/server';
let Jasmine = require('jasmine');
let jasmine = new Jasmine();
diff --git a/services/db/tests/vn/buyUltimate.spec.js b/services/db/tests/vn/buyUltimate.spec.js
index f5a26c1fe..4ff6c4708 100644
--- a/services/db/tests/vn/buyUltimate.spec.js
+++ b/services/db/tests/vn/buyUltimate.spec.js
@@ -1,4 +1,4 @@
-const app = require(`${loopbackApp}`);
+const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('buyUltimate()', () => {
diff --git a/services/db/tests/vn/buyUltimateFromInterval.spec.js b/services/db/tests/vn/buyUltimateFromInterval.spec.js
index 6a22fb34b..b416b5cb2 100644
--- a/services/db/tests/vn/buyUltimateFromInterval.spec.js
+++ b/services/db/tests/vn/buyUltimateFromInterval.spec.js
@@ -1,4 +1,4 @@
-const app = require(`${loopbackApp}`);
+const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('buyUltimateFromInterval()', () => {
diff --git a/services/db/tests/vn/logAddWithUser.spec.js b/services/db/tests/vn/logAddWithUser.spec.js
index 48bc70aac..8711769d0 100644
--- a/services/db/tests/vn/logAddWithUser.spec.js
+++ b/services/db/tests/vn/logAddWithUser.spec.js
@@ -1,4 +1,4 @@
-const app = require(`${loopbackApp}`);
+const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('logAddWithUser()', () => {
diff --git a/services/db/tests/vn/ticketCalculateClon.spec.js b/services/db/tests/vn/ticketCalculateClon.spec.js
index 3c7bd0c2e..0b3969f1f 100644
--- a/services/db/tests/vn/ticketCalculateClon.spec.js
+++ b/services/db/tests/vn/ticketCalculateClon.spec.js
@@ -1,4 +1,4 @@
-const app = require(`${loopbackApp}`);
+const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('ticket ticketCalculateClon()', () => {
diff --git a/services/db/tests/vn/ticketComponentUpdateSale.spec.js b/services/db/tests/vn/ticketComponentUpdateSale.spec.js
index 50e7cd265..45551c165 100644
--- a/services/db/tests/vn/ticketComponentUpdateSale.spec.js
+++ b/services/db/tests/vn/ticketComponentUpdateSale.spec.js
@@ -1,4 +1,4 @@
-const app = require(`${loopbackApp}`);
+const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('ticketComponentUpdateSale()', () => {
diff --git a/services/db/tests/vn/ticketCreateWithUser.spec.js b/services/db/tests/vn/ticketCreateWithUser.spec.js
index e8c5b5be8..52a8a1183 100644
--- a/services/db/tests/vn/ticketCreateWithUser.spec.js
+++ b/services/db/tests/vn/ticketCreateWithUser.spec.js
@@ -1,4 +1,4 @@
-const app = require(`${loopbackApp}`);
+const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('ticket ticketCreateWithUser()', () => {