Introduce helper method

#623
This commit is contained in:
Artur Beljajev 2018-03-13 11:39:18 +02:00
parent 3ed6416e50
commit beba81bc6d
5 changed files with 8 additions and 4 deletions

View file

@ -89,4 +89,8 @@ module ApplicationHelper
types.delete('ddoc') types.delete('ddoc')
".#{types.join(',.')}" ".#{types.join(',.')}"
end end
def vat_rate(value)
number_to_percentage(value, precision: 1)
end
end end

View file

@ -8,7 +8,7 @@
<dd><%= registrar.vat_no %></dd> <dd><%= registrar.vat_no %></dd>
<dt><%= Registrar.human_attribute_name :vat_rate %></dt> <dt><%= Registrar.human_attribute_name :vat_rate %></dt>
<dd><%= number_to_percentage registrar.vat_rate, precision: 1 %></dd> <dd><%= vat_rate registrar.vat_rate %></dd>
<dt><%= Registrar.human_attribute_name :accounting_customer_code %></dt> <dt><%= Registrar.human_attribute_name :accounting_customer_code %></dt>
<dd><%= registrar.accounting_customer_code %></dd> <dd><%= registrar.accounting_customer_code %></dd>

View file

@ -24,7 +24,7 @@
%td= currency(@invoice.subtotal) %td= currency(@invoice.subtotal)
%tr %tr
%th.no-border{colspan: 3} %th.no-border{colspan: 3}
%th= t('vat', rate: number_to_percentage(@invoice.vat_rate, precision: 1)) %th= t('vat', rate: vat_rate(@invoice.vat_rate))
%td= currency(@invoice.vat) %td= currency(@invoice.vat)
%tr %tr
%th.no-border{colspan: 3} %th.no-border{colspan: 3}

View file

@ -242,7 +242,7 @@
%td= "#{currency(@invoice.subtotal)} #{@invoice.currency}" %td= "#{currency(@invoice.subtotal)} #{@invoice.currency}"
%tr %tr
%th.no-border{colspan: 3} %th.no-border{colspan: 3}
%th= t('vat', rate: number_to_percentage(@invoice.vat_rate, precision: 1)) %th= t('vat', rate: vat_rate(@invoice.vat_rate))
%td= "#{currency(@invoice.vat)} #{@invoice.currency}" %td= "#{currency(@invoice.vat)} #{@invoice.currency}"
%tr %tr
%th.no-border{colspan: 3} %th.no-border{colspan: 3}

View file

@ -22,6 +22,6 @@ class ShowRegistrarTest < ActionDispatch::IntegrationTest
end end
def test_vat_rate def test_vat_rate
assert_text number_to_percentage(@registrar.vat_rate, precision: 1) assert_text vat_rate(@registrar.vat_rate)
end end
end end