Class: TranslationCms::Api::Customers::Payment

Inherits:
Base
  • Object
show all
Extended by:
EnumField::EnumeratedAttribute
Defined in:
lib/translation_cms/api/customers/payment.rb

Instance Method Summary collapse

Methods inherited from Base

all!, custom_scope!, default_attributes, destroy, dummy_resource!, #method_missing_with_translations_will_change, parsed!, path_with_custom_scope, resource_type!, update

Instance Method Details

#any_created_atObject



42
43
44
# File 'lib/translation_cms/api/customers/payment.rb', line 42

def any_created_at
  parsed_created_at || parsed_customer_due_date
end


46
47
48
49
50
51
52
# File 'lib/translation_cms/api/customers/payment.rb', line 46

def order_link
  if order.present?
    url = Rails.application.routes.url_helpers
               .(id: order.number, locale: I18n.locale)
    "<a href='#{url}'>##{order.number}</a>"
  end
end

#parsed_titleObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/translation_cms/api/customers/payment.rb', line 20

def parsed_title
  if order.present?
    url = Rails.application.routes.url_helpers
               .(id: order.number, locale: I18n.locale)
  end
  if payment.present?
    description = payment.description(
      amount: amount,
      order_id: order ? order.number : nil,
      order_link: order_link
    )
  end
  if description.blank?
    description = transaction_type.description(
      amount: amount,
      order_id: order ? order.number : nil,
      order_link: order_link
    )
  end
  description
end