module OpenFoodNetwork
  class UserBalanceCalculator
    def initialize(email, distributor)
      @email = email
      @distributor = distributor
    end

    def balance
      -completed_orders.to_a.sum(&:outstanding_balance)
    end

    private

    def completed_orders
      Spree::Order.where(distributor_id: @distributor, email: @email).complete.not_state(:canceled)
    end
  end
end

module OpenFoodNetwork
  class UserBalanceCalculator
    def initialize(email, distributor)
      @email = email
      @distributor = distributor
    end

    def balance
      -completed_orders.to_a.sum(&:old_outstanding_balance)
    end

    private

    def completed_orders
      Spree::Order.where(distributor_id: @distributor, email: @email).complete.not_state(:canceled)
    end
  end
end

Make BalanceCalculator use old balance calculation
Make BalanceCalculator use old balance calculation

This class is currently used and it gets skipped when the
:customer_balance toggle is enabled, so there's no point on abstracting
the balance with `OrderBalance`. It'll never go through its
`#new_outstanding_balance` branch and it'll be removed once we active
that toggle to everyone.
