tax_jp 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/data//346/270/233/344/276/241/345/204/237/345/215/264/schema_depreciation_rates.sql +9 -0
- data/data//346/270/233/344/276/241/345/204/237/345/215/264//346/270/233/344/276/241/345/204/237/345/215/264/347/216/207-20070401-20120331.tsv +50 -0
- data/data//346/270/233/344/276/241/345/204/237/345/215/264//346/270/233/344/276/241/345/204/237/345/215/264/347/216/207-20120401-20991231.tsv +50 -0
- data/data//346/270/233/344/276/241/345/204/237/345/215/264/347/216/207.db +0 -0
- data/lib/build_tasks/build.rake +12 -4
- data/lib/tax_jp/depreciation_rate.rb +68 -0
- data/lib/tax_jp/depreciation_rates/db_builder.rb +58 -0
- data/lib/tax_jp/social_insurance.rb +2 -4
- data/lib/tax_jp/social_insurances/utils.rb +0 -14
- data/lib/tax_jp/utils.rb +14 -0
- data/lib/tax_jp/version.rb +1 -1
- data/lib/tax_jp/withheld_tax.rb +0 -2
- data/lib/tax_jp.rb +4 -0
- data/tax_jp.gemspec +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 168ef822b3f5c9836e33ae118758b4e545ed5fc9
|
4
|
+
data.tar.gz: 49b8d79bedb28032200a2a5300a6b369076ae609
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 163d3df21f60b59083c84256a44f3ccd2ea1c552e9ee6886703f8548ce85252ff1baea74e06fe9eb2250e98b79f45548bbeaac8cf284d50ff9a3ee1740deee14
|
7
|
+
data.tar.gz: bedea1f069a2570290e7c48f535fda6fcaec699e197cfe5ffa0a9622dfc3af93f8fbe040463e9919917372852915d0c92779d89174a7f8e74ca64bc929daf9a7
|
data/.travis.yml
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
create table depreciation_rates (
|
2
|
+
valid_from date not null,
|
3
|
+
valid_until date not null,
|
4
|
+
durable_years integer not null,
|
5
|
+
fixed_amount_rate decimal(1,6) not null,
|
6
|
+
rate decimal(1,6) not null,
|
7
|
+
revised_rate decimal(1,6) not null,
|
8
|
+
guaranteed_rate decimal(1,6) not null
|
9
|
+
);
|
@@ -0,0 +1,50 @@
|
|
1
|
+
耐用年数 定額法償却率 定率法償却率 定率法改定償却率 定率法保証率
|
2
|
+
2 0.5 1 0 0
|
3
|
+
3 0.334 0.833 1 0.02789
|
4
|
+
4 0.25 0.625 1 0.05274
|
5
|
+
5 0.2 0.5 1 0.06249
|
6
|
+
6 0.167 0.417 0.5 0.05776
|
7
|
+
7 0.143 0.357 0.5 0.05496
|
8
|
+
8 0.125 0.313 0.334 0.05111
|
9
|
+
9 0.112 0.278 0.334 0.04731
|
10
|
+
10 0.1 0.25 0.334 0.04448
|
11
|
+
11 0.091 0.227 0.25 0.04123
|
12
|
+
12 0.084 0.208 0.25 0.0387
|
13
|
+
13 0.077 0.192 0.2 0.03633
|
14
|
+
14 0.072 0.179 0.2 0.03389
|
15
|
+
15 0.067 0.167 0.2 0.03217
|
16
|
+
16 0.063 0.156 0.167 0.03063
|
17
|
+
17 0.059 0.147 0.167 0.02905
|
18
|
+
18 0.056 0.139 0.143 0.02757
|
19
|
+
19 0.053 0.132 0.143 0.02616
|
20
|
+
20 0.05 0.125 0.143 0.02517
|
21
|
+
21 0.048 0.119 0.125 0.02408
|
22
|
+
22 0.046 0.114 0.125 0.02296
|
23
|
+
23 0.044 0.109 0.112 0.02226
|
24
|
+
24 0.042 0.104 0.112 0.02157
|
25
|
+
25 0.04 0.1 0.112 0.02058
|
26
|
+
26 0.039 0.096 0.1 0.01989
|
27
|
+
27 0.038 0.093 0.1 0.01902
|
28
|
+
28 0.036 0.089 0.091 0.01866
|
29
|
+
29 0.035 0.086 0.091 0.01803
|
30
|
+
30 0.034 0.083 0.084 0.01766
|
31
|
+
31 0.033 0.081 0.084 0.01688
|
32
|
+
32 0.032 0.078 0.084 0.01655
|
33
|
+
33 0.031 0.076 0.077 0.01585
|
34
|
+
34 0.03 0.074 0.077 0.01532
|
35
|
+
35 0.029 0.071 0.072 0.01532
|
36
|
+
36 0.028 0.069 0.072 0.01494
|
37
|
+
37 0.028 0.068 0.072 0.01425
|
38
|
+
38 0.027 0.066 0.067 0.01393
|
39
|
+
39 0.026 0.064 0.067 0.0137
|
40
|
+
40 0.025 0.063 0.067 0.01317
|
41
|
+
41 0.025 0.061 0.063 0.01306
|
42
|
+
42 0.024 0.06 0.063 0.01261
|
43
|
+
43 0.024 0.058 0.059 0.01248
|
44
|
+
44 0.023 0.057 0.059 0.0121
|
45
|
+
45 0.023 0.056 0.059 0.01175
|
46
|
+
46 0.022 0.054 0.056 0.01175
|
47
|
+
47 0.022 0.053 0.056 0.01153
|
48
|
+
48 0.021 0.052 0.053 0.01126
|
49
|
+
49 0.021 0.051 0.053 0.01102
|
50
|
+
50 0.02 0.05 0.053 0.01072
|
@@ -0,0 +1,50 @@
|
|
1
|
+
耐用年数 定額法償却率 定率法償却率 定率法改定償却率 定率法保証率
|
2
|
+
2 0.5 1 0 0
|
3
|
+
3 0.334 0.667 1 0.11089
|
4
|
+
4 0.25 0.5 1 0.12499
|
5
|
+
5 0.2 0.4 0.5 0.108
|
6
|
+
6 0.167 0.333 0.334 0.09911
|
7
|
+
7 0.143 0.286 0.334 0.0868
|
8
|
+
8 0.125 0.25 0.334 0.07909
|
9
|
+
9 0.112 0.222 0.25 0.07126
|
10
|
+
10 0.1 0.2 0.25 0.06552
|
11
|
+
11 0.091 0.182 0.2 0.05992
|
12
|
+
12 0.084 0.167 0.2 0.05566
|
13
|
+
13 0.077 0.154 0.167 0.0518
|
14
|
+
14 0.072 0.143 0.167 0.04854
|
15
|
+
15 0.067 0.133 0.143 0.04565
|
16
|
+
16 0.063 0.125 0.143 0.04294
|
17
|
+
17 0.059 0.118 0.125 0.04038
|
18
|
+
18 0.056 0.111 0.112 0.03884
|
19
|
+
19 0.053 0.105 0.112 0.03693
|
20
|
+
20 0.05 0.1 0.112 0.03486
|
21
|
+
21 0.048 0.095 0.1 0.03335
|
22
|
+
22 0.046 0.091 0.1 0.03182
|
23
|
+
23 0.044 0.087 0.091 0.03052
|
24
|
+
24 0.042 0.083 0.084 0.02969
|
25
|
+
25 0.04 0.08 0.084 0.02841
|
26
|
+
26 0.039 0.077 0.084 0.02716
|
27
|
+
27 0.038 0.074 0.077 0.02624
|
28
|
+
28 0.036 0.071 0.072 0.02568
|
29
|
+
29 0.035 0.069 0.072 0.02463
|
30
|
+
30 0.034 0.067 0.072 0.02366
|
31
|
+
31 0.033 0.065 0.067 0.02286
|
32
|
+
32 0.032 0.063 0.067 0.02216
|
33
|
+
33 0.031 0.061 0.063 0.02161
|
34
|
+
34 0.03 0.059 0.063 0.02097
|
35
|
+
35 0.029 0.057 0.059 0.02051
|
36
|
+
36 0.028 0.056 0.059 0.01974
|
37
|
+
37 0.028 0.054 0.056 0.0195
|
38
|
+
38 0.027 0.053 0.056 0.01882
|
39
|
+
39 0.026 0.051 0.053 0.0186
|
40
|
+
40 0.025 0.05 0.053 0.01791
|
41
|
+
41 0.025 0.049 0.05 0.01741
|
42
|
+
42 0.024 0.048 0.05 0.01694
|
43
|
+
43 0.024 0.047 0.048 0.01664
|
44
|
+
44 0.023 0.045 0.046 0.01664
|
45
|
+
45 0.023 0.044 0.046 0.01634
|
46
|
+
46 0.022 0.043 0.044 0.01601
|
47
|
+
47 0.022 0.043 0.044 0.01532
|
48
|
+
48 0.021 0.042 0.044 0.01499
|
49
|
+
49 0.021 0.041 0.042 0.01475
|
50
|
+
50 0.02 0.04 0.042 0.0144
|
data/lib/build_tasks/build.rake
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'tax_jp'
|
3
|
+
require 'tax_jp/depreciation_rates/db_builder'
|
3
4
|
require 'tax_jp/social_insurances/db_builder'
|
4
5
|
require 'tax_jp/withheld_taxes/db_builder'
|
5
6
|
|
6
7
|
namespace :taxjp do
|
7
8
|
task :build do
|
8
9
|
Rake::Task["taxjp:build:consumption_tax"].invoke
|
10
|
+
Rake::Task["taxjp:build:depreciation_rate"].invoke
|
9
11
|
Rake::Task["taxjp:build:social_insurance"].invoke
|
10
12
|
Rake::Task["taxjp:build:withheld_tax"].invoke
|
11
13
|
end
|
@@ -18,10 +20,10 @@ namespace :taxjp do
|
|
18
20
|
TaxJp::Utils.render 'app/assets/javascripts/tax.js'
|
19
21
|
end
|
20
22
|
|
21
|
-
desc '
|
22
|
-
task :
|
23
|
-
puts '
|
24
|
-
TaxJp::
|
23
|
+
desc '減価償却率DBを構築します。'
|
24
|
+
task :depreciation_rate do
|
25
|
+
puts '減価償却率'
|
26
|
+
TaxJp::DepreciationRates::DbBuilder.new.run
|
25
27
|
end
|
26
28
|
|
27
29
|
desc '社会保険料DBを構築します。'
|
@@ -30,5 +32,11 @@ namespace :taxjp do
|
|
30
32
|
TaxJp::SocialInsurances::DbBuilder.new.run
|
31
33
|
end
|
32
34
|
|
35
|
+
desc '源泉徴収税DBを構築します。'
|
36
|
+
task :withheld_tax do
|
37
|
+
puts '源泉徴収税'
|
38
|
+
TaxJp::WithheldTaxes::DbBuilder.new.run
|
39
|
+
end
|
40
|
+
|
33
41
|
end
|
34
42
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module TaxJp
|
2
|
+
module DepreciationRates
|
3
|
+
end
|
4
|
+
|
5
|
+
# 減価償却率
|
6
|
+
class DepreciationRate
|
7
|
+
DB_PATH = File.join(TaxJp::Utils.data_dir, '減価償却率.db')
|
8
|
+
|
9
|
+
attr_reader :valid_from, :valid_until
|
10
|
+
attr_reader :durable_years
|
11
|
+
attr_reader :fixed_amount_rate
|
12
|
+
attr_reader :rate, :revised_rate, :guaranteed_rate
|
13
|
+
|
14
|
+
def initialize(row)
|
15
|
+
@valid_from = row[0]
|
16
|
+
@valid_until = row[1]
|
17
|
+
@durable_years = row[2]
|
18
|
+
@fixed_amount_rate = row[3]
|
19
|
+
@rate = row[4]
|
20
|
+
@revised_rate = row[5]
|
21
|
+
@guaranteed_rate = row[6]
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.find_all_by_date(date)
|
25
|
+
date = TaxJp::Utils.convert_to_date(date)
|
26
|
+
|
27
|
+
with_database do |db|
|
28
|
+
sql = 'select * from depreciation_rates '
|
29
|
+
sql << 'where valid_from <= ? and valid_until >= ? '
|
30
|
+
sql << 'order by durable_years '
|
31
|
+
|
32
|
+
ret = []
|
33
|
+
db.execute(sql, [date, date]) do |row|
|
34
|
+
ret << TaxJp::DepreciationRate.new(row)
|
35
|
+
end
|
36
|
+
ret
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.find_by_date_and_durable_years(date, durable_years)
|
41
|
+
date = TaxJp::Utils.convert_to_date(date)
|
42
|
+
|
43
|
+
with_database do |db|
|
44
|
+
sql = 'select * from depreciation_rates '
|
45
|
+
sql << 'where valid_from <= ? and valid_until >= ? '
|
46
|
+
sql << ' and durable_years = ? '
|
47
|
+
|
48
|
+
ret = nil
|
49
|
+
db.execute(sql, [date, date, durable_years]) do |row|
|
50
|
+
ret = TaxJp::DepreciationRate.new(row)
|
51
|
+
end
|
52
|
+
ret
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def self.with_database
|
59
|
+
db = SQLite3::Database.new(DB_PATH)
|
60
|
+
begin
|
61
|
+
yield db
|
62
|
+
ensure
|
63
|
+
db.close
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
class TaxJp::DepreciationRates::DbBuilder
|
4
|
+
|
5
|
+
def initialize(db_path = nil)
|
6
|
+
@db_path = db_path || TaxJp::DepreciationRate::DB_PATH
|
7
|
+
end
|
8
|
+
|
9
|
+
def run(options = {})
|
10
|
+
with_database(options) do |db|
|
11
|
+
Dir.glob(File.join(TaxJp::Utils.data_dir, '減価償却', '減価償却率-*.tsv')).each do |filename|
|
12
|
+
valid_from, valid_until = filename_to_date(filename)
|
13
|
+
|
14
|
+
CSV.foreach(filename, :col_sep => "\t") do |row|
|
15
|
+
next if row[0].to_i == 0
|
16
|
+
db.execute(insert_sql, [valid_from, valid_until] + row)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def with_database(options = {})
|
25
|
+
if options.fetch(:recreate, true)
|
26
|
+
FileUtils.rm_f(@db_path)
|
27
|
+
db = SQLite3::Database.new(@db_path)
|
28
|
+
db.execute(TaxJp::Utils.load_file(File.join('減価償却', 'schema_depreciation_rates.sql')))
|
29
|
+
else
|
30
|
+
db = SQLite3::Database.new(@db_path)
|
31
|
+
end
|
32
|
+
|
33
|
+
begin
|
34
|
+
yield db
|
35
|
+
ensure
|
36
|
+
db.close
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def insert_sql
|
41
|
+
columns = %w{valid_from valid_until durable_years fixed_amount_rate rate revised_rate guaranteed_rate}
|
42
|
+
|
43
|
+
ret = 'insert into depreciation_rates ( '
|
44
|
+
ret << columns.join(',')
|
45
|
+
ret << ') values ('
|
46
|
+
ret << columns.map{|c| '?' }.join(',')
|
47
|
+
ret << ')'
|
48
|
+
ret
|
49
|
+
end
|
50
|
+
|
51
|
+
def filename_to_date(filename)
|
52
|
+
title, valid_from, valid_until = File.basename(filename).split('.').first.split('-')
|
53
|
+
valid_from = Date.strptime(valid_from, '%Y%m%d')
|
54
|
+
valid_until = Date.strptime(valid_until, '%Y%m%d')
|
55
|
+
[valid_from.strftime('%Y-%m-%d'), valid_until.strftime('%Y-%m-%d')]
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'sqlite3'
|
2
|
-
|
3
1
|
module TaxJp
|
4
2
|
module SocialInsurances
|
5
3
|
require_relative 'social_insurances/utils'
|
@@ -65,7 +63,7 @@ module TaxJp
|
|
65
63
|
end
|
66
64
|
|
67
65
|
def self.find_all_by_date_and_prefecture(date, prefecture)
|
68
|
-
date = convert_to_date(date)
|
66
|
+
date = TaxJp::Utils.convert_to_date(date)
|
69
67
|
prefecture_code = convert_to_prefecture_code(prefecture)
|
70
68
|
|
71
69
|
with_database do |db|
|
@@ -83,7 +81,7 @@ module TaxJp
|
|
83
81
|
end
|
84
82
|
|
85
83
|
def self.find_by_date_and_prefecture_and_salary(date, prefecture, salary)
|
86
|
-
date = convert_to_date(date)
|
84
|
+
date = TaxJp::Utils.convert_to_date(date)
|
87
85
|
prefecture_code = convert_to_prefecture_code(prefecture)
|
88
86
|
salary = salary.to_i
|
89
87
|
|
@@ -1,19 +1,5 @@
|
|
1
1
|
module TaxJp::SocialInsurances::Utils
|
2
2
|
|
3
|
-
def convert_to_date(value)
|
4
|
-
ret = nil
|
5
|
-
|
6
|
-
if value.is_a?(Date)
|
7
|
-
ret = value.strftime('%Y-%m-%d')
|
8
|
-
elsif value.is_a?(String)
|
9
|
-
ret = value
|
10
|
-
else
|
11
|
-
raise TypeError.new(value.class)
|
12
|
-
end
|
13
|
-
|
14
|
-
ret
|
15
|
-
end
|
16
|
-
|
17
3
|
def convert_to_prefecture_code(value)
|
18
4
|
ret = nil
|
19
5
|
|
data/lib/tax_jp/utils.rb
CHANGED
@@ -27,6 +27,20 @@ module TaxJp
|
|
27
27
|
File.write(dest, ERB.new(File.read(src), 0, '-').result)
|
28
28
|
end
|
29
29
|
|
30
|
+
def convert_to_date(value)
|
31
|
+
ret = nil
|
32
|
+
|
33
|
+
if value.is_a?(Date)
|
34
|
+
ret = value.strftime('%Y-%m-%d')
|
35
|
+
elsif value.is_a?(String)
|
36
|
+
ret = value
|
37
|
+
else
|
38
|
+
raise TypeError.new(value.class)
|
39
|
+
end
|
40
|
+
|
41
|
+
ret
|
42
|
+
end
|
43
|
+
|
30
44
|
end
|
31
45
|
end
|
32
46
|
end
|
data/lib/tax_jp/version.rb
CHANGED
data/lib/tax_jp/withheld_tax.rb
CHANGED
data/lib/tax_jp.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'sqlite3'
|
1
2
|
require 'tax_jp/version'
|
2
3
|
require 'tax_jp/const'
|
3
4
|
|
@@ -14,6 +15,9 @@ module TaxJp
|
|
14
15
|
require 'tax_jp/consumption_tax'
|
15
16
|
extend TaxJp::ConsumptionTax
|
16
17
|
|
18
|
+
# 減価償却率
|
19
|
+
require 'tax_jp/depreciation_rate'
|
20
|
+
|
17
21
|
# 社会保険料
|
18
22
|
require 'tax_jp/social_insurance'
|
19
23
|
|
data/tax_jp.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_runtime_dependency 'sqlite3', '~> 1.3'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
25
|
-
spec.add_development_dependency 'closer', '~> 0.
|
25
|
+
spec.add_development_dependency 'closer', '~> 0.3'
|
26
26
|
spec.add_development_dependency 'rake', '~> 10.0'
|
27
27
|
spec.add_development_dependency 'rails', '>= 3.2.0', '< 5.0.0'
|
28
28
|
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: 0.2.
|
4
|
+
version: 0.2.6
|
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: 2015-
|
12
|
+
date: 2015-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sqlite3
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0.
|
48
|
+
version: '0.3'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
55
|
+
version: '0.3'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rake
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,6 +104,10 @@ files:
|
|
104
104
|
- app/assets/javascripts/tax.js
|
105
105
|
- app/assets/javascripts/tax_jp.js
|
106
106
|
- data/消費税.yml
|
107
|
+
- data/減価償却/schema_depreciation_rates.sql
|
108
|
+
- data/減価償却/減価償却率-20070401-20120331.tsv
|
109
|
+
- data/減価償却/減価償却率-20120401-20991231.tsv
|
110
|
+
- data/減価償却率.db
|
107
111
|
- data/源泉徴収税.db
|
108
112
|
- data/源泉徴収税/20070101-20121231.tsv
|
109
113
|
- data/源泉徴収税/20130101-20371231.tsv
|
@@ -134,6 +138,8 @@ files:
|
|
134
138
|
- lib/tax_jp.rb
|
135
139
|
- lib/tax_jp/const.rb
|
136
140
|
- lib/tax_jp/consumption_tax.rb
|
141
|
+
- lib/tax_jp/depreciation_rate.rb
|
142
|
+
- lib/tax_jp/depreciation_rates/db_builder.rb
|
137
143
|
- lib/tax_jp/prefecture.rb
|
138
144
|
- lib/tax_jp/rails/engine.rb
|
139
145
|
- lib/tax_jp/rails/railtie.rb
|