Sha256: d54546f085b8bde194002290dcc34ffbc458a53e0fd1d0815dcf1f2dae04cebc

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 Bytes

Contents

require 'pdv/version'
require 'active_support'
require 'active_support/number_helper'
require 'i18n'
require 'set'

# Izbegni upozorenje
I18n.enforce_available_locales = true

module PDV
  
  TAX       = 0.2
  PRECISION = 2
  RJUST     = 20

  # Za dati neto iznos prikazuje formatiran neto, pdv i bruto
  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

  def _format(amount)
    format_options = {separator: ',', delimiter: '.', precision: PRECISION}
    ActiveSupport::NumberHelper.number_to_rounded(amount, format_options).rjust(RJUST)
  end

  def _round(amount)
    amount.round(PRECISION)
  end

  extend self
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pdv-0.0.1 lib/pdv.rb