作者 何书鹏
1 个管道 的构建 通过 耗费 2 秒

bug修改

... ... @@ -26,6 +26,8 @@ class AfterToBefore extends Api
*
* @ApiParams (name="salary_hand_average", type="inter", required=true, description="税后每月工资")
* @ApiParams (name="add_money", type="inter", required=false, description="每月专项附加金额")
* @ApiParams (name="social_base", type="inter", required=false, description="社保汇缴基数")
* @ApiParams (name="housing_fund_base", type="inter", required=false, description="公积金汇缴基数")
* @ApiParams (name="housing_fund_rate", type="inter", required=false, description="公积金汇缴比例")
*
* @ApiReturn({
... ... @@ -259,6 +261,8 @@ class AfterToBefore extends Api
$param = $this->request->param(); //返回给前端
$salary_hand_average = $this->request->param('salary_hand_average',0);
$add_money = $this->request->param('add_money',0);
$social_base = $this->request->param('social_base');
$housing_fund_base = $this->request->param('housing_fund_base');
$housing_fund_rate = $this->request->param('housing_fund_rate');
empty($salary_hand_average) && $this->error('请输入税后平均每月工资');
if(empty($add_money)){
... ... @@ -267,9 +271,21 @@ class AfterToBefore extends Api
// 社保基数
$social_top = config('site.social_top_after'); //社保封顶金额
$social_bottom = config('site.social_bottom_after'); //社保保底金额
if(!empty($social_base)){
$social_base > $social_top && $this->error('社保汇缴基数不能大于'.$social_top);
$social_base < $social_bottom && $this->error('社保汇缴基数不能小于'.$social_bottom);
}else{
$social_base = $salary_hand_average > $social_top ? $social_top : ($salary_hand_average < $social_bottom ? $social_bottom : $salary_hand_average);
}
// 公积金基数
$housing_fund_top = config('site.housing_fund_top_after'); //公积金封顶金额
$housing_fund_bottom = config('site.housing_fund_bottom_after'); //公积金保底金额
if(!empty($housing_fund_base)){
$housing_fund_base > $housing_fund_top && $this->error('公积金汇缴基数不能大于'.$housing_fund_top);
$housing_fund_base < $housing_fund_bottom && $this->error('公积金汇缴基数不能小于'.$housing_fund_bottom);
}else{
$housing_fund_base = $salary_hand_average > $housing_fund_top ? $housing_fund_top : ($salary_hand_average < $housing_fund_bottom ? $housing_fund_bottom : $salary_hand_average);
}
// 公积金缴存比例5%-7%
$social_rate_user = Db::name('social_insurance_rate')->where('id',1)->find();
$social_rate_company = Db::name('social_insurance_rate')->where('id',2)->find();
... ... @@ -279,10 +295,10 @@ class AfterToBefore extends Api
}else{
$housing_fund_rate = config('site.housing_fund_rate');
}
// 每月个人承担的三险比例(其中养老8%,医疗2%,失业0.5%,三种保险总和为10.5%,上海地区个人承担的三种保险比例一致。)
$social_rate = ($social_rate_user['endowment']+$social_rate_user['medical']+$social_rate_user['unemployment']+$social_rate_user['birth']+$social_rate_user['industrial'])/100;
// 个人五险一金比例
$wuxianyijin_rate = ($social_rate_user['endowment']+$social_rate_user['medical']+$social_rate_user['unemployment']+$social_rate_user['birth']+$housing_fund_rate)/100;
$fee_top = $social_top*$wuxianyijin_rate; //三金封顶费用
$fee_bottom = $social_bottom*$wuxianyijin_rate; //三金保底费用
$tax_rate_new = db('tax_rate_new')->order('level desc')->select();
// 月份
$month = 12;
... ... @@ -307,17 +323,10 @@ class AfterToBefore extends Api
}
// 累计个人所得税
$person_fee_total = $suode == 0 ? 0 : $suode+$dec_fee_total-$salary_hand;
// 每月个人承担的公积金
$housing_fund = $housing_fund_base * $housing_fund_rate / 100;
// 个人三险一金部分
$san_gong_money_total = 0;
if(($salary_hand+$person_fee_total)/(1-$wuxianyijin_rate)/$month>=$social_top){
$san_gong_money_total = $fee_top*$month;
}else{
if(($salary_hand+$person_fee_total)/(1-$wuxianyijin_rate)/$month>=$fee_bottom){
$san_gong_money_total = ($salary_hand+$person_fee_total)/(1-$wuxianyijin_rate)*$wuxianyijin_rate;
}else{
$san_gong_money_total = $fee_bottom*$month;
}
}
$san_gong_money_total = ($social_base*$social_rate+$housing_fund)*$month;
// 累计工资总额
$salary_total = $salary_hand + $person_fee_total + $san_gong_money_total;
// 平均个税金额
... ... @@ -328,27 +337,27 @@ class AfterToBefore extends Api
$social_user = [
'housing_fund' => [
'rate' => $housing_fund_rate,
'money' => round($san_gong_money_total/$wuxianyijin_rate*($housing_fund_rate/100)/$month,2)
'money' => round($housing_fund,2)
],
'endowment' => [
'rate' => $social_rate_user['endowment'],
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['endowment']/100)/$month,2)
'money' => round($social_base * $social_rate_user['endowment']/100,2)
],
'medical' => [
'rate' => $social_rate_user['medical'],
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['medical']/100)/$month,2)
'money' => round($social_base * $social_rate_user['medical']/100,2)
],
'unemployment' => [
'rate' => $social_rate_user['unemployment'],
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['unemployment']/100)/$month,2)
'money' => round($social_base * $social_rate_user['unemployment']/100,2)
],
'birth' => [
'rate' => $social_rate_user['birth'],
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['birth']/100)/$month,2)
'money' => round($social_base * $social_rate_user['birth']/100,2)
],
'industrial' => [
'rate' => $social_rate_user['industrial'],
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['industrial']/100)/$month,2)
'money' => round($social_base * $social_rate_user['industrial']/100,2)
],
];
// 五险一金汇缴明细-个人合计
... ... @@ -361,23 +370,23 @@ class AfterToBefore extends Api
],
'endowment' => [
'rate' => $social_rate_company['endowment'],
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['endowment']/100)/$month,2)
'money' => round($social_base * $social_rate_company['endowment']/100,2)
],
'medical' => [
'rate' => $social_rate_company['medical'],
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['medical']/100)/$month,2)
'money' => round($social_base * $social_rate_company['medical']/100,2)
],
'unemployment' => [
'rate' => $social_rate_company['unemployment'],
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['unemployment']/100)/$month,2)
'money' => round($social_base * $social_rate_company['unemployment']/100,2)
],
'birth' => [
'rate' => $social_rate_company['birth'],
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['birth']/100)/$month,2)
'money' => round($social_base * $social_rate_company['birth']/100,2)
],
'industrial' => [
'rate' => $social_rate_company['industrial'],
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['industrial']/100)/$month,2)
'money' => round($social_base * $social_rate_company['industrial']/100,2)
],
];
// 五险一金汇缴明细-单位合计
... ... @@ -496,10 +505,6 @@ class AfterToBefore extends Api
]
],$user_go['en']),
];
// 社保汇缴基数
$social_base = $salary_average > $social_top ? $social_top : ($salary_average < $social_bottom ? $social_bottom : $salary_average);
// 公积金汇缴基数
$housing_fund_base = $salary_average > $housing_fund_top ? $housing_fund_top : ($salary_average < $housing_fund_bottom ? $housing_fund_bottom : $salary_average);
$this->success('请求成功',compact('param','salary_average','social_user','social_user_money','social_company','social_company_money','person_fee_average','company_cost','user_go','company_go','social_base','housing_fund_base'));
}
... ...
... ... @@ -423,7 +423,8 @@ class BeforeToAfter extends Api
'money' => round($social_base * $social_rate_user['industrial']/100,2)
],
];
$social_user_money = round($social_money+$housing_fund,2);
// 五险一金汇缴明细-个人合计
$social_user_money = round(array_sum(array_map(function($val){return $val['money'];}, $social_user)),2);
// 五险一金汇缴明细-单位
$social_company = [
'housing_fund' => [
... ... @@ -451,7 +452,8 @@ class BeforeToAfter extends Api
'money' => round($company_industrial_money,2)
],
];
$social_company_money = round($company_fourxian_money+$company_industrial_money+$company_housing_fund,2);
// 五险一金汇缴明细-单位合计
$social_company_money = round(array_sum(array_map(function($val){return $val['money'];}, $social_company)),2);
// 税前工资去向
$user_go = [
'salary' => round($salary,2),
... ... @@ -625,13 +627,10 @@ class BeforeToAfter extends Api
}
}
// 新税法下个人当月到手工资
// $new_current_salary = $salary - $social_money - $housing_fund - $new_person_current_fee;
$new_current_salary = ($salary - $social_money - $housing_fund - $new_person_current_fee) + ($annual_bonus - $annual_bonus_fee) / 12;
// 老税法下个人当月到手工资
// $old_current_salary = $salary - $social_money - $housing_fund - $old_person_current_fee;
$old_current_salary = $salary - $social_money - $housing_fund - $old_person_current_fee + ($annual_bonus - $annual_bonus_fee) / 12;
// 新税法下个人累计到手工资及年终奖总和
// $new_saan_total = $salary_total + $dec_fee - $san_gong_money_total - $new_fee - $annual_bonus_fee;
$new_saan_total = $salary_total - $san_gong_money_total - $new_person_fee + ($annual_bonus - $annual_bonus_fee)/12*$month;
// 老税法下个人累计到手工资及年终奖总和
$old_saan_total = $old_current_salary * $month + $annual_bonus - $annual_bonus_fee;
... ...