i dunno, can you?

This commit is contained in:
24c02 2025-12-18 15:10:44 -05:00
parent e5132db647
commit 0f8b36f7de
4 changed files with 14 additions and 2 deletions

View file

@ -95,6 +95,8 @@ class Letter::BatchesController < BaseBatchesController
# Only require payment account if indicia is selected
if letter_batch_params[:us_postage_type] == "indicia" || letter_batch_params[:intl_postage_type] == "indicia"
authorize @batch, :process_batch_with_indicia?, policy_class: Letter::BatchPolicy
payment_account = USPS::PaymentAccount.find_by(id: letter_batch_params[:usps_payment_account_id])
if payment_account.nil?

View file

@ -17,7 +17,13 @@ class Letter::BatchPolicy < ApplicationPolicy
alias_method :set_mapping?, :map_fields?
alias_method :process_form?, :map_fields?
alias_method :process_batch?, :map_fields?
def process_batch_with_indicia?
user.present? && user.can_use_indicia?
end
alias_method :mark_printed?, :update?
alias_method :mark_mailed?, :mark_printed?

View file

@ -9,7 +9,11 @@ class Letter::QueuePolicy < ApplicationPolicy
user.present?
end
alias_method :create_instant_letter?, :create_letter?
def create_instant_letter?
return false unless user.present?
return true unless record.indicia?
user.can_use_indicia?
end
def batch?
record_belongs_to_user || user_is_admin

View file

@ -36,7 +36,7 @@ class LetterPolicy < ApplicationPolicy
end
def buy_indicia?
record_belongs_to_user || user_is_admin
user&.can_use_indicia? && (record_belongs_to_user || user_is_admin)
end
def mark_printed?