+
+
+
+
+ |
{
+ this.sales = res.data;
+ this.getTaxes();
+ });
+ }
+ $onChanges() {
+ if (this.ticket)
+ this.getSales(this.ticket.clientFk);
+ }
onMoreOpen() {
let options = this.moreOptions.filter(o => o.always || this.isChecked);
this.$.moreButton.data = options;
@@ -34,7 +41,7 @@ class Controller extends FilterTicketList {
}
getSubTotal() {
- let sales = this.$.index.model.instances;
+ let sales = this.sales;
this.subTotal = 0.00;
sales.forEach(sale => {
@@ -60,7 +67,7 @@ class Controller extends FilterTicketList {
}
get isChecked() {
- let data = this.$.index.model.instances;
+ let data = this.sales;
if (data)
for (let instance of data)
if (instance.checked)
@@ -71,7 +78,7 @@ class Controller extends FilterTicketList {
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)
@@ -144,7 +151,7 @@ class Controller extends FilterTicketList {
removeInstances(instances) {
for (let i = instances.length - 1; i >= 0; i--) {
- this.$.index.model.instances.splice(instances[i].instance, 1);
+ this.sales.splice(instances[i].instance, 1);
}
}
@@ -186,7 +193,10 @@ 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.id}, {absolute: true});
+ window.open(url, '_blank');
+ this.$.transfer.hide();
+ this.getSales();
});
}
@@ -228,7 +238,7 @@ class Controller extends FilterTicketList {
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();
@@ -253,19 +263,21 @@ class Controller extends FilterTicketList {
}
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();
});
}
@@ -290,18 +302,6 @@ class Controller extends FilterTicketList {
this.$.edit.hide();
}*/
-/**
- * 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);
- }
- }
-
/**
* Unmark sale as reserved
*/
@@ -321,7 +321,7 @@ class Controller extends FilterTicketList {
let params = {sales: sales, ticketFk: this.ticket.id, reserved: reserved};
this.$http.post(`/ticket/api/Sales/reserve`, params).then(() => {
- this.$.index.accept();
+ this.getSales();
});
}
}
diff --git a/client/ticket/src/sale/locale/es.yml b/client/ticket/src/sale/locale/es.yml
index d98539709..bfeb9cd37 100644
--- a/client/ticket/src/sale/locale/es.yml
+++ b/client/ticket/src/sale/locale/es.yml
@@ -10,4 +10,5 @@ Move to ticket: Mover a ticket
New ticket: Nuevo ticket
Edit price: Editar precio
You are going to delete lines of the ticket: Vas a borrar lineas del ticket
-Continue anyway?: ¿Estás seguro?
\ No newline at end of file
+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
\ No newline at end of file
diff --git a/client/ticket/src/sale/style.scss b/client/ticket/src/sale/style.scss
index 24cce9966..abff21c8c 100644
--- a/client/ticket/src/sale/style.scss
+++ b/client/ticket/src/sale/style.scss
@@ -1,87 +1,88 @@
@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;
+ }
+ & i {
+ padding-top: 0.2em;
+ font-size: 1.8em;
+ }
}
-}
-
-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;
+ }
}
-
- 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/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/models/ticket.js b/services/loopback/common/models/ticket.js
index 2c26b92f8..62c3fb24f 100644
--- a/services/loopback/common/models/ticket.js
+++ b/services/loopback/common/models/ticket.js
@@ -12,5 +12,6 @@ module.exports = 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);
};
|