diff --git a/Gemfile b/Gemfile index 5a3545597e1..b75f6b3c02f 100644 --- a/Gemfile +++ b/Gemfile @@ -22,6 +22,7 @@ gem 'oauth2' gem 'rack-cors' # Database +gem 'after_commit_everywhere' gem 'clickhouse-activerecord', git: 'https://github.com/getlago/clickhouse-activerecord.git' gem 'discard', '~> 1.2' gem 'kaminari-activerecord' diff --git a/Gemfile.lock b/Gemfile.lock index 2eca9a93be7..b448e49b033 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -110,6 +110,9 @@ GEM public_suffix (>= 2.0.2, < 6.0) adyen-ruby-api-library (7.0.1) faraday + after_commit_everywhere (1.4.0) + activerecord (>= 4.2) + activesupport analytics-ruby (2.4.0) ast (2.4.2) aws-eventstream (1.2.0) @@ -576,6 +579,7 @@ DEPENDENCIES activejob-traceable activejob-uniqueness adyen-ruby-api-library + after_commit_everywhere analytics-ruby (~> 2.4.0) aws-sdk-s3 bcrypt diff --git a/app/services/base_service.rb b/app/services/base_service.rb index d890c034257..14b70bfcd24 100644 --- a/app/services/base_service.rb +++ b/app/services/base_service.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class BaseService + include AfterCommitEverywhere + class FailedResult < StandardError attr_reader :result diff --git a/app/services/customers/eu_auto_taxes_service.rb b/app/services/customers/eu_auto_taxes_service.rb index 7b9a1cd584c..9ed90b55963 100644 --- a/app/services/customers/eu_auto_taxes_service.rb +++ b/app/services/customers/eu_auto_taxes_service.rb @@ -25,8 +25,7 @@ def call def vies_check vies_check = Valvat.new(customer.tax_identification_number).exists?(detail: true) - - SendWebhookJob.perform_later('customer.vies_check', customer, vies_check:) + after_commit { SendWebhookJob.perform_later('customer.vies_check', customer, vies_check:) } vies_check end