Skip to content

Commit

Permalink
Merge pull request #1495 from dmitry-sinina/customer_api_fix_uuid_fil…
Browse files Browse the repository at this point in the history
…ters

customer API: services and transactions filter by UUID
  • Loading branch information
dmitry-sinina committed Jul 1, 2024
2 parents ee0b554 + a763add commit 83887ad
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/billing/service_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def validate_provisioning_class
return
end

if persisted? && services.any?
if persisted? && services.any? && attribute_changed?(:provisioning_class)
errors.add(:provisioning_class, "can't be changed because have linked services")
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/resources/api/rest/customer/v1/service_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Api::Rest::Customer::V1::ServiceResource < Api::Rest::Customer::V1::BaseRe

ransack_filter :created_at, type: :datetime
ransack_filter :name, type: :string
ransack_filter :account_id, type: :foreign_key
association_uuid_filter :account_id, class_name: 'Account'
ransack_filter :initial_price, type: :number
ransack_filter :renew_price, type: :number
ransack_filter :renew_at, type: :datetime
Expand Down
4 changes: 2 additions & 2 deletions app/resources/api/rest/customer/v1/transaction_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class Api::Rest::Customer::V1::TransactionResource < Api::Rest::Customer::V1::Ba
has_one :service, class_name: 'Service', relation_name: :type, foreign_key_on: :related

ransack_filter :created_at, type: :datetime
ransack_filter :account_id, type: :foreign_key
association_uuid_filter :account_id, class_name: 'Account'
ransack_filter :service_id, type: :foreign_key
ransack_filter :amount, type: :number
ransack_filter :description, type: :string

def self.sortable_fields(_ctx = nil)
%i[id created_at account_id service_id amount]
%i[id created_at service_id amount]
end
end

0 comments on commit 83887ad

Please sign in to comment.