Skip to content

Commit

Permalink
change the way to load invoice with subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
annvelents committed Dec 17, 2024
1 parent 797c514 commit 37f13ca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/services/invoices/refresh_draft_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ def call
refresh: true
).raise_if_error!

# TODO: instead of invoice.reload, do the full request to the DB with includes to have preloaded relationships:
# invoice = Invoice.find(invoice.id).includes(invoice_subscriptions: :subscription)
invoice = Invoice.includes(invoice_subscriptions: :subscription).find(result.invoice.id)
calculate_result = Invoices::CalculateFeesService.call(
invoice: invoice.reload,
invoice: invoice,
recurring:,
context:
)
Expand Down Expand Up @@ -103,7 +102,8 @@ def fetch_timestamp
def invoice_credit_note_items
CreditNoteItem
.joins(:credit_note)
.where(credit_note: {invoice_id: invoice.id}).includes(:fee)
.where(credit_note: {invoice_id: invoice.id})
.includes(:fee)
end

def flag_lifetime_usage_for_refresh
Expand Down

0 comments on commit 37f13ca

Please sign in to comment.