Sha256: 086e7726030e598f38cac50fbdea5b45dbb63776397245a31cba7c3575d4f006

Contents?: true

Size: 593 Bytes

Versions: 2

Compression:

Stored size: 593 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

    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

2 entries across 2 versions & 1 rubygems

Version Path
polish_invoicer-0.0.19 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.18 lib/polish_invoicer/vat.rb