|
@@ -26,6 +26,8 @@ class AfterToBefore extends Api |
|
@@ -26,6 +26,8 @@ class AfterToBefore extends Api |
26
|
*
|
26
|
*
|
27
|
* @ApiParams (name="salary_hand_average", type="inter", required=true, description="税后每月工资")
|
27
|
* @ApiParams (name="salary_hand_average", type="inter", required=true, description="税后每月工资")
|
28
|
* @ApiParams (name="add_money", type="inter", required=false, description="每月专项附加金额")
|
28
|
* @ApiParams (name="add_money", type="inter", required=false, description="每月专项附加金额")
|
|
|
29
|
+ * @ApiParams (name="social_base", type="inter", required=false, description="社保汇缴基数")
|
|
|
30
|
+ * @ApiParams (name="housing_fund_base", type="inter", required=false, description="公积金汇缴基数")
|
29
|
* @ApiParams (name="housing_fund_rate", type="inter", required=false, description="公积金汇缴比例")
|
31
|
* @ApiParams (name="housing_fund_rate", type="inter", required=false, description="公积金汇缴比例")
|
30
|
*
|
32
|
*
|
31
|
* @ApiReturn({
|
33
|
* @ApiReturn({
|
|
@@ -259,6 +261,8 @@ class AfterToBefore extends Api |
|
@@ -259,6 +261,8 @@ class AfterToBefore extends Api |
259
|
$param = $this->request->param(); //返回给前端
|
261
|
$param = $this->request->param(); //返回给前端
|
260
|
$salary_hand_average = $this->request->param('salary_hand_average',0);
|
262
|
$salary_hand_average = $this->request->param('salary_hand_average',0);
|
261
|
$add_money = $this->request->param('add_money',0);
|
263
|
$add_money = $this->request->param('add_money',0);
|
|
|
264
|
+ $social_base = $this->request->param('social_base');
|
|
|
265
|
+ $housing_fund_base = $this->request->param('housing_fund_base');
|
262
|
$housing_fund_rate = $this->request->param('housing_fund_rate');
|
266
|
$housing_fund_rate = $this->request->param('housing_fund_rate');
|
263
|
empty($salary_hand_average) && $this->error('请输入税后平均每月工资');
|
267
|
empty($salary_hand_average) && $this->error('请输入税后平均每月工资');
|
264
|
if(empty($add_money)){
|
268
|
if(empty($add_money)){
|
|
@@ -267,9 +271,21 @@ class AfterToBefore extends Api |
|
@@ -267,9 +271,21 @@ class AfterToBefore extends Api |
267
|
// 社保基数
|
271
|
// 社保基数
|
268
|
$social_top = config('site.social_top_after'); //社保封顶金额
|
272
|
$social_top = config('site.social_top_after'); //社保封顶金额
|
269
|
$social_bottom = config('site.social_bottom_after'); //社保保底金额
|
273
|
$social_bottom = config('site.social_bottom_after'); //社保保底金额
|
|
|
274
|
+ if(!empty($social_base)){
|
|
|
275
|
+ $social_base > $social_top && $this->error('社保汇缴基数不能大于'.$social_top);
|
|
|
276
|
+ $social_base < $social_bottom && $this->error('社保汇缴基数不能小于'.$social_bottom);
|
|
|
277
|
+ }else{
|
|
|
278
|
+ $social_base = $salary_hand_average > $social_top ? $social_top : ($salary_hand_average < $social_bottom ? $social_bottom : $salary_hand_average);
|
|
|
279
|
+ }
|
270
|
// 公积金基数
|
280
|
// 公积金基数
|
271
|
$housing_fund_top = config('site.housing_fund_top_after'); //公积金封顶金额
|
281
|
$housing_fund_top = config('site.housing_fund_top_after'); //公积金封顶金额
|
272
|
$housing_fund_bottom = config('site.housing_fund_bottom_after'); //公积金保底金额
|
282
|
$housing_fund_bottom = config('site.housing_fund_bottom_after'); //公积金保底金额
|
|
|
283
|
+ if(!empty($housing_fund_base)){
|
|
|
284
|
+ $housing_fund_base > $housing_fund_top && $this->error('公积金汇缴基数不能大于'.$housing_fund_top);
|
|
|
285
|
+ $housing_fund_base < $housing_fund_bottom && $this->error('公积金汇缴基数不能小于'.$housing_fund_bottom);
|
|
|
286
|
+ }else{
|
|
|
287
|
+ $housing_fund_base = $salary_hand_average > $housing_fund_top ? $housing_fund_top : ($salary_hand_average < $housing_fund_bottom ? $housing_fund_bottom : $salary_hand_average);
|
|
|
288
|
+ }
|
273
|
// 公积金缴存比例5%-7%
|
289
|
// 公积金缴存比例5%-7%
|
274
|
$social_rate_user = Db::name('social_insurance_rate')->where('id',1)->find();
|
290
|
$social_rate_user = Db::name('social_insurance_rate')->where('id',1)->find();
|
275
|
$social_rate_company = Db::name('social_insurance_rate')->where('id',2)->find();
|
291
|
$social_rate_company = Db::name('social_insurance_rate')->where('id',2)->find();
|
|
@@ -279,10 +295,10 @@ class AfterToBefore extends Api |
|
@@ -279,10 +295,10 @@ class AfterToBefore extends Api |
279
|
}else{
|
295
|
}else{
|
280
|
$housing_fund_rate = config('site.housing_fund_rate');
|
296
|
$housing_fund_rate = config('site.housing_fund_rate');
|
281
|
}
|
297
|
}
|
|
|
298
|
+ // 每月个人承担的三险比例(其中养老8%,医疗2%,失业0.5%,三种保险总和为10.5%,上海地区个人承担的三种保险比例一致。)
|
|
|
299
|
+ $social_rate = ($social_rate_user['endowment']+$social_rate_user['medical']+$social_rate_user['unemployment']+$social_rate_user['birth']+$social_rate_user['industrial'])/100;
|
282
|
// 个人五险一金比例
|
300
|
// 个人五险一金比例
|
283
|
$wuxianyijin_rate = ($social_rate_user['endowment']+$social_rate_user['medical']+$social_rate_user['unemployment']+$social_rate_user['birth']+$housing_fund_rate)/100;
|
301
|
$wuxianyijin_rate = ($social_rate_user['endowment']+$social_rate_user['medical']+$social_rate_user['unemployment']+$social_rate_user['birth']+$housing_fund_rate)/100;
|
284
|
- $fee_top = $social_top*$wuxianyijin_rate; //三金封顶费用
|
|
|
285
|
- $fee_bottom = $social_bottom*$wuxianyijin_rate; //三金保底费用
|
|
|
286
|
$tax_rate_new = db('tax_rate_new')->order('level desc')->select();
|
302
|
$tax_rate_new = db('tax_rate_new')->order('level desc')->select();
|
287
|
// 月份
|
303
|
// 月份
|
288
|
$month = 12;
|
304
|
$month = 12;
|
|
@@ -307,17 +323,10 @@ class AfterToBefore extends Api |
|
@@ -307,17 +323,10 @@ class AfterToBefore extends Api |
307
|
}
|
323
|
}
|
308
|
// 累计个人所得税
|
324
|
// 累计个人所得税
|
309
|
$person_fee_total = $suode == 0 ? 0 : $suode+$dec_fee_total-$salary_hand;
|
325
|
$person_fee_total = $suode == 0 ? 0 : $suode+$dec_fee_total-$salary_hand;
|
|
|
326
|
+ // 每月个人承担的公积金
|
|
|
327
|
+ $housing_fund = $housing_fund_base * $housing_fund_rate / 100;
|
310
|
// 个人三险一金部分
|
328
|
// 个人三险一金部分
|
311
|
- $san_gong_money_total = 0;
|
|
|
312
|
- if(($salary_hand+$person_fee_total)/(1-$wuxianyijin_rate)/$month>=$social_top){
|
|
|
313
|
- $san_gong_money_total = $fee_top*$month;
|
|
|
314
|
- }else{
|
|
|
315
|
- if(($salary_hand+$person_fee_total)/(1-$wuxianyijin_rate)/$month>=$fee_bottom){
|
|
|
316
|
- $san_gong_money_total = ($salary_hand+$person_fee_total)/(1-$wuxianyijin_rate)*$wuxianyijin_rate;
|
|
|
317
|
- }else{
|
|
|
318
|
- $san_gong_money_total = $fee_bottom*$month;
|
|
|
319
|
- }
|
|
|
320
|
- }
|
329
|
+ $san_gong_money_total = ($social_base*$social_rate+$housing_fund)*$month;
|
321
|
// 累计工资总额
|
330
|
// 累计工资总额
|
322
|
$salary_total = $salary_hand + $person_fee_total + $san_gong_money_total;
|
331
|
$salary_total = $salary_hand + $person_fee_total + $san_gong_money_total;
|
323
|
// 平均个税金额
|
332
|
// 平均个税金额
|
|
@@ -328,27 +337,27 @@ class AfterToBefore extends Api |
|
@@ -328,27 +337,27 @@ class AfterToBefore extends Api |
328
|
$social_user = [
|
337
|
$social_user = [
|
329
|
'housing_fund' => [
|
338
|
'housing_fund' => [
|
330
|
'rate' => $housing_fund_rate,
|
339
|
'rate' => $housing_fund_rate,
|
331
|
- 'money' => round($san_gong_money_total/$wuxianyijin_rate*($housing_fund_rate/100)/$month,2)
|
340
|
+ 'money' => round($housing_fund,2)
|
332
|
],
|
341
|
],
|
333
|
'endowment' => [
|
342
|
'endowment' => [
|
334
|
'rate' => $social_rate_user['endowment'],
|
343
|
'rate' => $social_rate_user['endowment'],
|
335
|
- 'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['endowment']/100)/$month,2)
|
344
|
+ 'money' => round($social_base * $social_rate_user['endowment']/100,2)
|
336
|
],
|
345
|
],
|
337
|
'medical' => [
|
346
|
'medical' => [
|
338
|
'rate' => $social_rate_user['medical'],
|
347
|
'rate' => $social_rate_user['medical'],
|
339
|
- 'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['medical']/100)/$month,2)
|
348
|
+ 'money' => round($social_base * $social_rate_user['medical']/100,2)
|
340
|
],
|
349
|
],
|
341
|
'unemployment' => [
|
350
|
'unemployment' => [
|
342
|
'rate' => $social_rate_user['unemployment'],
|
351
|
'rate' => $social_rate_user['unemployment'],
|
343
|
- 'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['unemployment']/100)/$month,2)
|
352
|
+ 'money' => round($social_base * $social_rate_user['unemployment']/100,2)
|
344
|
],
|
353
|
],
|
345
|
'birth' => [
|
354
|
'birth' => [
|
346
|
'rate' => $social_rate_user['birth'],
|
355
|
'rate' => $social_rate_user['birth'],
|
347
|
- 'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['birth']/100)/$month,2)
|
356
|
+ 'money' => round($social_base * $social_rate_user['birth']/100,2)
|
348
|
],
|
357
|
],
|
349
|
'industrial' => [
|
358
|
'industrial' => [
|
350
|
'rate' => $social_rate_user['industrial'],
|
359
|
'rate' => $social_rate_user['industrial'],
|
351
|
- 'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['industrial']/100)/$month,2)
|
360
|
+ 'money' => round($social_base * $social_rate_user['industrial']/100,2)
|
352
|
],
|
361
|
],
|
353
|
];
|
362
|
];
|
354
|
// 五险一金汇缴明细-个人合计
|
363
|
// 五险一金汇缴明细-个人合计
|
|
@@ -361,23 +370,23 @@ class AfterToBefore extends Api |
|
@@ -361,23 +370,23 @@ class AfterToBefore extends Api |
361
|
],
|
370
|
],
|
362
|
'endowment' => [
|
371
|
'endowment' => [
|
363
|
'rate' => $social_rate_company['endowment'],
|
372
|
'rate' => $social_rate_company['endowment'],
|
364
|
- 'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['endowment']/100)/$month,2)
|
373
|
+ 'money' => round($social_base * $social_rate_company['endowment']/100,2)
|
365
|
],
|
374
|
],
|
366
|
'medical' => [
|
375
|
'medical' => [
|
367
|
'rate' => $social_rate_company['medical'],
|
376
|
'rate' => $social_rate_company['medical'],
|
368
|
- 'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['medical']/100)/$month,2)
|
377
|
+ 'money' => round($social_base * $social_rate_company['medical']/100,2)
|
369
|
],
|
378
|
],
|
370
|
'unemployment' => [
|
379
|
'unemployment' => [
|
371
|
'rate' => $social_rate_company['unemployment'],
|
380
|
'rate' => $social_rate_company['unemployment'],
|
372
|
- 'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['unemployment']/100)/$month,2)
|
381
|
+ 'money' => round($social_base * $social_rate_company['unemployment']/100,2)
|
373
|
],
|
382
|
],
|
374
|
'birth' => [
|
383
|
'birth' => [
|
375
|
'rate' => $social_rate_company['birth'],
|
384
|
'rate' => $social_rate_company['birth'],
|
376
|
- 'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['birth']/100)/$month,2)
|
385
|
+ 'money' => round($social_base * $social_rate_company['birth']/100,2)
|
377
|
],
|
386
|
],
|
378
|
'industrial' => [
|
387
|
'industrial' => [
|
379
|
'rate' => $social_rate_company['industrial'],
|
388
|
'rate' => $social_rate_company['industrial'],
|
380
|
- 'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['industrial']/100)/$month,2)
|
389
|
+ 'money' => round($social_base * $social_rate_company['industrial']/100,2)
|
381
|
],
|
390
|
],
|
382
|
];
|
391
|
];
|
383
|
// 五险一金汇缴明细-单位合计
|
392
|
// 五险一金汇缴明细-单位合计
|
|
@@ -496,10 +505,6 @@ class AfterToBefore extends Api |
|
@@ -496,10 +505,6 @@ class AfterToBefore extends Api |
496
|
]
|
505
|
]
|
497
|
],$user_go['en']),
|
506
|
],$user_go['en']),
|
498
|
];
|
507
|
];
|
499
|
- // 社保汇缴基数
|
|
|
500
|
- $social_base = $salary_average > $social_top ? $social_top : ($salary_average < $social_bottom ? $social_bottom : $salary_average);
|
|
|
501
|
- // 公积金汇缴基数
|
|
|
502
|
- $housing_fund_base = $salary_average > $housing_fund_top ? $housing_fund_top : ($salary_average < $housing_fund_bottom ? $housing_fund_bottom : $salary_average);
|
|
|
503
|
$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'));
|
508
|
$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'));
|
504
|
|
509
|
|
505
|
}
|
510
|
}
|