Commit 873b80fc by ilal Committed by chenzg

提交

parent fc4b1b5e
......@@ -48,6 +48,7 @@ import cn.timer.api.bean.xcgl.XcglAssoGztzt;
import cn.timer.api.bean.xcgl.XcglAssoJsgzzx;
import cn.timer.api.bean.xcgl.XcglAssoJxgz;
import cn.timer.api.bean.xcgl.XcglAssoOption;
import cn.timer.api.bean.xcgl.XcglAssoTaxFormula;
import cn.timer.api.bean.xcgl.XcglAssoXcjsgz;
import cn.timer.api.bean.xcgl.XcglAssoXzb;
import cn.timer.api.bean.xcgl.XcglAssoXzdadx;
......@@ -1628,18 +1629,14 @@ public class SalaryManagementController {
double actual_attendance_days = 0;//实出勤天数
double matter_leave = 0;//事假
double sick_leave;//病假
double personal_income_tax = 0;//个税
double other_deductions = 0;//其他扣除
double wages_payable = 0;//应发工资
String[] noperincuser = new String[paygrlist.size()];//用来储存没有个税的用户id
int i = 0;
//薪资组内成员
for(XcglAssoXzury pag : paygrlist) {
XcglAssoGsjsmx gsjs = XcglAssoGsjsmx.builder().build().selectOne(new QueryWrapper<XcglAssoGsjsmx>().lambda().eq(XcglAssoGsjsmx::getQyid, userBean.getOrgCode()).eq(XcglAssoGsjsmx::getUserNum, pag.getUserid())
.eq(XcglAssoGsjsmx::getSalaryMonth, salary_month));
if(gsjs == null) {
noperincuser[i] = String.valueOf(pag.getUserid());
i++;
}
//存在的计薪规则组项数据对应
for(XcglAssoJsgzzx xzx : sjbt) {
if(xzx.getRulestate() == 1 && xzx.getIsCustom() == 0 && xzx.getOptionid() == 0 && xzx.getSalaryitem().equals("基本工资")) {
......@@ -1650,54 +1647,56 @@ public class SalaryManagementController {
XcglAssoXzb xzb = XcglAssoXzb.builder().build().selectOne(new QueryWrapper<XcglAssoXzb>().lambda().eq(XcglAssoXzb::getXzxid, xzx.getId()));
post_allowance = xzb.getXzxjg();
}
if(xzx.getIsCustom() == 0 && xzx.getOptionid() == 10) {
if(xzx.getIsCustom() == 0 && xzx.getOptionid() == 10) {//应出勤天数
XcglAssoXzb xzb = XcglAssoXzb.builder().build().selectOne(new QueryWrapper<XcglAssoXzb>().lambda().eq(XcglAssoXzb::getXzxid, xzx.getId()));
attendance_days = xzb.getXzxjg();
}
if(xzx.getIsCustom() == 0 && xzx.getOptionid() == 11) {
if(xzx.getIsCustom() == 0 && xzx.getOptionid() == 11) {//实出勤天数
XcglAssoXzb xzb = XcglAssoXzb.builder().build().selectOne(new QueryWrapper<XcglAssoXzb>().lambda().eq(XcglAssoXzb::getXzxid, xzx.getId()));
actual_attendance_days = xzb.getXzxjg();
}
if(xzx.getIsCustom() == 0 && xzx.getOptionid() == 32) {
if(xzx.getIsCustom() == 0 && xzx.getOptionid() == 32) {//事假
XcglAssoXzb xzb = XcglAssoXzb.builder().build().selectOne(new QueryWrapper<XcglAssoXzb>().lambda().eq(XcglAssoXzb::getXzxid, xzx.getId()));
matter_leave = xzb.getXzxjg();
}
if(xzx.getIsCustom() == 0 && xzx.getOptionid() == 34) {
if(xzx.getIsCustom() == 0 && xzx.getOptionid() == 34) {//病假
XcglAssoXzb xzb = XcglAssoXzb.builder().build().selectOne(new QueryWrapper<XcglAssoXzb>().lambda().eq(XcglAssoXzb::getXzxid, xzx.getId()));
sick_leave = xzb.getXzxjg();
}
if(xzx.getIsCustom() == 0 && xzx.getOptionid() == 72) {//其他扣除
XcglAssoXzb xzb = XcglAssoXzb.builder().build().selectOne(new QueryWrapper<XcglAssoXzb>().lambda().eq(XcglAssoXzb::getXzxid, xzx.getId()));
other_deductions = xzb.getXzxjg();
}
}
}
//#计算个税 (薪资组id、薪资月份)
//循环计算当前薪资月没有个税的用户 根据
for(String gsus : ClockInTool.deleteArrayNull(noperincuser)) {
//个税计算
try {
personal_income_tax = CalculationOfIndividualIncomeTax(String.valueOf(pag.getUserid()), salary_month, orgcode, wages_payable, other_deductions);
} catch (ParseException e) {
e.printStackTrace();
System.out.println("个税计算错误");
}
}
return ResultUtil.data(null, "计算完成");
}
/**
* 计算个税
* 个税计算明细
* @param gsus 用户id
* @param salary_month 计算薪资月
* @param orgcode 企业id
* @param wages_payable 应发工资
* @param other_deductions 其他扣除
* @return
* @throws ParseException
*/
public double CalculationOfIndividualIncomeTax(String gsus,String salary_month,int orgcode,double wages_payable) {
public double CalculationOfIndividualIncomeTax(String gsus,String salary_month,int orgcode,double wages_payable,double other_deductions) throws ParseException {
double personalincome = 0;
String strY = new SimpleDateFormat("yyyy").format(new Date());
//当月个税存在则直接获取 无则根据计算薪资月的上月个税为基准计算
......@@ -1705,25 +1704,19 @@ public class SalaryManagementController {
.eq(XcglAssoGsjsmx::getSalaryMonth, salary_month));
if(dyxzgs != null) {
personalincome = dyxzgs.getThmonthPersonal();
}else {
//#(上月)# 对应薪资月的-1 个税对标数据 (九月工资:对应8月的个税来计算九月的个税)
XcglAssoGsjsmx sygs = XcglAssoGsjsmx.builder().build().selectOne(new QueryWrapper<XcglAssoGsjsmx>().lambda().eq(XcglAssoGsjsmx::getUserNum, gsus).eq(XcglAssoGsjsmx::getQyid, orgcode)
.eq(XcglAssoGsjsmx::getSalaryMonth, SalaryTool.getfirstlastMo(salary_month+"-01 00:00:00")));
YgglMainEmp yh = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getEmpNum, gsus).eq(YgglMainEmp::getOrgCode, orgcode));
//对应算薪月份的专项附加扣除
XcglAssoZxfjkc zxf = XcglAssoZxfjkc.builder().build().selectOne(new QueryWrapper<XcglAssoZxfjkc>().lambda().eq(XcglAssoZxfjkc::getUserid, gsus)
.eq(XcglAssoZxfjkc::getQyid, orgcode).eq(XcglAssoZxfjkc::getTaxmonth, salary_month));
//写入个税明细表*****************
XcglAssoGsjsmx gsmx = XcglAssoGsjsmx.builder().build();
gsmx.setUserNum(gsus);//用户id
gsmx.setUserName(yh.getName());//用户姓名
gsmx.setSalaryMonth(salary_month);//薪资月
//报税周期:(1:当月报税;2:次月报税)
XcglAssoBszqsz bssz = XcglAssoBszqsz.builder().build().selectOne(new QueryWrapper<XcglAssoBszqsz>().lambda().eq(XcglAssoBszqsz::getQyid, orgcode));
String taxmonth = "";
......@@ -1732,61 +1725,105 @@ public class SalaryManagementController {
}else{
taxmonth = SalaryTool.getfirstnextMo(salary_month+"-01 00:00:00");
}
gsmx.setTaxMonth(taxmonth);//税款所属月份
gsmx.setCumZljy(zxf == null ? 0 : zxf.getChildrenedu());//累计子女教育
gsmx.setCumZfdklx(zxf == null ? 0 : zxf.getHouseloans());//累计住房贷款利息
gsmx.setCumZfzj(zxf == null ? 0 : zxf.getHouserents());//累计住房租金
gsmx.setCumSylr(zxf == null ? 0 : zxf.getSupportolder());//累计赡养老人
gsmx.setCumJxjy(zxf == null ? 0 : zxf.getContinueedu());//累计继续教育
gsmx.setCumZxfjkc(zxf == null ? 0 : zxf.getTotalmoney());//累计专项附加扣除
gsmx.setTaxType("工资薪金所得");//计税类型
gsmx.setCurrentIncome(wages_payable);//本期收入 【应发工资】
SbgjjAssoYjzd cuspde = sbgjjassoyjzdmapper.IndividualTotalsbgjj(gsus, orgcode, salary_month);
gsmx.setCurrentSpecialDeduction(cuspde == null ? 0 : Double.valueOf(cuspde.getGrjltotal()));//本期专项扣除 【个人的社保公积金缴纳扣除】
gsmx.setCumSre(wages_payable+(sygs == null ? 0 : sygs.getCumSre()));//累计收入额 【本期收入+累计收入额(上月)】
double cumjcfy = 0;
int xcy = 0;
YgglMainEmp xzrz = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getEmpNum, gsus).eq(YgglMainEmp::getOrgCode, orgcode));
if(xzrz != null) {
String entry_date = ClockInTool.SunNovCSTYMD(xzrz.getRzTime());//yyyyMMdd
if(bssz.getTaxReturnCycle().equals(1)) {//当月报税
if(entry_date.substring(0,4).equals(strY)) {//判断是否是本年
xcy = SalaryTool.getMonthDiff(entry_date, salary_month+"-01");
}else {
xcy = SalaryTool.getMonthDiff(strY+"-01-01", salary_month+"-01");
}
cumjcfy = xcy*5000;
}else {//次月报税
if(entry_date.substring(0,4).equals(strY)) {//判断是否是本年
xcy = SalaryTool.getMonthDiff(entry_date, salary_month+"-01")+1;
}else {
xcy = SalaryTool.getMonthDiff(strY+"-01-01", salary_month+"-01")+1;
}
cumjcfy = xcy*5000;
}
}
gsmx.setCumJcfy(cumjcfy);//累计减除费用 【5000*在职月份数】
gsmx.setCumZxkc((cuspde == null ? 0 : Double.valueOf(cuspde.getGrjltotal())) + (sygs == null ? 0 : sygs.getCumZxkc()));//累计专项扣除 【本期专项扣除+累计专项扣除(上月)】
gsmx.setCumQtkc(other_deductions+(sygs == null ? 0 : sygs.getCumQtkc()));//累计其他扣除 【其他扣除+累计其他扣除(上月)】
gsmx.setTaxMonth(taxmonth);//税款所属月份
// gsmx.setThmonthPersonal(thmonthPersonal);//本月个税
// gsmx.setCumZljy(zxf == null ? 0 : zxf.getChildrenedu());//累计子女教育
// gsmx.setCumZfdklx(zxf == null ? 0 : zxf.getHouseloans());//累计住房贷款利息
// gsmx.setCumZfzj(zxf == null ? 0 : zxf.getHouserents());//累计住房租金
// gsmx.setCumSylr(zxf == null ? 0 : zxf.getSupportolder());//累计赡养老人
// gsmx.setCumJxjy(zxf == null ? 0 : zxf.getContinueedu());//累计继续教育
// gsmx.setCumZxfjkc(zxf == null ? 0 : zxf.getTotalmoney());//累计专项附加扣除
// gsmx.setTaxType("工资薪金所得");//计税类型
// gsmx.setCurrentIncome(wages_payable);//本期收入 【应发工资】
// gsmx.setCurrentSpecialDeduction(currentSpecialDeduction);//本期专项扣除 【个人的社保公积金缴纳扣除】
// gsmx.setCumSre(cumSre);//累计收入额 【本期收入+累计收入额(上月)】
//
// double cumjcfy = 0;
// int xcy = 0;
// YgglMainEmp xzrz = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getEmpNum, gsus).eq(YgglMainEmp::getOrgCode, orgcode));
// if(xzrz != null) {
// String entry_date = ClockInTool.SunNovCSTYMD(xzrz.getRzTime());//yyyyMMdd
// if(bssz.getTaxReturnCycle().equals(1)) {//当月报税
// if(entry_date.substring(0,4).equals(strY)) {//判断是否是本年
// xcy = SalaryTool.getMonthDiff(entry_date, salary_month+"-01");
// }else {
// xcy = SalaryTool.getMonthDiff(strY+"-01-01", salary_month+"-01");
// }
// cumjcfy = xcy*5000;
// }else {//次月报税
// if(entry_date.substring(0,4).equals(strY)) {//判断是否是本年
// xcy = SalaryTool.getMonthDiff(entry_date, salary_month+"-01")+1;
// }else {
// xcy = SalaryTool.getMonthDiff(strY+"-01-01", salary_month+"-01")+1;
// }
// cumjcfy = xcy*5000;
// }
// }
// gsmx.setCumJcfy(cumjcfy);//累计减除费用 【5000*在职月份数】
//
// gsmx.setCumZxkc(cumZxkc);//累计专项扣除 【本期专项扣除+累计专项扣除(上月)】
// gsmx.setCumQtkc(cumQtkc);//累计其他扣除 【本期其他扣除+累计其他扣除(上月)】
// gsmx.setCumYnssde(cumYnssde);//累计应纳税所得额 【累计收入额-累计减除费用-累计专项扣除-累计专项附加扣除-累计其他扣除】
// gsmx.setTaxRate(taxRate);//税率
// gsmx.setQuickCalculationDeduction(quickCalculationDeduction);//速算扣除数
// gsmx.setCumYnse(cumYnse);//累计应纳税额 【累计应纳税所得额*税率-速算扣除数】
// gsmx.setCumYyjse(cumYyjse);//累计已预缴纳税额 【累计已预缴税额(上月)+累计应补(退)税额(上月)】
// gsmx.setCumYbtse(cumYbtse);//累计应补(退)税额(本月个税) 【累计应纳税额-累计已预缴纳税额】
double cumynssde = 0;
cumynssde = gsmx.getCumSre() - cumjcfy - gsmx.getCumZxkc() - gsmx.getCumZxfjkc() - gsmx.getCumQtkc();
gsmx.setCumYnssde(cumynssde);//累计应纳税所得额 【累计收入额-累计减除费用-累计专项扣除-累计专项附加扣除-累计其他扣除】
String[] miscalculation = getPersonalincometax(cumynssde);
gsmx.setTaxRate(Double.valueOf(miscalculation[0]));//税率
gsmx.setQuickCalculationDeduction(Double.valueOf(miscalculation[1]));//速算扣除数
gsmx.setCumYnse(Double.valueOf(miscalculation[3]));//累计应纳税额 【累计应纳税所得额*税率-速算扣除数】
double cumyyjse = 0;
cumyyjse = (sygs == null ? 0 : sygs.getCumYyjse()) + (sygs == null ? 0 : sygs.getCumYbtse());
gsmx.setCumYyjse(cumyyjse);//累计已预缴纳税额 【累计已预缴税额(上月)+累计应补(退)税额(上月)】
double cumybtse = 0;
cumybtse = gsmx.getCumYnse() - gsmx.getCumYyjse();
gsmx.setCumYbtse(cumybtse);//累计应补(退)税额(本月个税) 【累计应纳税额-累计已预缴纳税额】
gsmx.setThmonthPersonal(cumybtse);//本月个税
gsmx.setQyid(orgcode);//企业id
gsmx.insert();
personalincome = cumybtse;
}
return personalincome;
}
/**
* 计算个税
* @param taxpayroll 累计应纳税所得额
*/
public String[] getPersonalincometax(double taxpayroll){
String[] perinctax = new String[3];
List<XcglAssoTaxFormula> taxratelist = XcglAssoTaxFormula.builder().build().selectList(new QueryWrapper<XcglAssoTaxFormula>().lambda().eq(XcglAssoTaxFormula::getQyid, 0));
double personalIncomeTax=0;//个税
double money=36000;//应交税工资最低点
if(taxpayroll>money){//应交税
for (XcglAssoTaxFormula tax : taxratelist) {//计算个税
if(tax.getTaxablestart()<=taxpayroll&&taxpayroll<tax.getTaxableend()){
//个人所得税=计税工资*税率-速算扣除数
BigDecimal aa = new BigDecimal(tax.getTaxrate());
BigDecimal bb = new BigDecimal(100);
double taxrate = aa.divide(bb,2,BigDecimal.ROUND_HALF_UP).doubleValue();
personalIncomeTax = taxpayroll*taxrate-tax.getDeductions();
perinctax[0] = String.valueOf(taxrate);//税率
perinctax[1] = String.valueOf(tax.getDeductions());//速算扣除数
perinctax[2] = String.valueOf(SalaryTool.formatDouble(personalIncomeTax));//累计应纳税额
}
}
}else{
perinctax[0] = "0";
perinctax[1] = "0";
perinctax[2] = "0";
}
return perinctax;
}
/**
* 新增/修改--报税周期信息
......
......@@ -10,6 +10,15 @@ public class SalaryTool {
static SimpleDateFormat mat = new SimpleDateFormat("yyyy-MM-dd");
static SimpleDateFormat matM = new SimpleDateFormat("yyyy-MM");
/**
* 保留两位小数,四舍五入的一个老土的方法
* @param d
* @return
*/
public static double formatDouble(double d) {
return (double)Math.round(d*10000)/10000;
}
/**
* 获取两个日期相差的月数
* @param d2 较大的日期
......
......@@ -23,5 +23,7 @@ public interface SbgjjAssoYjzdMapper extends BaseMapper<SbgjjAssoYjzd> {
SbgjjAssoYjzd zcjsjginsurance(int usernum,int qyid,String zymonth);
List<MonthlyCheckoutSheetDto> MonthlycheckoutsheetList(MonthlyStatementDto monthlystatementdto);
SbgjjAssoYjzd IndividualTotalsbgjj(String usernum,int qyid,String zymonth);
}
......@@ -85,6 +85,21 @@
cbryid SbgjjAssoYjzd_cbryid
</sql>
<select id="IndividualTotalsbgjj" resultMap="BaseResultMap">
select * from sbgjj_asso_yjzd yj
where yj.cbryid = (
select cb.id from sbgjj_admin_cbry cb
where cb.user_num = #{usernum}
and cb.qyid = #{qyid}
and cb.id in (select yj.cbryid from sbgjj_asso_yjzd yj
where yj.zymonth = #{zymonth}
and yj.user_num = #{usernum})
and cb.state = 1
and cb.is_use = 1
)
and yj.qyid = #{qyid}
</select>
<select id="MonthlycheckoutsheetList" resultMap="MonthlyCheckoutSheetMap">
select emp.`name` as empname,
yjzd.user_num as usernum,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment