Created
March 5, 2017 22:10
-
-
Save bleonard/d9d80c8a2f9dc894d506e0d4dc3f08d4 to your computer and use it in GitHub Desktop.
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
| class InvoiceJobOp < ::Backend::Op | |
| include Mixins::AtomicOperation # all in same transaction | |
| field :hours | |
| field :job_id | |
| validates :job_id, presence: true | |
| validate :validate_hour # hours given | |
| validate :validate_assignment # tasker is assigned | |
| # ... other checks | |
| def perform | |
| create_invoice! # record hours and such | |
| generate_payment! # pending payment transaction | |
| appointment_done! # note that appointment completed | |
| if ongoing? | |
| schedule_next_appointment! # schedule next if more | |
| else | |
| complete_assignment! # otherwise, no more | |
| end | |
| enqueue_background_workers! # follow up later on stuff | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment