sk_calc 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/sk_calc/items.rb +1 -1
- data/lib/sk_calc/version.rb +1 -1
- data/spec/sk_calc/items_spec.rb +12 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWMxYjkzZDAwNGY2ZDk3ZjIwZDkxZTllNTkzZDliOTc1ZThiNGJjYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDk4YmZjYzRjZTc4OGEyMjI1OTc5YzJhZWFjNGQ5NTFkNWQ1OTYwNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWYyMDU5NDkwMjYwMjJmNGI1YWVhNWI3YzA3ODM2YTJjMmYxMmRiNWY5M2Y4
|
10
|
+
YjRiYzQ0MTAzNmRlNzI1ZGE1MmQwMDBhMjhjZTM0NWMzZDBhMDNkM2FiM2Yw
|
11
|
+
YTYxNGFlNjUxNWZjYjM4MGU4ODk3MTJiYWRkMzQwNTlhMTk3MDQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTYzYTA1OTU4YjA3YzViZTQzODRhZTY3NmQ3MDc2MGU4ZTBlZWZjNjkyNmU3
|
14
|
+
N2NhNzYxZjg5ZmMxZjc2ZjE5M2EwZTI0MTlmNWIxNGFiYjVmM2U4MDJiNTc5
|
15
|
+
OTRkYjdjNTFmYzM3NTE3ZThjMzRmYzU5MjkwM2Y3ZjAyMmY3NjQ=
|
data/lib/sk_calc/items.rb
CHANGED
@@ -73,7 +73,7 @@ module SK::Calc::Items
|
|
73
73
|
result = {}
|
74
74
|
items.group_by(&:tax).each do |tax, item_group|
|
75
75
|
net_total_sum = item_group.to_a.sum(&:net_total_base)
|
76
|
-
result[tax] = (net_total_sum * tax / 100.0).round(SK::Calc.precision) if tax && !tax.zero?
|
76
|
+
result[tax] = (net_total_sum * tax.to_r / 100.0).round(SK::Calc.precision) if tax && !tax.zero?
|
77
77
|
end
|
78
78
|
result.sort
|
79
79
|
end
|
data/lib/sk_calc/version.rb
CHANGED
data/spec/sk_calc/items_spec.rb
CHANGED
@@ -20,27 +20,33 @@ describe SK::Calc, 'items calculations' do
|
|
20
20
|
@i.discount = 0
|
21
21
|
@i.quantity = 1
|
22
22
|
@i.tax = 19.0
|
23
|
-
|
23
|
+
|
24
24
|
@doc = Doc.new
|
25
25
|
@doc.line_items = [@i]
|
26
|
-
|
27
|
-
|
28
26
|
end
|
29
27
|
|
30
|
-
it "
|
28
|
+
it "calc net_total" do
|
31
29
|
@doc.sum_items
|
32
30
|
@doc.net_total.should == 10.0
|
33
31
|
end
|
34
32
|
|
35
|
-
it "
|
33
|
+
it "calc gross_total" do
|
36
34
|
@doc.sum_items
|
37
35
|
@doc.gross_total.should == 11.90
|
38
36
|
end
|
39
37
|
|
40
|
-
it "
|
38
|
+
it "sums totals" do
|
41
39
|
@doc.sum_items
|
42
40
|
@doc.price_total.should == 10.0
|
43
41
|
@doc.price_tax.should == 1.90
|
44
42
|
end
|
45
43
|
|
44
|
+
it "sums items with tax as rational" do
|
45
|
+
@i.price_single = 7142.857143
|
46
|
+
@i.tax = BigDecimal('19.0')
|
47
|
+
@doc.sum_items
|
48
|
+
@doc.price_total.should == 7142.857143
|
49
|
+
@doc.price_tax.should == 1357.142857
|
50
|
+
@doc.gross_total.should == 8500.00
|
51
|
+
end
|
46
52
|
end
|