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
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-by: Carlos Jimenez <carlosjr@verdnatura.es>
This commit is contained in:
commit
65432ef1ed
|
@ -43,6 +43,9 @@ class Controller extends Component {
|
||||||
updateDiscount() {
|
updateDiscount() {
|
||||||
let salesIds = [];
|
let salesIds = [];
|
||||||
let modified = false;
|
let modified = false;
|
||||||
|
|
||||||
|
if (!this.newDiscount) return;
|
||||||
|
|
||||||
for (let i = 0; i < this.edit.length; i++) {
|
for (let i = 0; i < this.edit.length; i++) {
|
||||||
if (this.newDiscount != this.edit[0].discount || this.bulk || !this.newDiscount) {
|
if (this.newDiscount != this.edit[0].discount || this.bulk || !this.newDiscount) {
|
||||||
salesIds.push(this.edit[i].id);
|
salesIds.push(this.edit[i].id);
|
||||||
|
@ -57,7 +60,6 @@ class Controller extends Component {
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
this.clearDiscount();
|
this.clearDiscount();
|
||||||
modified = false;
|
modified = false;
|
||||||
// this.vnTicketSale.$scope.model.refresh();
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
this.vnApp.showError(e.message);
|
this.vnApp.showError(e.message);
|
||||||
});
|
});
|
||||||
|
|
|
@ -225,8 +225,7 @@
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
vn-focus
|
vn-focus
|
||||||
label="Price"
|
label="Price"
|
||||||
ng-model="$ctrl.editedPrice"
|
ng-model="$ctrl.newPrice"
|
||||||
type="text"
|
|
||||||
step="0.01"
|
step="0.01"
|
||||||
on-change="$ctrl.updatePrice()"
|
on-change="$ctrl.updatePrice()"
|
||||||
suffix="€">
|
suffix="€">
|
||||||
|
|
|
@ -287,7 +287,7 @@ class Controller extends Section {
|
||||||
showEditPricePopover(event, sale) {
|
showEditPricePopover(event, sale) {
|
||||||
if (!this.isEditable) return;
|
if (!this.isEditable) return;
|
||||||
this.sale = sale;
|
this.sale = sale;
|
||||||
this.editedPrice = this.sale.price;
|
this.newPrice = this.sale.price;
|
||||||
this.edit = {
|
this.edit = {
|
||||||
ticketFk: this.ticket.id,
|
ticketFk: this.ticket.id,
|
||||||
id: sale.id,
|
id: sale.id,
|
||||||
|
@ -298,8 +298,9 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePrice() {
|
updatePrice() {
|
||||||
if (this.editedPrice != this.sale.price) {
|
if (this.newPrice && this.newPrice != this.sale.price) {
|
||||||
this.$http.post(`Sales/${this.edit.id}/updatePrice`, {newPrice: this.editedPrice}).then(res => {
|
const query = `Sales/${this.edit.id}/updatePrice`;
|
||||||
|
this.$http.post(query, {newPrice: this.newPrice}).then(res => {
|
||||||
this.sale.price = res.data.price;
|
this.sale.price = res.data.price;
|
||||||
|
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
|
@ -313,7 +314,7 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNewPrice() {
|
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) {
|
showEditDiscountPopover(event, sale) {
|
||||||
|
|
Loading…
Reference in New Issue