feat(orders): execute OneOff orders#5887
Draft
toommz wants to merge 6 commits into
Draft
Conversation
1cdd348 to
c836eb7
Compare
toommz
commented
Jul 8, 2026
| GenerateDocumentsJob.perform_later(invoice:, notify: should_deliver_email?) | ||
| Integrations::Aggregator::Invoices::CreateJob.perform_later(invoice:) if invoice.should_sync_invoice? | ||
| Integrations::Aggregator::Invoices::Hubspot::CreateJob.perform_later(invoice:) if invoice.should_sync_hubspot_invoice? | ||
| after_commit { Utils::SegmentTrack.invoice_created(invoice) } |
Contributor
Author
There was a problem hiding this comment.
Utils::SegmentTrack.invoice_created calls perform_later behind the hood, but changing the implementation is outside the scope of this PR. Wrapping it in an after_commit block here before doing the changes in Utils::SegmentTrack in another PR.
toommz
commented
Jul 8, 2026
Comment on lines
+34
to
+37
| # Add-ons are resolved by id only outside api context, and CurrentContext | ||
| # leaks across spec files (no global reset), so pin it. | ||
| before { CurrentContext.source = nil } | ||
|
|
Contributor
Author
There was a problem hiding this comment.
This should belong in spec/spec_helper.rb as:
# spec/spec_helper.rb:162
# In config.before global hook
ActiveSupport::CurrentAttributes.reset_allBut outside the scope of this PR, as it might have some side effects to fix at the same time.
8cdcf60 to
344f0d6
Compare
c836eb7 to
f678fa7
Compare
6275845 to
c265e88
Compare
f678fa7 to
27f25e6
Compare
8da91f0 to
7ee1bb9
Compare
7ee1bb9 to
389bf6c
Compare
389bf6c to
7c0b28c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Signed one-off orders now actually get billed. When the execution mode is
execute_in_lago, Lago turns the order into a one-off invoice, either immediately at signing or at the scheduledexecute_atdate.If billing fails, the order moves to a
failedstatus with theerrorsrecorded, and won't be retried automatically. Retrying is a deliberate user action. The execution outcome (when, how, resulting invoice) is exposed on the API and GraphQL so users can audit what happened to each order.Reviewer notes
Two changes touch the shared one-off invoicing path:
Invoices::CreateOneOffServicemove toperform_after_commitbecause the service now runs inside the order execution transactionwith_discarded_add_ons:opt-in flag is added since add-ons can be discarded between signing and execution