1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-10 21:24:20 +01:00
fab-manager/app/policies/local_payment_policy.rb

12 lines
468 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# Check the access policies for API::LocalPaymentsController
class LocalPaymentPolicy < ApplicationPolicy
def confirm_payment?
2021-10-12 14:07:35 +02:00
# only admins and managers can offer free extensions of a subscription
has_free_days = record.shopping_cart.items.any? { |item| item.is_a? CartItem::FreeExtension }
user.admin? || (user.manager? && record.shopping_cart.customer.id != user.id) || (record.price.zero? && !has_free_days)
end
end