diff options
| author | Joseph Caburnay <jcb@odoo.com> | 2019-10-31 10:10:26 +0000 |
|---|---|---|
| committer | Joseph Caburnay <jcb@odoo.com> | 2019-10-31 12:16:28 +0000 |
| commit | 7d3dfeb4738149b154791efc8e5adfe9fe79a05e (patch) | |
| tree | 2cb08b1e4e3744f0271f45fc6665af0e609b23bd /addons | |
| parent | 191dc9e6da5192579d51996f9692d76e553d6364 (diff) | |
[IMP] pos_mercury: prevent multiple electronic payments
If there is a Vantiv payment line, adding terminal payment line (e.g.
Adyen) was possible because Vantiv payment line is not recognized as
electronic payment. This commit generalizes the behavior where new
paymentline is prevented if there is a pending electronic payment.
task-id: 1984690
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/pos_mercury/static/src/js/pos_mercury.js | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/addons/pos_mercury/static/src/js/pos_mercury.js b/addons/pos_mercury/static/src/js/pos_mercury.js index 8a1e56e9ac2..70e9db8f3d2 100644 --- a/addons/pos_mercury/static/src/js/pos_mercury.js +++ b/addons/pos_mercury/static/src/js/pos_mercury.js @@ -132,6 +132,14 @@ pos_model.Paymentline = pos_model.Paymentline.extend({ } }); +var _order_super = pos_model.Order.prototype; +pos_model.Order = pos_model.Order.extend({ + electronic_payment_in_progress: function() { + var res = _order_super.electronic_payment_in_progress.apply(this, arguments); + return res || this.get_paymentlines().some(line => line.mercury_swipe_pending); + }, +}); + // Lookup table to store status and error messages var lookUpCodeTransaction = { 'Approved': { @@ -618,36 +626,13 @@ PaymentScreenWidget.include({ // make sure there is only one paymentline waiting for a swipe click_paymentmethods: function (id) { - var i; var order = this.pos.get_order(); - var payment_method = this.pos.payment_methods_by_id[id] - // this.pos.get_order().add_paymentline(payment_method); - - if (payment_method.pos_mercury_config_id) { - var already_swipe_pending = false; - var lines = order.get_paymentlines(); - - for (i = 0; i < lines.length; i++) { - if (lines[i].payment_method.pos_mercury_config_id && lines[i].mercury_swipe_pending) { - already_swipe_pending = true; - } - } - - if (already_swipe_pending) { - this.gui.show_popup('error',{ - 'title': _t('Error'), - 'body': _t('One credit card swipe already pending.'), - }); - } else { - var res = this._super(id); - if (res && order.get_due(order.selected_paymentline) > 0) { - order.selected_paymentline.mercury_swipe_pending = true; - this.render_paymentlines(); - order.trigger('change', order); // needed so that export_to_JSON gets triggered - } - } - } else { - this._super(id); + var payment_method = this.pos.payment_methods_by_id[id]; + var res = this._super(id); + if (res && payment_method.pos_mercury_config_id) { + order.selected_paymentline.mercury_swipe_pending = true; + this.render_paymentlines(); + order.trigger('change', order); // needed so that export_to_JSON gets triggered } }, |
