Class: NotificationWorkers::Partner::TicketsReport

Inherits:
ApplicationWorker show all
Includes:
MoneyRails::ActionViewExtension, RollbarSynTokenSetterWorker
Defined in:
app/workers/notification_workers/partner/tickets_report.rb

Overview

typed: true frozen_string_literal: true

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationWorker

unlimited_retry

Instance Attribute Details

#dateObject

Returns the value of attribute date.



9
10
11
# File 'app/workers/notification_workers/partner/tickets_report.rb', line 9

def date
  @date
end

#date_filter_typeObject

Returns the value of attribute date_filter_type.



9
10
11
# File 'app/workers/notification_workers/partner/tickets_report.rb', line 9

def date_filter_type
  @date_filter_type
end

#date_fromObject

Returns the value of attribute date_from.



9
10
11
# File 'app/workers/notification_workers/partner/tickets_report.rb', line 9

def date_from
  @date_from
end

#date_toObject

Returns the value of attribute date_to.



9
10
11
# File 'app/workers/notification_workers/partner/tickets_report.rb', line 9

def date_to
  @date_to
end

#emailsObject

Returns the value of attribute emails.



9
10
11
# File 'app/workers/notification_workers/partner/tickets_report.rb', line 9

def emails
  @emails
end

#pdf_urlObject

Returns the value of attribute pdf_url.



9
10
11
# File 'app/workers/notification_workers/partner/tickets_report.rb', line 9

def pdf_url
  @pdf_url
end

#restaurant_idObject

Returns the value of attribute restaurant_id.



9
10
11
# File 'app/workers/notification_workers/partner/tickets_report.rb', line 9

def restaurant_id
  @restaurant_id
end

#typeObject

Returns the value of attribute type.



9
10
11
# File 'app/workers/notification_workers/partner/tickets_report.rb', line 9

def type
  @type
end

Instance Method Details

#perform(args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/workers/notification_workers/partner/tickets_report.rb', line 14

def perform(args)
  args.to_h.with_indifferent_access.each do |k, v|
    next if k.to_s == :use_long_process.to_s

    send("#{k}=".to_sym, v)
  end
  I18n.locale = :en
  tickets = collect_tickets
  if pdf?
    report = VouchersHistoryReportPdf.new(tickets)
    report.generate_pdf(tickets, args)
    self.pdf_url = report.pdf_url
  else
    generate_vouchers_history_report_to_restaurant
    self.attachment = store_to_attachment
  end
  OwnerMailer.vouchers_list_report(email_body, email_subject, emails).deliver_later!
rescue StandardError => e
  APMErrorHandler.report e
  raise e
end