Class: Returns::SendChargeNotice
- Inherits:
-
BaseService
- Object
- BaseService
- Returns::SendChargeNotice
- Defined in:
- app/services/returns/send_charge_notice.rb
Overview
Service object: send charge notice.
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#renderer ⇒ Object
readonly
Returns the value of attribute renderer.
Instance Method Summary collapse
-
#initialize(_options = {}) ⇒ SendChargeNotice
constructor
A new instance of SendChargeNotice.
- #process(_options = {}) ⇒ Object
Constructor Details
#initialize(_options = {}) ⇒ SendChargeNotice
Returns a new instance of SendChargeNotice.
11 12 13 |
# File 'app/services/returns/send_charge_notice.rb', line 11 def initialize( = {}) @renderer = PdfRenderer.new end |
Instance Attribute Details
#renderer ⇒ Object (readonly)
Returns the value of attribute renderer.
9 10 11 |
# File 'app/services/returns/send_charge_notice.rb', line 9 def renderer @renderer end |
Instance Method Details
#process(_options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/services/returns/send_charge_notice.rb', line 15 def process( = {}) processed_rmas = [] invoices = Invoice.joins(order: [:rma, { deliveries: [:payments] }]).where("invoices.state = ? and payments.category = ? and invoices.document_date = ? and rmas.state = ?", 'unpaid', Payment::ADV_REPL, 30.days.ago.to_date, 'awaiting_return') invoices.each do |i| rma = i.order.rma keep_as_draft = rma.transmission_email.empty? and rma.transmission_fax.empty? comm = CommunicationBuilder.new(resource: i.order.rma, merge_options: { invoice: i, rma: i.order.rma }, template_system_code: 'RMA_CHARGE').create(keep_as_draft: keep_as_draft) if keep_as_draft == true # couldn't send as no email/fax listed on the RMA RmaMailer.unable_to_deliver_rma_reminder(rma, comm).deliver_later end processed_rmas << i.order.rma.rma_number end Result.new({ rmas: processed_rmas }) end |