Sha256: b2b1125837cb4b4e08a2bb7e6b9916e7868ac21c98dabf304056707d925b018d

Contents?: true

Size: 606 Bytes

Versions: 12

Compression:

Stored size: 606 Bytes

Contents

module PolishInvoicer
  class Vat
    def self.rates
      [23, 8, 5, 0, -1] # -1 oznacza zwolniony z VAT
    end

    def self.valid?(rate)
      rates.include?(rate)
    end

    # Czy stawka VAT to "zwolniony"?
    def self.zw?(rate)
      rate == -1
    end

    def self.to_s(rate)
      hash.invert[rate]
    end

    # Potrzebne do obliczeń netto/vat/brutto
    def self.to_i(rate)
      rate != -1 ? rate : 0
    end

    private

    def self.hash
      h = {}
      rates.each do |r|
        name = "#{r}%"
        name = 'zw.' if r == -1
        h[name] = r
      end
      h
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
polish_invoicer-0.0.17 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.16 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.15 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.14 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.13 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.12 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.11 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.10 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.9 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.8 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.7 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.6 lib/polish_invoicer/vat.rb