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 "1": //有限公司 case "2": //个人独资企业 case "3": //合伙人企业 result = VATCountDetail(invoiceType,taxType, money); break; case "4": //个体工商户,纳税性质只有小规模纳税人 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 BigDecimal PITCount(String type,String produceType,double money) throws Exception{ 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); return b.setScale(2, BigDecimal.ROUND_HALF_UP); } }