Class: Cats::Core::ReceiptAuthorizationNotification

Inherits:
Noticed::Base
  • Object
show all
Defined in:
app/notifications/cats/core/receipt_authorization_notification.rb

Instance Method Summary collapse

Instance Method Details

#messageObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/notifications/cats/core/receipt_authorization_notification.rb', line 8

def message
  authorization = params[:receipt_authorization]
  dispatch = authorization.dispatch
  ref_no = dispatch.dispatch_plan_item.dispatch_plan.upstream ? dispatch.dispatch_transactions[0].reference_no : dispatch.reference_no
  commodity = dispatch.dispatch_plan_item.commodity
  title = "Receipt Authorization Notification - #{commodity.name}"
  date = Date.today

  body = <<~BODY
    Commodity with the following details has been dispatched to you:
        Authorization no. = #{dispatch.dispatch_plan_item.reference_no}
        Dispatch Ref. = #{ref_no}
        Batch No. = #{commodity.batch_no}
        Commodity = #{commodity.name}
        Quantity = #{authorization.quantity}
        Unit = #{authorization.unit.abbreviation}
        Truck Plate No. = #{dispatch.plate_no}
        Driver Name = #{dispatch.driver_name}
        Driver Phone = #{dispatch.driver_phone}
  BODY
  {title: title, date: date, body: body}
end