Sha256: 824ef8d2b2289805ad912d4ee4408e1c80f154226e5228e9a1bd435050f2f0a9

Contents?: true

Size: 637 Bytes

Versions: 2

Compression:

Stored size: 637 Bytes

Contents

# frozen_string_literal: true

module SolidusAfterpay
  class ShippingRatePresenter
    def initialize(shipping_rate:)
      @shipping_rate = shipping_rate
    end

    def order_amount
      shipping_rate.order.item_total.to_f +
        shipping_rate.cost +
        shipping_rate.taxes.sum(&:amount) +
        order_presenter.line_items_tax_amount
    end

    def amount_with_taxes
      shipping_rate.cost.to_f + shipping_rate.taxes.sum(&:amount)
    end

    private

    def order_presenter
      @order_presenter ||= SolidusAfterpay::OrderPresenter.new(order: shipping_rate.order)
    end

    attr_reader :shipping_rate
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_afterpay-0.3.0 app/presentes/solidus_afterpay/shipping_rate_presenter.rb
solidus_afterpay-0.2.0 app/presentes/solidus_afterpay/shipping_rate_presenter.rb