[FIX] pos_coupon: remove the reward lines before recomputation of rewards
Task-id: 2631220 Part-of: odoo/odoo#77903
This commit is contained in:
committed by
Pierre Masereel
parent
9c19cadef7
commit
4e16218848
@@ -22,6 +22,7 @@ odoo.define('pos_coupon.pos', function (require) {
|
||||
const session = require('web.session');
|
||||
const concurrency = require('web.concurrency');
|
||||
const { Gui } = require('point_of_sale.Gui');
|
||||
const { float_is_zero } = require('web.utils');
|
||||
|
||||
const dp = new concurrency.DropPrevious();
|
||||
|
||||
@@ -258,7 +259,6 @@ odoo.define('pos_coupon.pos', function (require) {
|
||||
() => {
|
||||
if (!this.pos.config.use_coupon_programs) return;
|
||||
dp.add(this._getNewRewardLines()).then(([newRewardLines, rewardsContainer]) => {
|
||||
this.orderlines.remove(this._getRewardLines());
|
||||
this.orderlines.add(newRewardLines);
|
||||
// We need this for the rendering of ActivePrograms component.
|
||||
this.rewardsContainer = rewardsContainer;
|
||||
@@ -427,6 +427,8 @@ odoo.define('pos_coupon.pos', function (require) {
|
||||
* @returns {[models.Orderline[], RewardsContainer]}
|
||||
*/
|
||||
_getNewRewardLines: async function () {
|
||||
// Remove the reward lines before recalculation of rewards.
|
||||
this.orderlines.remove(this._getRewardLines());
|
||||
const rewardsContainer = await this._calculateRewards();
|
||||
// We set the programs that will generate coupons after validation of this order.
|
||||
// See `_postPushOrderResolve` in the `PaymentScreen`.
|
||||
@@ -770,7 +772,12 @@ odoo.define('pos_coupon.pos', function (require) {
|
||||
? this.get_total_with_tax()
|
||||
: this.get_total_without_tax();
|
||||
// TODO jcb rule_minimum_amount has to be converted.
|
||||
if (!(amountToCheck >= program.rule_minimum_amount)) {
|
||||
if (
|
||||
!(
|
||||
amountToCheck > program.rule_minimum_amount ||
|
||||
float_is_zero(amountToCheck - program.rule_minimum_amount, this.pos.currency.decimals)
|
||||
)
|
||||
) {
|
||||
return {
|
||||
successful: false,
|
||||
reason: 'Minimum amount for this program is not satisfied.',
|
||||
|
||||
Reference in New Issue
Block a user