...
|
...
|
@@ -274,8 +274,10 @@ class AfterToBefore extends Api |
|
|
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);
|
|
|
// 如果只自定义了基数中的一个就,就让两者全部按照已经自定义的那个来
|
|
|
if(empty($housing_fund_base)){
|
|
|
$housing_fund_base = $social_base;
|
|
|
}
|
|
|
}
|
|
|
// 公积金基数
|
|
|
$housing_fund_top = config('site.housing_fund_top_after'); //公积金封顶金额
|
...
|
...
|
@@ -283,8 +285,10 @@ class AfterToBefore extends Api |
|
|
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);
|
|
|
// 如果只自定义了基数中的一个就,就让两者全部按照已经自定义的那个来
|
|
|
if(empty($social_base)){
|
|
|
$social_base = $housing_fund_base;
|
|
|
}
|
|
|
}
|
|
|
// 公积金缴存比例5%-7%
|
|
|
$social_rate_user = Db::name('social_insurance_rate')->where('id',1)->find();
|
...
|
...
|
@@ -295,10 +299,6 @@ 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;
|
|
|
$tax_rate_new = db('tax_rate_new')->order('level desc')->select();
|
|
|
// 月份
|
|
|
$month = 12;
|
...
|
...
|
@@ -323,72 +323,145 @@ 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 = ($social_base*$social_rate+$housing_fund)*$month;
|
|
|
if(empty($social_base) && empty($housing_fund_base)){
|
|
|
// 个人五险一金比例
|
|
|
$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; //三金保底费用
|
|
|
$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;
|
|
|
}
|
|
|
}
|
|
|
// 五险一金汇缴明细-个人
|
|
|
$social_user = [
|
|
|
'housing_fund' => [
|
|
|
'rate' => $housing_fund_rate,
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($housing_fund_rate/100)/$month,2)
|
|
|
],
|
|
|
'endowment' => [
|
|
|
'rate' => $social_rate_user['endowment'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['endowment']/100)/$month,2)
|
|
|
],
|
|
|
'medical' => [
|
|
|
'rate' => $social_rate_user['medical'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['medical']/100)/$month,2)
|
|
|
],
|
|
|
'unemployment' => [
|
|
|
'rate' => $social_rate_user['unemployment'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['unemployment']/100)/$month,2)
|
|
|
],
|
|
|
'birth' => [
|
|
|
'rate' => $social_rate_user['birth'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['birth']/100)/$month,2)
|
|
|
],
|
|
|
'industrial' => [
|
|
|
'rate' => $social_rate_user['industrial'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['industrial']/100)/$month,2)
|
|
|
],
|
|
|
];
|
|
|
// 五险一金汇缴明细-单位
|
|
|
$social_company = [
|
|
|
'housing_fund' => [
|
|
|
'rate' => $housing_fund_rate,
|
|
|
'money' => $social_user['housing_fund']['money']
|
|
|
],
|
|
|
'endowment' => [
|
|
|
'rate' => $social_rate_company['endowment'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['endowment']/100)/$month,2)
|
|
|
],
|
|
|
'medical' => [
|
|
|
'rate' => $social_rate_company['medical'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['medical']/100)/$month,2)
|
|
|
],
|
|
|
'unemployment' => [
|
|
|
'rate' => $social_rate_company['unemployment'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['unemployment']/100)/$month,2)
|
|
|
],
|
|
|
'birth' => [
|
|
|
'rate' => $social_rate_company['birth'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['birth']/100)/$month,2)
|
|
|
],
|
|
|
'industrial' => [
|
|
|
'rate' => $social_rate_company['industrial'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['industrial']/100)/$month,2)
|
|
|
],
|
|
|
];
|
|
|
}else{
|
|
|
// 每月个人承担的三险比例(其中养老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;
|
|
|
// 每月个人承担的公积金
|
|
|
$housing_fund = $housing_fund_base * $housing_fund_rate / 100;
|
|
|
// 个人三险一金部分
|
|
|
$san_gong_money_total = ($social_base*$social_rate+$housing_fund)*$month;
|
|
|
// 五险一金汇缴明细-个人
|
|
|
$social_user = [
|
|
|
'housing_fund' => [
|
|
|
'rate' => $housing_fund_rate,
|
|
|
'money' => round($housing_fund,2)
|
|
|
],
|
|
|
'endowment' => [
|
|
|
'rate' => $social_rate_user['endowment'],
|
|
|
'money' => round($social_base * $social_rate_user['endowment']/100,2)
|
|
|
],
|
|
|
'medical' => [
|
|
|
'rate' => $social_rate_user['medical'],
|
|
|
'money' => round($social_base * $social_rate_user['medical']/100,2)
|
|
|
],
|
|
|
'unemployment' => [
|
|
|
'rate' => $social_rate_user['unemployment'],
|
|
|
'money' => round($social_base * $social_rate_user['unemployment']/100,2)
|
|
|
],
|
|
|
'birth' => [
|
|
|
'rate' => $social_rate_user['birth'],
|
|
|
'money' => round($social_base * $social_rate_user['birth']/100,2)
|
|
|
],
|
|
|
'industrial' => [
|
|
|
'rate' => $social_rate_user['industrial'],
|
|
|
'money' => round($social_base * $social_rate_user['industrial']/100,2)
|
|
|
],
|
|
|
];
|
|
|
// 五险一金汇缴明细-单位
|
|
|
$social_company = [
|
|
|
'housing_fund' => [
|
|
|
'rate' => $housing_fund_rate,
|
|
|
'money' => $social_user['housing_fund']['money']
|
|
|
],
|
|
|
'endowment' => [
|
|
|
'rate' => $social_rate_company['endowment'],
|
|
|
'money' => round($social_base * $social_rate_company['endowment']/100,2)
|
|
|
],
|
|
|
'medical' => [
|
|
|
'rate' => $social_rate_company['medical'],
|
|
|
'money' => round($social_base * $social_rate_company['medical']/100,2)
|
|
|
],
|
|
|
'unemployment' => [
|
|
|
'rate' => $social_rate_company['unemployment'],
|
|
|
'money' => round($social_base * $social_rate_company['unemployment']/100,2)
|
|
|
],
|
|
|
'birth' => [
|
|
|
'rate' => $social_rate_company['birth'],
|
|
|
'money' => round($social_base * $social_rate_company['birth']/100,2)
|
|
|
],
|
|
|
'industrial' => [
|
|
|
'rate' => $social_rate_company['industrial'],
|
|
|
'money' => round($social_base * $social_rate_company['industrial']/100,2)
|
|
|
],
|
|
|
];
|
|
|
}
|
|
|
// 累计工资总额
|
|
|
$salary_total = $salary_hand + $person_fee_total + $san_gong_money_total;
|
|
|
// 平均个税金额
|
|
|
$person_fee_average = round($person_fee_total/$month,2);
|
|
|
// 平均每月税前工资
|
|
|
$salary_average = round($salary_total/$month,2);
|
|
|
// 五险一金汇缴明细-个人
|
|
|
$social_user = [
|
|
|
'housing_fund' => [
|
|
|
'rate' => $housing_fund_rate,
|
|
|
'money' => round($housing_fund,2)
|
|
|
],
|
|
|
'endowment' => [
|
|
|
'rate' => $social_rate_user['endowment'],
|
|
|
'money' => round($social_base * $social_rate_user['endowment']/100,2)
|
|
|
],
|
|
|
'medical' => [
|
|
|
'rate' => $social_rate_user['medical'],
|
|
|
'money' => round($social_base * $social_rate_user['medical']/100,2)
|
|
|
],
|
|
|
'unemployment' => [
|
|
|
'rate' => $social_rate_user['unemployment'],
|
|
|
'money' => round($social_base * $social_rate_user['unemployment']/100,2)
|
|
|
],
|
|
|
'birth' => [
|
|
|
'rate' => $social_rate_user['birth'],
|
|
|
'money' => round($social_base * $social_rate_user['birth']/100,2)
|
|
|
],
|
|
|
'industrial' => [
|
|
|
'rate' => $social_rate_user['industrial'],
|
|
|
'money' => round($social_base * $social_rate_user['industrial']/100,2)
|
|
|
],
|
|
|
];
|
|
|
// 五险一金汇缴明细-个人合计
|
|
|
$social_user_money = round(array_sum(array_map(function($val){return $val['money'];}, $social_user)),2);
|
|
|
// 五险一金汇缴明细-单位
|
|
|
$social_company = [
|
|
|
'housing_fund' => [
|
|
|
'rate' => $housing_fund_rate,
|
|
|
'money' => $social_user['housing_fund']['money']
|
|
|
],
|
|
|
'endowment' => [
|
|
|
'rate' => $social_rate_company['endowment'],
|
|
|
'money' => round($social_base * $social_rate_company['endowment']/100,2)
|
|
|
],
|
|
|
'medical' => [
|
|
|
'rate' => $social_rate_company['medical'],
|
|
|
'money' => round($social_base * $social_rate_company['medical']/100,2)
|
|
|
],
|
|
|
'unemployment' => [
|
|
|
'rate' => $social_rate_company['unemployment'],
|
|
|
'money' => round($social_base * $social_rate_company['unemployment']/100,2)
|
|
|
],
|
|
|
'birth' => [
|
|
|
'rate' => $social_rate_company['birth'],
|
|
|
'money' => round($social_base * $social_rate_company['birth']/100,2)
|
|
|
],
|
|
|
'industrial' => [
|
|
|
'rate' => $social_rate_company['industrial'],
|
|
|
'money' => round($social_base * $social_rate_company['industrial']/100,2)
|
|
|
],
|
|
|
];
|
|
|
// 五险一金汇缴明细-单位合计
|
|
|
$social_company_money = round(array_sum(array_map(function($val){return $val['money'];}, $social_company)),2);
|
|
|
// 税前工资去向
|
...
|
...
|
|