sk_calc 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Zjk4Y2ZlMmY2N2EwMTY2NmE4ZjM2MjhkYzc2ODA3YjdmNjIwMjljNA==
4
+ OWMxYjkzZDAwNGY2ZDk3ZjIwZDkxZTllNTkzZDliOTc1ZThiNGJjYg==
5
5
  data.tar.gz: !binary |-
6
- MmU2OTgyZDQwNzA5YjRlZjNhMjhjMWNkMzAyMTc4NzE3Yzk2MzIyMA==
6
+ NDk4YmZjYzRjZTc4OGEyMjI1OTc5YzJhZWFjNGQ5NTFkNWQ1OTYwNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MThiZTg5ZTc4OGQ0NTg4MTllNjA3OTQ3ZGQ4ZTJlNjU2OTdhODgwNjI0MGNh
10
- OGIyZmJjNDY2NzQ5NmE3ZDE1YTdlMDM2YWM3MDRkNTU0MmExM2M3ZDgzNTBi
11
- N2YxZjJmZGI1MmE2YWJiYmUzM2UzYWFiNWNiNzQ2NThkNDFhNWQ=
9
+ MWYyMDU5NDkwMjYwMjJmNGI1YWVhNWI3YzA3ODM2YTJjMmYxMmRiNWY5M2Y4
10
+ YjRiYzQ0MTAzNmRlNzI1ZGE1MmQwMDBhMjhjZTM0NWMzZDBhMDNkM2FiM2Yw
11
+ YTYxNGFlNjUxNWZjYjM4MGU4ODk3MTJiYWRkMzQwNTlhMTk3MDQ=
12
12
  data.tar.gz: !binary |-
13
- MTU0OWQyNzFiYjFjZmE5Njg4ZWI4MTEwZjdhYjlmNmMyNTg2MTU5ZTE0ZTgy
14
- N2Y1NGI1NWU2MTFmYmVlYmRmNDM2OTBkMGMyNWRhNDNmZTVmMTUxY2E0MTZh
15
- N2MzMDMxMTEyZmY0OTY0ZTBkNDlhMTYyOWE4NGFkZDNmODg2YTQ=
13
+ ZTYzYTA1OTU4YjA3YzViZTQzODRhZTY3NmQ3MDc2MGU4ZTBlZWZjNjkyNmU3
14
+ N2NhNzYxZjg5ZmMxZjc2ZjE5M2EwZTI0MTlmNWIxNGFiYjVmM2U4MDJiNTc5
15
+ OTRkYjdjNTFmYzM3NTE3ZThjMzRmYzU5MjkwM2Y3ZjAyMmY3NjQ=
@@ -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
@@ -1,5 +1,5 @@
1
1
  module SK
2
2
  module Calc
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
@@ -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 "should calc net_total" do
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 "should calc gross_total" do
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 "should sum totals" do
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
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.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Leciejewski