The year is coming. It's time to give out the year-end bonus. So I went to the Internet to find the personal tax calculator, but I found it was a little like a virus website. So the result of calculation is not very dare to believe, so ponder, or write a personal income tax calculator by yourself.
First, I went to the State Administration of Taxation to understand the formula of the next individual income tax calculation, which is simple, simple and complex. The calculation of individual income tax can be divided into several types:
1. Comprehensive tax rate table
Generally speaking, the salary of our employees is calculated according to this tax rate table.
2. Operating income
This should be the application of individual businesses
3. Labor remuneration
This generally applies to, for example, having a part-time job, outsourcing, etc. if you want to pay taxes, you should use this tax rate table.
This is the latest personal tax rate in 2018. Now it is levied uniformly at 5000 yuan, i.e. the income is less than 5000 yuan, so there is no need to pay tax.
The project is developed with springboot, which is very easy to start.
Code of calculation rule:
1 /** 2 * Calculation of individual income tax 3 * www.xcc.cn Copyright 4 * @param minusAmount Amount deducted from social security 5 * @param minusAmount2 Salary of the month (after deducting social security) (calculated as year-end bonus) 6 * @param salaryType Revenue type 7 * @param minimumAmount Personal tax base, 5000 8 * */ 9 public GeshuiDto calc(double originAmount, double minusAmount, double minusAmount2, String salaryType, int minimumAmount) { 10 GeshuiDto dto = new GeshuiDto(); 11 dto.originAmount = originAmount; 12 dto.minusAmount = minusAmount; 13 dto.taxAmount = 0; 14 dto.finalAmount = 0; 15 16 if(originAmount == 0){ 17 return dto; 18 } 19 20 //Income from wages and salaries 21 if(Objects.equal("1", salaryType)){ 22 double balanceAmount = BigDecimal.valueOf(originAmount) 23 .subtract(BigDecimal.valueOf(minusAmount)) 24 .subtract(BigDecimal.valueOf(minimumAmount)).doubleValue(); 25 dto.balanceAmount = balanceAmount; 26 if(minimumAmount == 5000) { 27 if(balanceAmount >0 && balanceAmount <=3000){ 28 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.03)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 29 } 30 if(balanceAmount >3000 && balanceAmount <=12000){ 31 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.1)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(210)).doubleValue(); 32 } 33 if(balanceAmount >12000 && balanceAmount <=25000){ 34 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.2)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(1410)).doubleValue(); 35 } 36 if(balanceAmount >25000 && balanceAmount <=35000){ 37 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.25)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(2660)).doubleValue(); 38 } 39 if(balanceAmount >35000 && balanceAmount <=55000){ 40 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.3)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(4410)).doubleValue(); 41 } 42 if(balanceAmount >55000 && balanceAmount <=80000){ 43 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.35)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(7160)).doubleValue(); 44 } 45 if(balanceAmount >80000 ){ 46 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.45)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(15160)).doubleValue(); 47 } 48 }else { 49 if(balanceAmount >0 && balanceAmount <=1500){ 50 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.03)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 51 } 52 if(balanceAmount >1500 && balanceAmount <=4500){ 53 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.1)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(105)).doubleValue(); 54 } 55 if(balanceAmount >4500 && balanceAmount <=9000){ 56 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.2)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(555)).doubleValue(); 57 } 58 if(balanceAmount >9000 && balanceAmount <=35000){ 59 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.25)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(1005)).doubleValue(); 60 } 61 if(balanceAmount >35000 && balanceAmount <=55000){ 62 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.3)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(2755)).doubleValue(); 63 } 64 if(balanceAmount >55000 && balanceAmount <=80000){ 65 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.35)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(5505)).doubleValue(); 66 } 67 if(balanceAmount >80000 ){ 68 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.45)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(13505)).doubleValue(); 69 } 70 } 71 72 }else if(Objects.equal("2", salaryType)){ //Income from production and operation of individual businesses 73 double balanceAmount = originAmount; 74 dto.balanceAmount = balanceAmount; 75 if(balanceAmount >0 && balanceAmount <= 15000){ 76 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.05)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 77 } 78 if(balanceAmount > 15000 && balanceAmount <= 30000){ 79 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.1)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(750)).doubleValue(); 80 } 81 if(balanceAmount > 30000 && balanceAmount <= 60000){ 82 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.2)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(3750)).doubleValue(); 83 } 84 if(balanceAmount > 60000 && balanceAmount <= 100000){ 85 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.3)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(9750)).doubleValue(); 86 } 87 if(balanceAmount > 100000){ 88 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.35)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(14750)).doubleValue(); 89 } 90 }else if(Objects.equal("3", salaryType)){ //Year end bonus income 91 double balanceAmount = 0; 92 if(minusAmount2 - minimumAmount < 0){ 93 balanceAmount = BigDecimal.valueOf(originAmount).subtract(BigDecimal.valueOf(3500-minusAmount2)).doubleValue(); 94 }else{ 95 balanceAmount = originAmount; 96 } 97 dto.balanceAmount = balanceAmount; 98 double avg_balanceAmount = balanceAmount/12; 99 if(minimumAmount == 5000) { 100 if(avg_balanceAmount >0 && avg_balanceAmount<=3000){ 101 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.03)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 102 } 103 if(avg_balanceAmount >3000 && avg_balanceAmount<=12000){ 104 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.1)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(210)).doubleValue(); 105 } 106 if(avg_balanceAmount >12000 && avg_balanceAmount<=25000){ 107 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.2)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(1410)).doubleValue(); 108 } 109 if(avg_balanceAmount >25000 && avg_balanceAmount<=35000){ 110 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.25)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(2660)).doubleValue(); 111 } 112 if(avg_balanceAmount >35000 && avg_balanceAmount<=55000){ 113 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.3)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(4410)).doubleValue(); 114 } 115 if(avg_balanceAmount >55000 && avg_balanceAmount<=80000){ 116 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.35)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(7160)).doubleValue(); 117 } 118 if(avg_balanceAmount >80000){ 119 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.45)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(15160)).doubleValue(); 120 } 121 }else { 122 if(avg_balanceAmount >0 && avg_balanceAmount<=1500){ 123 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.03)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 124 } 125 if(avg_balanceAmount >1500 && avg_balanceAmount<=4500){ 126 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.1)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(105)).doubleValue(); 127 } 128 if(avg_balanceAmount >4500 && avg_balanceAmount<=9000){ 129 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.2)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(555)).doubleValue(); 130 } 131 if(avg_balanceAmount >9000 && avg_balanceAmount<=35000){ 132 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.25)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(1005)).doubleValue(); 133 } 134 if(avg_balanceAmount >35000 && avg_balanceAmount<=55000){ 135 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.3)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(2775)).doubleValue(); 136 } 137 if(avg_balanceAmount >55000 && avg_balanceAmount<=80000){ 138 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.35)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(5505)).doubleValue(); 139 } 140 if(avg_balanceAmount >80000){ 141 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.45)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(13505)).doubleValue(); 142 } 143 } 144 145 }else if(Objects.equal("4", salaryType)){ //Income from labor remuneration 146 dto.balanceAmount = originAmount; 147 if(originAmount>0 && originAmount <= 800){ 148 dto.taxAmount =0; 149 }else if(originAmount > 800){ 150 double balanceAmount = 0; 151 if(originAmount >800 && originAmount <= 4000){ 152 balanceAmount = originAmount-800; 153 } 154 if(originAmount > 4000){ 155 balanceAmount = originAmount*0.8; 156 } 157 if(balanceAmount >0 && balanceAmount <= 20000){ 158 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 159 } 160 if(balanceAmount >20000 && balanceAmount <= 50000){ 161 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.3)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(2000)).doubleValue(); 162 } 163 if(balanceAmount >50000){ 164 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.4)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(BigDecimal.valueOf(7000)).doubleValue(); 165 } 166 } 167 }else if(Objects.equal("5", salaryType)){ //Income from remuneration 168 double balanceAmount = 0; 169 if(originAmount >0 && originAmount <= 4000){ 170 balanceAmount = originAmount-800; 171 }else if(originAmount > 4000){ 172 balanceAmount = originAmount*0.8; 173 } 174 dto.balanceAmount = balanceAmount; 175 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.14)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 176 }else if(Objects.equal("6", salaryType)){ //income from franchise royalties 177 double balanceAmount = 0; 178 if(originAmount >0 && originAmount <= 4000){ 179 balanceAmount = originAmount-800; 180 }else if(originAmount > 4000){ 181 balanceAmount = originAmount*0.8; 182 } 183 dto.balanceAmount = balanceAmount; 184 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 185 }else if(Objects.equal("7", salaryType)){ //Income from property lease 186 double balanceAmount = 0; 187 if(originAmount >0 && originAmount <= 4000){ 188 balanceAmount = originAmount-800; 189 }else if(originAmount > 4000){ 190 balanceAmount = originAmount*0.8; 191 } 192 dto.balanceAmount = balanceAmount; 193 dto.taxAmount = BigDecimal.valueOf(balanceAmount).multiply(BigDecimal.valueOf(0.2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 194 }else if(Objects.equal("8", salaryType)){ //Income from transfer of property 195 dto.balanceAmount = originAmount; 196 dto.taxAmount = BigDecimal.valueOf(originAmount).multiply(BigDecimal.valueOf(0.2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 197 }else if(Objects.equal("9", salaryType)){ //Income from interest, dividend and bonus 198 dto.balanceAmount = originAmount; 199 dto.taxAmount = BigDecimal.valueOf(originAmount).multiply(BigDecimal.valueOf(0.2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 200 }else if(Objects.equal("10", salaryType)){ //Incidental income 201 dto.balanceAmount = originAmount; 202 dto.taxAmount = BigDecimal.valueOf(originAmount).multiply(BigDecimal.valueOf(0.2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 203 }else{ 204 return dto; 205 } 206 if(Objects.equal("1", salaryType)){ 207 dto.finalAmount = BigDecimal.valueOf(originAmount) 208 .subtract(BigDecimal.valueOf(minusAmount)) 209 .subtract(BigDecimal.valueOf(dto.taxAmount)) 210 .setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 211 }else{ 212 dto.finalAmount = BigDecimal.valueOf(originAmount) 213 .subtract(BigDecimal.valueOf(dto.taxAmount)) 214 .setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 215 } 216 return dto; 217 }
Now that the development is completed, I want to get a domain name and hang a server for everyone to use. I happen to have an empty domain name xcc.cn on hand, so I set up the deployment and go online. On the deployment, jenkins+portainer is used to print the project as a docker image, and then push it to the portainer deployment to start.
In the current formula of the personal tax calculator, there may be some inconsistencies. You can point them out.
Welcome to watch: Personal tax calculator Come on, everyone. Don't be crippled.