1. 程式人生 > >個人所得稅計算java版

個人所得稅計算java版

watermark handler ret 鏡像 ply 員工 else int bae

年關將至,該到了發年終獎的時候了。所以就到網上去找下,個稅計算器,但是發現做的有點像病毒網站似的。所以計算結果也不太敢信,於是琢磨著,要不自己動手寫一個個稅計算器吧。

說幹就幹,先上國家稅務局了解了下個稅計算的公式,說簡單也簡單說復雜也復雜,個稅計算,分幾個種類:

1、綜合稅率表

技術分享圖片技術分享圖片?

一般來說,我們員工的工資就按這個稅率表來計算。

2、經營所得

技術分享圖片技術分享圖片?

這個應該是個體工商戶類的適用

3、勞務報酬

技術分享圖片技術分享圖片?

這個一般適用於,比如有個兼職,外包等,如果要納稅,就按這個稅率表。

這個是2018年最新的個稅稅率,現在統一按5000元起征,也就是收入在5000元以下,是不用納稅的。

項目采用springboot開發,非常容易上手。

計算規則的代碼:

  1    /**
  2      * 計算個人所得稅
  3      * www.xcc.cn 版權所有
  4      * @param minusAmount 扣除社保的金額
  5      * @param minusAmount2 當月工資(扣除社保後)(算年終獎)
  6      * @param salaryType 收入類型
  7      * @param minimumAmount 個稅基數,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 //工資、薪金所得 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)){ //個體工商戶生產、經營所得 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)){ //年終獎所得 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)){ //勞務報酬所得 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)){ //稿酬所得 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)){ //特許權使用費所得 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)){ //財產租賃所得 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)){ //財產轉讓所得 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)){ //利息、股息、紅利所得 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)){ //偶然所得 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 }
技術分享圖片

既然開發完了,就想著,弄個域名,掛個服務器給大家用一用,正好手頭也有一個空著的域名xcc.cn,就搭建部署上線了。部署上,使用了jenkins+portainer,將項目打成了docker鏡像,然後推到portainer部署啟動。

個稅計算器目前的公式上,可能有考慮不周的地方,大家可以指出來。

歡迎大家圍觀:個稅計算器 ,各位下手輕點,別弄殘了。

個人所得稅計算java版