jp-national-tax 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/jp_national_tax/income_tax/income_kouran_2020.rb +7 -7
- data/lib/jp_national_tax/income_tax/income_nenmatsu_2020.rb +3 -2
- data/lib/jp_national_tax/version.rb +1 -1
- data/tools/parse-etax-spec.rb +76 -0
- data/tools/stats-etax-spec.rb +33 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8aa134083bb93f5a7a31d8dd1593d0281a4cea993f560605aa6515afceab823
|
4
|
+
data.tar.gz: 510666c3b3005caf8c1bab5070e6f678bd866052e422c4f4f5bb327b4894f1e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2974fb0084b12e51c8c455efc67a3159104a98b4e02e0323164276aa2d7e1e1c2f6809aca4baeb22f1d4982ecde855b6d26065328582128682d03700f905bba8
|
7
|
+
data.tar.gz: 56ac46121279307a27b78a561e5db9cffa47b7a87b21d0610c83f7a33c475bb37d71715399e80e44cee19f1b3f5414f18c1dd65faec72b36a108b244c9b7575a
|
data/CHANGELOG.md
CHANGED
@@ -85,19 +85,19 @@ module JpNationalTax
|
|
85
85
|
|
86
86
|
case その月の課税給与所得金額
|
87
87
|
when 0 .. 162_500
|
88
|
-
(その月の課税給与所得金額 * BigDecimal("0.05105")).round(
|
88
|
+
(その月の課税給与所得金額 * BigDecimal("0.05105")).round(-1, BigDecimal::ROUND_HALF_UP)
|
89
89
|
when 162_501 .. 275_000
|
90
|
-
(その月の課税給与所得金額 * BigDecimal("0.10210")).round(
|
90
|
+
(その月の課税給与所得金額 * BigDecimal("0.10210") - 8_296).round(-1, BigDecimal::ROUND_HALF_UP)
|
91
91
|
when 275_001 .. 579_166
|
92
|
-
(その月の課税給与所得金額 * BigDecimal("0.20420")).round(
|
92
|
+
(その月の課税給与所得金額 * BigDecimal("0.20420") - 36_374).round(-1, BigDecimal::ROUND_HALF_UP)
|
93
93
|
when 579_001 .. 750_000
|
94
|
-
(その月の課税給与所得金額 * BigDecimal("0.23483")).round(
|
94
|
+
(その月の課税給与所得金額 * BigDecimal("0.23483") - 54_113).round(-1, BigDecimal::ROUND_HALF_UP)
|
95
95
|
when 750_001 .. 1_500_000
|
96
|
-
(その月の課税給与所得金額 * BigDecimal("0.33693")).round(
|
96
|
+
(その月の課税給与所得金額 * BigDecimal("0.33693") - 130_688).round(-1, BigDecimal::ROUND_HALF_UP)
|
97
97
|
when 1_500_001 .. 3_333_333
|
98
|
-
(その月の課税給与所得金額 * BigDecimal("0.40840")).round(
|
98
|
+
(その月の課税給与所得金額 * BigDecimal("0.40840") - 237_893).round(-1, BigDecimal::ROUND_HALF_UP)
|
99
99
|
else
|
100
|
-
(その月の課税給与所得金額 * BigDecimal("0.45945")).round(
|
100
|
+
(その月の課税給与所得金額 * BigDecimal("0.45945") - 408_061).round(-1, BigDecimal::ROUND_HALF_UP)
|
101
101
|
end
|
102
102
|
|
103
103
|
end
|
@@ -44,7 +44,7 @@ module JpNationalTax #:nodoc:
|
|
44
44
|
#
|
45
45
|
def 給与所得控除後の給与等の金額(年調給与額)
|
46
46
|
case 年調給与額
|
47
|
-
when
|
47
|
+
when 0 .. 550_999
|
48
48
|
0
|
49
49
|
when 551_000 .. 1_618_999
|
50
50
|
年調給与額 - 550_000
|
@@ -67,7 +67,8 @@ module JpNationalTax #:nodoc:
|
|
67
67
|
when 8_500_000 .. 20_000_000
|
68
68
|
年調給与額 - 1_950_000
|
69
69
|
else
|
70
|
-
|
70
|
+
STDERR.puts '年末調整の対象となりません'
|
71
|
+
年調給与額 - 1_950_000
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "csv"
|
3
|
+
require "roo"
|
4
|
+
|
5
|
+
#
|
6
|
+
# eTax仕様のXML構造設計書をTSV変換するツール
|
7
|
+
#
|
8
|
+
|
9
|
+
TARGET_COLUMNS = {
|
10
|
+
origin: ["タグ名", "レベル", "共通ボキャブラリまたはデータ型", "項番", "備考"],
|
11
|
+
dest: ["version", "tag", "level", "struct", "order", "note", "label"],
|
12
|
+
}
|
13
|
+
|
14
|
+
def search_columns(xlsx)
|
15
|
+
[].tap do |columns|
|
16
|
+
xlsx.each_row_streaming do |row|
|
17
|
+
next if row[0].value != "項番"
|
18
|
+
|
19
|
+
TARGET_COLUMNS[:origin].each do |label|
|
20
|
+
columns.push row.find_index { |cell| cell.value == label }
|
21
|
+
end
|
22
|
+
break
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def collect_rows(xlsx, columns)
|
28
|
+
[].tap do |res|
|
29
|
+
xlsx.each_row_streaming do |row|
|
30
|
+
next unless row[0].value.to_s =~ /^[0-9]+$/
|
31
|
+
|
32
|
+
label = extract_label(row, columns[1], columns[2])
|
33
|
+
res.push(columns.map{ |col| row[col].value }.push(label))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def extract_label(row, prev, subs)
|
39
|
+
(prev+1...subs).map { |idx| row[idx].value }.join("")
|
40
|
+
end
|
41
|
+
|
42
|
+
def sheet_defs(xlsx)
|
43
|
+
columns = []
|
44
|
+
xlsx.each_row_streaming do |row|
|
45
|
+
next if row[0].value != "帳票名称"
|
46
|
+
|
47
|
+
["様式ID", "帳票名称", "バージョン"].each do |label|
|
48
|
+
columns.push row.find_index { |cell| cell.value == label }
|
49
|
+
end
|
50
|
+
break
|
51
|
+
end
|
52
|
+
|
53
|
+
[].tap { |res|
|
54
|
+
xlsx.each_row_streaming do |row|
|
55
|
+
next if row[0].value == "帳票名称"
|
56
|
+
|
57
|
+
res.push columns.map { |i| row[i].value }
|
58
|
+
break
|
59
|
+
end
|
60
|
+
}.flatten
|
61
|
+
end
|
62
|
+
|
63
|
+
# ARGV[0]にはExcelファイルのpathを指定
|
64
|
+
xlsx = Roo::Excelx.new(ARGV[0])
|
65
|
+
xlsx.each_with_pagename do |name, sheet|
|
66
|
+
id, name, version = sheet_defs(xlsx)
|
67
|
+
filename = "#{id}-#{version}-#{name.gsub(/\//, '=')[0, 80]}.tsv"
|
68
|
+
columns = search_columns(sheet)
|
69
|
+
|
70
|
+
CSV.open(filename, "w", col_sep: "\t") do |csv|
|
71
|
+
csv << TARGET_COLUMNS[:dest]
|
72
|
+
collect_rows(xlsx, columns).each do |row|
|
73
|
+
csv << row.unshift(version)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "csv"
|
3
|
+
|
4
|
+
#
|
5
|
+
# eTax仕様を変換したTSVを集計して、タグの有効バージョンをリストするツール
|
6
|
+
#
|
7
|
+
|
8
|
+
def accumulate_versions(attr, csv)
|
9
|
+
csv.each do |row|
|
10
|
+
attr[row['tag']] ||= { versions: [] }
|
11
|
+
attr[row['tag']][:versions].push(row['version'])
|
12
|
+
attr[row['tag']][:label] = row['label']
|
13
|
+
attr[row['tag']][:level] = row['level']
|
14
|
+
attr[row['tag']][:order] = row['order']
|
15
|
+
attr[row['tag']][:struct] = row['struct']
|
16
|
+
attr[row['tag']][:note] = row['note']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# ARGV[0]には申請書コード(ファイル名の一部)を指定
|
21
|
+
attr = {}
|
22
|
+
Dir.glob("#{ARGV[0]}*.tsv").each do |path|
|
23
|
+
CSV.open(path, "r", col_sep: "\t", headers: true) do |csv|
|
24
|
+
accumulate_versions(attr, csv)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
output = "stats-#{ARGV[0]}.tsv"
|
28
|
+
CSV.open(output, "w", col_sep: "\t") do |csv|
|
29
|
+
csv << ["tag", "count", "level", "versions", "order", "label", "struct", "note"]
|
30
|
+
attr.each do |k, v|
|
31
|
+
csv << [k, v[:versions].length, v[:level], v[:versions].join(', '), v[:order], v[:label], v[:struct], v[:note]]
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jp-national-tax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chuma Takahiro
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,13 +75,15 @@ files:
|
|
75
75
|
- lib/jp_national_tax/income_tax/income_kouran_2020.rb
|
76
76
|
- lib/jp_national_tax/income_tax/income_nenmatsu_2020.rb
|
77
77
|
- lib/jp_national_tax/version.rb
|
78
|
+
- tools/parse-etax-spec.rb
|
79
|
+
- tools/stats-etax-spec.rb
|
78
80
|
homepage: https://github.com/chumaltd/jp-national-tax
|
79
81
|
licenses: []
|
80
82
|
metadata:
|
81
83
|
homepage_uri: https://github.com/chumaltd/jp-national-tax
|
82
84
|
source_code_uri: https://github.com/chumaltd/jp-national-tax
|
83
85
|
changelog_uri: https://github.com/chumaltd/jp-national-tax/CHANGELOG.md
|
84
|
-
post_install_message:
|
86
|
+
post_install_message:
|
85
87
|
rdoc_options: []
|
86
88
|
require_paths:
|
87
89
|
- lib
|
@@ -96,8 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
98
|
- !ruby/object:Gem::Version
|
97
99
|
version: '0'
|
98
100
|
requirements: []
|
99
|
-
rubygems_version: 3.4.
|
100
|
-
signing_key:
|
101
|
+
rubygems_version: 3.4.10
|
102
|
+
signing_key:
|
101
103
|
specification_version: 4
|
102
104
|
summary: Tax calculation libs for Japan National tax
|
103
105
|
test_files: []
|