From f9c477b83c7ad9023a3cce36e09b886e2ad100da Mon Sep 17 00:00:00 2001 From: Vincent Pochet Date: Thu, 15 Sep 2022 08:46:40 +0200 Subject: [PATCH] fix: Fix cache expiration result for customer current usage --- app/services/invoices/customer_usage_service.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/services/invoices/customer_usage_service.rb b/app/services/invoices/customer_usage_service.rb index 9afe0a298c3..b5a6adea774 100644 --- a/app/services/invoices/customer_usage_service.rb +++ b/app/services/invoices/customer_usage_service.rb @@ -120,7 +120,10 @@ def expire_cache(date) def cache_expiration expiration = (boundaries[:charges_to_date] - Time.zone.today).to_i + 1 - expiration > 4 ? 4 : expiration + return 1 if expiration < 1 + return 4 if expiration > 4 + + expiration end def format_usage