Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Admin] Add Refunds and Returns section with correlated index pages #5539

Merged
merged 8 commits into from
Dec 6, 2023
Prev Previous commit
Next Next commit
Add ransackable attributes to reasons models for search in admin"
Enhanced the search capabilities in the admin panel by updating
the `allowed_ransackable_attributes` of `Spree::AdjustmentReason`,
`Spree::RefundReason`, `Spree::ReimbursementType`, `Spree::ReturnReason`
and `Spree::StoreCreditReason`.
  • Loading branch information
rainerdema committed Dec 6, 2023
commit 193dd8ef3892a64f46d3cb199775151a37aac9cd
2 changes: 2 additions & 0 deletions core/app/models/spree/adjustment_reason.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ class AdjustmentReason < Spree::Base
validates :code, presence: true, uniqueness: { case_sensitive: false, allow_blank: true }

scope :active, -> { where(active: true) }

self.allowed_ransackable_attributes = %w[name code]
end
end
2 changes: 2 additions & 0 deletions core/app/models/spree/refund_reason.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class RefundReason < Spree::Base

has_many :refunds

self.allowed_ransackable_attributes = %w[name code]

def self.return_processing_reason
find_by!(name: RETURN_PROCESSING_REASON, mutable: false)
end
Expand Down
2 changes: 2 additions & 0 deletions core/app/models/spree/reimbursement_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class ReimbursementType < Spree::Base

has_many :return_items

self.allowed_ransackable_attributes = %w[name]

# This method will reimburse the return items based on however it child implements it
# By default it takes a reimbursement, the return items it needs to reimburse, and if
# it is a simulation or a real reimbursement. This should return an array
Expand Down
2 changes: 2 additions & 0 deletions core/app/models/spree/return_reason.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class ReturnReason < Spree::Base

has_many :return_authorizations

self.allowed_ransackable_attributes = %w[name]

def self.reasons_for_return_items(return_items)
# Only allow an inactive reason if it's already associated to a return item
active | return_items.map(&:return_reason).compact
Expand Down
2 changes: 2 additions & 0 deletions core/app/models/spree/store_credit_reason.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ class Spree::StoreCreditReason < Spree::Base
include Spree::NamedType

has_many :store_credit_events, inverse_of: :store_credit_reason

self.allowed_ransackable_attributes = %w[name]
end