[FIX] pos_cash_rounding: Fix value under rounding
It should be allowed to pay amount that are not rounded if the value is less than the rounding value. Ex: Rounding value: 0.05 Amount to pay: 0.04 The amount to pay should remain 0.04 and not be rounded to 0.05. This fix allows the user to pay for values under the rounding value without applying the rounding. closes odoo/odoo#81392 X-original-commit: 523bc2f9b26bbb51ededcb734fa4ec384671575b Signed-off-by: Masereel Pierre <pim@odoo.com>
This commit is contained in:
@@ -3588,8 +3588,9 @@ exports.Order = Backbone.Model.extend({
|
||||
if (utils.float_is_zero(rounding_applied, this.pos.currency.decimals)){
|
||||
// https://xkcd.com/217/
|
||||
return 0;
|
||||
}
|
||||
else if(this.pos.cash_rounding[0].rounding_method === "UP" && rounding_applied < 0 && remaining > 0) {
|
||||
} else if(this.get_total_with_tax() < this.pos.cash_rounding[0].rounding) {
|
||||
return 0;
|
||||
} else if(this.pos.cash_rounding[0].rounding_method === "UP" && rounding_applied < 0 && remaining > 0) {
|
||||
rounding_applied += this.pos.cash_rounding[0].rounding;
|
||||
}
|
||||
else if(this.pos.cash_rounding[0].rounding_method === "UP" && rounding_applied > 0 && remaining < 0) {
|
||||
@@ -3610,7 +3611,7 @@ exports.Order = Backbone.Model.extend({
|
||||
return 0;
|
||||
},
|
||||
has_not_valid_rounding: function() {
|
||||
if(!this.pos.config.cash_rounding)
|
||||
if(!this.pos.config.cash_rounding || this.get_total_with_tax() < this.pos.cash_rounding[0].rounding)
|
||||
return false;
|
||||
|
||||
const only_cash = this.pos.config.only_round_cash_method;
|
||||
@@ -3641,6 +3642,8 @@ exports.Order = Backbone.Model.extend({
|
||||
for(var id in this.get_paymentlines()) {
|
||||
var line = this.get_paymentlines()[id];
|
||||
var diff = round_pr(round_pr(line.amount, cash_rounding) - round_pr(line.amount, default_rounding), default_rounding);
|
||||
if(this.get_total_with_tax() < this.pos.cash_rounding[0].rounding)
|
||||
return true;
|
||||
if(diff && line.payment_method.is_cash_count) {
|
||||
return false;
|
||||
} else if(!this.pos.config.only_round_cash_method && diff) {
|
||||
|
||||
Reference in New Issue
Block a user