Files
openfoodnetwork/app/models/invoice/data_presenter/line_item.rb
Matt-Yorkley 72e537b598 Update *_amount_with_adjustments methods on LineItem presenter
These methods are slightly different and they're both needed in the template for invoice4
2023-06-18 21:03:13 +02:00

34 lines
1.1 KiB
Ruby

# frozen_string_literal: false
class Invoice
class DataPresenter
class LineItem < Invoice::DataPresenter::Base
attributes :added_tax, :currency, :included_tax, :price_with_adjustments, :quantity,
:variant_id
attributes_with_presenter :variant
invoice_generation_attributes :added_tax, :included_tax, :price_with_adjustments,
:quantity, :variant_id
delegate :name_to_display, :options_text, to: :variant
def display_amount_with_adjustments
Spree::Money.new((price_with_adjustments * quantity), currency: currency)
end
def single_display_amount_with_adjustments
Spree::Money.new(price_with_adjustments, currency: currency)
end
def display_line_items_taxes(display_zero: true)
if included_tax.positive?
Spree::Money.new( included_tax, currency: currency)
elsif added_tax.positive?
Spree::Money.new( added_tax, currency: currency)
elsif display_zero
Spree::Money.new(0.00, currency: currency)
end
end
end
end
end