Sha256: 8614650f2cf446e0f5b3ffd9ee8dfe3c663e4459993b12db57e5104f31e42094

Contents?: true

Size: 433 Bytes

Versions: 1

Compression:

Stored size: 433 Bytes

Contents

require 'bigdecimal'
require 'bigdecimal/util'

class BigDecimal

  def inc_vat
    (self * vat_rate).to_d
  end
  
  def ex_vat
    (self / vat_rate).to_d
  end
  
  def next_ninety_nine
    self.ceil - BigDecimal.new("0.01")
  end
    
  old_to_s = instance_method :to_s

  define_method :to_s do |*param|
    "%.2f" % self.round(2)
  end
  
  protected
    def vat_rate
      1 + (Corrency::Config.vat_rate.to_f / 100)
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
corrency-0.2.0 lib/core_ext/big_decimal.rb