From c48956be102e9e4776d4d63572926c78b2c8dd8a Mon Sep 17 00:00:00 2001 From: Du Peng Date: Wed, 19 Oct 2022 11:38:17 +0200 Subject: [PATCH] (bug) unable apply a coupon if this coupon has used by an user removed --- CHANGELOG.md | 2 ++ app/models/coupon.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 003d95d30..8a148ba52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog Fab-manager +- Fix a bug: unable apply a coupon if this coupon has used by an user removed + ## v5.4.24 2022 October 14 - Fix a bug: unable debit hours of prepaid pack after a reservation of machine diff --git a/app/models/coupon.rb b/app/models/coupon.rb index 744ad35ba..ec7ef910d 100644 --- a/app/models/coupon.rb +++ b/app/models/coupon.rb @@ -82,7 +82,8 @@ class Coupon < ApplicationRecord end def users - invoices.map(&:user) + # compact to user removed + invoices.map(&:user).compact end def users_ids @@ -104,5 +105,4 @@ class Coupon < ApplicationRecord def delete_gateway_coupon PaymentGatewayService.new.delete_coupon(id) end - end