mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
(bug) prepaid-packs without expiration date do not work
This commit is contained in:
parent
512828931f
commit
a46e3ae783
@ -7,6 +7,7 @@
|
||||
- Fix a bug: when requesting to send the sso migration code, the email was case-sensitive
|
||||
- Fix a bug: the adminsys email was case-sensitive
|
||||
- Fix a bug: members are unable to buy prepaid-packs by wallet
|
||||
- Fix a bug: prepaid-packs without expiration date do not work
|
||||
- [TODO DEPLOY] `rails fablab:maintenance:regenerate_statistics[2020,04]`
|
||||
|
||||
# v5.3.1 2022 January 17
|
||||
|
@ -18,7 +18,9 @@ class PrepaidPack < ApplicationRecord
|
||||
validates :amount, :group_id, :priceable_id, :priceable_type, :minutes, presence: true
|
||||
|
||||
def validity
|
||||
validity_count.send(validity_interval)
|
||||
return nil if validity_interval.nil?
|
||||
|
||||
validity_count&.send(validity_interval)
|
||||
end
|
||||
|
||||
def destroyable?
|
||||
|
@ -14,6 +14,8 @@ class StatisticProfilePrepaidPack < ApplicationRecord
|
||||
private
|
||||
|
||||
def set_expiration_date
|
||||
return unless prepaid_pack.validity
|
||||
|
||||
self.expires_at = DateTime.current + prepaid_pack.validity
|
||||
end
|
||||
end
|
||||
|
@ -24,7 +24,7 @@ class PrepaidPackService
|
||||
.includes(:prepaid_pack)
|
||||
.references(:prepaid_packs)
|
||||
.where('statistic_profile_id = ?', user.statistic_profile.id)
|
||||
.where('expires_at > ?', DateTime.current)
|
||||
.where('expires_at > ? OR expires_at IS NULL', DateTime.current)
|
||||
.where('prepaid_packs.priceable_id = ?', priceable.id)
|
||||
.where('prepaid_packs.priceable_type = ?', priceable.class.name)
|
||||
.where('minutes_used < prepaid_packs.minutes')
|
||||
|
Loading…
x
Reference in New Issue
Block a user