[IMP] point_of_sale,pos_mercury: do not count invalid paymentline
With the introduction of pos_adyen, pending payments are not counted in the total payments. We are now implementing the same behavior for pos_mercury. task-id: 1984690
This commit is contained in:
@@ -2191,6 +2191,14 @@ exports.Paymentline = Backbone.Model.extend({
|
||||
this.trigger('change', this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if paymentline is done.
|
||||
* Paymentline is done if there is no payment status or the payment status is done.
|
||||
*/
|
||||
is_done: function() {
|
||||
return this.get_payment_status() ? this.get_payment_status() === 'done' : true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set additional info to be printed on the receipts. value should
|
||||
* be compatible with both the QWeb and ESC/POS receipts.
|
||||
@@ -2862,11 +2870,7 @@ exports.Order = Backbone.Model.extend({
|
||||
},
|
||||
get_total_paid: function() {
|
||||
return round_pr(this.paymentlines.reduce((function(sum, paymentLine) {
|
||||
if (paymentLine.get_payment_status()) {
|
||||
if (paymentLine.get_payment_status() == 'done') {
|
||||
sum += paymentLine.get_amount();
|
||||
}
|
||||
} else {
|
||||
if (paymentLine.is_done()) {
|
||||
sum += paymentLine.get_amount();
|
||||
}
|
||||
return sum;
|
||||
|
||||
@@ -125,6 +125,10 @@ pos_model.Paymentline = pos_model.Paymentline.extend({
|
||||
if (this.mercury_card_number) {
|
||||
this.name = this.mercury_card_brand + " (****" + this.mercury_card_number + ")";
|
||||
}
|
||||
},
|
||||
is_done: function () {
|
||||
var res = _paylineproto.is_done.apply(this);
|
||||
return res && !this.mercury_swipe_pending;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user