Module: PDV
Constant Summary collapse
- TAX =
0.2- PRECISION =
2- RJUST =
20- VERSION =
"0.0.1"
Instance Method Summary collapse
- #_format(amount) ⇒ Object
- #_round(amount) ⇒ Object
-
#za(neto) ⇒ Object
Za dati neto iznos prikazuje formatiran neto, pdv i bruto.
Instance Method Details
#_format(amount) ⇒ Object
30 31 32 33 |
# File 'lib/pdv.rb', line 30 def _format(amount) = {separator: ',', delimiter: '.', precision: PRECISION} ActiveSupport::NumberHelper.number_to_rounded(amount, ).rjust(RJUST) end |
#_round(amount) ⇒ Object
35 36 37 |
# File 'lib/pdv.rb', line 35 def _round(amount) amount.round(PRECISION) end |
#za(neto) ⇒ Object
Za dati neto iznos prikazuje formatiran neto, pdv i bruto
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pdv.rb', line 17 def za(neto) neto_amount = _round neto tax_amount = _round(neto_amount * TAX) bruto_amount = _round(neto_amount + tax_amount) puts puts " NETO: #{_format neto_amount}" puts " PDV: #{_format tax_amount}" puts " -------#{'-'*RJUST}" puts " BRUTO: #{_format bruto_amount}" puts end |