Commit 1fa3835e by lizhilin

更新

parent b0ba3362
......@@ -36,7 +36,7 @@ protected function grid()
return sprintf('%.2f', $paid_amount);
});
$grid->column('posting_tickets_money', '贴票金额')->display(function () use ($year) {
$tickets_money = ModelLawyerCost::getPostingTicketsMoney($year, $this->id, $this->commission_rate, $this->ticket_ratio);
$tickets_money = ModelLawyerCost::getPostingTicketsMoney($this->id, $year, $this->commission_rate, $this->ticket_ratio);
return $tickets_money;
});
$grid->column('commission_retention', '提成留底')->display(function () use ($year) {
......
......@@ -2,9 +2,8 @@
namespace App\Admin\Repositories;
use App\Models\Lawyer;
use App\Models\Lawyer as ModelLawyer;
use App\Models\LawyerCost as ModelLawyerCost;
//use Dcat\Admin\Repositories\EloquentRepository;
use Dcat\Admin\Repositories\Repository;
use Dcat\Admin\Grid;
......@@ -48,6 +47,7 @@ public function get(Grid\Model $model)
{
// 获取筛选条件
$year = $model->filter()->input('year') ?? date("Y");
$lnum = $model->filter()->input('no') ?? '';
$data = [];
$nowyear = date('Y');
......@@ -64,85 +64,92 @@ public function get(Grid\Model $model)
for ($i = 1; $i <= $monthNum; $i++) {
$tmp[$i] = '0.00';
$condition = ['year' => $year, 'month' => $i, 'number' => $lnum];
//基本工资
if ($val['field'] == 'basic_salary') {
$basic_salary = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('basic_salary');
$basic_salary = ModelLawyerCost::where($condition)->sum('basic_salary');
$tmp[$i] = $basic_salary;
$fieldTotal += $basic_salary;
}
//专项附加
if ($val['field'] == 'special_additional') {
$special_additional = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('special_additional');
$special_additional = ModelLawyerCost::where($condition)->sum('special_additional');
$tmp[$i] = $special_additional;
$fieldTotal += $special_additional;
}
//社保
if ($val['field'] == 'social') {
$social_person_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('social_person_fee');
$social_company_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('social_company_fee');
$social_person_fee = ModelLawyerCost::where($condition)->sum('social_person_fee');
$social_company_fee = ModelLawyerCost::where($condition)->sum('social_company_fee');
$tmp[$i] = sprintf("%.2f", ($social_person_fee + $social_company_fee));
}
//社保个人部分
if ($val['field'] == 'social_person_fee') {
$social_person_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('social_person_fee');
$social_person_fee = ModelLawyerCost::where($condition)->sum('social_person_fee');
$tmp[$i] = $social_person_fee;
}
//社保企业部分
if ($val['field'] == 'social_company_fee') {
$social_company_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('social_company_fee');
$social_company_fee = ModelLawyerCost::where($condition)->sum('social_company_fee');
$tmp[$i] = $social_company_fee;
}
//公积金
if ($val['field'] == 'accumulation_fund') {
$person_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('accumulation_fund_person_fee');
$company_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('accumulation_fund_company_fee');
$person_fee = ModelLawyerCost::where($condition)->sum('accumulation_fund_person_fee');
$company_fee = ModelLawyerCost::where($condition)->sum('accumulation_fund_company_fee');
$tmp[$i] = sprintf("%.2f", ($person_fee + $company_fee));
}
//公积金个人部分
if ($val['field'] == 'accumulation_fund_person_fee') {
$person_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('accumulation_fund_person_fee');
$person_fee = ModelLawyerCost::where($condition)->sum('accumulation_fund_person_fee');
$tmp[$i] = sprintf("%.2f", $person_fee);
}
//公积金企业部分
if ($val['field'] == 'accumulation_fund_company_fee') {
$company_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('accumulation_fund_company_fee');
$company_fee = ModelLawyerCost::where($condition)->sum('accumulation_fund_company_fee');
$tmp[$i] = sprintf("%.2f", $company_fee);
}
//律所年检费
if ($val['field'] == 'annual_inspection_fee') {
$annual_inspection_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('annual_inspection_fee');
$annual_inspection_fee = ModelLawyerCost::where($condition)->sum('annual_inspection_fee');
$tmp[$i] = $annual_inspection_fee;
}
//律所年金
if ($val['field'] == 'annuity') {
$annuity = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('annuity');
$annuity = ModelLawyerCost::where($condition)->sum('annuity');
$tmp[$i] = $annuity;
}
//贴票成本
if ($val['field'] == 'posting_tickets_fee') {
$lawyerObj = ModelLawyer::where('number', $lnum)->first();
$tickets_money = ModelLawyerCost::getPostingTicketsMoney($lawyerObj->lawyer_id, $year, $lawyerObj->commission_rate, $lawyerObj->ticket_ratio, $i);
$tmp[$i] = $tickets_money;
}
//助理律师成本
if ($val['field'] == 'assistant_fee') {
$assistant_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('assistant_fee');
$assistant_fee = ModelLawyerCost::where($condition)->sum('assistant_fee');
$tmp[$i] = $assistant_fee;
}
//办公室租赁成本
if ($val['field'] == 'office_rental_fee') {
$office_rental_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('office_rental_fee');
$office_rental_fee = ModelLawyerCost::where($condition)->sum('office_rental_fee');
$tmp[$i] = $office_rental_fee;
}
//无票成本
if ($val['field'] == 'noticket_cost') {
$noticket_cost = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('noticket_cost');
$noticket_cost = ModelLawyerCost::where($condition)->sum('noticket_cost');
$tmp[$i] = $noticket_cost;
}
//个人所得税
if ($val['field'] == 'personal_income_tax') {
$personal_income_tax = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('personal_income_tax');
$personal_income_tax = ModelLawyerCost::where($condition)->sum('personal_income_tax');
$tmp[$i] = $personal_income_tax;
}
......
......@@ -56,7 +56,7 @@ public static function getInvoiceNoreceipt($lawyer_id = 0)
}
//创收已收款
public static function getReceivedMoney($lawyer_id = 0, $year = 0)
public static function getReceivedMoney($lawyer_id = 0, $year = 0, $month = 0)
{
$where = ['rtype' => 1];
if ($lawyer_id) {
......@@ -65,6 +65,9 @@ public static function getReceivedMoney($lawyer_id = 0, $year = 0)
if ($year) {
$where['year'] = $year;
}
if ($month) {
$where['month'] = $month;
}
$money = self::where($where)
->sum('received_amount');
return $money;
......
......@@ -159,13 +159,16 @@ public static function getAdvanceFee($lawyer_id = 0, $year = 0)
//已支付款项
public static function getPaidAmount($lawyer_id, $year = 0)
public static function getPaidAmount($lawyer_id, $year = 0, $month = 0)
{
$paid_amount = 0;
$where = ['lawyer_id' => $lawyer_id];
if ($year) {
$where['year'] = $year;
}
if ($month) {
$where['month'] = $month;
}
$list = self::where($where)->get();
if ($list->toArray()) {
$basic_salary = $special_additional = $social_company_fee = $accumulation_fund_company_fee = 0;
......@@ -190,11 +193,11 @@ public static function getPaidAmount($lawyer_id, $year = 0)
* commission_rate 提成比例
* ticket_ratio 贴票比例
*/
public static function getPostingTicketsMoney($lawyer_id, $year, $commission_rate, $ticket_ratio)
public static function getPostingTicketsMoney($lawyer_id, $year, $commission_rate, $ticket_ratio, $month = 0)
{
$ticket = 0;
$received_money = CovenantReceivePayment::getReceivedMoney($lawyer_id, $year); //创收已收款
$paid_amount = LawyerCost::getPaidAmount($lawyer_id, $year); //已支付款项
$received_money = CovenantReceivePayment::getReceivedMoney($lawyer_id, $year, $month); //创收已收款
$paid_amount = LawyerCost::getPaidAmount($lawyer_id, $year, $month); //已支付款项
$commission = $received_money * ($commission_rate / 100); //提成
if ($commission_rate == 80) {
if ($commission > 300000) {
......
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