Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

控除額を人物単位で計算できるようにする(配偶者控除, 勤労学生控除, 寡婦控除, ひとり親控除) #256

Merged
merged 8 commits into from
Mar 31, 2024

Conversation

Syuparn
Copy link
Contributor

@Syuparn Syuparn commented Mar 28, 2024

Pull request前の確認

  • フォークしたリポジトリのdevelopブランチ(あるいはそこから新たに切ったブランチ)にプッシュを行った。(mainブランチに直接プッシュしていない。)
  • プルリクエストでマージを要求するブランチをmainブランチからdevelopブランチに変更した。

概要

  • この Pull request は 所得、住民税控除の計算単位 を修正する
    • そのために 配偶者控除 を変更した
    • そのために 配偶者特別控除 を変更した
    • そのために 勤労学生控除 を変更した
    • そのために 寡婦控除 を変更した
    • そのために ひとり親控除 を変更した
    • そのために 児童手当の控除後世帯高所得 を 控除後世帯高所得 と分離した

動作確認

  • 変更した部分の影響しそうな箇所をテストした

関連issue: #165

Copy link

netlify bot commented Mar 28, 2024

Deploy Preview for shien-yadokari canceled.

Name Link
🔨 Latest commit d1619b2
🔍 Latest deploy log https://app.netlify.com/sites/shien-yadokari/deploys/6605fc5a55690700081855dc

@Syuparn
Copy link
Contributor Author

Syuparn commented Mar 28, 2024

障害者控除と扶養控除については、改修が大きくなりそうなので別PRに分けようと思っています。

ひとり親控除額 = parameters(対象期間).所得.ひとり親控除額
ひとり親控除_所得制限額 = parameters(対象期間).所得.ひとり親控除_所得制限額

return ひとり親控除額 * 対象ひとり親 * (世帯高所得 < ひとり親控除_所得制限額)
return 親である * ひとり親控除額 * 対象ひとり親 * (所得 < ひとり親控除_所得制限額)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

対象は親(一人)のみなので条件を追加しています。そのため世帯での合計額も変わりません。

@Syuparn Syuparn marked this pull request as draft March 28, 2024 23:19
控除対象者の配偶者である = (所得降順 == 1) * 対象人物.has_role(世帯.親)
控除対象者の所得 = 所得一覧 * 控除対象者である
# NOTE: 異なる人物に対する値であるため、人物ではなく世帯ごとに集計(でないと「控除対象者の所得」と要素がずれてしまい計算できない)
控除対象者の配偶者の所得 = 対象人物.世帯.sum(所得一覧 * 控除対象者の配偶者である)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

控除額自体は 控除対象者であるTrue でないと0円になるため、世帯ごとの計算にしても金額が増えてしまうことはありません。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

逆に人物ごとの計算にすると計算が正確にできません。

例:

控除対象者の所得 = [5000000, 0]
控除対象者の配偶者の所得 = [0, 300000]

# 計算したいのは{対象者の所得 = 5000000, 控除対象者の配偶者の所得 = 300000 の場合} だが...
配偶者特別控除額表()[納税者の配偶者の所得区分, 納税者の所得区分] = [
    {対象者の所得 = 5000000, 控除対象者の配偶者の所得 = 0 の場合},,
    {対象者の所得 = 0, 控除対象者の配偶者の所得 = 300000 の場合},
]

@@ -134,22 +136,19 @@ class 住民税勤労学生控除(Variable):
OpenFiscaではクラス名をアプリ全体で一意にする必要があるため、先頭に「住民税」を追加。
"""

def formula(対象世帯, 対象期間, parameters):
# 勤労学生控除額は対象人数によらず定額そう
# https://www.city.hirakata.osaka.jp/kosodate/0000000544.html
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

勤労学生控除の説明に

納税者自身が勤労学生であるときは、一定の金額の所得控除を受けることができます。

とあるので、人物ごとの控除に修正しました。

コメントにある児童手当のリンク先の説明ですが、

また、所得は世帯合算ではなく、受給者(申請者)の所得のみで判定します。

とあるため、児童手当の場合は手当を受ける本人の所得(世帯高所得)を参照し、その世帯員自身が勤労学生控除を受ける場合に控除額が適用されると考えるのが適切だと思いました。
(本人が対象となるか否かなので、この場合も表の通り控除額は定額になります)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

児童手当側の修正は障害者控除、扶養控除の分離が終わったタイミングで合わせて行います。

@Syuparn Syuparn marked this pull request as ready for review March 28, 2024 23:41
@Syuparn
Copy link
Contributor Author

Syuparn commented Mar 28, 2024

@SnoozingJellyfish
別制度で控除額を参照する際の準備として、控除額を人物ごとの計算にするよう修正しました。お手すきの際にレビューよろしくお願いします 🙇

@SnoozingJellyfish
Copy link
Contributor

修正ありがとうございます!確認しました。マージします。
控除の計算なかなかに複雑なので、OpenFiscaを税金シミュレーターとして使ってもらうのもいいかもしれませんね。。

@SnoozingJellyfish SnoozingJellyfish merged commit 7fff55c into project-inclusive:develop Mar 31, 2024
7 checks passed
@Syuparn Syuparn deleted the issue-165 branch April 8, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants