[FIX] point_of_sale: allow refunds on non-cash journals
A customer can pay an order with a non-cash journal (e.g. a credit
card through a stand-alone terminal).
When this order has to be refunded later it should be possible to do
so on that same journal.
Some code prevented this from happening, notably a check in
order_is_valid which explicitly prevented this for an unknown
reason. There is no explanation in the
commit (4647f896a4) introducing that.
This commit allows the following:
1. input what you want to refund with a negative qty
2. click 'Payment'
3. click the Credit Card (type Bank) journal
4. (amount is auto-populated)
5. click 'Validate'
opw-805302
This commit is contained in:
@@ -2360,7 +2360,7 @@ exports.Order = Backbone.Model.extend({
|
||||
this.assert_editable();
|
||||
var newPaymentline = new exports.Paymentline({},{order: this, cashregister:cashregister, pos: this.pos});
|
||||
if(cashregister.journal.type !== 'cash' || this.pos.config.iface_precompute_cash){
|
||||
newPaymentline.set_amount( Math.max(this.get_due(),0) );
|
||||
newPaymentline.set_amount( this.get_due() );
|
||||
}
|
||||
this.paymentlines.add(newPaymentline);
|
||||
this.select_paymentline(newPaymentline);
|
||||
@@ -2524,10 +2524,10 @@ exports.Order = Backbone.Model.extend({
|
||||
}
|
||||
}
|
||||
}
|
||||
return round_pr(Math.max(0,due), this.pos.currency.rounding);
|
||||
return round_pr(due, this.pos.currency.rounding);
|
||||
},
|
||||
is_paid: function(){
|
||||
return this.get_due() === 0;
|
||||
return this.get_due() <= 0;
|
||||
},
|
||||
is_paid_with_cash: function(){
|
||||
return !!this.paymentlines.find( function(pl){
|
||||
|
||||
@@ -1975,17 +1975,6 @@ var PaymentScreenWidget = ScreenWidget.extend({
|
||||
return false;
|
||||
}
|
||||
|
||||
var plines = order.get_paymentlines();
|
||||
for (var i = 0; i < plines.length; i++) {
|
||||
if (plines[i].get_type() === 'bank' && plines[i].get_amount() < 0) {
|
||||
this.gui.show_popup('error',{
|
||||
'message': _t('Negative Bank Payment'),
|
||||
'comment': _t('You cannot have a negative amount in a Bank payment. Use a cash payment method to return money to the customer.'),
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!order.is_paid() || this.invoicing) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user