Files
openfoodnetwork/app/models/invoice/data_presenter/payment.rb
Mohamed ABDELLANI 61d58df56f fix linter issues
2023-06-18 21:03:13 +02:00

26 lines
642 B
Ruby

# frozen_string_literal: false
class Invoice
class DataPresenter
class Payment < Invoice::DataPresenter::Base
attributes :amount, :currency, :state, :payment_method_id
attributes_with_presenter :payment_method
invoice_generation_attributes :amount, :payment_method_id
invoice_update_attributes :state
def created_at
datetime = data&.[](:created_at)
datetime.present? ? Time.zone.parse(datetime) : nil
end
def display_amount
Spree::Money.new(amount, currency: currency)
end
def payment_method_name
payment_method&.name
end
end
end
end