Module: FacturaePrint::Renderers::HTMLRendererHelpers

Defined in:
lib/facturae_print/renderers/html_renderer_helpers.rb

Constant Summary collapse

TAX_ABBREVIATIONS =
{
  '01' => 'IVA',
  '02' => 'IPSI',
  '03' => 'IGIC',
  '04' => 'IRPF',
  '05' => 'Otro',
  '06' => 'ITPAJD',
  '07' => 'IE',
  '08' => 'Ra',
  '09' => 'IGTECM',
  '10' => 'IECDPCAC',
  '11' => 'IIIMAB',
  '12' => 'ICIO',
  '13' => 'IMVDN',
  '14' => 'IMSN',
  '15' => 'IMGSN',
  '16' => 'IMPN',
  '17' => 'REIVA',
  '18' => 'REIGIC',
  '19' => 'REIPSI'
}

Instance Method Summary collapse

Instance Method Details

#currency_symbol(currency_code) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/facturae_print/renderers/html_renderer_helpers.rb', line 13

def currency_symbol(currency_code)
  case currency_code
  when "EUR"
    ""
  when "USD"
    "$"
  else
    currency_code
  end
end

#formatted_date(date, strftime = "%d/%m/%Y") ⇒ Object



28
29
30
# File 'lib/facturae_print/renderers/html_renderer_helpers.rb', line 28

def formatted_date(date, strftime="%d/%m/%Y")
  (date.is_a?(String) ? Date.parse(date) : date).strftime(strftime)
end

#individual_full_name(individual) ⇒ Object



24
25
26
# File 'lib/facturae_print/renderers/html_renderer_helpers.rb', line 24

def individual_full_name(individual)
  [individual.name, individual.first_surname, individual.second_surname].compact.join(' ')
end

#tax_abbreviation(tax_type_code) ⇒ Object



32
33
34
# File 'lib/facturae_print/renderers/html_renderer_helpers.rb', line 32

def tax_abbreviation(tax_type_code)
  TAX_ABBREVIATIONS[tax_type_code]
end

#tax_description(tax_type_code, tax_rate) ⇒ Object



36
37
38
# File 'lib/facturae_print/renderers/html_renderer_helpers.rb', line 36

def tax_description(tax_type_code, tax_rate)
  "#{tax_abbreviation(tax_type_code)} #{tax_rate.to_i}%"
end

#to_currency(amount) ⇒ Object



8
9
10
11
# File 'lib/facturae_print/renderers/html_renderer_helpers.rb', line 8

def to_currency(amount)
  @invoice_currency_symbol ||= currency_symbol(@invoice.invoices.first.invoice_issue_data.invoice_currency_code)
  "#{amount} #{@invoice_currency_symbol}"
end