Class: QuoteCopyWorker
- Inherits:
-
Object
- Object
- QuoteCopyWorker
- Includes:
- Sidekiq::Job, Workers::StatusBroadcastable
- Defined in:
- app/workers/quote_copy_worker.rb
Overview
Sidekiq worker: quote copy.
Instance Attribute Summary
Attributes included from Workers::StatusBroadcastable
Instance Method Summary collapse
Methods included from Workers::StatusBroadcastable::Overrides
Instance Method Details
#perform(options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/workers/quote_copy_worker.rb', line 8 def perform( = {}) = .symbolize_keys = Opportunity.find([:opportunity_id]) current_quote = Quote.find([:quote_id]) notify_email = [:notify_email] report = Quote::Copier.new(current_quote).copy_to() do |current_step, total_steps, | total total_steps at(current_step, ) end new_quote = report[:new_quote].present? ? Quote.find(report[:new_quote].first.to_i) : nil if report[:errors].any? store redirect_to: "/quotes/#{current_quote.id}" SalesMailer.quote_copy_complete(, new_quote, user_email: notify_email, report: report).deliver_now = report[:errors].first store message: else = report[:successes].first store redirect_to: "/quotes/#{new_quote.id}" store message: end end |