Files
openfoodnetwork/app/models/order_balance.rb
Pau Perez 5bca7d1f8f Remove the old balance's code branch
This keeps the `OrderBalance` abstraction but removes the old code now
that the feature is enabled for all users in all instances and there are
no bugs reported. It's become dead code.
2021-04-19 11:52:41 +02:00

30 lines
472 B
Ruby

# frozen_string_literal: true
class OrderBalance
delegate :zero?, :abs, :to_s, :to_f, :to_d, :<, :>, to: :amount
def initialize(order)
@order = order
end
def label
amount.negative? ? I18n.t(:credit_owed) : I18n.t(:balance_due)
end
def display_amount
Spree::Money.new(amount, currency: order.currency)
end
def amount
order.new_outstanding_balance
end
def +(other)
amount + other.to_f
end
private
attr_reader :order
end