jptax 0.1.1 → 0.1.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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b988ae4b21478bbe36fb76183d6f87427c5e62756033f0f018e19e507258a40
4
- data.tar.gz: c7b089591c549a40dacda6b2f0ef60237193666f5e494654f9c1e61a1eb54659
3
+ metadata.gz: 7ede5229c1ac11d3dab9aa2e93dab639bd5ed10016807252fb0eca95c383b1da
4
+ data.tar.gz: 5e69b40ec461dbc71035051274f7c696a5d6f58350f7bb3bbd94212c2f0f1869
5
5
  SHA512:
6
- metadata.gz: 1bd413d43164984614a328b2d36ab2479d6375382146cd4ef024e2b61a5ccfe375cdc0cab4e3068eb52df39efd38cad567fae8dcc32f970ac9996688c15961f8
7
- data.tar.gz: 707a6d2c165e0145f29cb74502e5c8c0838758e95f3a422b53837b03aecf8c01e9076fd5dc9843015f8749cb6ad04e7e0d33e65a2b9f4318bbb04f5a192aa17a
6
+ metadata.gz: 06a2e6afeb9bc6c98387b9d2d3274dffc4afd0a80c2ea1daa5306bad696a7a893109aa3279882a5a4eabebff876d72314658a94735eceadc2d2f4534161a57b4
7
+ data.tar.gz: 11fb19218f86d977325337a2fdcc67c51b47fefaf3b323905780b70e835ce34d78d67380bacdd54a1ac7e89977a9c5ab4222508792552963c9a44b4687f65208
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jptax (0.1.1)
4
+ jptax (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  diff-lcs (1.3)
10
- rake (10.5.0)
10
+ rake (13.0.1)
11
11
  rspec (3.7.0)
12
12
  rspec-core (~> 3.7.0)
13
13
  rspec-expectations (~> 3.7.0)
data/README.md CHANGED
@@ -22,28 +22,49 @@ Or install it yourself as:
22
22
  $ gem install jptax
23
23
  ```
24
24
 
25
+ ## Reference
26
+
27
+ ```ruby
28
+ Jptax.amount_with_tax(通常税率の税抜金額, 軽減税率の税抜金額, 丸め方法)
29
+ ```
30
+
31
+ ### 丸め方法
32
+ 端数の丸方法として、以下のいずれかを指定します。
33
+ 未指定の場合は切り捨てられます。
34
+ - `floor`: 切り捨て
35
+ - `ceil`: 切り上げ
36
+ - `round`: 四捨五入
37
+
38
+
25
39
  ## Usage
26
40
 
27
41
  ### 税込金額計算
28
42
  税抜金額を元に税込金額を計算します。
29
- 端数は切り捨てられます。
43
+ 端数は切り捨て・切り上げ・四捨五入を指定できます。
44
+ 未指定の場合は切り捨てられます。
30
45
 
31
- #### 通常税率の税込金額を計算
46
+ #### 通常税率の税込金額を計算(切り捨て)
32
47
  ```ruby
33
48
  Jptax.amount_with_tax(100)
34
49
  # => 110
35
50
  ````
36
51
 
37
- #### 軽減税率の税込金額を計算
52
+ #### 軽減税率の税込金額を計算(切り捨て)
38
53
  ```ruby
39
54
  Jptax.amount_with_tax(0, 200)
40
55
  # => 216
41
56
  ```
42
57
 
43
- #### 通常税率と軽減税率の税込金額を計算
58
+ #### 通常税率と軽減税率の税込金額を計算(切り捨て)
59
+ ```ruby
60
+ Jptax.amount_with_tax(100, 199)
61
+ # => 314
62
+ ```
63
+
64
+ #### 通常税率と軽減税率の税込金額を計算(四捨五入)
44
65
  ```ruby
45
- Jptax.amount_with_tax(100, 200)
46
- # => 316
66
+ Jptax.amount_with_tax(100, 199, 'round')
67
+ # => 315
47
68
  ```
48
69
 
49
70
  ## Note
@@ -1,8 +1,14 @@
1
1
  require 'jptax/version'
2
2
 
3
3
  module Jptax
4
- def amount_with_tax(amount=0, amount_for_reduced=0)
5
- (amount.to_i * 1.1 + amount_for_reduced.to_i * 1.08).floor
4
+ def amount_with_tax(amount=0, amount_for_reduced=0, round_types='floor')
5
+ if round_types == 'ceil'
6
+ (amount.to_i * 1.1 + amount_for_reduced.to_i * 1.08).ceil
7
+ elsif round_types == 'round'
8
+ (amount.to_i * 1.1 + amount_for_reduced.to_i * 1.08).round
9
+ else
10
+ (amount.to_i * 1.1 + amount_for_reduced.to_i * 1.08).floor
11
+ end
6
12
  end
7
13
 
8
14
  module_function :amount_with_tax
@@ -1,3 +1,3 @@
1
1
  module Jptax
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jptax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - tomoeine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-14 00:00:00.000000000 Z
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
- rubygems_version: 3.1.2
94
+ rubygems_version: 3.0.3
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Easy calculating Japanese consumption tax.