lib/polish_invoicer/presenter.rb in polish_invoicer-0.0.5 vs lib/polish_invoicer/presenter.rb in polish_invoicer-0.0.6
- old
+ new
@@ -1,6 +1,5 @@
-# encoding: utf-8
module PolishInvoicer
class Presenter
attr_accessor :invoice
def initialize(invoice)
@@ -17,47 +16,48 @@
format_comments
format_vat
@out
end
- protected
- def copy_available_params
- Invoice::AVAILABLE_PARAMS.each do |field|
- @out[field] = @invoice.send(field)
- end
- end
+ private
- def remove_redundand_params
- @out.delete(:price)
+ def copy_available_params
+ Invoice::AVAILABLE_PARAMS.each do |field|
+ @out[field] = @invoice.send(field)
end
+ end
- def copy_additional_params
- %w(net_value vat_value gross_value).each do |field|
- @out[field.to_sym] = @invoice.send(field)
- end
- end
+ def remove_redundand_params
+ @out.delete(:price)
+ end
- def format_dates
- %w(trade_date create_date payment_date).each do |field|
- v = @invoice.send(field)
- next unless v
- @out[field.to_sym] = v.strftime "%d.%m.%Y"
- end
+ def copy_additional_params
+ %w(net_value vat_value gross_value).each do |field|
+ @out[field.to_sym] = @invoice.send(field)
end
+ end
- def format_prices
- %w(net_value vat_value gross_value).each do |field|
- v = @invoice.send(field)
- next unless v
- @out[field.to_sym] = sprintf("%02.2f", v).gsub('.', ',')
- end
+ def format_dates
+ %w(trade_date create_date payment_date).each do |field|
+ v = @invoice.send(field)
+ next unless v
+ @out[field.to_sym] = v.strftime '%d.%m.%Y'
end
+ end
- def format_comments
- @out[:comments] = [@invoice.comments].flatten.compact
+ def format_prices
+ %w(net_value vat_value gross_value).each do |field|
+ v = @invoice.send(field)
+ next unless v
+ @out[field.to_sym] = sprintf('%02.2f', v).tr('.', ',')
end
+ end
- def format_vat
- @out[:vat] = Vat.to_s(@invoice.vat)
- end
+ def format_comments
+ @out[:comments] = [@invoice.comments].flatten.compact
+ end
+
+ def format_vat
+ @out[:vat] = Vat.to_s(@invoice.vat)
+ end
end
end