Skip to content

Commit

Permalink
feat(wallet): Flag wallets only when amount has changed
Browse files Browse the repository at this point in the history
  • Loading branch information
rsempe committed Nov 27, 2024
1 parent 4b4767d commit e205d3c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/services/invoices/refresh_draft_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def call

ActiveRecord::Base.transaction do
invoice.update!(ready_to_be_refreshed: false) if invoice.ready_to_be_refreshed?
invoice.customer.flag_wallets_for_refresh
old_total_amount_cents = invoice.total_amount_cents

old_fee_values = invoice_credit_note_items.map do |item|
{credit_note_item_id: item.id, fee_amount_cents: item.fee&.amount_cents}
Expand Down Expand Up @@ -69,6 +69,7 @@ def call
calculate_result.raise_if_error!

flag_lifetime_usage_for_refresh
invoice.customer.flag_wallets_for_refresh if old_total_amount_cents != invoice.total_amount_cents

# NOTE: In case of a refresh the same day of the termination.
invoice.fees.update_all(created_at: invoice.created_at) # rubocop:disable Rails/SkipsModelValidations
Expand Down

0 comments on commit e205d3c

Please sign in to comment.