You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
227 lines
7.9 KiB
Java
227 lines
7.9 KiB
Java
package com.gszc.service;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.text.DecimalFormat;
|
|
|
|
@Service
|
|
public class CountService {
|
|
|
|
public JSONObject VATCount(String companyType,String invoiceType,String taxType,double money) throws Exception{
|
|
|
|
JSONObject result = new JSONObject();
|
|
switch (companyType){
|
|
case "limit": //有限公司
|
|
case "proprietorship": //个人独资企业
|
|
case "partner": //合伙人企业
|
|
result = VATCountDetail(invoiceType,taxType, money);
|
|
break;
|
|
case "individual": //个体工商户,纳税性质只有小规模纳税人
|
|
result = VATCountDetail(invoiceType,"1", money);
|
|
break;
|
|
default:
|
|
throw new Exception("公司类型不正确");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private JSONObject VATCountDetail(String invoiceType,String taxType,double money) throws Exception{
|
|
if(money <= 0){
|
|
throw new Exception("金额须大于0");
|
|
}
|
|
JSONObject jsonObject = new JSONObject();
|
|
double result = 0;
|
|
double rate = 0;
|
|
switch (taxType){
|
|
case "1":
|
|
rate = 0.033;
|
|
break;
|
|
case "2":
|
|
rate = 0.066;
|
|
break;
|
|
case "3":
|
|
rate = 0.143;
|
|
break;
|
|
default:
|
|
throw new Exception("纳税性质不正确");
|
|
}
|
|
|
|
if(invoiceType.equals("1")){//普票类型
|
|
if(money <= 300000){
|
|
rate = 0;
|
|
}
|
|
result = money * rate;
|
|
}else if(invoiceType.equals("2")){//专票类型
|
|
result = money * rate;
|
|
}else {
|
|
throw new Exception("开票类型不正确");
|
|
}
|
|
|
|
BigDecimal b = new BigDecimal(result);
|
|
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;
|
|
}
|
|
|
|
public JSONObject PITCount(double money) throws Exception{
|
|
if(money <= 0){
|
|
throw new Exception("金额须大于0");
|
|
}
|
|
JSONObject jsonObject = new JSONObject();
|
|
double result =0;
|
|
double rate = 0;
|
|
if(money<=300000){
|
|
rate = 0.005;
|
|
}else if(300000<money&&money<=310000){
|
|
rate = 0.0052;
|
|
}else if(310000<money&&money<=400000){
|
|
rate = 0.0063;
|
|
}else if(400000<money&&money<=500000){
|
|
rate = 0.007;
|
|
}else if(500000<money&&money<=600000){
|
|
rate = 0.0075;
|
|
}else if(600000<money&&money<=700000){
|
|
rate = 0.0079;
|
|
}else if(700000<money&&money<=800000){
|
|
rate = 0.0081;
|
|
}else if(800000<money&&money<=900000){
|
|
rate = 0.0083;
|
|
}else if(900000<money&&money<=910000){
|
|
rate = 0.0085;
|
|
}else if(910000<money&&money<=1000000){
|
|
rate = 0.0095;
|
|
}else if(1000000<money&&money<=1210000){
|
|
rate = 0.0113;
|
|
}else if(1210000<money&&money<=1500000){
|
|
rate = 0.013;
|
|
}else if(1500000<money&&money<=2000000){
|
|
rate = 0.0148;
|
|
}else if(2000000<money&&money<=2500000){
|
|
rate = 0.0158;
|
|
}else if(2500000<money&&money<=3000000){
|
|
rate = 0.0168;
|
|
}else if(3000000<money&&money<=3100000){
|
|
rate = 0.0169;
|
|
}else if(3100000<money&&money<=3500000){
|
|
rate = 0.0184;
|
|
}else if(3500000<money&&money<=4000000){
|
|
rate = 0.0199;
|
|
}else if(4000000<money&&money<=4100000){
|
|
rate = 0.0201;
|
|
}else if(4100000<money&&money<=4500000){
|
|
rate = 0.021;
|
|
}else if(4500000<money&&money<=5000000){
|
|
rate = 0.0219;
|
|
}else{
|
|
throw new Exception("不支持的金额");
|
|
}
|
|
result = money * rate;
|
|
// double result = 0;
|
|
// if(type.equals("1")){
|
|
// double amount=money-5000;
|
|
// double a = 36000 * 0.03-2520,
|
|
// b = (144000 - 36000) * 0.10-16920,
|
|
// c = (300000 - 144000) * 0.20-31920,
|
|
// d = (420000 - 300000) * 0.25-52920,
|
|
// e = (660000 - 420000) * 0.30-85920,
|
|
// f = (960000 - 660000) * 0.35-181920;
|
|
// if(amount<=36000){
|
|
// result = result + amount * 0.03;
|
|
// }
|
|
// if(amount>36000&&amount<=144000){
|
|
// result = result+(amount-36000)*0.10+a;
|
|
// }
|
|
// if(amount>144000&&amount<=300000){
|
|
// result = result+(amount-144000)*0.20+a+b;
|
|
// }
|
|
// if(amount>300000&&amount<=420000){
|
|
// result = result+(amount-300000)*0.25+a+b+c;
|
|
// }
|
|
// if(amount>420000&&amount<=660000){
|
|
// result = result+(amount-420000)*0.30+a+b+c+d;
|
|
// }
|
|
// if(amount>660000&&amount<=960000){
|
|
// result = result+(amount-660000)*0.35+a+b+c+d+e;
|
|
// }
|
|
// if(amount>960000){
|
|
// result = result+(amount-960000)*0.45+a+b+c+d+e+f;
|
|
// }
|
|
//
|
|
// }else if(type.equals("2")){
|
|
// double a = 30000/1.03*0.05,
|
|
// b=(90000-30000)/1.03*0.10,
|
|
// c=(300000-90000)/1.03*0.20,
|
|
// d=(500000-300000)/1.03*0.30;
|
|
// if(produceType.equals("1")){//核定征收
|
|
//
|
|
// if(money<=30000){
|
|
// result = result + money/1.03*0.05;
|
|
// }
|
|
// if(money>30000&&money<=90000){
|
|
// result = result + money/1.03*0.10+a;
|
|
// }
|
|
// if(money>90000&&money<=300000){
|
|
// result = result + money/1.03*0.20+a+b;
|
|
// }
|
|
// if(money>300000&&money<=500000){
|
|
// result = result + money/1.03*0.30+a+b+c;
|
|
// }
|
|
// if(money>500000){
|
|
// result = result + money/1.03*0.35+a+b+c+d;
|
|
// }
|
|
//
|
|
// }else if(produceType.equals("2")){//累进税率
|
|
// if(money<=30000){
|
|
// result = result + money/1.03*0.05;
|
|
// }
|
|
// if(money>30000&&money<=90000){
|
|
// result = result + (money-30000)/1.03*0.10+(a-1500);
|
|
// }
|
|
// if(money>90000&&money<=300000){
|
|
// result = result + (money-90000)/1.03*0.20+a-1500+b-10500;
|
|
// }
|
|
// if(money>300000&&money<=500000){
|
|
// result = result + (money-300000)/1.03*0.30+a-1500+b-10500+c-40500;
|
|
// }
|
|
// if(money>500000){
|
|
// result = result + (money-500000)/1.03*0.35+a+b+c+d-1500-10500-40500-65500;
|
|
// }
|
|
// }else{
|
|
// throw new Exception("方式类型不正确");
|
|
// }
|
|
//
|
|
// }else {
|
|
// throw new Exception("专票类型不正确");
|
|
// }
|
|
BigDecimal b = new BigDecimal(result);
|
|
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;
|
|
}
|
|
|
|
public JSONObject VATSurchargeCount(String money){
|
|
double m = Double.parseDouble(money);
|
|
|
|
double result = (m / (1 + 0.033) * 0.033) * 1.1;
|
|
|
|
BigDecimal b = new BigDecimal(result);
|
|
BigDecimal keep = b.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
jsonObject.put("result",keep);
|
|
return jsonObject;
|
|
}
|
|
}
|