Skip to content

Instantly share code, notes, and snippets.

@tbtbt
Last active June 19, 2019 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbtbt/691125149751df403b43712185a938cc to your computer and use it in GitHub Desktop.
Save tbtbt/691125149751df403b43712185a938cc to your computer and use it in GitHub Desktop.
平成30年源泉所得税取得(Google Cloud Functions用スクリプト)
/**
* 平成30年度源泉所得税を算出します
*/
// 加算額
const additionalTax = [{
"condition": (salary, type) => salary < 88000 && type === 'b',
"method": (salary) => Math.floor(salary * 0.03063)
},
{
"condition": (salary, type) => salary > 860000 && salary < 970000 && type === 'a',
"method": (salary) => Math.floor((salary - 860000) * 0.23483)
},
{
"condition": (salary, type) => salary > 860000 && salary < 970000 && type === 'b',
"method": (salary) => Math.floor((salary - 860000) * 0.4084)
},
{
"condition": (salary, type) => salary > 970000 && salary < 1720000 && type === 'a',
"method": (salary) => Math.floor((salary - 970000) * 0.33693)
},
{
"condition": (salary, type) => salary > 970000 && salary < 1720000 && type === 'b',
"method": (salary) => Math.floor((salary - 860000) * 0.4084)
},
{
"condition": (salary, type) => salary > 1720000 && salary < 3550000 && type === 'a',
"method": (salary) => Math.floor((salary - 1720000) * 0.4084)
},
{
"condition": (salary, type) => salary > 1720000 && salary < 3550000 && type === 'b',
"method": (salary) => Math.floor((salary - 1720000) * 0.45945)
},
{
"condition": (salary, type) => salary > 3550000 && type === 'a',
"method": (salary) => Math.floor((salary - 3550000) * 0.45945)
},
{
"condition": (salary, type) => salary > 3550000 && type === 'b',
"method": (salary) => Math.floor((salary - 1720000) * 0.45945)
},
];
// 扶養人数に関する控除額
const deductionByDependents = (number_of_dependents) => (number_of_dependents - 7) * 1610;
// 基礎税額
const basicTaxList = [
[0, 88000, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[88000, 89000, 130, 0, 0, 0, 0, 0, 0, 0, 3200],
[89000, 90000, 180, 0, 0, 0, 0, 0, 0, 0, 3200],
[90000, 91000, 230, 0, 0, 0, 0, 0, 0, 0, 3200],
[91000, 92000, 290, 0, 0, 0, 0, 0, 0, 0, 3200],
[92000, 93000, 340, 0, 0, 0, 0, 0, 0, 0, 3300],
[93000, 94000, 390, 0, 0, 0, 0, 0, 0, 0, 3300],
[94000, 95000, 440, 0, 0, 0, 0, 0, 0, 0, 3300],
[95000, 96000, 490, 0, 0, 0, 0, 0, 0, 0, 3400],
[96000, 97000, 540, 0, 0, 0, 0, 0, 0, 0, 3400],
[97000, 98000, 590, 0, 0, 0, 0, 0, 0, 0, 3500],
[98000, 99000, 640, 0, 0, 0, 0, 0, 0, 0, 3500],
[99000, 101000, 720, 0, 0, 0, 0, 0, 0, 0, 3600],
[101000, 103000, 830, 0, 0, 0, 0, 0, 0, 0, 3600],
[103000, 105000, 930, 0, 0, 0, 0, 0, 0, 0, 3700],
[105000, 107000, 1030, 0, 0, 0, 0, 0, 0, 0, 3800],
[107000, 109000, 1130, 0, 0, 0, 0, 0, 0, 0, 3800],
[109000, 111000, 1240, 0, 0, 0, 0, 0, 0, 0, 3900],
[111000, 113000, 1340, 0, 0, 0, 0, 0, 0, 0, 4000],
[113000, 115000, 1440, 0, 0, 0, 0, 0, 0, 0, 4100],
[115000, 117000, 1540, 0, 0, 0, 0, 0, 0, 0, 4100],
[117000, 119000, 1640, 0, 0, 0, 0, 0, 0, 0, 4200],
[119000, 121000, 1750, 120, 0, 0, 0, 0, 0, 0, 4300],
[121000, 123000, 1850, 220, 0, 0, 0, 0, 0, 0, 4500],
[123000, 125000, 1950, 330, 0, 0, 0, 0, 0, 0, 4800],
[125000, 127000, 2050, 430, 0, 0, 0, 0, 0, 0, 5100],
[127000, 129000, 2150, 530, 0, 0, 0, 0, 0, 0, 5400],
[129000, 131000, 2260, 630, 0, 0, 0, 0, 0, 0, 5700],
[131000, 133000, 2360, 740, 0, 0, 0, 0, 0, 0, 6000],
[133000, 135000, 2460, 840, 0, 0, 0, 0, 0, 0, 6300],
[135000, 137000, 2550, 930, 0, 0, 0, 0, 0, 0, 6600],
[137000, 139000, 2610, 990, 0, 0, 0, 0, 0, 0, 6800],
[139000, 141000, 2680, 1050, 0, 0, 0, 0, 0, 0, 7100],
[141000, 143000, 2740, 1110, 0, 0, 0, 0, 0, 0, 7500],
[143000, 145000, 2800, 1170, 0, 0, 0, 0, 0, 0, 7800],
[145000, 147000, 2860, 1240, 0, 0, 0, 0, 0, 0, 8100],
[147000, 149000, 2920, 1300, 0, 0, 0, 0, 0, 0, 8400],
[149000, 151000, 2980, 1360, 0, 0, 0, 0, 0, 0, 8700],
[151000, 153000, 3050, 1430, 0, 0, 0, 0, 0, 0, 9000],
[153000, 155000, 3120, 1500, 0, 0, 0, 0, 0, 0, 9300],
[155000, 157000, 3200, 1570, 0, 0, 0, 0, 0, 0, 9600],
[157000, 159000, 3270, 1640, 0, 0, 0, 0, 0, 0, 9900],
[159000, 161000, 3340, 1720, 100, 0, 0, 0, 0, 0, 10200],
[161000, 163000, 3410, 1790, 170, 0, 0, 0, 0, 0, 10500],
[163000, 165000, 3480, 1860, 250, 0, 0, 0, 0, 0, 10800],
[165000, 167000, 3550, 1930, 320, 0, 0, 0, 0, 0, 11100],
[167000, 169000, 3620, 2000, 390, 0, 0, 0, 0, 0, 11400],
[169000, 171000, 3700, 2070, 460, 0, 0, 0, 0, 0, 11700],
[171000, 173000, 3770, 2140, 530, 0, 0, 0, 0, 0, 12000],
[173000, 175000, 3840, 2220, 600, 0, 0, 0, 0, 0, 12400],
[175000, 177000, 3910, 2290, 670, 0, 0, 0, 0, 0, 12700],
[177000, 179000, 3980, 2360, 750, 0, 0, 0, 0, 0, 13200],
[179000, 181000, 4050, 2430, 820, 0, 0, 0, 0, 0, 13900],
[181000, 183000, 4120, 2500, 890, 0, 0, 0, 0, 0, 14600],
[183000, 185000, 4200, 2570, 960, 0, 0, 0, 0, 0, 15300],
[185000, 187000, 4270, 2640, 1030, 0, 0, 0, 0, 0, 16000],
[187000, 189000, 4340, 2720, 1100, 0, 0, 0, 0, 0, 16700],
[189000, 191000, 4410, 2790, 1170, 0, 0, 0, 0, 0, 17500],
[191000, 193000, 4480, 2860, 1250, 0, 0, 0, 0, 0, 18100],
[193000, 195000, 4550, 2930, 1320, 0, 0, 0, 0, 0, 18800],
[195000, 197000, 4630, 3000, 1390, 0, 0, 0, 0, 0, 19500],
[197000, 199000, 4700, 3070, 1460, 0, 0, 0, 0, 0, 20200],
[199000, 201000, 4770, 3140, 1530, 0, 0, 0, 0, 0, 20900],
[201000, 203000, 4840, 3220, 1600, 0, 0, 0, 0, 0, 21500],
[203000, 205000, 4910, 3290, 1670, 0, 0, 0, 0, 0, 22200],
[205000, 207000, 4980, 3360, 1750, 130, 0, 0, 0, 0, 22700],
[207000, 209000, 5050, 3430, 1820, 200, 0, 0, 0, 0, 23300],
[209000, 211000, 5130, 3500, 1890, 280, 0, 0, 0, 0, 23900],
[211000, 213000, 5200, 3570, 1960, 350, 0, 0, 0, 0, 24400],
[213000, 215000, 5270, 3640, 2030, 420, 0, 0, 0, 0, 25000],
[215000, 217000, 5340, 3720, 2100, 490, 0, 0, 0, 0, 25500],
[217000, 219000, 5410, 3790, 2170, 560, 0, 0, 0, 0, 26100],
[219000, 221000, 5480, 3860, 2250, 630, 0, 0, 0, 0, 26800],
[221000, 224000, 5560, 3950, 2340, 710, 0, 0, 0, 0, 27400],
[224000, 227000, 5680, 4060, 2440, 830, 0, 0, 0, 0, 28400],
[227000, 230000, 5780, 4170, 2550, 930, 0, 0, 0, 0, 29300],
[230000, 233000, 5890, 4280, 2650, 1040, 0, 0, 0, 0, 30300],
[233000, 236000, 5990, 4380, 2770, 1140, 0, 0, 0, 0, 31300],
[236000, 239000, 6110, 4490, 2870, 1260, 0, 0, 0, 0, 32400],
[239000, 242000, 6210, 4590, 2980, 1360, 0, 0, 0, 0, 33400],
[242000, 245000, 6320, 4710, 3080, 1470, 0, 0, 0, 0, 34400],
[245000, 248000, 6420, 4810, 3200, 1570, 0, 0, 0, 0, 35400],
[248000, 251000, 6530, 4920, 3300, 1680, 0, 0, 0, 0, 36400],
[251000, 254000, 6640, 5020, 3410, 1790, 170, 0, 0, 0, 37500],
[254000, 257000, 6750, 5140, 3510, 1900, 290, 0, 0, 0, 38500],
[257000, 260000, 6850, 5240, 3620, 2000, 390, 0, 0, 0, 39400],
[260000, 263000, 6960, 5350, 3730, 2110, 500, 0, 0, 0, 40400],
[263000, 266000, 7070, 5450, 3840, 2220, 600, 0, 0, 0, 41500],
[266000, 269000, 7180, 5560, 3940, 2330, 710, 0, 0, 0, 42500],
[269000, 272000, 7280, 5670, 4050, 2430, 820, 0, 0, 0, 43500],
[272000, 275000, 7390, 5780, 4160, 2540, 930, 0, 0, 0, 44500],
[275000, 278000, 7490, 5880, 4270, 2640, 1030, 0, 0, 0, 45500],
[278000, 281000, 7610, 5990, 4370, 2760, 1140, 0, 0, 0, 46600],
[281000, 284000, 7710, 6100, 4480, 2860, 1250, 0, 0, 0, 47600],
[284000, 287000, 7820, 6210, 4580, 2970, 1360, 0, 0, 0, 48600],
[287000, 290000, 7920, 6310, 4700, 3070, 1460, 0, 0, 0, 49500],
[290000, 293000, 8040, 6420, 4800, 3190, 1570, 0, 0, 0, 50500],
[293000, 296000, 8140, 6520, 4910, 3290, 1670, 0, 0, 0, 51600],
[296000, 299000, 8250, 6640, 5010, 3400, 1790, 160, 0, 0, 52300],
[299000, 302000, 8420, 6740, 5130, 3510, 1890, 280, 0, 0, 52900],
[302000, 305000, 8670, 6860, 5250, 3630, 2010, 400, 0, 0, 53500],
[305000, 308000, 8910, 6980, 5370, 3760, 2130, 520, 0, 0, 54200],
[308000, 311000, 9160, 7110, 5490, 3880, 2260, 640, 0, 0, 54800],
[311000, 314000, 9400, 7230, 5620, 4000, 2380, 770, 0, 0, 55400],
[314000, 317000, 9650, 7350, 5740, 4120, 2500, 890, 0, 0, 56100],
[317000, 320000, 9890, 7470, 5860, 4250, 2620, 1010, 0, 0, 56800],
[320000, 323000, 10140, 7600, 5980, 4370, 2750, 1130, 0, 0, 57700],
[323000, 326000, 10380, 7720, 6110, 4490, 2870, 1260, 0, 0, 58500],
[326000, 329000, 10630, 7840, 6230, 4610, 2990, 1380, 0, 0, 59300],
[329000, 332000, 10870, 7960, 6350, 4740, 3110, 1500, 0, 0, 60200],
[332000, 335000, 11120, 8090, 6470, 4860, 3240, 1620, 0, 0, 61100],
[335000, 338000, 11360, 8210, 6600, 4980, 3360, 1750, 130, 0, 62000],
[338000, 341000, 11610, 8370, 6720, 5110, 3480, 1870, 260, 0, 63000],
[341000, 344000, 11850, 8620, 6840, 5230, 3600, 1990, 380, 0, 64000],
[344000, 347000, 12100, 8860, 6960, 5350, 3730, 2110, 500, 0, 65000],
[347000, 350000, 12340, 9110, 7090, 5470, 3850, 2240, 620, 0, 66200],
[350000, 353000, 12590, 9350, 7210, 5600, 3970, 2360, 750, 0, 67200],
[353000, 356000, 12830, 9600, 7330, 5720, 4090, 2480, 870, 0, 68200],
[356000, 359000, 13080, 9840, 7450, 5840, 4220, 2600, 990, 0, 69200],
[359000, 362000, 13320, 10090, 7580, 5960, 4340, 2730, 1110, 0, 70200],
[362000, 365000, 13570, 10330, 7700, 6090, 4460, 2850, 1240, 0, 71300],
[365000, 368000, 13810, 10580, 7820, 6210, 4580, 2970, 1360, 0, 72300],
[368000, 371000, 14060, 10820, 7940, 6330, 4710, 3090, 1480, 0, 73200],
[371000, 374000, 14300, 11070, 8070, 6450, 4830, 3220, 1600, 0, 74200],
[374000, 377000, 14550, 11310, 8190, 6580, 4950, 3340, 1730, 100, 75100],
[377000, 380000, 14790, 11560, 8320, 6700, 5070, 3460, 1850, 220, 76100],
[380000, 383000, 15040, 11800, 8570, 6820, 5200, 3580, 1970, 350, 77000],
[383000, 386000, 15280, 12050, 8810, 6940, 5320, 3710, 2090, 470, 77900],
[386000, 389000, 15530, 12290, 9060, 7070, 5440, 3830, 2220, 590, 78800],
[389000, 392000, 15770, 12540, 9300, 7190, 5560, 3950, 2340, 710, 80600],
[392000, 395000, 16020, 12780, 9550, 7310, 5690, 4070, 2460, 840, 82300],
[395000, 398000, 16260, 13030, 9790, 7430, 5810, 4200, 2580, 960, 83900],
[398000, 401000, 16510, 13270, 10040, 7560, 5930, 4320, 2710, 1080, 85700],
[401000, 404000, 16750, 13520, 10280, 7680, 6050, 4440, 2830, 1200, 87400],
[404000, 407000, 17000, 13760, 10530, 7800, 6180, 4560, 2950, 1330, 89000],
[407000, 410000, 17240, 14010, 10770, 7920, 6300, 4690, 3070, 1450, 90800],
[410000, 413000, 17490, 14250, 11020, 8050, 6420, 4810, 3200, 1570, 92500],
[413000, 416000, 17730, 14500, 11260, 8170, 6540, 4930, 3320, 1690, 94100],
[416000, 419000, 17980, 14740, 11510, 8290, 6670, 5050, 3440, 1820, 95900],
[419000, 422000, 18220, 14990, 11750, 8530, 6790, 5180, 3560, 1940, 97600],
[422000, 425000, 18470, 15230, 12000, 8770, 6910, 5300, 3690, 2060, 99200],
[425000, 428000, 18710, 15480, 12240, 9020, 7030, 5420, 3810, 2180, 101000],
[428000, 431000, 18960, 15720, 12490, 9260, 7160, 5540, 3930, 2310, 102600],
[431000, 434000, 19210, 15970, 12730, 9510, 7280, 5670, 4050, 2430, 104300],
[434000, 437000, 19450, 16210, 12980, 9750, 7400, 5790, 4180, 2550, 106100],
[437000, 440000, 19700, 16460, 13220, 10000, 7520, 5910, 4300, 2680, 107700],
[440000, 443000, 20090, 16700, 13470, 10240, 7650, 6030, 4420, 2800, 109500],
[443000, 446000, 20580, 16950, 13710, 10490, 7770, 6160, 4540, 2920, 111200],
[446000, 449000, 21070, 17190, 13960, 10730, 7890, 6280, 4670, 3040, 112800],
[449000, 452000, 21560, 17440, 14200, 10980, 8010, 6400, 4790, 3170, 114600],
[452000, 455000, 22050, 17680, 14450, 11220, 8140, 6520, 4910, 3290, 116300],
[455000, 458000, 22540, 17930, 14690, 11470, 8260, 6650, 5030, 3410, 117900],
[458000, 461000, 23030, 18170, 14940, 11710, 8470, 6770, 5160, 3530, 119700],
[461000, 464000, 23520, 18420, 15180, 11960, 8720, 6890, 5280, 3660, 121400],
[464000, 467000, 24010, 18660, 15430, 12200, 8960, 7010, 5400, 3780, 123000],
[467000, 470000, 24500, 18910, 15670, 12450, 9210, 7140, 5520, 3900, 124800],
[470000, 473000, 24990, 19150, 15920, 12690, 9450, 7260, 5650, 4020, 126500],
[473000, 476000, 25480, 19400, 16160, 12940, 9700, 7380, 5770, 4150, 128100],
[476000, 479000, 25970, 19640, 16410, 13180, 9940, 7500, 5890, 4270, 129900],
[479000, 482000, 26460, 20000, 16650, 13430, 10190, 7630, 6010, 4390, 131600],
[482000, 485000, 26950, 20490, 16900, 13670, 10430, 7750, 6140, 4510, 133200],
[485000, 488000, 27440, 20980, 17140, 13920, 10680, 7870, 6260, 4640, 135000],
[488000, 491000, 27930, 21470, 17390, 14160, 10920, 7990, 6380, 4760, 136600],
[491000, 494000, 28420, 21960, 17630, 14410, 11170, 8120, 6500, 4880, 138300],
[494000, 497000, 28910, 22450, 17880, 14650, 11410, 8240, 6630, 5000, 140100],
[497000, 500000, 29400, 22940, 18120, 14900, 11660, 8420, 6750, 5130, 141700],
[500000, 503000, 29890, 23430, 18370, 15140, 11900, 8670, 6870, 5250, 143500],
[503000, 506000, 30380, 23920, 18610, 15390, 12150, 8910, 6990, 5370, 145200],
[506000, 509000, 30880, 24410, 18860, 15630, 12390, 9160, 7120, 5490, 146800],
[509000, 512000, 31370, 24900, 19100, 15880, 12640, 9400, 7240, 5620, 148600],
[512000, 515000, 31860, 25390, 19350, 16120, 12890, 9650, 7360, 5740, 150300],
[515000, 518000, 32350, 25880, 19590, 16370, 13130, 9890, 7480, 5860, 151900],
[518000, 521000, 32840, 26370, 19900, 16610, 13380, 10140, 7610, 5980, 153700],
[521000, 524000, 33330, 26860, 20390, 16860, 13620, 10380, 7730, 6110, 155400],
[524000, 527000, 33820, 27350, 20880, 17100, 13870, 10630, 7850, 6230, 157000],
[527000, 530000, 34310, 27840, 21370, 17350, 14110, 10870, 7970, 6350, 158800],
[530000, 533000, 34800, 28330, 21860, 17590, 14360, 11120, 8100, 6470, 160300],
[533000, 536000, 35290, 28820, 22350, 17840, 14600, 11360, 8220, 6600, 161900],
[536000, 539000, 35780, 29310, 22840, 18080, 14850, 11610, 8380, 6720, 163500],
[539000, 542000, 36270, 29800, 23330, 18330, 15090, 11850, 8630, 6840, 165000],
[542000, 545000, 36760, 30290, 23820, 18570, 15340, 12100, 8870, 6960, 166600],
[545000, 548000, 37250, 30780, 24310, 18820, 15580, 12340, 9120, 7090, 168200],
[548000, 551000, 37740, 31270, 24800, 19060, 15830, 12590, 9360, 7210, 169800],
[551000, 554000, 38280, 31810, 25340, 19330, 16100, 12860, 9630, 7350, 171300],
[554000, 557000, 38830, 32370, 25890, 19600, 16380, 13140, 9900, 7480, 173000],
[557000, 560000, 39380, 32920, 26440, 19980, 16650, 13420, 10180, 7630, 174500],
[560000, 563000, 39930, 33470, 27000, 20530, 16930, 13690, 10460, 7760, 175900],
[563000, 566000, 40480, 34020, 27550, 21080, 17200, 13970, 10730, 7900, 177300],
[566000, 569000, 41030, 34570, 28100, 21630, 17480, 14240, 11010, 8040, 178900],
[569000, 572000, 41590, 35120, 28650, 22190, 17760, 14520, 11280, 8180, 180300],
[572000, 575000, 42140, 35670, 29200, 22740, 18030, 14790, 11560, 8330, 181800],
[575000, 578000, 42690, 36230, 29750, 23290, 18310, 15070, 11830, 8610, 183300],
[578000, 581000, 43240, 36780, 30300, 23840, 18580, 15350, 12110, 8880, 184700],
[581000, 584000, 43790, 37330, 30850, 24390, 18860, 15620, 12380, 9160, 186200],
[584000, 587000, 44340, 37880, 31410, 24940, 19130, 15900, 12660, 9430, 187700],
[587000, 590000, 44890, 38430, 31960, 25490, 19410, 16170, 12940, 9710, 189200],
[590000, 593000, 45440, 38980, 32510, 26050, 19680, 16450, 13210, 9990, 190600],
[593000, 596000, 46000, 39530, 33060, 26600, 20130, 16720, 13490, 10260, 192100],
[596000, 599000, 46550, 40080, 33610, 27150, 20690, 17000, 13760, 10540, 193600],
[599000, 602000, 47100, 40640, 34160, 27700, 21240, 17280, 14040, 10810, 195000],
[602000, 605000, 47650, 41190, 34710, 28250, 21790, 17550, 14310, 11090, 196500],
[605000, 608000, 48200, 41740, 35270, 28800, 22340, 17830, 14590, 11360, 198000],
[608000, 611000, 48750, 42290, 35820, 29350, 22890, 18100, 14870, 11640, 199400],
[611000, 614000, 49300, 42840, 36370, 29910, 23440, 18380, 15140, 11920, 200900],
[614000, 617000, 49860, 43390, 36920, 30460, 23990, 18650, 15420, 12190, 202400],
[617000, 620000, 50410, 43940, 37470, 31010, 24540, 18930, 15690, 12470, 203900],
[620000, 623000, 50960, 44500, 38020, 31560, 25100, 19210, 15970, 12740, 205300],
[623000, 626000, 51510, 45050, 38570, 32110, 25650, 19480, 16240, 13020, 206800],
[626000, 629000, 52060, 45600, 39120, 32660, 26200, 19760, 16520, 13290, 208300],
[629000, 632000, 52610, 46150, 39680, 33210, 26750, 20280, 16800, 13570, 209700],
[632000, 635000, 53160, 46700, 40230, 33760, 27300, 20830, 17070, 13840, 211200],
[635000, 638000, 53710, 47250, 40780, 34320, 27850, 21380, 17350, 14120, 212700],
[638000, 641000, 54270, 47800, 41330, 34870, 28400, 21930, 17620, 14400, 214100],
[641000, 644000, 54820, 48350, 41880, 35420, 28960, 22480, 17900, 14670, 215600],
[644000, 647000, 55370, 48910, 42430, 35970, 29510, 23030, 18170, 14950, 217000],
[647000, 650000, 55920, 49460, 42980, 36520, 30060, 23590, 18450, 15220, 218000],
[650000, 653000, 56470, 50010, 43540, 37070, 30610, 24140, 18730, 15500, 219000],
[653000, 656000, 57020, 50560, 44090, 37620, 31160, 24690, 19000, 15770, 220000],
[656000, 659000, 57570, 51110, 44640, 38180, 31710, 25240, 19280, 16050, 221000],
[659000, 662000, 58130, 51660, 45190, 38730, 32260, 25790, 19550, 16330, 222100],
[662000, 665000, 58680, 52210, 45740, 39280, 32810, 26340, 19880, 16600, 223100],
[665000, 668000, 59230, 52770, 46290, 39830, 33370, 26890, 20430, 16880, 224100],
[668000, 671000, 59780, 53320, 46840, 40380, 33920, 27440, 20980, 17150, 225000],
[671000, 674000, 60330, 53870, 47390, 40930, 34470, 28000, 21530, 17430, 226000],
[674000, 677000, 60880, 54420, 47950, 41480, 35020, 28550, 22080, 17700, 227100],
[677000, 680000, 61430, 54970, 48500, 42030, 35570, 29100, 22640, 17980, 228100],
[680000, 683000, 61980, 55520, 49050, 42590, 36120, 29650, 23190, 18260, 229100],
[683000, 686000, 62540, 56070, 49600, 43140, 36670, 30200, 23740, 18530, 230100],
[686000, 689000, 63090, 56620, 50150, 43690, 37230, 30750, 24290, 18810, 231200],
[689000, 692000, 63640, 57180, 50700, 44240, 37780, 31300, 24840, 19080, 232700],
[692000, 695000, 64190, 57730, 51250, 44790, 38330, 31860, 25390, 19360, 234200],
[695000, 698000, 64740, 58280, 51810, 45340, 38880, 32410, 25940, 19630, 235700],
[698000, 701000, 65290, 58830, 52360, 45890, 39430, 32960, 26490, 20030, 237300],
[701000, 704000, 65840, 59380, 52910, 46450, 39980, 33510, 27050, 20580, 238900],
[704000, 707000, 66400, 59930, 53460, 47000, 40530, 34060, 27600, 21130, 240400],
[707000, 710000, 66950, 60480, 54010, 47550, 41090, 34610, 28150, 21690, 242000],
[710000, 713000, 67500, 61040, 54560, 48100, 41640, 35160, 28700, 22240, 243500],
[713000, 716000, 68050, 61590, 55110, 48650, 42190, 35710, 29250, 22790, 245000],
[716000, 719000, 68600, 62140, 55660, 49200, 42740, 36270, 29800, 23340, 246600],
[719000, 722000, 69150, 62690, 56220, 49750, 43290, 36820, 30350, 23890, 248100],
[722000, 725000, 69700, 63240, 56770, 50300, 43840, 37370, 30910, 24440, 249700],
[725000, 728000, 70260, 63790, 57320, 50860, 44390, 37920, 31460, 24990, 251300],
[728000, 731000, 70810, 64340, 57870, 51410, 44940, 38470, 32010, 25550, 252800],
[731000, 734000, 71360, 64890, 58420, 51960, 45500, 39020, 32560, 26100, 254300],
[734000, 737000, 71910, 65450, 58970, 52510, 46050, 39570, 33110, 26650, 255900],
[737000, 740000, 72460, 66000, 59520, 53060, 46600, 40130, 33660, 27200, 257400],
[740000, 743000, 73010, 66550, 60080, 53610, 47150, 40680, 34210, 27750, 259000],
[743000, 746000, 73560, 67100, 60630, 54160, 47700, 41230, 34770, 28300, 260600],
[746000, 749000, 74110, 67650, 61180, 54720, 48250, 41780, 35320, 28850, 262100],
[749000, 752000, 74670, 68200, 61730, 55270, 48800, 42330, 35870, 29400, 263600],
[752000, 755000, 75220, 68750, 62280, 55820, 49360, 42880, 36420, 29960, 265200],
[755000, 758000, 75770, 69310, 62830, 56370, 49910, 43430, 36970, 30510, 266700],
[758000, 761000, 76320, 69860, 63380, 56920, 50460, 43980, 37520, 31060, 268200],
[761000, 764000, 76870, 70410, 63940, 57470, 51010, 44540, 38070, 31610, 269900],
[764000, 767000, 77420, 70960, 64490, 58020, 51560, 45090, 38620, 32160, 271400],
[767000, 770000, 77970, 71510, 65040, 58570, 52110, 45640, 39180, 32710, 272900],
[770000, 773000, 78530, 72060, 65590, 59130, 52660, 46190, 39730, 33260, 274400],
[773000, 776000, 79080, 72610, 66140, 59680, 53210, 46740, 40280, 33820, 276000],
[776000, 779000, 79630, 73160, 66690, 60230, 53770, 47290, 40830, 34370, 277500],
[779000, 782000, 80180, 73720, 67240, 60780, 54320, 47840, 41380, 34920, 279000],
[782000, 785000, 80730, 74270, 67790, 61330, 54870, 48400, 41930, 35470, 280700],
[785000, 788000, 81280, 74820, 68350, 61880, 55420, 48950, 42480, 36020, 282200],
[788000, 791000, 81830, 75370, 68900, 62430, 55970, 49500, 43040, 36570, 283700],
[791000, 794000, 82460, 75920, 69450, 62990, 56520, 50050, 43590, 37120, 285300],
[794000, 797000, 83100, 76470, 70000, 63540, 57070, 50600, 44140, 37670, 286800],
[797000, 800000, 83730, 77020, 70550, 64090, 57630, 51150, 44690, 38230, 288300],
[800000, 803000, 84370, 77580, 71100, 64640, 58180, 51700, 45240, 38780, 290000],
[803000, 806000, 85000, 78130, 71650, 65190, 58730, 52250, 45790, 39330, 291500],
[806000, 809000, 85630, 78680, 72210, 65740, 59280, 52810, 46340, 39880, 293000],
[809000, 812000, 86260, 79230, 72760, 66290, 59830, 53360, 46890, 40430, 294600],
[812000, 815000, 86900, 79780, 73310, 66840, 60380, 53910, 47450, 40980, 296100],
[815000, 818000, 87530, 80330, 73860, 67400, 60930, 54460, 48000, 41530, 297600],
[818000, 821000, 88160, 80880, 74410, 67950, 61480, 55010, 48550, 42090, 299200],
[821000, 824000, 88800, 81430, 74960, 68500, 62040, 55560, 49100, 42640, 300800],
[824000, 827000, 89440, 82000, 75510, 69050, 62590, 56110, 49650, 43190, 302300],
[827000, 830000, 90070, 82630, 76060, 69600, 63140, 56670, 50200, 43740, 303800],
[830000, 833000, 90710, 83260, 76620, 70150, 63690, 57220, 50750, 44290, 305400],
[833000, 836000, 91360, 83930, 77200, 70720, 64260, 57800, 51330, 44860, 306900],
[836000, 839000, 92060, 84630, 77810, 71340, 64870, 58410, 51940, 45480, 308400],
[839000, 842000, 92770, 85340, 78420, 71950, 65490, 59020, 52550, 46090, 310000],
[842000, 845000, 93470, 86040, 79040, 72560, 66100, 59640, 53160, 46700, 311600],
[845000, 848000, 94180, 86740, 79650, 73180, 66710, 60250, 53780, 47310, 313100],
[848000, 851000, 94880, 87450, 80260, 73790, 67320, 60860, 54390, 47930, 314700],
[851000, 854000, 95590, 88150, 80870, 74400, 67940, 61470, 55000, 48540, 316200],
[854000, 857000, 96290, 88860, 81490, 75010, 68550, 62090, 55610, 49150, 317700],
[857000, 860000, 97000, 89560, 82130, 75630, 69160, 62700, 56230, 49760, 319300],
[860000, 970000, 97350, 89920, 82480, 75930, 69470, 63010, 56530, 50070, 320900],
[970000, 1720000, 123190, 115760, 108320, 101770, 95310, 88850, 82370, 75910, 320900],
[1720000, 3550000, 375890, 368460, 361020, 354470, 348010, 341550, 335070, 328610, 672200],
[3550000, null, 1123270, 1115840, 1108400, 1101850, 1095390, 1088930, 1082450, 1075990, 672200]
];
// 基礎税額のテーブルインデックスを取得
const getBasicTaxIndex = (type, numberOfDependents) => {
if (type === 'b') {
return 10;
}
return numberOfDependents <= 7 ? numberOfDependents + 2 : 9;
}
// 基礎税額を取得する
const getBasicTax = (salary, type, numberOfDependents) => {
let idx = getBasicTaxIndex(type, numberOfDependents);
for (let i = 0; i < basicTaxList.length; i++) {
if (basicTaxList[i][0] <= salary && basicTaxList[i][1] > salary) {
return basicTaxList[i][idx];
}
}
return basicTaxList[basicTaxList.length - 1][idx];
};
// 加算税額を取得
const getAddtionalTax = (salary, type) => {
for (let i = 0; i < additionalTax.length; i++) {
if (additionalTax[i].condition(salary, type)) {
return additionalTax[i].method(salary);
}
}
return 0; // nothing.
};
// 控除額を算出
const getDeduction = (numberOfDependents) => {
return (numberOfDependents > 7) ? deductionByDependents(numberOfDependents) : 0;
};
// 所得税額を取得する
exports.getIncomeTax2018 = (req, res) => {
// check parameters.
if (!('type' in req.query) || !('salary' in req.query) || !('numberOfDependents' in req.query) ||
!/[1-9][0-9]*/.test(req.query.salary) || !/0|[1-9][0-9]*/.test(req.query.numberOfDependents) || ['a', 'b'].indexOf(req.query.type) === -1) {
res.status(400).send(`invalid parameters.`);
}
// format
const format = ('format' in req.query && (req.query.format === 'json' || req.query.format === 'xml')) ? req.query.format : 'json';
// 税額を算出
let salary = parseInt(req.query.salary, 10);
let type = req.query.type;
let numberOfDependents = parseInt(req.query.numberOfDependents, 10);
let tax = {
"basic": getBasicTax(salary, type, numberOfDependents),
"additional": getAddtionalTax(salary, type),
"deduction": getDeduction(numberOfDependents),
};
tax['total'] = Math.max(tax.basic + tax.additional - tax.deduction, 0);
// レスポンスを返す
if( format === 'xml' ) {
res.header('Content-type','text/xml');
const xml = '<?xml version="1.0" encoding="UTF-8"?>' +
'<data><tax>' +
'<basic>' + tax['basic'] + '</basic>' +
'<additional>' + tax['additional'] + '</additional>' +
'<deduction>' + tax['deduction'] + '</deduction>' +
'<total>' + tax['total'] + '</total>' +
'</tax></data>';
return res.status(200).send(xml);
}
return res.status(200).send(tax);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment