diff --git a/app/models/account.rb b/app/models/account.rb index 484fbea0a4..5d67dd5aec 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -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) diff --git a/app/models/order_detail.rb b/app/models/order_detail.rb index 4a2b2c08e4..9d9d12b017 100644 --- a/app/models/order_detail.rb +++ b/app/models/order_detail.rb @@ -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)