diff --git a/client/client/src/address/index/index.html b/client/client/src/address/index/index.html index c175f42ff..448d72c11 100644 --- a/client/client/src/address/index/index.html +++ b/client/client/src/address/index/index.html @@ -1,8 +1,15 @@ - + + + Addresses - + @@ -56,7 +63,6 @@ - this.$scope.index.accept() + () => this.$scope.model.refresh() ); } } } -Controller.$inject = ['$http', '$scope']; +Controller.$inject = ['$http', '$scope', '$stateParams']; ngModule.component('vnClientAddressIndex', { template: require('./index.html'), diff --git a/client/client/src/basic-data/index.html b/client/client/src/basic-data/index.html index 0b42536e6..7626704d1 100644 --- a/client/client/src/basic-data/index.html +++ b/client/client/src/basic-data/index.html @@ -1,4 +1,4 @@ - + { $httpBackend = _$httpBackend_; $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); $scope = $rootScope.$new(); - let submit = jasmine.createSpy('submit').and.returnValue(Promise.resolve()); - $scope.watcher = {submit}; + $scope.watcher = { + submit: () => { + return { + then: callback => { + callback(); + } + }; + } + }; $httpBackend.get = jasmine.createSpy('get').and.returnValue(Promise.resolve()); controller = $componentController('vnClientBillingData', {$scope: $scope}, {$http: $httpBackend}); + controller.client = {id: 101, name: 'Client name', payMethodFk: 4}; })); - describe('copyData()', () => { - it(`should define billData using client's data`, () => { - controller.client = { - dueDay: 0, - iban: null, - payMethodFk: 1 - }; - controller.billData = {}; - controller.copyData(controller.client); - - expect(controller.billData).toEqual(controller.client); + describe('client()', () => { + it(`should call setter client`, () => { + expect(controller.orgData).toEqual(controller.client); }); }); - describe('submit()', () => { - it(`should call submit() on the watcher then receive a callback`, done => { - spyOn(controller, 'checkPaymentChanges'); - controller.submit() - .then(() => { - expect(controller.$.watcher.submit).toHaveBeenCalledWith(); - expect(controller.checkPaymentChanges).toHaveBeenCalledWith(); - done(); - }); + describe('hasPaymethodChanged()', () => { + it(`should call hasPaymethodChanged() and return true if there are changes on payMethod data`, () => { + controller.client.payMethodFk = 5; + + expect(controller.hasPaymethodChanged()).toBeTruthy(); + }); + + it(`should call hasPaymethodChanged() and return false if there are no changes on payMethod data`, () => { + controller.client.payMethodFk = 4; + + expect(controller.hasPaymethodChanged()).toBeFalsy(); }); }); - describe('checkPaymentChanges()', () => { - it(`should not call sendMail.show() if there are no changes on billing data`, () => { - controller.billData = {marvelHero: 'Silver Surfer'}; - controller.client = {marvelHero: 'Silver Surfer'}; - controller.checkPaymentChanges(); + describe('onSubmit()', () => { + it(`should call notifyChanges() if there are changes on payMethod data`, () => { + spyOn(controller, 'notifyChanges'); + controller.client.payMethodFk = 5; + controller.onSubmit(); - expect(controller.$http.get).not.toHaveBeenCalled(); - }); - - it(`should call sendMail.show() if there are changes on billing data object`, () => { - controller.billData = {id: '123', marvelHero: 'Silver Surfer'}; - controller.client = {id: '123', marvelHero: 'Spider-Man'}; - controller.checkPaymentChanges(); - - expect(controller.$http.get).toHaveBeenCalled(); + expect(controller.hasPaymethodChanged()).toBeTruthy(); + expect(controller.notifyChanges).toHaveBeenCalledWith(); }); }); }); diff --git a/client/client/src/billing-data/index.html b/client/client/src/billing-data/index.html index 588ef2bc3..9330d910c 100644 --- a/client/client/src/billing-data/index.html +++ b/client/client/src/billing-data/index.html @@ -1,11 +1,11 @@ - + -
+ Pay method @@ -36,8 +36,8 @@ diff --git a/client/client/src/billing-data/index.js b/client/client/src/billing-data/index.js index 50fc4963e..947de8481 100644 --- a/client/client/src/billing-data/index.js +++ b/client/client/src/billing-data/index.js @@ -2,47 +2,42 @@ import ngModule from '../module'; export default class Controller { constructor($scope, $http, vnApp, $translate) { - this.$ = $scope; + this.$scope = $scope; this.$http = $http; this.vnApp = vnApp; this.translate = $translate; - this.billData = {}; - this.copyData(); } - $onChanges() { - this.copyData(); + set client(value) { + this._client = value; + + if (value) + this.orgData = Object.assign({}, value); } - copyData() { - if (this.client) { - this.billData.payMethodFk = this.client.payMethodFk; - this.billData.iban = this.client.iban; - this.billData.dueDay = this.client.dueDay; - } + get client() { + return this._client; } - submit() { - return this.$.watcher.submit().then( - () => this.checkPaymentChanges()); + onSubmit() { + this.$scope.watcher.submit().then(() => { + if (this.hasPaymethodChanged()) + this.notifyChanges(); + }); } - checkPaymentChanges() { - let equals = true; - Object.keys(this.billData).forEach( - val => { - if (this.billData[val] !== this.client[val]) { - this.billData[val] = this.client[val]; - equals = false; - } - } + notifyChanges() { + this.$http.get(`/mailer/notification/payment-update/${this.client.id}`).then( + () => this.vnApp.showMessage(this.translate.instant('Notification sent!')) ); + } - if (!equals) { - this.$http.get(`/mailer/notification/payment-update/${this.client.id}`).then( - () => this.vnApp.showMessage(this.translate.instant('Notification sent!')) - ); - } + hasPaymethodChanged() { + let payMethod = this.orgData.payMethodFk != this.client.payMethodFk; + let iban = this.orgData.iban != this.client.iban; + let dueDay = this.orgData.dueDay != this.client.dueDay; + + return payMethod || iban || dueDay; } } Controller.$inject = ['$scope', '$http', 'vnApp', '$translate']; diff --git a/client/client/src/billing-data/locale/en.yml b/client/client/src/billing-data/locale/en.yml index 20f5272b6..20177159b 100644 --- a/client/client/src/billing-data/locale/en.yml +++ b/client/client/src/billing-data/locale/en.yml @@ -9,7 +9,6 @@ Equivalent tax spreaded: Equivalent tax spreaded Invoice by address: Invoice by address Equalization tax: Equalization tax Due day: Due day -Received core VNH: VNH core received Received core VNL: VNL core received Received B2B VNL: VNL B2B received Save: Save \ No newline at end of file diff --git a/client/client/src/billing-data/locale/es.yml b/client/client/src/billing-data/locale/es.yml index ed4725ac2..b0334d0df 100644 --- a/client/client/src/billing-data/locale/es.yml +++ b/client/client/src/billing-data/locale/es.yml @@ -9,7 +9,7 @@ Equivalent tax spreaded: Recargo de equivalencia propagado Invoice by address: Facturar por consignatario Equalization tax: Recargo de equivalencia Due day: Vencimiento -Received core VNH: Recibido core VNH +Received LCR: Recibido LCR Received core VNL: Recibido core VNL Received B2B VNL: Recibido B2B VNL Save: Guardar \ No newline at end of file diff --git a/client/client/src/contact/contact.spec.js b/client/client/src/contact/contact.spec.js index d79754a15..a4d20ea7f 100644 --- a/client/client/src/contact/contact.spec.js +++ b/client/client/src/contact/contact.spec.js @@ -19,7 +19,7 @@ describe('Client', () => { $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); $scope = $rootScope.$new(); $scope.form = {$invalid: false}; - $scope.index = {accept: () => {}}; + $scope.model = {refresh: () => {}}; controller = $componentController('vnClientContactIndex', {$scope: $scope}, {$state: $state}); controller.client = { id: 101 @@ -70,11 +70,11 @@ describe('Client', () => { describe('submit()', () => { it("should perfom a query to delete contacts", () => { - controller._oldContacts = []; - controller._oldContacts[1] = {id: 1, clientFk: 101, name: 'My contact 1', phone: '123456789'}; - controller._oldContacts[2] = {id: 2, clientFk: 101, name: 'My contact 2', phone: '123456789'}; + controller.oldContacts = []; + controller.oldContacts[1] = {id: 1, clientFk: 101, name: 'My contact 1', phone: '123456789'}; + controller.oldContacts[2] = {id: 2, clientFk: 101, name: 'My contact 2', phone: '123456789'}; - controller._contacts = [ + controller.contacts = [ {id: 2, name: 'My contact 2', phone: '123456789'} ]; controller.removedContacts = [1]; @@ -93,11 +93,11 @@ describe('Client', () => { }); it("should perfom a query to update contacts", () => { - controller._oldContacts = []; - controller._oldContacts[1] = {id: 1, clientFk: 101, name: 'My contact 1', phone: '123456789'}; - controller._oldContacts[2] = {id: 2, clientFk: 101, name: 'My contact 2', phone: '123456789'}; + controller.oldContacts = []; + controller.oldContacts[1] = {id: 1, clientFk: 101, name: 'My contact 1', phone: '123456789'}; + controller.oldContacts[2] = {id: 2, clientFk: 101, name: 'My contact 2', phone: '123456789'}; - controller._contacts = [ + controller.contacts = [ {id: 1, clientFk: 101, name: 'My contact 1', phone: '123456789'}, {id: 2, clientFk: 101, name: 'My contact 2', phone: '111111111'} ]; @@ -119,11 +119,11 @@ describe('Client', () => { }); it("should perfom a query to create new contact", () => { - controller._oldContacts = []; - controller._oldContacts[1] = {id: 1, name: 'My contact 1', phone: '123456789'}; - controller._oldContacts[2] = {id: 2, name: 'My contact 2', phone: '123456789'}; + controller.oldContacts = []; + controller.oldContacts[1] = {id: 1, name: 'My contact 1', phone: '123456789'}; + controller.oldContacts[2] = {id: 2, name: 'My contact 2', phone: '123456789'}; - controller._contacts = [ + controller.contacts = [ {id: 1, name: 'My contact 1', phone: '123456789'}, {id: 2, name: 'My contact 2', phone: '123456789'}, {name: 'My contact 3', phone: '123456789'} diff --git a/client/client/src/contact/index.html b/client/client/src/contact/index.html index 1acf29ed7..dd97d850e 100644 --- a/client/client/src/contact/index.html +++ b/client/client/src/contact/index.html @@ -1,12 +1,14 @@ - - + + + Contacts - + { this.vnApp.showSuccess(this.$translate.instant('Data saved!')); - this.$scope.index.accept(); + this.$scope.model.refresh(); }); } @@ -85,7 +78,7 @@ class Controller { add() { let data = { clientFk: this.client.id, - name: 'Teléfono', + name: this.$translate.instant('Phone'), phone: null }; this.contacts.push(data); @@ -115,7 +108,7 @@ class Controller { } } -Controller.$inject = ['$http', '$scope', '$translate', 'vnApp']; +Controller.$inject = ['$http', '$scope', '$stateParams', '$translate', 'vnApp']; ngModule.component('vnClientContactIndex', { template: require('./index.html'), diff --git a/client/client/src/credit-insurance/create/index.html b/client/client/src/credit-insurance/create/index.html index b37ed2c9a..38c598601 100644 --- a/client/client/src/credit-insurance/create/index.html +++ b/client/client/src/credit-insurance/create/index.html @@ -6,7 +6,7 @@ vn-one label="Credit" model="$ctrl.creditClassification.credit", - rule="CreditInsurance.credit" + rule="creditInsurance.credit" step="1" vn-focus> @@ -20,7 +20,7 @@ vn-one label="Since" model="$ctrl.creditClassification.started" - ini-options="{dateFormat: 'd-m-Y'}"> + ini-options="{enableTime: true, dateFormat: 'd-m-Y', time_24hr: true}"> diff --git a/client/client/src/credit-insurance/create/index.js b/client/client/src/credit-insurance/create/index.js index 81ab7c67d..f812000ce 100644 --- a/client/client/src/credit-insurance/create/index.js +++ b/client/client/src/credit-insurance/create/index.js @@ -14,15 +14,17 @@ class Controller { submit() { if (this.$scope.form.$invalid) - return this.vnApp.showMessage(this.$translate.instant('Some fields are invalid')); + return this.vnApp.showError(this.$translate.instant('Some fields are invalid')); let query = `/client/api/creditClassifications/createWithInsurance`; let data = this.creditClassification; data.clientFk = this.client.id; - this.$http.post(query, data).then((res, err) => { - if (res.data) + this.$http.post(query, data).then(res => { + if (res.data) { + this.card.reload(); this.$state.go('client.card.creditInsurance.index'); + } }); } } @@ -32,6 +34,9 @@ Controller.$inject = ['$http', '$filter', '$state', '$scope', '$translate', 'vnA ngModule.component('vnClientCreditInsuranceCreate', { template: require('./index.html'), controller: Controller, + require: { + card: '^vnClientCard' + }, bindings: { client: '<' } diff --git a/client/client/src/credit-insurance/index/credit-insurance-index.spec.js b/client/client/src/credit-insurance/index/credit-insurance-index.spec.js index 74cf9f789..19128c821 100644 --- a/client/client/src/credit-insurance/index/credit-insurance-index.spec.js +++ b/client/client/src/credit-insurance/index/credit-insurance-index.spec.js @@ -20,7 +20,7 @@ describe('Client', () => { describe('_getClassifications()', () => { it('should perform a GET query to define the classifications property in the controller', () => { let res = ['some classifications']; - let query = '/client/api/CreditClassifications?filter=%7B%22order%22%3A%22finished%20ASC%2C%20started%20DESC%22%2C%22include%22%3A%5B%7B%22relation%22%3A%22creditInsurances%22%2C%22scope%22%3A%7B%22fields%22%3A%5B%22id%22%2C%22credit%22%2C%22created%22%2C%22grade%22%5D%2C%22order%22%3A%22created%20DESC%22%2C%22limit%22%3A2%7D%7D%5D%2C%22where%22%3A%7B%7D%7D'; + let query = '/client/api/CreditClassifications?filter=%7B%22order%22%3A%22finished%20ASC%2C%20started%20DESC%22%2C%22include%22%3A%5B%7B%22relation%22%3A%22insurances%22%2C%22scope%22%3A%7B%22fields%22%3A%5B%22id%22%2C%22credit%22%2C%22created%22%2C%22grade%22%5D%2C%22order%22%3A%22created%20DESC%22%2C%22limit%22%3A2%7D%7D%5D%2C%22where%22%3A%7B%7D%7D'; $httpBackend.whenGET(query).respond(res); $httpBackend.expectGET(query); diff --git a/client/client/src/credit-insurance/index/index.html b/client/client/src/credit-insurance/index/index.html index 69ee6cb74..b8c2480c5 100644 --- a/client/client/src/credit-insurance/index/index.html +++ b/client/client/src/credit-insurance/index/index.html @@ -15,7 +15,7 @@
To {{classification.finished | date:'dd/MM/yyyy'}}
- + diff --git a/client/client/src/credit-insurance/index/index.js b/client/client/src/credit-insurance/index/index.js index cee5a20b2..6d6994a9a 100644 --- a/client/client/src/credit-insurance/index/index.js +++ b/client/client/src/credit-insurance/index/index.js @@ -17,7 +17,7 @@ class Controller { order: 'finished ASC, started DESC', include: [ { - relation: 'creditInsurances', + relation: 'insurances', scope: { fields: ['id', 'credit', 'created', 'grade'], order: 'created DESC', diff --git a/client/client/src/credit-insurance/index/locale/es.yml b/client/client/src/credit-insurance/index/locale/es.yml index 1262a5dd4..75e004721 100644 --- a/client/client/src/credit-insurance/index/locale/es.yml +++ b/client/client/src/credit-insurance/index/locale/es.yml @@ -3,5 +3,4 @@ New contract: Nuevo contrato Close contract: Cerrar contrato Edit contract: Modificar contrato View credits: Ver créditos -Are you sure you want to close this contract?: ¿Seguro que quieres cerrar este contrato? -Grade: Grado \ No newline at end of file +Are you sure you want to close this contract?: ¿Seguro que quieres cerrar este contrato? \ No newline at end of file diff --git a/client/client/src/credit-insurance/insurance/create/index.html b/client/client/src/credit-insurance/insurance/create/index.html index 77465eb91..802060da1 100644 --- a/client/client/src/credit-insurance/insurance/create/index.html +++ b/client/client/src/credit-insurance/insurance/create/index.html @@ -1,12 +1,11 @@ - + - + New credit @@ -22,7 +21,7 @@ + ini-options="{enableTime: true, dateFormat: 'd-m-Y', time_24hr: true}"> diff --git a/client/client/src/credit-insurance/insurance/create/index.js b/client/client/src/credit-insurance/insurance/create/index.js index 51feab0f5..2c7670ff5 100644 --- a/client/client/src/credit-insurance/insurance/create/index.js +++ b/client/client/src/credit-insurance/insurance/create/index.js @@ -1,18 +1,32 @@ import ngModule from '../../../module'; class Controller { - constructor($filter) { + constructor($scope, $state, $filter) { + this.$scope = $scope; + this.$state = $state; this.insurance = { - created: $filter('date')(new Date(), 'yyyy-MM-dd HH:mm') + created: $filter('date')(new Date(), 'yyyy-MM-dd HH:mm:ss') }; } + + onSubmit() { + let params = {classificationId: this.$state.params.classificationId}; + let state = 'client.card.creditInsurance.insurance.index'; + + this.$scope.watcher.submitGo(state, params).then(() => { + this.card.reload(); + }); + } } -Controller.$inject = ['$filter']; +Controller.$inject = ['$scope', '$state', '$filter']; ngModule.component('vnClientCreditInsuranceInsuranceCreate', { template: require('./index.html'), controller: Controller, + require: { + card: '^vnClientCard' + }, bindings: { client: '<' } diff --git a/client/client/src/credit-insurance/insurance/index/credit-insurance-list.spec.js b/client/client/src/credit-insurance/insurance/index/credit-insurance-list.spec.js index f994829a8..38c43fce7 100644 --- a/client/client/src/credit-insurance/insurance/index/credit-insurance-list.spec.js +++ b/client/client/src/credit-insurance/insurance/index/credit-insurance-list.spec.js @@ -12,10 +12,10 @@ describe('Client', () => { beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => { $componentController = _$componentController_; - let $state = {params: {classificationId: 1}}; + let $stateParams = {classificationId: 1}; $httpBackend = _$httpBackend_; $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); - controller = $componentController('vnClientCreditInsuranceInsuranceIndex', {$state: $state}); + controller = $componentController('vnClientCreditInsuranceInsuranceIndex', {$stateParams: $stateParams}); })); it('should perform a query to GET credit the credit classification', () => { diff --git a/client/client/src/credit-insurance/insurance/index/index.html b/client/client/src/credit-insurance/insurance/index/index.html index b5c42326a..7d277ebeb 100644 --- a/client/client/src/credit-insurance/insurance/index/index.html +++ b/client/client/src/credit-insurance/insurance/index/index.html @@ -1,28 +1,39 @@ - + + + Requested credits - - - - - - - - - - - - - - - - - - -
CreditGradeCreated
{{::insurance.credit | currency: '€': 2}}{{::insurance.grade}}{{::insurance.created | date: 'dd/MM/yyyy'}}
No results
+ + + + Credit + Grade + Created + + + + + {{::insurance.credit | currency: ' €': 2}} + {{::insurance.grade}} + {{::insurance.created | date: 'dd/MM/yyyy'}} + + + + No results + +
+ +
-
- \ No newline at end of file diff --git a/client/client/src/credit-insurance/insurance/index/index.js b/client/client/src/credit-insurance/insurance/index/index.js index 5f8c14afd..cfb8a807c 100644 --- a/client/client/src/credit-insurance/insurance/index/index.js +++ b/client/client/src/credit-insurance/insurance/index/index.js @@ -1,19 +1,21 @@ import ngModule from '../../../module'; -import FilterList from 'core/src/lib/filter-list'; -class Controller extends FilterList { - constructor($scope, $timeout, $state, $http) { - super($scope, $timeout, $state); - this.modelName = 'creditClassificationFk'; - this.modelId = $state.params.classificationId; - this.isClosed = true; +class Controller { + constructor($stateParams, $http) { + this.$stateParams = $stateParams; this.$http = $http; + this.isClosed = true; + this.filter = { + include: [ + {relation: 'classification'} + ] + }; } $onInit() { let filter = { fields: ['finished'], - where: {id: this.modelId} + where: {id: this.$stateParams.classificationId} }; filter = encodeURIComponent(JSON.stringify(filter)); @@ -25,7 +27,7 @@ class Controller extends FilterList { } } -Controller.$inject = ['$scope', '$timeout', '$state', '$http']; +Controller.$inject = ['$stateParams', '$http']; ngModule.component('vnClientCreditInsuranceInsuranceIndex', { template: require('./index.html'), diff --git a/client/client/src/credit/index/index.html b/client/client/src/credit/index/index.html index 4e1b0e03f..0a108ac78 100644 --- a/client/client/src/credit/index/index.html +++ b/client/client/src/credit/index/index.html @@ -1,29 +1,41 @@ - + + + Credit - - - - - - - - {{::credit.amount | number:2}} € - {{::credit.created | date:'dd/MM/yyyy HH:mm'}} - {{::credit.worker.firstName}} {{::credit.worker.name}} - - - No results - + + + + Credit + Since + Employee + + + + + {{::credit.amount | number:2}} € + {{::credit.created | date:'dd/MM/yyyy HH:mm'}} + {{::credit.worker.firstName}} {{::credit.worker.name}} + + + + No results + + + + - - diff --git a/client/client/src/credit/index/index.js b/client/client/src/credit/index/index.js index ee9fc3f3c..a12dfc5fe 100644 --- a/client/client/src/credit/index/index.js +++ b/client/client/src/credit/index/index.js @@ -1,7 +1,24 @@ import ngModule from '../../module'; -import FilterClientList from '../../filter-client-list'; + +class Controller { + constructor($stateParams) { + this.$stateParams = $stateParams; + this.filter = { + include: [ + { + relation: 'worker', + scope: { + fields: ['firstName', 'name'] + } + } + ] + }; + } +} + +Controller.$inject = ['$stateParams']; ngModule.component('vnClientCreditIndex', { template: require('./index.html'), - controller: FilterClientList + controller: Controller }); diff --git a/client/client/src/fiscal-data/index.html b/client/client/src/fiscal-data/index.html index 86c612ebb..1e8dcac50 100644 --- a/client/client/src/fiscal-data/index.html +++ b/client/client/src/fiscal-data/index.html @@ -1,4 +1,4 @@ - + - + + + + + + Greuge - - - - - - - - - {{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }} - {{::greuge.description}} - {{::greuge.amount | number:2}} € - {{::greuge.greugeType.name}} - - - No results - - - - {{edit.model.sumAmount | number:2}} € - - + + + + Date + Comment + Amount + Type + + + + + {{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }} + {{::greuge.description}} + {{::greuge.amount | currency: ' €': 2}} + {{::greuge.greugeType.name}} + + + + No results + + + + + + + {{edit.model.sumAmount | currency: ' €': 2}} + + + + + + + - - diff --git a/client/client/src/greuge/index/index.js b/client/client/src/greuge/index/index.js index 06ef11513..3dd5c9eaf 100644 --- a/client/client/src/greuge/index/index.js +++ b/client/client/src/greuge/index/index.js @@ -1,7 +1,24 @@ import ngModule from '../../module'; -import FilterClientList from '../../filter-client-list'; + +class Controller { + constructor($stateParams) { + this.$stateParams = $stateParams; + this.filter = { + include: [ + { + relation: "greugeType", + scope: { + fields: ["id", "name"] + } + } + ] + }; + } +} + +Controller.$inject = ['$stateParams']; ngModule.component('vnClientGreugeIndex', { template: require('./index.html'), - controller: FilterClientList + controller: Controller }); diff --git a/client/client/src/index/index.js b/client/client/src/index/index.js index 175ddb7d2..2bcf77084 100644 --- a/client/client/src/index/index.js +++ b/client/client/src/index/index.js @@ -10,12 +10,9 @@ export default class Controller { exprBuilder(param, value) { switch (param) { case 'search': - return { - or: [ - {id: value}, - {name: {regexp: value}} - ] - }; + return /^\d+$/.test(value) + ? {id: value} + : {name: {regexp: value}}; case 'phone': return { or: [ diff --git a/client/client/src/invoice/index.html b/client/client/src/invoice/index.html index 5650a193a..64e6f2d84 100644 --- a/client/client/src/invoice/index.html +++ b/client/client/src/invoice/index.html @@ -1,35 +1,42 @@ - + + + Invoices - - - - - - - - - - - {{::invoice.ref}} - {{::invoice.issued | date:'dd/MM/yyyy' }} - {{::invoice.dued | date:'dd/MM/yyyy' }} - {{::invoice.amount | currency:'€':2}} - - - No results - - - + + + + Reference + Issue date + Due date + Amount + + + + + + {{::invoice.ref}} + {{::invoice.issued | date:'dd/MM/yyyy' }} + {{::invoice.dued | date:'dd/MM/yyyy' }} + {{::invoice.amount | currency:' €': 2}} + + + + No results + + + + - - \ No newline at end of file diff --git a/client/client/src/invoice/index.js b/client/client/src/invoice/index.js index 6dcfdb258..fd973ceb9 100644 --- a/client/client/src/invoice/index.js +++ b/client/client/src/invoice/index.js @@ -1,13 +1,12 @@ import ngModule from '../module'; -import FilterClientList from '../filter-client-list'; -class Controller extends FilterClientList { - constructor($scope, $timeout, $state, $stateParams) { - super($scope, $timeout, $state); - $scope.$stateParams = $stateParams; +class Controller { + constructor($stateParams) { + this.$stateParams = $stateParams; } } -Controller.$inject = ['$scope', '$timeout', '$state', '$stateParams']; + +Controller.$inject = ['$stateParams']; ngModule.component('vnClientInvoice', { template: require('./index.html'), diff --git a/client/client/src/locale/es.yml b/client/client/src/locale/es.yml index 15f819c67..9fc7fbdb3 100644 --- a/client/client/src/locale/es.yml +++ b/client/client/src/locale/es.yml @@ -1,8 +1,12 @@ Active: Activo +Add contact: Añadir contacto +Amount: Importe Client: Cliente Clients: Clientes Comercial Name: Comercial +Contacts: Contactos Basic data: Datos básicos +Back: Volver Fiscal data: Datos Fiscales Addresses: Consignatarios Web access: Acceso web @@ -21,6 +25,4 @@ Credit : Crédito Credit contracts: Contratos de crédito Verified data: Datos comprobados Mandate: Mandato -Amount: Importe -Back: Volver -Contacts: Contactos \ No newline at end of file +Remove contact: Eliminar \ No newline at end of file diff --git a/client/client/src/mandate/index.html b/client/client/src/mandate/index.html index 429d8eb93..34a6edf5a 100644 --- a/client/client/src/mandate/index.html +++ b/client/client/src/mandate/index.html @@ -1,31 +1,43 @@ - + + + Mandate - - - - - - - - - - {{::mandate.id}} - {{::mandate.company.code}} - {{::mandate.mandateType.name}} - {{::mandate.created | date:'dd/MM/yyyy HH:mm' }} - {{::mandate.finished | date:'dd/MM/yyyy HH:mm' || '-'}} - - - No results - + + + + Id + Company + Type + Register date + End date + + + + + {{::mandate.id}} + {{::mandate.company.code}} + {{::mandate.mandateType.name}} + {{::mandate.created | date:'dd/MM/yyyy HH:mm' }} + {{::mandate.finished | date:'dd/MM/yyyy HH:mm' || '-'}} + + + + No results + + + + - - \ No newline at end of file diff --git a/client/client/src/mandate/index.js b/client/client/src/mandate/index.js index d290db569..a406fcab3 100644 --- a/client/client/src/mandate/index.js +++ b/client/client/src/mandate/index.js @@ -1,7 +1,30 @@ import ngModule from '../module'; -import FilterClientList from '../filter-client-list'; + +class Controller { + constructor($stateParams) { + this.$stateParams = $stateParams; + this.filter = { + include: [ + { + relation: "mandateType", + scope: { + fields: ["id", "name"] + } + }, + { + relation: "company", + scope: { + fields: ["id", "code"] + } + } + ] + }; + } +} + +Controller.$inject = ['$stateParams']; ngModule.component('vnClientMandate', { template: require('./index.html'), - controller: FilterClientList + controller: Controller }); diff --git a/client/client/src/note/index/index.html b/client/client/src/note/index/index.html index 9405b5bed..0e2581997 100644 --- a/client/client/src/note/index/index.html +++ b/client/client/src/note/index/index.html @@ -1,25 +1,31 @@ + + + - + Notes - {{::n.worker.firstName}} {{::n.worker.name}} - {{::n.created | date:'dd/MM/yyyy HH:mm'}} + {{::note.worker.firstName}} {{::note.worker.name}} + {{::note.created | date:'dd/MM/yyyy HH:mm'}} - {{::n.text}} + {{::note.text}} - - \ No newline at end of file + + + + diff --git a/client/client/src/note/index/index.js b/client/client/src/note/index/index.js index 12a5e3338..2415aa482 100644 --- a/client/client/src/note/index/index.js +++ b/client/client/src/note/index/index.js @@ -1,31 +1,12 @@ import ngModule from '../../module'; export default class Controller { - constructor($http, $state) { - this.$http = $http; - this.$state = $state; - } - - $onChanges() { - if (this.client) { - this.getObservation(this.client.id); - } - } - - getObservation(clientId) { - let json = JSON.stringify({where: {clientFk: this.client.id}, order: 'created DESC'}); - this.$http.get(`/client/api/clientObservations?filter=${json}`).then( - json => { - this.observations = json.data; - } - ); - } - - newObservation() { - this.$state.go("client.card.note.create", {id: this.client.id}); + constructor($stateParams) { + this.$stateParams = $stateParams; } } -Controller.$inject = ['$http', '$state']; + +Controller.$inject = ['$stateParams']; ngModule.component('vnClientNote', { template: require('./index.html'), diff --git a/client/client/src/note/index/notes.spec.js b/client/client/src/note/index/notes.spec.js deleted file mode 100644 index 017d9aea0..000000000 --- a/client/client/src/note/index/notes.spec.js +++ /dev/null @@ -1,58 +0,0 @@ -import './index'; - -describe('Client', () => { - describe('Component vnClientNote', () => { - let $componentController; - let $state; - let $httpBackend; - let controller; - - beforeEach(() => { - angular.mock.module('client'); - }); - - beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => { - $componentController = _$componentController_; - $state = _$state_; - $httpBackend = _$httpBackend_; - $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); - controller = $componentController('vnClientNote', {$state: $state}); - })); - - describe('$onChanges()', () => { - it(`should call getObservation() with the client id`, () => { - controller.client = { - id: 1234 - }; - spyOn(controller, 'getObservation').and.returnValue(); - controller.$onChanges(); - - expect(controller.getObservation).toHaveBeenCalledWith(1234); - }); - }); - - describe('$getObservation()', () => { - it(`should request to GET the client notes`, () => { - controller.client = {id: '1234'}; - let jsonString = JSON.stringify({where: {clientFk: '1234'}, order: 'created DESC'}); - let json = {data: 'some data'}; - $httpBackend.when('GET', `/client/api/clientObservations?filter=${jsonString}`).respond(json); - $httpBackend.expectGET(`/client/api/clientObservations?filter=${jsonString}`, {Accept: 'application/json, text/plain, */*'}); - controller.getObservation(); - $httpBackend.flush(); - - expect(controller.observations).toEqual(json); - }); - }); - - describe('$newObservation()', () => { - it(`should redirect the user to the newObservation view`, () => { - controller.client = {id: '1234'}; - spyOn(controller.$state, 'go'); - controller.newObservation(); - - expect(controller.$state.go).toHaveBeenCalledWith('client.card.note.create', Object({id: '1234'})); - }); - }); - }); -}); diff --git a/client/client/src/recovery/index/index.html b/client/client/src/recovery/index/index.html index 985fd42a2..c10e16628 100644 --- a/client/client/src/recovery/index/index.html +++ b/client/client/src/recovery/index/index.html @@ -1,37 +1,53 @@ - + + + Recovery - - - - - - - - - - lock - - {{::recovery.started | date:'dd/MM/yyyy' }} - {{recovery.finished | date:'dd/MM/yyyy' }} - {{::recovery.amount | currency:'€':0}} - {{::recovery.period}} - - - No results - + + + + + Since + To + Amount + Period + + + + + + + + + {{::recovery.started | date:'dd/MM/yyyy' }} + {{recovery.finished | date:'dd/MM/yyyy' }} + {{::recovery.amount | currency:' €': 0}} + {{::recovery.period}} + + + + No results + + + + - - diff --git a/client/client/src/recovery/index/index.js b/client/client/src/recovery/index/index.js index 733d67abf..a52166fc8 100644 --- a/client/client/src/recovery/index/index.js +++ b/client/client/src/recovery/index/index.js @@ -1,22 +1,23 @@ import ngModule from '../../module'; -import FilterClientList from '../../filter-client-list'; -class Controller extends FilterClientList { - constructor($scope, $timeout, $state, $http) { - super($scope, $timeout, $state); +class Controller { + constructor($stateParams, $scope, $http) { + this.$stateParams = $stateParams; + this.$scope = $scope; this.$http = $http; } + setFinished(recovery) { if (!recovery.finished) { let params = {finished: Date.now()}; this.$http.patch(`/client/api/Recoveries/${recovery.id}`, params).then( - () => this.$.index.accept() + () => this.$scope.model.refresh() ); } } } -Controller.$inject = ['$scope', '$timeout', '$state', '$http']; +Controller.$inject = ['$stateParams', '$scope', '$http']; ngModule.component('vnClientRecoveryIndex', { template: require('./index.html'), diff --git a/client/client/src/summary/index.html b/client/client/src/summary/index.html index 5767f48c7..de34ae66b 100644 --- a/client/client/src/summary/index.html +++ b/client/client/src/summary/index.html @@ -118,8 +118,8 @@

@@ -199,9 +199,16 @@ - - + + + + + + + {{$ctrl.grade ? ' / ' + $ctrl.grade : ' / - '}} + +
diff --git a/client/client/src/summary/index.js b/client/client/src/summary/index.js index a8a54b55a..8c1986bd6 100644 --- a/client/client/src/summary/index.js +++ b/client/client/src/summary/index.js @@ -11,8 +11,12 @@ class Controller { return; this.$http.get(`/client/api/Clients/${this.client.id}/summary`).then(res => { - if (res && res.data) + if (res && res.data) { this.summary = res.data; + + if (res.data.classifications.length) + this.grade = res.data.classifications[0].insurances[0].grade; + } }); } } diff --git a/client/core/src/components/auto-paging/auto-paging.html b/client/core/src/components/auto-paging/auto-paging.html deleted file mode 100644 index eee5ec1f4..000000000 --- a/client/core/src/components/auto-paging/auto-paging.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/client/core/src/components/auto-paging/auto-paging.js b/client/core/src/components/auto-paging/auto-paging.js deleted file mode 100644 index 3278e6869..000000000 --- a/client/core/src/components/auto-paging/auto-paging.js +++ /dev/null @@ -1,123 +0,0 @@ -import ngModule from '../../module'; -import getWatchers from '../../lib/get-watchers'; - -class AutoPaging { - constructor($http, $window, $element, $timeout, vnApp, $translate, $scope) { - this.$http = $http; - this.$window = $window; - this.$element = $element; - this.$timeout = $timeout; - this.vnApp = vnApp; - this.$translate = $translate; - this.$scope = $scope; - - this.numPerPage = null; - this.maxItems = 0; - this.watchScroll = false; - this.waitingNewPage = false; - - this.handlerScroll = this.onScroll.bind(this); - } - - get numPages() { - return this.numPerPage ? Math.ceil(this.maxItems / this.numPerPage) : 0; - } - - loadNewPage() { - this.index.filter.page++; - this.waitingNewPage = true; - - this.index.accept().then(res => { - this.$timeout(() => { - res.instances.forEach(item => { - this.items.push(item); - }); - this.$scope.$apply(); - this.checkWatchers(); - }); - if (this.index.filter.page == this.numPages) { - this.cancelScroll(); - } - this.waitingNewPage = false; - }); - } - - checkPosition() { - let element = this.$element[0].querySelector('vn-spinner'); - let position = element.getBoundingClientRect(); - let isVisible = position.y < document.body.offsetHeight + 150; - if (this.currentPage < this.numPages && isVisible && !this.waitingNewPage) { - this.loadNewPage(); - } - } - - onScroll() { - this.checkPosition(); - } - - startScroll() { - this.watchScroll = true; - this.checkPosition(); - let mainView = this.$window.document.querySelector('.main-view > ui-view.ng-scope'); - angular.element(mainView).bind("scroll", this.handlerScroll); - } - - cancelScroll() { - this.watchScroll = false; - let mainView = this.$window.document.querySelector('.main-view > ui-view.ng-scope'); - angular.element(mainView).unbind("scroll", this.handlerScroll); - } - - checkScroll() { - if (this.numPages > this.currentPage && !this.watchScroll) { - this.startScroll(); - } else if (this.numPages <= this.currentPage && this.watchScroll) { - this.cancelScroll(); - } - } - - checkWatchers() { - let watchers = getWatchers(); - if (watchers > 3000 && this.watchScroll) { - this.cancelScroll(); - this.vnApp.showMessage( - this.$translate.instant('Auto-scroll interrupted, please adjust the search') - ); - } - } - - $onChanges(changes) { - if (!this.index) return; - - this.numPerPage = this.index.filter.size; - this.currentPage = this.index.filter.page; - this.currentInstances = this.items; - if (changes.total) - this.maxItems = changes.total.currentValue; - - this.checkScroll(); - } - - $postLink() { - this.checkScroll(); - } - - $doCheck() { - if (this.index && this.index.filter && this.index.filter.page && this.index.filter.page != this.currentPage) { - this.currentPage = this.index.filter.page; - this.checkScroll(); - } - } -} - -AutoPaging.$inject = ['$http', '$window', '$element', '$timeout', 'vnApp', '$translate', '$scope']; - -ngModule.component('vnAutoPaging', { - template: require('./auto-paging.html'), - bindings: { - index: '<', - total: '<', - items: '<' - }, - controller: AutoPaging -}); diff --git a/client/core/src/components/auto-paging/auto-paging.spec.js b/client/core/src/components/auto-paging/auto-paging.spec.js deleted file mode 100644 index e5070ffbb..000000000 --- a/client/core/src/components/auto-paging/auto-paging.spec.js +++ /dev/null @@ -1,61 +0,0 @@ -import './auto-paging.js'; -import template from './auto-paging.html'; - -describe('Component vnAutoPaging', () => { - let $http; - let $window; - let $element; - let $timeout; - let controller; - - beforeEach(() => { - angular.mock.module('client'); - }); - - beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_, _$window_, _$timeout_) => { - $http = _$httpBackend_; - $window = _$window_; - $timeout = _$timeout_; - $element = angular.element(`
${template}
`); - - controller = _$componentController_('vnAutoPaging', {$http, $window, $element, $timeout}); - })); - - describe('onChanges: actions when index object changes', () => { - beforeEach(() => { - controller.index = { - filter: { - size: 5, - page: 1 - } - }; - controller.items = [1, 2, 3, 4, 5]; - }); - - it('call startScroll() if there are pages to load', () => { - let changes = { - total: { - currentValue: 20 - } - }; - spyOn(controller, 'startScroll'); - - controller.$onChanges(changes); - - expect(controller.startScroll).toHaveBeenCalled(); - }); - - it('call stopScroll() if there are not pages to load', () => { - let changes = { - total: { - currentValue: 5 - } - }; - controller.watchScroll = true; - spyOn(controller, 'cancelScroll'); - controller.$onChanges(changes); - - expect(controller.cancelScroll).toHaveBeenCalled(); - }); - }); -}); diff --git a/client/core/src/components/autocomplete/autocomplete.html b/client/core/src/components/autocomplete/autocomplete.html index 22085f1a6..7e6580d78 100755 --- a/client/core/src/components/autocomplete/autocomplete.html +++ b/client/core/src/components/autocomplete/autocomplete.html @@ -17,11 +17,6 @@ - - clear - { controller = _$componentController_('vnAutocomplete', {$element, $scope, $httpBackend, $transclude: null}); })); + describe('url() setter', () => { + it(`should set url controllers property and call refreshSelection`, () => { + spyOn(controller, "refreshSelection"); + controller.url = "url"; + + expect(controller.url).toEqual("url"); + expect(controller.refreshSelection).toHaveBeenCalledWith(); + }); + }); + describe('field() setter/getter', () => { it(`should set field controllers property`, () => { controller.field = data.id; diff --git a/client/core/src/components/drop-down/style.scss b/client/core/src/components/drop-down/style.scss index c668af096..28fbaa489 100755 --- a/client/core/src/components/drop-down/style.scss +++ b/client/core/src/components/drop-down/style.scss @@ -5,6 +5,7 @@ vn-drop-down { .dropdown { display: flex; flex-direction: column; + height: inherit; & > .filter { position: relative; diff --git a/client/core/src/components/icon-menu/icon-menu.js b/client/core/src/components/icon-menu/icon-menu.js index efde0cfaa..120898150 100644 --- a/client/core/src/components/icon-menu/icon-menu.js +++ b/client/core/src/components/icon-menu/icon-menu.js @@ -26,6 +26,7 @@ export default class IconMenu extends Input { onClick(event) { event.preventDefault(); + if (this.onOpen) this.onOpen(); this.showDropDown(); } @@ -81,7 +82,8 @@ ngModule.component('vnIconMenu', { multiple: ' this.onScroll(e); } diff --git a/client/core/src/components/popover/popover.js b/client/core/src/components/popover/popover.js index bfdaaaed6..2a8760e6a 100644 --- a/client/core/src/components/popover/popover.js +++ b/client/core/src/components/popover/popover.js @@ -75,15 +75,6 @@ export default class Popover extends Component { this.document.addEventListener('keydown', this.docKeyDownHandler); this.document.addEventListener('focusin', this.docFocusInHandler); - let firstFocusable = this.element.querySelector('input, textarea'); - if (firstFocusable) { - firstFocusable.addEventListener('focus', () => { - firstFocusable.select(); - }); - setTimeout(() => { - firstFocusable.focus(); - }, 200); - } this.deregisterCallback = this.$transitions.onStart({}, () => this.hide()); this.relocate(); @@ -136,10 +127,10 @@ export default class Popover extends Component { let arrowHeight = Math.sqrt(Math.pow(arrowRect.height, 2) * 2) / 2; - let top = parentRect.top + parentRect.height + arrowHeight; - let left = parentRect.left; let height = popoverRect.height; let width = Math.max(popoverRect.width, parentRect.width); + let top = parentRect.top + parentRect.height + arrowHeight; + let left = parentRect.left + parentRect.width / 2 - width / 2; let margin = 10; let showTop = top + height + margin > window.innerHeight; diff --git a/client/core/src/components/popover/style.scss b/client/core/src/components/popover/style.scss index 458a47df9..b44554439 100644 --- a/client/core/src/components/popover/style.scss +++ b/client/core/src/components/popover/style.scss @@ -19,25 +19,24 @@ } & > .popover { position: absolute; - display: flex; box-shadow: 0 .1em .4em rgba(1, 1, 1, .4); + z-index: 0; & > .arrow { - width: 1em; + width: 1em; height: 1em; margin: -.5em; background-color: white; box-shadow: 0 .1em .4em rgba(1, 1, 1, .4); position: absolute; transform: rotate(45deg); - z-index: 0; + z-index: -1; } & > .content { - width: 100%; border-radius: .1em; - overflow: auto; background-color: white; - z-index: 1; + height: inherit; + overflow: auto; } } } \ No newline at end of file diff --git a/client/core/src/components/rest-model/crud-model.js b/client/core/src/components/rest-model/crud-model.js index ab2c93956..1d71dfd61 100644 --- a/client/core/src/components/rest-model/crud-model.js +++ b/client/core/src/components/rest-model/crud-model.js @@ -19,7 +19,7 @@ export default class CrudModel extends ModelProxy { this.refresh(); } - refresh(usFilter, usData) { + refresh(usFilter) { if (!this.url) return; let myFilter = { @@ -27,8 +27,7 @@ export default class CrudModel extends ModelProxy { where: mergeWhere(this.link, this.where), include: this.include, order: this.order, - limit: this.limit, - userData: this.userData + limit: this.limit }; let filter = this.filter; @@ -47,9 +46,16 @@ export default class CrudModel extends ModelProxy { sendRequest(filter, append) { this.cancelRequest(); this.canceler = this.$q.defer(); - let options = {timeout: this.canceler.promise}; - let json = encodeURIComponent(JSON.stringify(filter)); - return this.$http.get(`${this.url}?filter=${json}`, options).then( + + let options = { + timeout: this.canceler.promise, + params: {filter: filter} + }; + + if (this.userParams instanceof Object) + Object.assign(options.params, this.userParams); + + return this.$http.get(this.url, options).then( json => this.onRemoteDone(json, filter, append), json => this.onRemoteError(json) ); @@ -118,7 +124,7 @@ export default class CrudModel extends ModelProxy { return changes; } - save(ignoreChanges) { + save() { let changes = this.getChanges(); if (!changes) @@ -146,7 +152,7 @@ ngModule.component('vnCrudModel', { order: '@?', limit: ' { - console.error('Error in history.pushState(): Browser incompatibility error'); - }}; - let aux = window.location.hash.split('?q='); - if (Object.keys(filter).length) - history.pushState({}, null, `${aux[0]}?q=${encodeURIComponent(JSON.stringify(filter))}`); - else - history.pushState({}, null, aux[0]); + let state = window.location.hash.split('?')[0]; + let keys = Object.keys(filter); + + if (keys.length) { + let hashFilter = {}; + + keys.forEach(key => { + let value = filter[key]; + + if (value instanceof Date) + hashFilter[key] = value; + else + switch (typeof value) { + case 'number': + case 'string': + case 'boolean': + hashFilter[key] = value; + } + }); + + let search = encodeURIComponent(JSON.stringify(hashFilter)); + state += `?q=${search}`; + } + + if (!window.history) + throw new Error('Browser incompatibility: window.history not found'); + + window.history.pushState({}, null, state); } /** diff --git a/client/core/src/components/table/index.js b/client/core/src/components/table/index.js index 047e82278..f031b174d 100644 --- a/client/core/src/components/table/index.js +++ b/client/core/src/components/table/index.js @@ -18,15 +18,17 @@ export default class Table { this.order = order; } - applyFilter(field = this.field, order = this.order) { - this.model.filter.order = `${field} ${order}`; + applyOrder(field = this.field, order = this.order) { + if (!field) return; + + this.model.order = `${field} ${order}`; this.model.refresh(); this.setActiveArrow(); } $onChanges() { - if (this.model) - this.applyFilter(); + if (this.model && this.model.filter) + this.applyOrder(); } setActiveArrow() { diff --git a/client/core/src/components/table/style.scss b/client/core/src/components/table/style.scss index 821a71f52..b573b0c2d 100644 --- a/client/core/src/components/table/style.scss +++ b/client/core/src/components/table/style.scss @@ -13,6 +13,7 @@ vn-table { display: table-header-group; vn-th[field] { + position: relative; cursor: pointer } @@ -77,6 +78,7 @@ vn-table { } vn-td, vn-th { + vertical-align: middle; display: table-cell; text-align: left; padding: 10px; @@ -84,6 +86,10 @@ vn-table { &[number]{ text-align: right; } + + vn-icon.bright, i.bright { + color: #f7931e; + } } } } diff --git a/client/core/src/components/textfield/style.scss b/client/core/src/components/textfield/style.scss index 10609c55c..37ee3b511 100644 --- a/client/core/src/components/textfield/style.scss +++ b/client/core/src/components/textfield/style.scss @@ -1,28 +1,29 @@ @import "colors"; vn-textfield { margin: 20px 0!important; - display: block; + display: inline-block; - .leftIcons, .rightIcons, .suffix{ - display: inline-flex; - color: $secondary-font-color; - & .material-icons{ - font-size: 20px!important - } - } - .leftIcons{ - margin-right: 3px; - } - .container{ + & > .container { width: 100%; position: relative; padding-bottom: 2px; + display: flex; + + & > .textField { + width: 100%; + display: flex; + align-items: center; + position: relative; + padding-top: 4px; + } } - .textField{ - width: 100%; - display: inline-flex; - position: relative; - padding: 4px 0; + .leftIcons, .rightIcons, .suffix { + display: flex; + color: $secondary-font-color; + + .material-icons { + font-size: 20px !important + } } .infix { position: relative; @@ -31,43 +32,61 @@ vn-textfield { width: 100%; min-width: 0; } - i.pointer { + i.clear { visibility: hidden; + cursor: pointer; + + &:hover { + color: #222; + } + } + &:hover i.clear { + visibility: visible; } i.visible { visibility: visible; } label { position: absolute; - bottom: 2px; + bottom: 0; + padding: 4px 0!important; pointer-events: none; color: $secondary-font-color; transition-duration: .2s; transition-timing-function: cubic-bezier(.4,0,.2,1); } + &.not-empty label{ + bottom: 24px; + color: $main-01; + padding: 0; + font-size: 12px; + } input { outline: none; border: none; - font-family: "Helvetica","Arial",sans-serif; + font-family: "Helvetica", "Arial", sans-serif; display: block; font-size: 16px; width: 100%; background: 0 0; color: inherit; + padding: 4px; + box-sizing: border-box; + border-bottom: 0!important; &[type=number] { -moz-appearance: textfield; &::-webkit-outer-spin-button, - &::-webkit-inner-spin-button{ + &::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; } } &:invalid { - box-shadow:none; + box-shadow: none; } } - .underline{ + .underline { position: absolute; bottom: 0; height: 1px; @@ -76,49 +95,40 @@ vn-textfield { width: 100%; background-color: rgba(0,0,0,.12); } - .selected.underline{ + .selected.underline { background-color: rgb(255,152,0); height: 2px; left: 50%; - width: 0px!important; + width: 0px !important; transition-duration: 0.2s; transition-timing-function: cubic-bezier(.4,0,.2,1); } - &.not-empty { - & label { - bottom: 24px; - color: $main-01; - font-size: 12px; - } - } - div.selected{ + + div.selected { &.container{ border-bottom: 0px; } - & label { + label { bottom: 24px; color: $main-01; font-size: 12px; } - & .selected.underline{ + .selected.underline{ left: 0; width: 100%!important; } } - & > div.container > div.textField > div.infix.invalid{ + & > div.container > div.textField > div.infix.invalid { @extend div.selected; - & > span.mdl-textfield__error{ + & > span.mdl-textfield__error { visibility: visible; - margin-top: 9px; } - & > label{ + & > label { color: #d50000; } } .infix.invalid + .underline { - &{ - background-color: #d50000; - } + background-color: #d50000; } } \ No newline at end of file diff --git a/client/core/src/components/textfield/textfield.html b/client/core/src/components/textfield/textfield.html index edd341b9c..a730517ac 100644 --- a/client/core/src/components/textfield/textfield.html +++ b/client/core/src/components/textfield/textfield.html @@ -1,36 +1,30 @@
+ ng-class="{selected: $ctrl.hasFocus}">
-
-
- +
- - +
- clear diff --git a/client/core/src/components/textfield/textfield.js b/client/core/src/components/textfield/textfield.js index fb86e2309..94b73b35d 100644 --- a/client/core/src/components/textfield/textfield.js +++ b/client/core/src/components/textfield/textfield.js @@ -44,6 +44,7 @@ export default class Textfield extends Input { if (this.hasValue) this.element.classList.add('not-empty'); else this.element.classList.remove('not-empty'); + this.mdlUpdate(); } get value() { return this._value; @@ -57,6 +58,10 @@ export default class Textfield extends Input { set vnTabIndex(value) { this.input.tabindex = value; } + mdlUpdate() { + let mdlElement = this.element.firstChild.MaterialTextfield; + if (mdlElement) mdlElement.updateClasses_(); + } clear() { this.value = null; this.input.focus(); diff --git a/client/core/src/components/th/index.js b/client/core/src/components/th/index.js index 86a58993a..4b3716080 100644 --- a/client/core/src/components/th/index.js +++ b/client/core/src/components/th/index.js @@ -57,7 +57,7 @@ export default class Th { this.updateArrow(); - this.table.applyFilter(this.field, this.order); + this.table.applyOrder(this.field, this.order); } /** diff --git a/client/core/src/directives/index.js b/client/core/src/directives/index.js index ed316a512..fc1171d03 100644 --- a/client/core/src/directives/index.js +++ b/client/core/src/directives/index.js @@ -8,3 +8,4 @@ import './on-error-src'; import './zoom-image'; import './visible-by'; import './bind'; +import './repeat-last'; diff --git a/client/core/src/directives/repeat-last.js b/client/core/src/directives/repeat-last.js new file mode 100644 index 000000000..894666cae --- /dev/null +++ b/client/core/src/directives/repeat-last.js @@ -0,0 +1,21 @@ +import ngModule from '../module'; + +/** + * Calls a passed function if is the last element from an ng-repeat. + * + * @attribute {String} onLast - Callback function + * @return {Object} The directive + */ +directive.$inject = ['$parse']; +export function directive($parse) { + return { + restrict: 'A', + link: function($scope, $element, $attrs) { + if ($scope.$last && $attrs.onLast) { + let fn = $parse($attrs.onLast); + fn($scope); + } + } + }; +} +ngModule.directive('vnRepeatLast', directive); diff --git a/client/item/routes.json b/client/item/routes.json index 89f6b442e..018393b36 100644 --- a/client/item/routes.json +++ b/client/item/routes.json @@ -110,7 +110,7 @@ "item": "$ctrl.item" } }, { - "url" : "/diary", + "url" : "/diary?q", "state": "item.card.diary", "component": "vn-item-diary", "params": { diff --git a/client/item/src/barcode/barcode.spec.js b/client/item/src/barcode/barcode.spec.js index 585af2d71..06adc75da 100644 --- a/client/item/src/barcode/barcode.spec.js +++ b/client/item/src/barcode/barcode.spec.js @@ -88,7 +88,7 @@ describe('Item', () => { describe('submit()', () => { it("should return an error message 'The barcode must be unique' when the code isnt unique", () => { - spyOn(controller.vnApp, 'showMessage').and.callThrough(); + spyOn(controller.vnApp, 'showError').and.callThrough(); controller.barcodes = [ {code: 123454, itemFk: 1, id: 1}, {code: 123454, itemFk: 1} @@ -96,7 +96,7 @@ describe('Item', () => { controller.oldBarcodes = {1: {id: 1, code: 123454, itemFk: 1}}; controller.submit(); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The barcode must be unique'); + expect(controller.vnApp.showError).toHaveBeenCalledWith('The barcode must be unique'); }); it("should perfom a query to delete barcodes", () => { @@ -131,7 +131,7 @@ describe('Item', () => { }); it("should return a message 'No changes to save' when there are no changes to apply", () => { - spyOn(controller.vnApp, 'showMessage').and.callThrough(); + spyOn(controller.vnApp, 'showError').and.callThrough(); controller.oldBarcodes = [ {code: 1, itemFk: 1, id: 1}, {code: 2, itemFk: 1, id: 2} @@ -139,7 +139,7 @@ describe('Item', () => { controller.barcodes = []; controller.submit(); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No changes to save'); + expect(controller.vnApp.showError).toHaveBeenCalledWith('No changes to save'); }); }); }); diff --git a/client/item/src/barcode/index.js b/client/item/src/barcode/index.js index 3e31cab81..b1bbab3f4 100644 --- a/client/item/src/barcode/index.js +++ b/client/item/src/barcode/index.js @@ -86,7 +86,7 @@ export default class Controller { } if (repeatedBarcodes) { - return this.vnApp.showMessage(this.$translate.instant('The barcode must be unique')); + return this.vnApp.showError(this.$translate.instant('The barcode must be unique')); } canSubmit = barcodesObj.update.length > 0 || barcodesObj.create.length > 0 || barcodesObj.delete.length > 0; @@ -98,7 +98,7 @@ export default class Controller { this.$scope.watcher.notifySaved(); }); } - this.vnApp.showMessage(this.$translate.instant('No changes to save')); + this.vnApp.showError(this.$translate.instant('No changes to save')); } setOldBarcodes(response) { diff --git a/client/item/src/card/card.spec.js b/client/item/src/card/card.spec.js index acb6d39df..20693836a 100644 --- a/client/item/src/card/card.spec.js +++ b/client/item/src/card/card.spec.js @@ -25,8 +25,8 @@ describe('Item', () => { describe('_getItem()', () => { it('should request to get the item', () => { - $httpBackend.whenGET('/item/api/Items/123?filter={"include":[{"relation":"itemType","scope":{"fields":["name","workerFk"],"include":{"relation":"worker","fields":["firstName","name"]}}},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"}]}').respond({data: 'item'}); - $httpBackend.expectGET('/item/api/Items/123?filter={"include":[{"relation":"itemType","scope":{"fields":["name","workerFk"],"include":{"relation":"worker","fields":["firstName","name"]}}},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"}]}'); + $httpBackend.whenGET('/item/api/Items/123?filter={"include":[{"relation":"itemType","scope":{"fields":["name","workerFk","warehouseFk"],"include":{"relation":"worker","fields":["firstName","name"]}}},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"}]}').respond({data: 'item'}); + $httpBackend.expectGET('/item/api/Items/123?filter={"include":[{"relation":"itemType","scope":{"fields":["name","workerFk","warehouseFk"],"include":{"relation":"worker","fields":["firstName","name"]}}},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"}]}'); controller._getItem(); $httpBackend.flush(); }); diff --git a/client/item/src/card/index.js b/client/item/src/card/index.js index b0b14e8a7..440c498b8 100644 --- a/client/item/src/card/index.js +++ b/client/item/src/card/index.js @@ -35,7 +35,7 @@ class Controller { include: [ {relation: "itemType", scope: { - fields: ['name', 'workerFk'], + fields: ['name', 'workerFk', 'warehouseFk'], include: { relation: 'worker', fields: ['firstName', 'name'] diff --git a/client/item/src/diary/index.html b/client/item/src/diary/index.html index 321082d40..ecc4170ac 100644 --- a/client/item/src/diary/index.html +++ b/client/item/src/diary/index.html @@ -1,3 +1,10 @@ + + @@ -8,42 +15,41 @@ url="/item/api/Warehouses" show-field="name" value-field="id" - initial-data="$ctrl.warehouseFk" - field="$ctrl.warehouseFk" - label="Select warehouse"> + initial-data="$ctrl.filter.where.warehouseFk" + field="$ctrl.filter.where.warehouseFk" + label="Select warehouse" on-change="$ctrl.onChange(value)"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DateStateOriginReferenceNameInOutBalance
{{diary.date | date:'dd/MM/yyyy HH:mm' }}{{diary.alertLevel | dashIfEmpty}}{{diary.origin | dashIfEmpty}}{{diary.reference | dashIfEmpty}}{{diary.name | dashIfEmpty}}{{diary.in | dashIfEmpty}}{{diary.out | dashIfEmpty}}{{diary.balance | dashIfEmpty}}
No results
+ + + + Date + Id + State + Reference + Worker + In + Out + Balance + + + + + {{::sale.date | date:'dd/MM/yyyy HH:mm' }} + {{::sale.origin | dashIfEmpty}} + {{::sale.stateName | dashIfEmpty}} + {{::sale.reference | dashIfEmpty}} + {{sale.name | dashIfEmpty}} + {{::sale.in | dashIfEmpty}} + {{::sale.out | dashIfEmpty}} + {{::sale.balance | dashIfEmpty}} + + + + No results + +
- -
diff --git a/client/item/src/diary/index.js b/client/item/src/diary/index.js index 67c6bcd34..79af25b13 100644 --- a/client/item/src/diary/index.js +++ b/client/item/src/diary/index.js @@ -2,32 +2,96 @@ import ngModule from '../module'; import './style.scss'; class Controller { - constructor($scope, $http) { - this.$ = $scope; + constructor($scope, $http, $state, $window) { + this.$scope = $scope; this.$http = $http; - this.diary = []; + this.$state = $state; + this.$window = $window; } - set warehouseFk(value) { - this._getItemDiary(value); - this._warehouseFk = value; + $postLink() { + if (this.item) + this.filterBuilder(); } - get warehouseFk() { - return this._warehouseFk; + set item(value) { + this._item = value; + + if (value && this.$scope.model) + this.filterBuilder(); } - _getItemDiary(warehouse) { - if (warehouse == null) - return; - let params = {itemFk: this.item.id, warehouseFk: warehouse}; - this.$http.get(`/item/api/Items/getDiary?params=${JSON.stringify(params)}`).then(res => { - this.diary = res.data; - }); + get item() { + return this._item; + } + + get alertLevelIndex() { + let lines = this.$scope.model.data; + for (let i = 0; i < lines.length; i++) { + let isFutureDate = new Date(lines[i].date) > new Date(); + let isGenreOut = lines[i].alertLevel != 0; + + if (!isFutureDate && !isGenreOut) + return i; + } + } + + onChange(value) { + if (!value) return; + + 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; + } + } + + scrollToActive() { + let body = this.$window.document.body; + let lineIndex = this.alertLevelIndex; + let lines = body.querySelector('vn-tbody').children; + + if (!lineIndex || !lines.length) return; + + lines[lineIndex].scrollIntoView(); + lines[lineIndex - 1].querySelector('.balance').classList.add('counter'); + } + +/** + * Compares a date with the current one + * @param {Object} date - Date to compare + * @return {Boolean} - Returns true if the two dates equals + */ + isToday(date) { + let today = new Date(); + today.setHours(0, 0, 0, 0); + + let comparedDate = new Date(date); + comparedDate.setHours(0, 0, 0, 0); + + if (!(today - comparedDate)) + return true; } } -Controller.$inject = ['$scope', '$http']; +Controller.$inject = ['$scope', '$http', '$state', '$window']; 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 6cad8fc81..303a36083 100644 --- a/client/item/src/diary/index.spec.js +++ b/client/item/src/diary/index.spec.js @@ -17,25 +17,47 @@ describe('Item', () => { $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); $scope = $rootScope.$new(); controller = $componentController('vnItemDiary', {$scope: $scope}); - controller.item = {id: 3}; + controller.$scope.model = {}; })); - describe('set warehouseFk()', () => { - it(`should call _getItemDiary() with 2 and set warehouseFk`, () => { - spyOn(controller, '_getItemDiary'); - controller.warehouseFk = 2; + describe('isToday()', () => { + it(`should call isToday() an return true if an specified date is the current date`, () => { + let date = new Date(); - expect(controller._getItemDiary).toHaveBeenCalledWith(2); - expect(controller.warehouseFk).toEqual(2); + let result = controller.isToday(date); + + expect(result).toBeTruthy(); + }); + + it(`should call isToday() an return false if an specified date is the current date`, () => { + let date = '2018-07-03'; + + let result = controller.isToday(date); + + expect(result).toBeFalsy(); }); }); - describe('_getItemDiary()', () => { - it(`should make a request to get the diary hwen is called with a number`, () => { - $httpBackend.whenGET('/item/api/Items/getDiary?params={"itemFk":3,"warehouseFk":2}').respond({data: 'item'}); - $httpBackend.expectGET('/item/api/Items/getDiary?params={"itemFk":3,"warehouseFk":2}'); - controller._getItemDiary(2); - $httpBackend.flush(); + describe('alertLevelIndex()', () => { + it(`should call alertLevelIndex() and return an index from line with alertLevel 0 and current date`, () => { + controller.$scope.model = {data: [ + {name: 'My item 1', alertLevel: 3, date: '2018-05-02'}, + {name: 'My item 2', alertLevel: 1, date: '2018-05-03'}, + {name: 'My item 3', alertLevel: 0, date: new Date()}] + }; + let result = controller.alertLevelIndex; + + expect(result).toEqual(2); + }); + }); + + describe('set item()', () => { + it(`should call filterBuilder()`, () => { + spyOn(controller, 'filterBuilder'); + controller.item = {id: 1}; + + expect(controller.filterBuilder).toHaveBeenCalledWith(); + expect(controller.item).toEqual({id: 1}); }); }); }); diff --git a/client/item/src/history/index.html b/client/item/src/history/index.html index f6bdc9ae2..da07a8e85 100644 --- a/client/item/src/history/index.html +++ b/client/item/src/history/index.html @@ -1,29 +1,41 @@ - + + + Item history - - - - - - - - - {{::itemLog.description}} - {{::itemLog.action}} - {{::itemLog.user.name}} - {{::itemLog.creationDate | date:'dd/MM/yyyy HH:mm'}} - - - No results - + + + + Description + Action + Changed by + Date + + + + + {{::itemLog.description}} + {{::itemLog.action}} + {{::itemLog.user.name}} + {{::itemLog.creationDate | date:'dd/MM/yyyy HH:mm'}} + + + + No results + + + + - - diff --git a/client/item/src/history/index.js b/client/item/src/history/index.js index f788bf1da..910a4f488 100644 --- a/client/item/src/history/index.js +++ b/client/item/src/history/index.js @@ -1,7 +1,25 @@ import ngModule from '../module'; -import FilterItemList from '../filter-item-list'; + +class Controller { + constructor($stateParams) { + this.$stateParams = $stateParams; + this.filter = { + include: [{ + relation: "item" + }, + { + relation: "user", + scope: { + fields: ["name"] + } + }] + }; + } +} + +Controller.$inject = ['$stateParams']; ngModule.component('vnItemHistory', { template: require('./index.html'), - controller: FilterItemList + controller: Controller }); diff --git a/client/item/src/index/index.html b/client/item/src/index/index.html index a0b0f5101..a310769c3 100644 --- a/client/item/src/index/index.html +++ b/client/item/src/index/index.html @@ -1,8 +1,8 @@ diff --git a/client/item/src/index/index.js b/client/item/src/index/index.js index d772e810c..6e17a8521 100644 --- a/client/item/src/index/index.js +++ b/client/item/src/index/index.js @@ -8,38 +8,23 @@ class Controller { this.$state = $state; this.$ = $scope; this.itemSelected = null; - - this.filter = { - include: [ - {relation: 'itemType', - scope: { - fields: ['name', 'workerFk'], - include: { - relation: 'worker', - fields: ['firstName', 'name'] - } - } - } - ], - order: 'name ASC' - }; } exprBuilder(param, value) { switch (param) { case 'search': - return { - or: [ - {id: value}, - {name: {regexp: value}} - ] - }; + return /^\d+$/.test(value) + ? {id: value} + : {name: {like: `%${value}%`}}; case 'name': case 'description': - return {[param]: {regexp: value}}; + return {[param]: {like: `%${value}%`}}; case 'id': case 'typeFk': return {[param]: value}; + case 'tags': + this.$.model.userParams = {tags: value}; + break; } } diff --git a/client/item/src/index/product.html b/client/item/src/index/product.html index 63a413c6b..99419f138 100644 --- a/client/item/src/index/product.html +++ b/client/item/src/index/product.html @@ -21,10 +21,10 @@ value="{{::$ctrl.item.size}}"> + value="{{::$ctrl.item.type}}"> + value="{{::$ctrl.item.firstName}} {{::$ctrl.item.worker}}"> diff --git a/client/item/src/index/product.js b/client/item/src/index/product.js index 71d730e29..d141677f5 100644 --- a/client/item/src/index/product.js +++ b/client/item/src/index/product.js @@ -8,12 +8,12 @@ class ItemProduct { clone(event) { event.preventDefault(); - this.ItemList.cloneItem(this.item); + this.index.cloneItem(this.item); } preview(event) { event.preventDefault(); - this.ItemList.showItemPreview(this.item); + this.index.showItemPreview(this.item); } } @@ -24,6 +24,6 @@ ngModule.component('vnItemProduct', { }, controller: ItemProduct, require: { - ItemList: '^vnItemIndex' + index: '^vnItemIndex' } }); diff --git a/client/item/src/last-entries/index.html b/client/item/src/last-entries/index.html index 1a2735a32..1f427719f 100644 --- a/client/item/src/last-entries/index.html +++ b/client/item/src/last-entries/index.html @@ -1,3 +1,9 @@ + + @@ -6,63 +12,65 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IgWarehouseLandedEntryP.P.UP.P.PLabelPackingGroupingStemsQuantityCostCubeProvider
+ + + + Ig + Warehouse + Landed + Entry + P.P.U + P.P.P + Label + Packing + Grouping + Stems + Quantity + Cost + Cube + Provider + + + + + - {{entries.warehouse| dashIfEmpty}}{{entries.landed | date:'dd/MM/yyyy HH:mm'}}{{entries.entryFk | dashIfEmpty}}{{entries.price2 | dashIfEmpty}}{{entries.price3 | dashIfEmpty}}{{entries.stickers | dashIfEmpty}} -
{{entries.packing | dashIfEmpty}}
-
-
{{entries.grouping | dashIfEmpty}}
-
{{entries.stems | dashIfEmpty}}{{entries.quantity}}{{entries.buyingValue | dashIfEmpty}}{{entries.packageFk | dashIfEmpty}}{{entries.supplier | dashIfEmpty}}
No results
+ + {{entry.warehouse| dashIfEmpty}} + {{entry.landed | date:'dd/MM/yyyy HH:mm'}} + {{entry.entryFk | dashIfEmpty}} + {{entry.price2 | dashIfEmpty}} + {{entry.price3 | dashIfEmpty}} + {{entry.stickers | dashIfEmpty}} + +
{{entry.packing | dashIfEmpty}}
+
+ + {{entry.grouping | dashIfEmpty}} + + {{entry.stems | dashIfEmpty}} + {{entry.quantity}} + {{entry.buyingValue | dashIfEmpty}} + {{entry.packageFk | dashIfEmpty}} + {{entry.supplier | dashIfEmpty}} + + + + No results + + + + - - diff --git a/client/item/src/last-entries/index.js b/client/item/src/last-entries/index.js index 5fa32e7eb..3ef89f086 100644 --- a/client/item/src/last-entries/index.js +++ b/client/item/src/last-entries/index.js @@ -2,50 +2,38 @@ import ngModule from '../module'; import './style.scss'; class Controller { - constructor($scope, $http) { - this.$ = $scope; - this.$http = $http; - this.entries = []; - } + constructor($scope, $stateParams) { + this.$scope = $scope; + this.$stateParams = $stateParams; - set item(value) { - this._item = value; - this._defaultEntriesDate(); - this._getLastEntries(); - } - - get item() { - return this._item; - } - - set entriesDate(value) { - this._entriesDate = value; - this._getLastEntries(); - } - - get entriesDate() { - return this._entriesDate; - } - - _defaultEntriesDate() { - let defaultDate; - defaultDate = new Date(); + let defaultDate = new Date(); defaultDate.setDate(defaultDate.getDate() - 75); defaultDate.setHours(0, 0, 0, 0); - this._entriesDate = defaultDate; + + this.filter = { + where: { + itemFk: $stateParams.id, + date: defaultDate + } + }; + this._date = defaultDate; } - _getLastEntries() { - if (!this.entriesDate || !this.item) - return; - let filter = {itemFk: this.item.id, date: this.entriesDate}; - this.$http.get(`/item/api/Items/getLastEntries?filter=${JSON.stringify(filter)}`).then(res => { - this.entries = res.data; - }); + set date(value) { + this._date = value; + + if (!value) return; + + this.filter.where.date = value; + this.$scope.model.refresh(); + } + + get date() { + return this._date; } } -Controller.$inject = ['$scope', '$http']; +Controller.$inject = ['$scope', '$stateParams']; ngModule.component('vnItemLastEntries', { template: require('./index.html'), diff --git a/client/item/src/last-entries/index.spec.js b/client/item/src/last-entries/index.spec.js deleted file mode 100644 index 50e68d4d5..000000000 --- a/client/item/src/last-entries/index.spec.js +++ /dev/null @@ -1,71 +0,0 @@ -import './index.js'; - -describe('Item', () => { - describe('Component vnItemLastEntries', () => { - let $componentController; - let $scope; - let controller; - let $httpBackend; - let defaultDate; - - beforeEach(() => { - angular.mock.module('item'); - }); - - beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => { - $componentController = _$componentController_; - $httpBackend = _$httpBackend_; - $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); - $scope = $rootScope.$new(); - controller = $componentController('vnItemLastEntries', {$scope: $scope}); - controller.item = {id: 3}; - })); - - describe('set item()', () => { - it(`should set item and call _defaultEntriesDate() and _getLastEntries()`, () => { - spyOn(controller, '_defaultEntriesDate'); - spyOn(controller, '_getLastEntries'); - controller.item = []; - - expect(controller._defaultEntriesDate).toHaveBeenCalledWith(); - expect(controller._getLastEntries).toHaveBeenCalledWith(); - expect(controller.item).toEqual([]); - }); - }); - - describe('set entriesDate()', () => { - it(`should set entriesDate and call _getLastEntries()`, () => { - spyOn(controller, '_getLastEntries'); - controller.item = []; - controller.entriesDate = new Date(); - - expect(controller._getLastEntries).toHaveBeenCalledWith(); - expect(controller.item).toEqual([]); - }); - }); - - describe('_defaultEntriesDate()', () => { - it(`should set entriesDate to a date 75 days ago`, () => { - defaultDate = new Date(); - defaultDate.setDate(defaultDate.getDate() - 75); - defaultDate.setHours(0, 0, 0, 0); - controller._defaultEntriesDate(); - - expect(controller.entriesDate).toEqual(defaultDate); - }); - }); - - describe('_getLastEntries()', () => { - it(`should make a GET if entriesDate and item are defined`, () => { - controller._defaultEntriesDate(); - let filter = {itemFk: controller.item.id, date: controller.entriesDate}; - $httpBackend.whenGET(`/item/api/Items/getLastEntries?filter=${JSON.stringify(filter)}`).respond([]); - $httpBackend.expectGET(`/item/api/Items/getLastEntries?filter=${JSON.stringify(filter)}`); - controller._getLastEntries(); - $httpBackend.flush(); - // expect(controller.entriesDate).toEqual(defaultDate); - }); - }); - }); -}); - diff --git a/client/item/src/locale/es.yml b/client/item/src/locale/es.yml index 89cffcc67..75e27ff1f 100644 --- a/client/item/src/locale/es.yml +++ b/client/item/src/locale/es.yml @@ -50,4 +50,5 @@ Add barcode: Añadir código de barras Remove barcode: Quitar código de barras Buyer: Comprador No results: Sin resultados -Tag: Etiqueta \ No newline at end of file +Tag: Etiqueta +Worker: Trabajador \ No newline at end of file diff --git a/client/item/src/niche/index.js b/client/item/src/niche/index.js index 9fec4ba91..f483fb1f9 100644 --- a/client/item/src/niche/index.js +++ b/client/item/src/niche/index.js @@ -122,11 +122,11 @@ export default class Controller { }); if (this.$scope.form.$invalid) { - return this.vnApp.showMessage(this.$translate.instant('Some fields are invalid')); + return this.vnApp.showError(this.$translate.instant('Some fields are invalid')); } if (repeatedWarehouse) { - return this.vnApp.showMessage(this.$translate.instant('The niche must be unique')); + return this.vnApp.showError(this.$translate.instant('The niche must be unique')); } canSubmit = nichesObj.update.length > 0 || nichesObj.create.length > 0 || nichesObj.delete.length > 0; @@ -138,7 +138,7 @@ export default class Controller { this.$scope.watcher.notifySaved(); }); } - this.vnApp.showMessage(this.$translate.instant('No changes to save')); + this.vnApp.showError(this.$translate.instant('No changes to save')); } } diff --git a/client/item/src/niche/niche.spec.js b/client/item/src/niche/niche.spec.js index d3b91be9e..0309d2535 100644 --- a/client/item/src/niche/niche.spec.js +++ b/client/item/src/niche/niche.spec.js @@ -98,7 +98,7 @@ describe('Item', () => { describe('submit()', () => { it("should return an error message 'The niche must be unique' when the niche warehouse isnt unique", () => { controller.$scope.form = {}; - spyOn(controller.vnApp, 'showMessage').and.callThrough(); + spyOn(controller.vnApp, 'showError').and.callThrough(); controller.niches = [ {warehouseFk: 1, code: 123454, itemFk: 1, id: 1}, {warehouseFk: 1, code: 123454, itemFk: 1} @@ -106,7 +106,7 @@ describe('Item', () => { controller.oldNiches = {1: {warehouseFk: 1, id: 1, code: 123454, itemFk: 1}}; controller.submit(); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The niche must be unique'); + expect(controller.vnApp.showError).toHaveBeenCalledWith('The niche must be unique'); }); it("should perfom a query to delete niches", () => { @@ -144,7 +144,7 @@ describe('Item', () => { it("should return a message 'No changes to save' when there are no changes to apply", () => { controller.$scope.form = {$setPristine: () => {}}; - spyOn(controller.vnApp, 'showMessage').and.callThrough(); + spyOn(controller.vnApp, 'showError').and.callThrough(); controller.oldNiches = [ {warehouseFk: 1, code: 1, itemFk: 1, id: 1}, {warehouseFk: 2, code: 2, itemFk: 1, id: 2} @@ -152,7 +152,7 @@ describe('Item', () => { controller.niches = []; controller.submit(); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No changes to save'); + expect(controller.vnApp.showError).toHaveBeenCalledWith('No changes to save'); }); }); }); diff --git a/client/item/src/search-panel/index.html b/client/item/src/search-panel/index.html index 5b545d8bc..392efb51e 100644 --- a/client/item/src/search-panel/index.html +++ b/client/item/src/search-panel/index.html @@ -30,7 +30,6 @@ model="filter.description"> - diff --git a/client/item/src/tags/tags.spec.js b/client/item/src/tags/tags.spec.js index 41e2380a6..5b3049809 100644 --- a/client/item/src/tags/tags.spec.js +++ b/client/item/src/tags/tags.spec.js @@ -132,7 +132,7 @@ describe('Item', () => { // TODO: Server validation should be implemented xit("should return an error message 'The tag must be unique' when the tag value isnt unique", () => { controller.$.form = []; - spyOn(controller.vnApp, 'showMessage').and.callThrough(); + spyOn(controller.vnApp, 'showError').and.callThrough(); controller.tags = [ {typeFk: 1, value: 123454, itemFk: 1, id: 1}, {typeFk: 1, value: 123454, itemFk: 1} @@ -140,7 +140,7 @@ describe('Item', () => { controller.orgTags = {1: {typeFk: 1, id: 1, value: 123454, itemFk: 1}}; controller.submit(); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The tag must be unique'); + expect(controller.vnApp.showError).toHaveBeenCalledWith('The tag must be unique'); }); it("should perfom a query to delete tags", () => { diff --git a/client/item/src/tax/index.js b/client/item/src/tax/index.js index 9ad2ad592..5e5e108f1 100644 --- a/client/item/src/tax/index.js +++ b/client/item/src/tax/index.js @@ -29,7 +29,7 @@ export default class Controller { let url = `/item/api/Items/${this.$stateParams.id}/updateTaxes`; this.$http.post(url, data).then( - () => this.vnApp.showMessage(this._.instant('Data saved!')) + () => this.vnApp.showSuccess(this._.instant('Data saved!')) ); } } diff --git a/client/order/routes.json b/client/order/routes.json index a57904950..a516f01ad 100644 --- a/client/order/routes.json +++ b/client/order/routes.json @@ -8,7 +8,8 @@ "url": "/order", "state": "order", "abstract": true, - "component": "ui-view" + "component": "ui-view", + "acl": ["developer"] }, { "url": "/index?q", diff --git a/client/salix/src/styles/misc.scss b/client/salix/src/styles/misc.scss index 4e311df21..f94ddb8bd 100644 --- a/client/salix/src/styles/misc.scss +++ b/client/salix/src/styles/misc.scss @@ -242,4 +242,15 @@ fieldset[disabled] .mdl-textfield .mdl-textfield__label, text-overflow: ellipsis; white-space: nowrap; overflow: hidden; +} + +.counter { + background-color: $main-header; + color: $color-white; + border-radius: 3px; + padding: 5px +} + +.counter.small { + font-size: 0.7em } \ No newline at end of file diff --git a/client/ticket/routes.json b/client/ticket/routes.json index eb65fe367..7fae3e5ae 100644 --- a/client/ticket/routes.json +++ b/client/ticket/routes.json @@ -153,8 +153,7 @@ "menu": { "description": "Tracking", "icon": "remove_red_eye" - }, - "acl": ["production"] + } }, { "url": "/edit", @@ -162,15 +161,8 @@ "component": "vn-ticket-tracking-edit", "params": { "ticket": "$ctrl.ticket" - } - }, - { - "url": "/create", - "state": "ticket.card.tracking.create", - "component": "vn-ticket-tracking-create", - "params": { - "client": "$ctrl.client" - } + }, + "acl": ["production"] }, { "url" : "/sale-checked", @@ -195,6 +187,18 @@ "description": "Components", "icon": "icon-components" } + }, + { + "url" : "/sale-tracking", + "state": "ticket.card.saleTracking", + "component": "vn-ticket-sale-tracking", + "params": { + "ticket": "$ctrl.ticket" + }, + "menu": { + "description": "Sale tracking", + "icon": "assignment" + } } ] } \ No newline at end of file diff --git a/client/ticket/src/component/index.html b/client/ticket/src/component/index.html index 11d600bb7..67af10bd9 100644 --- a/client/ticket/src/component/index.html +++ b/client/ticket/src/component/index.html @@ -67,7 +67,6 @@ - diff --git a/client/ticket/src/create/card.html b/client/ticket/src/create/card.html new file mode 100644 index 000000000..e1b7a611d --- /dev/null +++ b/client/ticket/src/create/card.html @@ -0,0 +1,34 @@ +New order + + {{id}}: {{name}} + + + {{nickname}}: {{street}}, {{city}} + + + + + diff --git a/client/ticket/src/create/card.js b/client/ticket/src/create/card.js new file mode 100644 index 000000000..36fee36b3 --- /dev/null +++ b/client/ticket/src/create/card.js @@ -0,0 +1,93 @@ +import ngModule from '../module'; + +class Controller { + constructor($scope, $http, vnApp, $translate) { + this.$scope = $scope; + this.$http = $http; + this.translate = $translate; + this.vnApp = vnApp; + this.ticket = {}; + } + + set ticket(value) { + if (value) { + this._ticket = value; + } + } + + get ticket() { + return this._ticket; + } + + set clientFk(value) { + this.ticket.clientFk = value; + this.addressFk = null; + } + + get clientFk() { + return this.ticket.clientFk; + } + + set addressFk(value) { + this.ticket.addressFk = value; + this.getAvaibleAgencies(); + } + + get addressFk() { + return this.ticket.addressFk; + } + + set landed(value) { + this.ticket.landed = value; + this.getAvaibleAgencies(); + } + + get landed() { + return this.ticket.landed; + } + + get warehouseFk() { + return this.ticket.warehouseFk; + } + + getAvaibleAgencies() { + this.ticket.agencyModeFk = null; + if (this.ticket.landed && this.ticket.addressFk) { + let filter = {addressFk: this.ticket.addressFk, landed: this.ticket.landed}; + filter = encodeURIComponent(JSON.stringify(filter)); + let query = `/api/Agencies/landsThatDay?filter=${filter}`; + this.$http.get(query).then(res => { + this._avaibleAgencies = res.data[0]; + }); + } + } + + onSubmit() { + this.createOrder(); + } + + createOrder() { + let params = { + landed: this.ticket.landed, + addressFk: this.ticket.addressFk, + agencyModeFk: this.ticket.agencyModeFk + }; + + this.$http.post(`order/api/Orders/new`, params).then(res => { + this.vnApp.showSuccess(this.translate.instant('Data saved!')); + return res.data.id; + }).catch(e => { + this.vnApp.showError(this.translate.instant(e.data.error.message)); + }); + } +} + +Controller.$inject = ['$scope', '$http', 'vnApp', '$translate']; + +ngModule.component('vnTicketCreateCard', { + template: require('./card.html'), + controller: Controller, + bindings: { + ticket: ' { + describe('Component vnTicketCreateCard', () => { + let $componentController; + let $scope; + let controller; + let $httpBackend; + + beforeEach(() => { + angular.mock.module('ticket'); + }); + + beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => { + $componentController = _$componentController_; + $httpBackend = _$httpBackend_; + $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); + $scope = $rootScope.$new(); + controller = $componentController('vnTicketCreateCard', {$scope: $scope}); + controller.item = {id: 3}; + })); + + describe('set clientFk', () => { + it(`should set addressFk to null and clientFk to a value`, () => { + controller.clientFk = 2; + + expect(controller.clientFk).toEqual(2); + expect(controller.ticket.addressFk).toBe(null); + }); + }); + + describe('set addressFk', () => { + it(`should set agencyModeFk property to null and addressFk to a value`, () => { + controller.addressFk = 101; + + expect(controller.addressFk).toEqual(101); + expect(controller.ticket.agencyModeFk).toBe(null); + }); + }); + + describe('getAvaibleAgencies()', () => { + it(`should make a query if landed and addressFk exists`, () => { + controller.ticket.addressFk = 101; + controller.ticket.landed = 101; + + let filter = {addressFk: controller.ticket.addressFk, landed: controller.ticket.landed}; + filter = encodeURIComponent(JSON.stringify(filter)); + $httpBackend.whenGET(`/api/Agencies/landsThatDay?filter=${filter}`).respond({data: 1}); + $httpBackend.expectGET(`/api/Agencies/landsThatDay?filter=${filter}`); + + controller.getAvaibleAgencies(); + $httpBackend.flush(); + }); + }); + + describe('onSubmit()', () => { + it(`should call createOrder()`, () => { + spyOn(controller, 'createOrder'); + controller.onSubmit(); + + expect(controller.createOrder).toHaveBeenCalledWith(); + }); + }); + + describe('createOrder()', () => { + it(`should make a query`, () => { + controller.ticket.addressFk = 101; + controller.ticket.agencyModeFk = 101; + controller.ticket.landed = 101; + + $httpBackend.whenPOST('order/api/Orders/new').respond({data: 1}); + $httpBackend.expectPOST('order/api/Orders/new'); + controller.createOrder(); + $httpBackend.flush(); + }); + }); + }); +}); + diff --git a/client/ticket/src/create/index.html b/client/ticket/src/create/index.html index 1542ffbc4..5e7e469c8 100644 --- a/client/ticket/src/create/index.html +++ b/client/ticket/src/create/index.html @@ -1,18 +1,11 @@ - - - - -
+
+
- New ticket - + - + +
- +
\ No newline at end of file diff --git a/client/ticket/src/create/index.js b/client/ticket/src/create/index.js index d7a59d800..2c50c1e44 100644 --- a/client/ticket/src/create/index.js +++ b/client/ticket/src/create/index.js @@ -1,20 +1,18 @@ import ngModule from '../module'; class Controller { - constructor($scope, $state) { + constructor($scope, $http, $state) { this.$ = $scope; + this.$http = $http; this.$state = $state; - this.Ticket = {}; } - onSubmit() { - this.$.watcher.submit().then( - json => this.$state.go('ticket.card.data', {id: json.data.id}) - ); + async onSubmit() { + let newOrderID = await this.$.card.createOrder(); + this.$state.go("ticket.card.summary", {id: newOrderID}); } } - -Controller.$inject = ['$scope', '$state']; +Controller.$inject = ['$scope', '$http', '$state']; ngModule.component('vnTicketCreate', { template: require('./index.html'), diff --git a/client/ticket/src/create/index.spec.js b/client/ticket/src/create/index.spec.js new file mode 100644 index 000000000..89a59ca39 --- /dev/null +++ b/client/ticket/src/create/index.spec.js @@ -0,0 +1,40 @@ +import './index.js'; + +describe('Ticket', () => { + describe('Component vnTicketCreate', () => { + let $componentController; + let $scope; + let controller; + let $state; + + beforeEach(() => { + angular.mock.module('ticket'); + }); + + beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$state_) => { + $componentController = _$componentController_; + + $scope = $rootScope.$new(); + $scope.card = {createOrder: () => {}}; + $state = _$state_; + controller = $componentController('vnTicketCreate', {$scope: $scope, $state: $state}); + })); + + describe('onSubmit()', () => { + it(`should call createOrder()`, () => { + spyOn(controller.$.card, 'createOrder'); + controller.onSubmit(); + + expect(controller.$.card.createOrder).toHaveBeenCalledWith(); + }); + + xit(`should call go()`, () => { + spyOn(controller.$state, 'go'); + controller.onSubmit(); + + expect(controller.$state.go).toHaveBeenCalledWith(); + }); + }); + }); +}); + diff --git a/client/ticket/src/create/locale/es.yml b/client/ticket/src/create/locale/es.yml new file mode 100644 index 000000000..df21d09f4 --- /dev/null +++ b/client/ticket/src/create/locale/es.yml @@ -0,0 +1,6 @@ +You can't create an order for a frozen client: No puedes crear una orden a un cliente congelado +You can't create an order for a inactive client: No puedes crear una orden a un cliente inactivo +You can't create an order for a client that doesn't has tax data verified: + No puedes crear una orden a un cliente cuyos datos fiscales no han sido verificados +You can't create an order for a client that has a debt: No puedes crear una orden a un cliente que tiene deuda +New order: Nueva orden \ No newline at end of file diff --git a/client/ticket/src/data/step-one/index.html b/client/ticket/src/data/step-one/index.html index 19bf410c6..d0c56ec12 100644 --- a/client/ticket/src/data/step-one/index.html +++ b/client/ticket/src/data/step-one/index.html @@ -8,16 +8,18 @@ label="Client" show-field="name" value-field="id" - field="$ctrl.ticket.clientFk" - initial-data="$ctrl.ticket.clientFk" - on-change="$ctrl.onChange()"> + field="$ctrl.clientFk" + initial-data="$ctrl.clientFk"> + {{::nickname}} + - {{::city}} ({{::province.name}}) + { + if (res.data) + this.addresses = res.data; + }); } async onStepChange(state) { diff --git a/client/ticket/src/data/step-one/step-one.spec.js b/client/ticket/src/data/step-one/step-one.spec.js index 625c90e90..83c94e7de 100644 --- a/client/ticket/src/data/step-one/step-one.spec.js +++ b/client/ticket/src/data/step-one/step-one.spec.js @@ -19,6 +19,25 @@ describe('ticket', () => { controller = $componentController('vnTicketDataStepOne', {$state: $state}); })); + describe('ticket() setter', () => { + it('should set ticket property and call onChange() method ', () => { + spyOn(controller, 'onChange'); + controller.ticket = {id: 1, clientFk: 101}; + + expect(controller.onChange).toHaveBeenCalledWith(101); + }); + }); + + describe('clientFk() setter', () => { + it('should set clientFk property and call onChange() method ', () => { + spyOn(controller, 'onChange'); + controller.ticket = {id: 1, clientFk: 101}; + controller.clientFk = 102; + + expect(controller.onChange).toHaveBeenCalledWith(102); + }); + }); + describe('isFormInvalid()', () => { it('should check if all form fields are valid', () => { controller.ticket = { @@ -31,8 +50,7 @@ describe('ticket', () => { landed: new Date() }; - let result = controller.isFormInvalid(); - expect(result).toBeFalsy(); + expect(controller.isFormInvalid()).toBeFalsy(); }); }); @@ -41,7 +59,7 @@ describe('ticket', () => { let landed = new Date(); landed.setHours(0, 0, 0, 0); - controller.ticket = { + controller._ticket = { id: 1, clientFk: 1, addressFk: 121, diff --git a/client/ticket/src/expedition/index.html b/client/ticket/src/expedition/index.html index 8da3bbfb5..a7908559a 100644 --- a/client/ticket/src/expedition/index.html +++ b/client/ticket/src/expedition/index.html @@ -40,6 +40,5 @@ - - + diff --git a/client/ticket/src/fetched-tags/index.html b/client/ticket/src/fetched-tags/index.html index 4a3c679a7..7b6515d7c 100644 --- a/client/ticket/src/fetched-tags/index.html +++ b/client/ticket/src/fetched-tags/index.html @@ -1,10 +1,10 @@ - + {{::$ctrl.sale.concept}}
+ vn-tooltip="{{::fetchedTag.tag.name}}: {{::fetchedTag.value}}"> {{::fetchedTag.value}}
diff --git a/client/ticket/src/fetched-tags/style.scss b/client/ticket/src/fetched-tags/style.scss index 6abfd33d5..31738193e 100644 --- a/client/ticket/src/fetched-tags/style.scss +++ b/client/ticket/src/fetched-tags/style.scss @@ -1,42 +1,54 @@ @import "colors"; vn-fetched-tags { - @media screen and (max-width: 1700px){ + @media screen and (max-width: 1600px){ & vn-horizontal { flex-direction: column; text-align: center; - & .inline-tag { - display: inline-block; - float: none + & vn-two { + text-align: center; + margin: 0 auto + } + + .inline-tag { + font-size: 0.7em; + padding: 0.3em } } } - - & vn-one:first-child { - padding-top: 0.36em + + @media screen and (max-width: 1200px){ + & vn-horizontal { + .inline-tag { + font-size: 0.6em; + padding: 0.2em + } + } } + + & vn-one { + padding-top: 6px + } + + & vn-two { + white-space: nowrap + } + & .inline-tag { background-color: $secondary-font-color; - margin: 0.4em 0.4em 0 0; + display: inline-block; color: $color-white; + margin-right: 0.4em; text-align: center; font-size: 0.8em; height: 1.25em; padding: 0.4em; - float: left; width: 5em } & .inline-tag.empty { background-color: $main-bg } - - & .inline-tag.empty:after { - overflow: hidden; - display: block; - content: ' '; - clear: both - } } \ No newline at end of file diff --git a/client/ticket/src/index/index.html b/client/ticket/src/index/index.html index e04c85854..f0411633f 100644 --- a/client/ticket/src/index/index.html +++ b/client/ticket/src/index/index.html @@ -39,16 +39,16 @@ class="{{::$ctrl.compareDate(ticket.shipped)}} clickable" ui-sref="ticket.card.summary({id: {{::ticket.id}}})"> {{::ticket.id}} - {{::ticket.client.salesPerson.name | dashIfEmpty}} - {{::ticket.shipped | date:'dd/MM/yyyy'}} - {{::ticket.shipped | date:'HH:MM'}} - {{::ticket.nickname}} - {{::ticket.address.province.name}} - {{::ticket.tracking.state.name}} - {{::ticket.agencyMode.name}} - {{::ticket.warehouse.name}} - {{::ticket.refFk | dashIfEmpty}} - {{::ticket.routeFk | dashIfEmpty}} + {{::ticket.client.salesPerson.name | dashIfEmpty}} + {{::ticket.shipped | date:'dd/MM/yyyy'}} + {{::ticket.shipped | date:'HH:mm'}} + {{::ticket.nickname}} + {{::ticket.address.province.name}} + {{::ticket.tracking.state.name}} + {{::ticket.agencyMode.name}} + {{::ticket.warehouse.name}} + {{::ticket.refFk | dashIfEmpty}} + {{::ticket.routeFk | dashIfEmpty}} 0 || observationsObj.create.length > 0 || observationsObj.delete.length > 0; @@ -122,7 +122,7 @@ class Controller { this.$scope.watcher.notifySaved(); }); } - this.vnApp.showMessage(this.$translate.instant('No changes to save')); + this.vnApp.showError(this.$translate.instant('No changes to save')); } $onInit() { diff --git a/client/ticket/src/note/ticket-observation.spec.js b/client/ticket/src/note/ticket-observation.spec.js index f1bbbdd0b..fc2681375 100644 --- a/client/ticket/src/note/ticket-observation.spec.js +++ b/client/ticket/src/note/ticket-observation.spec.js @@ -90,7 +90,7 @@ describe('ticket', () => { it("should return an error message 'Some fields are invalid'", () => { controller.$scope.form = {}; controller.$scope.form.$invalid = true; - spyOn(controller.vnApp, 'showMessage').and.callThrough(); + spyOn(controller.vnApp, 'showError').and.callThrough(); controller.ticketObservations = [ {id: 1, observationTypeFk: 1, description: 'one', itemFk: 1}, {observationTypeFk: 1, description: 'one', itemFk: 1} @@ -98,12 +98,12 @@ describe('ticket', () => { controller.oldObservations = {1: {id: 1, observationTypeFk: 1, description: 'one', itemFk: 1}}; controller.submit(); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Some fields are invalid'); + expect(controller.vnApp.showError).toHaveBeenCalledWith('Some fields are invalid'); }); it("should return an error message 'The observation type must be unique'", () => { controller.$scope.form = {}; - spyOn(controller.vnApp, 'showMessage').and.callThrough(); + spyOn(controller.vnApp, 'showError').and.callThrough(); controller.ticketObservations = [ {id: 1, observationTypeFk: 1, description: 'one', itemFk: 1}, {observationTypeFk: 1, description: 'one', itemFk: 1} @@ -111,7 +111,7 @@ describe('ticket', () => { controller.oldObservations = {1: {id: 1, observationTypeFk: 1, description: 'one', itemFk: 1}}; controller.submit(); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The observation type must be unique'); + expect(controller.vnApp.showError).toHaveBeenCalledWith('The observation type must be unique'); }); it("should perfom a query to delete observations", () => { @@ -149,7 +149,7 @@ describe('ticket', () => { it("should return a message 'No changes to save' when there are no changes to apply", () => { controller.$scope.form = {$setPristine: () => {}}; - spyOn(controller.vnApp, 'showMessage').and.callThrough(); + spyOn(controller.vnApp, 'showError').and.callThrough(); controller.oldObservations = [ {id: 1, observationTypeFk: 1, description: 'one', showAddIcon: false}, {id: 2, observationTypeFk: 2, description: 'two', showAddIcon: true} @@ -157,7 +157,7 @@ describe('ticket', () => { controller.ticketObservations = []; controller.submit(); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No changes to save'); + expect(controller.vnApp.showError).toHaveBeenCalledWith('No changes to save'); }); }); }); diff --git a/client/ticket/src/package/index.js b/client/ticket/src/package/index.js index a3f1119f9..c26be3d21 100644 --- a/client/ticket/src/package/index.js +++ b/client/ticket/src/package/index.js @@ -26,10 +26,10 @@ class Controller { }); if (this.$.form.$invalid) - return this.vnApp.showMessage(this.$translate.instant('Some fields are invalid')); + return this.vnApp.showError(this.$translate.instant('Some fields are invalid')); if (!this.hasChanges(packagesObj)) - return this.vnApp.showMessage(this.$translate.instant('No changes to save')); + return this.vnApp.showError(this.$translate.instant('No changes to save')); this.$http.post(query, packagesObj).then(res => { this.$.index.accept(); diff --git a/client/ticket/src/sale-checked/index.html b/client/ticket/src/sale-checked/index.html index 00de7cec2..6d68a0d7d 100644 --- a/client/ticket/src/sale-checked/index.html +++ b/client/ticket/src/sale-checked/index.html @@ -33,6 +33,5 @@ - - + diff --git a/client/ticket/src/sale-tracking/index.html b/client/ticket/src/sale-tracking/index.html new file mode 100644 index 000000000..13b81943a --- /dev/null +++ b/client/ticket/src/sale-tracking/index.html @@ -0,0 +1,62 @@ + + + + + + Sale tracking + + + + + Item + Description + Quantity + Original quantity + Worker + State + Created + + + + + + + + + {{::sale.itemFk}} + + + {{::sale.quantity}} + {{::sale.originalQuantity}} + + {{::sale.firstName}} {{::sale.name}} + + {{::sale.state}} + {{::sale.created | date: 'dd/MM/yyyy HH:mm'}} + + + + No results + + + + + + + + + + diff --git a/client/ticket/src/sale-tracking/index.js b/client/ticket/src/sale-tracking/index.js new file mode 100644 index 000000000..b1fd653a3 --- /dev/null +++ b/client/ticket/src/sale-tracking/index.js @@ -0,0 +1,31 @@ +import ngModule from '../module'; + +class Controller { + constructor($scope, $state, $http) { + this.$scope = $scope; + this.$http = $http; + this.filter = { + where: {ticketFk: $state.params.id} + }; + } + + showDescriptor(event, itemFk) { + this.$scope.descriptor.itemFk = itemFk; + this.$scope.descriptor.parent = event.target; + this.$scope.descriptor.show(); + } + + onDescriptorLoad() { + this.$scope.popover.relocate(); + } +} + +Controller.$inject = ['$scope', '$state', '$http']; + +ngModule.component('vnTicketSaleTracking', { + template: require('./index.html'), + controller: Controller, + bindings: { + ticket: '<' + } +}); diff --git a/client/ticket/src/sale/editDiscount.html b/client/ticket/src/sale/editDiscount.html index c6d7e34cd..58e49e1bc 100644 --- a/client/ticket/src/sale/editDiscount.html +++ b/client/ticket/src/sale/editDiscount.html @@ -5,7 +5,7 @@ % @@ -18,7 +18,7 @@ | currency:' €':2}}

+ ng-click="$ctrl.hide()">
\ No newline at end of file diff --git a/client/ticket/src/sale/editDiscount.js b/client/ticket/src/sale/editDiscount.js index 2ec694c56..bdb4f76d6 100644 --- a/client/ticket/src/sale/editDiscount.js +++ b/client/ticket/src/sale/editDiscount.js @@ -45,11 +45,15 @@ class Controller { if (modified) { this.$http.post(`/ticket/api/Sales/updateDiscount`, {editLines}).then(() => { this.hide(); + this.vnApp.showSuccess(this.translate.instant('Data saved!')); + this.clear(); + modified = false; + }).catch(e => { + this.vnApp.showError(this.translate.instant(e.data.error.message)); }); } else { this.vnApp.showError(this.translate.instant('There is no changes to save')); } - this.clear(); } clear() { diff --git a/client/ticket/src/sale/index.html b/client/ticket/src/sale/index.html index 74d8e7782..4aaeb8408 100644 --- a/client/ticket/src/sale/index.html +++ b/client/ticket/src/sale/index.html @@ -1,4 +1,3 @@ - @@ -16,17 +15,17 @@ on-change="$ctrl.onStateChange(value)"> + on-open="$ctrl.onMoreOpen()"> @@ -42,29 +41,40 @@ - - - + + + + - + - - + + + + - - + + -
ItemDescriptionItemIdDescription Quantity PriceDiscountDisc Amount
+ + + + + + {{::sale.itemFk}} {{sale.quantity}} + type="text"> + vn-tooltip="Edit price"> {{sale.price | currency:'€':2}} @@ -104,12 +115,12 @@ {{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency:' €':2}}
No results
No results
+

Subtotal {{$ctrl.subTotal | currency:' €':2}}

VAT {{$ctrl.VAT | currency:' €':2}}

@@ -122,7 +133,6 @@
- @@ -185,10 +195,9 @@
@@ -196,7 +205,7 @@

New price

-

{{($ctrl.sale.quantity * $ctrl.sale.price) +

{{($ctrl.sale.quantity * $ctrl.editedPrice) - (($ctrl.sale.discount * ($ctrl.sale.quantity * $ctrl.editedPrice))/100) | currency:' €':2}}

- - + + + + + +
@@ -286,3 +302,9 @@ question="You are going to delete this ticket" message="Continue anyway?"> + + \ No newline at end of file diff --git a/client/ticket/src/sale/index.js b/client/ticket/src/sale/index.js index 2369ca25e..7d6697f93 100644 --- a/client/ticket/src/sale/index.js +++ b/client/ticket/src/sale/index.js @@ -1,48 +1,57 @@ import ngModule from '../module'; -import FilterTicketList from '../filter-ticket-list'; import './style.scss'; -class Controller extends FilterTicketList { +class Controller { constructor($scope, $timeout, $stateParams, $http, vnApp, $translate) { - super($scope, $timeout, $stateParams); this.$ = $scope; this.vnApp = vnApp; this.translate = $translate; this.$timeout = $timeout; - this.onOrder('itemFk', 'ASC'); this.$state = $stateParams; this.$http = $http; this.deletable = false; this.edit = {}; this.moreOptions = [ - {callback: this.showAddTurnDialog, name: "Add turn"}, - {callback: this.showDeleteTicketDialog, name: "Delete ticket"} + {callback: this.showAddTurnDialog, name: "Add turn", always: true}, + {callback: this.showDeleteTicketDialog, name: "Delete ticket", always: true}, + {callback: this.markAsReserved, name: 'Mark as reserved'}, + {callback: this.unmarkAsReserved, name: 'Unmark as reserved'}, + {callback: this.showEditDialog, name: 'Update discount'} ]; } + getSales() { + this.$http.get(`/api/Tickets/${this.ticket.id}/getSales`).then(res => { + this.sales = res.data; + this.getTaxes(); + }); + } + $onChanges() { + if (this.ticket && this.ticket.clientFk) + this.getSales(this.ticket.clientFk); + } + onMoreOpen() { + let options = this.moreOptions.filter(o => o.always || this.isChecked); + this.$.moreButton.data = options; + } getTaxes() { this.getSubTotal(); this.getVAT(); } - getSubTotal() { - let sales = this.$.index.model.instances; + let sales = this.sales; this.subTotal = 0.00; sales.forEach(sale => { this.subTotal += (sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price)) / 100); }); } - getVAT() { this.$http.get(`/ticket/api/Tickets/${this.ticket.id}/getVAT`).then(res => { - if (res.data) { - this.VAT = res.data; - this.total = this.subTotal + this.VAT; - } + this.VAT = res.data || 0; + this.total = this.subTotal + this.VAT; }); } - get isEditable() { try { return !this.ticket.tracking.state.alertLevel; @@ -50,9 +59,8 @@ class Controller extends FilterTicketList { return true; } - get isChecked() { - let data = this.$.index.model.instances; + let data = this.sales; if (data) for (let instance of data) if (instance.checked) @@ -60,10 +68,9 @@ class Controller extends FilterTicketList { return false; } - getCheckedLines() { let lines = []; - let data = this.$.index.model.instances; + let data = this.sales; if (data) for (let i = 0; i < data.length; i++) if (data[i].checked) @@ -71,11 +78,9 @@ class Controller extends FilterTicketList { return lines; } - onMoreChange(callback) { callback.call(this); } - // Change State onStateOkClick() { let filter = {where: {code: "OK"}, fields: ["id"]}; @@ -84,7 +89,6 @@ class Controller extends FilterTicketList { this.onStateChange(res.data[0].id); }); } - onStateChange(value) { let params = {ticketFk: this.$state.params.id, stateFk: value}; this.$http.post(`/ticket/api/TicketTrackings/changeState`, params).then(() => { @@ -92,57 +96,62 @@ class Controller extends FilterTicketList { this.vnApp.showSuccess(this.translate.instant('Data saved!')); }); } - // Add Turn showAddTurnDialog() { this.$.addTurn.show(); } - addTurn(day) { let params = {ticketFk: this.$state.params.id, weekDay: day}; this.$http.patch(`/ticket/api/TicketWeeklies`, params).then(() => { this.$.addTurn.hide(); + this.vnApp.showSuccess(this.translate.instant('Data saved!')); }); } - // Delete Ticket showDeleteTicketDialog() { this.$.deleteConfirmation.show(); } - returnDeleteTicketDialog(response) { if (response === 'ACCEPT') this.deleteTicket(); } - deleteTicket() { let params = {id: this.$state.params.id}; this.$http.post(`/ticket/api/Tickets/deleted`, params).then(() => { - this.$state.go('ticket.list'); + this.$state.go('ticket.index'); + this.vnApp.showSuccess(this.translate.instant('Ticket deleted')); }); } - // Remove Lines - onRemoveLinesClick() { - let sales = this.getCheckedLines(); - let params = {sales: sales, actualTicketFk: this.ticket.id}; - let query = `/ticket/api/Sales/removes`; - this.$http.post(query, params).then(() => { - this.removeInstances(sales); - }); + onRemoveLinesClick(response) { + if (response === 'ACCEPT') { + let sales = this.getCheckedLines(); + let params = {sales: sales, actualTicketFk: this.ticket.id}; + let query = `/ticket/api/Sales/removes`; + this.$http.post(query, params).then(() => { + this.removeInstances(sales); + }); + } + } + removeInstances(instances) { + for (let i = instances.length - 1; i >= 0; i--) { + this.sales.splice(instances[i].instance, 1); + } + } + showRemoveLinesDialog() { + this.$.deleteLines.show(); } - // Move Lines showTransferPopover(event) { let filter = {clientFk: this.ticket.clientFk, ticketFk: this.ticket.id}; let json = encodeURIComponent(JSON.stringify(filter)); - this.$http.get(`/ticket/api/Tickets/threeLastActive?filter=${json}`).then(res => { + let query = `/ticket/api/Tickets/threeLastActive?filter=${json}`; + this.$http.get(query).then(res => { this.lastThreeTickets = res.data; }); this.$.transfer.parent = event.target; this.$.transfer.show(); } - moveLines(ticketID) { let sales = this.getCheckedLines(); @@ -151,7 +160,6 @@ class Controller extends FilterTicketList { this.goToTicket(ticketID); }); } - // In Progress linesToNewTicket() { let ticket = { @@ -165,17 +173,25 @@ class Controller extends FilterTicketList { let sales = this.getCheckedLines(); this.$http.post(`/api/Sales/MoveToNewTicket`, {ticket: ticket, sales: sales}).then(res => { - this.goToTicket(res.data.id); + let url = this.$state.href("ticket.card.sale", {id: res.data}, {absolute: true}); + window.open(url, '_blank'); + this.$.transfer.hide(); + this.getSales(); }); } - goToTicket(ticketID) { this.$state.go("ticket.card.sale", {id: ticketID}); } - - removeInstances(instances) { - for (let i = instances.length - 1; i >= 0; i--) { - this.$.index.model.instances.splice(instances[i].instance, 1); + // Focus First Input + focusFirstInput(e) { + let firstFocusable = e.querySelector('input, textarea'); + if (firstFocusable) { + firstFocusable.addEventListener('focus', () => { + firstFocusable.select(); + }); + setTimeout(() => { + firstFocusable.focus(); + }, 200); } } // Slesperson Mana @@ -190,11 +206,9 @@ class Controller extends FilterTicketList { this.$.descriptor.parent = event.target; this.$.descriptor.show(); } - onDescriptorLoad() { this.$.popover.relocate(); } - // Edit Line showEditPricePopover(event, sale) { this.sale = sale; @@ -206,18 +220,17 @@ class Controller extends FilterTicketList { }; this.$.editPricePopover.parent = event.target; this.$.editPricePopover.show(); + this.focusFirstInput(this.$.editPricePopover.$element[0]); } - updatePrice() { if (this.editedPrice != this.sale.price) { this.$http.post(`/ticket/api/Sales/updatePrice`, {id: this.edit.id, price: this.editedPrice, ticketFk: this.ticket.id}).then(() => { this.sale.price = this.edit.price; - this.$.index.accept(); + this.getSales(); }); } this.$.editPricePopover.hide(); } - showEditPopover(event, sale) { this.sale = sale; this.edit = [{ @@ -229,92 +242,30 @@ class Controller extends FilterTicketList { }]; this.$.editPopover.parent = event.target; this.$.editPopover.show(); + this.focusFirstInput(this.$.editPopover.$element[0]); } - - async showEditDialog() { + showEditDialog() { this.edit = this.getCheckedLines(); this.$.editDialog.show(); + this.focusFirstInput(this.$.editDialog.$element[0]); } - hideEditDialog() { - this.$.index.accept(); + this.getSales(); this.$.editDialog.hide(); } - hideEditPopover() { - this.$.index.accept(); + this.getSales(); this.$.editPopover.hide(); } - updateQuantity(id, quantity) { this.$http.post(`/ticket/api/Sales/${id}/updateQuantity`, {quantity: parseInt(quantity)}).then(() => { this.vnApp.showSuccess(this.translate.instant('Data saved!')); - this.$.index.accept(); + }).catch(e => { + this.vnApp.showError(this.translate.instant(e.data.error.message)); + this.getSales(); }); } - /* updateLine() { - if (this.edit.quantity != this.sale.quantity) { - this.$http.post(`/ticket/api/Sales/updateQuantity`, {id: this.edit.id, quantity: this.edit.quantity}).then(() => { - this.sale.quantity = this.edit.quantity; - }); - } - - if (this.edit.price != this.sale.price) { - this.$http.post(`/ticket/api/Sales/updatePrice`, {id: this.edit.id, price: this.edit.price}).then(() => { - this.sale.price = this.edit.price; - }); - } - - if (this.edit.discount != this.sale.discount) { - this.$http.post(`/ticket/api/Sales/updateDiscount`, {id: this.edit.id, discount: this.edit.discount}).then(() => { - this.sale.discount = this.edit.discount; - }); - } - this.$.edit.hide(); - }*/ - - onMoreClick() { - this.removeOptionByName('Mark as reserved'); - this.removeOptionByName('Unmark as reserved'); - this.removeOptionByName('Update discount'); - if (!this.isChecked) return; - - this.moreOptions.push({ - callback: this.markAsReserved, - name: 'Mark as reserved'} - ); - - this.moreOptions.push({ - callback: this.unmarkAsReserved, - name: 'Unmark as reserved'} - ); - - this.moreOptions.push({ - callback: this.showEditDialog, - name: 'Update discount'} - ); - } - -/** - * Remove options from 'More' menu - * @param {String} name - Option name - */ - removeOptionByName(name) { - let options = this.moreOptions; - for (let i = 0; i < this.moreOptions.length; i++) { - if (options[i].name === name) - this.moreOptions.splice(i, 1); - } - } - -/** - * Mark sale as reserved - */ - markAsReserved() { - this.setReserved(true); - } - /** * Unmark sale as reserved */ @@ -323,22 +274,18 @@ class Controller extends FilterTicketList { } /** - * Mark/Unmark sale as reserved from selected lines - * @param {Boolean} reserved reserved + * Mark sale as reserved */ + markAsReserved() { + this.setReserved(true); + } + setReserved(reserved) { - let data = { - delete: [], - create: [], - update: this.getCheckedLines() - }; + let sales = this.getCheckedLines(); + let params = {sales: sales, ticketFk: this.ticket.id, reserved: reserved}; - data.update.forEach(line => { - line.reserved = reserved; - }); - - this.$http.post(`/ticket/api/Sales/crudSale`, data).then(() => { - this.$.index.accept(); + this.$http.post(`/ticket/api/Sales/reserve`, params).then(() => { + this.getSales(); }); } } diff --git a/client/ticket/src/sale/locale/es.yml b/client/ticket/src/sale/locale/es.yml index 727be3a78..0b70f5c2e 100644 --- a/client/ticket/src/sale/locale/es.yml +++ b/client/ticket/src/sale/locale/es.yml @@ -8,4 +8,10 @@ There is no changes to save: No hay cambios que guardar Edit discount: Editar descuento Move to ticket: Mover a ticket New ticket: Nuevo ticket -Edit price: Editar precio \ No newline at end of file +Edit price: Editar precio +You are going to delete lines of the ticket: Vas a borrar lineas del ticket +Continue anyway?: ¿Estás seguro? +The new quantity should be smaller than the old one: La nueva cantidad debe de ser menor que la anterior +You have to allow pop-ups in your web browser to use this functionality: + Debes permitir los pop-pups en tu navegador para que esta herramienta funcione correctamente +Disc: Dto \ No newline at end of file diff --git a/client/ticket/src/sale/sale.spec.js b/client/ticket/src/sale/sale.spec.js index 94f84e73e..e96650f61 100644 --- a/client/ticket/src/sale/sale.spec.js +++ b/client/ticket/src/sale/sale.spec.js @@ -1,6 +1,6 @@ import './index.js'; -xdescribe('Ticket', () => { +describe('Ticket', () => { describe('Component vnTicketSale', () => { let $componentController; let controller; @@ -16,29 +16,96 @@ xdescribe('Ticket', () => { $componentController = _$componentController_; $httpBackend = _$httpBackend_; $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); + $httpBackend.when('GET', '/api/Tickets/1/getSales').respond({}); $scope = $rootScope.$new(); - $scope.index = {model: {instances: [{id: 1}, {id: 2}]}, accept: () => { - return { - then: () => {} - }; - }}; $state = _$state_; $state.params.id = 1; controller = $componentController('vnTicketSale', {$scope: $scope}, {$state: $state}); + controller.ticket = {id: 1}; + controller.$ = {index: {model: {instances: [ + { + id: 1, + quantity: 5, + price: 23.5, + discount: 0, + checked: true + }, + { + id: 4, + quantity: 20, + price: 5.5, + discount: 0, + checked: true + } + ]}, accept: () => { + return { + then: () => {} + }; + }}}; })); + describe('getSales()', () => { + it('should make a query and call getTaxes()', () => { + spyOn(controller, 'getTaxes'); + $httpBackend.expectGET(`/api/Tickets/1/getSales`).respond(); + controller.getSales(); + $httpBackend.flush(); + + expect(controller.getTaxes).toHaveBeenCalledWith(); + }); + }); + + describe('$onChanges()', () => { + it('should call getSales and getVAT', () => { + spyOn(controller, 'getSubTotal'); + spyOn(controller, 'getVAT'); + controller.getTaxes(); + + expect(controller.getSubTotal).toHaveBeenCalledWith(); + expect(controller.getVAT).toHaveBeenCalledWith(); + }); + }); + + describe('getSubTotal()', () => { + it('should calculate SubTotal', () => { + controller.sales = [{quantity: 2, price: 10, discount: 10}]; + controller.getSubTotal(); + + expect(controller.subTotal).toEqual(18); + }); + }); + + describe('getVAT()', () => { + it('should make a query, set vat and calculate total', () => { + controller.subTotal = 10; + $httpBackend.expectGET(`/ticket/api/Tickets/1/getVAT`).respond(); + controller.getVAT(); + $httpBackend.flush(); + + expect(controller.total).toEqual(10); + }); + }); + describe('isChecked() setter/getter', () => { it('should set isChecked value to true when one of the instances has the value checked to true', () => { let lines = [ {checked: false}, {checked: true} ]; - $scope.index.model.instances = lines; + controller.sales = lines; expect(controller.isChecked).toBeTruthy(); }); }); + describe('getCheckedLines()', () => { + it('should make an array of the instances with the property checked true()', () => { + controller.sales = [{id: 1, checked: true}, {id: 2, checked: false}, {id: 3, checked: true}]; + + expect(controller.getCheckedLines()).toEqual([{id: 1, instance: 0}, {id: 3, instance: 2}]); + }); + }); + describe('onStateOkClick()', () => { it('should perform a get and then call a function', () => { let filter = {where: {code: "OK"}, fields: ["id"]}; @@ -55,6 +122,26 @@ xdescribe('Ticket', () => { }); }); + describe('showAddTurnDialog()', () => { + it('should call contrtoller.$.addTurn.show()', () => { + controller.$.addTurn = {show: () => {}}; + spyOn(controller.$.addTurn, 'show'); + controller.showAddTurnDialog(); + + expect(controller.$.addTurn.show).toHaveBeenCalledWith(); + }); + }); + + xdescribe('addTurn(day)', () => { + it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => { + controller.$.addTurn = {hide: () => {}}; + spyOn(controller.$.addTurn, 'hide'); + controller.showAddTurnDialog(); + + expect(controller.$.addTurn.show).toHaveBeenCalledWith(); + }); + }); + describe('onStateChange()', () => { it('should perform a post and then call a function', () => { $httpBackend.expectPOST(`/ticket/api/TicketTrackings/changeState`).respond(); @@ -64,19 +151,48 @@ xdescribe('Ticket', () => { }); }); - describe('onRemoveLinesClick()', () => { - it('should remove an object of the model if has the attribute cheched true', () => { - $scope.index.model.instances = [{id: 1, checked: true}, {id: 2, checked: false}]; - controller.onRemoveLinesClick(); + xdescribe('onRemoveLinesClick()', () => { + it('should call getCheckedLines, call removeInstances, and make a query', () => { + spyOn(controller, 'getCheckedLines'); + spyOn(controller, 'removeInstances'); + $httpBackend.expectPOST(`/ticket/api/Sales/removes`).respond(); - expect($scope.index.model.instances).toEqual([{id: 2, checked: false}]); - }); - - it('should make a post if an object the model has the attribute cheched true', () => { - $scope.index.model.instances = [{id: 1, checked: false}, {id: 2, checked: false}]; - $httpBackend.expectPOST(`/ticket/api/Sales/crudSale`).respond(); - controller.onRemoveLinesClick(); + controller.onRemoveLinesClick('ACCEPT'); $httpBackend.flush(); + + expect(controller.getCheckedLines).toHaveBeenCalledWith(); + expect(controller.removeInstances).toHaveBeenCalledWith(); + }); + }); + + describe('unmarkAsReserved()', () => { + it('should call setReserved with false', () => { + spyOn(controller, 'setReserved'); + + controller.unmarkAsReserved(false); + + expect(controller.setReserved).toHaveBeenCalledWith(false); + }); + }); + + describe('markAsReserved()', () => { + it('should call setReserved with true', () => { + spyOn(controller, 'setReserved'); + + controller.markAsReserved(true); + + expect(controller.setReserved).toHaveBeenCalledWith(true); + }); + }); + + xdescribe('setReserved()', () => { + it('should call getCheckedLines, $.index.accept and make a query ', () => { + spyOn(controller, 'getCheckedLines'); + $httpBackend.expectPOST(`/ticket/api/Sales/reserve`).respond(); + controller.setReserved(true); + $httpBackend.flush(); + + expect(controller.getCheckedLines).toHaveBeenCalledWith(); }); }); }); diff --git a/client/ticket/src/sale/style.scss b/client/ticket/src/sale/style.scss index 24cce9966..cb1c4c45a 100644 --- a/client/ticket/src/sale/style.scss +++ b/client/ticket/src/sale/style.scss @@ -1,87 +1,95 @@ @import "colors"; - -vn-popover.edit { - & div.popover{ - width: 200px; - } - - & vn-horizontal.header{ - background-color: $main-01; - & h5{ - color: white; - margin: 0 auto; +vn-ticket-sale { + vn-popover.edit { + div.popover{ + width: 200px; + } + + vn-horizontal.header{ + background-color: $main-01; + h5{ + color: white; + margin: 0 auto; + } + } + + p.simulatorTitle{ + margin-bottom: 0px; + font-size: 12px; + color: $main-01; + } + + vn-label-value{ + padding-bottom: 20px; + } + + div.simulator{ + text-align: center; } } - - & p.simulatorTitle{ - margin-bottom: 0px; - font-size: 12px; - color: $main-01; + + vn-dialog.edit { + @extend vn-popover.edit; + + .buttons{ + margin-top: 0!important; + } + + p{ + display: none; + } + + vn-ticket-sale-edit-discount > div { + padding-bottom: 0!important; + } } - - & vn-label-value{ - padding-bottom: 20px; + + vn-ticket-sale{ + tr .mdl-textfield{ + width: inherit; + max-width: 100%; + } } - - div.simulator{ - text-align: center; + + vn-popover.transfer{ + table { + min-width: 650px; + margin-bottom: 10px; + } + vn-icon:nth-child(1) { + padding-top: 0.2em; + font-size: 1.7em; + } } -} - -vn-dialog.edit { - @extend vn-popover.edit; - - .buttons{ - margin-top: 0!important; + + vn-dialog.ticket-create{ + vn-button[label=Cancel]{ + display: none; + } + vn-card.vn-ticket-create{ + padding: 0!important; + } } - - p{ - display: none; + + table { + vn-textfield { + max-width: 100px; + float: right; + margin: 0!important; + input { + text-align: right; + } + } + img { + border-radius: 50%; + } } - - vn-ticket-sale-edit-discount > div { - padding-bottom: 0!important; - } -} - -vn-ticket-sale{ - & tr .mdl-textfield{ - width: inherit; - max-width: 100%; - } -} - -vn-popover.transfer{ - & table { - min-width: 650px; - margin-bottom: 10px; - } - & i { - padding-top: 0.2em; - font-size: 1.8em; - } -} - -vn-dialog.ticket-create{ - & vn-button[label=Cancel]{ - display: none; - } - & vn-card.vn-ticket-create{ - padding: 0!important; - } -} - -table { - & vn-textfield { - max-width: 100px; - float: right; - } -} - -vn-textfield { - & span.filter { - padding-top: 3px; - padding-right: 3px; - color: $main-font-color + + vn-textfield { + span.filter { + padding-top: 3px; + padding-right: 3px; + color: $main-font-color + } } } \ No newline at end of file diff --git a/client/ticket/src/summary/index.html b/client/ticket/src/summary/index.html index 3e33e01d8..77d66820d 100644 --- a/client/ticket/src/summary/index.html +++ b/client/ticket/src/summary/index.html @@ -83,6 +83,9 @@ {{::sale.discount}} % {{::sale.quantity * sale.price | currency:'€':2}} + + No results + diff --git a/client/ticket/src/ticket.js b/client/ticket/src/ticket.js index d07caa7cd..4212b486a 100644 --- a/client/ticket/src/ticket.js +++ b/client/ticket/src/ticket.js @@ -3,6 +3,7 @@ export * from './module'; import './search-panel'; import './index'; import './create'; +import './create/card'; import './card'; import './descriptor'; import './summary'; @@ -21,3 +22,4 @@ import './tracking/edit'; import './fetched-tags'; import './sale-checked'; import './component'; +import './sale-tracking'; diff --git a/client/ticket/src/tracking/index/index.html b/client/ticket/src/tracking/index/index.html index 0f7f4af2e..97c43099d 100644 --- a/client/ticket/src/tracking/index/index.html +++ b/client/ticket/src/tracking/index/index.html @@ -23,8 +23,7 @@ - - -
+ + \ No newline at end of file diff --git a/client/ticket/src/volume/index.html b/client/ticket/src/volume/index.html index 9bab229d6..a990bded2 100644 --- a/client/ticket/src/volume/index.html +++ b/client/ticket/src/volume/index.html @@ -3,7 +3,7 @@ - Volumes + Volume @@ -37,7 +37,6 @@ - - + diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index adc615809..1d9f6ffeb 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -76,7 +76,7 @@ export default { payMethodOptionOne: `vn-autocomplete[field="$ctrl.client.payMethodFk"] vn-drop-down ul > li:nth-child(2)`, IBANInput: `${components.vnTextfield}[name="iban"]`, dueDayInput: `${components.vnTextfield}[name="dueDay"]`, - receivedCoreVNHCheckbox: `vn-check[label='Received core VNH'] > label > input`, + receivedCoreLCRCheckbox: `vn-check[label='Received LCR'] > label > input`, receivedCoreVNLCheckbox: `vn-check[label='Received core VNL'] > label > input`, receivedB2BVNLCheckbox: `vn-check[label='Received B2B VNL'] > label > input`, saveButton: `${components.vnSubmit}` @@ -132,7 +132,7 @@ export default { addCreditFloatButton: `${components.vnFloatButton}`, creditInput: `${components.vnTextfield}[name="credit"]`, saveButton: `${components.vnSubmit}`, - firstCreditText: 'vn-client-credit-index .list-element' + firstCreditText: 'vn-client-credit-index vn-card > div vn-table vn-tbody > vn-tr' }, clientGreuge: { greugeButton: `vn-menu-item a[ui-sref="client.card.greuge.index"]`, @@ -142,15 +142,15 @@ export default { typeInput: `vn-autocomplete[field="$ctrl.greuge.greugeTypeFk"] input`, typeSecondOption: `vn-autocomplete[field="$ctrl.greuge.greugeTypeFk"] vn-drop-down ul > li`, saveButton: `${components.vnSubmit}`, - firstGreugeText: 'vn-client-greuge-index .list-element' + firstGreugeText: 'vn-client-greuge-index vn-card > div vn-table vn-tbody > vn-tr' }, clientMandate: { mandateButton: `vn-menu-item a[ui-sref="client.card.mandate"]`, - firstMandateText: 'vn-client-mandate .list-element' + firstMandateText: 'vn-client-mandate vn-card > div vn-table vn-tbody > vn-tr' }, clientInvoices: { invoicesButton: `vn-menu-item a[ui-sref="client.card.invoice"]`, - firstInvoiceText: 'vn-client-invoice .list-element' + firstInvoiceText: 'vn-client-invoice vn-card > div vn-table vn-tbody > vn-tr' }, itemsIndex: { createItemButton: `${components.vnFloatButton}`, @@ -275,10 +275,10 @@ export default { barcode: `vn-item-summary vn-vertical[name="barcode"]` }, ticketsIndex: { - createTicketButton: `${components.vnFloatButton}`, - searchResult: `table > tbody > tr`, - searchTicketInput: `${components.vnTextfield}`, - searchButton: `vn-searchbar vn-icon-button[icon="search"]` + createTicketButton: `vn-ticket-index ${components.vnFloatButton}`, + searchResult: `vn-ticket-index vn-card > div > table > tbody > tr`, + searchTicketInput: `vn-ticket-index ${components.vnTextfield}`, + searchButton: `vn-ticket-index vn-searchbar vn-icon-button[icon="search"]` }, ticketNotes: { notesButton: `vn-menu-item a[ui-sref="ticket.card.observation"]`, diff --git a/e2e/paths/client-module/04_edit_pay_method.spec.js b/e2e/paths/client-module/04_edit_pay_method.spec.js index e0e0cb057..d0ca3f2ed 100644 --- a/e2e/paths/client-module/04_edit_pay_method.spec.js +++ b/e2e/paths/client-module/04_edit_pay_method.spec.js @@ -52,13 +52,13 @@ describe('Client', () => { .waitToClick(selectors.clientPayMethod.payMethodIBANOption) .clearInput(selectors.clientPayMethod.dueDayInput) .type(selectors.clientPayMethod.dueDayInput, '60') - .waitToClick(selectors.clientPayMethod.receivedCoreVNHCheckbox) + .waitToClick(selectors.clientPayMethod.receivedCoreLCRCheckbox) .waitToClick(selectors.clientPayMethod.receivedCoreVNLCheckbox) .waitToClick(selectors.clientPayMethod.receivedB2BVNLCheckbox) .waitToClick(selectors.clientPayMethod.saveButton) .waitForSnackbar() .then(result => { - expect(result).toEqual(jasmine.arrayContaining(['requires an IBAN'])); + expect(result).toEqual(jasmine.arrayContaining(['That payment method requires an IBAN'])); }); }); @@ -89,13 +89,13 @@ describe('Client', () => { }); }); - it('should confirm Received core VNH checkbox is unchecked', () => { + it('should confirm Received LCR checkbox is checked', () => { return nightmare .evaluate(selector => { return document.querySelector(selector).checked; - }, selectors.clientPayMethod.receivedCoreVNHCheckbox) + }, selectors.clientPayMethod.receivedCoreLCRCheckbox) .then(value => { - expect(value).toBeFalsy(); + expect(value).toBeTruthy(); }); }); diff --git a/e2e/paths/client-module/06_add_address_notes.spec.js b/e2e/paths/client-module/06_add_address_notes.spec.js index e8f0df0d4..ac8bca29f 100644 --- a/e2e/paths/client-module/06_add_address_notes.spec.js +++ b/e2e/paths/client-module/06_add_address_notes.spec.js @@ -65,7 +65,7 @@ describe('Client', () => { .waitToClick(selectors.clientAddresses.saveButton) .waitForSnackbar() .then(result => { - expect(result).toEqual(jasmine.arrayContaining(['type cannot be blank'])); + expect(result).toEqual(jasmine.arrayContaining(['Observation type cannot be blank'])); }); }); diff --git a/e2e/paths/ticket-module/03_list_sale.spec.js b/e2e/paths/ticket-module/03_list_sale.spec.js index f62ac21e6..2f6ec4ab6 100644 --- a/e2e/paths/ticket-module/03_list_sale.spec.js +++ b/e2e/paths/ticket-module/03_list_sale.spec.js @@ -64,11 +64,10 @@ describe('Ticket', () => { .wait(selectors.ticketSales.secondSaleText) .getInnerText(selectors.ticketSales.secondSaleText) .then(value => { - expect(value).toContain('Yellow'); - expect(value).toContain('2'); - expect(value).toContain('€23.50'); + expect(value).toContain('Red'); + expect(value).toContain('€4.50'); expect(value).toContain('0 %'); - expect(value).toContain('€47.00'); + expect(value).toContain('€45.00'); }); }); }); diff --git a/services/client/common/methods/client-contact/crud.js b/services/client/common/methods/client-contact/crud.js deleted file mode 100644 index d3a1075d5..000000000 --- a/services/client/common/methods/client-contact/crud.js +++ /dev/null @@ -1,32 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('crud', { - description: 'Client contact crud', - accepts: [{ - arg: 'data', - type: 'object', - http: {source: 'body'} - }], - returns: { - root: true, - type: 'boolean' - }, - http: { - verb: 'post', - path: '/crud' - } - }); - - Self.crud = async data => { - let models = Self.app.models; - - await Promise.all(data.delete.map(contactId => { - return models.ClientContact.destroyById(contactId); - })); - - let upsert = data.update.concat(data.create); - - await Promise.all(upsert.map(contact => { - return models.ClientContact.upsert(contact); - })); - }; -}; diff --git a/services/client/common/methods/client-contact/specs/crud.spec.js b/services/client/common/methods/client-contact/specs/crud.spec.js deleted file mode 100644 index f58752b3a..000000000 --- a/services/client/common/methods/client-contact/specs/crud.spec.js +++ /dev/null @@ -1,52 +0,0 @@ -const app = require(`${servicesDir}/client/server/server`); - -describe('Client crud', () => { - afterAll(async() => { - await app.models.ClientContact.destroyById(4113); - }); - - it('should perfom a query to create new contacts', async() => { - let data = { - delete: [], - create: [ - {id: 4113, clientFk: 101, name: 'My contact', phone: '111111111'} - ], - update: [] - }; - - await app.models.ClientContact.crud(data); - let contacts = await app.models.ClientContact.find(); - - expect(contacts.length).toEqual(5); - }); - - it('should perfom a query to update contacts', async() => { - let data = { - delete: [], - create: [], - update: [ - {id: 4113, name: 'My contact 2 updated', phone: '222222222'} - ] - }; - - await app.models.ClientContact.crud(data); - let contacts = await app.models.ClientContact.findById(4113); - - expect(contacts.name).toEqual('My contact 2 updated'); - expect(contacts.phone).toEqual('222222222'); - }); - - it('should perfom a query to delete contacts', async() => { - let data = { - delete: [4113], - create: [], - update: [] - }; - - await app.models.ClientContact.crud(data); - - let contacts = await app.models.ClientContact.find(); - - expect(contacts.length).toEqual(4); - }); -}); diff --git a/services/client/common/models/client-contact.js b/services/client/common/models/client-contact.js index c731ffc15..db9d72ef6 100644 --- a/services/client/common/models/client-contact.js +++ b/services/client/common/models/client-contact.js @@ -1,6 +1,4 @@ module.exports = Self => { - require('../methods/client-contact/crud')(Self); - Self.validatesPresenceOf('name', { message: 'Name cannot be blank' }); diff --git a/services/client/common/models/credit-classification.json b/services/client/common/models/credit-classification.json index 51bda330a..2e636af63 100644 --- a/services/client/common/models/credit-classification.json +++ b/services/client/common/models/credit-classification.json @@ -33,7 +33,7 @@ "model": "Client", "foreignKey": "client" }, - "creditInsurances": { + "insurances": { "type": "hasMany", "model": "CreditInsurance", "foreignKey": "creditClassification" diff --git a/services/client/common/models/recovery.js b/services/client/common/models/recovery.js index 1386b3754..c456cb9a4 100644 --- a/services/client/common/models/recovery.js +++ b/services/client/common/models/recovery.js @@ -1,4 +1,6 @@ module.exports = function(Self) { require('../methods/recovery/filter')(Self); require('../methods/recovery/hasActiveRecovery')(Self); + + Self.validatesPresenceOf('period', {message: 'Period cannot be blank'}); }; diff --git a/services/db/install/changes/1.0.8/01-ACL.sql b/services/db/install/changes/1.0.8/01-ACL.sql new file mode 100644 index 000000000..d8abe02f2 --- /dev/null +++ b/services/db/install/changes/1.0.8/01-ACL.sql @@ -0,0 +1,2 @@ +UPDATE `salix`.`ACL` SET `accessType`='*' WHERE `id`='58'; +UPDATE `salix`.`ACL` SET `accessType`='*' WHERE `id`='60'; \ No newline at end of file diff --git a/services/db/install/changes/1.0.8/02-alertLevel.sql b/services/db/install/changes/1.0.8/02-alertLevel.sql new file mode 100644 index 000000000..c338d681b --- /dev/null +++ b/services/db/install/changes/1.0.8/02-alertLevel.sql @@ -0,0 +1,18 @@ +USE `vn`; + +CREATE TABLE `vn`.`alertLevel` ( + `code` VARCHAR(45) CHARACTER SET 'utf8' NOT NULL, + `alertLevel` INT(11) NOT NULL, + PRIMARY KEY (`code`)); + +ALTER TABLE `vn`.`alertLevel` +ADD CONSTRAINT `fk_code_1` + FOREIGN KEY (`code`) + REFERENCES `vn2008`.`state` (`code`) + ON DELETE CASCADE + ON UPDATE CASCADE; + +INSERT INTO `vn`.`alertLevel` (`code`, `alertLevel`) VALUES ('FREE', '0'); +INSERT INTO `vn`.`alertLevel` (`code`, `alertLevel`) VALUES ('ON_PREPARATION', '1'); +INSERT INTO `vn`.`alertLevel` (`code`, `alertLevel`) VALUES ('PACKED', '2'); +INSERT INTO `vn`.`alertLevel` (`code`, `alertLevel`) VALUES ('DELIVERED', '3'); diff --git a/services/db/install/changes/1.0.8/03-itemDiary.sql b/services/db/install/changes/1.0.8/03-itemDiary.sql new file mode 100644 index 000000000..ca853c5af --- /dev/null +++ b/services/db/install/changes/1.0.8/03-itemDiary.sql @@ -0,0 +1,105 @@ +USE `vn`; +DROP procedure IF EXISTS `itemDiary`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `itemDiary`(IN vItemId INT, IN vWarehouse INT) +BEGIN + DECLARE vDateInventory DATETIME; + DECLARE vCurdate DATE DEFAULT CURDATE(); + -- traduccion: date, alertLevel, origin, reference, name, In, Out, Balance + SELECT Fechainventario INTO vDateInventory FROM vn2008.tblContadores; + SET @a = 0; + SELECT DATE(date) AS date, + alertLevel, + stateName, + origin, + reference, + name, + `in`, + `out`, + @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance + FROM + ( SELECT tr.landed as date, + b.quantity as `in`, + NULL as `out`, + IF(tr.isReceived != FALSE,3, IF(tr.isDelivered,1,0)) as alertLevel, + st.name AS stateName, + s.name as name, + e.ref as reference, + e.id as origin + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.supplier s ON s.id = e.supplierFk + JOIN vn.alertLevel al ON al.alertLevel = + CASE + WHEN tr.isReceived != FALSE THEN 3 + WHEN tr.isDelivered THEN 1 + ELSE 0 + END + JOIN vn.state st ON st.code = al.code + WHERE tr.landed >= vDateInventory + AND vWarehouse = tr.warehouseInFk + AND b.itemFk = vItemId + AND e.isInventory = 0 + + UNION ALL + + SELECT tr.shipped as date, + NULL as `in`, + b.quantity as `out`, + IF(tr.isReceived != FALSE,3, IF(tr.isDelivered,1,0)) as alertLevel, + st.name AS stateName, + s.name as name, + e.ref as reference, + e.id as origin + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.warehouse w ON w.id = tr.warehouseOutFk + JOIN vn.supplier s ON s.id = e.supplierFk + JOIN vn.alertLevel al ON al.alertLevel = + CASE + WHEN tr.isReceived != FALSE THEN 3 + WHEN tr.isDelivered THEN 1 + ELSE 0 + END + JOIN vn.state st ON st.code = al.code + WHERE tr.shipped >= vDateInventory + AND vWarehouse =tr.warehouseOutFk + AND s.id <> 4 + AND b.itemFk = vItemId + AND e.isInventory = 0 + AND w.isFeedStock = 0 + + UNION ALL + + SELECT t.shipped as date, + NULL as `in`, + s.quantity as `out`, + IF(t.shipped < vCurdate,3,IF(t.shipped > vCurdate, 0, IFNULL(ts.alertLevel,0))) as alertLevel, + st.name AS stateName, + t.nickname as name, + t.refFk as reference, + t.id as origin + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + LEFT JOIN vn.ticketState ts ON ts.ticket = t.id + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.alertLevel al ON al.alertLevel = + CASE + WHEN t.shipped < vCurdate THEN 3 + WHEN t.shipped > vCurdate THEN 0 + ELSE IFNULL(ts.alertLevel, 0) + END + JOIN vn.state st ON st.code = al.code + WHERE t.shipped >= vDateInventory + AND s.itemFk = vItemId + AND vWarehouse =t.warehouseFk + ) AS itemDiary + ORDER BY date, alertLevel, `in` DESC; +END$$ + +DELIMITER ; + diff --git a/services/db/install/changes/1.0.8/04-ticketComponentCalculate.sql b/services/db/install/changes/1.0.8/04-ticketComponentCalculate.sql new file mode 100644 index 000000000..f7fe61d75 --- /dev/null +++ b/services/db/install/changes/1.0.8/04-ticketComponentCalculate.sql @@ -0,0 +1,294 @@ +USE `vn`; +DROP procedure IF EXISTS `ticketComponentCalculate`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentCalculate`( + vAddressFk INT, + vAgencyModeFk INT) +proc: BEGIN +/** + * Calcula los componentes de un ticket + * + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id del modo de agencia + * @return tmp.ticketComponent, tmp.ticketComponentPrice + */ + DECLARE vClientFk INT; + DECLARE vGeneralInflationCoefficient INT DEFAULT 1.3; + DECLARE vMinimumDensityWeight INT DEFAULT 167; + DECLARE vBoxFreightItem INT DEFAULT 71; + DECLARE vBoxVolume BIGINT DEFAULT 138000; + DECLARE vSpecialPriceComponent INT DEFAULT 10; + DECLARE vExtraFreightComponent INT DEFAULT 14; + DECLARE vDeliveryComponent INT DEFAULT 15; + DECLARE vRecoveryComponent INT DEFAULT 17; + DECLARE vSellByPacketComponent INT DEFAULT 22; + DECLARE vBuyValueComponent INT DEFAULT 28; + DECLARE vMarginComponent INT DEFAULT 29; + DECLARE vDiscountLastItemComponent INT DEFAULT 32; + DECLARE vExtraBaggedComponent INT DEFAULT 38; + DECLARE vManaAutoComponent INT DEFAULT 39; + DECLARE vFreightBonusComponent INT DEFAULT 41; + + SELECT clientFk INTO vClientFK + FROM address + WHERE id = vAddressFk; + + SET @rate2 := 0; + SET @rate3 := 0; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate; + CREATE TEMPORARY TABLE tmp.ticketComponentCalculate + (PRIMARY KEY (itemFk, warehouseFk)) + ENGINE = MEMORY + SELECT + tl.itemFk, tl.warehouseFk, tl.available, + IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) * 1.0 rate2, + IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3, + IFNULL(pf.rate3, 0) AS minPrice, + IFNULL(pf.packing, b.packing) packing, + IFNULL(pf.grouping, b.grouping) grouping, + ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, + tl.buyFk, i.typeFk + FROM tmp.ticketLot tl + JOIN buy b ON b.id = tl.buyFk + JOIN item i ON i.id = tl.itemFk + JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk + LEFT JOIN ( + SELECT * FROM ( + SELECT pf.itemFk, pf.grouping, pf.packing, pf.box, pf.rate2, pf.rate3, aho.warehouseFk + FROM priceFixed pf + JOIN tmp.agencyHourGetShipped aho ON pf.warehouseFk = aho.warehouseFk OR pf.warehouseFk = 0 + WHERE aho.shipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC + ) tpf + GROUP BY tpf.itemFk, tpf.warehouseFk + ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk + WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.display <> 0; + + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; + CREATE TEMPORARY TABLE tmp.ticketComponent ( + `warehouseFk` INT UNSIGNED NOT NULL, + `itemFk` INT NOT NULL, + `componentFk` INT UNSIGNED NOT NULL, + `cost` DECIMAL(10,4) NOT NULL, + INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), + UNIQUE INDEX `itemWarehouseComponent` (`itemFk` ASC, `warehouseFk` ASC, `componentFk` ASC)); + + + + INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) + SELECT + tcc.warehouseFk, + tcc.itemFk, + vBuyValueComponent, + b.buyingValue + b.freightValue + b.packageValue + b.comissionValue + FROM tmp.ticketComponentCalculate tcc + JOIN buy b ON b.id = tcc.buyFk; + + INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) + SELECT + tcc.warehouseFk, + tcc.itemFk, + vMarginComponent, + tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue + FROM tmp.ticketComponentCalculate tcc + JOIN buy b ON b.id = tcc.buyFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; + CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY + SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk + FROM tmp.ticketComponent tc + GROUP BY tc.itemFk, warehouseFk; + + INSERT INTO tmp.ticketComponent + SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, ROUND(tcb.base * LEAST(cr.recobro, 0.25), 3) + FROM tmp.ticketComponentBase tcb + JOIN bi.claims_ratio cr ON cr.Id_Cliente = vClientFk + WHERE cr.recobro > 0.009; + + INSERT INTO tmp.ticketComponent + SELECT tcb.warehouseFk, tcb.itemFk, vManaAutoComponent, ROUND(base * (0.01 + prices_modifier_rate), 3) as manaAuto + FROM tmp.ticketComponentBase tcb + JOIN `client` c on c.id = vClientFk + JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador + WHERE ms.prices_modifier_activated + HAVING manaAuto <> 0; + + INSERT INTO tmp.ticketComponent + SELECT + tcb.warehouseFk, + tcb.itemFk, + cr.id, + GREATEST(IFNULL(ROUND(tcb.base * cr.tax, 4), 0), tcc.minPrice - tcc.rate3) + FROM tmp.ticketComponentBase tcb + JOIN componentRate cr + JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk + LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk + WHERE cr.id = vDiscountLastItemComponent AND cr.tax <> 0 AND tcc.minPrice < tcc.rate3 AND sp.value IS NULL; + + INSERT INTO tmp.ticketComponent + SELECT tcc.warehouseFk, tcc.itemFk, vSellByPacketComponent, tcc.rate2 - tcc.rate3 + FROM tmp.ticketComponentCalculate tcc + JOIN buy b ON b.id = tcc.buyFk + LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk + WHERE sp.value IS NULL; + + INSERT INTO tmp.ticketComponent + SELECT + tcc.warehouseFK, + tcc.itemFk, + vDeliveryComponent, + vGeneralInflationCoefficient + * ROUND( + r.cm3 + * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) + * IFNULL(amz.price + * amz.inflation, 50) / vBoxVolume, 4 + ) cost + FROM tmp.ticketComponentCalculate tcc + JOIN item i ON i.id = tcc.itemFk + JOIN agencyMode am ON am.id = vAgencyModeFk + JOIN `address` a ON a.id = vAddressFk + JOIN agencyProvince ap ON ap.agencyFk = am.agencyFk + AND ap.warehouseFk = tcc.warehouseFk AND ap.provinceFk = a.provinceFk + JOIN agencyModeZone amz ON amz.agencyModeFk = vAgencyModeFk + AND amz.zone = ap.zone AND amz.itemFk = 71 AND amz.warehouseFk = tcc.warehouseFk + LEFT JOIN bi.rotacion r ON r.warehouse_id = tcc.warehouseFk + AND r.Id_Article = tcc.itemFk + HAVING cost <> 0; + + INSERT INTO tmp.ticketComponent + SELECT + tcc.warehouseFk, + tcc.itemFk, + vFreightBonusComponent, + vGeneralInflationCoefficient + * ROUND( + r.cm3 + * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) + * awb.bonus + * amz.inflation / vBoxVolume, 4 + ) cost + FROM tmp.ticketComponentCalculate tcc + JOIN item i ON i.id = tcc.itemFk + JOIN agencyMode am ON am.id = vAgencyModeFk + JOIN `address` a ON a.id = vAddressFk + JOIN agencyProvince ap ON ap.agencyFk = a.id + AND ap.warehouseFk = tcc.warehouseFk AND ap.provinceFk = a.provinceFk + JOIN agencyModeZone amz ON amz.agencyModeFk = vAgencyModeFk + AND amz.zone = ap.zone AND amz.itemFk = vBoxFreightItem AND amz.warehouseFk = tcc.warehouseFk + JOIN agencyWeekDayBonus awb ON awb.warehouseFk = amz.warehouseFk AND awb.zone = amz.zone AND am.id = awb.agencyFk + LEFT JOIN bi.rotacion r ON r.warehouse_id = tcc.warehouseFk + AND r.Id_Article = tcc.itemFk + JOIN tmp.agencyHourGetShipped aho ON aho.warehouseFk = awb.warehouseFk + AND WEEKDAY(aho.landed) = awb.weekDay + HAVING cost <> 0 + LIMIT 1; + + IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN + INSERT INTO tmp.ticketComponent + SELECT tcc.warehouseFk, b.itemFk, vExtraBaggedComponent, ap.packagingValue cost + FROM tmp.ticketComponentCalculate tcc + JOIN vn.addressForPackaging ap + WHERE ap.addressFk = vAddressFk; + END IF; + + INSERT INTO tmp.ticketComponent + SELECT tcb.warehouseFk, tcb.itemFk, vExtraFreightComponent, tcb.base * (IFNULL(pe.percentage,pp.percentage)/100) + FROM tmp.ticketComponentBase tcb + JOIN tmp.agencyHourGetShipped aho ON aho.warehouseFk = tcb.warehouseFk + LEFT JOIN preparationPercentage pp ON pp.weekDay = WEEKDAY(aho.shipped) + AND tcb.warehouseFk = IFNULL(pp.warehouseFk, tcb.warehouseFk) + LEFT JOIN preparationException pe ON pe.exceptionDay = aho.shipped + AND tcb.warehouseFk = IFNULL(pe.warehouseFk, tcb.warehouseFk) + WHERE IFNULL(pe.percentage, pp.percentage); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; + CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY + SELECT * FROM tmp.ticketComponent; + + INSERT INTO tmp.ticketComponent + SELECT + tcc.warehouseFk, + tcc.itemFk, + vSpecialPriceComponent, + sp.value - SUM(tcc.cost) sumCost + FROM tmp.ticketComponentCopy tcc + JOIN componentRate cr ON cr.id = tcc.componentFk + JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk + WHERE cr.classRate IS NULL + GROUP BY tcc.itemFk, tcc.warehouseFk + HAVING ABS(sumCost) > 0.001; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum; + CREATE TEMPORARY TABLE tmp.ticketComponentSum + (INDEX (itemFk, warehouseFk)) + ENGINE = MEMORY + SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, cr.classRate + FROM tmp.ticketComponent tc + JOIN componentRate cr ON cr.id = tc.componentFk + GROUP BY tc.itemFk, tc.warehouseFk, cr.classRate; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; + CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY + SELECT + tcc.warehouseFk, + tcc.itemFk, + 1 rate, + IF(tcc.groupingMode = 1, tcc.grouping, 1) grouping, + SUM(tcs.sumCost) price + FROM tmp.ticketComponentCalculate tcc + JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk + AND tcs.warehouseFk = tcc.warehouseFk + WHERE IFNULL(tcs.classRate, 1) = 1 + AND tcc.groupingMode < 2 AND (tcc.packing > tcc.grouping or tcc.groupingMode = 0) + GROUP BY tcs.warehouseFk, tcs.itemFk; + + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, grouping, price) + SELECT + tcc.warehouseFk, + tcc.itemFk, + 2 rate, + tcc.packing grouping, + SUM(tcs.sumCost) price + FROM tmp.ticketComponentCalculate tcc + JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk + AND tcs.warehouseFk = tcc.warehouseFk + WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2 + AND tcc.packing > 0 AND tcc.available >= tcc.packing) + GROUP BY tcs.warehouseFk, tcs.itemFk; + + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, grouping, price) + SELECT + tcc.warehouseFk, + tcc.itemFk, + 3 rate, + tcc.available grouping, + SUM(tcs.sumCost) price + FROM tmp.ticketComponentCalculate tcc + JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk + AND tcs.warehouseFk = tcc.warehouseFk + WHERE IFNULL(tcs.classRate, 3) = 3 + GROUP BY tcs.warehouseFk, tcs.itemFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPrice; + CREATE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY + SELECT * FROM ( + SELECT * FROM tmp.ticketComponentRate ORDER BY price + ) t + GROUP BY itemFk, warehouseFk, grouping; + + DROP TEMPORARY TABLE + tmp.ticketComponentCalculate, + tmp.ticketComponentSum, + tmp.ticketComponentBase, + tmp.ticketComponentRate, + tmp.ticketComponentCopy; +END$$ + +DELIMITER ; + diff --git a/services/db/install/changes/1.0.8/05-ticketComponentPriceDifference.sql b/services/db/install/changes/1.0.8/05-ticketComponentPriceDifference.sql new file mode 100644 index 000000000..571990103 --- /dev/null +++ b/services/db/install/changes/1.0.8/05-ticketComponentPriceDifference.sql @@ -0,0 +1,55 @@ +USE `vn`; +DROP procedure IF EXISTS `ticketComponentPriceDifference`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentPriceDifference`( + vTicketFk INT, + vDate DATE, + vAddressFk INT, + vAgencyModeFk INT, + vWarehouseFk INT) +BEGIN +/** + * Devuelve las diferencias de precio + * de los movimientos de un ticket. + * + * @param vTicketFk Id del ticket + * @param vDate Fecha de envío + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id del modo de agencia + * @param vWarehouseFk Id del almacén + */ + CALL vn.ticketComponentPreview(vTicketFk, vDate, vAddressFk, vAgencyModeFk, vWarehouseFk); + + SELECT + s.itemFk, + i.name, + i.size, + i.category, + IFNULL(s.quantity, 0) AS quantity, + IFNULL(s.price, 0) AS price, + ROUND(SUM(tc.cost), 2) AS newPrice, + s.quantity * (s.price - ROUND(SUM(cost), 2)) difference, + s.id AS saleFk + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk + AND tc.warehouseFk = t.warehouseFk + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + AND sc.componentFk = tc.componentFk + LEFT JOIN componentRate cr ON cr.id = tc.componentFk + WHERE + t.id = vTicketFk + AND IF(sc.componentFk IS NULL + AND cr.classRate IS NOT NULL, FALSE, TRUE) + GROUP BY s.id ORDER BY s.id; + + DROP TEMPORARY TABLE + tmp.ticketComponent, + tmp.ticketComponentPrice; +END$$ + +DELIMITER ; + diff --git a/services/db/install/changes/1.0.8/06-ticketComponentUpdateSale.sql b/services/db/install/changes/1.0.8/06-ticketComponentUpdateSale.sql new file mode 100644 index 000000000..ef02c2746 --- /dev/null +++ b/services/db/install/changes/1.0.8/06-ticketComponentUpdateSale.sql @@ -0,0 +1,154 @@ +USE `vn`; +DROP procedure IF EXISTS `ticketComponentUpdateSale`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentUpdateSale`(vOption INT) +BEGIN +/** + * A partir de la tabla tmp.sale, crea los Movimientos_componentes + * y modifica el campo Preu de la tabla Movimientos + * + * @param i_option integer tipo de actualizacion + * @param table tmp.sale tabla memory con el campo Id_Movimiento, warehouse_id + **/ + DECLARE vComponentFk INT; + DECLARE vRenewComponents BOOLEAN; + DECLARE vKeepPrices BOOLEAN; + + CASE vOption + WHEN 1 THEN + SET vRenewComponents = TRUE; + SET vKeepPrices = FALSE; + WHEN 2 THEN + SET vComponentFk = 17; + SET vRenewComponents = TRUE; + SET vKeepPrices = TRUE; + WHEN 3 THEN + SET vComponentFk = 37; + SET vRenewComponents = TRUE; + SET vKeepPrices = TRUE; + WHEN 4 THEN + SET vComponentFk = 34; + SET vRenewComponents = TRUE; + SET vKeepPrices = TRUE; + WHEN 5 THEN + SET vComponentFk = 35; + SET vRenewComponents = TRUE; + SET vKeepPrices = TRUE; + WHEN 6 THEN + SET vComponentFk = 36; + SET vRenewComponents = TRUE; + SET vKeepPrices = TRUE; + WHEN 7 THEN + REPLACE INTO saleComponent(saleFk, componentFk, value) + SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.8, 3) + FROM sale s + JOIN tmp.sale tmps ON tmps.saleFk = s.id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + AND sc.componentFk NOT IN (28, 29) + GROUP BY s.id; + + REPLACE INTO saleComponent(saleFk, componentFk, value) + SELECT s.id, 29, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.2, 3) + FROM sale s + JOIN tmp.sale tmps ON tmps.saleFk = s.id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + AND sc.componentFk NOT IN (28, 29) + GROUP BY s.id; + + SET vRenewComponents = FALSE; + SET vKeepPrices = FALSE; + WHEN 8 THEN + DELETE sc.* + FROM tmp.sale tmps JOIN saleComponent sc ON sc.saleFk = tmps.saleFk; + + REPLACE INTO saleComponent(saleFk, componentFk, value) + SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100)), 3) + FROM sale s + JOIN tmp.sale tmps ON tmps.saleFk = s.id; + + SET vRenewComponents = FALSE; + SET vKeepPrices = FALSE; + WHEN 9 THEN + SET vRenewComponents = TRUE; + SET vKeepPrices = TRUE; + END CASE; + + IF vRenewComponents THEN + DELETE sc.* + FROM tmp.sale tmps + JOIN saleComponent sc ON sc.saleFk = tmps.saleFk + JOIN componentRate cr ON cr.id = sc.componentFk + WHERE cr.isRenewable; + + REPLACE INTO saleComponent(saleFk, componentFk, value) + SELECT s.id, tc.componentFk, tc.cost + FROM sale s + JOIN tmp.sale tmps ON tmps.saleFk = s.id + JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + AND sc.componentFk = tc.componentFk + LEFT JOIN componentRate cr ON cr.id = tc.componentFk + WHERE IF(sc.componentFk IS NULL AND NOT cr.isRenewable, FALSE, TRUE); + END IF; + + IF vKeepPrices THEN + REPLACE INTO saleComponent(saleFk, componentFk, value) + SELECT s.id, vComponentFk, ROUND((s.price * (100 - s.discount) / 100) - SUM(sc.value), 3) dif + FROM sale s + JOIN tmp.sale tmps ON tmps.saleFk = s.id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + WHERE sc.saleFk <> vComponentFk + GROUP BY s.id + HAVING dif <> 0; + ELSE + UPDATE sale s + JOIN item i on i.id = s.itemFk + JOIN itemType it on it.id = i.typeFk + JOIN (SELECT SUM(sc.value) sumValue, sc.saleFk + FROM saleComponent sc + JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk + GROUP BY sc.saleFk) sc ON sc.saleFk = s.id + SET s.price = sumValue + WHERE it.code != 'PRT'; + + REPLACE INTO saleComponent(saleFk, componentFk, value) + SELECT s.id, 21, s.price * (100 - s.discount) / 100 - sum(value) saleValue + FROM sale s + JOIN tmp.sale tmps ON tmps.saleFk = s.id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + WHERE sc.componentFk != 21 + GROUP BY s.id + HAVING ROUND(saleValue, 4) <> 0; + END IF; + + UPDATE sale s + JOIN ( + SELECT SUM(sc.value) sumValue, sc.saleFk + FROM saleComponent sc + JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk + JOIN componentRate cr ON cr.id = sc.componentFk + JOIN componentTypeRate ctr on ctr.id = cr.componentTypeRate AND ctr.base + GROUP BY sc.saleFk) sc ON sc.saleFk = s.id + SET s.priceFixed = sumValue, s.isPriceFixed = 1; + + DELETE sc.* + FROM saleComponent sc + JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk + JOIN sale s on s.id = sc.saleFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + WHERE it.code = 'PRT'; + + INSERT INTO saleComponent(saleFk, componentFk, value) + SELECT s.id, 15, s.price + FROM sale s + JOIN tmp.sale tmps ON tmps.saleFk = s.id + JOIN item i ON i.id = s.itemFK + JOIN itemType it ON it.id = i.typeFk + WHERE it.code = 'PRT' AND s.price > 0; +END$$ + +DELIMITER ; + diff --git a/services/db/install/changes/1.0.8/08-ticketGetVisibleAvailable.sql b/services/db/install/changes/1.0.8/08-ticketGetVisibleAvailable.sql new file mode 100644 index 000000000..a6bd524ac --- /dev/null +++ b/services/db/install/changes/1.0.8/08-ticketGetVisibleAvailable.sql @@ -0,0 +1,38 @@ +USE `vn`; +DROP procedure IF EXISTS `ticketGetVisibleAvailable`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetVisibleAvailable`( + vTicket INT) +BEGIN + DECLARE vVisibleCalc INT; + DECLARE vAvailableCalc INT; + DECLARE vShipped DATE; + DECLARE vWarehouse TINYINT; + DECLARE vAlertLevel INT; + + SELECT t.warehouseFk, t.shipped, ts.alertLevel INTO vWarehouse, vShipped, vAlertLevel + FROM ticket t + LEFT JOIN ticketState ts ON ts.ticketFk = vTicket + WHERE t.id = vTicket; + + IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN + IF vShipped >= CURDATE() THEN + CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped); + END IF; + IF vShipped = CURDATE() THEN + CALL cache.visible_refresh(vVisibleCalc, FALSE, vWarehouse); + END IF; + END IF; + + SELECT s.id, s.itemFk, s.quantity, s.concept, s.price, s.reserved, s.discount, v.visible, av.available, it.image + FROM sale s + LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCalc + LEFT JOIN cache.available av ON av.item_id = s.itemFk AND av.calc_id = vAvailableCalc + LEFT JOIN item it ON it.id = s.itemFk + WHERE s.ticketFk = vTicket; + +END$$ + +DELIMITER ; \ No newline at end of file diff --git a/services/db/install/dump/01-structure.sql b/services/db/install/dump/01-structure.sql index 2ba6cae87..b7e39e015 100644 --- a/services/db/install/dump/01-structure.sql +++ b/services/db/install/dump/01-structure.sql @@ -363,7 +363,7 @@ CREATE TABLE `user` ( KEY `nickname` (`nickname`), KEY `lang` (`lang`), CONSTRAINT `user_ibfk_2` FOREIGN KEY (`role`) REFERENCES `role` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=14349 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; +) ENGINE=InnoDB AUTO_INCREMENT=14382 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2433,7 +2433,7 @@ CREATE TABLE `Agencias_dits` ( `value_old` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `value_new` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`idAgencia_dits`) -) ENGINE=InnoDB AUTO_INCREMENT=20997 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21044 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2534,7 +2534,7 @@ CREATE TABLE `Articles` ( CONSTRAINT `Articles_ibfk_5` FOREIGN KEY (`tipo_id`) REFERENCES `Tipos` (`tipo_id`) ON UPDATE CASCADE, CONSTRAINT `expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `Gastos` (`Id_Gasto`) ON UPDATE CASCADE, CONSTRAINT `producer_id` FOREIGN KEY (`producer_id`) REFERENCES `producer` (`producer_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=315762 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=316296 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2724,7 +2724,7 @@ CREATE TABLE `Articles_dits` ( KEY `fgkey1_idx` (`idaccion_dits`), KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`) -) ENGINE=InnoDB AUTO_INCREMENT=20260 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20282 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2746,7 +2746,7 @@ CREATE TABLE `Articles_nicho` ( KEY `Articles_nicho_wh_fk` (`warehouse_id`), CONSTRAINT `Articles_nicho_wh_fk` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Articles_nichos_fk` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=488255 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=492701 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2910,7 +2910,7 @@ CREATE TABLE `Cajas` ( KEY `warehouse_id` (`warehouse_id`), KEY `fk_Cajas_Proveedores_account1_idx` (`Proveedores_account_Id`), CONSTRAINT `Cajas_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=595126 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=596625 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3037,6 +3037,7 @@ CREATE TABLE `Clientes` ( `isCreatedAsServed` tinyint(1) DEFAULT '0', `hasInvoiceSimplified` tinyint(1) NOT NULL DEFAULT '0', `iban` varchar(45) CHARACTER SET utf8 DEFAULT NULL, + `hasLcr` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id_cliente`), UNIQUE KEY `IF` (`if`), KEY `Id_Trabajador` (`Id_Trabajador`), @@ -3057,7 +3058,7 @@ CREATE TABLE `Clientes` ( CONSTRAINT `Clientes_ibfk_5` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON UPDATE CASCADE, CONSTRAINT `canal_nuevo_cliente` FOREIGN KEY (`chanel_id`) REFERENCES `chanel` (`chanel_id`) ON UPDATE CASCADE, CONSTRAINT `tipos_de_cliente` FOREIGN KEY (`clientes_tipo_id`) REFERENCES `clientes_tipo` (`clientes_tipo_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=14349 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14382 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3240,7 +3241,7 @@ CREATE TABLE `Clientes_dits` ( PRIMARY KEY (`idClientes_dits`), KEY `idaccion_dits` (`idaccion_dits`), CONSTRAINT `Clientes_dits_ibfk_1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=71673 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=71674 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3340,7 +3341,7 @@ CREATE TABLE `Colas` ( CONSTRAINT `Colas_ibfk_3` FOREIGN KEY (`Id_Prioridad`) REFERENCES `Prioridades` (`Id_Prioridad`) ON UPDATE CASCADE, CONSTRAINT `Colas_ibfk_4` FOREIGN KEY (`Id_Impresora`) REFERENCES `Impresoras` (`Id_Impresora`) ON UPDATE CASCADE, CONSTRAINT `Colas_ibfk_5` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=274425 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=284201 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3422,7 +3423,7 @@ CREATE TABLE `Compres` ( CONSTRAINT `Compres_ibfk_2` FOREIGN KEY (`Id_Cubo`) REFERENCES `Cubos` (`Id_Cubo`) ON UPDATE CASCADE, CONSTRAINT `Compres_ibfk_3` FOREIGN KEY (`container_id`) REFERENCES `container` (`container_id`) ON UPDATE CASCADE, CONSTRAINT `buy_id` FOREIGN KEY (`Id_Entrada`) REFERENCES `Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=259298031 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=260214635 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3674,7 +3675,7 @@ CREATE TABLE `Compres_ok` ( KEY `Id_Movimiento` (`Id_Compra`), KEY `Id_Accion` (`Id_Accion`), CONSTRAINT `Compres_ok_ibfk_1` FOREIGN KEY (`Id_Compra`) REFERENCES `Compres` (`Id_Compra`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=19926 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20389 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3718,7 +3719,7 @@ CREATE TABLE `Consignatarios` ( CONSTRAINT `Consignatarios_ibfk_3` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON UPDATE CASCADE, CONSTRAINT `Consignatarios_ibfk_4` FOREIGN KEY (`Id_Agencia`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `address_customer_id` FOREIGN KEY (`Id_cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=25335 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=25379 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3902,7 +3903,7 @@ CREATE TABLE `Contactos` ( PRIMARY KEY (`Id_Contacto`), KEY `Telefono` (`Telefono`), KEY `Movil` (`Movil`) -) ENGINE=InnoDB AUTO_INCREMENT=2636 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2638 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4099,7 +4100,7 @@ CREATE TABLE `Entradas` ( CONSTRAINT `Entradas_ibfk_1` FOREIGN KEY (`Id_Proveedor`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, CONSTRAINT `Entradas_ibfk_6` FOREIGN KEY (`travel_id`) REFERENCES `travel` (`id`) ON UPDATE CASCADE, CONSTRAINT `Entradas_ibfk_7` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=144836 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; +) ENGINE=InnoDB AUTO_INCREMENT=145185 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4263,7 +4264,7 @@ CREATE TABLE `Entradas_dits` ( CONSTRAINT `Entradas_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgkey_entradas_1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fgkey_entradas_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2867272 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2877088 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4281,7 +4282,7 @@ CREATE TABLE `Entradas_kop` ( PRIMARY KEY (`Id_Entradas_kop`), KEY `entradas_entradas_kop_idx` (`Id_Entrada`), CONSTRAINT `entradas_entradas_kop` FOREIGN KEY (`Id_Entrada`) REFERENCES `Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=591 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; +) ENGINE=InnoDB AUTO_INCREMENT=632 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4369,7 +4370,7 @@ CREATE TABLE `Equipos` ( PRIMARY KEY (`id`), KEY `trabajador_id` (`trabajador_id`), CONSTRAINT `Equipos_ibfk_1` FOREIGN KEY (`trabajador_id`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=154 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=157 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4524,7 +4525,7 @@ CREATE TABLE `Facturas` ( CONSTRAINT `Facturas_ibfk_4` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `vn`.`cplusTaxBreak` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoice_bank_id` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `invoice_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=457753 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=460773 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4742,7 +4743,7 @@ CREATE TABLE `Greuges` ( KEY `Id_Ticket_Greuge_Ticket_idx` (`Id_Ticket`), CONSTRAINT `Id_Ticket_Greuge_Ticket` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `greuges_type_fk` FOREIGN KEY (`Greuges_type_id`) REFERENCES `Greuges_type` (`Greuges_type_id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2291846 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=FIXED; +) ENGINE=InnoDB AUTO_INCREMENT=2297969 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=FIXED; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4943,7 +4944,7 @@ CREATE TABLE `Movimientos` ( KEY `itemFk_ticketFk` (`Id_Article`,`Id_Ticket`), CONSTRAINT `Movimientos_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON UPDATE CASCADE, CONSTRAINT `movement_ticket_id` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=21247590 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21351994 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5092,7 +5093,7 @@ CREATE TABLE `Movimientos_mark` ( `Id_Movimiento_mark` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`Id_Movimiento_mark`), KEY `Id_Movimiento` (`Id_Movimiento`) -) ENGINE=InnoDB AUTO_INCREMENT=11090985 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=11148908 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5162,7 +5163,7 @@ CREATE TABLE `Ordenes` ( KEY `Id_Comprador` (`CodCOMPRADOR`), KEY `Id_Movimiento` (`Id_Movimiento`), KEY `Id_Vendedor` (`CodVENDEDOR`) -) ENGINE=InnoDB AUTO_INCREMENT=32089 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=32222 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5231,7 +5232,7 @@ CREATE TABLE `Paises` ( `isUeeMember` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`Id`), KEY `Id_Paisreal` (`Id_Paisreal`) -) ENGINE=InnoDB AUTO_INCREMENT=68 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=69 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5334,7 +5335,7 @@ CREATE TABLE `Proveedores` ( CONSTRAINT `pay_dem_id` FOREIGN KEY (`pay_dem_id`) REFERENCES `pay_dem` (`id`) ON UPDATE CASCADE, CONSTRAINT `pay_met_id` FOREIGN KEY (`pay_met_id`) REFERENCES `pay_met` (`id`) ON UPDATE CASCADE, CONSTRAINT `province_id` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2533 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2535 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5451,7 +5452,7 @@ CREATE TABLE `Recibos` ( CONSTRAINT `Recibos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `Recibos_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `recibo_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=470332 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=472398 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5542,7 +5543,7 @@ CREATE TABLE `Relaciones` ( KEY `Id_Contacto` (`Id_Contacto`), KEY `Id_Proveedor` (`Id_Proveedor`), KEY `Id_Cliente` (`Id_Cliente`) -) ENGINE=InnoDB AUTO_INCREMENT=2637 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2639 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5562,7 +5563,7 @@ CREATE TABLE `Remesas` ( KEY `empresa_id` (`empresa_id`), CONSTRAINT `Remesas_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `Remesas_ibfk_2` FOREIGN KEY (`Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1094 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1099 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5587,7 +5588,7 @@ CREATE TABLE `Reservas` ( PRIMARY KEY (`Id_Reserva`), KEY `Id_1` (`Id_Ticket`), KEY `Id_Article` (`Id_Article`) -) ENGINE=InnoDB AUTO_INCREMENT=2056 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2178 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5618,7 +5619,7 @@ CREATE TABLE `Rutas` ( KEY `Fecha` (`Fecha`), KEY `gestdoc_id` (`gestdoc_id`), CONSTRAINT `Rutas_ibfk_1` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=39939 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=40088 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5680,7 +5681,7 @@ CREATE TABLE `Rutas_Master` ( PRIMARY KEY (`id`), KEY `fk_rutas_warehouse_id_idx` (`warehouse_id`), CONSTRAINT `fk_rutas_warehouse_id` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=69 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5806,7 +5807,7 @@ CREATE TABLE `Split_lines` ( KEY `Id_Compra` (`Id_Compra`), CONSTRAINT `Id_Compra` FOREIGN KEY (`Id_Compra`) REFERENCES `Compres` (`Id_Compra`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Split_lines_ibfk_1` FOREIGN KEY (`Id_Split`) REFERENCES `Splits` (`Id_Split`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=324846 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=325141 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5824,7 +5825,7 @@ CREATE TABLE `Splits` ( `Notas` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`Id_Split`), KEY `Id_Entrada` (`Id_Entrada`) -) ENGINE=InnoDB AUTO_INCREMENT=36276 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=36281 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5852,7 +5853,7 @@ CREATE TABLE `Stockcontrol` ( CONSTRAINT `Stockcontrol_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Stockcontrol_ibfk_2` FOREIGN KEY (`Id_Remitente`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Stockcontrol_ibfk_3` FOREIGN KEY (`Id_Solver`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=23571 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=23581 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5910,7 +5911,7 @@ CREATE TABLE `Tickets` ( CONSTRAINT `Tickets_ibfk_9` FOREIGN KEY (`Id_Ruta`) REFERENCES `Rutas` (`Id_Ruta`) ON UPDATE CASCADE, CONSTRAINT `ticket_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `tickets_fk10` FOREIGN KEY (`Factura`) REFERENCES `Facturas` (`Id_Factura`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1908471 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1913059 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6119,7 +6120,7 @@ CREATE TABLE `Tickets_dits` ( CONSTRAINT `Tickets_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgkey1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fgkey3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=59491792 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=59579031 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6168,7 +6169,7 @@ CREATE TABLE `Tickets_turno` ( `weekDay` tinyint(1) DEFAULT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6', PRIMARY KEY (`Id_Ticket`), CONSTRAINT `Id_Ticket_fk` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1900565 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1911195 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6325,7 +6326,7 @@ CREATE TABLE `Trabajadores` ( KEY `sub` (`sub`), CONSTRAINT `Clientes` FOREIGN KEY (`Id_Cliente_Interno`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `Trabajadores_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1141 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1152 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6478,7 +6479,7 @@ CREATE TABLE `Vehiculos_consumo` ( PRIMARY KEY (`Vehiculos_consumo_id`,`Id_Vehiculo`), KEY `fk_Vehiculos_consumo_Vehiculos_idx` (`Id_Vehiculo`), CONSTRAINT `fk_Vehiculos_consumo_Vehiculos` FOREIGN KEY (`Id_Vehiculo`) REFERENCES `Vehiculos` (`Id_Vehiculo`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8475 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntan el importe de los tickets de la gasolinera solred, con quien tenemos un contrato y nos facturan mensualmente'; +) ENGINE=InnoDB AUTO_INCREMENT=8492 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntan el importe de los tickets de la gasolinera solred, con quien tenemos un contrato y nos facturan mensualmente'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6592,7 +6593,7 @@ CREATE TABLE `XDiario` ( PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), CONSTRAINT `XDiario_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3365117 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3387978 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6700,7 +6701,7 @@ CREATE TABLE `account_conciliacion` ( KEY `fg_accconciliacion_key1_idx` (`Id_Proveedores_account`), KEY `index_id_calculated` (`id_calculated`), CONSTRAINT `fg_key1_accountconc` FOREIGN KEY (`Id_Proveedores_account`) REFERENCES `Proveedores_account` (`Id_Proveedores_account`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3972 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4408 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7033,7 +7034,7 @@ CREATE TABLE `albaran` ( CONSTRAINT `fk_albaran_empresa1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_recibida` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `fk_albaran_warehouse1` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2381 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2387 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7110,7 +7111,7 @@ CREATE TABLE `awb` ( CONSTRAINT `awbInvoiceIn` FOREIGN KEY (`invoiceInFk`) REFERENCES `recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `awbTransitoryFk` FOREIGN KEY (`transitario_id`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, CONSTRAINT `awb_ibfk_1` FOREIGN KEY (`iva_id`) REFERENCES `iva_codigo` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2594 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2600 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7368,7 +7369,7 @@ CREATE TABLE `awb_gestdoc` ( KEY `awb_gestdoc_gestdoc_fk` (`gestdoc_id`), CONSTRAINT `awb_gestdoc_awb_fk` FOREIGN KEY (`awb_id`) REFERENCES `awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `awb_gestdoc_gestdoc_fk` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2257 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2262 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7486,7 +7487,7 @@ CREATE TABLE `barcodes` ( UNIQUE KEY `Id_Article_2` (`Id_Article`,`code`), KEY `Id_Article` (`Id_Article`), CONSTRAINT `barcodes_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=36155 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=36189 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7627,7 +7628,7 @@ CREATE TABLE `buy_edi` ( KEY `kop` (`kop`), KEY `barcode` (`barcode`), KEY `fec` (`fec`) -) ENGINE=InnoDB AUTO_INCREMENT=716798 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=719182 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7881,7 +7882,7 @@ CREATE TABLE `cl_act` ( CONSTRAINT `cl_act_ibfk_1` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `cl_act_ibfk_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `cl_act_ibfk_4` FOREIGN KEY (`cl_main_id`) REFERENCES `cl_main` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=85829 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=86208 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7915,7 +7916,7 @@ CREATE TABLE `cl_cau` ( CONSTRAINT `cl_cau_ibfk_7` FOREIGN KEY (`cl_mot_id`) REFERENCES `cl_mot` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_cau_ibfk_8` FOREIGN KEY (`cl_con_id`) REFERENCES `cl_con` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_cau_ibfk_9` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=46110 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=46256 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7969,7 +7970,7 @@ CREATE TABLE `cl_det` ( CONSTRAINT `cl_det_ibfk_6` FOREIGN KEY (`cl_pet_id`) REFERENCES `cl_pet` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_det_ibfk_7` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `cl_det_ibfk_8` FOREIGN KEY (`cl_main_id`) REFERENCES `cl_main` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=118173 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=118534 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8026,7 +8027,7 @@ CREATE TABLE `cl_main` ( CONSTRAINT `cl_main_ibfk_3` FOREIGN KEY (`cl_est_id`) REFERENCES `cl_est` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_main_ibfk_4` FOREIGN KEY (`cl_dep_id`) REFERENCES `cl_dep` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_main_ibfk_5` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=51164 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; +) ENGINE=InnoDB AUTO_INCREMENT=51317 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8139,7 +8140,7 @@ CREATE TABLE `client_observation` ( KEY `Id_Cliente` (`Id_Cliente`), CONSTRAINT `client_observation_ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `client_observation_ibfk_2` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=64633 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=64829 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8305,7 +8306,7 @@ CREATE TABLE `consignatarios_observation` ( `text` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`consignatarios_observation_id`), UNIQUE KEY `Id_Consigna` (`Id_Consigna`,`observation_type_id`) -) ENGINE=InnoDB AUTO_INCREMENT=3236 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; +) ENGINE=InnoDB AUTO_INCREMENT=3258 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8387,7 +8388,7 @@ CREATE TABLE `credit` ( KEY `credit_ClienteFk` (`Id_Cliente`), CONSTRAINT `credit_ClienteFk` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `workers_fk` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=64190 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=64308 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8901,7 +8902,7 @@ CREATE TABLE `escritos_det` ( PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), CONSTRAINT `escritos_det_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=15627 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=15657 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8930,7 +8931,7 @@ CREATE TABLE `expeditions` ( KEY `index4` (`ticket_id`), CONSTRAINT `Id_Agencia` FOREIGN KEY (`agency_id`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `ticket_id` FOREIGN KEY (`ticket_id`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2469933 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2477079 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9190,7 +9191,7 @@ CREATE TABLE `gestdoc` ( UNIQUE KEY `emp_id` (`emp_id`,`orden`,`warehouse_id`), KEY `trabajador_id` (`trabajador_id`), KEY `warehouse_id` (`warehouse_id`) -) ENGINE=InnoDB AUTO_INCREMENT=1022035 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; +) ENGINE=InnoDB AUTO_INCREMENT=1026134 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9389,7 +9390,7 @@ CREATE TABLE `intrastat_data` ( KEY `recibida` (`recibida_id`), CONSTRAINT `intrastat_data_ibfk_1` FOREIGN KEY (`intrastat_id`) REFERENCES `Intrastat` (`Codintrastat`) ON UPDATE CASCADE, CONSTRAINT `intrastat_data_ibfk_2` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=66795 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=67013 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9727,7 +9728,7 @@ CREATE TABLE `mail` ( `recipientFk` int(11) DEFAULT NULL, `plainTextBody` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=1375159 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=1381925 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9785,7 +9786,7 @@ CREATE TABLE `mandato` ( CONSTRAINT `mandato_fgkey1` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey2` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey3` FOREIGN KEY (`idmandato_tipo`) REFERENCES `mandato_tipo` (`idmandato_tipo`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=15285 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=15310 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9994,7 +9995,7 @@ CREATE TABLE `pago` ( CONSTRAINT `pago_moneda` FOREIGN KEY (`id_moneda`) REFERENCES `Monedas` (`Id_Moneda`) ON UPDATE CASCADE, CONSTRAINT `pago_pay_met` FOREIGN KEY (`pay_met_id`) REFERENCES `pay_met` (`id`) ON UPDATE CASCADE, CONSTRAINT `proveedor_pago` FOREIGN KEY (`id_proveedor`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=42218 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=42351 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -10489,7 +10490,7 @@ CREATE TABLE `price_fixed` ( KEY `date_end` (`date_end`), KEY `warehouse_id` (`warehouse_id`), CONSTRAINT `price_fixed_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=54118 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=54167 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -10551,7 +10552,7 @@ CREATE TABLE `producer` ( `visible` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`producer_id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=4755 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4779 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10720,7 +10721,7 @@ CREATE TABLE `recibida` ( CONSTRAINT `recibida_ibfk_5` FOREIGN KEY (`cplusInvoiceType472Fk`) REFERENCES `vn`.`cplusInvoiceType472` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibida_ibfk_6` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `vn`.`cplusRectificationType` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibida_ibfk_7` FOREIGN KEY (`cplusTrascendency472Fk`) REFERENCES `vn`.`cplusTrascendency472` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=69261 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=69434 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11309,7 +11310,7 @@ CREATE TABLE `recibida_iva` ( CONSTRAINT `recibida_iva_ibfk_2` FOREIGN KEY (`iva_id`) REFERENCES `iva_codigo` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `recibida_iva_ibfk_5` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `recibida_iva_ibfk_6` FOREIGN KEY (`gastos_id`) REFERENCES `Gastos` (`Id_Gasto`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=93766 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=94330 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11332,7 +11333,7 @@ CREATE TABLE `recibida_vencimiento` ( KEY `banco_id` (`banco_id`), CONSTRAINT `recibida_vencimiento_ibfk_6` FOREIGN KEY (`banco_id`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `recibida_vencimiento_ibfk_7` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=91038 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=91558 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11569,7 +11570,7 @@ CREATE TABLE `scan` ( `name` varchar(45) CHARACTER SET utf8 DEFAULT NULL, `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=60520 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; +) ENGINE=InnoDB AUTO_INCREMENT=60975 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11609,7 +11610,7 @@ CREATE TABLE `scan_line` ( PRIMARY KEY (`scan_line_id`), KEY `id_scan_id_idx` (`scan_id`), CONSTRAINT `id_scan_id` FOREIGN KEY (`scan_id`) REFERENCES `scan` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=765612 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=770397 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11631,7 +11632,7 @@ CREATE TABLE `sharingcart` ( KEY `Suplent` (`Id_Suplente`), CONSTRAINT `Suplent_key` FOREIGN KEY (`Id_Suplente`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `Trabajador_key` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1812 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1817 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11804,7 +11805,7 @@ CREATE TABLE `state` ( `code` varchar(45) CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) -) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12086,7 +12087,7 @@ CREATE TABLE `ticket_observation` ( KEY `observation_type_id` (`observation_type_id`), CONSTRAINT `ticket_observation_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticket_observation_ibfk_2` FOREIGN KEY (`observation_type_id`) REFERENCES `observation_type` (`observation_type_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1096044 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=1099271 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12209,7 +12210,7 @@ CREATE TABLE `travel` ( CONSTRAINT `travel_ibfk_2` FOREIGN KEY (`warehouse_id_out`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_3` FOREIGN KEY (`agency_id`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_4` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `Proveedores` (`Id_Proveedor`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=108753 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=108897 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12346,7 +12347,7 @@ CREATE TABLE `travel_dits` ( KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`), CONSTRAINT `travel_dits_ibfk_1` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=171843 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=172557 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -13720,7 +13721,7 @@ CREATE TABLE `workerTeam` ( PRIMARY KEY (`id`), KEY `user_team_idx` (`user`), CONSTRAINT `user_team` FOREIGN KEY (`user`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=153 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=159 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27340,6 +27341,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `historico`(IN idART INT, IN wh INT, IN v_virtual INT) BEGIN +-- DEPRECATED use vn.itemDiary DECLARE datFEC DATETIME; SELECT Fechainventario INTO datFEC FROM tblContadores; @@ -32533,9 +32535,6 @@ END; INSERT INTO vn2008.daily_task_log(consulta) VALUES('defaulting END'); INSERT INTO vn2008.Colas(Id_Informe,Id_Trabajador) VALUES (11,57); - - -- Desactivacion de usuarios con contrato terminado - INSERT INTO vn2008.Colas(Id_Informe) VALUES (16); SELECT SLEEP(1) INTO AUX; CALL `bi`.`Ultima_Accion`; @@ -35213,6 +35212,12 @@ BEGIN SELECT TIMESTAMP(TIMESTAMPADD(DAY, scopeDays, yesterday),'23:59:59') INTO maxDate; -- SELECT TIMESTAMP(TIMESTAMPADD(DAY, 14, yesterday),'23:59:59') INTO maxDate; -- Creamos una tabla con los Comerciales de los que se mostraran los tickets + IF worker = 2 and curdate() between '2018-07-02' and '2018-07-09' then + + set worker = 43; + + end if; + CALL subordinate(worker,TRUE); -- Se genera una tabla con los tickets representados @@ -42900,7 +42905,7 @@ CREATE TABLE `autoRadioLogCall` ( PRIMARY KEY (`id`), KEY `ticket_idx` (`ticketFk`), CONSTRAINT `ticket` FOREIGN KEY (`ticketFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43203,6 +43208,7 @@ SET character_set_client = utf8; 1 AS `hasSepaVnl`, 1 AS `hasCoreVnl`, 1 AS `hasCoreVnh`, + 1 AS `hasLcr`, 1 AS `defaultAddressFk`, 1 AS `riskCalculated`, 1 AS `clientTypeFk`, @@ -43301,7 +43307,7 @@ CREATE TABLE `clientLog` ( KEY `userFk` (`userFk`), CONSTRAINT `clientLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=166285 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=166687 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43765,7 +43771,7 @@ CREATE TABLE `creditInsurance` ( PRIMARY KEY (`id`), KEY `CreditInsurance_Fk1_idx` (`creditClassification`), CONSTRAINT `CreditInsurance_Fk1` FOREIGN KEY (`creditClassification`) REFERENCES `creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1930 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; +) ENGINE=InnoDB AUTO_INCREMENT=1935 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; /*!40101 SET character_set_client = @saved_cs_client */; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -43920,7 +43926,7 @@ CREATE TABLE `dua` ( CONSTRAINT `dua_fk1` FOREIGN KEY (`gestdocFk`) REFERENCES `vn2008`.`gestdoc` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `dua_fk2` FOREIGN KEY (`awbFk`) REFERENCES `vn2008`.`awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `dua_fk4` FOREIGN KEY (`companyFk`) REFERENCES `vn2008`.`empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3213 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3219 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43961,7 +43967,7 @@ CREATE TABLE `duaIntrastat` ( KEY `duaIntrastat_fk2_idx` (`duaFk`), CONSTRAINT `duaIntrastat_fk1` FOREIGN KEY (`intrastatFk`) REFERENCES `vn2008`.`Intrastat` (`Codintrastat`) ON UPDATE CASCADE, CONSTRAINT `duaIntrastat_fk2` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4453 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4482 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43981,7 +43987,7 @@ CREATE TABLE `duaInvoiceIn` ( KEY `duaInvoiceIn_fk2_idx` (`invoiceInFk`), CONSTRAINT `duaInvoiceIn_fk1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `duaInvoiceIn_fk2` FOREIGN KEY (`invoiceInFk`) REFERENCES `vn2008`.`recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4162 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Facturas asociadas a la declaración aduanera, básicamente la del agente transitario'; +) ENGINE=InnoDB AUTO_INCREMENT=4173 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Facturas asociadas a la declaración aduanera, básicamente la del agente transitario'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44006,7 +44012,7 @@ CREATE TABLE `duaTax` ( CONSTRAINT `duaTax_fk1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `duaTax_fk2` FOREIGN KEY (`supplierFk`) REFERENCES `vn2008`.`Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, CONSTRAINT `duaTax_fk3` FOREIGN KEY (`taxClassFk`) REFERENCES `vn2008`.`iva_group` (`iva_group_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1184 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1277 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44102,7 +44108,7 @@ CREATE TABLE `entryLog` ( KEY `entryLog_ibfk_2` (`userFk`), CONSTRAINT `entryLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `entryLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=52485 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=53296 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44686,7 +44692,7 @@ CREATE TABLE `invoiceOutExpence` ( KEY `invoiceOutExpence_FK_2_idx` (`expenceFk`), CONSTRAINT `invoiceOutExpence_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `vn2008`.`Facturas` (`factura_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutExpence_FK_2` FOREIGN KEY (`expenceFk`) REFERENCES `vn2008`.`Gastos` (`Id_Gasto`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=66896 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta'; +) ENGINE=InnoDB AUTO_INCREMENT=70220 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44729,7 +44735,7 @@ CREATE TABLE `invoiceOutTax` ( KEY `pgcFk` (`pgcFk`), CONSTRAINT `invoiceOutFk` FOREIGN KEY (`invoiceOutFk`) REFERENCES `vn2008`.`Facturas` (`factura_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutTax_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=928021 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=940415 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44942,7 +44948,7 @@ CREATE TABLE `itemTag` ( KEY `priorityItem` (`itemFk`,`priority`), KEY `tagFk` (`tagFk`,`value`), CONSTRAINT `itemFK` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=327306 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=327619 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45004,7 +45010,7 @@ CREATE TABLE `itemTaxCountry` ( CONSTRAINT `countryFK_paises` FOREIGN KEY (`countryFk`) REFERENCES `vn2008`.`Paises` (`Id`) ON UPDATE CASCADE, CONSTRAINT `itemFK_Article` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `taxClassFK_Iva_Group` FOREIGN KEY (`taxClassFk`) REFERENCES `vn2008`.`iva_group` (`iva_group_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=500774 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; +) ENGINE=InnoDB AUTO_INCREMENT=502664 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45236,7 +45242,7 @@ CREATE TABLE `message` ( KEY `sender` (`sender`), KEY `recipient` (`recipient`), KEY `uuid` (`uuid`(8)) -) ENGINE=InnoDB AUTO_INCREMENT=1515048 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1519133 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45258,7 +45264,7 @@ CREATE TABLE `messageInbox` ( PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), KEY `finalRecipient` (`finalRecipient`) -) ENGINE=InnoDB AUTO_INCREMENT=1661923 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1666176 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46159,7 +46165,7 @@ CREATE TABLE `routeLog` ( `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `description` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=510104 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=515021 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46264,7 +46270,7 @@ CREATE TABLE `sms` ( `status` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=98295 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=98690 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46428,7 +46434,7 @@ CREATE TABLE `stockBuyed` ( UNIQUE KEY `date_UNIQUE` (`date`,`user`), KEY `stockBuyed_user_idx` (`user`), CONSTRAINT `stockBuyedUserFk` FOREIGN KEY (`user`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=338307 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=342251 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46651,7 +46657,7 @@ CREATE TABLE `ticketLog` ( KEY `logTicketuserFk` (`userFk`), CONSTRAINT `ticketLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=989581 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1037767 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46751,7 +46757,7 @@ CREATE TABLE `ticketPackaging` ( KEY `ticketPackaging_fk2_idx` (`packagingFk`), CONSTRAINT `ticketPackaging_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `vn2008`.`Cubos` (`Id_Cubo`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=31840 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=32971 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47231,7 +47237,7 @@ CREATE TABLE `workerDocument` ( KEY `workerDocument_ibfk_2` (`document`), CONSTRAINT `workerDocument_ibfk_1` FOREIGN KEY (`worker`) REFERENCES `vn2008`.`Trabajadores` (`user_id`) ON UPDATE CASCADE, CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `vn2008`.`gestdoc` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=6157 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=6173 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47279,7 +47285,7 @@ CREATE TABLE `workerJourney` ( UNIQUE KEY `userFk_UNIQUE` (`userFk`,`dated`), KEY `fk_workerJourney_user_idx` (`userFk`), CONSTRAINT `fk_workerJourney_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=704119 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=736885 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47301,7 +47307,7 @@ CREATE TABLE `workerLog` ( KEY `userFk_idx` (`userFk`), CONSTRAINT `userFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `workerFk` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=4413 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4578 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47493,7 +47499,7 @@ DELIMITER ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; /*!50003 SET character_set_client = utf8mb4 */ ;; /*!50003 SET character_set_results = utf8mb4 */ ;; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; @@ -47515,7 +47521,7 @@ DELIMITER ;; vIsAlreadyNotified = FALSE THEN INSERT INTO vn2008.mail (`to`, subject, text) - VALUES ('jgallego@verdnatura.es', + VALUES ('cau@verdnatura.es', 'servidor de impresion parado', CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas')); UPDATE printingQueueCheck SET isAlreadyNotified = TRUE; @@ -49850,9 +49856,11 @@ BEGIN isTaxDataChecked = vIsTaxDataChecked, hasCoreVnl = vHasCoreVnl, isActive = TRUE; - - INSERT INTO mandate (clientFk, companyFk, mandateTypeFk) - VALUES (vUserFk, vCompanyFk, vMandateTypeFk); + + IF (SELECT COUNT(*) FROM mandate WHERE clientFk = vUserFk AND companyFk = vCompanyFk AND mandateTypeFk = vMandateTypeFk) = 0 THEN + INSERT INTO mandate (clientFk, companyFk, mandateTypeFk) + VALUES (vUserFk, vCompanyFk, vMandateTypeFk); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -50444,7 +50452,7 @@ BEGIN 1 TIPONOSUJE, 5 TIPOFACT, 1 TIPORECTIF, - 4 TERIDNIF, + IF(inv.countryFk IN (30, 1), 1, 4) TERIDNIF, inv.nif TERNIF, inv.name TERNOM, d.companyFk, @@ -50462,7 +50470,7 @@ BEGIN GROUP BY rate ) tr ON tr.rate = dt.rate JOIN - (SELECT s.account, ii.supplierRef, s.name, ii.id as serialNumber, s.nif, s.id + (SELECT s.countryFk, s.account, ii.supplierRef, s.name, ii.id as serialNumber, s.nif, s.id FROM duaEntry de JOIN entry e ON e.id = de.entryFk JOIN invoiceIn ii ON ii.id = e.invoiceInFk @@ -51862,6 +51870,7 @@ BEGIN JOIN taxCode tcLink ON tcLink.link = tc.link AND tc.id != tcLink.id AND tc.link JOIN expence e ON e.id = it.expenceFk AND e.taxTypeFk = tc.taxTypeFk WHERE tc.isActive + AND tc.type = 'S' GROUP BY tcLink.rate, e.id; @@ -53868,6 +53877,33 @@ BEGIN SET vOrderId = LAST_INSERT_ID(); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `orderListCreate` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `orderListCreate`( + vLanded DATE, + vAgencyMode INT, + vAddress INT, + vSourceApp VARCHAR(10)) +BEGIN + + DECLARE vOrderId INT; + CALL vn.orderCreate(vLanded,vAgencyMode,vAddress,vSourceApp,vOrderId); + SELECT vOrderId; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -56621,6 +56657,85 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticketGetVisibleAvailable` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetVisibleAvailable`( + vTicket INT) +BEGIN + DECLARE vVisibleCalc INT; + DECLARE vAvailableCalc INT; + DECLARE vShipped DATE; + DECLARE vWarehouse INT; + DECLARE vAlertLevel INT; + + SELECT t.warehouseFk, t.shipped, ts.alertLevel INTO vWarehouse, vShipped, vAlertLevel + FROM ticket t + LEFT JOIN ticketState ts ON ts.ticketFk = vTicket + WHERE t.id = vTicket; + + IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN + + IF vShipped >= CURDATE() THEN + CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped); + END IF; + IF vShipped = CURDATE() THEN + CALL cache.visible_refresh(vVisibleCalc, FALSE, vWarehouse); + END IF; + END IF; + + SELECT s.itemFk, s.quantity, s.price, s.discount, + i.tag1, i.val1, i.tag2, i.val2, i.tag3, i.val3, i.tag4, i.val4, i.tag5, i.val5, i.tag6, i.val6, + v.visible, av.available + FROM vn.sale s + LEFT JOIN vn.itemTagArranged i ON i.itemFk = s.itemFk + LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCalc + LEFT JOIN cache.available av ON av.item_id = s.itemFk AND av.calc_id = vAvailableCalc + WHERE s.ticketFk = vTicket; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticketListCreate` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketListCreate`( + vClientId INT + ,vShipped DATE + ,vWarehouseId INT + ,vCompanyFk INT + ,vAddressFk INT + ,vAgencyType INT + ,vRouteFk INT + ,vlanded DATE) +BEGIN + + DECLARE vNewTicket INT; + CALL vn.ticketCreate(vClientId, vShipped, vWarehouseId, vCompanyFk, vAddressFk, vAgencyType, vRouteFk, vlanded,vNewTicket); + SELECT vNewTicket; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketListVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57094,6 +57209,56 @@ BEGIN SET c.credit = 0, c.payMethodFk = p.id, hasCoreVnl = FALSE WHERE c.id = 206; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerDisableAll` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`z-developer`@`%` PROCEDURE `workerDisableAll`() +BEGIN + DECLARE done BOOL DEFAULT FALSE; + DECLARE vUserFk INT; + + DECLARE rs CURSOR FOR + SELECT a.id + FROM (((select date_end,date_start,business_id, client_id + FROM postgresql.business + GROUP BY client_id + ORDER BY client_id, date_end IS NULL DESC , date_end DESC) c + INNER JOIN (postgresql.business b + INNER JOIN (postgresql.profile pr + INNER JOIN postgresql.person p ON pr.person_id = p.person_id) ON b.client_id = pr.profile_id) ON (c.client_id = b.client_id) + AND (c.business_id = b.business_id)) + INNER JOIN vn.worker w ON p.id_trabajador = w.id) + INNER JOIN account.account a ON w.userFk = a.id + WHERE (((b.date_end) IS NOT NULL + AND (b.date_end) < CURDATE() + AND (b.date_end) > CURDATE() - 70)); + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + + OPEN rs; + + FETCH rs INTO vUserFk; + + WHILE NOT done DO + CALL workerDisable(vUserFk); + FETCH rs INTO vUserFk; + + END WHILE; + + CLOSE rs; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -57622,7 +57787,7 @@ CREATE TABLE `batch` ( KEY `buy_edi_id` (`buy_edi_id`), CONSTRAINT `batch_ibfk_1` FOREIGN KEY (`message_id`) REFERENCES `message` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `batch_ibfk_2` FOREIGN KEY (`buy_edi_id`) REFERENCES `vn2008`.`buy_edi` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=336849 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=338525 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58009,7 +58174,7 @@ CREATE TABLE `message` ( UNIQUE KEY `mail_id` (`mail_id`), KEY `sender_id` (`sender_id`), CONSTRAINT `message_ibfk_2` FOREIGN KEY (`sender_id`) REFERENCES `mail` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=358443 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=360146 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -62302,7 +62467,9 @@ UPDATE vn2008.Movimientos_componentes mc * se va a utilizar en el recobro */ -DELETE FROM bi.claims_ratio; +REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro) + SELECT Id_Cliente, 0,0,0,0 + FROM vn2008.Clientes; REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro) SELECT fm.Id_Cliente, 12 * fm.Consumo, Reclamaciones, @@ -62346,6 +62513,8 @@ UPDATE bi.claims_ratio SET recobro = LEAST(0.05, recobro) WHERE Id_Cliente = 798 -- CLIENTE 3504, VAZQUEZ UPDATE bi.claims_ratio SET recobro = GREATEST(0.08, recobro) WHERE Id_Cliente = 3504; +-- CLIENTE 5523, VERDECORA +UPDATE bi.claims_ratio SET recobro = GREATEST(0.12, recobro) WHERE Id_Cliente = 5523; -- control INSERT INTO vn2008.daily_task_log(consulta) @@ -64092,7 +64261,7 @@ CREATE TABLE `cdr` ( KEY `dstchannel` (`dst_channel`), KEY `disposition` (`disposition`), KEY `src` (`src`) -) ENGINE=MyISAM AUTO_INCREMENT=204909 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=205976 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -64884,7 +65053,7 @@ CREATE TABLE `cache_calc` ( KEY `cache_id` (`cache_id`), KEY `cacheName` (`cacheName`), KEY `expires` (`expires`) -) ENGINE=InnoDB AUTO_INCREMENT=138447 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=140616 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -66411,7 +66580,7 @@ CREATE TABLE `ACL` ( `principalType` set('ROLE','USER') COLLATE utf8_unicode_ci DEFAULT 'ROLE', `principalId` varchar(512) CHARACTER SET utf8 DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=93 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=94 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -66653,7 +66822,7 @@ CREATE TABLE `inter` ( CONSTRAINT `inter_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inter_state` FOREIGN KEY (`state_id`) REFERENCES `vn2008`.`state` (`id`) ON UPDATE CASCADE, CONSTRAINT `responsable` FOREIGN KEY (`Id_Supervisor`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=11328429 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=11396320 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67289,7 +67458,8 @@ SET character_set_client = utf8; 1 AS `id`, 1 AS `ref`, 1 AS `issued`, - 1 AS `amount`*/; + 1 AS `amount`, + 1 AS `pdf`*/; SET character_set_client = @saved_cs_client; -- @@ -67389,7 +67559,7 @@ CREATE TABLE `news` ( KEY `tag` (`tag`), CONSTRAINT `news_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`account` (`id`) ON UPDATE CASCADE, CONSTRAINT `news_ibfk_2` FOREIGN KEY (`tag`) REFERENCES `newsTag` (`name`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=13013 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13015 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67440,7 +67610,7 @@ CREATE TABLE `order` ( CONSTRAINT `order_ibfk_5` FOREIGN KEY (`address_id`) REFERENCES `vn2008`.`Consignatarios` (`id_consigna`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_8` FOREIGN KEY (`delivery_method_id`) REFERENCES `vn2008`.`Vistas` (`vista_id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_9` FOREIGN KEY (`agency_id`) REFERENCES `vn2008`.`Agencias` (`Id_Agencia`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1447495 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1453338 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67539,7 +67709,7 @@ CREATE TABLE `orderRow` ( KEY `warehouse_shipment` (`warehouseFk`,`shipment`), CONSTRAINT `orderRow_ibfk_2` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON UPDATE CASCADE, CONSTRAINT `orderRow_ibfk_3` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8897233 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8936585 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67886,7 +68056,7 @@ CREATE TABLE `tpvTransaction` ( CONSTRAINT `receipt_id` FOREIGN KEY (`receiptFk`) REFERENCES `vn2008`.`Recibos` (`Id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_2` FOREIGN KEY (`merchantFk`) REFERENCES `tpvMerchant` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=226602 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDB AUTO_INCREMENT=227743 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67921,7 +68091,7 @@ CREATE TABLE `visit` ( PRIMARY KEY (`id`), KEY `firstAgent` (`firstAgent`), CONSTRAINT `visit_ibfk_1` FOREIGN KEY (`firstAgent`) REFERENCES `visitAgent` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1300195 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1305030 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67941,7 +68111,7 @@ CREATE TABLE `visitAccess` ( KEY `visit_access_idx_agent` (`agent`), KEY `stamp` (`stamp`), CONSTRAINT `visitAccess_ibfk_1` FOREIGN KEY (`agent`) REFERENCES `visitAgent` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2843373 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2855411 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67966,7 +68136,7 @@ CREATE TABLE `visitAgent` ( KEY `firstAccess` (`firstAccess`), CONSTRAINT `visitAgent_ibfk_1` FOREIGN KEY (`visit`) REFERENCES `visit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `visitAgent_ibfk_2` FOREIGN KEY (`firstAccess`) REFERENCES `visitAccess` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1845585 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1851273 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67986,7 +68156,7 @@ CREATE TABLE `visitUser` ( KEY `date_time` (`stamp`), KEY `user_id` (`user`), CONSTRAINT `visitUser_ibfk_1` FOREIGN KEY (`access`) REFERENCES `visitAccess` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2705822 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2715474 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -72929,7 +73099,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `client` AS select `c`.`id_cliente` AS `id`,`c`.`cliente` AS `name`,`c`.`if` AS `fi`,`c`.`razonSocial` AS `socialName`,`c`.`contacto` AS `contact`,`c`.`domicilio` AS `street`,`c`.`poblacion` AS `city`,`c`.`codPostal` AS `postcode`,`c`.`telefono` AS `phone`,`c`.`movil` AS `mobile`,`c`.`fax` AS `fax`,`c`.`real` AS `isRelevant`,`c`.`e-mail` AS `email`,`c`.`iban` AS `iban`,`c`.`vencimiento` AS `dueDay`,`c`.`Cuenta` AS `accountingAccount`,`c`.`RE` AS `isEqualizated`,`c`.`province_id` AS `provinceFk`,`c`.`invoice` AS `hasToInvoice`,`c`.`credito` AS `credit`,`c`.`Id_Pais` AS `countryFk`,`c`.`activo` AS `isActive`,`c`.`gestdoc_id` AS `gestdocFk`,`c`.`calidad` AS `quality`,`c`.`pay_met_id` AS `payMethodFk`,`c`.`created` AS `created`,`c`.`mail` AS `isToBeMailed`,`c`.`chanel_id` AS `contactChannelFk`,`c`.`sepaVnl` AS `hasSepaVnl`,`c`.`coreVnl` AS `hasCoreVnl`,`c`.`coreVnh` AS `hasCoreVnh`,`c`.`default_address` AS `defaultAddressFk`,`c`.`risk_calculated` AS `riskCalculated`,`c`.`clientes_tipo_id` AS `clientTypeFk`,`c`.`mail_address` AS `mailAddress`,`c`.`cplusTerIdNifFk` AS `cplusTerIdNifFk`,`c`.`invoiceByAddress` AS `hasToInvoiceByAddress`,`c`.`contabilizado` AS `isTaxDataChecked`,`c`.`congelado` AS `isFreezed`,`c`.`creditInsurance` AS `creditInsurance`,`c`.`isCreatedAsServed` AS `isCreatedAsServed`,`c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`,`c`.`Id_Trabajador` AS `salesPersonFk`,`c`.`vies` AS `isVies`,`c`.`EYPBC` AS `eypbc` from `vn2008`.`Clientes` `c` */; +/*!50001 VIEW `client` AS select `c`.`id_cliente` AS `id`,`c`.`cliente` AS `name`,`c`.`if` AS `fi`,`c`.`razonSocial` AS `socialName`,`c`.`contacto` AS `contact`,`c`.`domicilio` AS `street`,`c`.`poblacion` AS `city`,`c`.`codPostal` AS `postcode`,`c`.`telefono` AS `phone`,`c`.`movil` AS `mobile`,`c`.`fax` AS `fax`,`c`.`real` AS `isRelevant`,`c`.`e-mail` AS `email`,`c`.`iban` AS `iban`,`c`.`vencimiento` AS `dueDay`,`c`.`Cuenta` AS `accountingAccount`,`c`.`RE` AS `isEqualizated`,`c`.`province_id` AS `provinceFk`,`c`.`invoice` AS `hasToInvoice`,`c`.`credito` AS `credit`,`c`.`Id_Pais` AS `countryFk`,`c`.`activo` AS `isActive`,`c`.`gestdoc_id` AS `gestdocFk`,`c`.`calidad` AS `quality`,`c`.`pay_met_id` AS `payMethodFk`,`c`.`created` AS `created`,`c`.`mail` AS `isToBeMailed`,`c`.`chanel_id` AS `contactChannelFk`,`c`.`sepaVnl` AS `hasSepaVnl`,`c`.`coreVnl` AS `hasCoreVnl`,`c`.`coreVnh` AS `hasCoreVnh`,`c`.`hasLcr` AS `hasLcr`,`c`.`default_address` AS `defaultAddressFk`,`c`.`risk_calculated` AS `riskCalculated`,`c`.`clientes_tipo_id` AS `clientTypeFk`,`c`.`mail_address` AS `mailAddress`,`c`.`cplusTerIdNifFk` AS `cplusTerIdNifFk`,`c`.`invoiceByAddress` AS `hasToInvoiceByAddress`,`c`.`contabilizado` AS `isTaxDataChecked`,`c`.`congelado` AS `isFreezed`,`c`.`creditInsurance` AS `creditInsurance`,`c`.`isCreatedAsServed` AS `isCreatedAsServed`,`c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`,`c`.`Id_Trabajador` AS `salesPersonFk`,`c`.`vies` AS `isVies`,`c`.`EYPBC` AS `eypbc` from `vn2008`.`Clientes` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -75928,12 +76098,12 @@ USE `hedera`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myInvoice` AS select `i`.`id` AS `id`,`i`.`ref` AS `ref`,`i`.`issued` AS `issued`,`i`.`amount` AS `amount` from `vn`.`invoiceOut` `i` where (`i`.`clientFk` = `account`.`myUserGetId`()) */; +/*!50001 VIEW `myInvoice` AS select `i`.`id` AS `id`,`i`.`ref` AS `ref`,`i`.`issued` AS `issued`,`i`.`amount` AS `amount`,`i`.`pdf` AS `pdf` from `vn`.`invoiceOut` `i` where (`i`.`clientFk` = `account`.`myUserGetId`()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -76062,4 +76232,4 @@ USE `stock`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-06-29 8:06:40 +-- Dump completed on 2018-07-04 9:12:43 diff --git a/services/db/install/dump/fixtures.sql b/services/db/install/dump/fixtures.sql index b43662633..a3156c21b 100644 --- a/services/db/install/dump/fixtures.sql +++ b/services/db/install/dump/fixtures.sql @@ -88,6 +88,8 @@ UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 4; UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 5; UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 2 WHERE `id` = 6; +UPDATE `vn`.`agencyMode` SET `web` = 1 WHERE `id` = 1; + INSERT INTO `vn`.`payMethod`(`id`, `name`, `graceDays`, `outstandingDebt`, `ibanRequired`) VALUES (1, 'PayMethod one', 0, 001, 0), @@ -156,7 +158,7 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city (101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceWayne@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1), (102, 'Petter Parker', '87945234L', 'Spider-Man', 'Aunt May', '20 Ingram Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'PetterParker@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 0, 1, NULL, 0, 0, 18, 0, 1), (103, 'Clark Kent', '06815934E', 'Super-Man', 'lois lane', '344 Clinton Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'ClarkKent@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1), - (104, 'Tony Stark', '06089160W', 'Iron-Man', 'Pepper Potts', '10880 Malibu Point', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'TonyStark@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1), + (104, 'Tony Stark', '06089160W', 'Iron-Man', 'Pepper Potts', '10880 Malibu Point', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'TonyStark@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), (105, 'Max Eisenhardt', '39182496H', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'MaxEisenhardt@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, NULL, 0, 1), (106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'Evil hideout', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'DavidCharlesHaller@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1), (107, 'Hank Pym', '09854837G', 'Ant-Man', 'Hawk', 'Anthill', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'HankPym@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1), diff --git a/services/loopback/common/locale/en.json b/services/loopback/common/locale/en.json index be28c8810..65a000c1b 100644 --- a/services/loopback/common/locale/en.json +++ b/services/loopback/common/locale/en.json @@ -7,7 +7,7 @@ "Can't be blank": "Can't be blank", "Invalid TIN": "Invalid TIN", "TIN must be unique": "TIN must be unique", - "A user with that name already exists": "A user with that name already exists", + "A client with that Web User name already exists": "A client with that Web User name already exists", "Is invalid": "Is invalid", "Quantity cannot be zero": "Quantity cannot be zero", "Enter an integer different to zero": "Enter an integer different to zero", @@ -21,6 +21,5 @@ "Only manager can change the credit": "Only manager can change the credit", "Name cannot be blank": "Name cannot be blank", "Phone cannot be blank": "Phone cannot be blank", - "ValidationError: La instancia `ClientContact` no es válida. Detalles: `name` Name cannot be blank (value: null).": "ValidationError: La instancia `ClientContact` no es válida. Detalles: `name` Name cannot be blank (value: null).", - "La instancia `ClientContact` no es válida. Detalles: `name` Name cannot be blank (value: null).": "La instancia `ClientContact` no es válida. Detalles: `name` Name cannot be blank (value: null)." + "Observation type cannot be blank": "Observation type cannot be blank" } \ No newline at end of file diff --git a/services/loopback/common/locale/es.json b/services/loopback/common/locale/es.json index d267a3464..58fe0f3c1 100644 --- a/services/loopback/common/locale/es.json +++ b/services/loopback/common/locale/es.json @@ -7,7 +7,7 @@ "Can't be blank": "No puede estar en blanco", "Invalid TIN": "DNI Incorrecto", "TIN must be unique": "El NIF/CIF debe ser único", - "A user with that name already exists": "Ya existe un usuario con ese nombre", + "A client with that Web User name already exists": "Ya existe un cliente con ese Usuario Web", "Is invalid": "Is invalid", "Quantity cannot be zero": "La cantidad no puede ser cero", "Enter an integer different to zero": "Introduce un entero distinto de cero", @@ -26,5 +26,6 @@ "NO_AGENCY_AVAILABLE": "NO_AGENCY_AVAILABLE", "Only manager can change the credit": "Solo el gerente puede cambiar el credito de este cliente", "Name cannot be blank": "El nombre no puede estar en blanco", - "Phone cannot be blank": "El teléfono no puede estar en blanco" + "Phone cannot be blank": "El teléfono no puede estar en blanco", + "Period cannot be blank": "El periodo no puede estar en blanco" } \ No newline at end of file diff --git a/services/loopback/common/methods/agency/landsThatDay.js b/services/loopback/common/methods/agency/landsThatDay.js new file mode 100644 index 000000000..00184f32f --- /dev/null +++ b/services/loopback/common/methods/agency/landsThatDay.js @@ -0,0 +1,27 @@ +module.exports = Self => { + Self.remoteMethod('landsThatDay', { + description: 'Returns a list of agencies that can land a shipment on a day for an address', + accessType: '', + accepts: [{ + arg: 'filter', + type: 'object', + required: true, + description: 'addressFk' + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/landsThatDay`, + verb: 'get' + } + }); + + Self.landsThatDay = async filter => { + let query = `CALL vn.agencyHourGetAgency(?, ?)`; + let result = await Self.rawSql(query, [filter.addressFk, filter.landed]); + + return result; + }; +}; diff --git a/services/loopback/common/methods/client/summary.js b/services/loopback/common/methods/client/summary.js index 95cecbc9d..ab0732032 100644 --- a/services/loopback/common/methods/client/summary.js +++ b/services/loopback/common/methods/client/summary.js @@ -47,6 +47,19 @@ module.exports = Self => { where: {isDefaultAddress: true}, fields: ['nickname', 'street', 'city', 'postalCode'] } + }, + { + relation: 'classifications', + scope: { + include: { + relation: 'insurances', + scope: { + fields: ['id', 'grade', 'created'], + order: 'created DESC' + } + }, + where: {finished: null} + } } ], where: {id: clientId} diff --git a/services/loopback/common/methods/client/updateBasicData.js b/services/loopback/common/methods/client/updateBasicData.js new file mode 100644 index 000000000..81c216c06 --- /dev/null +++ b/services/loopback/common/methods/client/updateBasicData.js @@ -0,0 +1,38 @@ +module.exports = Self => { + Self.remoteMethod('updateBasicData', { + description: 'Updates billing data of a client', + accessType: 'WRITE', + accepts: [{ + arg: 'data', + type: 'Object', + required: true, + description: 'Params to update', + http: {source: 'body'} + }, { + arg: 'id', + type: 'string', + required: true, + description: 'Model id', + http: {source: 'path'} + }], + returns: { + arg: 'data', + type: 'Worker', + root: true + }, + http: { + path: `/:id/updateBasicData`, + verb: 'PATCH' + } + }); + + Self.updateBasicData = async(params, id) => { + let validUpdateParams = ['id', 'contact', 'name', 'email', 'phone', 'mobile', 'salesPersonFk', 'contactChannelFk']; + for (const key in params) { + if (validUpdateParams.indexOf(key) === -1) + throw new Error(`You don't have enough privileges to do that`); + } + + return await Self.app.models.Client.update({id: id}, params); + }; +}; diff --git a/services/loopback/common/methods/client/updateBillingData.js b/services/loopback/common/methods/client/updateBillingData.js new file mode 100644 index 000000000..3f8a8448d --- /dev/null +++ b/services/loopback/common/methods/client/updateBillingData.js @@ -0,0 +1,53 @@ +module.exports = Self => { + Self.remoteMethodCtx('updateBillingData', { + description: 'Updates billing data of a client', + accessType: 'WRITE', + accepts: [{ + arg: 'data', + type: 'Object', + required: true, + description: 'Params to update', + http: {source: 'body'} + }, { + arg: 'id', + type: 'string', + required: true, + description: 'Model id', + http: {source: 'path'} + }], + returns: { + arg: 'data', + type: 'Worker', + root: true + }, + http: { + path: `/:id/updateBillingData`, + verb: 'PATCH' + } + }); + + Self.updateBillingData = async(ctx, params, id) => { + let userId = ctx.req.accessToken.userId; + let isAdministrative = await Self.app.models.Account.hasRole(userId, 'administrative'); + + let [taxData] = await Self.app.models.Client.find({where: {id: id}, fields: ['isTaxDataChecked']}); + if (!isAdministrative && taxData.isTaxDataChecked) + throw new Error(`You don't have enough privileges to do that`); + + let validUpdateParams = [ + 'payMethodFk', + 'dueDay', + 'iban', + 'hasLcr', + 'hasCoreVnl', + 'hasSepaVnl' + ]; + + for (const key in params) { + if (validUpdateParams.indexOf(key) === -1) + throw new Error(`You don't have enough privileges to do that`); + } + + return await Self.app.models.Client.update({id: id}, params); + }; +}; diff --git a/services/loopback/common/methods/client/updateFiscalData.js b/services/loopback/common/methods/client/updateFiscalData.js new file mode 100644 index 000000000..36f7268e8 --- /dev/null +++ b/services/loopback/common/methods/client/updateFiscalData.js @@ -0,0 +1,65 @@ +module.exports = Self => { + Self.remoteMethodCtx('updateFiscalData', { + description: 'Updates billing data of a client', + accessType: 'WRITE', + accepts: [{ + arg: 'data', + type: 'Object', + required: true, + description: 'Params to update', + http: {source: 'body'} + }, { + arg: 'id', + type: 'string', + required: true, + description: 'Model id', + http: {source: 'path'} + }], + returns: { + arg: 'res', + type: 'String', + root: true + }, + http: { + path: `/:id/updateFiscalData`, + verb: 'PATCH' + } + }); + + Self.updateFiscalData = async(ctx, params, id) => { + let userId = ctx.req.accessToken.userId; + let isAdministrative = await Self.app.models.Account.hasRole(userId, 'administrative'); + + let [taxData] = await Self.app.models.Client.find({where: {id: id}, fields: ['isTaxDataChecked']}); + if (!isAdministrative && taxData.isTaxDataChecked) + throw new Error(`You don't have enough privileges to do that`); + + let validUpdateParams = [ + 'id', + 'socialName', + 'fi', + 'street', + 'postcode', + 'city', + 'countryFk', + 'provinceFk', + 'isActive', + 'isFreezed', + 'hasToInvoice', + 'isVies', + 'isToBeMailed', + 'hasToInvoiceByAddress', + 'isEqualizated', + 'isTaxDataVerified', + 'isTaxDataChecked' + ]; + + for (const key in params) { + if (validUpdateParams.indexOf(key) === -1) + throw new Error(`You don't have enough privileges to do that`); + } + + params.id = id; + return await Self.app.models.Client.update({id: id}, params); + }; +}; diff --git a/services/loopback/common/methods/item/filter.js b/services/loopback/common/methods/item/filter.js new file mode 100644 index 000000000..8334e77d8 --- /dev/null +++ b/services/loopback/common/methods/item/filter.js @@ -0,0 +1,57 @@ + +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +module.exports = Self => { + Self.remoteMethod('filter', { + description: 'Find all instances of the model matched by filter from the data source.', + accessType: 'READ', + accepts: [ + { + arg: 'filter', + type: 'Object', + description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', + http: {source: 'query'} + }, { + arg: 'tags', + type: ['Object'], + description: 'List of tags to filter with', + http: {source: 'query'} + } + ], + returns: { + type: ['Object'], + root: true + }, + http: { + path: `/filter`, + verb: 'GET' + } + }); + + Self.filter = async(filter, tags) => { + let stmt = new ParameterizedSQL( + `SELECT i.id, i.image, i.name, i.description, i.size, + t.name type, w.firstName, w.name worker + FROM item i + JOIN itemType t ON t.id = i.typeFk + JOIN worker w ON w.id = t.workerFk` + ); + + if (tags) { + let i = 1; + for (let tag of tags) { + if (tag.value == null) continue; + let tAlias = `it${i++}`; + stmt.merge({ + sql: `JOIN itemTag ${tAlias} ON ${tAlias}.itemFk = i.id + AND ${tAlias}.tagFk = ? + AND ${tAlias}.value = ?`, + params: [tag.tagFk, tag.value] + }); + } + } + + stmt.merge(Self.buildSuffix(filter, 'i')); + return Self.rawStmt(stmt); + }; +}; diff --git a/services/loopback/common/methods/item/getDiary.js b/services/loopback/common/methods/item/getDiary.js index df4176713..5d8259867 100644 --- a/services/loopback/common/methods/item/getDiary.js +++ b/services/loopback/common/methods/item/getDiary.js @@ -3,12 +3,14 @@ module.exports = Self => { description: 'Returns the ', accessType: 'READ', accepts: [{ - arg: 'params', - type: 'object', - description: 'itemFk, warehouseFk' + arg: 'filter', + type: 'Object', + required: true, + description: 'Filter defining where and paginated data', + http: {source: 'query'} }], returns: { - arg: 'diary', + type: ['Object'], root: true }, http: { @@ -17,8 +19,9 @@ module.exports = Self => { } }); - Self.getDiary = async params => { - let [diary] = await Self.rawSql(`CALL vn.itemDiary(?, ?)`, [params.itemFk, params.warehouseFk]); + Self.getDiary = async filter => { + let where = filter.where; + let [diary] = await Self.rawSql(`CALL vn.itemDiary(?, ?)`, [where.itemFk, where.warehouseFk]); return diary; }; }; diff --git a/services/loopback/common/methods/item/getLastEntries.js b/services/loopback/common/methods/item/getLastEntries.js index ec414f60f..bab808cef 100644 --- a/services/loopback/common/methods/item/getLastEntries.js +++ b/services/loopback/common/methods/item/getLastEntries.js @@ -19,8 +19,9 @@ module.exports = Self => { }); Self.getLastEntries = async filter => { + let where = filter.where; let query = `CALL vn.itemLastEntries(?, ?)`; - let [lastEntries] = await Self.rawSql(query, [filter.itemFk, filter.date]); + let [lastEntries] = await Self.rawSql(query, [where.itemFk, where.date]); return lastEntries; }; }; diff --git a/services/loopback/common/methods/sale/crudSale.js b/services/loopback/common/methods/sale/crudSale.js deleted file mode 100644 index b33d70fc5..000000000 --- a/services/loopback/common/methods/sale/crudSale.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = Self => { - Self.installCrudModel('crudSale'); -}; diff --git a/services/loopback/common/methods/sale/moveToNewTicket.js b/services/loopback/common/methods/sale/moveToNewTicket.js index 348e1e51e..469b729fe 100644 --- a/services/loopback/common/methods/sale/moveToNewTicket.js +++ b/services/loopback/common/methods/sale/moveToNewTicket.js @@ -32,20 +32,25 @@ module.exports = Self => { throw new Error(`The sales of this ticket can't be modified`); let travelDates = await model.Agency.getFirstShipped(params.ticket); + let shipped = new Date(travelDates.vShipped); + shipped.setMinutes(shipped.getMinutes() + shipped.getTimezoneOffset()); + + let landed = new Date(travelDates.vLanded); + landed.setMinutes(landed.getMinutes() + landed.getTimezoneOffset()); let newTicketParams = { clientFk: params.ticket.clientFk, addressFk: params.ticket.addressFk, agencyModeFk: params.ticket.agencyModeFk, warehouseFk: params.ticket.warehouseFk, - shipped: travelDates.vShipped, - landed: travelDates.vLanded + shipped: shipped, + landed: landed }; - let newTicket = await model.Ticket.create(newTicketParams); + let newTicket = await model.Ticket.new(newTicketParams); for (let i = 0; i < params.sales.length; i++) { - await model.Sale.update({id: params.sales[i].id}, {ticketFk: newTicket.id}); + await model.Sale.update({id: params.sales[i].id}, {ticketFk: newTicket}); } return newTicket; }; diff --git a/services/loopback/common/methods/sale/reserve.js b/services/loopback/common/methods/sale/reserve.js new file mode 100644 index 000000000..1370058c4 --- /dev/null +++ b/services/loopback/common/methods/sale/reserve.js @@ -0,0 +1,32 @@ + +module.exports = Self => { + Self.remoteMethod('reserve', { + description: 'Change the state of a ticket', + accessType: '', + accepts: [{ + arg: 'params', + type: 'object', + required: true, + description: '[sales IDs], actualTicketFk, reserved', + http: {source: 'body'} + }], + returns: { + type: 'string', + root: true + }, + http: { + path: `/reserve`, + verb: 'post' + } + }); + + Self.reserve = async params => { + let thisTicketIsEditable = await Self.app.models.Ticket.isEditable(params.actualTicketFk); + if (!thisTicketIsEditable) + throw new Error(`The sales of this ticket can't be modified`); + + for (let i = 0; i < params.sales.length; i++) { + await Self.app.models.Sale.update({id: params.sales[i].id}, {reserved: params.reserved}); + } + }; +}; diff --git a/services/loopback/common/methods/sale/updateDiscount.js b/services/loopback/common/methods/sale/updateDiscount.js index 5d393c9a6..a46dc1f7d 100644 --- a/services/loopback/common/methods/sale/updateDiscount.js +++ b/services/loopback/common/methods/sale/updateDiscount.js @@ -20,6 +20,9 @@ module.exports = Self => { }); Self.updateDiscount = async params => { + if (isNaN(params.editLines[0].discount)) + throw new Error(`The value should be a number`); + let model = Self.app.models; let thisTicketIsEditable = await model.Ticket.isEditable(params.editLines[0].ticketFk); @@ -49,7 +52,7 @@ module.exports = Self => { for (let i = 0; i < params.editLines.length; i++) { let currentLine = await model.Sale.findOne({where: {id: params.editLines[i].id}, fields: 'price'}); - let value = (-currentLine.price * params.editLines[i].discount / 100); + let value = ((-currentLine.price * params.editLines[i].discount) / 100); await model.SaleComponent.upsert({saleFk: params.editLines[i].id, value: value, componentFk: componentToUse}); await model.Sale.update({id: params.editLines[i].id}, {discount: params.editLines[i].discount}); diff --git a/services/loopback/common/methods/sale/updatePrice.js b/services/loopback/common/methods/sale/updatePrice.js index be0b5af31..5f38d1440 100644 --- a/services/loopback/common/methods/sale/updatePrice.js +++ b/services/loopback/common/methods/sale/updatePrice.js @@ -20,6 +20,8 @@ module.exports = Self => { }); Self.updatePrice = async params => { + if (isNaN(params.price)) + throw new Error(`The value should be a number`); if (!params.price) params.price = 0; let model = Self.app.models; let thisTicketIsEditable = await model.Ticket.isEditable(params.ticketFk); diff --git a/services/loopback/common/methods/sale/updateQuantity.js b/services/loopback/common/methods/sale/updateQuantity.js index eac9ac309..5fd66866a 100644 --- a/services/loopback/common/methods/sale/updateQuantity.js +++ b/services/loopback/common/methods/sale/updateQuantity.js @@ -25,6 +25,9 @@ module.exports = Self => { }); Self.updateQuantity = async(id, quantity) => { + if (isNaN(params.editLines[0].discount)) + throw new Error(`The value should be a number`); + let currentLine = await Self.app.models.Sale.findOne({where: {id: id}, fields: ['quantity']}); if (quantity > currentLine.quantity) throw new Error('The new quantity should be smaller than the old one'); diff --git a/services/loopback/common/methods/ticket/getSales.js b/services/loopback/common/methods/ticket/getSales.js new file mode 100644 index 000000000..86f64be8b --- /dev/null +++ b/services/loopback/common/methods/ticket/getSales.js @@ -0,0 +1,59 @@ +module.exports = Self => { + Self.remoteMethod('getSales', { + description: 'New filter', + accessType: 'READ', + accepts: [{ + arg: 'ticketFk', + type: 'number', + required: true, + description: 'ticket id', + http: {source: 'path'} + }], + returns: { + type: ['Object'], + root: true + }, + http: { + path: `/:ticketFk/getSales`, + verb: 'get' + } + }); + + Self.getSales = async ticketFk => { + let query = `CALL vn.ticketGetVisibleAvailable(?)`; + let [lines] = await Self.rawSql(query, [ticketFk]); + let ids = []; + + for (line of lines) + ids.push(line.itemFk); + + let filter = { + fields: ['id'], + where: {id: {inq: ids}}, + include: { + relation: 'tags', + scope: { + fields: ['tagFk', 'value', 'priority'], + where: {priority: {lte: 6}}, + order: 'priority', + include: { + relation: 'tag', + scope: { + fields: ['name'] + } + } + } + } + }; + let items = await Self.app.models.Item.find(filter); + + let map = {}; + for (item of items) + map[item.id] = item; + + for (line of lines) + line.item = {tags: map[line.itemFk].tags()}; + + return lines; + }; +}; diff --git a/services/loopback/common/methods/ticket/create.js b/services/loopback/common/methods/ticket/new.js similarity index 81% rename from services/loopback/common/methods/ticket/create.js rename to services/loopback/common/methods/ticket/new.js index db7c100cb..b6d9e87bb 100644 --- a/services/loopback/common/methods/ticket/create.js +++ b/services/loopback/common/methods/ticket/new.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('create', { + Self.remoteMethod('new', { description: 'Create a newticket and returns the new ID', accessType: 'WRITE', accepts: [{ @@ -14,12 +14,12 @@ module.exports = Self => { root: true }, http: { - path: `/create`, + path: `/new`, verb: 'post' } }); - Self.create = async params => { + Self.new = async params => { let existsAddress = await Self.app.models.Address.findOne({where: {id: params.addressFk, clientFk: params.clientFk}}); if (!existsAddress) throw new Error(`This address doesn't exist`); @@ -28,13 +28,13 @@ module.exports = Self => { let result = await Self.rawSql(query, [ params.clientFk, params.shipped, - params.wharehouseFk, - params.companyFk, + params.warehouseFk, + params.companyFk | 442, params.addressFk, params.agencyModeFk, - params.routeFk, + params.routeFk | null, params.landed ]); - return result; + return result[0][0].vNewTicket; }; }; diff --git a/services/loopback/common/methods/vn-model/rawSql.js b/services/loopback/common/methods/vn-model/rawSql.js deleted file mode 100644 index 9b8a0a07e..000000000 --- a/services/loopback/common/methods/vn-model/rawSql.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = function(Self) { - Self.rawSql = function(query, params, cb) { - var connector = this.dataSource.connector; - return new Promise(function(resolve, reject) { - connector.execute(query, params, function(error, response) { - if (cb) - cb(error, response); - if (error) - reject(error); - else - resolve(response); - }); - }); - }; -}; diff --git a/services/loopback/common/models/account.js b/services/loopback/common/models/account.js index 3a7cb2da8..791f21d14 100644 --- a/services/loopback/common/models/account.js +++ b/services/loopback/common/models/account.js @@ -4,7 +4,7 @@ module.exports = Self => { // Validations Self.validatesUniquenessOf('name', { - message: 'A user with that name already exists' + message: `A client with that Web User name already exists` }); Self.observe('before save', (ctx, next) => { diff --git a/services/loopback/common/models/agency.js b/services/loopback/common/models/agency.js index 251ba183a..9994624df 100644 --- a/services/loopback/common/models/agency.js +++ b/services/loopback/common/models/agency.js @@ -1,5 +1,5 @@ module.exports = Self => { Self.defineScope({where: {isManaged: {neq: 0}}}); - //require('../methods/agency/sendsThatDay')(Self); + require('../methods/agency/landsThatDay')(Self); require('../methods/agency/getFirstShipped')(Self); }; diff --git a/services/loopback/common/models/client.js b/services/loopback/common/models/client.js index c85a78571..2aa0d39a8 100644 --- a/services/loopback/common/models/client.js +++ b/services/loopback/common/models/client.js @@ -18,6 +18,9 @@ module.exports = Self => { require('../methods/client/getMana')(Self); require('../methods/client/getAverageInvoiced')(Self); require('../methods/client/summary')(Self); + require('../methods/client/updateFiscalData')(Self); + require('../methods/client/updateBillingData')(Self); + require('../methods/client/updateBasicData')(Self); // Validations @@ -89,7 +92,9 @@ module.exports = Self => { Self.observe('before save', async function(ctx) { let changes = ctx.data || ctx.instance; + let orgData = ctx.currentInstance; let finalState = getFinalState(ctx); + let payMethodWithIban = 4; if (changes.salesPerson === null) { changes.credit = 0; @@ -97,7 +102,10 @@ module.exports = Self => { changes.payMethodFk = 5; // Credit card } - if (changes.payMethodFk !== undefined && changes.dueDay === undefined) + let payMethodFk = changes.payMethodFk || (orgData && orgData.payMethodFk); + let dueDay = changes.dueDay || (orgData && orgData.dueDay); + + if (payMethodFk == payMethodWithIban && dueDay == 0) changes.dueDay = 5; if (isMultiple(ctx)) return; diff --git a/services/loopback/common/models/client.json b/services/loopback/common/models/client.json index a44afb813..d80e31d9e 100644 --- a/services/loopback/common/models/client.json +++ b/services/loopback/common/models/client.json @@ -83,6 +83,9 @@ "hasSepaVnl": { "type": "boolean" }, + "hasLcr": { + "type": "boolean" + }, "hasCoreVnl": { "type": "boolean" }, @@ -157,7 +160,7 @@ "model": "Greuge", "foreignKey": "clientFk" }, - "creditClassifications": { + "classifications": { "type": "hasMany", "model": "CreditClassification", "foreignKey": "client" diff --git a/services/loopback/common/models/item-type.json b/services/loopback/common/models/item-type.json index 8619a35be..c4753e531 100644 --- a/services/loopback/common/models/item-type.json +++ b/services/loopback/common/models/item-type.json @@ -24,10 +24,15 @@ }, "relations": { "worker": { - "type": "belongsTo", - "model": "Worker", - "foreignKey": "workerFk" - } + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "warehouse": { + "type": "belongsTo", + "model": "Warehouse", + "foreignKey": "warehouseFk" + } }, "acls": [ { diff --git a/services/loopback/common/models/item.js b/services/loopback/common/models/item.js index 2f54244bf..08ea8828a 100644 --- a/services/loopback/common/models/item.js +++ b/services/loopback/common/models/item.js @@ -1,6 +1,7 @@ let UserError = require('../helpers').UserError; module.exports = Self => { + require('../methods/item/filter')(Self); require('../methods/item/clone')(Self); require('../methods/item/updateTaxes')(Self); require('../methods/item/getDiary')(Self); diff --git a/services/loopback/common/models/sale.js b/services/loopback/common/models/sale.js index 9bd300860..47feb07d8 100644 --- a/services/loopback/common/models/sale.js +++ b/services/loopback/common/models/sale.js @@ -2,8 +2,8 @@ module.exports = Self => { require('../methods/sale/filter')(Self); require('../methods/sale/saleComponentFilter')(Self); require('../methods/sale/priceDifference')(Self); - require('../methods/sale/crudSale')(Self); require('../methods/sale/moveToTicket')(Self); + require('../methods/sale/reserve')(Self); require('../methods/sale/moveToNewTicket')(Self); require('../methods/sale/removes')(Self); require('../methods/sale/updateDiscount')(Self); diff --git a/services/loopback/common/models/sale.json b/services/loopback/common/models/sale.json index cc2569b89..7dc61cc09 100644 --- a/services/loopback/common/models/sale.json +++ b/services/loopback/common/models/sale.json @@ -25,7 +25,7 @@ "type": "Number" }, "reserved": { - "type": "Number" + "type": "boolean" }, "isPicked": { "type": "Number" @@ -56,6 +56,11 @@ "type": "hasMany", "model": "SaleComponent", "foreignKey": "saleFk" - } + }, + "saleTracking": { + "type": "hasOne", + "model": "SaleTracking", + "foreignKey": "saleFk" + } } } diff --git a/services/loopback/common/models/ticket.js b/services/loopback/common/models/ticket.js index 2c26b92f8..1eaadb5ce 100644 --- a/services/loopback/common/models/ticket.js +++ b/services/loopback/common/models/ticket.js @@ -7,10 +7,11 @@ module.exports = Self => { require('../methods/ticket/getTotal')(Self); require('../methods/ticket/getTaxes')(Self); require('../methods/ticket/componentUpdate')(Self); - require('../methods/ticket/create')(Self); + require('../methods/ticket/new')(Self); require('../methods/ticket/isEditable')(Self); require('../methods/ticket/threeLastActive')(Self); require('../methods/ticket/deleted')(Self); require('../methods/ticket/getVAT')(Self); + require('../methods/ticket/getSales')(Self); require('../methods/ticket/getSalesPersonMana')(Self); }; diff --git a/services/loopback/common/models/vn-model.js b/services/loopback/common/models/vn-model.js index 5d1f4b7be..f1e19351d 100644 --- a/services/loopback/common/models/vn-model.js +++ b/services/loopback/common/models/vn-model.js @@ -1,3 +1,6 @@ + +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + module.exports = function(Self) { Self.setup = function() { Self.super_.setup.call(this); @@ -162,7 +165,89 @@ module.exports = function(Self) { }; }; - require('../methods/vn-model/rawSql')(Self); + Self.rawSql = function(query, params, cb) { + var connector = this.dataSource.connector; + return new Promise(function(resolve, reject) { + connector.execute(query, params, function(error, response) { + if (cb) + cb(error, response); + if (error) + reject(error); + else + resolve(response); + }); + }); + }; + + Self.rawStmt = function(stmt) { + return this.rawSql(stmt.sql, stmt.params); + }; + + Self.escapeName = function(name) { + return this.dataSource.connector.escapeName(name); + }; + + Self.buildWhere = function(filter, tableAlias) { + let connector = this.dataSource.connector; + let wrappedConnector = Object.create(connector); + wrappedConnector.columnEscaped = function(model, property) { + let sql = tableAlias + ? connector.escapeName(tableAlias) + '.' + : ''; + return sql + connector.columnEscaped(model, property); + }; + + return wrappedConnector.buildWhere(this.modelName, filter.where); + }; + + Self.buildLimit = function(filter) { + let sql = new ParameterizedSQL(''); + this.dataSource.connector.applyPagination(this.modelName, sql, filter); + return sql; + }; + + Self.buildOrderBy = function(filter) { + let order = filter.order; + + if (!order) + return ''; + if (typeof order === 'string') + order = [order]; + + let clauses = []; + + for (let clause of order) { + let sqlOrder = ''; + let t = clause.split(/[\s,]+/); + let names = t[0].split('.'); + + if (names.length > 1) + sqlOrder += this.escapeName(names[0]) + '.'; + sqlOrder += this.escapeName(names[names.length - 1]); + + if (t.length > 1) + sqlOrder += ' ' + (t[1].toUpperCase() == 'ASC' ? 'ASC' : 'DESC'); + + clauses.push(sqlOrder); + } + + return `ORDER BY ${clauses.join(', ')}`; + }; + + Self.buildPagination = function(filter) { + return ParameterizedSQL.join([ + this.buildOrderBy(filter), + this.buildLimit(filter) + ]); + }; + + Self.buildSuffix = function(filter, tableAlias) { + return ParameterizedSQL.join([ + this.buildWhere(filter, tableAlias), + this.buildPagination(filter) + ]); + }; + require('../methods/vn-model/installMethod')(Self); require('../methods/vn-model/validateBinded')(Self); }; diff --git a/services/loopback/server/connectors/vn-mysql.js b/services/loopback/server/connectors/vn-mysql.js new file mode 100644 index 000000000..27f200975 --- /dev/null +++ b/services/loopback/server/connectors/vn-mysql.js @@ -0,0 +1,55 @@ + +var mysql = require('mysql'); +var SqlConnector = require('loopback-connector').SqlConnector; +var MySQL = require('loopback-connector-mysql').MySQL; +var EnumFactory = require('loopback-connector-mysql').EnumFactory; + +exports.initialize = function(dataSource, callback) { + dataSource.driver = mysql; + dataSource.connector = new VnMySQL(dataSource.settings); + dataSource.connector.dataSource = dataSource; + + var modelBuilder = dataSource.modelBuilder; + var defineType = modelBuilder.defineValueType ? + modelBuilder.defineValueType.bind(modelBuilder) : + modelBuilder.constructor.registerType.bind(modelBuilder.constructor); + + defineType(function Point() {}); + + dataSource.EnumFactory = EnumFactory; + + if (callback) { + if (dataSource.settings.lazyConnect) { + process.nextTick(function() { + callback(); + }); + } else { + dataSource.connector.connect(callback); + } + } +}; + +exports.VnMySQL = VnMySQL; + +function VnMySQL(settings) { + SqlConnector.call(this, 'mysql', settings); +} + +VnMySQL.prototype = Object.create(MySQL.prototype); +VnMySQL.constructor = VnMySQL; + +VnMySQL.prototype.toColumnValue = function(prop, val) { + if (val == null || !prop || prop.type !== Date) + return MySQL.prototype.toColumnValue.call(this, prop, val); + + return val.getFullYear() + '-' + + fillZeros(val.getMonth() + 1) + '-' + + fillZeros(val.getDate()) + ' ' + + fillZeros(val.getHours()) + ':' + + fillZeros(val.getMinutes()) + ':' + + fillZeros(val.getSeconds()); + + function fillZeros(v) { + return v < 10 ? '0' + v : v; + } +}; diff --git a/services/loopback/server/datasources.json b/services/loopback/server/datasources.json index e1e46bf4f..1bc491c64 100644 --- a/services/loopback/server/datasources.json +++ b/services/loopback/server/datasources.json @@ -3,7 +3,8 @@ "connector": "memory" }, "vn": { - "connector": "mysql", + "connector": "vn-mysql", + "timezone": "CET", "database": "vn", "debug": false, "host": "${salixHost}", @@ -14,7 +15,8 @@ "acquireTimeout": 20000 }, "salix": { - "connector": "mysql", + "connector": "vn-mysql", + "timezone": "CET", "database": "salix", "debug": false, "host": "${salixHost}", @@ -25,7 +27,8 @@ "acquireTimeout": 20000 }, "account": { - "connector": "mysql", + "connector": "vn-mysql", + "timezone": "CET", "database": "account", "debug": false, "host": "${salixHost}", @@ -36,7 +39,8 @@ "acquireTimeout": 20000 }, "edi": { - "connector": "mysql", + "connector": "vn-mysql", + "timezone": "CET", "database": "edi", "debug": false, "host": "${salixHost}", @@ -47,7 +51,8 @@ "acquireTimeout": 20000 }, "bs": { - "connector": "mysql", + "connector": "vn-mysql", + "timezone": "CET", "database": "bs", "debug": false, "host": "${salixHost}", @@ -58,7 +63,8 @@ "acquireTimeout": 20000 }, "hedera": { - "connector": "mysql", + "connector": "vn-mysql", + "timezone": "CET", "database": "hedera", "debug": false, "host": "${salixHost}", diff --git a/services/loopback/server/server.js b/services/loopback/server/server.js index 012dd21b7..f8678de06 100644 --- a/services/loopback/server/server.js +++ b/services/loopback/server/server.js @@ -1,9 +1,24 @@ let loopback = require('loopback'); let boot = require('loopback-boot'); +let DataSource = require('loopback-datasource-juggler').DataSource; let fs = require('fs-extra'); let i18n = require('i18n'); let path = require('path'); +let _resolveConnector = DataSource._resolveConnector; + +DataSource._resolveConnector = function(name) { + let testPath = `${__dirname}/connectors/${name}.js`; + + if (fs.existsSync(testPath)) + return { + connector: require(testPath), + error: null + }; + + return _resolveConnector.apply(this, arguments); +}; + module.exports = { loopback: loopback, boot: vnBoot diff --git a/services/mailer/application/template/footer/locale/fr.json b/services/mailer/application/template/footer/locale/fr.json new file mode 100644 index 000000000..4953874ff --- /dev/null +++ b/services/mailer/application/template/footer/locale/fr.json @@ -0,0 +1,7 @@ +{ + "actionButton": "Visitez notre site web", + "infoButton": "Aidez-nous à améliorer", + "fiscalAddress": "VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla · www.verdnatura.es · clientes@verdnatura.es", + "privacy": "- AVISO - Este mensaje es privado y confidencial, y debe ser utilizado exclusivamente por la persona destinataria del mismo. Si usted ha recibido este mensaje por error, le rogamos lo comunique al remitente y borre dicho mensaje y cualquier documento adjunto que pudiera contener. Verdnatura Levante SL no renuncia a la confidencialidad ni a ningún privilegio por causa de transmisión errónea o mal funcionamiento. Igualmente no se hace responsable de los cambios, alteraciones, errores u omisiones que pudieran hacerse al mensaje una vez enviado.", + "privacyLaw": "En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de Datos de Carácter Personal, le comunicamos que los datos personales que facilite se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L., pudiendo en todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, comunicándolo por escrito al domicilio social de la entidad. La finalidad del fichero es la gestión administrativa, contabilidad, y facturación." +} \ No newline at end of file diff --git a/services/mailer/application/template/payment-update/locale/fr.json b/services/mailer/application/template/payment-update/locale/fr.json new file mode 100644 index 000000000..a3b76a73f --- /dev/null +++ b/services/mailer/application/template/payment-update/locale/fr.json @@ -0,0 +1,13 @@ +{ + "subject": "Changement des C.G.V", + "title": "Changement des C.G.V", + "dear": "Chèr client,", + "bodyDescription": "Nous vous informons que les conditions de paiement ont changé. Voici les nouvelles conditions:", + "paymentMethod": "Méthode de paiement:", + "paymentDay": "Date paiement:", + "everyMonth": "de chaque mois", + "cardPaymentAdvice": "Su modo de pago actual implica que deberá abonar el importe de los pedidos realizados en el mismo día para que se puedan enviar.", + "accountPaymentAdviceBefore": "Su modo de pago actual implica que se le pasará un cargo a la cuenta", + "accountPaymentAdviceAfter": "por el importe pendiente, al vencimiento establecido en las condiciones.", + "notifyError": "Pour tout renseignement contactez votre commercial.." +} \ No newline at end of file diff --git a/services/mailer/application/template/payment-update/payment-update.js b/services/mailer/application/template/payment-update/payment-update.js index 565fd8a74..9d75f20b3 100644 --- a/services/mailer/application/template/payment-update/payment-update.js +++ b/services/mailer/application/template/payment-update/payment-update.js @@ -28,16 +28,16 @@ module.exports = class PaymentUpdate { } get paymentDay() { - if (this.payMethodFk != 5) + if (this.payMethodFk != 5) return `
${this._.paymentDay} ${this.dueDay} ${this._.everyMonth}
`; } get paymentAdvice() { switch (this.payMethodFk) { - case 4: - return `${this._.accountPaymentAdviceBefore} ${format.partialAccountAddress(this.iban)} ${this._.accountPaymentAdviceAfter}`; - case 5: - return this._.cardPaymentAdvice; + case 4: + return `${this._.accountPaymentAdviceBefore} ${format.partialAccountAddress(this.iban)} ${this._.accountPaymentAdviceAfter}`; + case 5: + return this._.cardPaymentAdvice; } } }; diff --git a/services/mailer/application/util/format.js b/services/mailer/application/util/format.js index 681fea72d..52e997a72 100644 --- a/services/mailer/application/util/format.js +++ b/services/mailer/application/util/format.js @@ -19,6 +19,7 @@ module.exports = { * @return {String} Cuenta bancaria formateada */ accountAddress: function(addressNumber) { + if (!addressNumber) return; var formattedAccountAddress = addressNumber.replace(/(.{4})/g, '$1-'); return formattedAccountAddress.substring(0, formattedAccountAddress.length - 1); }, @@ -29,6 +30,7 @@ module.exports = { * @return {String} Cuenta bancaria formateada */ partialAccountAddress: function(addressNumber) { + if (!addressNumber) return; let address = this.accountAddress(addressNumber); return address.substring(0, 19).replace(/[0-9]/g, 'X') + address.substring(19, 24); }, diff --git a/services/order/common/methods/new.js b/services/order/common/methods/new.js new file mode 100644 index 000000000..02154e337 --- /dev/null +++ b/services/order/common/methods/new.js @@ -0,0 +1,51 @@ +module.exports = Self => { + Self.remoteMethod('new', { + description: 'Create a new order and returns the new ID', + accessType: 'WRITE', + accepts: [{ + arg: 'params', + type: 'object', + http: {source: 'body'} + }], + returns: { + type: 'number', + root: true + }, + http: { + path: `/new`, + verb: 'post' + } + }); + + Self.new = async params => { + let cli = await Self.app.models.Address.findOne({where: {id: params.addressFk}, fields: 'clientFk'}); + + let client = await Self.app.models.Client.findOne({ + where: {id: cli.clientFk}, + fields: ['isTaxDataChecked', 'isFreezed', 'isActive'] + }); + + if (client.isFreezed) + throw new Error(`You can't create an order for a frozen client`); + + if (!client.isActive) + throw new Error(`You can't create an order for a inactive client`); + + if (!client.isTaxDataChecked) + throw new Error(`You can't create an order for a client that doesn't has tax data verified`); + + let query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`; + let clientDebt = await Self.rawSql(query, [cli.clientFk]); + if (clientDebt[0].debt > 0) + throw new Error(`You can't create an order for a client that has a debt`); + + query = `CALL vn.orderListCreate(?, ?, ?, ?);`; + result = await Self.rawSql(query, [ + params.landed, + params.agencyModeFk, + params.addressFk, + "SALIX" + ]); + return result[0].vOrderId; + }; +}; diff --git a/services/order/common/models/order.js b/services/order/common/models/order.js new file mode 100644 index 000000000..966d2750f --- /dev/null +++ b/services/order/common/models/order.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/new')(Self); +}; diff --git a/services/ticket/common/methods/sale-tracking/listSaleTracking.js b/services/ticket/common/methods/sale-tracking/listSaleTracking.js new file mode 100644 index 000000000..e45249ec6 --- /dev/null +++ b/services/ticket/common/methods/sale-tracking/listSaleTracking.js @@ -0,0 +1,94 @@ +module.exports = Self => { + Self.remoteMethod('listSaleTracking', { + description: 'Returns all ticket sale trackings', + accessType: 'READ', + accepts: [{ + arg: 'filter', + type: 'Object', + required: false, + description: 'Filter defining where and paginated data', + http: {source: 'query'} + }], + returns: { + type: ["Object"], + root: true + }, + http: { + path: `/listSaleTracking`, + verb: 'get' + } + }); + + Self.listSaleTracking = async filter => { + let where = ''; + let limit = ''; + let order = ''; + let params; + + if (filter) { + let connector = Self.dataSource.connector; + if (filter.where) { + where = 'WHERE s.ticketFk = ?'; + params = [filter.where.ticketFk]; + } + + limit = connector._buildLimit(null, filter.limit, filter.skip); + order = connector.buildOrderBy('Item', filter.order); + } + + let query = `SELECT + st.id, + s.quantity, + s.concept, + s.itemFk, + st.originalQuantity, + st.created, + st.workerFk, + w.firstName, + w.name, + ste.name AS state + FROM saleTracking st + JOIN sale s ON s.id = st.saleFK + JOIN worker w ON w.id = st.workerFk + JOIN ticketState ts ON ts.ticketFk = s.ticketFk + JOIN state ste ON ste.id = ts.stateFK ${where} ${order} ${limit}`; + + let trackings = await Self.rawSql(query, params); + + let salesFilter = { + include: [ + { + relation: 'item', + scope: { + fields: ['itemFk', 'name'], + include: { + relation: 'tags', + scope: { + fields: ['tagFk', 'value'], + include: { + relation: 'tag', + scope: { + fields: ['name'] + } + }, + limit: 6 + } + } + } + } + ], + where: {ticketFk: filter.where.ticketFk} + }; + + let sales = await Self.app.models.Sale.find(salesFilter); + + trackings.forEach(tracking => { + sales.forEach(sale => { + if (tracking.itemFk == sale.itemFk) + tracking.item = sale.item(); + }); + }); + + return trackings; + }; +}; diff --git a/services/ticket/common/methods/sale-tracking/specs/listSaleTracking.spec.js b/services/ticket/common/methods/sale-tracking/specs/listSaleTracking.spec.js new file mode 100644 index 000000000..80ba86147 --- /dev/null +++ b/services/ticket/common/methods/sale-tracking/specs/listSaleTracking.spec.js @@ -0,0 +1,22 @@ +const app = require(`${servicesDir}/ticket/server/server`); + +describe('ticket listSaleTracking()', () => { + it('should call the listSaleTracking method and return the response', done => { + let filter = {where: {ticketFk: 1}}; + app.models.SaleTracking.listSaleTracking(filter) + .then(response => { + expect(response[0].concept).toEqual('Gem of Time'); + done(); + }); + }); + + it(`should call the listSaleTracking method and return zero if doesn't have lines`, done => { + let filter = {where: {ticketFk: 2}}; + app.models.SaleTracking.listSaleTracking(filter) + .then(response => { + expect(response.length).toEqual(0); + done(); + }); + }); +}); + diff --git a/services/ticket/common/models/sale-tracking.js b/services/ticket/common/models/sale-tracking.js new file mode 100644 index 000000000..4a46dd6b7 --- /dev/null +++ b/services/ticket/common/models/sale-tracking.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/sale-tracking/listSaleTracking')(Self); +}; diff --git a/services_tests.js b/services_tests.js index 3ab2ed8ec..c891bab91 100644 --- a/services_tests.js +++ b/services_tests.js @@ -24,6 +24,7 @@ jasmine.loadConfig({ 'auth/server/**/*[sS]pec.js', 'client/common/**/*[sS]pec.js', 'item/common/**/*[sS]pec.js', + 'ticket/common/**/*[sS]pec.js', 'loopback/common/**/*[sS]pec.js' ], helpers: [