tax_jp 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11a54f4e4111eb0c5218fbf446e5ce265341bcd87989e1e7654ef6405742f845
4
- data.tar.gz: 7051c81595882053ff3c15baa5ef41cee96ce0b8869dd74d480e3180bd428a3f
3
+ metadata.gz: 5d231fd19f8e0a2603cd6f289aae66de527a7dc29705b8831387ebb179b3150a
4
+ data.tar.gz: a72410cc728a5146a06acc4e6335fa557ccd96e5bd86a7c1a50c416868a0f691
5
5
  SHA512:
6
- metadata.gz: 1f162c5013f8694da55e3fbb86fd1a5e4acb94b7eee0b15104730682334ef38bee3228975dcf137e4ccdd26f641d83ab36ee869c661452bf431a1b541f48748f
7
- data.tar.gz: f9658e9db888dfb35da7802908d15527501f51573198a7500c673b076d495e75c4d8515dbffc607baaac9e768b141e825f268ecc4f4d0f0a661d38cdf6b8a561
6
+ metadata.gz: 074e65b0c5ab90955d77815a6ea4d576fb4dbbf2b30396f33fed66f983e5aed351c145f16dbda4bd8bfb9807795a3da1954c4b1b454764d75a00d213564a9f5a
7
+ data.tar.gz: a67853c1323bb72909316ff98639ccb2585d235558aae48b83a68ce48acd344e36bdf26d8a3d8e931f1e55362daa1d2204a5e77594df641eaa4f2d1bda98f305
@@ -7,9 +7,10 @@ tax.INCLUSIVE = 2; // 内税
7
7
  tax.EXCLUSIVE = 3; // 外税
8
8
 
9
9
  tax.consumptionTaxes = [
10
- {date: Date.parse('2014-04-01'), rate: 0.08},
11
- {date: Date.parse('1997-04-01'), rate: 0.05},
12
- {date: Date.parse('1989-04-01'), rate: 0.03},
10
+ {date: Date.parse('2019-10-01'), rate: 0.1, reduced_rate: 0.08},
11
+ {date: Date.parse('2014-04-01'), rate: 0.08, reduced_rate: 0},
12
+ {date: Date.parse('1997-04-01'), rate: 0.05, reduced_rate: 0},
13
+ {date: Date.parse('1989-04-01'), rate: 0.03, reduced_rate: 0},
13
14
  ];
14
15
 
15
16
  tax.getRateOn = function(date, options) {
@@ -20,7 +21,11 @@ tax.getRateOn = function(date, options) {
20
21
 
21
22
  var ret = 0;
22
23
  for (var i = 0; this.consumptionTaxes.length; i ++) {
23
- ret = this.consumptionTaxes[i].rate;
24
+ if (options.reduced) {
25
+ ret = this.consumptionTaxes[i].reduced_rate;
26
+ } else {
27
+ ret = this.consumptionTaxes[i].rate;
28
+ }
24
29
  if (date >= this.consumptionTaxes[i].date) {
25
30
  break;
26
31
  }
@@ -29,7 +34,7 @@ tax.getRateOn = function(date, options) {
29
34
  if (options.percent) {
30
35
  ret *= 100;
31
36
  }
32
-
37
+
33
38
  return ret;
34
39
  };
35
40
 
@@ -40,8 +45,7 @@ tax.calcTaxAmount = function(taxType, rate, amount) {
40
45
 
41
46
  if ( taxType == tax.INCLUSIVE ) {
42
47
  return parseInt(amount * rate / (1 + rate));
43
- }
44
- else if ( taxType == tax.EXCLUSIVE ) {
48
+ } else if ( taxType == tax.EXCLUSIVE ) {
45
49
  return parseInt(amount * rate);
46
50
  }
47
51
 
@@ -22,9 +22,9 @@
22
22
  <td class="text-center"><%= number_to_currency(ct.national_percent, unit: '', precision: 1) if ct.national_percent > 0 %></td>
23
23
  <td class="text-center"><%= number_to_currency(ct.local_percent, unit: '', precision: 1) if ct.local_percent > 0 %></td>
24
24
  <td class="text-center"><%= number_to_currency(ct.total_percent, unit: '') if ct.total_percent > 0 %></td>
25
- <td class="text-center"></td>
26
- <td class="text-center"></td>
27
- <td class="text-center"></td>
25
+ <td class="text-center"><%= number_to_currency(ct.national_reduced_percent, unit: '', precision: 2) if ct.national_reduced_percent > 0 %></td>
26
+ <td class="text-center"><%= number_to_currency(ct.local_reduced_percent, unit: '', precision: 2) if ct.local_reduced_percent > 0 %></td>
27
+ <td class="text-center"><%= number_to_currency(ct.total_reduced_percent, unit: '') if ct.total_reduced_percent > 0 %></td>
28
28
  </tr>
29
29
  <% end %>
30
30
  </tbody>
@@ -2,14 +2,23 @@
2
2
  national: 0.03
3
3
  local: 0.00
4
4
  total: 0.03
5
+ national_reduced: 0
6
+ local_reduced: 0
7
+ total_reduced: 0
5
8
  1997-04-01:
6
9
  national: 0.04
7
10
  local: 0.01
8
11
  total: 0.05
12
+ national_reduced: 0
13
+ local_reduced: 0
14
+ total_reduced: 0
9
15
  2014-04-01:
10
16
  national: 0.063
11
17
  local: 0.017
12
18
  total: 0.08
19
+ national_reduced: 0
20
+ local_reduced: 0
21
+ total_reduced: 0
13
22
  2019-10-01:
14
23
  national: 0.078
15
24
  local: 0.022
@@ -7,12 +7,16 @@ module TaxJp
7
7
 
8
8
  attr_reader :valid_from
9
9
  attr_reader :national, :local, :total
10
+ attr_reader :national_reduced, :local_reduced, :total_reduced
10
11
 
11
12
  def initialize(valid_from, values)
12
13
  @valid_from = valid_from
13
14
  @national = values['national']
14
15
  @local = values['local']
15
16
  @total = values['total']
17
+ @national_reduced = values['national_reduced']
18
+ @local_reduced = values['local_reduced']
19
+ @total_reduced = values['total_reduced']
16
20
  end
17
21
 
18
22
  def self.all
@@ -53,5 +57,16 @@ module TaxJp
53
57
  total * 100
54
58
  end
55
59
 
60
+ def national_reduced_percent
61
+ national_reduced * 100
62
+ end
63
+
64
+ def local_reduced_percent
65
+ local_reduced * 100
66
+ end
67
+
68
+ def total_reduced_percent
69
+ total_reduced * 100
70
+ end
56
71
  end
57
72
  end
@@ -1,3 +1,3 @@
1
1
  module TaxJp
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tax_jp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichylinux
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-04-27 00:00:00.000000000 Z
12
+ date: 2019-07-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bootstrap
@@ -237,8 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  - !ruby/object:Gem::Version
238
238
  version: '0'
239
239
  requirements: []
240
- rubyforge_project:
241
- rubygems_version: 2.7.7
240
+ rubygems_version: 3.0.3
242
241
  signing_key:
243
242
  specification_version: 4
244
243
  summary: 税金計算ライブラリ