Skip to content

Commit

Permalink
[FIX] order validation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtyomLosev authored and Ivan Yelizariev committed Oct 24, 2017
1 parent 9d1e9e7 commit 5bc3d39
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pos_debt_notebook/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
`4.4.1`
-------
- **FIX:** Superfluous paymentlines at client change.
- **FIX:** Incorrect order validation.

`4.4.0`
-------

Expand Down
15 changes: 14 additions & 1 deletion pos_debt_notebook/static/src/js/pos.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ odoo.define('pos_debt_notebook.pos', function (require) {
});
return;
}
if (isDebt && currentOrder.get_total_paid() > currentOrder.get_total_with_tax()) {
if (this.debt_change_check()) {
this.gui.show_popup('error', {
'title': _t('Unable to return the change with a debt payment method'),
'body': _t('Please enter the exact or lower debt amount than the cost of the order.')
Expand All @@ -303,6 +303,18 @@ odoo.define('pos_debt_notebook.pos', function (require) {
this._super(options);
},

debt_change_check: function () {
var order = this.pos.get_order(),
paymentlines = order.get_paymentlines(),
flag = false;
for (var i = 0; i < paymentlines.length; i++) {
if (paymentlines[i].cashregister.journal.debt && order.get_change(paymentlines[i]) > 0) {
flag = true;
}
}
return flag;
},

pay_full_debt: function(){
var order = this.pos.get_order();

Expand All @@ -329,6 +341,7 @@ odoo.define('pos_debt_notebook.pos', function (require) {
});
newDebtPaymentline.set_amount(order.get_client().debt * -1);
order.paymentlines.add(newDebtPaymentline);

this.render_paymentlines();
},

Expand Down

1 comment on commit 5bc3d39

@gustavovalverde
Copy link
Contributor

@gustavovalverde gustavovalverde commented on 5bc3d39 Oct 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yelizariev just a simple tip. All commits which are fixing an issue, should reference the issue in the Title, like: https://help.github.com/articles/closing-issues-using-keywords/ this way it will keep the issues section a bit cleaner.

Please sign in to comment.