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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +27 -6
- data/lib/jptax.rb +8 -2
- data/lib/jptax/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7ede5229c1ac11d3dab9aa2e93dab639bd5ed10016807252fb0eca95c383b1da
|
|
4
|
+
data.tar.gz: 5e69b40ec461dbc71035051274f7c696a5d6f58350f7bb3bbd94212c2f0f1869
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 06a2e6afeb9bc6c98387b9d2d3274dffc4afd0a80c2ea1daa5306bad696a7a893109aa3279882a5a4eabebff876d72314658a94735eceadc2d2f4534161a57b4
|
|
7
|
+
data.tar.gz: 11fb19218f86d977325337a2fdcc67c51b47fefaf3b323905780b70e835ce34d78d67380bacdd54a1ac7e89977a9c5ab4222508792552963c9a44b4687f65208
|
data/Gemfile.lock
CHANGED
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,
|
|
46
|
-
# =>
|
|
66
|
+
Jptax.amount_with_tax(100, 199, 'round')
|
|
67
|
+
# => 315
|
|
47
68
|
```
|
|
48
69
|
|
|
49
70
|
## Note
|
data/lib/jptax.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
data/lib/jptax/version.rb
CHANGED
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.
|
|
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-
|
|
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.
|
|
94
|
+
rubygems_version: 3.0.3
|
|
95
95
|
signing_key:
|
|
96
96
|
specification_version: 4
|
|
97
97
|
summary: Easy calculating Japanese consumption tax.
|