Sha256: 7341dd7e932d92244c90738b58e98d61dbe6ccbf82486cc55ed0c8b8558bbb77

Contents?: true

Size: 627 Bytes

Versions: 5

Compression:

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

    protected
      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

5 entries across 5 versions & 1 rubygems

Version Path
polish_invoicer-0.0.5 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.4 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.3 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.2 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.1 lib/polish_invoicer/vat.rb