|
|
|
package com.gszc.service;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
@Service
|
|
|
|
public class CountService {
|
|
|
|
|
|
|
|
public JSONObject VATCount(String companyType,String invoiceType,String specialInvoiceType,double money) throws Exception{
|
|
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
if(companyType.equals("1")){//有限公司
|
|
|
|
result = VATCountDetail(invoiceType, money, specialInvoiceType);
|
|
|
|
|
|
|
|
}else if(companyType.equals("2")){//个独、合伙企业
|
|
|
|
result = VATCountDetail(invoiceType, money, specialInvoiceType);
|
|
|
|
} else {
|
|
|
|
throw new Exception("公司类型不正确");
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
private JSONObject VATCountDetail(String invoiceType,double money,String specialInvoiceType) throws Exception{
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
double result = 0;
|
|
|
|
if(invoiceType.equals("1")){//普票类型
|
|
|
|
result = money/1.03*0.03;
|
|
|
|
jsonObject.put("rate",3);
|
|
|
|
}else if(invoiceType.equals("2")){//专票类型
|
|
|
|
if(specialInvoiceType.equals("1")){
|
|
|
|
result = money/1.06*0.06;
|
|
|
|
jsonObject.put("rate",6);
|
|
|
|
}else if(specialInvoiceType.equals("2")){
|
|
|
|
result = money/1.13*0.13;
|
|
|
|
jsonObject.put("rate",13);
|
|
|
|
}else {
|
|
|
|
throw new Exception("专票类型不正确");
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
throw new Exception("发票类型不正确");
|
|
|
|
}
|
|
|
|
BigDecimal b = new BigDecimal(result);
|
|
|
|
BigDecimal keep = b.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
jsonObject.put("money",keep);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|