Module: Spree::Reimbursement::ReimbursementTypeValidator

Included in:
ReimbursementTypeEngine
Defined in:
core/app/models/spree/reimbursement/reimbursement_type_validator.rb

Instance Method Summary collapse

Instance Method Details

#past_reimbursable_time_period?(return_item) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'core/app/models/spree/reimbursement/reimbursement_type_validator.rb', line 12

def past_reimbursable_time_period?(return_item)
  shipped_at = return_item.inventory_unit.shipment.shipped_at
  shipped_at && shipped_at < refund_time_constraint.ago
end

#valid_preferred_reimbursement_type?(return_item) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
# File 'core/app/models/spree/reimbursement/reimbursement_type_validator.rb', line 5

def valid_preferred_reimbursement_type?(return_item)
  preferred_type = return_item.preferred_reimbursement_type.class

  !past_reimbursable_time_period?(return_item) ||
    preferred_type == expired_reimbursement_type
end