38 lines
613 B
Go
38 lines
613 B
Go
package utils
|
|
|
|
// 一些计算
|
|
|
|
// ComputeIndividualIncomeTax 计算个人所得税
|
|
func ComputeIndividualIncomeTax(income float64) float64 {
|
|
if income <= 800 {
|
|
return 0
|
|
}
|
|
|
|
if income <= 4000 {
|
|
income = income - 800
|
|
}
|
|
|
|
// 实际纳税金额
|
|
if income > 4000 {
|
|
income = income * 0.8
|
|
}
|
|
|
|
// 税率、速算扣除数
|
|
var taxRate, quickDeduction float64
|
|
|
|
if income <= 20000 {
|
|
taxRate = 0.2
|
|
quickDeduction = 0
|
|
} else if income <= 50000 {
|
|
taxRate = 0.3
|
|
quickDeduction = 2000
|
|
} else {
|
|
taxRate = 0.4
|
|
quickDeduction = 7000
|
|
}
|
|
|
|
incomeTax := income*taxRate - quickDeduction
|
|
|
|
return incomeTax
|
|
}
|