Skip to content

Commit

Permalink
[#161345] FIX: Order imports for expried accounts (#3834)
Browse files Browse the repository at this point in the history
Release Notes
There were a few more places that logic needed to be updated.
  • Loading branch information
giladshanan committed Nov 21, 2023
1 parent f8fac59 commit 1f8f03b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def price_groups
accepts_nested_attributes_for :account_users
has_many :log_events, as: :loggable

scope :active, -> { active_at (Time.current) }
scope :active_at, ->(time) { where("expires_at > ?", time).where(suspended_at: nil) }
scope :active, -> { where("expires_at > ?", Time.current).where(suspended_at: nil) }
scope :active_at, ->(time) { where("expires_at >= ?", time).where(suspended_at: nil) }

scope :administered_by, lambda { |user|
for_user(user).where("account_users.user_role" => AccountUser.admin_user_roles)
Expand Down
2 changes: 1 addition & 1 deletion app/models/order_detail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def validate_for_purchase(fulfilled_time = Time.zone.now)
return "The account is expired and cannot be used" if account.expires_at < fulfilled_time || account.suspended_at

# TODO: if chart string, is chart string + account valid
return I18n.t("not_open", model: account.type_string, scope: "activerecord.errors.models.account") if account.respond_to?(:account_open?) && !account.account_open?(product.account)
return I18n.t("not_open", model: account.type_string, scope: "activerecord.errors.models.account") if account.respond_to?(:account_open?) && !account.account_open?(product.account, fulfillment_time: fulfilled_time)

# is the user approved for the product
return "You are not approved to purchase this #{product.class.name.downcase}" unless product.can_be_used_by?(order.user) || order.created_by_user.can_override_restrictions?(product)
Expand Down

0 comments on commit 1f8f03b

Please sign in to comment.