diff --git a/client/ticket/src/sale/index.html b/client/ticket/src/sale/index.html
index 9e7c48f49..74d8e7782 100644
--- a/client/ticket/src/sale/index.html
+++ b/client/ticket/src/sale/index.html
@@ -73,27 +73,36 @@
{{::sale.itemFk}}
|
- {{sale.quantity}} |
-
- {{sale.price | currency:'€':2}} |
- {{sale.discount}} % |
- {{sale.quantity * sale.price | currency:'€':2}} |
-
+
+
+ {{sale.price | currency:'€':2}}
+ |
+
+ {{sale.price | currency:'€':2}}
+ |
+
+ {{sale.discount}} %
+ |
+
+ {{sale.discount}} %
+ |
+ {{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency:' €':2}} |
No results |
@@ -166,35 +175,66 @@
-
-
+
+
-
{{$ctrl.client.name}}
-
-
+ model="$ctrl.editedPrice"
+ type="number"
+ on-change="$ctrl.updatePrice()">
+
+ €
+
-
-
-
-
+
+
New price
+
{{($ctrl.sale.quantity * $ctrl.sale.price)
+ - (($ctrl.sale.discount * ($ctrl.sale.quantity * $ctrl.editedPrice))/100)
+ | currency:' €':2}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -232,11 +272,11 @@
ng-click="$ctrl.moveLines($ctrl.moveToTicketFk)">
-
+ ng-click="$ctrl.linesToNewTicket()">
+
diff --git a/client/ticket/src/sale/index.js b/client/ticket/src/sale/index.js
index 29532e771..2369ca25e 100644
--- a/client/ticket/src/sale/index.js
+++ b/client/ticket/src/sale/index.js
@@ -3,15 +3,17 @@ import FilterTicketList from '../filter-ticket-list';
import './style.scss';
class Controller extends FilterTicketList {
- constructor($scope, $timeout, $stateParams, $http, $state, vnApp) {
+ 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"}
@@ -28,7 +30,7 @@ class Controller extends FilterTicketList {
this.subTotal = 0.00;
sales.forEach(sale => {
- this.subTotal += sale.quantity * sale.price;
+ this.subTotal += (sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price)) / 100);
});
}
@@ -87,7 +89,7 @@ class Controller extends FilterTicketList {
let params = {ticketFk: this.$state.params.id, stateFk: value};
this.$http.post(`/ticket/api/TicketTrackings/changeState`, params).then(() => {
this.card.reload();
- this.vnApp.showMessage(this.translate.instant('Data saved'));
+ this.vnApp.showSuccess(this.translate.instant('Data saved!'));
});
}
@@ -150,12 +152,22 @@ class Controller extends FilterTicketList {
});
}
- /* newTicket() {
- let params = [this.ticket.clientFk, this.ticket.warehouseFk, this.ticket.companyFk, this.ticket.addressFk, this.ticket.agencyModeFk, null];
- this.$http.post(`/ticket/api/Tickets/create`, params).then(res => {
- console.log(res);
+ // In Progress
+ linesToNewTicket() {
+ let ticket = {
+ oldTicketFk: this.ticket.id,
+ clientFk: this.ticket.clientFk,
+ addressFk: this.ticket.addressFk,
+ agencyModeFk: this.ticket.agencyModeFk,
+ warehouseFk: this.ticket.warehouseFk
+ };
+
+ let sales = this.getCheckedLines();
+
+ this.$http.post(`/api/Sales/MoveToNewTicket`, {ticket: ticket, sales: sales}).then(res => {
+ this.goToTicket(res.data.id);
});
- }*/
+ }
goToTicket(ticketID) {
this.$state.go("ticket.card.sale", {id: ticketID});
@@ -166,6 +178,12 @@ class Controller extends FilterTicketList {
this.$.index.model.instances.splice(instances[i].instance, 1);
}
}
+ // Slesperson Mana
+ getManaSalespersonMana() {
+ this.$http.get(`/api/Tickets/${this.$state.params.id}/getSalesPersonMana`).then(res => {
+ this.mana = res.data;
+ });
+ }
// Item Descriptor
showDescriptor(event, itemFk) {
this.$.descriptor.itemFk = itemFk;
@@ -177,39 +195,65 @@ class Controller extends FilterTicketList {
this.$.popover.relocate();
}
- // Ticket Create
- showticketCreate() {
- console.log(this);
- this.$.newTicket.show();
+ // Edit Line
+ showEditPricePopover(event, sale) {
+ this.sale = sale;
+ this.editedPrice = this.sale.price;
+ this.edit = {
+ ticketFk: this.ticket.id,
+ id: sale.id,
+ quantity: sale.quantity
+ };
+ this.$.editPricePopover.parent = event.target;
+ this.$.editPricePopover.show();
}
- onResponse(response) {
- if (response === 'ACCEPT') {
- let newTicketID = this.$.newTicket.dialog.createTicket();
- console.log(newTicketID);
+ 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();
+ });
}
- }
- // Edit Line
- _getworkerMana() {
- this.$http.get(`/api/WorkerManas/getCurrentWorkerMana`).then(res => {
- this.workerMana = res.data[0].mana;
- });
+ this.$.editPricePopover.hide();
}
showEditPopover(event, sale) {
this.sale = sale;
- this.edit = {
+ this.edit = [{
+ ticketFk: this.ticket.id,
id: sale.id,
quantity: sale.quantity,
price: sale.price,
discount: sale.discount
- };
- this.$.edit.parent = event.target;
- this._getworkerMana();
- this.$.edit.show();
+ }];
+ this.$.editPopover.parent = event.target;
+ this.$.editPopover.show();
}
- updateLine() {
+ async showEditDialog() {
+ this.edit = this.getCheckedLines();
+ this.$.editDialog.show();
+ }
+
+ hideEditDialog() {
+ this.$.index.accept();
+ this.$.editDialog.hide();
+ }
+
+ hideEditPopover() {
+ this.$.index.accept();
+ 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();
+ });
+ }
+
+ /* 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;
@@ -228,12 +272,12 @@ class Controller extends FilterTicketList {
});
}
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({
@@ -245,6 +289,11 @@ class Controller extends FilterTicketList {
callback: this.unmarkAsReserved,
name: 'Unmark as reserved'}
);
+
+ this.moreOptions.push({
+ callback: this.showEditDialog,
+ name: 'Update discount'}
+ );
}
/**
@@ -294,7 +343,7 @@ class Controller extends FilterTicketList {
}
}
-Controller.$inject = ['$scope', '$timeout', '$state', '$http', 'vnApp'];
+Controller.$inject = ['$scope', '$timeout', '$state', '$http', 'vnApp', '$translate'];
ngModule.component('vnTicketSale', {
template: require('./index.html'),
diff --git a/client/ticket/src/sale/locale/es.yml b/client/ticket/src/sale/locale/es.yml
index 6860c643b..727be3a78 100644
--- a/client/ticket/src/sale/locale/es.yml
+++ b/client/ticket/src/sale/locale/es.yml
@@ -4,3 +4,8 @@ Delete ticket: Borrar ticket
Mark as reserved: Marcar como reservado
Unmark as reserved: Desmarcar como reservado
Update discount: Actualizar descuento
+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
diff --git a/client/ticket/src/sale/style.scss b/client/ticket/src/sale/style.scss
index 83d73bb2a..24cce9966 100644
--- a/client/ticket/src/sale/style.scss
+++ b/client/ticket/src/sale/style.scss
@@ -1,19 +1,47 @@
@import "colors";
vn-popover.edit {
-
& div.popover{
width: 200px;
}
& vn-horizontal.header{
background-color: $main-01;
- text-align: center;
-
& 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;
+ }
+}
+
+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-ticket-sale{
@@ -28,7 +56,7 @@ vn-popover.transfer{
min-width: 650px;
margin-bottom: 10px;
}
- & i {
+ & i {
padding-top: 0.2em;
font-size: 1.8em;
}
@@ -41,4 +69,19 @@ vn-dialog.ticket-create{
& 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
+ }
}
\ No newline at end of file