个税计算添加税率返回

master
cca 6 years ago
parent 1567d5e0de
commit dd7f2d31b5

@ -79,7 +79,8 @@ public class CountController {
} }
} catch (Exception e) { } catch (Exception e) {
return ResultBuilder.error("参数错误",e).build(); String msg = "".equals(e.getMessage()) ? "参数错误" : e.getMessage();
return ResultBuilder.error(msg,e).build();
} }
return ResultBuilder.withPayload(jsonObject).build(); return ResultBuilder.withPayload(jsonObject).build();
} }
@ -97,13 +98,14 @@ public class CountController {
@ApiImplicitParam(name = "money", value = "开票金额", dataType = "string", paramType = "query"), @ApiImplicitParam(name = "money", value = "开票金额", dataType = "string", paramType = "query"),
}) })
public Result PITCount(double money) { public Result PITCount(double money) {
BigDecimal bigDecimal = null; JSONObject jsonObject = new JSONObject();
try { try {
bigDecimal = countService.PITCount(money); jsonObject = countService.PITCount(money);
} catch (Exception e) { } catch (Exception e) {
return ResultBuilder.error("参数错误",e).build(); String msg = "".equals(e.getMessage()) ? "参数错误" : e.getMessage();
return ResultBuilder.error(msg,e).build();
} }
return ResultBuilder.withPayload(bigDecimal).build(); return ResultBuilder.withPayload(jsonObject).build();
} }
} }

@ -70,56 +70,59 @@ public class CountService {
return jsonObject; return jsonObject;
} }
public BigDecimal PITCount(double money) throws Exception{ public JSONObject PITCount(double money) throws Exception{
if(money <= 0){ if(money <= 0){
throw new Exception("金额须大于0"); throw new Exception("金额须大于0");
} }
JSONObject jsonObject = new JSONObject();
double result =0; double result =0;
double rate = 0;
if(money<=300000){ if(money<=300000){
result = money*0.005; rate = 0.005;
}else if(300000<money&&money<=310000){ }else if(300000<money&&money<=310000){
result = money*0.0052; rate = 0.0052;
}else if(310000<money&&money<=400000){ }else if(310000<money&&money<=400000){
result = money*0.0063; rate = 0.0063;
}else if(400000<money&&money<=500000){ }else if(400000<money&&money<=500000){
result = money*0.007; rate = 0.007;
}else if(500000<money&&money<=600000){ }else if(500000<money&&money<=600000){
result = money*0.0075; rate = 0.0075;
}else if(600000<money&&money<=700000){ }else if(600000<money&&money<=700000){
result = money*0.0079; rate = 0.0079;
}else if(700000<money&&money<=800000){ }else if(700000<money&&money<=800000){
result = money*0.0081; rate = 0.0081;
}else if(800000<money&&money<=900000){ }else if(800000<money&&money<=900000){
result = money*0.0083; rate = 0.0083;
}else if(900000<money&&money<=910000){ }else if(900000<money&&money<=910000){
result = money*0.0085; rate = 0.0085;
}else if(910000<money&&money<=1000000){ }else if(910000<money&&money<=1000000){
result = money*0.0095; rate = 0.0095;
}else if(1000000<money&&money<=1200000){ }else if(1000000<money&&money<=1210000){
result = money*0.0113; rate = 0.0113;
}else if(1200000<money&&money<=1210000){
result = money*0.0113;
}else if(1210000<money&&money<=1500000){ }else if(1210000<money&&money<=1500000){
result = money*0.013; rate = 0.013;
}else if(1500000<money&&money<=2000000){ }else if(1500000<money&&money<=2000000){
result = money*0.0148; rate = 0.0148;
}else if(2000000<money&&money<=2500000){ }else if(2000000<money&&money<=2500000){
result = money*0.0158; rate = 0.0158;
}else if(2500000<money&&money<=3000000){ }else if(2500000<money&&money<=3000000){
result = money*0.0168; rate = 0.0168;
}else if(3000000<money&&money<=3100000){ }else if(3000000<money&&money<=3100000){
result = money*0.0169; rate = 0.0169;
}else if(3100000<money&&money<=3500000){ }else if(3100000<money&&money<=3500000){
result = money*0.0184; rate = 0.0184;
}else if(3500000<money&&money<=4000000){ }else if(3500000<money&&money<=4000000){
result = money*0.0199; rate = 0.0199;
}else if(4000000<money&&money<=4100000){ }else if(4000000<money&&money<=4100000){
result = money*0.0201; rate = 0.0201;
}else if(4100000<money&&money<=4500000){ }else if(4100000<money&&money<=4500000){
result = money*0.021; rate = 0.021;
}else if(4500000<money&&money<=5000000){ }else if(4500000<money&&money<=5000000){
result = money*0.0219; rate = 0.0219;
}else{
throw new Exception("不支持的金额");
} }
result = money * rate;
// double result = 0; // double result = 0;
// if(type.equals("1")){ // if(type.equals("1")){
// double amount=money-5000; // double amount=money-5000;
@ -198,7 +201,14 @@ public class CountService {
// throw new Exception("专票类型不正确"); // throw new Exception("专票类型不正确");
// } // }
BigDecimal b = new BigDecimal(result); BigDecimal b = new BigDecimal(result);
return b.setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal r = new BigDecimal(rate * 100);
BigDecimal keep = b.setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal ratePercent = r.setScale(2, BigDecimal.ROUND_HALF_UP);
jsonObject.put("money",keep);
jsonObject.put("rate",ratePercent);
return jsonObject;
} }
} }

@ -51,6 +51,7 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> impl
public void addInvoice(Invoice invoice){ public void addInvoice(Invoice invoice){
String id = Uuid8Utils.generateShortUUID(); String id = Uuid8Utils.generateShortUUID();
invoice.setId(id); invoice.setId(id);
invoice.setStatusCode("disable");
invoice.setCreateDate(new Date()); invoice.setCreateDate(new Date());
invoice.setModifyDate(new Date()); invoice.setModifyDate(new Date());
invoiceMapper.insert(invoice); invoiceMapper.insert(invoice);

Loading…
Cancel
Save