diff --git a/client/client/src/address/edit/index.html b/client/client/src/address/edit/index.html index 9ccdd5fb2..40a932dc4 100644 --- a/client/client/src/address/edit/index.html +++ b/client/client/src/address/edit/index.html @@ -75,20 +75,20 @@ - - + - - + ng-click="$ctrl.removeObservation($index)" + tabindex="-1"> + + Addresses + ng-class="{'bg-main': address.isDefaultAddress,'bg-opacity-item': !address.isActive && !address.isDefaultAddress}"> Contract credit insurance - + - + + +
- - - - - + + + - + + ng-repeat="client in clients track by client.id" + client="::client"> - - + +
@@ -30,4 +35,4 @@ - + \ No newline at end of file diff --git a/client/client/src/index/index.js b/client/client/src/index/index.js index 57a109c03..175ddb7d2 100644 --- a/client/client/src/index/index.js +++ b/client/client/src/index/index.js @@ -2,23 +2,42 @@ import ngModule from '../module'; import './item-client'; export default class Controller { - constructor($scope) { - this.$scope = $scope; + this.$ = $scope; this.clientSelected = null; } - search(index) { - index.accept(); - /* this.clients = []; - index.accept().then(res => { - this.clients = res.instances; - }); */ + exprBuilder(param, value) { + switch (param) { + case 'search': + return { + or: [ + {id: value}, + {name: {regexp: value}} + ] + }; + case 'phone': + return { + or: [ + {phone: value}, + {mobile: value} + ] + }; + case 'name': + case 'socialName': + case 'city': + return {[param]: {regexp: value}}; + case 'id': + case 'fi': + case 'postcode': + case 'email': + return {[param]: value}; + } } openSummary(client) { this.clientSelected = client; - this.$scope.dialogSummaryClient.show(); + this.$.dialogSummaryClient.show(); } } Controller.$inject = ['$scope']; diff --git a/client/client/src/index/locale/es.yml b/client/client/src/index/locale/es.yml index c221de7f6..97ad69ac3 100644 --- a/client/client/src/index/locale/es.yml +++ b/client/client/src/index/locale/es.yml @@ -2,4 +2,5 @@ Client id: Id cliente Phone: Teléfono Town/City: Ciudad Email: Correo electrónico -Create client: Crear cliente \ No newline at end of file +Create client: Crear cliente +View client: Ver cliente \ No newline at end of file diff --git a/client/client/src/search-panel/index.html b/client/client/src/search-panel/index.html index 2cb6a5aeb..de772afe3 100644 --- a/client/client/src/search-panel/index.html +++ b/client/client/src/search-panel/index.html @@ -1,22 +1,22 @@
- - + + - + - + - - + + - - + + diff --git a/client/client/src/search-panel/index.js b/client/client/src/search-panel/index.js index 5033dcb65..2ed83601a 100644 --- a/client/client/src/search-panel/index.js +++ b/client/client/src/search-panel/index.js @@ -1,18 +1,7 @@ import ngModule from '../module'; - -export default class Controller { - constructor() { - // onSubmit() is defined by @vnSearchbar - this.onSubmit = () => {}; - } - - onSearch() { - this.onSubmit(this.filter); - } -} -Controller.$inject = []; +import SearchPanel from 'core/src/components/searchbar/search-panel'; ngModule.component('vnClientSearchPanel', { template: require('./index.html'), - controller: Controller + controller: SearchPanel }); diff --git a/client/core/src/components/grid-header/style.scss b/client/core/src/components/grid-header/style.scss index 2018b192f..9e8fccfab 100644 --- a/client/core/src/components/grid-header/style.scss +++ b/client/core/src/components/grid-header/style.scss @@ -1,7 +1,7 @@ @import "colors"; vn-grid-header { - border-bottom: 3px solid $main-header; + border-bottom: 3px solid $lines; font-weight: bold; .orderly{ text-align: center; diff --git a/client/core/src/components/grid/style.scss b/client/core/src/components/grid/style.scss index 88275ff61..e2002a894 100644 --- a/client/core/src/components/grid/style.scss +++ b/client/core/src/components/grid/style.scss @@ -19,10 +19,10 @@ } } & > thead, & > tbody { - border-bottom: 3px solid $main-header; + border-bottom: 3px solid $lines; } & > tbody > tr { - border-bottom: 1px solid $main-header; + border-bottom: 1px solid $lines; transition: background-color 200ms ease-in-out; &.clickable { diff --git a/client/core/src/components/icon-button/icon-button.js b/client/core/src/components/icon-button/icon-button.js index 2da16cf1e..eb0e3dd49 100644 --- a/client/core/src/components/icon-button/icon-button.js +++ b/client/core/src/components/icon-button/icon-button.js @@ -3,7 +3,8 @@ import './style.scss'; export default class IconButton { constructor($element) { - $element[0].tabIndex = 0; + if ($element[0].getAttribute('tabindex') == null) + $element[0].tabIndex = 0; $element.on("keyup", event => this.onKeyDown(event, $element)); } diff --git a/client/core/src/components/icon-button/style.scss b/client/core/src/components/icon-button/style.scss index e748a4ba4..bd1f3f142 100644 --- a/client/core/src/components/icon-button/style.scss +++ b/client/core/src/components/icon-button/style.scss @@ -2,32 +2,16 @@ vn-icon-button { display: inline-block; - text-align: center; color: rgba($main-01, 0.7); + font-size: 18pt; transition: color 200ms ease-in-out; cursor: pointer; - &.button { - background-color: $main-01; - color: white; - width: 64px; - height: 36px; - box-shadow: rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.2) 0px 3px 1px -2px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px; - border-radius: 2px; - } - &.button:focus { - will-change: box-shadow; - box-shadow: 0 0 8px rgba(0,0,0,.18),0 8px 16px rgba(0,0,0,.36); - transition: box-shadow .2s cubic-bezier(.4,0,1,1),background-color .2s cubic-bezier(.4,0,.2,1),color .2s cubic-bezier(.4,0,.2,1); - } - &.button i { - margin-top: 6px; - } - & > i, - & > i.material-icons { + & > vn-icon { display: block; font-size: inherit; color: inherit; + margin: 0 auto; } &:not(.button):hover { color: $main-01; diff --git a/client/core/src/components/index.js b/client/core/src/components/index.js index fb18d0eaa..84ced2ea1 100644 --- a/client/core/src/components/index.js +++ b/client/core/src/components/index.js @@ -3,7 +3,6 @@ import './rest-model/crud-model'; import './rest-model/rest-model'; import './watcher/watcher'; import './textfield/textfield'; -import './paging/paging'; import './icon/icon'; import './dialog/dialog'; import './confirm/confirm'; @@ -34,4 +33,7 @@ import './switch/switch'; import './float-button/float-button'; import './step-control/step-control'; import './label-value/label-value'; +import './paging/paging'; import './auto-paging/auto-paging'; +import './pagination/pagination'; +import './searchbar/searchbar'; diff --git a/client/core/src/components/label-value/label-value.js b/client/core/src/components/label-value/label-value.js index 09a6b28d6..60fcb4548 100644 --- a/client/core/src/components/label-value/label-value.js +++ b/client/core/src/components/label-value/label-value.js @@ -2,7 +2,7 @@ import ngModule from '../../module'; import './style.scss'; ngModule.component('vnLabelValue', { - template: require('../label-value/label-value.html'), + template: require('./label-value.html'), replace: true, transclude: true, bindings: { diff --git a/client/core/src/components/model-proxy/model-proxy.js b/client/core/src/components/model-proxy/model-proxy.js index ab010d651..d0fdff939 100644 --- a/client/core/src/components/model-proxy/model-proxy.js +++ b/client/core/src/components/model-proxy/model-proxy.js @@ -12,13 +12,17 @@ export default class ModelProxy { set orgData(value) { this._orgData = value; - this._data = []; // this._data.splice(0, this._data.length); - for (let i = 0; i < value.length; i++) { - let row = new this.Row(value[i], i); - this._data.push(row); - } + if (this.Row) { + this._data = []; + + for (let i = 0; i < value.length; i++) { + let row = new this.Row(value[i], i); + this._data.push(row); + } + } else + this._data = value; this.resetChanges(); } @@ -112,6 +116,11 @@ export default class ModelProxy { this.resetChanges(); } + + dataChanged() { + if (this.onDataChange) + this.onDataChange(); + } } ngModule.component('vnModelProxy', { @@ -120,6 +129,7 @@ ngModule.component('vnModelProxy', { orgData: ' + + + + +
\ No newline at end of file diff --git a/client/core/src/components/pagination/pagination.js b/client/core/src/components/pagination/pagination.js new file mode 100644 index 000000000..604e37b01 --- /dev/null +++ b/client/core/src/components/pagination/pagination.js @@ -0,0 +1,75 @@ +import ngModule from '../../module'; +import Component from '../../lib/component'; +import './style.scss'; + +/** + * Pagination component that automatically loads more rows when + * the user scrolls down an element. + * + * @property {CrudModel} model The model used for pagination + * @property {String} scrollSelector The the scrollable element selector + * @property {HTMLElement} scrollElement The scrollable element + * @property {Number} scrollOffset The distance, in pixels, until the end that activates the loading of the next rows + */ +class Pagination extends Component { + constructor($element, $scope) { + super($element, $scope); + this.scrollOffset = 20; + this.scrollHandler = e => this.onScroll(e); + } + + $onInit() { + if (!this._scrollElement) + this.scrollElement = document.body; + } + + set scrollSelector(value) { + this._scrollSelector = value; + this.scrollElement = document.querySelector(value); + } + + get scrollSelector() { + return this._scrollSelector; + } + + set scrollElement(value) { + if (this._scrollElement) + this._scrollElement.removeEventListener('scroll', this.scrollHandler); + + this._scrollElement = value; + + if (value) + this._scrollElement.addEventListener('scroll', this.scrollHandler); + } + + get scrollElement() { + return this._scrollElement; + } + + onScroll() { + let scrollElement = this.scrollElement; + let shouldLoad = + scrollElement.scrollTop + scrollElement.clientHeight >= (scrollElement.scrollHeight - this.scrollOffset) + && !this.model.isLoading; + + if (shouldLoad) { + this.model.loadMore(); + this.$.$apply(); + } + } + + $onDestroy() { + this.scrollElement = null; + } +} + +ngModule.component('vnPagination', { + template: require('./pagination.html'), + bindings: { + model: '<', + scrollSelector: '@?', + scrollElement: ' div > vn-icon-button { + font-size: 2em; + } +} \ 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 3133257d0..3bdac37c8 100644 --- a/client/core/src/components/rest-model/crud-model.js +++ b/client/core/src/components/rest-model/crud-model.js @@ -10,32 +10,80 @@ export default class CrudModel extends ModelProxy { this.autoLoad = true; } + get isLoading() { + return this.canceler != null; + } + $onInit() { if (this.autoLoad) this.refresh(); } - refresh() { + refresh(usFilter, usData) { if (!this.url) return; + let myFilter = { + fields: this.fields, + where: mergeWhere(this.link, this.where), + include: this.include, + order: this.order, + limit: this.limit, + userData: this.userData + }; + let filter = this.filter; + filter = mergeFilters(myFilter, filter); + filter = mergeFilters(usFilter, filter); + return this.sendRequest(filter); + } - if (!filter) { - let where = Object.assign({}, this.link, this.where); - filter = { - fields: this.fields, - where: where, - include: this.include, - order: this.order, - limit: this.limit - }; + cancelRequest() { + if (this.canceler) { + this.canceler.resolve(); + this.canceler = null; } + } - let urlFilter = encodeURIComponent(JSON.stringify(filter)); + 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( + json => this.onRemoteDone(json, filter, append), + json => this.onRemoteError(json) + ); + } - return this.$http.get(`${this.url}?filter=${urlFilter}`).then(res => { - this.orgData = res.data; - }); + onRemoteDone(json, filter, append) { + let data = json.data; + + if (append) + this.orgData = this.orgData.concat(data); + else + this.orgData = data; + + this.currentFilter = filter; + this.moreRows = filter.limit && data.length == filter.limit; + this.onRequestEnd(); + this.dataChanged(); + } + + onRemoteError(err) { + this.onRequestEnd(); + throw err; + } + + onRequestEnd() { + this.canceler = null; + } + + loadMore() { + if (this.moreRows) { + let filter = Object.assign({}, this.currentFilter); + filter.skip = (filter.skip || 0) + filter.limit; + this.sendRequest(filter, true); + } } getChanges() { @@ -97,7 +145,87 @@ ngModule.component('vnCrudModel', { order: '@?', limit: ' 1 ? {and} : and[0]; +} + +/** + * Merges two loopback filters returning the merged filter. + * + * @param {Object} src The source filter + * @param {Object} dst The destination filter + * @return {Object} The result filter + */ +function mergeFilters(src, dst) { + let res = Object.assign({}, dst); + + if (!src) + return res; + + if (src.fields) + res.fields = mergeFields(src.fields, res.fields); + if (src.where) + res.where = mergeWhere(res.where, src.where); + if (src.include) + res.include = src.include; + if (src.order) + res.order = src.order; + if (src.limit) + res.limit = src.limit; + if (src.userData) + res.userData = src.userData; + + return res; +} diff --git a/client/core/src/components/searchbar/search-panel.js b/client/core/src/components/searchbar/search-panel.js new file mode 100644 index 000000000..96dc67ed5 --- /dev/null +++ b/client/core/src/components/searchbar/search-panel.js @@ -0,0 +1,18 @@ +import Component from '../../lib/component'; + +export default class extends Component { + set filter(value) { + this.$.filter = value; + } + + get filter() { + return this.$.filter; + } + + onSearch() { + if (!this.onSubmit) + throw new Error('SearchPanel::onSubmit() method not defined'); + + this.onSubmit(this.filter); + } +} diff --git a/client/salix/src/components/searchbar/searchbar.html b/client/core/src/components/searchbar/searchbar.html similarity index 73% rename from client/salix/src/components/searchbar/searchbar.html rename to client/core/src/components/searchbar/searchbar.html index 72d5dad90..9bc053f1b 100644 --- a/client/salix/src/components/searchbar/searchbar.html +++ b/client/core/src/components/searchbar/searchbar.html @@ -5,11 +5,11 @@ ng-click="$ctrl.clearFilter(); $ctrl.onSubmit()" style="cursor: pointer; padding-top: 23px">
- + diff --git a/client/core/src/components/searchbar/searchbar.js b/client/core/src/components/searchbar/searchbar.js new file mode 100644 index 000000000..8db621933 --- /dev/null +++ b/client/core/src/components/searchbar/searchbar.js @@ -0,0 +1,200 @@ +import ngModule from '../../module'; +import Component from '../../lib/component'; +import './style.scss'; + +/** + * An input specialized to perform searches, it allows to use a panel + * for advanced searches when the panel property is defined. + * When model and exprBuilder properties are used, the model is updated + * automatically with an and-filter exprexion in which each operand is built + * by calling the exprBuilder function for each non-null parameter. + * + * @property {Object} filter A key-value object with filter parameters + * @property {Function} onSearch Function to call when search is submited + * @property {SearchPanel} panel The panel used for advanced searches + * @property {CrudModel} model The model used for searching + * @property {Function} exprBuilder If defined, is used to build each non-null param expresion + */ +export default class Controller extends Component { + constructor($element, $scope, $compile, $state, $transitions) { + super($element, $scope); + this.$compile = $compile; + this.$state = $state; + this.deregisterCallback = $transitions.onStart({}, + transition => this.changeState(transition)); + + this.filter = {}; + this.searchString = ''; + } + + $onInit() { + if (this.$state.params.q) + this.filter = JSON.parse(decodeURIComponent(this.$state.params.q)); + + this.refreshString(); + this.doSearch(); + } + + changeState(transition) { + return transition._targetState._identifier.name !== this.$state.current.name; + } + + openPanel(event) { + if (event.defaultPrevented) return; + event.preventDefault(); + + this.$panel = this.$compile(`<${this.panel}/>`)(this.$.$new()); + let panel = this.$panel.isolateScope().$ctrl; + panel.filter = this.filter; + panel.onSubmit = filter => this.onPanelSubmit(filter); + + this.$.popover.parent = this.element; + this.$.popover.child = this.$panel[0]; + this.$.popover.show(); + } + + onPopoverClose() { + this.$panel.scope().$destroy(); + this.$panel.remove(); + this.$panel = null; + } + + onPanelSubmit(filter) { + this.$.popover.hide(); + + for (let param in filter) + if (filter[param] == null) + delete filter[param]; + + this.filter = filter; + this.refreshString(); + this.doSearch(); + } + + refreshString() { + this.searchString = this.getStringFromObject(this.filter); + } + + onSubmit() { + this.filter = this.getObjectFromString(this.searchString); + this.doSearch(); + } + + doSearch() { + this.pushFilterToState(this.filter); + + if (this.onSearch) + this.onSearch({filter: this.filter}); + + if (this.model) { + if (!this.exprBuilder) + throw new Error('exprBuilder property should be defined when model is assigned'); + + let and = []; + + for (let param in this.filter) { + let value = this.filter[param]; + if (value == null) continue; + let expr = this.exprBuilder({param, value}); + if (expr) and.push(expr); + } + + let lbFilter = and.length > 0 ? {where: {and}} : null; + this.model.refresh(lbFilter); + } + } + + pushFilterToState(filter) { + let history = window.history || {pushState: () => { + 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]); + } + + /** + * Finds pattern key:value or key:(extra value) and passes it to object. + * + * @param {String} searchString The search string + * @return {Object} The parsed object + */ + getObjectFromString(searchString) { + let result = {}; + if (searchString) { + let regex = /((([\w_]+):([\w_]+))|([\w_]+):\(([\w_ ]+)\))/gi; + let findPattern = searchString.match(regex); + let remnantString = searchString.replace(regex, '').trim(); + if (findPattern) { + for (let i = 0; i < findPattern.length; i++) { + let aux = findPattern[i].split(':'); + let property = aux[0]; + let value = aux[1].replace(/\(|\)/g, ''); + result[property] = value.trim(); + } + } + if (remnantString) + result.search = remnantString; + } + return result; + } + + /** + * Passes an object to pattern key:value or key:(extra value). + * + * @param {Object} searchObject The search object + * @return {String} The passed string + */ + getStringFromObject(searchObject) { + let search = []; + + if (searchObject) { + let keys = Object.keys(searchObject); + keys.forEach(key => { + if (key == 'search') return; + + let value = searchObject[key]; + let valueString; + + if (typeof value === 'string' && value.indexOf(' ') !== -1) + valueString = `(${value})`; + else if (value instanceof Date) + valueString = value.toJSON(); + else + switch (typeof value) { + case 'number': + case 'string': + case 'boolean': + valueString = `${value}`; + } + + if (valueString) + search.push(`${key}:${valueString}`); + }); + + if (searchObject.search) + search.unshift(searchObject.search); + } + + return search.length ? search.join(' ') : ''; + } + + $onDestroy() { + this.deregisterCallback(); + } +} +Controller.$inject = ['$element', '$scope', '$compile', '$state', '$transitions']; + +ngModule.component('vnSearchbar', { + template: require('./searchbar.html'), + bindings: { + filter: ' form > vn-horizontal > vn-icon-button { color: black; diff --git a/client/core/src/locale/en.yml b/client/core/src/locale/en.yml index 3a06f2bd0..613eda985 100644 --- a/client/core/src/locale/en.yml +++ b/client/core/src/locale/en.yml @@ -11,4 +11,5 @@ Hide: Hide Next: Next Finalize: Finalize Previous: Back +Load more: Load more Auto-scroll interrupted, please adjust the search: Auto-scroll interrupted, please adjust the search \ No newline at end of file diff --git a/client/core/src/locale/es.yml b/client/core/src/locale/es.yml index 4e826330b..47a10ab21 100644 --- a/client/core/src/locale/es.yml +++ b/client/core/src/locale/es.yml @@ -11,4 +11,5 @@ Hide: Ocultar Next: Siguiente Finalize: Finalizar Previous: Anterior +Load more: Cargar más Auto-scroll interrupted, please adjust the search: Auto-scroll interrumpido, por favor ajusta la búsqueda \ No newline at end of file diff --git a/client/core/src/styles/fontello-icons.css b/client/core/src/styles/fontello-codes.css similarity index 90% rename from client/core/src/styles/fontello-icons.css rename to client/core/src/styles/fontello-codes.css index 6f448acf0..d90a5615a 100644 --- a/client/core/src/styles/fontello-icons.css +++ b/client/core/src/styles/fontello-codes.css @@ -20,5 +20,5 @@ .icon-ticket:before { content: '\e821'; } /* '' */ .icon-tax:before { content: '\e822'; } /* '' */ .icon-no036:before { content: '\e823'; } /* '' */ -.icon-mana:before { content: '\e824'; } /* '' */ +.icon-transaction:before { content: '\e826'; } /* '' */ .icon-solunion:before { content: '\e827'; } /* '' */ \ No newline at end of file diff --git a/client/core/src/styles/fontello.woff2 b/client/core/src/styles/fontello.woff2 index 8424baf8a..50b83f934 100644 Binary files a/client/core/src/styles/fontello.woff2 and b/client/core/src/styles/fontello.woff2 differ diff --git a/client/core/src/styles/index.js b/client/core/src/styles/index.js index fea272aed..f5ed1e400 100644 --- a/client/core/src/styles/index.js +++ b/client/core/src/styles/index.js @@ -2,4 +2,4 @@ import './mdl-override.scss'; import './mdi-override.css'; import './zoom-image.scss'; import './fontello-head.css'; -import './fontello-icons.css'; +import './fontello-codes.css'; diff --git a/client/item/routes.json b/client/item/routes.json index 9a3d35176..9d0dd3dd6 100644 --- a/client/item/routes.json +++ b/client/item/routes.json @@ -109,6 +109,18 @@ "params": { "item": "$ctrl.item" } + }, { + "url" : "/diary", + "state": "item.card.diary", + "component": "vn-item-diary", + "params": { + "item": "$ctrl.item" + }, + "menu": { + "description": "Diary", + "icon": "icon-transaction" + }, + "acl": ["employee"] } ] } \ No newline at end of file diff --git a/client/item/src/descriptor/index.html b/client/item/src/descriptor/index.html index 67a8bca44..140798989 100644 --- a/client/item/src/descriptor/index.html +++ b/client/item/src/descriptor/index.html @@ -25,8 +25,8 @@
{{$ctrl.item.id}}
- + value="{{$ctrl.item.name}}"> + diff --git a/client/item/src/diary/index.html b/client/item/src/diary/index.html new file mode 100644 index 000000000..321082d40 --- /dev/null +++ b/client/item/src/diary/index.html @@ -0,0 +1,49 @@ + + + + Item diary + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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
+
+
+ + +
diff --git a/client/item/src/diary/index.js b/client/item/src/diary/index.js new file mode 100644 index 000000000..67c6bcd34 --- /dev/null +++ b/client/item/src/diary/index.js @@ -0,0 +1,38 @@ +import ngModule from '../module'; +import './style.scss'; + +class Controller { + constructor($scope, $http) { + this.$ = $scope; + this.$http = $http; + this.diary = []; + } + + set warehouseFk(value) { + this._getItemDiary(value); + this._warehouseFk = value; + } + + get warehouseFk() { + return this._warehouseFk; + } + + _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; + }); + } +} + +Controller.$inject = ['$scope', '$http']; + +ngModule.component('vnItemDiary', { + template: require('./index.html'), + controller: Controller, + bindings: { + item: '<' + } +}); diff --git a/client/item/src/diary/index.spec.js b/client/item/src/diary/index.spec.js new file mode 100644 index 000000000..6cad8fc81 --- /dev/null +++ b/client/item/src/diary/index.spec.js @@ -0,0 +1,43 @@ +import './index.js'; + +describe('Item', () => { + describe('Component vnItemDiary', () => { + let $componentController; + let $scope; + let controller; + let $httpBackend; + + 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('vnItemDiary', {$scope: $scope}); + controller.item = {id: 3}; + })); + + describe('set warehouseFk()', () => { + it(`should call _getItemDiary() with 2 and set warehouseFk`, () => { + spyOn(controller, '_getItemDiary'); + controller.warehouseFk = 2; + + expect(controller._getItemDiary).toHaveBeenCalledWith(2); + expect(controller.warehouseFk).toEqual(2); + }); + }); + + 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(); + }); + }); + }); +}); + diff --git a/client/item/src/diary/style.scss b/client/item/src/diary/style.scss new file mode 100644 index 000000000..9e16a6d09 --- /dev/null +++ b/client/item/src/diary/style.scss @@ -0,0 +1,8 @@ +vn-item-diary { + & vn-horizontal { + justify-content: center; + } + & vn-autocomplete > div{ + width: 400px; + } +} \ No newline at end of file diff --git a/client/item/src/filter-panel/index.html b/client/item/src/filter-panel/index.html deleted file mode 100644 index 5dd64bb28..000000000 --- a/client/item/src/filter-panel/index.html +++ /dev/null @@ -1,77 +0,0 @@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/client/item/src/filter-panel/index.js b/client/item/src/filter-panel/index.js deleted file mode 100644 index 695a4710f..000000000 --- a/client/item/src/filter-panel/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import ngModule from '../module'; - -class Controller { - constructor() { - this.onSubmit = () => {}; - } - - onSearch() { - this.onSubmit(this.filter); - } -} - -ngModule.component('vnItemFilterPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/client/item/src/index/index.html b/client/item/src/index/index.html index 0879b5627..a0b0f5101 100644 --- a/client/item/src/index/index.html +++ b/client/item/src/index/index.html @@ -1,26 +1,30 @@ - + +
- - - - - + + + - + + ng-repeat="item in items track by item.id" + item="::item"> - - + +
diff --git a/client/item/src/index/index.js b/client/item/src/index/index.js index 8ddc7ada4..d772e810c 100644 --- a/client/item/src/index/index.js +++ b/client/item/src/index/index.js @@ -3,46 +3,68 @@ import './product'; import './style.scss'; class Controller { - constructor($http, $state, $scope) { this.$http = $http; this.$state = $state; - this.$scope = $scope; - this.model = {}; + this.$ = $scope; this.itemSelected = null; - this.items = []; + + this.filter = { + include: [ + {relation: 'itemType', + scope: { + fields: ['name', 'workerFk'], + include: { + relation: 'worker', + fields: ['firstName', 'name'] + } + } + } + ], + order: 'name ASC' + }; } - search(index) { - index.accept(); - /* this.items = []; - index.accept().then(res => { - this.items = res.instances; - }); */ + exprBuilder(param, value) { + switch (param) { + case 'search': + return { + or: [ + {id: value}, + {name: {regexp: value}} + ] + }; + case 'name': + case 'description': + return {[param]: {regexp: value}}; + case 'id': + case 'typeFk': + return {[param]: value}; + } } cloneItem(item) { this.itemSelected = item; - this.$scope.clone.show(); + this.$.clone.show(); } onCloneAccept(response) { - if (response == 'ACCEPT' && this.itemSelected) { - this.$http.post(`/item/api/Items/${this.itemSelected.id}/clone`).then(res => { - if (res && res.data && res.data.id) { - this.$state.go('item.card.tags', {id: res.data.id}); - } - }); - } + if (!(response == 'ACCEPT' && this.itemSelected)) + return; + + this.$http.post(`/item/api/Items/${this.itemSelected.id}/clone`).then(res => { + if (res && res.data && res.data.id) + this.$state.go('item.card.tags', {id: res.data.id}); + }); + this.itemSelected = null; } - + showItemPreview(item) { this.itemSelected = item; - this.$scope.preview.show(); + this.$.preview.show(); } } - Controller.$inject = ['$http', '$state', '$scope']; ngModule.component('vnItemIndex', { diff --git a/client/item/src/index/style.scss b/client/item/src/index/style.scss index 86f7f3ea1..9c6e97761 100644 --- a/client/item/src/index/style.scss +++ b/client/item/src/index/style.scss @@ -1,3 +1,4 @@ +@import "./colors"; vn-item-product { display: block; @@ -12,4 +13,4 @@ vn-item-product { border-radius: .2em; } } -} \ No newline at end of file +} diff --git a/client/item/src/item.js b/client/item/src/item.js index 384e91661..fd896c724 100644 --- a/client/item/src/item.js +++ b/client/item/src/item.js @@ -2,7 +2,8 @@ export * from './module'; import './index'; import './filter-item-list'; -import './filter-panel'; +import './search-panel'; +import './diary'; import './create'; import './card'; import './descriptor'; diff --git a/client/item/src/locale/es.yml b/client/item/src/locale/es.yml index b6a3eca94..424300b3b 100644 --- a/client/item/src/locale/es.yml +++ b/client/item/src/locale/es.yml @@ -29,10 +29,16 @@ Value: Valor Priority: Prioridad Item tax: Tasas del artículo Country: País +Select warehouse: Selecione almacén Class: Clase Item niches: Nichos del artículo +Item diary: Registro de compra-venta +Diary: Registro Warehouse: Almacén Code: Código +State: Estado +In: Entrada +Out: Salida Botanical: Botánico Species: Especie Add tag: Añadir etiqueta @@ -42,4 +48,5 @@ Remove niche: Quitar nicho Add barcode: Añadir código de barras Remove barcode: Quitar código de barras Buyer: Comprador -No results: Sin resultados \ No newline at end of file +No results: Sin resultados +Tag: Etiqueta \ No newline at end of file diff --git a/client/item/src/search-panel/index.html b/client/item/src/search-panel/index.html new file mode 100644 index 000000000..5b545d8bc --- /dev/null +++ b/client/item/src/search-panel/index.html @@ -0,0 +1,84 @@ + +
+
+ + + + + + + + + + + + + + + + +
+
diff --git a/client/item/src/search-panel/index.js b/client/item/src/search-panel/index.js new file mode 100644 index 000000000..b752e34e7 --- /dev/null +++ b/client/item/src/search-panel/index.js @@ -0,0 +1,32 @@ +import ngModule from '../module'; +import SearchPanel from 'core/src/components/searchbar/search-panel'; + +class Controller extends SearchPanel { + set filter(value) { + if (!value.tags) + value.tags = [{}]; + + this.$.filter = value; + } + + get filter() { + return this.$.filter; + } + + getSourceTable(selection) { + if (!selection || selection.isFree === true) + return null; + + if (selection.sourceTable) + return '/api/' + + selection.sourceTable.charAt(0).toUpperCase() + + selection.sourceTable.substring(1) + 's'; + else if (selection.sourceTable == null) + return `/api/ItemTags/filterItemTags/${selection.id}`; + } +} + +ngModule.component('vnItemSearchPanel', { + template: require('./index.html'), + controller: Controller +}); diff --git a/client/item/src/filter-panel/locale/es.yml b/client/item/src/search-panel/locale/es.yml similarity index 100% rename from client/item/src/filter-panel/locale/es.yml rename to client/item/src/search-panel/locale/es.yml diff --git a/client/item/src/tags/index.html b/client/item/src/tags/index.html index 18eaa613c..e20093813 100644 --- a/client/item/src/tags/index.html +++ b/client/item/src/tags/index.html @@ -48,14 +48,16 @@ rule="itemTag.priority" vn-acl="buyer"> - + - + ng-click="$ctrl.removeTag($index)" + tabindex="-1"> + + { this.removedTags = []; - this.itemTags = JSON.parse(JSON.stringify(this.tags)); this.tags = response.data; + this.itemTags = JSON.parse(JSON.stringify(this.tags)); this.orgTags = {}; this.tags.forEach(tag => { this.orgTags[tag.id] = Object.assign({}, tag); @@ -63,7 +63,7 @@ class Controller { return null; if (selection.sourceTable) { - return "/api/" + selection.sourceTable.charAt(0).toUpperCase() + + return '/api/' + selection.sourceTable.charAt(0).toUpperCase() + selection.sourceTable.substring(1) + 's'; } else if (selection.sourceTable == null) { return `/api/ItemTags/filterItemTags/${selection.id}`; @@ -107,7 +107,6 @@ ngModule.component('vnItemTags', { template: require('./index.html'), controller: Controller, bindings: { - itemTags: '=', - selection: ' diff --git a/client/production/src/index/index.html b/client/production/src/index/index.html index be21fd321..4e995dc54 100644 --- a/client/production/src/index/index.html +++ b/client/production/src/index/index.html @@ -21,7 +21,7 @@ show-field="name" value-field="id" field="$ctrl.filter.warehouseFk" - url="/production/api/Warehouses/production" + url="/production/api/Warehouses" on-change = "$ctrl.onChangeWareHouse(item)" label="Store"> diff --git a/client/salix/src/components/index.js b/client/salix/src/components/index.js index ab105ffff..afd469e89 100644 --- a/client/salix/src/components/index.js +++ b/client/salix/src/components/index.js @@ -4,4 +4,3 @@ import './main-menu/main-menu'; import './left-menu/left-menu'; import './left-menu/menu-item'; import './topbar/topbar'; -import './searchbar/searchbar'; diff --git a/client/salix/src/components/searchbar/searchbar.js b/client/salix/src/components/searchbar/searchbar.js deleted file mode 100644 index 6ff9a8072..000000000 --- a/client/salix/src/components/searchbar/searchbar.js +++ /dev/null @@ -1,160 +0,0 @@ -import ngModule from '../../module'; -import './style.scss'; - -export default class Controller { - constructor($element, $scope, $compile, $timeout, $state, $transitions) { - this.element = $element[0]; - this.$ = $scope; - this.$compile = $compile; - this.$timeout = $timeout; - this.stringSearch = ''; - this.$state = $state; - this.deregisterCallback = $transitions.onStart({}, - transition => this.changeState(transition)); - } - - clearFilter() { - this.index.filter = { - page: 1, - size: 20 - }; - } - - setFilter(filterObject) { - this.clearFilter(); - Object.assign(this.index.filter, filterObject); - } - - getFiltersFromString(stringSearch) { - let result = {}; - if (stringSearch) { - // find pattern key:value or key:(extra value) and returns array - let findPattern = stringSearch.match(/((([\w_]+):([\w_]+))|([\w_]+):\(([\w_ ]+)\))/gi); - let remnantString = (stringSearch.replace(/((([\w_]+):([\w_]+))|([\w_]+):\(([\w_ ]+)\))/gi, '')).trim(); - if (findPattern) { - for (let i = 0; i < findPattern.length; i++) { - let aux = findPattern[i].split(':'); - let property = aux[0]; - let value = aux[1].replace(/\(|\)/g, ''); - result[property] = value.trim(); - } - } - if (remnantString) { - result.search = remnantString; - } - } - return result; - } - - createStringFromObject(filterObject) { - let search = []; - let keys = Object.keys(filterObject); - if (keys.length) { - keys.forEach(k => { - let ignore = (this.ignoreKeys && this.ignoreKeys instanceof Array && this.ignoreKeys.indexOf(k) !== -1); - if (!ignore) { - let value = filterObject[k]; - - if (typeof value === 'string' && value.indexOf(' ') !== -1) { - search.push(`${k}:(${value})`); - } else if (typeof value !== 'object') { - search.push(`${k}:${value}`); - } - } - }); - - if (filterObject.search) - search.unshift(filterObject.search); - } - return (search.length) ? search.join(' ') : ''; - } - - changeState(transition) { - return !(transition._targetState._identifier.name === this.$state.current.name); - } - - pushFiltersToState(filters) { - let history = window.history || {pushState: () => { - console.error('Error in history.pushState(): Browser incompatibility error'); - }}; - let aux = window.location.hash.split('?q='); - if (Object.keys(filters).length) - history.pushState({}, null, `${aux[0]}?q=${encodeURIComponent(JSON.stringify(filters))}`); - else - history.pushState({}, null, aux[0]); - } - - onpenFilters(event) { - let filter = {}; - if (this.stringSearch) { - filter = this.getFiltersFromString(this.stringSearch); - } - - this.$child = this.$compile(`<${this.popover}/>`)(this.$.$new()); - - var childCtrl = this.$child.isolateScope().$ctrl; - childCtrl.filter = Object.assign({}, filter); - childCtrl.onSubmit = filter => this.onChildSubmit(filter); - if (this.data) - childCtrl.data = Object.assign({}, this.data); - - event.preventDefault(); - - this.$.popover.parent = this.element; - this.$.popover.child = this.$child[0]; - this.$.popover.show(); - } - - onPopoverClose() { - this.$child.scope().$destroy(); - this.$child.remove(); - this.$child = null; - } - - onChildSubmit(filter) { - this.$.popover.hide(); - this.stringSearch = this.createStringFromObject(filter); - this.clearFilter(); - this.$timeout(() => this.onSubmit()); - } - - onSubmit() { - let filter = {}; - if (this.stringSearch) { - filter = this.getFiltersFromString(this.stringSearch); - } - this.setFilter(filter); - - if (this.onSearch) - this.onSearch(); - - this.pushFiltersToState(filter); - } - - $onDestroy() { - this.clearFilter(); - this.deregisterCallback(); - } - - $onInit() { - if (this.$state.params.q) { - let filter = JSON.parse(decodeURIComponent(this.$state.params.q)); - this.stringSearch = this.createStringFromObject(filter); - } - this.$timeout(() => this.onSubmit()); - } -} -Controller.$inject = ['$element', '$scope', '$compile', '$timeout', '$state', '$transitions']; - -ngModule.component('vnSearchbar', { - template: require('./searchbar.html'), - bindings: { - index: '<', - onSearch: '&', - advanced: '=', - popover: '@', - ignoreKeys: ' -
-
- - TICKETS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ID TicketComercialDateHoraAliasProvinciaEstadoAgenciaAlmacenFacturaRuta
- - {{::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}} - - -
-
+ + +
+
+ + + - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdSalespersonDateHourAliasProvinceStateAgencyWarehouseInvoiceRoute
{{::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}} + + +
+
+ +
diff --git a/client/ticket/src/index/index.js b/client/ticket/src/index/index.js index fe75368e3..813165403 100644 --- a/client/ticket/src/index/index.js +++ b/client/ticket/src/index/index.js @@ -1,11 +1,82 @@ import ngModule from '../module'; -import './ticket-item'; -import './style.scss'; export default class Controller { constructor($scope) { - this.$scope = $scope; + this.$ = $scope; this.ticketSelected = null; + + this.filter = { + include: [ + { + relation: 'address', + scope: { + fields: ['provinceFk'], + include: { + relation: 'province', + scope: { + fields: ['name'] + } + } + } + }, { + relation: 'warehouse', + scope: { + fields: ['name'] + } + }, { + relation: 'agencyMode', + scope: { + fields: ['name'] + } + }, { + relation: 'tracking', + scope: { + fields: ['stateFk'], + include: { + relation: 'state', + scope: { + fields: ['name'] + } + } + } + }, { + relation: 'client', + scope: { + fields: ['salesPersonFk'], + include: { + relation: 'salesPerson', + scope: { + fields: ['name'] + } + } + } + } + ], + order: 'shipped DESC' + }; + } + + exprBuilder(param, value) { + switch (param) { + case 'search': + return { + or: [ + {id: value}, + {nickname: {regexp: value}} + ] + }; + case 'from': + return {shipped: {gte: value}}; + case 'to': + return {shipped: {lte: value}}; + case 'nickname': + return {[param]: {regexp: value}}; + case 'id': + case 'clientFk': + case 'agencyModeFk': + case 'warehouseFk': + return {[param]: value}; + } } compareDate(date) { @@ -26,17 +97,9 @@ export default class Controller { preview(event, ticket) { event.preventDefault(); event.stopImmediatePropagation(); - this.$scope.dialogSummaryTicket.show(); + this.$.dialogSummaryTicket.show(); this.ticketSelected = ticket; } - - search(index) { - index.accept(); - /* this.tickets = []; - index.accept().then(res => { - this.tickets = res.instances; - }); */ - } } Controller.$inject = ['$scope']; diff --git a/client/ticket/src/index/ticket-index.spec.js b/client/ticket/src/index/index.spec.js similarity index 86% rename from client/ticket/src/index/ticket-index.spec.js rename to client/ticket/src/index/index.spec.js index f6a004948..a6cd7d18c 100644 --- a/client/ticket/src/index/ticket-index.spec.js +++ b/client/ticket/src/index/index.spec.js @@ -34,14 +34,14 @@ describe('ticket', () => { it('should call preventDefault and stopImmediatePropagation from event and show', () => { let event = jasmine.createSpyObj('event', ['preventDefault', 'stopImmediatePropagation']); - controller.$scope = {dialogSummaryTicket: {show: () => {}}}; - spyOn(controller.$scope.dialogSummaryTicket, 'show'); + controller.$ = {dialogSummaryTicket: {show: () => {}}}; + spyOn(controller.$.dialogSummaryTicket, 'show'); let ticket = {}; controller.preview(event, ticket); expect(event.preventDefault).toHaveBeenCalledWith(); expect(event.stopImmediatePropagation).toHaveBeenCalledWith(); - expect(controller.$scope.dialogSummaryTicket.show).toHaveBeenCalledWith(); + expect(controller.$.dialogSummaryTicket.show).toHaveBeenCalledWith(); }); }); }); diff --git a/client/ticket/src/index/style.scss b/client/ticket/src/index/style.scss deleted file mode 100644 index eb363a9a7..000000000 --- a/client/ticket/src/index/style.scss +++ /dev/null @@ -1,3 +0,0 @@ -vn-ticket-item { - display: block; -} \ No newline at end of file diff --git a/client/ticket/src/index/ticket-item.html b/client/ticket/src/index/ticket-item.html deleted file mode 100644 index 9b9d25440..000000000 --- a/client/ticket/src/index/ticket-item.html +++ /dev/null @@ -1,20 +0,0 @@ - - - -
{{::$ctrl.ticket.nickname}}
- - -
- - - - -
-
diff --git a/client/ticket/src/index/ticket-item.js b/client/ticket/src/index/ticket-item.js deleted file mode 100644 index c62a989d9..000000000 --- a/client/ticket/src/index/ticket-item.js +++ /dev/null @@ -1,24 +0,0 @@ -import ngModule from '../module'; - -class Controller { - onClick(event) { - if (event.defaultPrevented) - event.stopImmediatePropagation(); - } - - preview(event) { - event.preventDefault(); - this.index.openSummary(this.ticket); - } -} - -ngModule.component('vnTicketItem', { - controller: Controller, - template: require('./ticket-item.html'), - bindings: { - ticket: '<' - }, - require: { - index: '^vnTicketIndex' - } -}); diff --git a/client/ticket/src/sale/index.html b/client/ticket/src/sale/index.html index 6834bbc5f..537971b66 100644 --- a/client/ticket/src/sale/index.html +++ b/client/ticket/src/sale/index.html @@ -5,31 +5,50 @@ Sale + + + + - + @@ -39,7 +58,10 @@ - - - - + + + + + + @@ -61,6 +100,135 @@ - - + + + + + + + + +
+
+ In which day you want to add the ticket? +
+ + + + + + + + + + + + + + + + +
+
+
+ + + + +
MANÁ: {{$ctrl.workerMana}}
+
+
+
{{$ctrl.client.name}}
+ + + + + + + + +
+
+ + + +
+
- + + ItemDescriptionDescription Quantity Price Discount
- + + {{::sale.quantity}}{{::sale.price | currency:'€':2}}{{::sale.discount}} %{{::sale.quantity * sale.price | currency:'€':2}}{{sale.quantity}}{{sale.price | currency:'€':2}}{{sale.discount}} %{{sale.quantity * sale.price | currency:'€':2}}
No results
+ + + + + + + + + + + + + + + + + +
IDF. envioAgenciaAlmacen
No results
{{::ticket.id}}{{::ticket.shipped | date: 'dd/MM/yyyy HH:mm'}}{{::ticket.agencyName}}{{::ticket.warehouseName}}
+ + + + + + + +
+ + + diff --git a/client/ticket/src/sale/index.js b/client/ticket/src/sale/index.js index d00f619b5..0b235948d 100644 --- a/client/ticket/src/sale/index.js +++ b/client/ticket/src/sale/index.js @@ -1,13 +1,29 @@ import ngModule from '../module'; import FilterTicketList from '../filter-ticket-list'; +import './style.scss'; class Controller extends FilterTicketList { - constructor($scope, $timeout, $stateParams, $http) { + constructor($scope, $timeout, $stateParams, $http, $state, vnApp) { super($scope, $timeout, $stateParams); this.$ = $scope; + this.vnApp = vnApp; this.$timeout = $timeout; this.onOrder('itemFk', 'ASC'); + this.$state = $stateParams; this.$http = $http; + this.deletable = false; + this.moreOptions = [ + {callback: this.showAddTurnDialog, name: "Add turn"}, + {callback: this.showDeleteTicketDialog, name: "Delete ticket"} + ]; + } + + get isEditable() { + try { + return !this.ticket.tracking.state.alertLevel; + } catch (e) {} + + return true; } get isChecked() { @@ -20,6 +36,22 @@ class Controller extends FilterTicketList { return false; } + getCheckedLines() { + let lines = []; + let data = this.$.index.model.instances; + if (data) + for (let i = 0; i < data.length; i++) + if (data[i].checked) + lines.push({id: data[i].id, instance: i}); + + return lines; + } + + onMoreChange(callback) { + callback.call(this); + } + + // Change State onStateOkClick() { let filter = {where: {code: "OK"}, fields: ["id"]}; let json = encodeURIComponent(JSON.stringify(filter)); @@ -30,41 +62,153 @@ class Controller extends FilterTicketList { onStateChange(value) { let params = {ticketFk: this.$state.params.id, stateFk: value}; - this.$http.post(`/ticket/api/TicketTrackings`, params).then(() => { + this.$http.post(`/ticket/api/TicketTrackings/changeState`, params).then(() => { this.card.reload(); + this.vnApp.showMessage(this.translate.instant('Data saved')); }); } - onRemoveLinesClick() { - let lines = { - delete: [] - }; - let data = this.$.index.model.instances; - if (data) - for (let i = 0; i < data.length;) { - if (data[i].checked) { - lines.delete.push(data[i].id); - data.splice(i, 1); - } else { - i++; - } - } - - let query = `/ticket/api/Sales/crudSale`; - this.$http.post(query, lines); + // 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(); + }); + } + + // 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'); + }); + } + + // 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); + }); + } + + // 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 => { + this.lastThreeTickets = res.data; + }); + this.$.transfer.parent = event.target; + this.$.transfer.show(); + } + + moveLines(ticketID) { + let sales = this.getCheckedLines(); + + let params = {sales: sales, newTicketFk: ticketID, actualTicketFk: this.ticket.id}; + this.$http.post(`/ticket/api/Sales/moveToTicket`, params).then(() => { + this.goToTicket(ticketID); + }); + } + + /* newTicket() { + let params = [this.ticket.clientFk, this.ticket.warehouseFk, this.ticket.companyFk, this.ticket.addressFk, this.ticket.agencyModeFk, null]; + this.$http.post(`/ticket/api/Tickets/create`, params).then(res => { + console.log(res); + }); + }*/ + + 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); + } + } + // Item Descriptor showDescriptor(event, itemFk) { this.$.descriptor.itemFk = itemFk; this.$.descriptor.parent = event.target; this.$.descriptor.show(); } + onDescriptorLoad() { this.$.popover.relocate(); } + + // Ticket Create + showticketCreate() { + console.log(this); + this.$.newTicket.show(); + } + + onResponse(response) { + if (response === 'ACCEPT') { + let newTicketID = this.$.newTicket.dialog.createTicket(); + console.log(newTicketID); + } + } + // Edit Line + _getworkerMana() { + this.$http.get(`/api/WorkerManas/getCurrentWorkerMana`).then(res => { + this.workerMana = res.data[0].mana; + }); + } + + showEditPopover(event, sale) { + this.sale = sale; + this.edit = { + id: sale.id, + quantity: sale.quantity, + price: sale.price, + discount: sale.discount + }; + this.$.edit.parent = event.target; + this._getworkerMana(); + this.$.edit.show(); + } + + 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(); + } } -Controller.$inject = ['$scope', '$timeout', '$state', '$http']; +Controller.$inject = ['$scope', '$timeout', '$state', '$http', 'vnApp']; ngModule.component('vnTicketSale', { template: require('./index.html'), diff --git a/client/ticket/src/sale/sale.spec.js b/client/ticket/src/sale/sale.spec.js index 729a9c4b7..94f84e73e 100644 --- a/client/ticket/src/sale/sale.spec.js +++ b/client/ticket/src/sale/sale.spec.js @@ -1,6 +1,6 @@ import './index.js'; -describe('Ticket', () => { +xdescribe('Ticket', () => { describe('Component vnTicketSale', () => { let $componentController; let controller; @@ -57,7 +57,7 @@ describe('Ticket', () => { describe('onStateChange()', () => { it('should perform a post and then call a function', () => { - $httpBackend.expectPOST(`/ticket/api/TicketTrackings`).respond(); + $httpBackend.expectPOST(`/ticket/api/TicketTrackings/changeState`).respond(); controller.card = {reload: () => {}}; controller.onStateChange(3); $httpBackend.flush(); diff --git a/client/ticket/src/sale/style.scss b/client/ticket/src/sale/style.scss new file mode 100644 index 000000000..83d73bb2a --- /dev/null +++ b/client/ticket/src/sale/style.scss @@ -0,0 +1,44 @@ +@import "colors"; + +vn-popover.edit { + + & div.popover{ + width: 200px; + } + + & vn-horizontal.header{ + background-color: $main-01; + text-align: center; + + & h5{ + color: white; + } + } +} + +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; + } +} \ No newline at end of file diff --git a/client/ticket/src/search-panel/index.html b/client/ticket/src/search-panel/index.html new file mode 100644 index 000000000..e8ddd290e --- /dev/null +++ b/client/ticket/src/search-panel/index.html @@ -0,0 +1,58 @@ +
+
+ + + + + + + + + + + + + + + + + + + {{name}} + + + + + + + +
+
diff --git a/client/ticket/src/search-panel/index.js b/client/ticket/src/search-panel/index.js new file mode 100644 index 000000000..be63116ef --- /dev/null +++ b/client/ticket/src/search-panel/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import SearchPanel from 'core/src/components/searchbar/search-panel'; + +ngModule.component('vnTicketSearchPanel', { + template: require('./index.html'), + controller: SearchPanel +}); diff --git a/client/ticket/src/search-panel/locale/es.yml b/client/ticket/src/search-panel/locale/es.yml new file mode 100644 index 000000000..1f892a742 --- /dev/null +++ b/client/ticket/src/search-panel/locale/es.yml @@ -0,0 +1,7 @@ +Ticket id: Id ticket +Client id: Id cliente +Nickname: Alias +From: Desde +To: Hasta +Agency: Agencia +Warehouse: Almacén \ No newline at end of file diff --git a/client/ticket/src/ticket.js b/client/ticket/src/ticket.js index 6719d535f..aae0d2005 100644 --- a/client/ticket/src/ticket.js +++ b/client/ticket/src/ticket.js @@ -1,5 +1,6 @@ export * from './module'; +import './search-panel'; import './index'; import './create'; import './card'; diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 294677ce2..ffbf88db2 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -192,7 +192,7 @@ export default { itemTags: { goToItemIndexButton: 'vn-item-descriptor [ui-sref="item.index"]', tagsButton: `vn-menu-item a[ui-sref="item.card.tags"]`, - firstRemoveTagButton: `vn-item-tags vn-horizontal:nth-child(2) > vn-icon[icon="remove_circle_outline"]`, + firstRemoveTagButton: `vn-item-tags vn-horizontal:nth-child(2) vn-icon-button[icon="remove_circle_outline"]`, firstTagSelect: `vn-item-tags vn-horizontal:nth-child(2) > vn-autocomplete[field="itemTag.tagFk"] input`, firstTagDisabled: `vn-item-tags vn-horizontal:nth-child(2) > vn-autocomplete > div > div > input`, firstTagSelectOptionOne: `vn-item-tags vn-horizontal:nth-child(2) > vn-autocomplete[field="itemTag.tagFk"] vn-drop-down ul > li:nth-child(1)`, @@ -218,7 +218,7 @@ export default { fifthTagSelectOptionFive: `vn-item-tags vn-horizontal:nth-child(6) > vn-autocomplete[field="itemTag.tagFk"] vn-drop-down ul > li:nth-child(5)`, fifthValueInput: `vn-item-tags vn-horizontal:nth-child(6) > vn-textfield[label="Value"] > div > input`, fifthRelevancyInput: `vn-horizontal:nth-child(6) > vn-textfield[label="Relevancy"] > div > input`, - addItemTagButton: `vn-icon[icon="add_circle"]`, + addItemTagButton: `vn-icon-button[icon="add_circle"]`, submitItemTagsButton: `${components.vnSubmit}` }, itemTax: { diff --git a/e2e/paths/ticket-module/01_create_ticket_observations.spec.js b/e2e/paths/ticket-module/01_create_ticket_observations.spec.js index 9905145d8..0e7b27975 100644 --- a/e2e/paths/ticket-module/01_create_ticket_observations.spec.js +++ b/e2e/paths/ticket-module/01_create_ticket_observations.spec.js @@ -23,7 +23,7 @@ describe('Ticket', () => { it('should search for the ticket with id 1', () => { return nightmare .wait(selectors.ticketsIndex.searchTicketInput) - .type(selectors.ticketsIndex.searchTicketInput, '1') + .type(selectors.ticketsIndex.searchTicketInput, 'id:1') .click(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) .countSearchResults(selectors.ticketsIndex.searchResult) diff --git a/e2e/paths/ticket-module/02_delete_ticket_expeditions.spec.js b/e2e/paths/ticket-module/02_delete_ticket_expeditions.spec.js index 559358439..38900da9d 100644 --- a/e2e/paths/ticket-module/02_delete_ticket_expeditions.spec.js +++ b/e2e/paths/ticket-module/02_delete_ticket_expeditions.spec.js @@ -23,7 +23,7 @@ describe('Ticket', () => { it('should search for the ticket with id 1', () => { return nightmare .wait(selectors.ticketsIndex.searchTicketInput) - .type(selectors.ticketsIndex.searchTicketInput, '1') + .type(selectors.ticketsIndex.searchTicketInput, 'id:1') .click(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) .countSearchResults(selectors.ticketsIndex.searchResult) diff --git a/e2e/paths/ticket-module/03_list_sale.spec.js b/e2e/paths/ticket-module/03_list_sale.spec.js index 4e1ec4e3e..0c1fc77c9 100644 --- a/e2e/paths/ticket-module/03_list_sale.spec.js +++ b/e2e/paths/ticket-module/03_list_sale.spec.js @@ -25,7 +25,7 @@ describe('Ticket', () => { it('should search for the ticket 1', () => { return nightmare .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 1) + .type(selectors.ticketsIndex.searchTicketInput, 'id:1') .click(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) .countSearchResults(selectors.ticketsIndex.searchResult) diff --git a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js index 1b98f9190..c87b99705 100644 --- a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js +++ b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js @@ -25,7 +25,7 @@ // it('should search for the ticket 1', () => { // return nightmare // .wait(selectors.ticketsIndex.searchResult) -// .type(selectors.ticketsIndex.searchTicketInput, 1) +// .type(selectors.ticketsIndex.searchTicketInput, 'id:1') // .click(selectors.ticketsIndex.searchButton) // .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) // .countSearchResults(selectors.ticketsIndex.searchResult) diff --git a/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js b/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js index 87bc5281d..ce44e1b26 100644 --- a/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js +++ b/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js @@ -25,7 +25,7 @@ describe('Ticket', () => { it('should search for the ticket 1', () => { return nightmare .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 1) + .type(selectors.ticketsIndex.searchTicketInput, 'id:1') .click(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) .countSearchResults(selectors.ticketsIndex.searchResult) diff --git a/package.json b/package.json index b1e2d6781..8ad42c02e 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "angular-translate-loader-partial": "^2.18.1", "flatpickr": "^4.4.6", "fs-extra": "^5.0.0", + "js-yaml": "^3.10.0", "material-design-lite": "^1.3.0", "mg-crud": "^1.1.2", "npm": "^5.8.0", @@ -55,7 +56,6 @@ "html-loader": "^0.4.4", "jasmine": "^2.9.0", "jasmine-spec-reporter": "^4.2.1", - "js-yaml": "^3.10.0", "karma": "^1.7.1", "karma-chrome-launcher": "^2.2.0", "karma-firefox-launcher": "^1.1.0", diff --git a/services/db/install/changes/1.0.6/buy.sql b/services/db/install/changes/1.0.6/buy.sql new file mode 100644 index 000000000..a46700342 --- /dev/null +++ b/services/db/install/changes/1.0.6/buy.sql @@ -0,0 +1,32 @@ +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `buy` AS + SELECT + `c`.`Id_Compra` AS `id`, + `c`.`Id_Entrada` AS `entryFk`, + `c`.`Id_Article` AS `itemFk`, + `c`.`Costefijo` AS `buyingValue`, + `c`.`Cantidad` AS `quantity`, + `c`.`Id_Cubo` AS `packageFk`, + `c`.`Etiquetas` AS `stickers`, + `c`.`Portefijo` AS `freightValue`, + `c`.`Embalajefijo` AS `packageValue`, + `c`.`Comisionfija` AS `comissionValue`, + `c`.`Packing` AS `packing`, + `c`.`grouping` AS `grouping`, + `c`.`caja` AS `groupingMode`, + `c`.`Nicho` AS `location`, + `c`.`Tarifa1` AS `price1`, + `c`.`Tarifa2` AS `price2`, + `c`.`Tarifa3` AS `price3`, + `c`.`PVP` AS `minPrice`, + `c`.`Productor` AS `producer`, + `c`.`Vida` AS `printedStickers`, + `c`.`punteo` AS `isChecked`, + `c`.`buy_edi_id` AS `ektFk`, + `c`.`Novincular` AS `isIgnored` + FROM + `vn2008`.`Compres` `c`; diff --git a/services/db/install/changes/1.0.6/ekt.sql b/services/db/install/changes/1.0.6/ekt.sql new file mode 100644 index 000000000..04679d689 --- /dev/null +++ b/services/db/install/changes/1.0.6/ekt.sql @@ -0,0 +1,45 @@ +USE `edi`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `edi`.`ekt` AS + SELECT + `vn2008`.`buy_edi`.`id` AS `id`, + `vn2008`.`buy_edi`.`barcode` AS `barcode`, + `vn2008`.`buy_edi`.`entry_year` AS `entry_year`, + `vn2008`.`buy_edi`.`delivery_number` AS `delivery_number`, + `vn2008`.`buy_edi`.`fec` AS `fec`, + `vn2008`.`buy_edi`.`hor` AS `hor`, + `vn2008`.`buy_edi`.`now` AS `now`, + `vn2008`.`buy_edi`.`ptj` AS `ptj`, + `vn2008`.`buy_edi`.`ref` AS `ref`, + `vn2008`.`buy_edi`.`item` AS `item`, + `vn2008`.`buy_edi`.`pac` AS `pac`, + `vn2008`.`buy_edi`.`qty` AS `qty`, + `vn2008`.`buy_edi`.`ori` AS `ori`, + `vn2008`.`buy_edi`.`cat` AS `cat`, + `vn2008`.`buy_edi`.`agj` AS `agj`, + `vn2008`.`buy_edi`.`kop` AS `kop`, + `vn2008`.`buy_edi`.`ptd` AS `ptd`, + `vn2008`.`buy_edi`.`sub` AS `sub`, + `vn2008`.`buy_edi`.`pro` AS `pro`, + `vn2008`.`buy_edi`.`pri` AS `pri`, + `vn2008`.`buy_edi`.`package` AS `package`, + `vn2008`.`buy_edi`.`auction` AS `auction`, + `vn2008`.`buy_edi`.`klo` AS `klo`, + `vn2008`.`buy_edi`.`k01` AS `k01`, + `vn2008`.`buy_edi`.`k02` AS `k02`, + `vn2008`.`buy_edi`.`k03` AS `k03`, + `vn2008`.`buy_edi`.`k04` AS `k04`, + `vn2008`.`buy_edi`.`s1` AS `s1`, + `vn2008`.`buy_edi`.`s2` AS `s2`, + `vn2008`.`buy_edi`.`s3` AS `s3`, + `vn2008`.`buy_edi`.`s4` AS `s4`, + `vn2008`.`buy_edi`.`s5` AS `s5`, + `vn2008`.`buy_edi`.`s6` AS `s6`, + `vn2008`.`buy_edi`.`ok` AS `ok`, + `vn2008`.`buy_edi`.`trolley_id` AS `trolley_id`, + `vn2008`.`buy_edi`.`scanned` AS `scanned` + FROM + `vn2008`.`buy_edi`; diff --git a/services/db/install/changes/1.0.6/itemLastEntries.sql b/services/db/install/changes/1.0.6/itemLastEntries.sql new file mode 100644 index 000000000..1bf18bce8 --- /dev/null +++ b/services/db/install/changes/1.0.6/itemLastEntries.sql @@ -0,0 +1,40 @@ +USE `vn`; +DROP procedure IF EXISTS `itemLastEntries`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `itemLastEntries`(vItem INT, vDays DATE) +BEGIN + SELECT + w.id AS warehouseFk, + tr.landed, + b.entryFk, + b.isIgnored, + b.price2, + b.price3, + b.stickers, + b.packing, + b.grouping, + i.stems, + b.quantity, + b.buyingValue, + b.packageFk , + s.id AS supplierFk +FROM itemType it + RIGHT JOIN (entry e + LEFT JOIN supplier s ON s.id = e.supplierFk + RIGHT JOIN buy b ON b.entryFk = e.id + LEFT JOIN item i ON i.id = b.itemFk + LEFT JOIN ink ON ink.id = i.inkFk + LEFT JOIN travel tr ON tr.id = e.travelFk + LEFT JOIN warehouse w ON w.id = tr.warehouseInFk + LEFT JOIN origin o ON o.id = i.originFk + ) ON it.id = i.typeFk + LEFT JOIN edi.ekt ek ON b.ektFk = ek.id +WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND CURDATE() + ORDER BY tr.landed DESC , b.id DESC; + +END$$ + +DELIMITER ; + diff --git a/services/db/install/changes/1.0.6/ticketComponentMakeUpdate.sql b/services/db/install/changes/1.0.6/ticketComponentMakeUpdate.sql deleted file mode 100644 index 272b4ab1b..000000000 --- a/services/db/install/changes/1.0.6/ticketComponentMakeUpdate.sql +++ /dev/null @@ -1,54 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticketComponentMakeUpdate`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketComponentMakeUpdate`( - vTicketFk INT, - vClientFk INT, - vAgencyModeFk INT, - vAddressFk INT, - vWarehouseFk INT, - vShipped DATETIME, - vLanded DATE, - vIsDeleted BOOLEAN, - vHasToBeUnrouted BOOLEAN, - vOption INT) -BEGIN -/** - * Calcula los componentes de un ticket - * y los actualiza con los nuevos datos. - * - * @param vTicketFk Id del ticket - * @param vClientFk Id del cliente - * @param vAgencyModeFk Id del tipo de agencia - * @param vAddressFk Id del consignatario - * @param vWarehouseFk Id del almacén - * @param vShipped Fecha de salida - * @param vLanded Fecha de llegada - * @param vIsDeleted Marcado como eliminado - * @param vHasToBeUnrouted Marcado para sacar de ruta - * @param vOption Id de la acción ticketUpdateAction - */ - - CALL vn.ticketComponentPreview (vTicketFk, vLanded, vAddressFk, vAgencyModeFk, vWarehouseFk); - CALL vn.ticketComponentUpdate ( - vTicketFk, - vClientFk, - vAgencyModeFk, - vAddressFk, - vWarehouseFk, - vShipped, - vLanded, - vIsDeleted, - vHasToBeUnrouted, - vOption - ); - - DROP TEMPORARY TABLE - tmp.ticketComponent, - tmp.ticketComponentPrice; -END$$ - -DELIMITER ; - diff --git a/services/db/install/changes/1.0.6/ticketComponentPreview.sql b/services/db/install/changes/1.0.6/ticketComponentPreview.sql deleted file mode 100644 index bcabd4552..000000000 --- a/services/db/install/changes/1.0.6/ticketComponentPreview.sql +++ /dev/null @@ -1,74 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticketComponentPreview`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentPreview`( - vTicketFk INT, - vDate DATE, - vAddressFk INT, - vAgencyModeFk INT, - vWarehouseFk SMALLINT) -BEGIN -/** - * Devuelve un listado previo de - * componentes para 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 - */ - DECLARE vAgencyFk INT; - DECLARE vShipped DATE; - DECLARE vBuyOrderItem INT DEFAULT 100; - - SELECT agencyFk INTO vAgencyFk - FROM agencyMode - WHERE id = vAgencyModeFk; - - CALL agencyHourOffer(vDate, vAddressFk, vAgencyFk); - - SELECT shipped INTO vShipped - FROM tmp.agencyHourOffer - WHERE warehouseFk = vWarehouseFK; - - CALL buyUltimate(vWarehouseFK, vShipped); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( - SELECT - vWarehouseFK AS warehouseFk, - NULL AS available, - s.itemFk, - bu.buyFk - FROM sale s - LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk - WHERE s.ticketFk = vTicketFk - AND s.itemFk != vBuyOrderItem - GROUP BY bu.warehouseFk, bu.itemFk); - - CALL ticketComponentCalculate(vAddressFk, vAgencyModeFk); - - REPLACE INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT t.warehouseFk, s.itemFk, sc.componentFk, sc.value - FROM saleComponent sc - JOIN sale s ON s.id = sc.saleFk - JOIN ticket t ON t.id = s.ticketFk - JOIN componentRate cr ON cr.id = sc.componentFk - WHERE s.ticketFk = vTicketFk AND NOT cr.isRenewable; - - SET @shipped = vShipped; - - DROP TEMPORARY TABLE - tmp.agencyHourOffer, - tmp.buyUltimate, - tmp.ticketLot; - - IF IFNULL(vShipped, CURDATE() - 1) < CURDATE() THEN - CALL util.throw('NO_AGENCY_AVAILABLE'); - END IF; -END$$ - -DELIMITER ; \ No newline at end of file diff --git a/services/db/install/changes/1.0.6/ticketComponentPriceDifference.sql b/services/db/install/changes/1.0.6/ticketComponentPriceDifference.sql deleted file mode 100644 index 849efea3e..000000000 --- a/services/db/install/changes/1.0.6/ticketComponentPriceDifference.sql +++ /dev/null @@ -1,55 +0,0 @@ -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), 4) AS newPrice, - s.quantity * (s.price - ROUND(SUM(cost), 4)) 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.6/ticketComponentUpdate.sql b/services/db/install/changes/1.0.6/ticketComponentUpdate.sql deleted file mode 100644 index 3306be405..000000000 --- a/services/db/install/changes/1.0.6/ticketComponentUpdate.sql +++ /dev/null @@ -1,74 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `ticketComponentUpdate`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentUpdate`( - vTicketFk INT, - vClientFk INT, - vAgencyModeFk INT, - vAddressFk INT, - vWarehouseFk INT, - vShipped DATETIME, - vLanded DATE, - vIsDeleted BOOLEAN, - vHasToBeUnrouted BOOLEAN, - vOption INT) -BEGIN -/** - * Actualiza un ticket y sus componentes - * con los nuevos datos. - * - * @param vTicketFk Id del ticket - * @param vClientFk Id del cliente - * @param vAgencyModeFk Id del tipo de agencia - * @param vAddressFk Id del consignatario - * @param vWarehouseFk Id del almacén - * @param vShipped Fecha de salida - * @param vLanded Fecha de llegada - * @param vIsDeleted Marcado como eliminado - * @param vHasToBeUnrouted Marcado para sacar de ruta - * @param vOption Id de la acción ticketUpdateAction - */ - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - START TRANSACTION; - - UPDATE ticket t - SET - t.clientFk = vClientFk, - t.agencyModeFk = vAgencyModeFk, - t.addressFk = vAddressFk, - t.warehouseFk = vWarehouseFk, - t.landed = vLanded, - t.shipped = vShipped, - t.isDeleted = vIsDeleted - WHERE - t.id = vTicketFk; - - IF vHasToBeUnrouted THEN - UPDATE ticket t SET t.routeFk = NULL - WHERE t.id = vTicketFk; - END IF; - - IF vOption <> 8 THEN - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - CREATE TEMPORARY TABLE tmp.sale - (PRIMARY KEY (saleFk)) - ENGINE = MEMORY - SELECT id AS saleFk, vWarehouseFk warehouseFk - FROM sale s WHERE s.ticketFk = vTicketFk; - - CALL ticketComponentUpdateSale (vOption); - - DROP TEMPORARY TABLE tmp.sale; - END IF; - COMMIT; -END$$ - -DELIMITER ; - diff --git a/services/db/install/dump/01-structure.sql b/services/db/install/dump/01-structure.sql index 0080d40c4..3549ba1ff 100644 --- a/services/db/install/dump/01-structure.sql +++ b/services/db/install/dump/01-structure.sql @@ -270,7 +270,7 @@ CREATE TABLE `role` ( `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=56 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Roles'; +) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Roles'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -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=14209 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; +) ENGINE=InnoDB AUTO_INCREMENT=14242 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=20680 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20719 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2533,7 +2533,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=312492 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=313524 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 */ ; @@ -2723,7 +2723,7 @@ CREATE TABLE `Articles_dits` ( KEY `fgkey1_idx` (`idaccion_dits`), KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`) -) ENGINE=InnoDB AUTO_INCREMENT=20197 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20221 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2745,7 +2745,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=466709 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=472091 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2909,7 +2909,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=585503 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=588092 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 */ ; @@ -3056,7 +3056,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=14207 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14242 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 */ ; @@ -3339,7 +3339,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=212089 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=230680 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3421,7 +3421,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=253422636 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=254891207 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 */ ; @@ -3673,7 +3673,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=19141 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=19565 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3717,7 +3717,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=25102 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=25151 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 */ ; @@ -3901,7 +3901,7 @@ CREATE TABLE `Contactos` ( PRIMARY KEY (`Id_Contacto`), KEY `Telefono` (`Telefono`), KEY `Movil` (`Movil`) -) ENGINE=InnoDB AUTO_INCREMENT=2633 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2634 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 */ ; @@ -4098,7 +4098,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=142448 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; +) ENGINE=InnoDB AUTO_INCREMENT=143067 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 */ ; @@ -4262,7 +4262,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=2797253 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2815062 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4280,7 +4280,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=258 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; +) ENGINE=InnoDB AUTO_INCREMENT=339 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4523,7 +4523,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=453920 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=457354 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 */ ; @@ -4741,7 +4741,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=2233651 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=FIXED; +) ENGINE=InnoDB AUTO_INCREMENT=2248721 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 */ ; @@ -4942,7 +4942,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=20917575 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21049676 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 */ ; @@ -5091,7 +5091,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=10638135 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=10756970 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5161,7 +5161,7 @@ CREATE TABLE `Ordenes` ( KEY `Id_Comprador` (`CodCOMPRADOR`), KEY `Id_Movimiento` (`Id_Movimiento`), KEY `Id_Vendedor` (`CodVENDEDOR`) -) ENGINE=InnoDB AUTO_INCREMENT=30788 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=31081 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5333,7 +5333,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=2503 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2510 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5359,7 +5359,7 @@ CREATE TABLE `Proveedores_account` ( KEY `fk_Proveedores_account_entity1_idx` (`entity_id`), KEY `fk_banco_prov_account_idx` (`Id_Banco`), CONSTRAINT `fk_banco_prov_account` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=639 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=644 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5450,7 +5450,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=462009 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=465616 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 */ ; @@ -5541,7 +5541,7 @@ CREATE TABLE `Relaciones` ( KEY `Id_Contacto` (`Id_Contacto`), KEY `Id_Proveedor` (`Id_Proveedor`), KEY `Id_Cliente` (`Id_Cliente`) -) ENGINE=InnoDB AUTO_INCREMENT=2634 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2635 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5561,7 +5561,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=1070 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1078 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5586,7 +5586,7 @@ CREATE TABLE `Reservas` ( PRIMARY KEY (`Id_Reserva`), KEY `Id_1` (`Id_Ticket`), KEY `Id_Article` (`Id_Article`) -) ENGINE=InnoDB AUTO_INCREMENT=786 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1168 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5617,7 +5617,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=38837 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=39113 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 */ ; @@ -5805,7 +5805,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=321219 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=321737 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5823,7 +5823,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=36235 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=36244 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5851,7 +5851,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=23507 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=23513 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5909,7 +5909,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=1874093 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1882728 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 */ ; @@ -6118,7 +6118,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=58938859 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=59101617 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6167,7 +6167,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=1873622 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1882387 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6312,6 +6312,7 @@ CREATE TABLE `Trabajadores` ( `user_id` int(10) unsigned DEFAULT NULL, `boss` int(11) NOT NULL DEFAULT '2', `DniExpiration` datetime DEFAULT NULL, + `hasMachineryAutorized` tinyint(2) DEFAULT '0', PRIMARY KEY (`Id_Trabajador`), UNIQUE KEY `CodigoTrabajador_UNIQUE` (`CodigoTrabajador`), UNIQUE KEY `user` (`user`), @@ -6320,7 +6321,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=1118 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1119 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 */ ; @@ -6447,7 +6448,7 @@ CREATE TABLE `Vehiculos` ( KEY `provinceFk_idx` (`warehouseFk`), CONSTRAINT `Vehiculos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `provinceFk` FOREIGN KEY (`warehouseFk`) REFERENCES `province` (`province_id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=378 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=379 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6473,7 +6474,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=8148 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=8225 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 */; -- @@ -6587,7 +6588,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=3321290 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3350773 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 */ ; @@ -6695,7 +6696,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=1966 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2547 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 */ ; @@ -6773,7 +6774,7 @@ CREATE TABLE `accumulatorsReadingDate` ( PRIMARY KEY (`id`), KEY `pagoSdcFk_idx` (`pagoSdcfk`), CONSTRAINT `pagoSdcFk` FOREIGN KEY (`pagoSdcfk`) REFERENCES `pago_sdc` (`pago_sdc_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=271 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=275 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6862,7 +6863,7 @@ CREATE TABLE `agency_hour` ( CONSTRAINT `agency_hour_ibfk_1` FOREIGN KEY (`agency_id`) REFERENCES `agency` (`agency_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `agency_hour_ibfk_2` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `agency_hour_ibfk_3` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4629 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4633 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 */ ; @@ -7028,7 +7029,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=2279 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2308 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7105,7 +7106,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=2548 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2560 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 */ ; @@ -7363,7 +7364,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=2212 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2223 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7481,7 +7482,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=35736 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=35847 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7622,7 +7623,7 @@ CREATE TABLE `buy_edi` ( KEY `kop` (`kop`), KEY `barcode` (`barcode`), KEY `fec` (`fec`) -) ENGINE=InnoDB AUTO_INCREMENT=697977 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=702925 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7876,7 +7877,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=83376 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=83904 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7910,7 +7911,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=45191 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=45421 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7964,7 +7965,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=115084 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=115779 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8021,7 +8022,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=49559 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; +) ENGINE=InnoDB AUTO_INCREMENT=49947 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8134,7 +8135,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=63623 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=63843 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8300,7 +8301,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=3164 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; +) ENGINE=InnoDB AUTO_INCREMENT=3187 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8382,7 +8383,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=63214 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=63490 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8813,6 +8814,8 @@ CREATE TABLE `empresa` ( `morosidad` tinyint(4) NOT NULL DEFAULT '0', `empresa_grupo` int(11) NOT NULL DEFAULT '1', `CodigoEmpresa` int(2) DEFAULT NULL COMMENT 'Campo para movConta', + `footnotes` longtext COLLATE utf8_unicode_ci COMMENT 'pie de paginas en las facturas', + `phytosanitary` longtext COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), KEY `gerente_id` (`gerente_id`), KEY `empresa_cliente_idx` (`Id_Cliente`), @@ -8855,7 +8858,7 @@ CREATE TABLE `entity` ( UNIQUE KEY `bic_UNIQUE` (`bic`), KEY `fg_entity1_idx` (`pais_id`), CONSTRAINT `fg_entity1` FOREIGN KEY (`pais_id`) REFERENCES `Paises` (`Id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=30007 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Entidades bancarias '; +) ENGINE=InnoDB AUTO_INCREMENT=30008 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Entidades bancarias '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8894,7 +8897,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=15406 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=15458 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8923,7 +8926,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=2412876 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2427728 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 */ ; @@ -9044,7 +9047,7 @@ CREATE TABLE `expeditions_deleted` ( KEY `index2` (`EsBulto`), KEY `index3` (`odbc_date`), KEY `index4` (`ticket_id`) -) ENGINE=InnoDB AUTO_INCREMENT=2412323 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2427724 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9183,7 +9186,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=985305 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; +) ENGINE=InnoDB AUTO_INCREMENT=995970 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 */ ; @@ -9382,7 +9385,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=65725 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=66071 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9720,7 +9723,7 @@ CREATE TABLE `mail` ( `recipientFk` int(11) DEFAULT NULL, `plainTextBody` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=1342007 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=1353602 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9778,7 +9781,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=14991 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=15071 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 */ ; @@ -9987,7 +9990,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=41495 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=41646 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 */ ; @@ -10068,7 +10071,7 @@ CREATE TABLE `pago_sdc` ( CONSTRAINT `empresa_sdc` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `financial_type_fk` FOREIGN KEY (`financialProductTypefk`) REFERENCES `financialProductType` (`id`) ON UPDATE CASCADE, CONSTRAINT `pago_sdc_entity_fk` FOREIGN KEY (`entity_id`) REFERENCES `entity` (`entity_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=45 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Seguros de cambio'; +) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Seguros de cambio'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10482,7 +10485,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=53547 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=53716 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 */ ; @@ -10544,7 +10547,7 @@ CREATE TABLE `producer` ( `visible` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`producer_id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=4523 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4574 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10713,7 +10716,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=68074 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=68422 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 */ ; @@ -11302,7 +11305,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=91322 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=91947 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11325,7 +11328,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=88491 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=89163 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 */ ; @@ -11368,7 +11371,7 @@ CREATE TABLE `recovery` ( KEY `cliente_idx` (`Id_Cliente`), CONSTRAINT `cliente333` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `cliente_cliente` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=258 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntaremos los acuerdos de recobro semanal a '; +) ENGINE=InnoDB AUTO_INCREMENT=259 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntaremos los acuerdos de recobro semanal a '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11562,7 +11565,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=56856 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; +) ENGINE=InnoDB AUTO_INCREMENT=57826 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 */; -- @@ -11602,7 +11605,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=725408 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=736401 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11624,7 +11627,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=1786 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1794 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 */ ; @@ -11800,6 +11803,21 @@ CREATE TABLE `state` ( ) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `subordinate` +-- + +DROP TABLE IF EXISTS `subordinate`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `subordinate` ( + `Id_Trabajador` bigint(11) DEFAULT NULL, + `visited` int(1) NOT NULL DEFAULT '0', + `boss` int(1) NOT NULL DEFAULT '0', + KEY `Id_Trabajador` (`Id_Trabajador`) +) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `tag` -- @@ -12079,7 +12097,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=1071942 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=1077635 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12202,7 +12220,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=106537 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=107031 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 */ ; @@ -12339,7 +12357,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=167282 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=168617 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12366,7 +12384,7 @@ CREATE TABLE `travel_pattern` ( CONSTRAINT `travel_pattern_ibfk_3` FOREIGN KEY (`warehouse_out`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_pattern_ibfk_4` FOREIGN KEY (`agency_id`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `travel_pattern_ibfk_5` FOREIGN KEY (`warehouse_in`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=323 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=325 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -13713,7 +13731,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=135 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=146 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15688,7 +15706,7 @@ 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 FUNCTION IF EXISTS `ticket_volumen_en_cajas` */; +/*!50003 DROP FUNCTION IF EXISTS `ticket_volumen_en_cajasKK` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -15698,7 +15716,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` FUNCTION `ticket_volumen_en_cajas`(idT INT) RETURNS decimal(10,1) +CREATE DEFINER=`root`@`%` FUNCTION `ticket_volumen_en_cajasKK`(idT INT) RETURNS decimal(10,1) BEGIN /* Devuelve el volumen estimado de un pedido, en cajas @@ -36894,7 +36912,7 @@ BEGIN * @param maxRiskDate Fecha maxima de los registros * @return table tmp.risk */ - DECLARE startingDate DATETIME DEFAULT TIMESTAMPADD(DAY, - DAYOFMONTH(CURDATE()) - 30, CURDATE()); + DECLARE startingDate DATETIME DEFAULT TIMESTAMPADD(DAY, - DAYOFMONTH(CURDATE()) - 60, CURDATE()); DECLARE endingDate DATETIME; DECLARE MAX_RISK_ALLOWED INT DEFAULT 200; @@ -40372,6 +40390,8 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `travel_tree`(vDate DATE, vAddress INT, vAgency INT) BEGIN /** + *DEPRECATED use vn.agencyHourGetShipped + * * Devuelve la lista de almacenes disponibles y la fecha de * envío desde cada uno. * @@ -40455,6 +40475,8 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `travel_tree_list`(vAddress INT, vDate DATE) BEGIN /** + *DEPRECATED use vn.agencyHourGetAgency + * * Devuelve el listado de agencias disponibles para la fecha * y dirección pasadas. * @@ -40508,6 +40530,8 @@ BEGIN CLOSE vCur; SELECT * FROM agency_list; + DROP TEMPORARY TABLE agency_list; + DROP TEMPORARY TABLE travel_tree; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -43218,7 +43242,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=163558 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=164082 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43324,6 +43348,8 @@ SET character_set_client = utf8; 1 AS `supplierAccountFk`, 1 AS `workerManagerFk`, 1 AS `sage200Company`, + 1 AS `footnotes`, + 1 AS `phytosanitary`, 1 AS `companyCode`*/; SET character_set_client = @saved_cs_client; @@ -43608,7 +43634,7 @@ CREATE TABLE `creditClassification` ( KEY `creditClassifClientFk_idx` (`client`), KEY `creditClassifdateEnd_idx` (`dateEnd`), CONSTRAINT `creditClassifClientFk` FOREIGN KEY (`client`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2750 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2755 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!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 */ ; @@ -43653,7 +43679,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=1894 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; +) ENGINE=InnoDB AUTO_INCREMENT=1901 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 */ ; @@ -43808,7 +43834,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=3162 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3175 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43849,7 +43875,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=4303 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4339 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43869,7 +43895,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=4125 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=4135 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 */; -- @@ -43894,7 +43920,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=829 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=916 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43990,7 +44016,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=46221 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=47652 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44574,7 +44600,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=62443 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=66411 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 */; -- @@ -44617,7 +44643,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=913436 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=927466 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44825,10 +44851,11 @@ CREATE TABLE `itemTag` ( `value` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `priority` int(2) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), + UNIQUE KEY `itemFk` (`itemFk`,`tagFk`), 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=303671 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=322902 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44890,7 +44917,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=487058 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; +) ENGINE=InnoDB AUTO_INCREMENT=490910 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 */; -- @@ -45121,7 +45148,7 @@ CREATE TABLE `message` ( KEY `sender` (`sender`), KEY `recipient` (`recipient`), KEY `uuid` (`uuid`(8)) -) ENGINE=InnoDB AUTO_INCREMENT=1481460 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1489264 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45143,7 +45170,7 @@ CREATE TABLE `messageInbox` ( PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), KEY `finalRecipient` (`finalRecipient`) -) ENGINE=InnoDB AUTO_INCREMENT=1627657 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1635671 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46044,7 +46071,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=473078 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=482434 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46131,7 +46158,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=95585 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=96248 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46295,7 +46322,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=316355 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=322470 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46517,7 +46544,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=828310 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=903759 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 */ ; @@ -46617,7 +46644,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=25940 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=27602 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47064,7 +47091,24 @@ 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=5249 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=5358 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `workerHourPrice` +-- + +DROP TABLE IF EXISTS `workerHourPrice`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerHourPrice` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `dated` date NOT NULL, + `hollidayInc` decimal(4,2) DEFAULT NULL, + `nightInc` decimal(4,2) DEFAULT NULL, + `extraInc` decimal(4,2) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Recoge los acuerdos de los distintos convenios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47089,10 +47133,11 @@ CREATE TABLE `workerJourney` ( `extra` decimal(5,2) NOT NULL DEFAULT '0.00', `contractJourney` decimal(5,2) NOT NULL DEFAULT '0.00', `priceExtraHollyday` decimal(5,2) NOT NULL DEFAULT '0.00', + `businessFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`,`userFk`), KEY `fk_workerJourney_user_idx` (`userFk`), CONSTRAINT `fk_workerJourney_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=121259 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=408966 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47114,7 +47159,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=3982 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4174 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47141,11 +47186,13 @@ DROP TABLE IF EXISTS `workerTimeControl`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerTimeControl` ( `id` int(11) NOT NULL, - `userFk` int(11) NOT NULL, + `userFk` int(10) unsigned NOT NULL, `timed` datetime NOT NULL, `manual` tinyint(4) NOT NULL DEFAULT '0', `order` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `workerTimeControl_fk1_idx` (`userFk`), + CONSTRAINT `workerTimeControl_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -47181,7 +47228,7 @@ CREATE TABLE `workingHours` ( PRIMARY KEY (`id`), KEY `user_working_hour_idx` (`userId`), CONSTRAINT `user_working_hour` FOREIGN KEY (`userId`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=22501 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena horas de Entrada y de Salida del personal'; +) ENGINE=InnoDB AUTO_INCREMENT=23002 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena horas de Entrada y de Salida del personal'; /*!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 */ ; @@ -48990,7 +49037,7 @@ 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 `agencyHourListOffer` */; +/*!50003 DROP PROCEDURE IF EXISTS `agencyHourGetAgency` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -49000,22 +49047,70 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `agencyHourListOffer`(vDate DATE, vAddressFk INT, vAgencyFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `agencyHourGetAgency`(vAddress INT, vDate DATE) BEGIN +/** + * Devuelve el listado de agencias disponibles para la fecha + * y dirección pasadas. + * + * @param vAddress Id de dirección de envío, %NULL si es recogida + * @param vDate Fecha de recogida + * @table agencyModeList Listado de agencias disponibles + */ + DECLARE vAgency INT; + DECLARE vDone BOOL DEFAULT FALSE; - CALL vn.agencyHourOffer(vDate, vAddressFk, vAgencyFk); + DECLARE vCur CURSOR FOR + SELECT DISTINCT a.id + FROM agency a + JOIN agencyHour ah ON ah.agencyFk = a.id; - SELECT * FROM tmp.agencyHourOffer; - - DROP TEMPORARY TABLE tmp.agencyHourOffer; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + DROP TEMPORARY TABLE IF EXISTS agencyModeList; + CREATE TEMPORARY TABLE agencyModeList ( + id INT NOT NULL, + agency VARCHAR(20), + description VARCHAR(45), + deliveryMethodFk VARCHAR(45), + shipped DATE, + warehouse VARCHAR(45), + PRIMARY KEY(id) + ) + ENGINE = MEMORY; + + OPEN vCur; + FETCH vCur INTO vAgency; + + WHILE NOT vDone + DO + CALL vn.agencyHourGetShipped(vDate, vAddress, vAgency); + INSERT INTO agencyModeList + SELECT a.id, a.name, a.description, + a.deliveryMethodFk, ah.shipped, w.name + FROM agencyMode a + JOIN tmp.agencyHourGetShipped ah + JOIN warehouse w on w.id = ah.warehouseFk + WHERE a.agencyFk = vAgency + AND a.web + ON DUPLICATE KEY UPDATE + warehouse = CONCAT(warehouse, ', ', w.name); + + FETCH vCur INTO vAgency; + END WHILE; + + CLOSE vCur; + DROP TEMPORARY TABLE tmp.agencyHourGetShipped; + SELECT * FROM agencyModeList; + DROP TEMPORARY TABLE IF EXISTS agencyModeList; 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 `agencyHourOffer` */; +/*!50003 DROP PROCEDURE IF EXISTS `agencyHourGetShipped` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -49025,7 +49120,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `agencyHourOffer`(vDate DATE, vAddressFk INT, vAgencyFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `agencyHourGetShipped`(vDate DATE, vAddressFk INT, vAgencyFk INT) BEGIN /** * Devuelve las posibles fechas de envío de un ticket @@ -49033,20 +49128,20 @@ BEGIN * @param vDate La fecha * @param vAddressFk Id del consignatario * @param vAgencyFk Id de la agencia - * @return tmp.agencyHourOffer + * @return tmp.agencyHourGetShipped */ DECLARE vDone BOOL; DECLARE vWarehouseFk SMALLINT; DECLARE vCur CURSOR FOR SELECT w.id warehouseFk - FROM warehouse w + FROM vn.warehouse w WHERE w.hasAvailable; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DROP TEMPORARY TABLE IF EXISTS tmp.agencyHourOffer; - CREATE TEMPORARY TABLE tmp.agencyHourOffer + DROP TEMPORARY TABLE IF EXISTS tmp.agencyHourGetShipped; + CREATE TEMPORARY TABLE tmp.agencyHourGetShipped ( warehouseFk TINYINT NOT NULL PRIMARY KEY, shipped DATE NOT NULL, @@ -49063,8 +49158,7 @@ BEGIN IF vDone THEN LEAVE l; END IF; - - INSERT INTO tmp.agencyHourOffer (warehouseFk, shipped, landed) + INSERT INTO tmp.agencyHourGetShipped (warehouseFk, shipped, landed) SELECT vWarehouseFk, shipping, vDate FROM ( SELECT TIMESTAMPADD(DAY, -ah.substractDay, vDate) shipping, ah.maxHour FROM agencyHour ah @@ -49084,7 +49178,7 @@ BEGIN ) DESC LIMIT 1 ) t - WHERE t.shipping >= CURDATE() + WHERE t.shipping >= CURDATE() AND IF(t.shipping = CURDATE(), t.maxHour > HOUR(NOW()), TRUE); END LOOP; @@ -49095,6 +49189,120 @@ 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 `agencyHourGetWarehouse` */; +/*!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 `agencyHourGetWarehouse`(vAddress INT, vDate DATE, vWarehouse INT) +BEGIN +/** +* Devuelve el listado de agencias disponibles para la fecha, + * dirección y warehouuse pasadas + * + * @param vAddress no puede ser NULL + * @param vWarehouse warehouse donde comprobaremos las agencias y fecha + * @param vDate Fecha de recogida + * @table agencyModeWarehouseList Listado de agencias disponibles + */ + DECLARE vAgency INT; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vCur CURSOR FOR + SELECT DISTINCT a.id + FROM agency a + JOIN agencyHour ah ON ah.agencyFk = a.id; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + IF vAddress IS NULL + THEN + CALL util.throw ('Address cannot be null'); + END IF; + + DROP TEMPORARY TABLE IF EXISTS tmp.agencyModeWarehouseList; + CREATE TEMPORARY TABLE tmp.agencyModeWarehouseList ( + id INT NOT NULL, + agency VARCHAR(20), + description VARCHAR(45), + deliveryMethodFk VARCHAR(45), + shipped DATE, + warehouse VARCHAR(45), + PRIMARY KEY(id) + ) + ENGINE = MEMORY; + + OPEN vCur; + FETCH vCur INTO vAgency; + + WHILE NOT vDone + DO + + INSERT INTO tmp.agencyModeWarehouseList + SELECT am.id, am.name, am.description,am.deliveryMethodFk, TIMESTAMPADD(DAY, -ah.substractDay, vDate), w.name + FROM agencyHour ah + LEFT JOIN address a ON a.id = vAddress + JOIN agencyMode am ON am.agencyFk = vAgency + JOIN warehouse w on w.id = ah.warehouseFk + WHERE ah.warehouseFk = vWarehouse + AND (weekDay = WEEKDAY(vDate) + OR weekDay IS NULL) + AND (ah.agencyFk = vAgency + OR ah.agencyFk IS NULL) + AND (ah.provinceFk = a.provinceFk + OR ah.provinceFk IS NULL + OR vAddress IS NULL) + AND TIMESTAMPADD(DAY, -ah.substractDay, vDate) >= CURDATE() + AND IF(TIMESTAMPADD(DAY, -ah.substractDay, vDate) = CURDATE(), ah.maxHour > HOUR(NOW()), TRUE) + ORDER BY ( + (ah.weekDay IS NOT NULL) + + (ah.agencyFk IS NOT NULL) + + ((ah.provinceFk IS NOT NULL) * 3) + ) DESC + LIMIT 1; + + + FETCH vCur INTO vAgency; + END WHILE; + + CLOSE vCur; + + SELECT * FROM tmp.agencyModeWarehouseList; + DROP TEMPORARY TABLE tmp.agencyModeWarehouseList; +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 `agencyHourListGetShipped` */; +/*!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 `agencyHourListGetShipped`(vDate DATE, vAddress INT, vAgency INT) +BEGIN + CALL vn.agencyHourGetShipped(vDate, vAddress, vAgency); + + SELECT * FROM tmp.agencyHourGetShipped; + + DROP TEMPORARY TABLE IF EXISTS tmp.agencyHourGetShipped; + +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 `agencyListAvailable` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52263,10 +52471,11 @@ BEGIN ) SELECT vInvoice, pgcFk, - SUM(taxableBase), + SUM(taxableBase) as BASE, SUM(tax) FROM tmp.ticketTax - GROUP BY pgcFk; + GROUP BY pgcFk + HAVING BASE; DROP TEMPORARY TABLE tmp.ticket; DROP TEMPORARY TABLE tmp.ticketTax; @@ -52299,13 +52508,13 @@ BEGIN origin, reference, name, - 'in', - 'out', - @a := @a + IFNULL('in',0) - IFNULL('out',0) as balance + `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', + b.quantity as `in`, + NULL as `out`, IF(tr.isReceived != FALSE,3, IF(tr.isDelivered,1,0)) as alertLevel, s.name as name, e.ref as reference, @@ -52322,8 +52531,8 @@ BEGIN UNION ALL SELECT tr.shipped as date, - NULL as 'in', - b.quantity as 'out', + NULL as `in`, + b.quantity as `out`, IF(tr.isReceived != FALSE,3, IF(tr.isDelivered,1,0)) as alertLevel, s.name as name, e.ref as reference, @@ -52343,8 +52552,8 @@ BEGIN UNION ALL SELECT t.shipped as date, - NULL as 'in', - s.quantity as 'out', + NULL as `in`, + s.quantity as `out`, IF(t.shipped < vCurdate,3,IF(t.shipped > vCurdate, 0, IFNULL(ts.alertLevel,0))) as alertLevel, t.nickname as name, t.refFk as reference, @@ -52357,7 +52566,7 @@ BEGIN AND s.itemFk = vItemId AND vWarehouse =t.warehouseFk ) AS itemDiary - ORDER BY date, alertLevel, 'in' DESC; + ORDER BY date, alertLevel, `in` DESC; END ;; DELIMITER ; @@ -52365,6 +52574,52 @@ 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 `itemLastEntries` */; +/*!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 `itemLastEntries`(vItem INT, vDays DATE) +BEGIN + SELECT + w.id AS Warehouse, + tr.landed, + b.entryFk, + b.isIgnored, + b.price2, + b.price3, + b.stickers, + b.packing, + b.grouping, + i.stems, + b.quantity, + b.buyingValue, + b.packageFk , + s.id AS Supplier +FROM itemType it + RIGHT JOIN (entry e + LEFT JOIN supplier s ON s.id = e.supplierFk + RIGHT JOIN buy b ON b.entryFk = e.id + LEFT JOIN item i ON i.id = b.itemFk + LEFT JOIN ink ON ink.id = i.inkFk + LEFT JOIN travel tr ON tr.id = e.travelFk + LEFT JOIN warehouse w ON w.id = tr.warehouseInFk + LEFT JOIN origin o ON o.id = i.originFk + ) ON it.id = i.typeFk + LEFT JOIN edi.ekt ek ON b.ektFk = ek.id +WHERE b.itemFk = vItem And tr.shipped > vDays + ORDER BY tr.landed DESC , b.id DESC; +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 `itemPlacementSave` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54546,7 +54801,7 @@ proc: BEGIN SELECT * FROM ( SELECT pf.itemFk, pf.grouping, pf.packing, pf.box, pf.rate2, pf.rate3, aho.warehouseFk FROM priceFixed pf - JOIN tmp.agencyHourOffer aho ON pf.warehouseFk = aho.warehouseFk OR pf.warehouseFk = 0 + 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 @@ -54669,7 +54924,7 @@ proc: BEGIN 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.agencyHourOffer aho ON aho.warehouseFk = awb.warehouseFk + JOIN tmp.agencyHourGetShipped aho ON aho.warehouseFk = awb.warehouseFk AND WEEKDAY(aho.landed) = awb.weekDay HAVING cost <> 0 LIMIT 1; @@ -54685,7 +54940,7 @@ proc: BEGIN INSERT INTO tmp.ticketComponent SELECT tcb.warehouseFk, tcb.itemFk, vExtraFreightComponent, tcb.base * (IFNULL(pe.percentage,pp.percentage)/100) FROM tmp.ticketComponentBase tcb - JOIN tmp.agencyHourOffer aho ON aho.warehouseFk = tcb.warehouseFk + 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 @@ -54791,30 +55046,43 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketComponentMakeUpdate`( vTicketFk INT, + vClientFk INT, vAgencyModeFk INT, vAddressFk INT, vWarehouseFk INT, vShipped DATETIME, vLanded DATE, vIsDeleted BOOLEAN, + vHasToBeUnrouted BOOLEAN, vOption INT) BEGIN /** - * Devuelve las diferencias de precio - * de los movimientos de un ticket. + * Calcula los componentes de un ticket + * y los actualiza con los nuevos datos. * * @param vTicketFk Id del ticket + * @param vClientFk Id del cliente + * @param vAgencyModeFk Id del tipo de agencia + * @param vAddressFk Id del consignatario + * @param vWarehouseFk Id del almacén + * @param vShipped Fecha de salida + * @param vLanded Fecha de llegada + * @param vIsDeleted Marcado como eliminado + * @param vHasToBeUnrouted Marcado para sacar de ruta + * @param vOption Id de la acción ticketUpdateAction */ - CALL vn.ticketComponentPreview (vLanded, vAddressFk, vAgencyModeFk, vTicketFk); + CALL vn.ticketComponentPreview (vTicketFk, vLanded, vAddressFk, vAgencyModeFk, vWarehouseFk); CALL vn.ticketComponentUpdate ( vTicketFk, + vClientFk, vAgencyModeFk, vAddressFk, vWarehouseFk, vShipped, vLanded, vIsDeleted, + vHasToBeUnrouted, vOption ); @@ -54838,37 +55106,34 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentPreview`( + vTicketFk INT, vDate DATE, vAddressFk INT, vAgencyModeFk INT, - vTicketFk INT) + vWarehouseFk SMALLINT) BEGIN /** * Devuelve un listado previo de * componentes para 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 vTicketFk Id del ticket + * @param vWarehouseFk Id del almacén */ - DECLARE vWarehouseFk SMALLINT; DECLARE vAgencyFk INT; DECLARE vShipped DATE; DECLARE vBuyOrderItem INT DEFAULT 100; - SELECT warehouseFk INTO vWarehouseFK - FROM ticket - WHERE id = vTicketFk; - SELECT agencyFk INTO vAgencyFk FROM agencyMode WHERE id = vAgencyModeFk; - CALL agencyHourOffer(vDate, vAddressFk, vAgencyFk); + CALL agencyHourGetShipped(vDate, vAddressFk, vAgencyFk); SELECT shipped INTO vShipped - FROM tmp.agencyHourOffer + FROM tmp.agencyHourGetShipped WHERE warehouseFk = vWarehouseFK; CALL buyUltimate(vWarehouseFK, vShipped); @@ -54899,7 +55164,7 @@ BEGIN SET @shipped = vShipped; DROP TEMPORARY TABLE - tmp.agencyHourOffer, + tmp.agencyHourGetShipped, tmp.buyUltimate, tmp.ticketLot; @@ -54923,18 +55188,23 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentPriceDifference`( - vDate DATE, + vTicketFk INT, + vDate DATE, vAddressFk INT, vAgencyModeFk INT, - vTicketFk 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(vDate, vAddressFk, vAgencyModeFk, vTicketFk); + CALL vn.ticketComponentPreview(vTicketFk, vDate, vAddressFk, vAgencyModeFk, vWarehouseFk); SELECT s.itemFk, @@ -54981,14 +55251,31 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentUpdate`( vTicketFk INT, + vClientFk INT, vAgencyModeFk INT, vAddressFk INT, vWarehouseFk INT, vShipped DATETIME, vLanded DATE, vIsDeleted BOOLEAN, + vHasToBeUnrouted BOOLEAN, vOption INT) BEGIN +/** + * Actualiza un ticket y sus componentes + * con los nuevos datos. + * + * @param vTicketFk Id del ticket + * @param vClientFk Id del cliente + * @param vAgencyModeFk Id del tipo de agencia + * @param vAddressFk Id del consignatario + * @param vWarehouseFk Id del almacén + * @param vShipped Fecha de salida + * @param vLanded Fecha de llegada + * @param vIsDeleted Marcado como eliminado + * @param vHasToBeUnrouted Marcado para sacar de ruta + * @param vOption Id de la acción ticketUpdateAction + */ DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN ROLLBACK; @@ -54999,6 +55286,7 @@ BEGIN UPDATE ticket t SET + t.clientFk = vClientFk, t.agencyModeFk = vAgencyModeFk, t.addressFk = vAddressFk, t.warehouseFk = vWarehouseFk, @@ -55008,6 +55296,11 @@ BEGIN WHERE t.id = vTicketFk; + IF vHasToBeUnrouted THEN + UPDATE ticket t SET t.routeFk = NULL + WHERE t.id = vTicketFk; + END IF; + IF vOption <> 8 THEN DROP TEMPORARY TABLE IF EXISTS tmp.sale; CREATE TEMPORARY TABLE tmp.sale @@ -55020,7 +55313,6 @@ BEGIN DROP TEMPORARY TABLE tmp.sale; END IF; - COMMIT; END ;; DELIMITER ; @@ -56051,7 +56343,7 @@ 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 `ticketVolume` */; +/*!50003 DROP PROCEDURE IF EXISTS `ticketVolumekk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -56061,7 +56353,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketVolume`(IN vTicketId INT) +CREATE DEFINER=`root`@`%` PROCEDURE `ticketVolumekk`(IN vTicketId INT) BEGIN DECLARE vWarehouseId INTEGER; DECLARE vShippedDate DATE; @@ -56377,8 +56669,10 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControlNonDays`() BEGIN - SELECT userFk, date(timed) as Fecha , MAX(`order`) as maxOrder, c.name as worker + SELECT wtc.userFk, date(wtc.timed) as Fecha , MAX(wtc.`order`) as maxOrder, c.name as worker, wb.workerCode as Boss FROM workerTimeControl wtc + JOIN worker w ON w.userFk = wtc.userFk + LEFT JOIN worker wb ON wb.id = w.bossFk JOIN client c ON c.id = wtc.userFk WHERE timed < CURDATE() GROUP BY userFk, date(timed) @@ -56779,7 +57073,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=323068 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=326843 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -57117,7 +57411,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=344499 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=348296 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -63194,7 +63488,7 @@ CREATE TABLE `cdr` ( KEY `dstchannel` (`dst_channel`), KEY `disposition` (`disposition`), KEY `src` (`src`) -) ENGINE=MyISAM AUTO_INCREMENT=198191 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=199241 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -63973,7 +64267,7 @@ CREATE TABLE `cache_calc` ( KEY `cache_id` (`cache_id`), KEY `cacheName` (`cacheName`), KEY `expires` (`expires`) -) ENGINE=InnoDB AUTO_INCREMENT=124348 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=128144 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -65742,7 +66036,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=10764998 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=10910658 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 */ ; @@ -66478,7 +66772,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=13010 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13011 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -66529,7 +66823,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=1402020 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1413533 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -66628,7 +66922,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=8633130 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8699865 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 */ ; @@ -66975,7 +67269,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=217397 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDB AUTO_INCREMENT=219991 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67010,7 +67304,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=1265990 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1274258 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67030,7 +67324,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=2756759 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2778507 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67055,7 +67349,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=1804929 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1814096 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67075,7 +67369,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=2636343 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2654162 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -72179,7 +72473,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `company` AS select `e`.`id` AS `id`,`e`.`abbreviation` AS `code`,`e`.`Id_Proveedores_account` AS `supplierAccountFk`,`e`.`gerente_id` AS `workerManagerFk`,`e`.`digito_factura` AS `sage200Company`,`e`.`CodigoEmpresa` AS `companyCode` from `vn2008`.`empresa` `e` */; +/*!50001 VIEW `company` AS select `e`.`id` AS `id`,`e`.`abbreviation` AS `code`,`e`.`Id_Proveedores_account` AS `supplierAccountFk`,`e`.`gerente_id` AS `workerManagerFk`,`e`.`digito_factura` AS `sage200Company`,`e`.`footnotes` AS `footnotes`,`e`.`phytosanitary` AS `phytosanitary`,`e`.`CodigoEmpresa` AS `companyCode` from `vn2008`.`empresa` `e` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -72575,7 +72869,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeInsuranceOut` AS select `p`.`received` AS `received`,sum(`p`.`divisa`) AS `divisa`,(sum(`p`.`divisa`) / sum(`p`.`amount`)) AS `rate` from (`vn`.`payment` `p` join `vn`.`exchangeInsurance` `ei` on((`ei`.`id` = `p`.`exchangeInsuranceFk`))) group by `p`.`received` */; +/*!50001 VIEW `exchangeInsuranceOut` AS select `p`.`received` AS `received`,sum(`p`.`divisa`) AS `divisa`,(sum(`p`.`divisa`) / sum(`p`.`amount`)) AS `rate` from (`vn`.`payment` `p` join `vn`.`bank` `b` on((`b`.`id` = `p`.`bankFk`))) where ((`p`.`currencyFk` = 2) and (`b`.`cash` = 0) and (`p`.`supplierFk` <> 2213)) group by `p`.`received` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -75060,4 +75354,4 @@ USE `stock`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-05-28 13:41:46 +-- Dump completed on 2018-06-05 12:42:12 diff --git a/services/db/install/dump/fixtures.sql b/services/db/install/dump/fixtures.sql index 16a9c0b7e..ccdf72114 100644 --- a/services/db/install/dump/fixtures.sql +++ b/services/db/install/dump/fixtures.sql @@ -328,16 +328,16 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des INSERT INTO `vn`.`ticketTracking`(`id`, `ticketFk`, `stateFk`, `workerFk`, `created`) VALUES - (1, 1, 1, 5, CURDATE()), - (2, 2, 2, 5, CURDATE()), - (3, 3, 3, 5, CURDATE()), - (4, 4, 1, 5, CURDATE()), - (5, 5, 2, 18, CURDATE()), - (6, 6, 3, 18, CURDATE()), - (7, 7, 1, 18, CURDATE()), - (8, 8, 2, 19, CURDATE()), - (9, 9, 3, 19, CURDATE()), - (10, 10, 3, 19, CURDATE()), + (1, 1, 13, 5, CURDATE()), + (2, 2, 15, 5, CURDATE()), + (3, 3, 16, 5, CURDATE()), + (4, 4, 13, 5, CURDATE()), + (5, 5, 15, 18, CURDATE()), + (6, 6, 16, 18, CURDATE()), + (7, 7, 13, 18, CURDATE()), + (8, 8, 15, 19, CURDATE()), + (9, 9, 16, 19, CURDATE()), + (10, 10, 13, 19, CURDATE()), (11, 11, 3, 19, CURDATE()), (12, 12, 3, 19, CURDATE()), (13, 13, 3, 19, CURDATE()), @@ -346,9 +346,9 @@ INSERT INTO `vn`.`ticketTracking`(`id`, `ticketFk`, `stateFk`, `workerFk`, `crea (16, 16, 1, 19, CURDATE()), (17, 17, 1, 19, CURDATE()), (18, 18, 1, 19, CURDATE()), - (19, 19, 1, 19, CURDATE()), - (20, 20, 1, 19, CURDATE()), - (21, 21, 1, 19, CURDATE()); + (19, 19, 13, 19, CURDATE()), + (20, 20, 15, 19, CURDATE()), + (21, 21, 16, 19, CURDATE()); INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`) VALUES @@ -631,12 +631,12 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`) ( 4, 4), ( 5, 6); -INSERT INTO `vn`.`travel`(`id`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`) +INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`) VALUES - ( 1, CURDATE(), 1, 2, 1, 100.00, 1000), - ( 2, CURDATE(), 1, 2, 1, 150, 2000), - ( 3, CURDATE(), 1, 2, 1, 0.00, 0.00), - ( 4, CURDATE(), 1, 2, 1, 50.00, 500); + ( 1, CURDATE(), CURDATE(), 1, 2, 1, 100.00, 1000), + ( 2, CURDATE(), CURDATE(), 1, 2, 1, 150, 2000), + ( 3, CURDATE(), CURDATE(), 1, 2, 1, 0.00, 0.00), + ( 4, CURDATE(), CURDATE(), 1, 2, 1, 50.00, 500); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`) VALUES diff --git a/services/item/common/models/warehouse.json b/services/item/common/models/warehouse.json deleted file mode 100644 index d52991ed6..000000000 --- a/services/item/common/models/warehouse.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "Warehouse", - "base": "VnModel", - "options": { - "mysql": { - "table": "warehouse", - "database": "vn" - } - }, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" - }, - "name": { - "type": "String", - "required": true - } - }, - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] - } diff --git a/services/loopback/common/methods/client/createWithUser.js b/services/loopback/common/methods/client/createWithUser.js index 59aa2c8e8..9b56d7c29 100644 --- a/services/loopback/common/methods/client/createWithUser.js +++ b/services/loopback/common/methods/client/createWithUser.js @@ -40,6 +40,7 @@ module.exports = function(Self) { street: data.street, city: data.city, provinceFk: data.provinceFk, + countryFk: data.countryFk, isEqualizated: data.isEqualizated }; newClient = await Self.create(client); diff --git a/services/loopback/common/methods/client/filter.js b/services/loopback/common/methods/client/filter.js deleted file mode 100644 index bb1288630..000000000 --- a/services/loopback/common/methods/client/filter.js +++ /dev/null @@ -1,61 +0,0 @@ -module.exports = function(Client) { - Client.installMethod('filter', filterClients); - - function filterClients(params) { - let filters = { - where: {}, - skip: (params.page - 1) * params.size, - limit: params.size - }; - - delete params.page; - delete params.size; - - if (params.search) { - filters.where.and = [ - { - or: [ - {id: params.search}, - {name: {regexp: params.search}} - ] - } - ]; - delete params.search; - } - - if (params.phone) { - let phones = [ - {phone: params.phone}, - {mobile: params.phone} - ]; - if (filters.where.and) { - filters.where.and.push( - { - or: phones - } - ); - } else { - filters.where.or = phones; - } - delete params.phone; - } - - let properties = Object.keys(params); - if (properties.length) { - properties.forEach( - property => { - let propertyToBeEqual = (property === 'postcode' || property === 'fi' || property === 'id'); - if (filters.where.and) { - let filter = {}; - filter[property] = propertyToBeEqual ? params[property] : {regexp: params[property]}; - filters.where.and.push(filter); - } else { - filters.where[property] = propertyToBeEqual ? params[property] : {regexp: params[property]}; - } - } - ); - } - - return filters; - } -}; diff --git a/services/loopback/common/methods/item/clone.js b/services/loopback/common/methods/item/clone.js index 4846a4825..0919fa602 100644 --- a/services/loopback/common/methods/item/clone.js +++ b/services/loopback/common/methods/item/clone.js @@ -47,9 +47,10 @@ module.exports = Self => { FROM vn.itemBotanical ib WHERE itemFk = ?`; promises.push(Self.rawSql(createBotanical, [newItem.id, origin.id])); - let createTags = `INSERT INTO vn.itemTag (itemFk, tagFk, value, priority) - SELECT ?, tagFk, value, priority - FROM vn.itemTag WHERE itemFk = ?`; + let createTags = `INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT ?, i.tagFk, i.value,i.priority + FROM vn.itemTag i WHERE i.itemFk = ? + ON DUPLICATE KEY UPDATE value = i.value, priority = i.priority`; promises.push(Self.rawSql(createTags, [newItem.id, origin.id])); let createTax = `REPLACE INTO vn.itemTaxCountry (itemFk, countryFk, taxClassFk) diff --git a/services/loopback/common/methods/item/filter.js b/services/loopback/common/methods/item/filter.js deleted file mode 100644 index 3f2273f97..000000000 --- a/services/loopback/common/methods/item/filter.js +++ /dev/null @@ -1,62 +0,0 @@ -module.exports = Self => { - Self.installMethod('filter', filterParams); - - function filterParams(params) { - let filter = { - where: {}, - skip: (params.page - 1) * params.size, - limit: params.size, - order: params.order || 'name ASC', // name, relevancy DESC - include: [ - {relation: 'itemType', - scope: { - fields: ['name', 'workerFk'], - include: { - relation: 'worker', - fields: ['firstName', 'name'] - } - } - }, - {relation: 'origin'}, - {relation: 'ink'}, - {relation: 'producer'}, - {relation: 'intrastat'}, - {relation: 'expence'} - ] - }; - - delete params.page; - delete params.size; - delete params.order; - - if (params.search) { - filter.where.and = [ - { - or: [ - {id: params.search}, - {name: {regexp: params.search}} - ] - } - ]; - delete params.search; - } - - if (params.itemSize) { - params.size = params.itemSize; - delete params.itemSize; - } - - Object.keys(params).forEach( - key => { - if (filter.where.and) { - let filter = {}; - filter[key] = (key === 'description' || key === 'name') ? {regexp: params[key]} : params[key]; - filter.where.and.push(filter); - } else { - filter.where[key] = (key === 'description' || key === 'name') ? {regexp: params[key]} : params[key]; - } - } - ); - return filter; - } -}; diff --git a/services/loopback/common/methods/item/getDiary.js b/services/loopback/common/methods/item/getDiary.js new file mode 100644 index 000000000..df4176713 --- /dev/null +++ b/services/loopback/common/methods/item/getDiary.js @@ -0,0 +1,24 @@ +module.exports = Self => { + Self.remoteMethod('getDiary', { + description: 'Returns the ', + accessType: 'READ', + accepts: [{ + arg: 'params', + type: 'object', + description: 'itemFk, warehouseFk' + }], + returns: { + arg: 'diary', + root: true + }, + http: { + path: `/getDiary`, + verb: 'GET' + } + }); + + Self.getDiary = async params => { + let [diary] = await Self.rawSql(`CALL vn.itemDiary(?, ?)`, [params.itemFk, params.warehouseFk]); + return diary; + }; +}; diff --git a/services/loopback/common/methods/sale/moveToTicket.js b/services/loopback/common/methods/sale/moveToTicket.js new file mode 100644 index 000000000..45b7f49df --- /dev/null +++ b/services/loopback/common/methods/sale/moveToTicket.js @@ -0,0 +1,35 @@ +module.exports = Self => { + Self.remoteMethod('moveToTicket', { + description: 'Change the state of a ticket', + accessType: '', + accepts: [{ + arg: 'params', + type: 'object', + required: true, + description: '[sales IDs], newTicketFk, actualTicketFk', + http: {source: 'body'} + }], + returns: { + type: 'string', + root: true + }, + http: { + path: `/moveToTicket`, + verb: 'post' + } + }); + + Self.moveToTicket = 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`); + + let newTicketIsEditable = await Self.app.models.Ticket.isEditable(params.newTicketFk); + if (!newTicketIsEditable) + 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}, {ticketFk: params.newTicketFk}); + } + }; +}; diff --git a/services/loopback/common/methods/sale/removes.js b/services/loopback/common/methods/sale/removes.js new file mode 100644 index 000000000..24c8e7783 --- /dev/null +++ b/services/loopback/common/methods/sale/removes.js @@ -0,0 +1,31 @@ +module.exports = Self => { + Self.remoteMethod('removes', { + description: 'Change the state of a ticket', + accessType: '', + accepts: [{ + arg: 'params', + type: 'object', + required: true, + description: '[sales IDs], actualTicketFk', + http: {source: 'body'} + }], + returns: { + type: 'string', + root: true + }, + http: { + path: `/removes`, + verb: 'post' + } + }); + + Self.removes = 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.destroyById(params.sales[i].id); + } + }; +}; diff --git a/services/loopback/common/methods/ticket/deleted.js b/services/loopback/common/methods/ticket/deleted.js new file mode 100644 index 000000000..36bffaf95 --- /dev/null +++ b/services/loopback/common/methods/ticket/deleted.js @@ -0,0 +1,25 @@ +module.exports = Self => { + Self.remoteMethod('deleted', { + description: 'Sets the isDeleted value of a ticket to 1', + accessType: '', + accepts: [{ + arg: 'ticketFk', + type: 'Object', + required: true, + description: 'TicketFk', + http: {source: 'body'} + }], + returns: { + type: 'string', + root: true + }, + http: { + path: `/deleted`, + verb: 'post' + } + }); + + Self.deleted = async params => { + return await Self.app.models.Ticket.update({id: params.id}, {isDeleted: '1'}); + }; +}; diff --git a/services/loopback/common/methods/ticket/filter.js b/services/loopback/common/methods/ticket/filter.js deleted file mode 100644 index 8c0ba8c52..000000000 --- a/services/loopback/common/methods/ticket/filter.js +++ /dev/null @@ -1,87 +0,0 @@ -module.exports = Self => { - Self.installMethod('filter', filterParams); - - function filterParams(params) { - let filters = { - where: {}, - skip: (params.page - 1) * params.size, - limit: params.size, - order: params.order || 'created DESC', - include: [ - { - relation: 'address', - scope: { - fields: ['provinceFk'], - include: { - relation: 'province', - scope: { - fields: ['name'] - } - } - } - }, { - relation: 'warehouse', - scope: { - fields: ['name'] - } - }, { - relation: 'agencyMode', - scope: { - fields: ['name'] - } - }, { - relation: 'tracking', - scope: { - fields: ['stateFk'], - include: { - relation: 'state', - scope: { - fields: ['name'] - } - } - } - }, { - relation: 'client', - scope: { - fields: ['salesPersonFk'], - include: { - relation: 'salesPerson', - scope: { - fields: ['name'] - } - } - } - } - ] - }; - - delete params.page; - delete params.size; - delete params.order; - - if (params.search) { - filters.where.and = [ - { - or: [ - {id: params.search}, - {name: {regexp: params.search}} - ] - } - ]; - delete params.search; - } - - Object.keys(params).forEach( - key => { - if (filters.where.and) { - let filter = {}; - filter[key] = (key === 'nickname') ? {regexp: params[key]} : params[key]; - filters.where.and.push(filter); - } else { - filters.where[key] = (key === 'nickname') ? {regexp: params[key]} : params[key]; - } - } - ); - return filters; - } -}; diff --git a/services/loopback/common/methods/ticket/isEditable.js b/services/loopback/common/methods/ticket/isEditable.js index 149a87ee1..a3968a315 100644 --- a/services/loopback/common/methods/ticket/isEditable.js +++ b/services/loopback/common/methods/ticket/isEditable.js @@ -21,7 +21,7 @@ module.exports = Self => { Self.isEditable = async ticketFk => { let state = await Self.app.models.TicketState.findOne({where: {ticketFk: ticketFk}, fields: 'alertLevel'}); - - return state != null && state.alertLevel == 0; + let exists = await Self.app.models.Ticket.findOne({where: {id: ticketFk}, fields: 'isDeleted'}); + return (exists && state == null && exists.isDeleted == 0) || (exists.isDeleted == 0 && state.alertLevel == 0); }; }; diff --git a/services/loopback/common/methods/ticket/specs/componentUpdate.spec.js b/services/loopback/common/methods/ticket/specs/componentUpdate.spec.js index fa096763f..6634708ec 100644 --- a/services/loopback/common/methods/ticket/specs/componentUpdate.spec.js +++ b/services/loopback/common/methods/ticket/specs/componentUpdate.spec.js @@ -4,7 +4,7 @@ describe('ticket componentUpdate()', () => { it('should call the componentUpdate method', done => { let data = { agencyModeFk: 1, - addressFk: 121, + addressFk: 121, warehouseFk: 1, shipped: Date.now(), landed: Date.now(), diff --git a/services/loopback/common/methods/ticket/threeLastActive.js b/services/loopback/common/methods/ticket/threeLastActive.js new file mode 100644 index 000000000..9ec1390ca --- /dev/null +++ b/services/loopback/common/methods/ticket/threeLastActive.js @@ -0,0 +1,35 @@ +module.exports = Self => { + Self.remoteMethod('threeLastActive', { + description: 'Returns the last three tickets of a client that have the alertLevel at 0 and the shiped day is gt today', + accessType: '', + accepts: [{ + arg: 'filter', + type: 'object', + required: true, + description: 'client id, ticketFk' + }], + returns: { + type: [this.modelName], + root: true + }, + http: { + path: `/threeLastActive`, + verb: 'GET' + } + }); + + Self.threeLastActive = async filter => { + console.log(filter); + let query = ` + SELECT t.id,t.shipped,a.name AS agencyName,w.name AS warehouseName + FROM vn.ticket t + JOIN vn.ticketState ts ON t.id = ts.ticketFk + JOIN vn.agencyMode a ON t.agencyModeFk = a.id + JOIN vn.warehouse w ON t.warehouseFk = w.id + WHERE t.shipped > CURDATE() AND t.clientFk = ? AND ts.alertLevel = 0 AND t.id <> ? + ORDER BY t.shipped + LIMIT 3`; + let result = await Self.rawSql(query, [filter.clientFk, filter.ticketFk]); + return result; + }; +}; diff --git a/services/loopback/common/models/client.js b/services/loopback/common/models/client.js index 667916de4..762cbe2f5 100644 --- a/services/loopback/common/models/client.js +++ b/services/loopback/common/models/client.js @@ -10,7 +10,6 @@ module.exports = Self => { require('../methods/client/card')(Self); require('../methods/client/createWithUser')(Self); require('../methods/client/listWorkers')(Self); - require('../methods/client/filter')(Self); require('../methods/client/hasCustomerRole')(Self); require('../methods/client/isValidClient')(Self); require('../methods/client/activeSalesPerson')(Self); diff --git a/services/loopback/common/models/item.js b/services/loopback/common/models/item.js index 1186c5ce3..5763f58d4 100644 --- a/services/loopback/common/models/item.js +++ b/services/loopback/common/models/item.js @@ -1,9 +1,9 @@ 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); Self.validatesPresenceOf('name', {message: 'Cannot be blank'}); Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'}); diff --git a/services/loopback/common/models/sale.js b/services/loopback/common/models/sale.js index 755cd432e..2d2aa22f5 100644 --- a/services/loopback/common/models/sale.js +++ b/services/loopback/common/models/sale.js @@ -3,4 +3,9 @@ module.exports = Self => { require('../methods/sale/saleComponentFilter')(Self); require('../methods/sale/priceDifference')(Self); require('../methods/sale/crudSale')(Self); + require('../methods/sale/moveToTicket')(Self); + require('../methods/sale/removes')(Self); +// require('../methods/sale/updateDiscount')(Self); +// require('../methods/sale/updatePrice')(Self); +// require('../methods/sale/updateQuantity')(Self); }; diff --git a/services/loopback/common/models/ticket.js b/services/loopback/common/models/ticket.js index a2897354c..a0a99a7ca 100644 --- a/services/loopback/common/models/ticket.js +++ b/services/loopback/common/models/ticket.js @@ -1,11 +1,14 @@ module.exports = Self => { require('../methods/ticket/changeTime')(Self); require('../methods/ticket/changeWorker')(Self); - require('../methods/ticket/filter')(Self); require('../methods/ticket/getVolume')(Self); require('../methods/ticket/getTotalVolume')(Self); require('../methods/ticket/summary')(Self); require('../methods/ticket/getTotal')(Self); require('../methods/ticket/getTaxes')(Self); require('../methods/ticket/componentUpdate')(Self); +// require('../methods/ticket/create')(Self); + require('../methods/ticket/isEditable')(Self); + require('../methods/ticket/threeLastActive')(Self); + require('../methods/ticket/deleted')(Self); };