diff --git a/enterprise/app/models/enterprise/account.rb b/enterprise/app/models/enterprise/account.rb index cde366f1a..239bd0ac8 100644 --- a/enterprise/app/models/enterprise/account.rb +++ b/enterprise/app/models/enterprise/account.rb @@ -37,8 +37,8 @@ module Enterprise::Account plan_features[plan_name] end - def captain_monthly_limit - default_value = { documents: ChatwootApp.max_limit, generated_responses: ChatwootApp.max_limit }.with_indifferent_access + def default_captain_limit + default_value = { documents: ChatwootApp.max_limit, responses: ChatwootApp.max_limit }.with_indifferent_access return default_value if plan_name.blank? plan_quota = InstallationConfig.find_by(name: 'CAPTAIN_CLOUD_PLAN_LIMITS')&.value @@ -48,6 +48,15 @@ module Enterprise::Account plan_quota[plan_name.downcase] end + def captain_monthly_limit + default_limits = default_captain_limit + + { + documents: custom_attributes['captain_document_limit'] || default_limits['documents'], + responses: custom_attributes['captain_response_limit'] || default_limits['responses'] + }.with_indifferent_access + end + private def get_captain_limits(type) diff --git a/spec/enterprise/models/account_spec.rb b/spec/enterprise/models/account_spec.rb index def07985e..3667c7095 100644 --- a/spec/enterprise/models/account_spec.rb +++ b/spec/enterprise/models/account_spec.rb @@ -124,7 +124,7 @@ RSpec.describe Account, type: :model do it 'returns default values' do account.custom_attributes = { 'plan_name': 'unknown' } expect(account.captain_monthly_limit).to eq( - { documents: ChatwootApp.max_limit, generated_responses: ChatwootApp.max_limit }.with_indifferent_access + { documents: ChatwootApp.max_limit, responses: ChatwootApp.max_limit }.with_indifferent_access ) end end