sk_calc 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTI1NzM2ZTM1YmJhOGFmMDgwODYwYTE3MWRkYTMzZjM4MDgxNDJkNA==
4
+ Zjk4Y2ZlMmY2N2EwMTY2NmE4ZjM2MjhkYzc2ODA3YjdmNjIwMjljNA==
5
5
  data.tar.gz: !binary |-
6
- MTJlMDVmMjNkMDg3Y2E4NmIxMWU5YzA3NGE0ZjgxZTg5ZDVjZGQ3ZA==
6
+ MmU2OTgyZDQwNzA5YjRlZjNhMjhjMWNkMzAyMTc4NzE3Yzk2MzIyMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjcyNGZiYmExNDcwMGY4MzkxNjM4YmJiNWQ2NWE3YzYxODllODVmZmMzMGVm
10
- OGZlNTU5ODgwMTBiMjNlZTM5NDg3OGFiNGEzNzRmZDQ4MTVhNjNhODU1ZGIz
11
- OGVhNDhjNWIzZmZiZTFiMDA5MDNlMzU2NTk2ODI4MjdhMzIwOTI=
9
+ MThiZTg5ZTc4OGQ0NTg4MTllNjA3OTQ3ZGQ4ZTJlNjU2OTdhODgwNjI0MGNh
10
+ OGIyZmJjNDY2NzQ5NmE3ZDE1YTdlMDM2YWM3MDRkNTU0MmExM2M3ZDgzNTBi
11
+ N2YxZjJmZGI1MmE2YWJiYmUzM2UzYWFiNWNiNzQ2NThkNDFhNWQ=
12
12
  data.tar.gz: !binary |-
13
- NjA4ZmM4NjgyNTI1YWFlZThiNzY4YzZmYmY5Y2QyYjI0NDM0NGQ3NjQxMzA2
14
- ZDBiNTgyOTA0ZDVhNmViNTYzZGViNTRmNGE0ODc1ZDRmOGFmYjZjOWQ5MWVk
15
- NWE4NmNiMWZiOGYzNGI4Nzk2MDllMGRlMGQxYzM1YTg4Y2I0MmE=
13
+ MTU0OWQyNzFiYjFjZmE5Njg4ZWI4MTEwZjdhYjlmNmMyNTg2MTU5ZTE0ZTgy
14
+ N2Y1NGI1NWU2MTFmYmVlYmRmNDM2OTBkMGMyNWRhNDNmZTVmMTUxY2E0MTZh
15
+ N2MzMDMxMTEyZmY0OTY0ZTBkNDlhMTYyOWE4NGFkZDNmODg2YTQ=
@@ -79,7 +79,7 @@ module SK::Calc::Item
79
79
  # Use it to do calculations!
80
80
  # @return [Rational]
81
81
  def total
82
- conv_price_single * ( quantity || 0)
82
+ conv_price_single * conv_quantity
83
83
  end
84
84
 
85
85
  ############################################
@@ -149,4 +149,8 @@ module SK::Calc::Item
149
149
  ((self.respond_to?(:tax) && tax) || 0).to_r
150
150
  end
151
151
 
152
+ def conv_quantity
153
+ (quantity || 0).to_r
154
+ end
155
+
152
156
  end
@@ -1,5 +1,5 @@
1
1
  module SK
2
2
  module Calc
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
@@ -34,6 +34,12 @@ describe SK::Calc do
34
34
  i = ItemWithoutFields.new
35
35
  i.send(:conv_discount).should == 0
36
36
  end
37
+
38
+ it 'conv_quantity' do
39
+ i = ItemWithoutFields.new
40
+ i.send(:conv_quantity).should == 0
41
+ i.send(:conv_quantity).should be_a Rational
42
+ end
37
43
  end
38
44
 
39
45
  describe 'item calculations' do
@@ -46,31 +52,31 @@ describe SK::Calc do
46
52
  @i.tax = 19.0
47
53
  end
48
54
 
49
- it "should calc net_single" do
55
+ it "has net_single" do
50
56
  @i.net_single.should == 10.00
51
57
  end
52
58
 
53
- it "should calc gross_single" do
59
+ it "has gross_single" do
54
60
  @i.gross_single.should == 11.90
55
61
  end
56
62
 
57
- it "should calc total" do
63
+ it "has total" do
58
64
  @i.total.should == 10.0
59
65
  end
60
66
 
61
- it "should calc net_total" do
67
+ it "has net_total" do
62
68
  @i.net_total.should == 10.0
63
69
  end
64
70
 
65
- it "should calc gross_total" do
71
+ it "has gross_total" do
66
72
  @i.gross_total.should == 11.90
67
73
  end
68
74
 
69
- it "should calc net_total_base" do
75
+ it "has net_total_base" do
70
76
  @i.net_total_base.should == 10.00
71
77
  end
72
78
 
73
- it "should calc tax_total" do
79
+ it "has tax_total" do
74
80
  @i.tax_total.should == 1.90
75
81
  end
76
82
  end
@@ -85,32 +91,43 @@ describe SK::Calc do
85
91
  @i.tax = 19.0
86
92
  end
87
93
 
88
- it "should calc total" do
94
+ it "has total" do
89
95
  @i.total.should == 12.605
90
96
  end
91
97
 
92
- it "should calc net_total" do
98
+ it "has net_total" do
93
99
  @i.net_total.to_f.should == 12.61
94
100
  end
95
101
 
96
- it "should calc gross_total" do
102
+ it "has gross_total" do
97
103
  @i.gross_total.should == 15.0
98
104
  end
99
105
 
100
- it "should calc net_total_base" do
106
+ it "has net_total_base" do
101
107
  @i.net_total_base.should == 12.605
102
108
  end
103
- it "should calc net_total" do
109
+ it "has net_total" do
104
110
  @i.net_total.should == 12.61
105
111
  end
106
112
 
107
- it "should calc tax_total_base" do
113
+ it "has tax_total_base" do
108
114
  @i.tax_total_base.should == 2.39495
109
115
  end
110
116
 
111
- it "should calc tax_total" do
117
+ it "has tax_total" do
112
118
  @i.tax_total.should == 2.39
113
119
  end
120
+ end
114
121
 
122
+ describe 'calculates with mixed values' do
123
+
124
+ it 'converts quantity to rationale' do
125
+ i = LineItem.new
126
+ i.price_single = 12345.123456
127
+ i.quantity = BigDecimal.new("1.0")
128
+ i.total.should == 12345.123456
129
+ i.total.should be_a Rational
130
+ end
115
131
  end
132
+
116
133
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sk_calc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Leciejewski