diff --git a/client/claim/routes.json b/client/claim/routes.json index efd4ecec3..5af69e52f 100644 --- a/client/claim/routes.json +++ b/client/claim/routes.json @@ -15,7 +15,7 @@ "url": "/index?q", "state": "claim.index", "component": "vn-claim-index", - "description": "Listado", + "description": "List", "acl": ["salesAssistant"] }, { diff --git a/client/core/src/components/chip/index.html b/client/core/src/components/chip/index.html index c687623be..c4c9f5ed9 100644 --- a/client/core/src/components/chip/index.html +++ b/client/core/src/components/chip/index.html @@ -1,7 +1,7 @@
- diff --git a/client/core/src/components/chip/index.js b/client/core/src/components/chip/index.js index b95030d68..b691bffee 100644 --- a/client/core/src/components/chip/index.js +++ b/client/core/src/components/chip/index.js @@ -6,12 +6,14 @@ export default class Chip { $transclude($scope.$parent, clone => { angular.element($element[0].querySelector('div')).append(clone); }); - /* this.mdlElement = this.element.querySelector('.mdl-slider'); - componentHandler.upgradeElement(this.mdlElement); */ - /* this.mdlElement.addEventListener('change', () => { - this._value = this.input.value; - this.$.$applyAsync(); - }); */ + } + +/** + * Remove chip event + */ + remove() { + if (this.onRemove) + this.onRemove(); } } @@ -22,6 +24,7 @@ ngModule.component('vnChip', { controller: Chip, transclude: true, bindings: { - disabled: ' { + let $element; + let $scope; + let $httpBackend; + let controller; + + beforeEach(() => { + angular.mock.module('client'); + }); + + beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_, _$timeout_) => { + $scope = $rootScope.$new(); + $element = angular.element(`
${template}
`); + $httpBackend = _$httpBackend_; + $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); + controller = _$componentController_('vnChip', {$element, $scope, $httpBackend, $transclude: () => {}}); + })); + + describe('remove()', () => { + it(`should call onRemove()`, () => { + controller.onRemove = () => {}; + spyOn(controller, 'onRemove'); + controller.remove(); + + expect(controller.onRemove).toHaveBeenCalledWith(); + }); + }); +}); diff --git a/client/core/src/components/chip/style.scss b/client/core/src/components/chip/style.scss index 20dea52ad..aca854efb 100644 --- a/client/core/src/components/chip/style.scss +++ b/client/core/src/components/chip/style.scss @@ -2,6 +2,10 @@ vn-chip { .mdl-chip { + background-color: rgba($main-01, 0.9); + } + + .mdl-chip:active { background-color: $main-01 } } \ No newline at end of file diff --git a/client/core/src/components/multi-check/multi-check.spec.js b/client/core/src/components/multi-check/multi-check.spec.js index e7855449f..86bc7e72f 100644 --- a/client/core/src/components/multi-check/multi-check.spec.js +++ b/client/core/src/components/multi-check/multi-check.spec.js @@ -1,16 +1,18 @@ import './multi-check.js'; -xdescribe('Component vnMultiCheck', () => { +describe('Component vnMultiCheck', () => { let $componentController; let controller; + let $element; beforeEach(() => { - angular.mock.module('client'); + angular.mock.module('ticket'); }); beforeEach(angular.mock.inject(_$componentController_ => { $componentController = _$componentController_; - controller = $componentController('vnMultiCheck', {}); + $element = angular.element(`
`); + controller = $componentController('vnMultiCheck', {$element: $element}); })); describe('checkAll() setter', () => { @@ -25,7 +27,7 @@ xdescribe('Component vnMultiCheck', () => { }); describe('switchChecks()', () => { - it(`should set checked property inside each existing elemenet when id begings with no-`, () => { + it(`should set checked property inside each existing element`, () => { controller.data = [ {name: 'name'}, {name: null} diff --git a/client/item/routes.json b/client/item/routes.json index 21399f9b5..b66d9212e 100644 --- a/client/item/routes.json +++ b/client/item/routes.json @@ -125,7 +125,7 @@ "item": "$ctrl.item" } }, { - "url" : "/diary?q", + "url" : "/diary?warehouseFk", "state": "item.card.diary", "component": "vn-item-diary", "description": "Diary", diff --git a/client/item/src/diary/index.html b/client/item/src/diary/index.html index 366902678..63b811b26 100644 --- a/client/item/src/diary/index.html +++ b/client/item/src/diary/index.html @@ -2,8 +2,7 @@ vn-id="model" url="item/api/Items/getDiary" filter="::$ctrl.filter" - data="sales" - auto-load="false"> + data="sales"> @@ -15,9 +14,10 @@ url="/item/api/Warehouses" show-field="name" value-field="id" - initial-data="$ctrl.filter.where.warehouseFk" - field="$ctrl.filter.where.warehouseFk" - label="Select warehouse" on-change="$ctrl.onChange(value)"> + initial-data="$ctrl.warehouseFk" + field="$ctrl.warehouseFk" + label="Select warehouse" + on-change="$ctrl.onChange(value)"> diff --git a/client/item/src/diary/index.js b/client/item/src/diary/index.js index b8fd34aec..826211c27 100644 --- a/client/item/src/diary/index.js +++ b/client/item/src/diary/index.js @@ -2,61 +2,58 @@ import ngModule from '../module'; import './style.scss'; class Controller { - constructor($scope, $http, $state, $window, $translate) { + constructor($scope, $http, $state, $window, $translate, $stateParams) { this.$scope = $scope; this.$http = $http; this.$state = $state; + this.$stateParams = $stateParams; this.$window = $window; this.$translate = $translate; } - +/* $postLink() { if (this.item) this.filterBuilder(); } - + */ set item(value) { this._item = value; - if (value && this.$scope.model) - this.filterBuilder(); + this.filter = { + where: {itemFk: this.$stateParams.id} + }; + + if (this.$stateParams.warehouseFk) + this.warehouseFk = this.$stateParams.warehouseFk; + else if (value) + this.warehouseFk = value.itemType.warehouseFk; } get item() { return this._item; } - onChange(value) { - if (!value) return; + set warehouseFk(value) { + this._warehouseFk = value; + + this.$state.go(this.$state.current.name, { + warehouseFk: value + }); this.filter.where.warehouseFk = value; - this.$scope.model.refresh(); } -/** - * Builds a filter with default values - * and aplies query params. - */ - filterBuilder() { - this.filter = { - where: { - itemFk: this.item.id, - warehouseFk: this.item.itemType.warehouseFk - } - - }; - let where = this.filter.where; - - if (this.$state.params.q) { - let queryFilter = JSON.parse(this.$state.params.q); - where.warehouseFk = queryFilter.warehouseFk; - } + get warehouseFk() { + return this._warehouseFk; } get freeLineIndex() { let lines = this.$scope.model.data; + let currentDate = new Date(); + currentDate.setHours(0, 0, 0); + for (let i = 0; i < lines.length; i++) { - let isFutureDate = new Date(lines[i].date) > new Date(); + let isFutureDate = new Date(lines[i].date) >= currentDate; if (isFutureDate) return i; @@ -140,7 +137,7 @@ class Controller { } } -Controller.$inject = ['$scope', '$http', '$state', '$window', '$translate']; +Controller.$inject = ['$scope', '$http', '$state', '$window', '$translate', '$stateParams']; ngModule.component('vnItemDiary', { template: require('./index.html'), diff --git a/client/item/src/diary/index.spec.js b/client/item/src/diary/index.spec.js index c5c909ed5..4e17653ad 100644 --- a/client/item/src/diary/index.spec.js +++ b/client/item/src/diary/index.spec.js @@ -3,6 +3,7 @@ import './index.js'; describe('Item', () => { describe('Component vnItemDiary', () => { let $componentController; + let $stateParams; let $scope; let controller; let $httpBackend; @@ -11,12 +12,14 @@ describe('Item', () => { angular.mock.module('item'); }); - beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => { + beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$stateParams_, _$httpBackend_) => { $componentController = _$componentController_; + $stateParams = _$stateParams_; + $stateParams.id = 1; $httpBackend = _$httpBackend_; $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); $scope = $rootScope.$new(); - controller = $componentController('vnItemDiary', {$scope: $scope}); + controller = $componentController('vnItemDiary', {$scope: $scope, $stateParams}); controller.$scope.model = {}; })); @@ -71,12 +74,19 @@ describe('Item', () => { }); describe('set item()', () => { - it(`should call filterBuilder()`, () => { - spyOn(controller, 'filterBuilder'); - controller.item = {id: 1}; + it(`should set warehouseFk property based on itemType warehouseFk`, () => { + controller.item = {id: 1, itemType: {warehouseFk: 1}}; - expect(controller.filterBuilder).toHaveBeenCalledWith(); - expect(controller.item).toEqual({id: 1}); + expect(controller.warehouseFk).toEqual(1); + expect(controller.item.id).toEqual(1); + }); + + it(`should set warehouseFk property based on url query warehouseFk`, () => { + controller.$stateParams.warehouseFk = 4; + controller.item = {id: 1, itemType: {warehouseFk: 1}}; + + expect(controller.warehouseFk).toEqual(4); + expect(controller.item.id).toEqual(1); }); }); }); diff --git a/client/route/index.js b/client/route/index.js index eadbde870..8420b1093 100644 --- a/client/route/index.js +++ b/client/route/index.js @@ -1 +1 @@ -export * from './src/route'; +export * from './src'; diff --git a/client/route/routes.json b/client/route/routes.json index 907a65b75..f9d358bbd 100644 --- a/client/route/routes.json +++ b/client/route/routes.json @@ -1,4 +1,4 @@ -/* { +{ "module": "route", "name": "Routes", "icon" : "local_shipping", @@ -8,61 +8,15 @@ "url": "/routes", "state": "routes", "abstract": true, - "component": "ui-view" + "component": "ui-view", + "description": "Routes" }, { - "url": "/list", + "url": "/index?q", "state": "routes.index", "component": "vn-route-index", + "description": "List", "acl": ["developer"] - }, - { - "url": "/create", - "state": "routes.create", - "component": "vn-route-create" - }, - { - "url": "/:id", - "state": "routes.card", - "abstract": true, - "component": "vn-route-card" - }, - { - "url": "/basicData", - "state": "routes.card.basicData", - "component": "vn-route-basic-data", - "params": { - "route": "$ctrl.route" - }, - "menu": { - "description": "Basic data", - "icon": "person" - } - }, - { - "url": "/logisticData", - "state": "routes.card.logisticData", - "component": "vn-route-logistic-data", - "acl": ["employee"], - "params": { - "route": "$ctrl.route" - }, - "menu": { - "description": "Logistic data", - "icon": "local_shipping" - } - }, - { - "url": "/tickets", - "state": "routes.card.tickets", - "component": "vn-route-tickets", - "params": { - "route": "$ctrl.route" - }, - "menu": { - "description": "Assigned tickets", - "icon": "assignment" - } } ] -} */ \ No newline at end of file +} \ No newline at end of file diff --git a/client/route/src/basic-data/basic-data.html b/client/route/src/basic-data/basic-data.html deleted file mode 100644 index 91a4bd70f..000000000 --- a/client/route/src/basic-data/basic-data.html +++ /dev/null @@ -1,35 +0,0 @@ - - -
- - - Basic data - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/client/route/src/basic-data/basic-data.js b/client/route/src/basic-data/basic-data.js deleted file mode 100644 index 9f2278dbb..000000000 --- a/client/route/src/basic-data/basic-data.js +++ /dev/null @@ -1,8 +0,0 @@ -import ngModule from '../module'; - -ngModule.component('vnRouteBasicData', { - template: require('./basic-data.html'), - bindings: { - route: '<' - } -}); diff --git a/client/route/src/card/card.html b/client/route/src/card/card.html deleted file mode 100644 index b787b738f..000000000 --- a/client/route/src/card/card.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - local_shipping - - -
Route {{::$ctrl.route.id}}
-
{{$ctrl.route.date | date:'dd/MM/yyyy'}}
-
-
-
-
- -
- - - -
- \ No newline at end of file diff --git a/client/route/src/card/card.js b/client/route/src/card/card.js deleted file mode 100644 index e0655c069..000000000 --- a/client/route/src/card/card.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../module'; - -class RouteCard { - constructor() { - this.route = null; - } -} - -ngModule.component('vnRouteCard', { - template: require('./card.html'), - controller: RouteCard -}); diff --git a/client/route/src/card/style.css b/client/route/src/card/style.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/client/route/src/create/create.html b/client/route/src/create/create.html deleted file mode 100644 index 8b7b7c6ba..000000000 --- a/client/route/src/create/create.html +++ /dev/null @@ -1,43 +0,0 @@ - - - -
-
- - - Create Route - - - - - - - - - - - - - - - - - -
-
diff --git a/client/route/src/create/create.js b/client/route/src/create/create.js deleted file mode 100644 index a51a32da7..000000000 --- a/client/route/src/create/create.js +++ /dev/null @@ -1,20 +0,0 @@ -import ngModule from '../module'; - -class RouteCreate { - constructor($scope, $state) { - this.$ = $scope; - this.$state = $state; - this.delivery = {}; - } - onSubmit() { - this.$.watcher.submit().then( - json => this.$state.go('routes.card.basicData', {id: json.data.id}) - ); - } -} -RouteCreate.$inject = ['$scope', '$state']; - -ngModule.component('vnRouteCreate', { - template: require('./create.html'), - controller: RouteCreate -}); diff --git a/client/route/src/index.js b/client/route/src/index.js new file mode 100644 index 000000000..cfb4664b4 --- /dev/null +++ b/client/route/src/index.js @@ -0,0 +1,3 @@ +export * from './module'; + +// import components diff --git a/client/route/src/index/googleMaps.svg b/client/route/src/index/googleMaps.svg deleted file mode 100644 index 9a7fc59d7..000000000 --- a/client/route/src/index/googleMaps.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/client/route/src/index/index.html b/client/route/src/index/index.html deleted file mode 100644 index e9debbac4..000000000 --- a/client/route/src/index/index.html +++ /dev/null @@ -1,23 +0,0 @@ - -
-
- - - - - - - - - - -
- - - -
diff --git a/client/route/src/index/index.js b/client/route/src/index/index.js deleted file mode 100644 index c8dc8ffd6..000000000 --- a/client/route/src/index/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import ngModule from '../module'; -import './style.css'; -import './item-route'; - -export default class Controller { - constructor() { - this.model = {}; - } - search(index) { - index.filter.search = this.model.search; - index.accept(); - } -} - -ngModule.component('vnRouteIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/client/route/src/index/item-route.html b/client/route/src/index/item-route.html deleted file mode 100644 index 226d75810..000000000 --- a/client/route/src/index/item-route.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - ID_RUTA: - {{$ctrl.route.id}} - - - Fecha: - {{$ctrl.route.date | date:'dd/MM/yyyy'}} - - - m3: - {{$ctrl.route.m3}} - - - - - - - \ No newline at end of file diff --git a/client/route/src/index/item-route.js b/client/route/src/index/item-route.js deleted file mode 100644 index 0eeb9fcd5..000000000 --- a/client/route/src/index/item-route.js +++ /dev/null @@ -1,8 +0,0 @@ -import ngModule from '../module'; - -ngModule.component('vnItemRoute', { - template: require('./item-route.html'), - bindings: { - route: '<' - } -}); diff --git a/client/route/src/index/routeIn.svg b/client/route/src/index/routeIn.svg deleted file mode 100644 index dec26dfbf..000000000 --- a/client/route/src/index/routeIn.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - diff --git a/client/route/src/index/routeOut.svg b/client/route/src/index/routeOut.svg deleted file mode 100644 index 7a69b7786..000000000 --- a/client/route/src/index/routeOut.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - diff --git a/client/route/src/index/style.css b/client/route/src/index/style.css deleted file mode 100644 index 0a369664e..000000000 --- a/client/route/src/index/style.css +++ /dev/null @@ -1,12 +0,0 @@ -vn-item-route { - display: block; -} -vn-item-route a { - display: block; - text-decoration: none; - color: inherit; -} -vn-item-route a:hover { - color: white; - background-color: #424242; -} \ No newline at end of file diff --git a/client/route/src/logistic-data/logistic-data.html b/client/route/src/logistic-data/logistic-data.html deleted file mode 100644 index 9ea4c802b..000000000 --- a/client/route/src/logistic-data/logistic-data.html +++ /dev/null @@ -1,26 +0,0 @@ - - -
- - - Logistic data - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/client/route/src/logistic-data/logistic-data.js b/client/route/src/logistic-data/logistic-data.js deleted file mode 100644 index 4230a8282..000000000 --- a/client/route/src/logistic-data/logistic-data.js +++ /dev/null @@ -1,8 +0,0 @@ -import ngModule from '../module'; - -ngModule.component('vnRouteLogisticData', { - template: require('./logistic-data.html'), - bindings: { - route: '<' - } -}); diff --git a/client/route/src/route.js b/client/route/src/route.js deleted file mode 100644 index a9db6db33..000000000 --- a/client/route/src/route.js +++ /dev/null @@ -1,10 +0,0 @@ -export * from './module'; - -// import components -import './index/index'; -import './search-panel/search-panel'; -import './create/create'; -import './card/card'; -import './basic-data/basic-data'; -import './logistic-data/logistic-data'; -import './tickets/tickets'; diff --git a/client/route/src/search-panel/locale/es.yml b/client/route/src/search-panel/locale/es.yml deleted file mode 100644 index 590d0e6d8..000000000 --- a/client/route/src/search-panel/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -Client id: Id cliente -Tax number: NIF/CIF -Name: Nombre -Social name: Razon social -Town/City: Ciudad -Postcode: Código postal -Email: Correo electrónico -Phone: Teléfono \ No newline at end of file diff --git a/client/route/src/search-panel/search-panel.html b/client/route/src/search-panel/search-panel.html deleted file mode 100644 index 3661a2c5f..000000000 --- a/client/route/src/search-panel/search-panel.html +++ /dev/null @@ -1,21 +0,0 @@ -
-
- - - - - - - - - - - - -
-
diff --git a/client/route/src/search-panel/search-panel.js b/client/route/src/search-panel/search-panel.js deleted file mode 100644 index c1b79d5de..000000000 --- a/client/route/src/search-panel/search-panel.js +++ /dev/null @@ -1,27 +0,0 @@ -import ngModule from '../module'; - -export default class Controller { - constructor($window) { - this.$window = $window; - // onSubmit() is defined by @vnSearchbar - this.onSubmit = () => {}; - } - onSearch() { - this.setStorageValue(); - this.onSubmit(this.filter); - } - $onChanges() { - var value = JSON.parse(this.$window.sessionStorage.getItem('filter')); - if (value !== undefined) - this.filter = value; - } - setStorageValue() { - this.$window.sessionStorage.setItem('filter', JSON.stringify(this.filter)); - } -} -Controller.$inject = ['$window']; - -ngModule.component('vnRouteSearchPanel', { - template: require('./search-panel.html'), - controller: Controller -}); diff --git a/client/route/src/tickets/tickets.html b/client/route/src/tickets/tickets.html deleted file mode 100644 index e78e9ab70..000000000 --- a/client/route/src/tickets/tickets.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - Assigned tickets - - - \ No newline at end of file diff --git a/client/route/src/tickets/tickets.js b/client/route/src/tickets/tickets.js deleted file mode 100644 index 2405d5d9e..000000000 --- a/client/route/src/tickets/tickets.js +++ /dev/null @@ -1,8 +0,0 @@ -import ngModule from '../module'; - -ngModule.component('vnRouteTickets', { - template: require('./tickets.html'), - bindings: { - route: '<' - } -}); diff --git a/client/ticket/routes.json b/client/ticket/routes.json index 312e28c4d..02a8703a4 100644 --- a/client/ticket/routes.json +++ b/client/ticket/routes.json @@ -15,7 +15,7 @@ "url": "/index?q", "state": "ticket.index", "component": "vn-ticket-index", - "description": "Listado" + "description": "List" }, { "url": "/:id", diff --git a/services/client/common/models/greuge.json b/services/client/common/models/greuge.json index 8524d3e19..36aa19ff8 100644 --- a/services/client/common/models/greuge.json +++ b/services/client/common/models/greuge.json @@ -2,42 +2,46 @@ "name": "Greuge", "base": "VnModel", "options": { - "mysql": { - "table": "greuge" - } + "mysql": { + "table": "greuge" + } }, "properties": { - "id": { - "id": true, - "type": "Number", - "description": "Identifier" - }, - "description": { - "type": "String", - "required": true - }, - "amount": { - "type": "Number", - "required": true - }, - "shipped": { - "type": "date" - }, - "created": { - "type": "date" - } + "id": { + "id": true, + "type": "Number", + "description": "Identifier" + }, + "description": { + "type": "String", + "required": true + }, + "amount": { + "type": "Number", + "required": true + }, + "shipped": { + "type": "date" + }, + "created": { + "type": "date" + }, + "greugeTypeFk": { + "type": "Number", + "required": true + } + }, "relations": { - "client": { - "type": "belongsTo", - "model": "Client", - "foreignKey": "clientFk" - }, - "greugeType": { - "type": "belongsTo", - "model": "GreugeType", - "foreignKey": "greugeTypeFk", - "required": true - } + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "clientFk" + }, + "greugeType": { + "type": "belongsTo", + "model": "GreugeType", + "foreignKey": "greugeTypeFk" + } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/services/db/export-data.cmd b/services/db/export-data.cmd index e6e35c909..e9a89854d 100755 --- a/services/db/export-data.cmd +++ b/services/db/export-data.cmd @@ -4,7 +4,7 @@ mysqldump --defaults-file=connect.ini --no-create-info account role roleRole rol echo USE `salix`; >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> install/dump/03-dumpedFixtures.sql echo USE `vn`; >> install/dump/03-dumpedFixtures.sql -mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak bookingPlanner pgc tag >> install/dump/03-dumpedFixtures.sql +mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak bookingPlanner pgc tag alertLevel>> install/dump/03-dumpedFixtures.sql echo USE `vn2008`; >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas container iva_group_codigo escritos cl_est cl_con cl_res cl_dev cl_mot cl_sol>> install/dump/03-dumpedFixtures.sql echo USE `bi`; >> install/dump/03-dumpedFixtures.sql diff --git a/services/db/export-data.sh b/services/db/export-data.sh index a1d42f501..3fb0fd3c4 100755 --- a/services/db/export-data.sh +++ b/services/db/export-data.sh @@ -5,13 +5,10 @@ mysqldump --defaults-file=connect.ini --no-create-info account role roleRole rol echo "USE \`salix\`;" >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> install/dump/03-dumpedFixtures.sql echo "USE \`vn\`;" >> install/dump/03-dumpedFixtures.sql -mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak bookingPlanner pgc tag >> install/dump/03-dumpedFixtures.sql +mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak bookingPlanner pgc tag alertLevel >> install/dump/03-dumpedFixtures.sql echo "USE \`vn2008\`;" >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas container iva_group_codigo escritos cl_est cl_con cl_res cl_dev cl_mot cl_sol>> install/dump/03-dumpedFixtures.sql echo "USE \`bi\`;" >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info bi tarifa_componentes tarifa_componentes_series >> install/dump/03-dumpedFixtures.sql echo "USE \`cache\`;" >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info cache cache >> install/dump/03-dumpedFixtures.sql - - - diff --git a/services/db/install/dump/03-dumpedFixtures.sql b/services/db/install/dump/03-dumpedFixtures.sql index 9513353a0..69c0854bd 100644 --- a/services/db/install/dump/03-dumpedFixtures.sql +++ b/services/db/install/dump/03-dumpedFixtures.sql @@ -55,7 +55,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-09-05 11:59:54 +-- Dump completed on 2018-09-06 14:58:36 USE `salix`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -93,7 +93,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-09-05 11:59:54 +-- Dump completed on 2018-09-06 14:58:36 USE `vn`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -171,6 +171,16 @@ LOCK TABLES `tag` WRITE; INSERT INTO `tag` VALUES (1,'Color',0,1,'ink',NULL),(2,'Forma',1,1,NULL,NULL),(3,'Material',1,1,NULL,NULL),(4,'Longitud',1,0,NULL,NULL),(5,'Diámetro',1,0,NULL,'mm'),(6,'Perímetro',1,0,NULL,'mm'),(7,'Ancho de la base',1,0,NULL,'mm'),(8,'Altura',1,0,NULL,'mm'),(9,'Volumen',1,0,NULL,'ml'),(10,'Densidad',1,0,NULL,NULL),(11,'Calidad',1,1,NULL,NULL),(12,'Textura',1,1,NULL,NULL),(13,'Material del mango',1,1,NULL,NULL),(14,'Compra mínima',1,1,NULL,NULL),(15,'Nº pétalos',1,0,NULL,NULL),(16,'Ancho',1,0,NULL,'mm'),(17,'Alto',1,0,NULL,'mm'),(18,'Profundidad',1,0,NULL,'mm'),(19,'Largo',1,0,NULL,'mm'),(20,'Ancho superior',1,0,NULL,'mm'),(21,'Ancho inferior',1,0,NULL,'mm'),(22,'Gramaje',1,0,NULL,'g'),(23,'Tallos',1,0,NULL,NULL),(24,'Estado',0,1,NULL,NULL),(25,'Color principal',0,1,NULL,NULL),(26,'Color secundario',0,1,NULL,NULL),(27,'Longitud(cm)',1,0,NULL,'cm'),(28,'Diámetro base',1,0,NULL,NULL),(29,'Colección',1,1,NULL,NULL),(30,'Uds / caja',1,0,NULL,NULL),(31,'Contenido',1,1,NULL,NULL),(32,'Peso',1,0,NULL,'g'),(33,'Grosor',1,0,NULL,'mm'),(34,'Marca',1,1,NULL,NULL),(35,'Origen',0,1,'origin',NULL),(36,'Proveedor',1,1,NULL,NULL),(37,'Productor',1,1,'producer',NULL),(38,'Duración',1,0,NULL,'s'),(39,'Flor',1,1,NULL,NULL),(40,'Soporte',1,1,NULL,NULL),(41,'Tamaño flor',1,1,NULL,NULL),(42,'Apertura',1,1,NULL,NULL),(43,'Tallo',0,1,NULL,NULL),(44,'Numero hojas',1,1,NULL,NULL),(45,'Dimensiones',1,1,NULL,NULL),(46,'Diámetro boca',1,1,NULL,NULL),(47,'Nº flores',1,0,NULL,NULL),(48,'Uds / paquete',1,0,NULL,NULL),(49,'Maceta',1,1,NULL,NULL),(50,'Textura flor',1,1,NULL,NULL),(51,'Textura hoja',1,1,NULL,NULL),(52,'Tipo de iva',1,1,NULL,NULL),(53,'Tronco',1,1,NULL,NULL),(54,'Hoja',1,1,NULL,NULL),(55,'Formato',1,1,NULL,NULL),(56,'Genero',1,1,NULL,NULL),(57,'Especie',1,1,NULL,NULL),(58,'Variedad',1,1,NULL,NULL),(59,'Medida grande',1,0,NULL,NULL),(60,'Medida mediano',1,0,NULL,NULL),(61,'Medida pequeño',1,0,NULL,NULL),(62,'Medida pequeño',1,0,NULL,NULL),(63,'Recipiente interior',1,1,NULL,NULL),(64,'Material secundario',1,1,NULL,NULL),(65,'Colores',1,1,NULL,NULL),(66,'Referencia',1,1,NULL,NULL),(67,'Categoria',1,0,NULL,NULL),(68,'Amb',0,1,NULL,NULL),(69,'Anchura',1,1,NULL,'cm'),(70,'Hueco interior',-1,1,NULL,NULL),(71,'Tamaño',1,1,NULL,NULL),(72,'Color botón',1,1,NULL,NULL),(73,'Tamaño minimo del botón',1,1,NULL,NULL),(74,'Obtentor',1,1,NULL,NULL),(75,'Logitud del brote',1,1,NULL,NULL),(76,'Tallos / u.v.',1,1,NULL,NULL),(77,'Madera de',1,1,NULL,NULL),(78,'Unidad de venta',1,1,NULL,NULL),(79,'Temporal',1,1,NULL,NULL),(80,'Gramaje/tallo',1,1,NULL,NULL),(81,'Gramaje/paquete',1,1,NULL,NULL),(82,'Flexibilidad del tallo',1,1,NULL,NULL),(83,'Nº planchas',1,1,NULL,NULL); /*!40000 ALTER TABLE `tag` ENABLE KEYS */; UNLOCK TABLES; + +-- +-- Dumping data for table `alertLevel` +-- + +LOCK TABLES `alertLevel` WRITE; +/*!40000 ALTER TABLE `alertLevel` DISABLE KEYS */; +INSERT INTO `alertLevel` VALUES ('DELIVERED',3),('FREE',0),('ON_PREPARATION',1),('PACKED',2); +/*!40000 ALTER TABLE `alertLevel` ENABLE KEYS */; +UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -181,7 +191,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-09-05 11:59:54 +-- Dump completed on 2018-09-06 14:58:37 USE `vn2008`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -296,7 +306,7 @@ UNLOCK TABLES; LOCK TABLES `escritos` WRITE; /*!40000 ALTER TABLE `escritos` DISABLE KEYS */; -INSERT INTO `escritos` VALUES (1,'Carta_1','Aviso inicial por saldo deudor',0,'0'),(2,'Carta_2','Reiteracion de aviso por saldo deudor',0,'0'),(3,'Cred_Up','Notificación de aumento de crédito',0,'0'),(4,'Cred_down','Notificación de reducción de crédito',0,'0'),(5,'Pet_CC','Petición de datos bancarios B2B',0,'0'),(6,'SolCredito','Solicitud de crédito',0,'0'),(7,'LeyPago','Ley de pagos',0,'0'),(8,'Pet_CC_Core','Petición de datos bancarios CORE',0,'0'),(9,'nueva_alta','Documento de nueva alta de cliente',0,'0'),(10,'client_welcome','Email de bienvenida para nuevo cliente',0,'0'),(11,'setup_printer','Email de instalación de impresora',0,'0'),(12,'client-welcome','Email de bienvenida como nuevo cliente.',1,'0'),(13,'printer-setup','Email de instalación y configuración de impresora de coronas.',1,'0'),(14,'sepa-core','Email de solicitud de datos bancarios core.',1,'1'),(15,'letter-debtor-st','Email de aviso inicial por saldo deudor',1,'1'),(16,'letter-debtor-nd','Email de aviso reiterado por saldo deudor',1,'1'); +INSERT INTO `escritos` VALUES (1,'Carta_1','Aviso inicial por saldo deudor',1,'0'),(2,'Carta_2','Reiteracion de aviso por saldo deudor',1,'0'),(3,'Cred_Up','Notificación de aumento de crédito',0,'0'),(4,'Cred_down','Notificación de reducción de crédito',0,'0'),(5,'Pet_CC','Petición de datos bancarios B2B',0,'0'),(6,'SolCredito','Solicitud de crédito',0,'0'),(7,'LeyPago','Ley de pagos',0,'0'),(8,'Pet_CC_Core','Petición de datos bancarios CORE',1,'0'),(9,'nueva_alta','Documento de nueva alta de cliente',0,'0'),(10,'client_welcome','Email de bienvenida para nuevo cliente',1,'0'),(11,'setup_printer','Email de instalación de impresora',1,'0'),(12,'client-welcome','Email de bienvenida como nuevo cliente.',0,'0'),(13,'printer-setup','Email de instalación y configuración de impresora de coronas.',0,'0'),(14,'sepa-core','Email de solicitud de datos bancarios core.',0,'1'),(15,'letter-debtor-st','Email de aviso inicial por saldo deudor',0,'1'),(16,'letter-debtor-nd','Email de aviso reiterado por saldo deudor',0,'1'); /*!40000 ALTER TABLE `escritos` ENABLE KEYS */; UNLOCK TABLES; @@ -369,7 +379,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-09-05 11:59:55 +-- Dump completed on 2018-09-06 14:58:37 USE `bi`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -417,7 +427,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-09-05 11:59:55 +-- Dump completed on 2018-09-06 14:58:37 USE `cache`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -455,4 +465,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-09-05 11:59:55 +-- Dump completed on 2018-09-06 14:58:37 diff --git a/services/loopback/common/methods/item/specs/getDiary.spec.js b/services/loopback/common/methods/item/specs/getDiary.spec.js new file mode 100644 index 000000000..6ebbbe004 --- /dev/null +++ b/services/loopback/common/methods/item/specs/getDiary.spec.js @@ -0,0 +1,11 @@ +const app = require(`${servicesDir}/item/server/server`); + +describe('item getShipped()', () => { + it('should return 3 entries, the first one with the property balance -100', async() => { + let params = {where: {itemFk: 1, warehouseFk: 2}}; + let result = await app.models.Item.getDiary(params); + + expect(result.length).toBe(3); + expect(result[0].balance).toBe(-100); + }); +}); diff --git a/services/loopback/common/methods/sale/specs/getClaimableFromTicket.spec.js b/services/loopback/common/methods/sale/specs/getClaimableFromTicket.spec.js new file mode 100644 index 000000000..fbcb0a4b3 --- /dev/null +++ b/services/loopback/common/methods/sale/specs/getClaimableFromTicket.spec.js @@ -0,0 +1,10 @@ +const app = require(`${servicesDir}/ticket/server/server`); + +describe('sale getClaimableFromTicket()', () => { + it('should throw an error if the ticket is not editable', async() => { + let claimableFromTicket = await app.models.Sale.getClaimableFromTicket(16); + + expect(claimableFromTicket[0].concept).toBe('Gem of Time'); + expect(claimableFromTicket.length).toBe(4); + }); +}); diff --git a/services/route/common/methods/comboVehicles.js b/services/route/common/methods/comboVehicles.js deleted file mode 100644 index df3978d9f..000000000 --- a/services/route/common/methods/comboVehicles.js +++ /dev/null @@ -1,42 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('comboVehicles', { - description: 'returns list of vehicles', - accessType: 'READ', - accepts: [{ - arg: 'filter', - type: 'Object', - required: false, - description: 'Filter defining where and paginated data', - http: {source: 'query'} - }], - returns: { - arg: 'data', - type: 'Vehicle', - root: true - }, - http: { - path: `/comboVehicles`, - verb: 'get' - } - }); - - Self.comboVehicles = (filter, callback) => { - Self.find(filter, (_, instances) => { - callback(null, formatOutput(instances)); - }); - }; - - function formatOutput(instances) { - let results = []; - - for (let instance of instances) { - let numberPlate = ` ${instance.numberPlate}` || ''; - results.push({ - id: instance.id, - name: `${instance.tradeMark} ${instance.model}${numberPlate}` - }); - } - - return results; - } -}; diff --git a/services/route/common/methods/drivers.js b/services/route/common/methods/drivers.js deleted file mode 100644 index d074391fa..000000000 --- a/services/route/common/methods/drivers.js +++ /dev/null @@ -1,79 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('activeDrivers', { - description: 'returns actives workers with driver role', - accessType: 'READ', - accepts: [{ - arg: 'filter', - type: 'Object', - required: false, - description: 'Filter defining where and paginated data', - http: {source: 'query'} - }], - returns: { - arg: 'data', - type: 'Worker', - root: true - }, - http: { - path: `/activeDrivers`, - verb: 'get' - } - }); - - Self.activeDrivers = (filter, callback) => { - let skip = filter.skip || 0; - let limit = filter.limit || 10; - let where = getCondition(filter.where); - // TODO: change salesPerson role to Driver role when it will be created - let query = `SELECT em.id, em.firstName, em.name - FROM worker em - JOIN account.user ac ON em.userFk = ac.id - JOIN account.role r ON r.id = ac.roleFK - WHERE ac.active AND r.\`name\` = 'salesPerson' ${where} - ORDER BY em.name ASC - LIMIT ${limit} OFFSET ${skip}`; - - Self.rawSql(query, [], callback) - .then(response => { - callback(null, formatDriver(response)); - }) - .catch(reject => { - callback(reject, null); - }); - }; - - function getCondition(where) { - let out = []; - if (typeof where === 'object') { - Object.keys(where).forEach(k => { - let value = where[k]; - if (typeof value === 'number') { - out.push(`em.${k}=${value}`); - } else if (typeof value === 'string') { - out.push(`em.${k}='${value}'`); - } else if (typeof value === 'boolean' || value === null) { - out.push(`em.${k} IS ${String(value).toUpperCase()}`); - } else if (Object.keys(value).length) { - let firstProperty = Object.keys(value)[0]; - out.push(`em.${k} ${firstProperty} '${value[firstProperty]}'`); - } else { - throw new Error('Error: unexpected type'); - } - }); - } - return out.length ? `AND (${out.join(' AND ')})` : ''; - } - - function formatDriver(response) { - let results = []; - - response.forEach(person => { - results.push({ - id: person.id, - name: `${person.firstName} ${person.name}` - }); - }); - - return results; - } -}; diff --git a/services/route/common/methods/filterRoutes.js b/services/route/common/methods/filterRoutes.js deleted file mode 100644 index 8d15050dd..000000000 --- a/services/route/common/methods/filterRoutes.js +++ /dev/null @@ -1,48 +0,0 @@ -module.exports = function(Self) { - Self.installMethod('filter', filterRoutes); - - function filterRoutes(params) { - if (params.search) - return searchWhere(params); - return andWhere(params); - } - - function searchWhere(params) { - return { - where: { - or: [ - {id: params.search}, - {name: {regexp: params.search}} - ] - - }, - skip: (parseInt(params.page, 10) - 1) * parseInt(params.size, 10), - limit: parseInt(params.size, 10) - }; - } - - function andWhere(params) { - let filters = { - where: {}, - skip: (parseInt(params.page, 10) - 1) * parseInt(params.size, 10), - limit: parseInt(params.size, 10) - }; - - delete params.page; - delete params.size; - - if (params.phone) { - filters.where.or = [ - {phone: params.phone}, - {mobile: params.phone} - ]; - delete params.phone; - } - Object.keys(params).forEach( - key => { - filters.where[key] = {regexp: params[key]}; - } - ); - return filters; - } -}; diff --git a/services/route/common/models/delivery.js b/services/route/common/models/delivery.js deleted file mode 100644 index 5bb764ee3..000000000 --- a/services/route/common/models/delivery.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = function(Self) { - require('../methods/filterRoutes.js')(Self); -}; diff --git a/services/route/common/models/vehicle.js b/services/route/common/models/vehicle.js deleted file mode 100644 index 6d6c3a113..000000000 --- a/services/route/common/models/vehicle.js +++ /dev/null @@ -1,5 +0,0 @@ - -module.exports = function(Self) { - require('../methods/comboVehicles.js')(Self); - require('../methods/drivers.js')(Self); -}; diff --git a/services/route/server/server.js.bak b/services/route/server/server.js similarity index 100% rename from services/route/server/server.js.bak rename to services/route/server/server.js