Skip to content

Instantly share code, notes, and snippets.

@leaysgur
Last active July 15, 2024 05:02
Show Gist options
  • Save leaysgur/812a1ae55b63a6a105cb6dffccabd492 to your computer and use it in GitHub Desktop.
Save leaysgur/812a1ae55b63a6a105cb6dffccabd492 to your computer and use it in GitHub Desktop.
所得税とその税率を計算
// @ts-check
/**
* | 課税所得 | 税率 | 控除額 |
* | ---------------------------------- | ---- | ----------- |
* | 1,000円 から 1,949,000円まで | 5% | 0円 |
* | 1,950,000円 から 3,299,000円まで | 10% | 97,500円 |
* | 3,300,000円 から 6,949,000円まで | 20% | 427,500円 |
* | 6,950,000円 から 8,999,000円まで | 23% | 636,000円 |
* | 9,000,000円 から 17,999,000円まで | 33% | 1,536,000円 |
* | 18,000,000円 から 39,999,000円まで | 40% | 2,796,000円 |
* | 40,000,000円 以上 | 45% | 4,796,000円 |
* https://www.nta.go.jp/taxes/shiraberu/taxanswer/shotoku/2260.htm
*
* @param {number} 課税所得
*/
const 課税所得から税率と控除額 = (課税所得) => {
if (課税所得 <= 1_949_000) return { 税率: 0.05, 控除額: 0 };
if (課税所得 <= 3_299_000) return { 税率: 0.1, 控除額: 97_500 };
if (課税所得 <= 6_949_000) return { 税率: 0.2, 控除額: 427_500 };
if (課税所得 <= 8_999_000) return { 税率: 0.23, 控除額: 636_000 };
if (課税所得 <= 17_999_900) return { 税率: 0.33, 控除額: 1_536_000 };
if (課税所得 <= 39_999_900) return { 税率: 0.4, 控除額: 2_796_000 };
return { 税率: 0.45, 控除額: 4_796_000 };
};
/**
* @param {number} 所得
* @param {number} 所得控除
*/
const 所得税の合計 = (所得, 所得控除) => {
// 課税所得は、1000円未満は切り捨て
const 課税所得 = Math.trunc((所得 - 所得控除) / 1000) * 1000;
const { 税率, 控除額 } = 課税所得から税率と控除額(課税所得);
// 1円未満は切り捨て
const 所得税 = Math.trunc(課税所得 * 税率 - 控除額);
// 復興特別所得税(2037年まで)
const 復興特別所得税 = Math.trunc(所得税 * 0.021);
// 100円未満は切り捨て
const 合計 = Math.trunc((所得税 + 復興特別所得税) / 100) * 100;
console.log({ 課税所得, 税率, 合計 });
return 合計;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment