sk_calc 0.0.2 → 0.0.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.3
data/lib/sk_calc/item.rb CHANGED
@@ -150,6 +150,59 @@ module SK::Calc::Item
150
150
  gross_single_base.round(2)
151
151
  end
152
152
 
153
+ ############################################
154
+ ### DISPLAY VALUES 4
155
+ ############################################
156
+ ### These values are used only to display to a user.
157
+ ### Use values under BASE VALUES section
158
+ ### for calculations!
159
+
160
+ # Total gross price incl. discount
161
+ # ==== Returns
162
+ # <BigDecimal>:: rounded 2 decimals
163
+ def gross_total_4
164
+ gross_total_base.round(4)
165
+ end
166
+
167
+ # Total net price(2 decimals) incl. discount
168
+ # ==== Returns
169
+ # <BigDecimal>:: rounded 2 decimals
170
+ def net_total_4
171
+ net_total_base.round(4)
172
+ end
173
+
174
+
175
+ # ==== Returns
176
+ # <BigDecimal>:: rounded 2 decimals
177
+ def tax_total_4
178
+ tax_total_base.round(4)
179
+ end
180
+
181
+ # The discount amount
182
+ # ==== Returns
183
+ # <BigDecimal>:: rounded 2 decimals
184
+ def discount_total_4
185
+ discount_total_base.round(4)
186
+ end
187
+
188
+
189
+ # Single net price with discount applied rounded 2.
190
+ # DO NOT use this method to calculate(eg. totals for a document) use net_total
191
+ # or gross_total instead
192
+ # ==== Returns
193
+ # <BigDecimal>:: rounded 2 decimals
194
+ def net_single_4
195
+ net_single_base.round(4)
196
+ end
197
+
198
+ # Single gross price rounded 2.
199
+ # DONT use this method to calculate(eg. totals for a document) use net_total
200
+ # or gross_total instead
201
+ # ==== Returns
202
+ # <BigDecimal>:: rounded 2 decimals
203
+ def gross_single_4
204
+ gross_single_base.round(4)
205
+ end
153
206
 
154
207
  private
155
208
 
data/lib/sk_calc/items.rb CHANGED
@@ -6,10 +6,16 @@
6
6
  # - line_items
7
7
  module SK::Calc::Items
8
8
  include SK::Calc::Helper
9
- # Gross total always rounded to 2 decimals
10
- def gross_total
11
- val = (net_total_base || 0) + conv_tax
12
- val.round(2)
9
+
10
+ # Unrounded net total so one can see the base sum of the line items before
11
+ # rounding
12
+ def net_total_base
13
+ conv_price_total
14
+ end
15
+
16
+ # Gross total
17
+ def gross_total_base
18
+ (net_total_base || 0) + conv_tax
13
19
  end
14
20
 
15
21
  # Net total rounded to 2 decimals, the taxation base
@@ -17,10 +23,9 @@ module SK::Calc::Items
17
23
  net_total_base.round(2)
18
24
  end
19
25
 
20
- # Unrounded net total so one can see the base sum of the line items before
21
- # rounding
22
- def net_total_base
23
- conv_price_total
26
+ # Gross total rounded to 2 decimals
27
+ def gross_total
28
+ gross_total_base.round(2)
24
29
  end
25
30
 
26
31
  # Rounded price_tax to 2 decimals
@@ -28,6 +33,16 @@ module SK::Calc::Items
28
33
  conv_tax.round(2)
29
34
  end
30
35
 
36
+ # Net total rounded to 2 decimals, the taxation base
37
+ def net_total_4
38
+ net_total_base.round(4)
39
+ end
40
+
41
+ # Rounded price_tax to 2 decimals
42
+ def tax_total_4
43
+ conv_tax.round(4)
44
+ end
45
+
31
46
  # Save items sums of net total and summed taxes into the price_total,
32
47
  # tax_total
33
48
  def sum_items(items=nil)
@@ -1,5 +1,5 @@
1
1
  module SK
2
2
  module Calc
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
data/sk_calc.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = SK::Calc::VERSION
8
8
 
9
9
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
- s.authors = ["Georg Leciejewski"]
10
+ s.authors = ["Georg Leciejewski", "Mike Połtyn"]
11
11
  s.date = %q{2012-02-15}
12
12
  s.description = %q{Calculate document and line item totals. This moule is used inside SalesKIng and outsourced for transparency and reusability.}
13
13
  s.email = %q{gl@salesking.eu}
@@ -80,6 +80,10 @@ describe SK::Calc do
80
80
  @i.tax_total_base.should == 2.39495
81
81
  end
82
82
 
83
+ it "should calc tax_total_4" do
84
+ @i.tax_total_4.should == 2.395
85
+ end
86
+
83
87
  it "should calc tax_total" do
84
88
  @i.tax_total.should == 2.39
85
89
  end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sk_calc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Georg Leciejewski
14
+ - "Mike Po\xC5\x82tyn"
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []