Sha256: 163e97f2a7273ad2883d9626ba597993760c7ae9f1c50b7560dc7f6a1ac1e6e5

Contents?: true

Size: 1.72 KB

Versions: 3

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

class LineItem
  include SK::Calc
  attr_accessor :price_single, :tax, :quantity, :discount
  calculates :item
end

describe SK::Calc do

 describe 'item calculations' do

    before :each do
      @i = LineItem.new
      @i.price_single = 10.0
      @i.discount = 0
      @i.quantity = 1
      @i.tax = 19.0
    end

    it "should calc net_single" do
      @i.net_single.should == 10.00
    end

    it "should calc gross_single" do
      @i.gross_single.should == 11.90
    end

    it "should calc total" do
      @i.total.should == 10.0
    end

    it "should calc net_total" do
      @i.net_total.should == 10.0
    end

    it "should calc gross_total" do
      @i.gross_total.should == 11.90
    end

    it "should calc net_total_base" do
      @i.net_total_base.should == 10.00
    end

    it "should calc tax_total" do
      @i.tax_total.should == 1.90
    end
  end

  describe 'calculates 15.00 gross price' do

    before :each do
      @i = LineItem.new
      @i.price_single = 12.605
      @i.discount = 0
      @i.quantity = 1
      @i.tax = 19.0
    end

    it "should calc total" do
      @i.total.should == 12.605
    end

    it "should calc net_total" do
      @i.net_total.to_f.should == 12.61
    end

    it "should calc gross_total" do
      @i.gross_total.should == 15.0
    end

    it "should calc net_total_base" do
      @i.net_total_base.should == 12.605
    end
    it "should calc net_total" do
      @i.net_total.should == 12.61
    end

    it "should calc tax_total_base" do
      @i.tax_total_base.should == 2.39495
    end

    it "should calc tax_total_4" do
      @i.tax_total_4.should == 2.395
    end

    it "should calc tax_total" do
      @i.tax_total.should == 2.39
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sk_calc-0.0.5 spec/sk_calc/item_spec.rb
sk_calc-0.0.4 spec/sk_calc/item_spec.rb
sk_calc-0.0.3 spec/sk_calc/item_spec.rb