2019年新个税计算(Go)

Posted By Zyp on 2019-06-14

2019个税改革,为了自己弄清楚自己扣税相关情况,用Go简单实现了自己使用的一个计算器。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main

import (
"fmt"
"strconv"
)

var months = [12]string{"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"}

func main(){
basic := 5000.0 //起征点
fiveOne := *** //五险一金
add := 1500.0 //专项附加扣除
other := 0.0 //其他

all := *** //税前工资

totalTax := 0.0 //记录当年总缴税

i:=1.0
for i<13{
this := i*(all - basic - fiveOne - add - other) //累计预扣预缴应纳税所得额

taxLv := 0.0 //当月预扣率
taxNum := 0.0 //速算扣除数
if this<=36000{
taxLv = 0.03
taxNum = 0.0
}else if this<=144000{
taxLv = 0.1
taxNum = 2520.0
}else if this<=300000{
taxLv = 0.2
taxNum = 16920.0
}else if this<=420000{
taxLv = 0.25
taxNum = 31920.0
}else if this<=660000{
taxLv = 0.3
taxNum = 52920.0
}else if this<=960000{
taxLv = 0.35
taxNum = 85920.0
}else{
taxLv = 0.45
taxNum = 181920.0
}

now := this*taxLv - totalTax - taxNum //本月应预扣预缴税额得额
totalTax += now //累计已预扣预缴税额
fmt.Println(months[int(i-1)]+":"+strconv.FormatFloat(now, 'f', 2, 64))

i = i+1
}

fmt.Println("totalTax:"+strconv.FormatFloat(totalTax, 'f', 2, 64))
}