Skip to content

Commit

Permalink
Fix: missing parent charge in the database (#2893)
Browse files Browse the repository at this point in the history
## Context

We started having errors in sidekiq that charge cannot be saved because
parent_id charge does not exist in the database

## Description

Wrap cascade_charge_creation in after_commit block
  • Loading branch information
annvelents authored Nov 29, 2024
1 parent 394fbee commit bad5146
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/plans/update_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def process_charges(plan, params_charges)
create_charge_result = Charges::CreateService.call(plan:, params: payload_charge)
create_charge_result.raise_if_error!

cascade_charge_creation(payload_charge.merge(parent_id: create_charge_result.charge.id))
after_commit { cascade_charge_creation(payload_charge.merge(parent_id: create_charge_result.charge.id)) }
created_charges_ids.push(create_charge_result.charge.id)
end

Expand Down

0 comments on commit bad5146

Please sign in to comment.