Merge pull request '1490 - Don't update with empty value' (#274) from 1490-ticket_update_price into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-by: Carlos Jimenez <carlosjr@verdnatura.es>
This commit is contained in:
Carlos Jimenez Ruiz 2020-05-25 12:56:42 +00:00
commit 65432ef1ed
3 changed files with 9 additions and 7 deletions

View File

@ -43,6 +43,9 @@ class Controller extends Component {
updateDiscount() {
let salesIds = [];
let modified = false;
if (!this.newDiscount) return;
for (let i = 0; i < this.edit.length; i++) {
if (this.newDiscount != this.edit[0].discount || this.bulk || !this.newDiscount) {
salesIds.push(this.edit[i].id);
@ -57,7 +60,6 @@ class Controller extends Component {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
this.clearDiscount();
modified = false;
// this.vnTicketSale.$scope.model.refresh();
}).catch(e => {
this.vnApp.showError(e.message);
});

View File

@ -225,8 +225,7 @@
<vn-input-number
vn-focus
label="Price"
ng-model="$ctrl.editedPrice"
type="text"
ng-model="$ctrl.newPrice"
step="0.01"
on-change="$ctrl.updatePrice()"
suffix="€">

View File

@ -287,7 +287,7 @@ class Controller extends Section {
showEditPricePopover(event, sale) {
if (!this.isEditable) return;
this.sale = sale;
this.editedPrice = this.sale.price;
this.newPrice = this.sale.price;
this.edit = {
ticketFk: this.ticket.id,
id: sale.id,
@ -298,8 +298,9 @@ class Controller extends Section {
}
updatePrice() {
if (this.editedPrice != this.sale.price) {
this.$http.post(`Sales/${this.edit.id}/updatePrice`, {newPrice: this.editedPrice}).then(res => {
if (this.newPrice && this.newPrice != this.sale.price) {
const query = `Sales/${this.edit.id}/updatePrice`;
this.$http.post(query, {newPrice: this.newPrice}).then(res => {
this.sale.price = res.data.price;
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
@ -313,7 +314,7 @@ class Controller extends Section {
}
updateNewPrice() {
this.newPrice = this.sale.quantity * this.editedPrice - ((this.sale.discount * (this.sale.quantity * this.editedPrice)) / 100);
this.newPrice = this.sale.quantity * this.newPrice - ((this.sale.discount * (this.sale.quantity * this.newPrice)) / 100);
}
showEditDiscountPopover(event, sale) {