Class: Returns::SendChargeNotice
- Inherits:
-
BaseService
- Object
- BaseService
- Returns::SendChargeNotice
- Defined in:
- app/services/returns/send_charge_notice.rb
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.
9 10 11 |
# File 'app/services/returns/send_charge_notice.rb', line 9 def initialize(={}) @renderer = PdfRenderer.new end |
Instance Attribute Details
#renderer ⇒ Object (readonly)
Returns the value of attribute renderer.
7 8 9 |
# File 'app/services/returns/send_charge_notice.rb', line 7 def renderer @renderer end |
Instance Method Details
#process(options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/returns/send_charge_notice.rb', line 13 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 InternalMailer.unable_to_deliver_rma_reminder(rma, comm).deliver_later end processed_rmas << i.order.rma.rma_number end Result.new({rmas: processed_rmas}) end |