Sha256: 72f7a737bf4526b65a623d7d2836321348226ce2b694d9382fe1d8304fdc56ea

Contents?: true

Size: 514 Bytes

Versions: 2

Compression:

Stored size: 514 Bytes

Contents

# frozen_string_literal: true

module PolishInvoicer
  class Vat
    def self.rates
      (0..27)
    end

    def self.valid?(rate)
      return true if zw?(rate)

      rates.include?(rate)
    end

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

    def self.to_s(rate)
      return 'zw.' if zw?(rate)

      "#{rate}%"
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polish_invoicer-0.0.29 lib/polish_invoicer/vat.rb
polish_invoicer-0.0.28 lib/polish_invoicer/vat.rb