mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
To keep the same method calls that are used on the legacy invoice template. I needed to redefine blank? on the address presenter.
39 lines
928 B
Ruby
39 lines
928 B
Ruby
# frozen_string_literal: false
|
|
|
|
class Invoice
|
|
class DataPresenter
|
|
class Address < Invoice::DataPresenter::Base
|
|
attributes :firstname, :lastname, :address1, :address2, :city, :zipcode, :company, :phone
|
|
attributes_with_presenter :state
|
|
invoice_generation_attributes :firstname, :lastname, :address1, :address2, :city, :zipcode,
|
|
:company, :phone
|
|
|
|
def full_name
|
|
"#{firstname} #{lastname}".strip
|
|
end
|
|
|
|
def address_part1
|
|
render_address([address1, address2])
|
|
end
|
|
|
|
def address_part2
|
|
render_address([city, zipcode, state&.name])
|
|
end
|
|
|
|
def full_address
|
|
render_address([address1, address2, city, zipcode, state&.name])
|
|
end
|
|
|
|
def blank?
|
|
@data.nil?
|
|
end
|
|
|
|
private
|
|
|
|
def render_address(address_parts)
|
|
address_parts.compact_blank.join(', ')
|
|
end
|
|
end
|
|
end
|
|
end
|