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