Skip to content

Commit

Permalink
streamline call.raise_if_error!
Browse files Browse the repository at this point in the history
  • Loading branch information
nudded committed Aug 22, 2024
1 parent a9477b6 commit 4d7b7a3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/services/invoices/progressive_billing_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ def total_lifetime_usage_amount_cents
end

def create_credit_note_credit
credit_result = Credits::CreditNoteService.new(invoice:).call
credit_result.raise_if_error!
credit_result = Credits::CreditNoteService.call(invoice:).raise_if_error!

invoice.total_amount_cents -= credit_result.credits.sum(&:amount_cents) if credit_result.credits
end
Expand All @@ -129,8 +128,7 @@ def create_applied_prepaid_credit
return unless invoice.total_amount_cents.positive?
return unless wallet.balance.positive?

prepaid_credit_result = Credits::AppliedPrepaidCreditService.call(invoice:, wallet:)
prepaid_credit_result.raise_if_error!
prepaid_credit_result = Credits::AppliedPrepaidCreditService.call(invoice:, wallet:).raise_if_error!

invoice.total_amount_cents -= prepaid_credit_result.prepaid_credit_amount_cents
end
Expand Down

0 comments on commit 4d7b7a3

Please sign in to comment.