Commit a030442f by lizhilin

更新

parent 74024957
<?php
namespace App\Admin\Actions;
use Dcat\Admin\Actions\Response;
use App\Admin\Forms\CovenantClosedForm;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Traits\HasPermissions;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Dcat\Admin\Widgets\Modal;
class CovenantClosed extends RowAction
{
/**
* @return string
*/
protected $title = '<i class="feather icon-stop-circle"> 已结案 </i>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<i class="feather icon-stop-circle"></i> ' . $this->title . '';
}
/**
* Handle the action request.
*
* @param Request $request
*
* @return Response
*/
public function handle(Request $request)
{
$id = $this->getKey() ?? 0;
return $this->response()->success('成功')->refresh();
}
/**
* 渲染模态框.
* @return Modal
*/
public function render()
{
$cid = $this->getKey() ?? 0;
// 这里直接创建一个modal框 model的内容由工具表单提供,这里也需要创建一个工具表单才行
return Modal::make()
->lg()
->title('已结案')
->button("已结案")
->body(CovenantClosedForm::make()->payload(['id' => $this->getKey()]));
//->button("<button class='btn btn-sm btn-primary'>$this->title</button>"); // 这个button就是对应上面的按钮
}
/**
* @return string|array|void
*/
public function confirm()
{
//return ['Confirm?', 'contents'];
}
/**
* @param Model|Authenticatable|HasPermissions|null $user
*
* @return bool
*/
protected function authorize($user): bool
{
return true;
}
/**
* @return array
*/
protected function parameters()
{
return [];
}
}
<?php
namespace App\Admin\Actions;
use Dcat\Admin\Actions\Response;
use App\Admin\Forms\CovenantInvoiceForm;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Traits\HasPermissions;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Dcat\Admin\Widgets\Modal;
class CovenantInvoice extends RowAction
{
/**
* @return string
*/
protected $title = '<i class="feather icon-stop-circle"> 添加开票 </i>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<i class="feather icon-stop-circle"></i> ' . $this->title . '';
}
/**
* Handle the action request.
*
* @param Request $request
*
* @return Response
*/
public function handle(Request $request)
{
$id = $this->getKey() ?? 0;
return $this->response()->success('成功')->refresh();
}
/**
* 渲染模态框.
* @return Modal
*/
public function render()
{
// 这里直接创建一个modal框 model的内容由工具表单提供,这里也需要创建一个工具表单才行
return Modal::make()
->lg()
->title('添加开票')
->button("添加开票")
->body(CovenantInvoiceForm::make()->payload(['id' => $this->getKey()]));
//->button("<button class='btn btn-sm btn-primary'>$this->title</button>"); // 这个button就是对应上面的按钮
}
/**
* @return string|array|void
*/
public function confirm()
{
// return ['Confirm?', 'contents'];
}
/**
* @param Model|Authenticatable|HasPermissions|null $user
*
* @return bool
*/
protected function authorize($user): bool
{
return true;
}
/**
* @return array
*/
protected function parameters()
{
return [];
}
}
<?php
namespace App\Admin\Actions;
use Dcat\Admin\Actions\Response;
use App\Admin\Forms\CovenantReceiveForm;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Traits\HasPermissions;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Dcat\Admin\Widgets\Modal;
class CovenantReceive extends RowAction
{
/**
* @return string
*/
protected $title = '<i class="feather icon-stop-circle"> 添加收款 </i>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<i class="feather icon-stop-circle"></i> ' . $this->title . '';
}
/**
* Handle the action request.
*
* @param Request $request
*
* @return Response
*/
public function handle(Request $request)
{
$id = $this->getKey() ?? 0;
return $this->response()->success('成功')->refresh();
}
/**
* 渲染模态框.
* @return Modal
*/
public function render()
{
// 这里直接创建一个modal框 model的内容由工具表单提供,这里也需要创建一个工具表单才行
return Modal::make()
->lg()
->title('添加收款')
->button("添加收款")
->body(CovenantReceiveForm::make()->payload(['id' => $this->getKey()]));
//->button("<button class='btn btn-sm btn-primary'>$this->title</button>"); // 这个button就是对应上面的按钮
}
/**
* @return string|array|void
*/
public function confirm()
{
// return ['Confirm?', 'contents'];
}
/**
* @param Model|Authenticatable|HasPermissions|null $user
*
* @return bool
*/
protected function authorize($user): bool
{
return true;
}
/**
* @return array
*/
protected function parameters()
{
return [];
}
}
<?php
namespace App\Admin\Actions;
use Dcat\Admin\Actions\Response;
use App\Admin\Forms\CovenantReturnForm;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Traits\HasPermissions;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Dcat\Admin\Widgets\Modal;
class CovenantReturn extends RowAction
{
/**
* @return string
*/
protected $title = '<i class="feather icon-stop-circle"> 已退还 </i>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<i class="feather icon-stop-circle"></i> ' . $this->title . '';
}
/**
* Handle the action request.
*
* @param Request $request
*
* @return Response
*/
public function handle(Request $request)
{
$id = $this->getKey() ?? 0;
return $this->response()->success('成功')->refresh();
}
/**
* 渲染模态框.
* @return Modal
*/
public function render()
{
$cid = $this->getKey() ?? 0;
// 这里直接创建一个modal框 model的内容由工具表单提供,这里也需要创建一个工具表单才行
return Modal::make()
->lg()
->title('已退还')
->button("已退还")
->body(CovenantReturnForm::make()->payload(['id' => $this->getKey()]));
//->button("<button class='btn btn-sm btn-primary'>$this->title</button>"); // 这个button就是对应上面的按钮
}
/**
* @return string|array|void
*/
public function confirm()
{
//return ['Confirm?', 'contents'];
}
/**
* @param Model|Authenticatable|HasPermissions|null $user
*
* @return bool
*/
protected function authorize($user): bool
{
return true;
}
/**
* @return array
*/
protected function parameters()
{
return [];
}
}
......@@ -9,6 +9,9 @@
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use App\Admin\Actions\CovenantClosed;
use App\Admin\Actions\CovenantReturn;
use Dcat\Admin\Admin;
class CovenantController extends AdminController
{
......@@ -20,6 +23,7 @@ class CovenantController extends AdminController
protected function grid()
{
return Grid::make(ModelsCovenant::with(['principal', 'lawyer']), function (Grid $grid) {
$grid->model()->orderBy('id', 'DESC');
$grid->column('id')->sortable();
$grid->column('number');
$grid->column('cname');
......@@ -45,6 +49,7 @@ protected function grid()
// $grid->column('updated_at')->sortable();
$grid->disableViewButton();
$grid->disableRowSelector();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
......@@ -57,6 +62,25 @@ protected function grid()
$filter->equal('payment_method')->select(Covenant::PAYMENT_METHOD)->width(3);
$filter->between('sign_at', '签约日期')->date()->width(4);
});
$grid->actions(function (Grid\Displayers\Actions $actions) {
//编辑
if (!Admin::user()->can('hetong-edit')) {
$actions->disableEdit();
}
//删除
if (!Admin::user()->can('hetong-delete')) {
$actions->disableDelete();
}
//已结案
if (Admin::user()->can('hetong-closed')) {
$actions->append(new CovenantClosed($actions->row->id));
}
// 已退还
if (Admin::user()->can('hetong-return')) {
$actions->append(new CovenantReturn($actions->row->id));
}
});
});
}
......
<?php
namespace App\Admin\Controllers;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
use App\Models\Covenant as ModelsCovenant;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use App\Admin\Repositories\CovenantReceivePaymentCollect;
class CovenantReceivePaymentController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new CovenantReceivePaymentCollect(), function (Grid $grid) {
//已收款
$receivedMoney = ModelsCovenantReceivePayment::getReceivedMoney();
//开票金额
$invoicedMoney = ModelsCovenantReceivePayment::getInvoicedMoney();
//已收款未开票
$receiptNoinvoice = ModelsCovenantReceivePayment::getReceiptNoinvoice();
//已开票未收款
$invoiceNoreceipt = ModelsCovenantReceivePayment::getInvoiceNoreceipt();
// 添加一行表头数据
$grid->header(function () use ($invoicedMoney, $receivedMoney, $receiptNoinvoice, $invoiceNoreceipt) {
return '<div class="row" style="text-align:center;">' .
'<div class="col-md-7">合计</div>' .
'<div class="col-md-1">' . $invoicedMoney . '</div>' .
'<div class="col-md-1">' . $receivedMoney . '</div>' .
'<div class="col-md-1">' . $receiptNoinvoice . '</div>' .
'<div class="col-md-1">' . $invoiceNoreceipt . '</div>' .
'</div>';
});
//$grid->column('id')->sortable();
$grid->column('lnum', '律师编号');
$grid->column('lname', '律师姓名');
$grid->column('covenant_num', '合同编号');
$grid->column('covenant_name', '合同名称');
$grid->column('covenant_type', '合同类型');
$grid->column('principal', '委托人');
$grid->column('invoice_amount', '开票金额');
$grid->column('receipt_money', '已收款');
$grid->column('receipt_noinvoice', '已收款未开票');
$grid->column('invoice_noreceipt', '已开票未收款');
//$grid->column('updated_at')->sortable();
$grid->disableCreateButton();
$grid->disableRowSelector();
$grid->disableActions();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('lnum', '律师编号')->width(3);
$filter->like('lname', '律师名称')->width(3);
$filter->like('cnum', '合同编号')->width(3);
$filter->equal('ctype', '合同类型')->select(ModelsCovenant::CTYPE)->width(3);
$filter->like('principal', '委托人')->width(3);
$filter->between('received_at', '收款日期')->date()->width(4);
$filter->between('invoiced_at', '开票日期')->date()->width(4);
});
});
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\LawyerCollect;
use App\Models\Covenant as ModelsCovenant;
use App\Models\Lawyer as ModelLawyer;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use App\Admin\Actions\CovenantReceive;
use App\Admin\Actions\CovenantInvoice;
class LawyerCollectController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new LawyerCollect(), function (Grid $grid) {
//$grid->column('id')->sortable();
$grid->column('lnumber', '律师编号');
$grid->column('lname', '律师名称');
$grid->column('commission_ratio', '提成比例 %');
$grid->column('receipt_money', '创收已收款');
$grid->column('commission_amount', '提成金额');
$grid->column('receipt_noinvoice', '已收款未开票');
$grid->column('invoice_noreceipt', '已开票未收款');
$grid->column('cost', '成本合计');
$grid->column('basic_salary', '基本工资');
$grid->column('special_additional', '专项附加');
$grid->column('social', '社保');
$grid->column('accumulation_fund', '公积金');
$grid->column('posting_tickets_fee', '贴票金额');
$grid->column('advance_fee', '预支款');
$grid->column('payable_commission', '可结算提成');
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
$grid->disableCreateButton();
$grid->disableViewButton();
$grid->disableRowSelector();
$grid->disableActions();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('number', '律师编号')->width(3);
$filter->like('name', '律师姓名')->width(3);
$filter->between('received_at', '收款日期')->date()->width(4);
$filter->between('invoiced_at', '开票日期')->date()->width(4);
});
});
}
}
<?php
namespace App\Admin\Controllers;
use App\Models\LawyerCost as ModelLawyerCost;
use App\Admin\Repositories\LawyerCommission;
use App\Models\Lawyer as ModelsLawyer;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
class LawyerCommissionCollectController extends AdminController
{
/**
* 律师提成汇总
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new LawyerCommission(), function (Grid $grid) {
$number = $grid->model()->filter()->input('no') ?? ''; //律师编号
$nowyear = date("Y");
$year = $grid->model()->filter()->input('year') ?? '';
$monthNum = ($year && $year < $nowyear) ? 12 : date('m');
$grid->column('title', '项目名称')->width('10%');
for ($i = 1; $i <= $monthNum; $i++) {
$grid->column($i, $i . '月');
}
$grid->column('total', '合计');
// $grid->disableViewButton();
// $grid->disableCreateButton();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('year', '年份')->width(3)->default(date("Y"));
});
$grid->disableRowSelector();
$grid->disableActions();
$grid->disableCreateButton();
$grid->disablePagination();
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $number) {
$fullname = '';
if ($number) {
$obj = ModelsLawyer::where('number', $number)->first();
$fullname = $obj->name;
}
$card_info = "&nbsp;&nbsp;律师编号:{$number}&nbsp;&nbsp;&nbsp;律师姓名:{$fullname}";
$tools->append($card_info);
});
});
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\Lawyer;
use App\Models\Lawyer as ModelLawyer;
use App\Models\LawyerCost as ModelLawyerCost;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Support\Facades\DB;
use App\Models\CovenantReceivePayment as ModelCovenantReceivePayment;
class LawyerCommissionController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new Lawyer(), function (Grid $grid) {
$year = $grid->model()->filter()->input('year') ?? date('Y');
//$grid->column('id')->sortable();
$grid->column('number', '律师编号');
$grid->column('name', '律师姓名');
$grid->column('received_money', '创收已收款')->display(function ($val) use ($year) {
$money = self::getReceivedMoney($year, $this->id);
return $money;
});
$grid->column('commission_rate', '提成比例 %');
$grid->column('paid_amount', '已支付款项')->display(function ($val) use ($year) {
$paid_amount = self::getPaidAmount($year, $this->id);
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);
return $tickets_money;
});
$grid->column('commission_retention', '提成留底')->display(function () use ($year) {
$received_money = ModelCovenantReceivePayment::getReceivedMoney($this->id, $year); //创收已收款
$commission_rate = $this->commission_rate; //提成比例
$result = $received_money * ($commission_rate / 100) * 0.05;
return sprintf('%.2f', $result);
});
$grid->column('payable_amount', '可支付提成结算金额')->display(function () use ($year) {
$received_money = ModelCovenantReceivePayment::getReceivedMoney($this->id, $year); //创收已收款
$paid_amount = ModelLawyerCost::getPaidAmount($this->id, $year); //已支付款项
$commission_rate = $this->commission_rate; //提成比例
$result = $received_money * ($commission_rate / 100) - $paid_amount;
return sprintf('%.2f', $result);
});
$grid->column('personal_income_tax', '个人所得税')->display(function ($val) use ($year) {
$amount = self::getPersonalIncomeTax($year, $this->id);
return sprintf('%.2f', $amount);
});
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
$grid->disableCreateButton();
$grid->disableViewButton();
$grid->disableEditButton();
$grid->disableDeleteButton();
$grid->disableRowSelector();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('number', '律师编号')->width(3);
$filter->like('name', '律师姓名')->width(3);
$filter->like('year', '年份')->width(3)->default(date("Y"))->ignore();
});
$grid->actions(function (Grid\Displayers\Actions $actions) {
//查看
$actions->append('<a href="/lawyer-commission-collect?no=' . $this->number . '" alt="查看" target="_blank">查看</a>');
});
});
}
//创收已收款
public static function getReceivedMoney($year, $lawyer_id)
{
$money = ModelCovenantReceivePayment::where(['lawyer_id' => $lawyer_id, 'rtype' => 1])
->where('received_at', 'like', $year . '%')
->sum('received_amount');
return $money;
}
//已支付款项
public static function getPaidAmount($year, $lawyer_id)
{
$paid_amount = 0;
$list = ModelLawyerCost::where(['lawyer_id' => $lawyer_id, 'year' => $year])->get();
if ($list->toArray()) {
$basic_salary = $special_additional = $social_company_fee = $accumulation_fund_company_fee = 0;
$annual_inspection_fee = $annuity = $office_rental_fee = $assistant_fee = 0;
foreach ($list as $item) {
$basic_salary += $item->basic_salary;
$special_additional += $item->special_additional;
$social_company_fee += $item->social_company_fee;
$accumulation_fund_company_fee += $item->accumulation_fund_company_fee;
$annual_inspection_fee += $item->annual_inspection_fee;
$annuity += $item->annuity;
$office_rental_fee += $item->office_rental_fee;
$assistant_fee += $item->assistant_fee;
}
$paid_amount = $basic_salary + $special_additional + $social_company_fee + $accumulation_fund_company_fee + $annual_inspection_fee + $annuity + $office_rental_fee + $assistant_fee;
}
return $paid_amount;
}
//个人所得税
public static function getPersonalIncomeTax($year, $lawyer_id)
{
$amount = 0;
$list = ModelLawyerCost::where(['lawyer_id' => $lawyer_id, 'year' => $year])->get();
if ($list->toArray()) {
$personal_income_tax = 0;
foreach ($list as $item) {
$amount += $item->personal_income_tax;
}
}
return $amount;
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Lawyer(), function (Show $show) {
$show->field('id');
$show->field('number');
$show->field('name');
$show->field('sex');
$show->field('identity_card');
$show->field('phone');
$show->field('bank_account');
$show->field('sign_at');
$show->field('commission_rate');
$show->field('settlement_period');
$show->field('created_at');
$show->field('updated_at');
});
}
}
......@@ -19,25 +19,19 @@ class LawyerCostCollectController extends AdminController
*/
protected function grid()
{
return Grid::make(new LawyerCost(), function (Grid $grid) {
$list = ModelLawyerCost::COSTiTEM;
return Grid::make(new LawyerCost(), function (Grid $grid) use ($list) {
$number = $grid->model()->filter()->input('no') ?? ''; //律师编号
$nowyear = date("Y");
$year = $grid->model()->filter()->input('year') ?? '';
$monthNum = ($year && $year < $nowyear) ? 12 : date('m');
// $where = [];
// if ($number) {
// $where['number'] = $number;
// }
// if ($year) {
// $where['year'] = $year;
// }
// $grid->model()->where($where);
$grid->column('title', '项目名称')->width('10%');
for ($i = 1; $i <= $monthNum; $i++) {
$grid->column($i, $i . '月');
}
$grid->column('total', '合计');
// $grid->disableViewButton();
// $grid->disableCreateButton();
......
......@@ -9,6 +9,7 @@
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Support\Facades\DB;
class LawyerCostController extends AdminController
{
......@@ -20,30 +21,57 @@ class LawyerCostController extends AdminController
protected function grid()
{
return Grid::make(new Lawyer(), function (Grid $grid) {
$grid->column('id')->sortable();
$number = $grid->model()->filter()->input('number') ?? '';
$name = $grid->model()->filter()->input('name') ?? '';
$year = $_GET['year'] ?? date("Y");
//$grid->column('id')->sortable();
$grid->column('number', '律师编号');
$grid->column('name', '律师姓名');
$grid->column('basic_salary', '基本工资');
$grid->column('special_additional', '专项附加');
$grid->column('social', '社保');
$grid->column('accumulation_fund', '公积金');
$grid->column('annual_inspection_fee', '律所年检费');
$grid->column('annuity', '律所年金');
$grid->column('posting_tickets_fee', '贴票成本');
$grid->column('assistant_fee', '助理律师成本');
$grid->column('office_rental_fee', '办公租赁成本');
$grid->column('noticket_cost', '无票成本');
$grid->column('personal_income_tax', '个人所得税');
$grid->column('basic_salary', '基本工资')->display(function ($val) use ($year) {
return self::getBasiSalary($this->number, $year);
});
$grid->column('special_additional', '专项附加')->display(function ($val) use ($year) {
return self::getSpecialAdditional($this->number, $year);
});
$grid->column('social', '社保')->display(function ($val) use ($year) {
return self::getSocial($this->number, $year);
});
$grid->column('accumulation_fund', '公积金')->display(function ($val) use ($year) {
return self::getAccumulationFund($this->number, $year);
});
$grid->column('annual_inspection_fee', '律所年检费')->display(function ($val) use ($year) {
return self::getAnnualInspectionFee($this->number, $year);
});
$grid->column('annuity', '律所年金')->display(function ($val) use ($year) {
return self::getAnnuity($this->number, $year);
});
$grid->column('posting_tickets_fee', '贴票成本')->display(function ($val) use ($year) {
return self::getAssistantFee($this->number, $year);
});
$grid->column('assistant_fee', '助理律师成本')->display(function ($val) use ($year) {
return self::getAssistantFee($this->number, $year);
});
$grid->column('office_rental_fee', '办公租赁成本')->display(function ($val) use ($year) {
return self::getOfficeRentalFee($this->number, $year);
});
$grid->column('noticket_cost', '无票成本')->display(function ($val) use ($year) {
return self::getNoticketCost($this->number, $year);
});
$grid->column('personal_income_tax', '个人所得税')->display(function ($val) use ($year) {
return self::getPersonalIncomeTax($this->number, $year);
});
$grid->disableViewButton();
$grid->disableEditButton();
$grid->disableDeleteButton();
$grid->disableRowSelector();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('number', '律师编号')->width(3);
$filter->like('name', '律师姓名')->width(3);
$filter->like('year', '年份')->width(3)->default(date("Y"));
$filter->like('year', '年份')->width(3)->default(date("Y"))->ignore();
//$filter->date('sign_at')->format('YYYY-MM-DD');
});
......@@ -90,6 +118,76 @@ protected function grid2()
});
}
//基本工资
public static function getBasiSalary($number, $year)
{
return ModelLawyerCost::where(['number' => $number, 'year' => $year])->sum('basic_salary');
}
//专项附加
public static function getSpecialAdditional($number, $year)
{
return ModelLawyerCost::where(['number' => $number, 'year' => $year])->sum('special_additional');
}
//社保
public static function getSocial($number, $year)
{
$social_person_fee = ModelLawyerCost::where(['number' => $number, 'year' => $year])->sum('social_person_fee');
$social_company_fee = ModelLawyerCost::where(['number' => $number, 'year' => $year])->sum('social_company_fee');
return round($social_person_fee + $social_company_fee, 2);
}
//公积金
public static function getAccumulationFund($number, $year)
{
$accumulation_fund_person_fee = ModelLawyerCost::where(['number' => $number, 'year' => $year])->sum('accumulation_fund_person_fee');
$accumulation_fund_company_fee = ModelLawyerCost::where(['number' => $number, 'year' => $year])->sum('accumulation_fund_company_fee');
return round($accumulation_fund_person_fee + $accumulation_fund_company_fee, 2);
}
//律所年检费
public static function getAnnualInspectionFee($number, $year)
{
$annual_inspection_fee = ModelLawyerCost::where(['number' => $number, 'year' => $year])->sum('annual_inspection_fee');
return $annual_inspection_fee;
}
//律所年金
public static function getAnnuity($number, $year)
{
$annuity = ModelLawyerCost::where(['number' => $number, 'year' => $year])->sum('annuity');
return $annuity;
}
//助理律师成本
public static function getAssistantFee($number, $year)
{
$annuity = ModelLawyerCost::where(['number' => $number, 'year' => $year])->sum('assistant_fee');
return $annuity;
}
//办公室租赁成本
public static function getOfficeRentalFee($number, $year)
{
$office_rental_fee = ModelLawyerCost::where(['number' => $number, 'year' => $year])->sum('office_rental_fee');
return $office_rental_fee;
}
//个人所得税
public static function getPersonalIncomeTax($number, $year)
{
$personal_income_tax = ModelLawyerCost::where(['number' => $number, 'year' => $year])->sum('personal_income_tax');
return $personal_income_tax;
}
//无票成本
public static function getNoticketCost($number, $year)
{
$noticket_cost = ModelLawyerCost::where(['number' => $number, 'year' => $year])->sum('noticket_cost');
return $noticket_cost;
}
/**
* Make a show builder.
*
......@@ -131,7 +229,7 @@ protected function detail($id)
*/
protected function form()
{
return Form::make(new ModelLawyerCost(), function (Form $form) {
$form = Form::make(new ModelLawyerCost(), function (Form $form) {
$form->display('id');
$form->text('year');
$form->select('month')->options(ModelLawyerCost::MONTH);
......@@ -162,5 +260,26 @@ protected function form()
$form->display('created_at');
$form->display('updated_at');
});
//副表保存规格
$form->saved(
function (Form $form, $result) {
$cost_id = $form->getKey();
$basic_salary = $_POST['basic_salary'] ?? 0;
$special_additional = $_POST['special_additional'] ?? 0;
$social_company_fee = $_POST['social_company_fee'] ?? 0;
$accumulation_fund_company_fee = $_POST['accumulation_fund_company_fee'] ?? 0;
$assistant_fee = $_POST['assistant_fee'] ?? 0;
$office_rental_fee = $_POST['office_rental_fee'] ?? 0;
//无票成本
if ($result) {
$noticket_cost = $basic_salary + $special_additional + $social_company_fee + $accumulation_fund_company_fee + $assistant_fee + $office_rental_fee;
DB::table('lawyer_cost')->where("id", $cost_id)->update(['noticket_cost' => $noticket_cost]);
}
}
);
return $form;
}
}
......@@ -9,6 +9,7 @@
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Support\Facades\DB;
class LawyerCostListController extends AdminController
{
......@@ -30,20 +31,28 @@ protected function grid()
$where['year'] = $year;
}
$grid->model()->where($where);
$grid->column('id')->sortable();
//$grid->column('id')->sortable();
$grid->column('year', '年份');
$grid->column('month', '月份');
$grid->column('basic_salary', '基本工资');
$grid->column('special_additional', '专项附加');
$grid->column('social', '社保');
$grid->column('social', '社保')->display(function ($val) {
$total = $this->social_person_fee + $this->social_company_fee;
return sprintf("%.2f", $total);
});
$grid->column('social_person_fee', '社保个人部分');
$grid->column('social_company_fee', '社保公司部分');
$grid->column('accumulation_fund', '公积金');
$grid->column('accumulation_fund', '公积金')->display(function ($val) {
$total = $this->accumulation_fund_person_fee + $this->accumulation_fund_company_fee;
return sprintf("%.2f", $total);
});
$grid->column('accumulation_fund_person_fee', '公积金个人部分');
$grid->column('accumulation_fund_company_fee', '公积金公司部分');
$grid->column('annual_inspection_fee', '律所年检费');
$grid->column('annuity', '律所年金');
$grid->column('posting_tickets_fee', '贴票成本');
$grid->column('posting_tickets_fee', '贴票成本')->display(function () {
return $this->assistant_fee;
});
$grid->column('assistant_fee', '助理律师成本');
$grid->column('office_rental_fee', '办公租赁成本');
$grid->column('noticket_cost', '无票成本');
......@@ -52,6 +61,7 @@ protected function grid()
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableRowSelector();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
......@@ -114,7 +124,7 @@ protected function detail($id)
*/
protected function form()
{
return Form::make(new ModelLawyerCost(), function (Form $form) {
$form = Form::make(new ModelLawyerCost(), function (Form $form) {
$form->display('id');
$form->text('year');
$form->select('month')->options(ModelLawyerCost::MONTH);
......@@ -145,5 +155,26 @@ protected function form()
$form->display('created_at');
$form->display('updated_at');
});
//副表保存规格
$form->saved(
function (Form $form, $result) {
$cost_id = $form->getKey();
$basic_salary = $_POST['basic_salary'] ?? 0;
$special_additional = $_POST['special_additional'] ?? 0;
$social_company_fee = $_POST['social_company_fee'] ?? 0;
$accumulation_fund_company_fee = $_POST['accumulation_fund_company_fee'] ?? 0;
$assistant_fee = $_POST['assistant_fee'] ?? 0;
$office_rental_fee = $_POST['office_rental_fee'] ?? 0;
//无票成本
if ($result) {
$noticket_cost = $basic_salary + $special_additional + $social_company_fee + $accumulation_fund_company_fee + $assistant_fee + $office_rental_fee;
DB::table('lawyer_cost')->where("id", $cost_id)->update(['noticket_cost' => $noticket_cost]);
}
}
);
return $form;
}
}
......@@ -9,6 +9,8 @@
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use App\Admin\Actions\CovenantReceive;
use App\Admin\Actions\CovenantInvoice;
class LawyerCovenantIncomeController extends AdminController
{
......@@ -19,32 +21,87 @@ class LawyerCovenantIncomeController extends AdminController
*/
protected function grid()
{
return Grid::make(new Covenant(), function (Grid $grid) {
$lawyerID = $grid->model()->filter()->input('no') ?? ''; //律师ID
if ($lawyerID) {
$grid->model()->where('lawyer_id', $lawyerID);
}
//$grid->column('cid')->sortable();
$grid->column('number', '合同编号');
$grid->column('cname', '合同名称');
$grid->column('ctype', '合同类型')->display(function ($val) {
return ModelsCovenant::CTYPE[$val];
});
$grid->column('principal', '委托人');
$grid->column('invoice_amount', '开票金额');
$grid->column('receipt_money', '已收款');
$grid->column('receipt_noinvoice', '已收款未开票');
$grid->column('invoice_noreceipt', '已开票未收款');
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableEditButton();
$grid->disableDeleteButton();
$grid->disableRowSelector();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('number', '合同编号')->width(3);
$filter->like('cname', '合同名称')->width(3);
$filter->like('principal', '委托人')->width(3);
$filter->between('received_at', '收款日期')->date()->width(4);
$filter->between('invoiced_at', '开票日期')->date()->width(4);
});
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $lawyerID) {
$fullname = $number = '';
if ($lawyerID) {
$obj = ModelLawyer::find($lawyerID);
$fullname = $obj->name;
$number = $obj->number;
}
$card_info = "&nbsp;&nbsp;律师编号:{$number}&nbsp;&nbsp;&nbsp;律师姓名:{$fullname}";
$tools->append($card_info);
});
$grid->actions(function (Grid\Displayers\Actions $actions) use ($lawyerID) {
//添加收款
$actions->append(new CovenantReceive($actions->row->id));
//添加开票
$actions->append(new CovenantInvoice($actions->row->id));
//查看收款
$cid = $actions->row->cid;
$actions->append('<a href="/view-covenant-received?cid=' . $cid . '" alt="查看收款" target="_blank">查看收款</a>');
//查看开票
$actions->append('<a href="/view-covenant-invoiced?cid=' . $cid . '" alt="查看开票" target="_blank">查看开票</a>');
});
});
}
protected function grid2()
{
return Grid::make(ModelsCovenant::with(['principal', 'lawyer']), function (Grid $grid) {
$number = $grid->model()->filter()->input('no') ?? ''; //律师编号
if ($number) {
$grid->model()->where('number', $number);
$lawyerID = $grid->model()->filter()->input('no') ?? ''; //律师ID
if ($lawyerID) {
$grid->model()->where('lawyer_id', $lawyerID);
}
$grid->column('id')->sortable();
$grid->column('number');
$grid->column('cname');
$grid->column('ctype')->display(function ($val) {
$grid->column('number', '合同编号');
$grid->column('cname', '合同名称');
$grid->column('ctype', '合同类型')->display(function ($val) {
return Covenant::CTYPE[$val];
});
$grid->column('sign_at');
//$grid->column('sign_at');
$grid->column('principal.name', '委托人');
$grid->column('lawyer.name', '办案律师');
$grid->column('amount');
$grid->column('payment_method')->display(function ($val) {
return $val == 1 ? '开票付款' : '付款开票';
});
$grid->column('reserve_fee', '预留结案费');
$grid->column('is_closed', '结案状态')->display(function ($val) {
return $val ? '已结案' : '未结案';
});
$grid->column('is_return', '退还状态')->display(function ($val) {
return $val ? '已退还' : '未退还';
});
$grid->column('return_fee', '退还结案费');
$grid->column('field1', '开票金额');
$grid->column('field2', '已收款');
$grid->column('field3', '已收款未开票');
$grid->column('field4', '已开票未收款');
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
......@@ -53,14 +110,25 @@ protected function grid()
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('number')->width(3);
$filter->like('cname')->width(3);
$filter->like('number', '合同编号')->width(3);
$filter->like('cname', '合同名称')->width(3);
$filter->like('principal.name', '委托人')->width(3);
$filter->like('lawyer.name', '办案律师')->width(3);
$filter->equal('ctype')->select(Covenant::CTYPE)->width(3);
$filter->equal('payment_method')->select(Covenant::PAYMENT_METHOD)->width(3);
$filter->between('sign_at', '签约日期')->date()->width(4);
});
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $lawyerID) {
$fullname = $number = '';
if ($lawyerID) {
$obj = ModelLawyer::find($lawyerID);
$fullname = $obj->name;
$number = $obj->number;
}
$card_info = "&nbsp;&nbsp;律师编号:{$number}&nbsp;&nbsp;&nbsp;律师姓名:{$fullname}";
$tools->append($card_info);
});
});
}
......
......@@ -5,10 +5,12 @@
//use App\Admin\Repositories\LawyerCost;
use App\Models\Lawyer as ModelLawyer;
use App\Models\LawyerCost as ModelLawyerCost;
use App\Models\CovenantReceivePayment as ModelCovenantReceivePayment;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use App\Admin\Actions\CovenantReceive;
class LawyerIncomeController extends AdminController
{
......@@ -20,41 +22,69 @@ class LawyerIncomeController extends AdminController
protected function grid()
{
return Grid::make(new ModelLawyer(), function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('number', '律师编号111');
//$grid->column('id')->sortable();
$year = $grid->model()->filter()->input('year') ?? date('Y');
$grid->column('number', '律师编号');
$grid->column('name', '律师姓名');
$grid->column('sex', '性别');
$grid->column('sex', '性别')->display(function ($val) {
return $val == 1 ? '男' : '女';
});
$grid->column('identity_card', '身份证号');
$grid->column('field1', '开票金额');
$grid->column('field2', '已收款');
$grid->column('field3', '已收款未开票');
$grid->column('field4', '已开票未收款')->display(function () {
$linkstr = '<a href="/lawyer-covenant-income?no="' . $this->number . ' target="_blank">创收收款表</a>&nbsp;&nbsp;';
$linkstr .= '<a href="http://baidu.com?no="' . $this->number . ' target="_blank">已收款/已开票汇总</a><br/>';
$grid->column('phone', '手机号');
$grid->column('field1', '开票金额')->display(function () use ($year) {
//开票金额
$invoiced_money = ModelCovenantReceivePayment::where(['lawyer_id' => $this->id, 'rtype' => 2])
->where('invoiced_at', 'like', $year . '%')
->sum('invoiced_money');
return $invoiced_money;
});
$grid->column('field2', '已收款')->display(function () use ($year) {
//已收款
$receipt_money = ModelCovenantReceivePayment::where(['lawyer_id' => $this->id, 'rtype' => 1])
->where('received_at', 'like', $year . '%')
->sum('received_amount');
return $receipt_money;
});
$grid->column('field3', '已收款未开票')->display(function () use ($year) {
//开票金额
$invoiced_money = ModelCovenantReceivePayment::where(['lawyer_id' => $this->id, 'rtype' => 2])
->where('invoiced_at', 'like', $year . '%')
->sum('invoiced_money');
//已收款
$receipt_money = ModelCovenantReceivePayment::where(['lawyer_id' => $this->id, 'rtype' => 1])
->where('received_at', 'like', $year . '%')
->sum('received_amount');
//已收款未开票
$receipt_noinvoice = ($receipt_money - $invoiced_money) > 0 ? $receipt_money - $invoiced_money : '-';
return $receipt_noinvoice;
});
$grid->column('field4', '已开票未收款')->display(function ($val) {
$id = $this->id;
$linkstr = '<a href="/lawyer-covenant-income?no=' . $id . '" target="_blank">创收收款表</a>&nbsp;&nbsp;';
$linkstr .= '<a href="/receive_payment?no=' . $id . '" target="_blank">已收款/已开票汇总</a><br/>';
return $linkstr;
});
$grid->disableCreateButton();
$grid->disableViewButton();
$grid->disableEditButton();
$grid->disableRowSelector();
$grid->disableActions();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('number', '律师编号')->width(3);
$filter->like('name', '律师姓名')->width(3);
$filter->like('year', '年份')->width(3)->default(date("Y"));
$filter->like('year', '年份')->width(3)->default(date("Y"))->ignore();
//$filter->date('sign_at')->format('YYYY-MM-DD');
});
$grid->actions(function (Grid\Displayers\Actions $actions) {
//$actions->append(new UserBuyCode($actions->row->id));
//成本汇总
$actions->append('<a href="/lycost-collect?no=' . $this->number . '" alt="成本汇总" target="_blank">成本汇总</a>');
// 成本明细
$actions->append('<a href="/lycost-list?no=' . $this->number . '" alt="成本明细" target="_blank">成本明细</a>');
// 或者使用 RowAction 来添加按钮
//$actions->append(RowAction::make('自定义按钮')->route('custom.route'));
});
});
}
......
<?php
namespace App\Admin\Controllers;
use App\Admin\Metrics\Examples;
use App\Http\Controllers\Controller;
use App\Models\Covenant;
use App\Models\Lawyer;
use Dcat\Admin\Http\Controllers\Dashboard;
use Dcat\Admin\Layout\Column;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Layout\Row;
use Dcat\Admin\Widgets\Tab;
use Dcat\Admin\Grid;
use App\Models\Lawyer as ModelsLawyer;
use App\Models\CovenantReceivePayment as ModelCovenantReceivePayment;
use App\Admin\Repositories\LawyerReceivePaymentCollect;
use App\Admin\Repositories\LawyerInvoicedPaymentCollect;
class ReceivePaymentController extends Controller
{
public function index(Content $content)
{
// 创建第一个数据列表 已收款汇总表
$grid1 = Grid::make(new LawyerReceivePaymentCollect(), function (Grid $grid) {
$lawyerID = $grid->model()->filter()->input('no') ?? ''; //律师ID
$nowyear = date("Y");
$year = $grid->model()->filter()->input('year') ?? date('Y');
$monthNum = ($year && $year < $nowyear) ? 12 : date('m');
for ($i = 1; $i <= $monthNum; $i++) {
$grid->column($i, $i . '月');
}
$grid->disableActions();
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableRowSelector();
$grid->disablePagination();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('year', '年份')->width(3)->default(date("Y"))->ignore();
});
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $lawyerID) {
$fullname = $number = '';
if ($lawyerID) {
$obj = ModelsLawyer::find($lawyerID);
$fullname = $obj->name;
$number = $obj->number;
}
$card_info = "&nbsp;&nbsp;律师编号:{$number}&nbsp;&nbsp;&nbsp;律师姓名:{$fullname}";
$tools->append($card_info);
});
$grid->export()->disableExportAll();
$grid->export()->disableExportSelectedRow();
$grid->export()->rows(function ($rows) {
return $rows;
});
});
// 创建第二个数据列表
$grid2 = Grid::make(new LawyerInvoicedPaymentCollect(), function (Grid $grid) {
$lawyerID = $grid->model()->filter()->input('no') ?? ''; //律师ID
$nowyear = date("Y");
$year = $grid->model()->filter()->input('year') ?? date('Y');
$monthNum = ($year && $year < $nowyear) ? 12 : date('m');
for ($i = 1; $i <= $monthNum; $i++) {
$grid->column($i, $i . '月');
}
$grid->disableActions();
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableRowSelector();
$grid->disablePagination();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('year', '年份')->width(3)->default(date("Y"))->ignore();
});
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $lawyerID) {
$fullname = $number = '';
if ($lawyerID) {
$obj = ModelsLawyer::find($lawyerID);
$fullname = $obj->name;
$number = $obj->number;
}
$card_info = "&nbsp;&nbsp;律师编号:{$number}&nbsp;&nbsp;&nbsp;律师姓名:{$fullname}";
$tools->append($card_info);
});
$grid->export()->disableExportAll();
$grid->export()->disableExportSelectedRow();
$grid->export()->rows(function ($rows) {
return $rows;
});
});
// 使用Tab面板展示两个数据列表
$tab = Tab::make()->add('已收款汇总表', $grid1)->add('已开票汇总表', $grid2);
return $content->body($tab);
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\Principal;
use App\Models\Covenant as ModelsCovenant;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ViewCovenantInvoicedController extends AdminController
{
/**
* 查看收款信息
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new ModelsCovenantReceivePayment(), function (Grid $grid) {
$cid = $grid->model()->filter()->input('cid') ?? 0;
$grid->model()->where('rtype', 2)->orderBy("id", "desc");
//$grid->column('id')->sortable();
$grid->column('invoiced_at', '开票时间');
$grid->column('invoiced_money', '开票金额');
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableRowSelector();
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $cid) {
$principal = $number = '';
if ($cid) {
$obj = ModelsCovenant::find($cid);
$principal = $obj->principal;
$number = $obj->number;
}
$card_info = "&nbsp;&nbsp;合同编号:{$number}&nbsp;&nbsp;&nbsp;委托人:{$principal}";
$tools->append($card_info);
});
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = Form::make(new ModelsCovenantReceivePayment(), function (Form $form) {
//$form->display('id');
$form->date('invoiced_at', '收款时间')->format('YYYY-MM-DD');
$form->text('invoiced_money', '收款金额');
$form->disableCreatingCheck();
$form->disableEditingCheck();
$form->disableViewCheck();
$form->disableDeleteButton();
$form->disableViewButton();
$form->disableListButton();
});
return $form;
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\Principal;
use App\Models\Covenant as ModelsCovenant;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ViewCovenantReceivedController extends AdminController
{
/**
* 查看收款信息
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new ModelsCovenantReceivePayment(), function (Grid $grid) {
$cid = $grid->model()->filter()->input('cid') ?? 0;
$grid->model()->where('rtype', 1)->orderBy("id", "desc");
//$grid->column('id')->sortable();
$grid->column('received_type', '收款账户')->display(function ($val) {
return $val == 1 ? '基本户' : '其它';
});
$grid->column('pay_method', '支付方式');
$grid->column('received_at', '收款时间');
$grid->column('received_amount', '收款金额');
$grid->column('paymenter', '付款人');
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableRowSelector();
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $cid) {
$principal = $number = '';
if ($cid) {
$obj = ModelsCovenant::find($cid);
$principal = $obj->principal;
$number = $obj->number;
}
$card_info = "&nbsp;&nbsp;合同编号:{$number}&nbsp;&nbsp;&nbsp;委托人:{$principal}";
$tools->append($card_info);
});
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = Form::make(new ModelsCovenantReceivePayment(), function (Form $form) {
//$form->display('id');
$form->select('received_type', '账户类型')->options(ModelsCovenantReceivePayment::RECEIVEDTYPE);
$form->text('pay_method', '支付方式');
$form->date('received_at', '收款时间')->format('YYYY-MM-DD');
$form->text('received_amount', '收款金额');
$form->text('paymenter', '付款人');
$form->disableCreatingCheck();
$form->disableEditingCheck();
$form->disableViewCheck();
$form->disableDeleteButton();
$form->disableViewButton();
$form->disableListButton();
});
return $form;
}
}
<?php
namespace App\Admin\Forms;
use App\Command\Log;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Exception;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
use App\Models\Covenant as ModelsCovenant;
class CovenantClosedForm extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$cid = $this->payload['id'];
DB::beginTransaction();
try {
$return_fee = floatval($input['return_fee']);
$uObj = ModelsCovenant::find($cid);
if ($uObj && $uObj->is_return == 0 && $return_fee) {
$uObj->is_return = 1;
$uObj->return_fee = $return_fee;
$uObj->save();
}
DB::commit();
} catch (\Exception $exception) {
DB::rollBack();
return $this->response()->error($exception->getMessage())->refresh();
}
return $this->response()->success('提交成功' . $cid)->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->html('<div class="row" style="text-align:center;">
是否确认已结案
</div>');
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
// 获取外部传递参数
return [];
}
}
<?php
namespace App\Admin\Forms;
use App\Command\Log;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Exception;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
use App\Models\Covenant as ModelsCovenant;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
class CovenantInvoiceForm extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$cid = $this->payload['id']; //合同ID
DB::beginTransaction();
try {
$invoiced_at = trim($input['invoiced_at']);
$invoiced_money = trim($input['invoiced_money']);
$datearr = explode('-', $invoiced_at);
$year = $datearr[0];
$month = $datearr[1];
$cObj = ModelsCovenant::find($cid);
if (!$cObj) {
throw new Exception('该合同不存在!');
}
$receivePaymentObj = new ModelsCovenantReceivePayment();
$receivePaymentObj->invoiced_money = $invoiced_money;
$receivePaymentObj->year = $year;
$receivePaymentObj->month = $month;
$receivePaymentObj->rtype = 2;
$receivePaymentObj->cid = $cid;
$receivePaymentObj->lawyer_id = $cObj->lawyer_id;
$receivePaymentObj->principal = $cObj->principal;
$receivePaymentObj->invoiced_at = $invoiced_at;
$receivePaymentObj->save();
DB::commit();
} catch (\Exception $exception) {
DB::rollBack();
return $this->response()->error($exception->getMessage())->refresh();
}
return $this->response()->success('提交成功')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->date('invoiced_at', '开票时间')->format('YYYY-MM-DD')->default(date("Y-m-d"));
$this->text('invoiced_money', '开票金额');
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
// 获取外部传递参数
return [];
}
}
<?php
namespace App\Admin\Forms;
use App\Command\Log;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Exception;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
use App\Models\Covenant as ModelsCovenant;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
class CovenantReceiveForm extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$cid = $this->payload['id']; //合同ID
DB::beginTransaction();
try {
$received_type = (int)$input['received_type'];
$pay_method = trim($input['pay_method']);
$received_at = trim($input['received_at']);
$received_amount = trim($input['received_amount']);
$paymenter = trim($input['paymenter']);
$datearr = explode('-', $received_at);
$year = $datearr[0];
$month = $datearr[1];
$cObj = ModelsCovenant::find($cid);
if (!$cObj) {
throw new Exception('该合同不存在!');
}
$receivePaymentObj = new ModelsCovenantReceivePayment();
$receivePaymentObj->received_type = $received_type;
$receivePaymentObj->pay_method = $pay_method;
$receivePaymentObj->received_at = $received_at;
$receivePaymentObj->received_amount = $received_amount;
$receivePaymentObj->paymenter = $paymenter;
$receivePaymentObj->cid = $cid;
$receivePaymentObj->lawyer_id = $cObj->lawyer_id;
$receivePaymentObj->principal = $cObj->principal;
$receivePaymentObj->year = $year;
$receivePaymentObj->month = $month;
$receivePaymentObj->rtype = 1;
$receivePaymentObj->save();
DB::commit();
} catch (\Exception $exception) {
DB::rollBack();
return $this->response()->error($exception->getMessage())->refresh();
}
return $this->response()->success('提交成功')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->select('received_type', '收款账户')->options([1 => '基本户', 2 => '其它']);
$this->text('pay_method', '支付方式');
$this->date('received_at', '收款时间')->format('YYYY-MM-DD')->default(date("Y-m-d"));
$this->text('received_amount', '收款金额');
$this->text('paymenter', '付款人');
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
// 获取外部传递参数
return [];
}
}
<?php
namespace App\Admin\Forms;
use App\Command\Log;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Exception;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
use App\Models\Covenant as ModelsCovenant;
class CovenantReturnForm extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$cid = $this->payload['id'];
DB::beginTransaction();
try {
$uObj = ModelsCovenant::find($cid);
if ($uObj && $uObj->is_closed == 0) {
$uObj->is_closed = 1;
$uObj->save();
}
DB::commit();
} catch (\Exception $exception) {
DB::rollBack();
return $this->response()->error($exception->getMessage())->refresh();
}
return $this->response()->success('提交成功' . $cid)->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->text('return_fee', '退还结案费');
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
// 获取外部传递参数
return [];
}
}
......@@ -2,9 +2,13 @@
namespace App\Admin\Repositories;
use App\Models\Covenant as Model;
use App\Models\Covenant as ModelsCovenant;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
use App\Models\Principal;
use App\Models\CovenantReceivePayment;
use Dcat\Admin\Repositories\EloquentRepository;
use Dcat\Admin\Grid;
use Illuminate\Support\Facades\DB;
class Covenant extends EloquentRepository
{
......@@ -13,7 +17,7 @@ class Covenant extends EloquentRepository
*
* @var string
*/
protected $eloquentClass = Model::class;
protected $eloquentClass = ModelsCovenant::class;
//合同类型
public const CTYPE = [
......@@ -32,8 +36,196 @@ class Covenant extends EloquentRepository
2 => '付款开票'
];
public function principal()
// public function covenant()
// {
// return $this->belongsTo(ModelsCovenant::class, 'cid', 'id');
// }
public function get(Grid\Model $model)
{
// 获取当前页数
$currentPage = $model->getCurrentPage();
// 获取每页显示行数
$perPage = $model->getPerPage();
$start = ($currentPage - 1) * $perPage;
// 获取排序参数, 格式例如['id', 'asc', null]
$sort = $model->getSort();
// 获取筛选条件
$number = $model->filter()->input('number');
$cname = $model->filter()->input('cname');
$principal = $model->filter()->input('principal');
$received_at = $invoiced_at = [];
$received_at['start'] = $_GET['received_at']['start'] ?? '';
$received_at['end'] = $_GET['received_at']['end'] ?? '';
$invoiced_at['start'] = $_GET['invoiced_at']['start'] ?? '';
$invoiced_at['end'] = $_GET['invoiced_at']['end'] ?? '';
$param = [
'sort' => $sort,
'start' => $start,
'search' => ['number' => $number, 'cname' => $cname, 'principal' => $principal, 'invoiced_at' => $invoiced_at, 'received_at' => $received_at,]
];
$data = $this->getList($param);
return $model->makePaginator(
$data['total'] ?? 0, // 传入总记录数
$data['subjects'] ?? [] // 传入数据二维数组
);
}
// 获取列表数据
public function getList(array $param)
{
return $this->belongsTo(Principal::class, 'principal_id', 'id');
$prePage = $param['per_page'] ?? 20;
$start = $param['start'] ?? 0;
$number = $param['search']['number'] ?? '';
$cname = $param['search']['cname'] ?? '';
$invoiced_at = $param['search']['invoiced_at'] ?? [];
$principal = $param['search']['principal'] ?? '';
$received_at = $param['search']['received_at'] ?? [];
$list = [];
if ($invoiced_at['start'] && $received_at['start']) {
$in_start = $invoiced_at['start'] ?? '';
$in_end = $invoiced_at['end'] ?? '';
$re_start = $received_at['start'] ?? '';
$re_end = $received_at['end'] ?? '';
if ($in_start && $re_start) {
if ($in_end && $re_end) {
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereBetween('rp.received_at', [$re_start, $re_end])
->whereBetween('rp.invoiced_at', [$in_start, $in_end])
->groupBy('rp.cid');
} else {
if ($in_end) {
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.received_at', '>', $re_start)
->whereBetween('rp.invoiced_at', [$in_start, $in_end])
->groupBy('rp.cid');
} elseif ($re_end) {
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.invoiced_at', '>', $in_start)
->whereBetween('rp.received_at', [$re_start, $re_end])
->groupBy('rp.cid');
} else {
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.invoiced_at', '>', $in_start)
->whereDate('rp.received_at', '>', $re_start)
->groupBy('rp.cid');
}
}
}
// 计算列表总数
$count = $note_monitor->count();
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->orderBy('rp.cid', 'desc')->get()->toArray();
} elseif ($invoiced_at['start'] && !$received_at['start']) { //开票日期
$start = $invoiced_at['start'] ?? '';
$end = $invoiced_at['end'] ?? '';
if ($start) {
if ($end) {
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereBetween('rp.received_at', [$start, $end])
->groupBy('rp.cid');
} else {
$note_monitor = DB::table("covenant_receive_payment as rp")
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.received_at', '>', $start)
->groupBy('rp.cid');
}
// 计算列表总数
$count = $note_monitor->count();
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->orderBy('rp.cid', 'desc')->get()->toArray();
}
//
} elseif ($received_at['start'] && !$invoiced_at['start']) { //收款日期
$start = $received_at['start'] ?? '';
$end = $received_at['end'] ?? '';
if ($start) {
if ($end) {
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereBetween('rp.received_at', [$start, $end])
->groupBy('rp.cid');
} else {
$note_monitor = DB::table("covenant_receive_payment as rp")
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.received_at', '>', $start)
->groupBy('rp.cid');
}
// 计算列表总数
$count = $note_monitor->count();
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->orderBy('rp.cid', 'desc')->get()->toArray();
}
} else { //关键词搜索
$note_monitor = DB::table('covenant')->select(['id as cid', 'number', 'cname', 'principal', 'ctype']);
if ($number) {
$note_monitor = $note_monitor->where("number", $number);
}
if ($cname) {
$note_monitor = $note_monitor->where("cname", $cname);
}
if ($principal) {
$note_monitor = $note_monitor->where("principal", $principal);
}
// 计算列表总数
$count = $note_monitor->count();
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->get()->toArray();
}
foreach ($list as $key => $item) {
$tmp = [];
$tmp['cid'] = $item->cid;
$tmp['number'] = $item->number;
$tmp['cname'] = $item->cname;
$tmp['ctype'] = $item->ctype;
$tmp['principal'] = $item->principal;
$cid = $item->cid;
//开票金额
$invoiced_money = ModelsCovenantReceivePayment::where(['cid' => $cid, 'rtype' => 2])->sum('invoiced_money');
//已收款
$receipt_money = ModelsCovenantReceivePayment::where(['cid' => $cid, 'rtype' => 1])->sum('received_amount');
$tmp['invoice_amount'] = $invoiced_money;
$tmp['receipt_money'] = $receipt_money;
//已收款未开票
$receipt_noinvoice = ($receipt_money - $invoiced_money) > 0 ? $receipt_money - $invoiced_money : '-';
$tmp['receipt_noinvoice'] = $receipt_noinvoice;
//已开票未收款
$invoice_noreceipt = ($invoiced_money - $receipt_money) > 0 ? $invoiced_money - $receipt_money : '-';
$tmp['invoice_noreceipt'] = $invoice_noreceipt;
array_push($data, $tmp);
}
return [
'total' => $count,
'subjects' => $data
];
}
}
<?php
namespace App\Admin\Repositories;
use App\Models\Covenant as ModelsCovenant;
use App\Models\Principal;
use App\Models\CovenantReceivePayment;
use Dcat\Admin\Repositories\EloquentRepository;
use Dcat\Admin\Grid;
use Illuminate\Support\Facades\DB;
class CovenantReceivePaymentCollect extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = ModelsCovenant::class;
public function get(Grid\Model $model)
{
// 获取当前页数
$currentPage = $model->getCurrentPage();
// 获取每页显示行数
$perPage = $model->getPerPage();
$start = ($currentPage - 1) * $perPage;
// 获取排序参数, 格式例如['id', 'asc', null]
$sort = $model->getSort();
// 获取筛选条件
$number = $model->filter()->input('lnum');
$lname = $model->filter()->input('lname');
$cnum = $model->filter()->input('cnum');
$ctype = $model->filter()->input('ctype');
$principal = $model->filter()->input('principal');
$received_at = $invoiced_at = [];
$received_at['start'] = $_GET['received_at']['start'] ?? '';
$received_at['end'] = $_GET['received_at']['end'] ?? '';
$invoiced_at['start'] = $_GET['invoiced_at']['start'] ?? '';
$invoiced_at['end'] = $_GET['invoiced_at']['end'] ?? '';
$param = [
'sort' => $sort,
'start' => $start,
'search' => [
'lnum' => $number,
'lname' => $lname,
'cnum' => $cnum,
'ctype' => $ctype,
'principal' => $principal,
'invoiced_at' => $invoiced_at,
'received_at' => $received_at,
]
];
$data = $this->getList($param);
return $model->makePaginator(
$data['total'] ?? 0, // 传入总记录数
$data['subjects'] ?? [] // 传入数据二维数组
);
}
// 获取列表数据
public function getList(array $param)
{
$prePage = $param['per_page'] ?? 20;
$start = $param['start'] ?? 0;
$lnum = $param['search']['lnum'] ?? '';
$lname = $param['search']['lname'] ?? '';
$cnum = $param['search']['cnum'] ?? '';
$ctype = $param['search']['ctype'] ?? '';
$principal = $param['search']['principal'] ?? '';
$invoiced_at = $param['search']['invoiced_at'] ?? [];
$received_at = $param['search']['received_at'] ?? [];
$list = [];
$note_monitor = DB::table("covenant_receive_payment as rp")
->select(DB::raw('rp.cid, c.cname,c.ctype,c.number as cnum,c.principal,l.number as lnum,l.name as lname,sum(invoiced_money) as invoiced_money,sum(received_amount) as received_amount'))
//->select(['rp.cid', 'c.cname', 'c.ctype', 'c.number as cnum', 'c.principal', 'l.number as lnum', 'l.name as lname', 'sum(invoiced_money) as invoiced_money'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id');
if ($lnum) {
$note_monitor = $note_monitor->where("l.number", $lnum);
}
if ($lname) {
$note_monitor = $note_monitor->where("l.name", $lname);
}
if ($cnum) {
$note_monitor = $note_monitor->where("c.number", $cnum);
}
if ($ctype) {
$note_monitor = $note_monitor->where("c.ctype", $ctype);
}
if ($principal) {
$note_monitor = $note_monitor->where("c.principal", $principal);
}
if ($invoiced_at['start'] && $received_at['start']) {
$in_start = $invoiced_at['start'] ?? '';
$in_end = $invoiced_at['end'] ?? '';
$re_start = $received_at['start'] ?? '';
$re_end = $received_at['end'] ?? '';
if ($in_start && $re_start) {
if ($in_end && $re_end) {
$note_monitor = $note_monitor->whereBetween('rp.received_at', [$re_start, $re_end])
->whereBetween('rp.invoiced_at', [$in_start, $in_end]);
} else {
if ($in_end) {
$note_monitor = $note_monitor->whereDate('rp.received_at', '>', $re_start)
->whereBetween('rp.invoiced_at', [$in_start, $in_end]);
} elseif ($re_end) {
$note_monitor = $note_monitor->whereDate('rp.invoiced_at', '>', $in_start)
->whereBetween('rp.received_at', [$re_start, $re_end]);
} else {
$note_monitor = $note_monitor->whereDate('rp.invoiced_at', '>', $in_start)
->whereDate('rp.received_at', '>', $re_start);
}
}
}
} elseif ($invoiced_at['start'] && !$received_at['start']) { //开票日期
$start = $invoiced_at['start'] ?? '';
$end = $invoiced_at['end'] ?? '';
if ($start) {
if ($end) {
$note_monitor = $note_monitor->whereBetween('rp.received_at', [$start, $end]);
} else {
$note_monitor = $note_monitor->whereDate('rp.received_at', '>', $start);
}
}
//
} elseif ($received_at['start'] && !$invoiced_at['start']) { //收款日期
$start = $received_at['start'] ?? '';
$end = $received_at['end'] ?? '';
if ($start) {
if ($end) {
$note_monitor = $note_monitor->whereBetween('rp.received_at', [$start, $end]);
} else {
$note_monitor = $note_monitor->whereDate('rp.received_at', '>', $start);
}
}
}
// 计算列表总数
$count = 0;
$cObj = $note_monitor->groupBy('rp.cid')->get();
if ($cObj->toArray()) {
$count = count($cObj->toArray());
}
// 获取列表
$data = [];
$list = $note_monitor->groupBy('rp.cid')
->limit($prePage)
->offset($start)
->get()
->toArray();
foreach ($list as $key => $item) {
$tmp = [];
//$tmp['id'] = $item->id;
$tmp['lnum'] = $item->lnum;
$tmp['lname'] = $item->lname;
$tmp['covenant_num'] = $item->cnum;
$tmp['covenant_name'] = $item->cname;
$tmp['covenant_type'] = $item->ctype ? ModelsCovenant::CTYPE[$item->ctype] : '';
$tmp['principal'] = $item->principal;
$tmp['invoice_amount'] = $item->invoiced_money;
$tmp['receipt_money'] = $item->received_amount;
$receipt_noinvoice = $item->received_amount - $item->invoiced_money;
$tmp['receipt_noinvoice'] = $receipt_noinvoice > 0 ? $receipt_noinvoice : '-';
$invoice_noreceipt = $item->invoiced_money - $item->received_amount;
$tmp['invoice_noreceipt'] = $invoice_noreceipt > 0 ? $invoice_noreceipt : '-';
array_push($data, $tmp);
}
return [
'total' => $count,
'subjects' => $data
];
}
}
<?php
namespace App\Admin\Repositories;
use App\Models\Lawyer;
use App\Models\LawyerCost as ModelLawyerCost;
//use Dcat\Admin\Repositories\EloquentRepository;
use Dcat\Admin\Repositories\Repository;
use Dcat\Admin\Grid;
use Illuminate\Support\Collection;
class LawyerCommission extends Repository
{
/**
* Model.
*
* @var string
*/
//protected $eloquentClass = Model::class;
/**
*
*
*/
public function get(Grid\Model $model)
{
// 获取筛选条件
$year = $model->filter()->input('year') ?? date("Y");
$data = [];
$nowyear = date('Y');
$monthNum = $year >= $nowyear ? date('m') : 12;
$fieldTotal = 0;
$list = ModelLawyerCost::CommissioniTEM; //Lawyer::all();
foreach ($list as $key => $val) {
$tmp = [];
$tmp['title'] = $val['name']; //项目名称
//总计
$tmp['total'] = 0;
for ($i = 1; $i <= $monthNum; $i++) {
$tmp[$i] = '0.00';
//基本工资
if ($val['field'] == 'basic_salary') {
$basic_salary = ModelLawyerCost::where(['year' => $year, 'month' => $i])->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');
$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');
$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');
$tmp[$i] = $social_person_fee;
}
//社保企业部分
if ($val['field'] == 'social_company_fee') {
$social_company_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->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');
$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');
$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');
$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');
$tmp[$i] = $annual_inspection_fee;
}
//律所年金
if ($val['field'] == 'annuity') {
$annuity = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('annuity');
$tmp[$i] = $annuity;
}
//助理律师成本
if ($val['field'] == 'assistant_fee') {
$assistant_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->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');
$tmp[$i] = $office_rental_fee;
}
//无票成本
if ($val['field'] == 'noticket_cost') {
$noticket_cost = ModelLawyerCost::where(['year' => $year, 'month' => $i])->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');
$tmp[$i] = $personal_income_tax;
}
//总计
$tmp['total'] += $tmp[$i];
}
$data[$key] = $tmp;
}
// echo "<pre>";
// print_r($data);
// die;
return $data;
// $data = [
// ['id' => 1, 'year' => '2016', 'jzsqNum' => '100', 'jzhpNum' => '100', 'sbTotal' => '100'],
// ['id' => 2, 'year' => '2017', 'jzsqNum' => '100', 'jzhpNum' => '100', 'sbTotal' => '100']
// ];
// return $data;
}
}
......@@ -18,10 +18,31 @@ class LawyerCost extends Repository
* @var string
*/
//protected $eloquentClass = Model::class;
public const COSTiTEM = [
['field' => 'basic_salary', 'name' => '基本工资'],
['field' => 'special_additional', 'name' => '专项附加'],
['field' => 'social', 'name' => '社保'],
['field' => 'social_person_fee', 'name' => '社保个人部分'],
['field' => 'social_company_fee', 'name' => '社保单位部分'],
['field' => 'accumulation_fund', 'name' => '公积金'],
[
'field' => 'accumulation_fund_person_fee',
'name' => '公积金个人部分'
],
['field' => 'accumulation_fund_company_fee', 'name' => '公积金单位部分'],
['field' => 'annual_inspection_fee', 'name' => '律所年检费'],
['field' => 'annuity', 'name' => '律所年金'],
['field' => 'posting_tickets_fee', 'name' => '贴票成本'],
['field' => 'assistant_fee', 'name' => '助理律师成本'],
['field' => 'office_rental_fee', 'name' => '办公室租赁成本'],
['field' => 'noticket_cost', 'name' => '无票成本'],
['field' => 'personal_income_tax', 'name' => '个人所得税'],
['field' => 'total', 'name' => '合计'],
];
/**
* 各学部申报情况
* 项目类型 数理 化学 生命 地学 工材 信息 管理 医学 交叉 其他 总计
*
*
*/
public function get(Grid\Model $model)
{
......@@ -32,24 +53,155 @@ public function get(Grid\Model $model)
$nowyear = date('Y');
$monthNum = $year >= $nowyear ? date('m') : 12;
$fieldTotal = 0;
$list = ModelLawyerCost::COSTiTEM; //Lawyer::all();
foreach ($list as $key => $val) {
$tmp = [];
$tmp['title'] = $val['name']; //项目名称
//总计
$total = 10;
$tmp['total'] = 0;
for ($i = 1; $i <= $monthNum; $i++) {
$tmp[$i] = $i;
}
$tmp[$i] = '0.00';
//基本工资
if ($val['field'] == 'basic_salary') {
$basic_salary = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('basic_salary');
$tmp[$i] = $basic_salary;
$fieldTotal += $basic_salary;
}
//总计
$tmp['total'] = $total;
//专项附加
if ($val['field'] == 'special_additional') {
$special_additional = ModelLawyerCost::where(['year' => $year, 'month' => $i])->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');
$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');
$tmp[$i] = $social_person_fee;
}
//社保企业部分
if ($val['field'] == 'social_company_fee') {
$social_company_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->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');
$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');
$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');
$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');
$tmp[$i] = $annual_inspection_fee;
}
//律所年金
if ($val['field'] == 'annuity') {
$annuity = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('annuity');
$tmp[$i] = $annuity;
}
//助理律师成本
if ($val['field'] == 'assistant_fee') {
$assistant_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('assistant_fee');
$tmp[$i] = $assistant_fee;
}
array_push($data, $tmp);
//办公室租赁成本
if ($val['field'] == 'office_rental_fee') {
$office_rental_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->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');
$tmp[$i] = $noticket_cost;
}
//个人所得税
if ($val['field'] == 'personal_income_tax') {
$personal_income_tax = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('personal_income_tax');
$tmp[$i] = $personal_income_tax;
}
//总计
$tmp['total'] += $tmp[$i];
}
$data[$key] = $tmp;
}
//总计
//初始化
$heji = ['title' => '合计', 'total' => 0];
for ($i = 0; $i <= $monthNum; $i++) {
array_push($heji, 0);
}
unset($heji[0]);
foreach ($data as $key => $item) {
if (isset($item[1])) {
$heji[1] += $item[1];
}
if (isset($item[2])) {
$heji[2] += $item[2];
}
if (isset($item[3])) {
$heji[3] += $item[3];
}
if (isset($item[4])) {
$heji[4] += $item[4];
}
if (isset($item[5])) {
$heji[5] += $item[5];
}
if (isset($item[6])) {
$heji[6] += $item[6];
}
if (isset($item[7])) {
$heji[7] += $item[7];
}
if (isset($item[8])) {
$heji[8] += $item[8];
}
if (isset($item[9])) {
$heji[9] += $item[9];
}
if (isset($item[10])) {
$heji[10] += $item[10];
}
if (isset($item[11])) {
$heji[11] += $item[11];
}
if (isset($item[12])) {
$heji[12] += $item[12];
}
if (isset($item['total'])) {
$heji['total'] += $item['total'];
}
}
array_push($data, $heji);
return $data;
// $data = [
// ['id' => 1, 'year' => '2016', 'jzsqNum' => '100', 'jzhpNum' => '100', 'sbTotal' => '100'],
......
<?php
namespace App\Admin\Repositories;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
use Dcat\Admin\Repositories\EloquentRepository;
use Dcat\Admin\Grid;
use Illuminate\Support\Facades\DB;
class LawyerInvoicedPaymentCollect extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = ModelsCovenantReceivePayment::class;
public function get(Grid\Model $model)
{
// 获取筛选条件
$year = $model->filter()->input('year');
$param = [
'search' => [
'year' => $year
]
];
$data = $this->getList($param);
return $data;
}
// 获取列表数据
public function getList(array $param)
{
$year = $param['search']['year'] ?? '';
$nowyear = date("Y");
$monthNum = ($year && $year < $nowyear) ? 12 : date('m');
$data = [];
for ($i = 1; $i <= $monthNum; $i++) {
$received_amount = ModelsCovenantReceivePayment::where(['rtype' => 2, 'year' => $year, 'month' => $i])->sum('invoiced_money');
$data[$i] = $received_amount;
}
return [$data];
}
}
<?php
namespace App\Admin\Repositories;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
use Dcat\Admin\Repositories\EloquentRepository;
use Dcat\Admin\Grid;
use Illuminate\Support\Facades\DB;
class LawyerReceivePaymentCollect extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = ModelsCovenantReceivePayment::class;
public function get(Grid\Model $model)
{
// 获取筛选条件
$year = $model->filter()->input('year');
$param = [
'search' => [
'year' => $year
]
];
$data = $this->getList($param);
return $data;
}
// 获取列表数据
public function getList(array $param)
{
$year = $param['search']['year'] ?? '';
$nowyear = date("Y");
$monthNum = ($year && $year < $nowyear) ? 12 : date('m');
$data = [];
for ($i = 1; $i <= $monthNum; $i++) {
$received_amount = ModelsCovenantReceivePayment::where(['rtype' => 1, 'year' => $year, 'month' => $i])->sum('received_amount');
$data[$i] = $received_amount;
}
return [$data];
}
}
......@@ -58,43 +58,24 @@
$router->resource('lawyer_income', 'LawyerIncomeController'); //律师创收表
$router->resource('lawyer-covenant-income', 'LawyerCovenantIncomeController'); //创收收款表
$router->resource('project_type', 'ProjectTypeController'); //项目类型
$router->resource('receive_payment', 'ReceivePaymentController'); //已收款/已开票汇总
$router->resource('user_type', 'UserTypeController'); //人员类型
$router->resource('project_apply', 'ProjectApplyController'); //历年项目申请表
$router->resource('project_ratify', 'ProjectRatifyController'); //历年项目获批表
$router->resource('lawyer-covenant-income', 'LawyerCovenantIncomeController'); //创收收款表
$router->resource('senior_professional', 'SeniorProfessionalController'); //高级职称参与表
$router->resource('view-covenant-received', 'ViewCovenantReceivedController'); //创收收款表--查看收款信息
/********************************** 历年 *****************************/
$router->resource('linian/declaration', 'DeclarationController'); //申报统计
Route::get('nd/declarationExport', 'DeclarationController@export'); //导出
$router->resource('view-covenant-invoiced', 'ViewCovenantInvoicedController'); //创收收款表--查看开票信息
$router->resource('linian/ratify', 'LnRatifyController'); //获批统计
Route::get('ln/ratifyExport', 'LnRatifyController@export'); //导出
$router->resource('lawyer_commission', 'LawyerCommissionController'); //律师提成表
$router->resource('linian/applyratify', 'LnApplyratifyController'); //申报获批汇总
Route::get('ln/applyRatifyExport', 'LnApplyratifyController@export'); //导出
$router->resource('lawyer-commission-collect', 'LawyerCommissionCollectController'); //律师提成 查看汇总
$router->resource('linian/jyapplyratify', 'LnJyApplyratifyController'); //杰优、青优申报获批汇总
Route::get('ln/jyApplyratifyExport', 'LnJyApplyratifyController@export'); //导出
$router->resource('lawyer_collect', 'LawyerCollectController'); //律师汇总表
$router->resource('linian/department', 'LnDepartmentController'); //院系所历年获批
Route::get('ln/departmentExport', 'LnDepartmentController@export'); //导出
$router->resource('covenant_receive_invoice', 'CovenantReceivePaymentController'); //开票收款汇总表
$router->resource('linian/hospital', 'LnHospitalController'); //院系所历年获批
Route::get('ln/hospitalExport', 'LnHospitalController@export'); //导出
$router->resource('linian/msratify', 'LnMsRatifyController'); //面上项目历年获批
Route::get('ln/msRatifyExport', 'LnMsRatifyController@export'); //导出
$router->resource('linian/qnratify', 'LnQnRatifyController'); //青年项目历年获批
Route::get('ln/qnRatifyExport', 'LnQnRatifyController@export'); //导出
});
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
class CovenantReceivePayment extends Model
{
use HasDateTimeFormatter;
protected $table = 'covenant_receive_payment';
//账户类型
public const RECEIVEDTYPE = [
1 => '基本户',
2 => '其它',
];
//已收款未开票
public static function getReceiptNoinvoice($lawyer_id = 0)
{
$where = [];
if ($lawyer_id) {
$where['lawyer_id'] = $lawyer_id;
}
//开票金额
$invoiced_money = self::where(['rtype' => 2])->where($where)
->sum('invoiced_money');
//已收款
$receipt_money = self::where(['rtype' => 1])->where($where)
->sum('received_amount');
//已收款未开票
$receipt_noinvoice = ($receipt_money - $invoiced_money) > 0 ? $receipt_money - $invoiced_money : 0;
return $receipt_noinvoice;
}
//已开票未收款
public static function getInvoiceNoreceipt($lawyer_id = 0)
{
$where = [];
if ($lawyer_id) {
$where['lawyer_id'] = $lawyer_id;
}
//开票金额
$invoiced_money = self::where(['lawyer_id' => $lawyer_id, 'rtype' => 2])->where($where)
->sum('invoiced_money');
//已收款
$receipt_money = self::where(['lawyer_id' => $lawyer_id, 'rtype' => 1])->where($where)
->sum('received_amount');
$invoice_noreceipt = ($invoiced_money - $receipt_money) > 0 ? $invoiced_money - $receipt_money : 0;
return $invoice_noreceipt;
}
//创收已收款
public static function getReceivedMoney($lawyer_id = 0, $year = 0)
{
$where = ['rtype' => 1];
if ($lawyer_id) {
$where['lawyer_id'] = $lawyer_id;
}
if ($year) {
$where['year'] = $year;
}
$money = self::where($where)
->sum('received_amount');
return $money;
}
//开票金额
public static function getInvoicedMoney($lawyer_id = 0, $year = 0)
{
$where = ['rtype' => 2];
if ($lawyer_id) {
$where['lawyer_id'] = $lawyer_id;
}
if ($year) {
$where['year'] = $year;
}
$money = self::where($where)
->sum('invoiced_money');
return $money;
}
}
......@@ -8,7 +8,6 @@
class Lawyer extends Model
{
use HasDateTimeFormatter;
use HasDateTimeFormatter;
protected $table = 'lawyer';
}
......@@ -31,7 +31,7 @@ class LawyerCost extends Model
public const COSTiTEM = [
['field' => 'basic_salary', 'name' => '基本工资'],
['field' => 'special_additional', 'name' => '专项附加'],
['field' => 'social_person_fee', 'name' => '社保'],
['field' => 'social', 'name' => '社保'],
['field' => 'social_person_fee', 'name' => '社保个人部分'],
['field' => 'social_company_fee', 'name' => '社保单位部分'],
['field' => 'accumulation_fund', 'name' => '公积金'],
......@@ -44,6 +44,116 @@ class LawyerCost extends Model
['field' => 'office_rental_fee', 'name' => '办公室租赁成本'],
['field' => 'noticket_cost', 'name' => '无票成本'],
['field' => 'personal_income_tax', 'name' => '个人所得税'],
['field' => 'total', 'name' => '合计'],
];
public const CommissioniTEM = [
['field' => 'received_money', 'name' => '创收已收款'],
['field' => 'commission_rate', 'name' => '提成比例'],
['field' => 'royalty_amount', 'name' => '可提成金额'],
['field' => 'paid_amount', 'name' => '已支付款项'],
['field' => 'basic_salary', 'name' => '1.基本工资'],
['field' => 'special_additional', 'name' => '2.专项附加'],
['field' => 'social_company_fee', 'name' => '3.社保(单位)'],
['field' => 'accumulation_fund_company_fee', 'name' => '4.公积金(单位)'],
['field' => 'annual_inspection_fee', 'name' => '5.律师年检费'],
['field' => 'annuity', 'name' => '6.律师年金'],
['field' => 'office_rental_fee', 'name' => '7.办公室租金'],
['field' => 'assistant_fee', 'name' => '8.助理律师成本'],
['field' => 'advance_fee', 'name' => '9.预支款'],
['field' => 'reserved_closing_fee', 'name' => '10.预留结案费'],
['field' => 'posting_tickets_money', 'name' => '贴票金额'],
['field' => 'commission_retention', 'name' => '提成留底'],
['field' => 'payable_commission_amount', 'name' => '可支付提成结算金额'],
['field' => 'personal_income_tax', 'name' => '个人所得税'],
];
//基本工资
public static function getBasiSalary($lawyer_id)
{
return self::where(['lawyer_id' => $lawyer_id])->sum('basic_salary');
}
//专项附加
public static function getSpecialAdditional($lawyer_id)
{
return self::where(['lawyer_id' => $lawyer_id])->sum('special_additional');
}
//社保
public static function getSocial($lawyer_id)
{
$social_person_fee = self::where(['lawyer_id' => $lawyer_id])->sum('social_person_fee');
$social_company_fee = self::where(['lawyer_id' => $lawyer_id])->sum('social_company_fee');
return $social_person_fee + $social_company_fee;
}
//公积金
public static function getAccumulationFund($lawyer_id)
{
$accumulation_fund_person_fee = self::where(['lawyer_id' => $lawyer_id])->sum('accumulation_fund_person_fee');
$accumulation_fund_company_fee = self::where(['lawyer_id' => $lawyer_id])->sum('accumulation_fund_company_fee');
return $accumulation_fund_person_fee + $accumulation_fund_company_fee;
}
//预支款
public static function getAdvanceFee($lawyer_id)
{
return self::where(['lawyer_id' => $lawyer_id])->sum('advance_fee');
}
//已支付款项
public static function getPaidAmount($lawyer_id, $year = 0)
{
$paid_amount = 0;
$where = ['lawyer_id' => $lawyer_id];
if ($year) {
$where['year'] = $year;
}
$list = self::where($where)->get();
if ($list->toArray()) {
$basic_salary = $special_additional = $social_company_fee = $accumulation_fund_company_fee = 0;
$annual_inspection_fee = $annuity = $office_rental_fee = $assistant_fee = 0;
foreach ($list as $item) {
$basic_salary += $item->basic_salary;
$special_additional += $item->special_additional;
$social_company_fee += $item->social_company_fee;
$accumulation_fund_company_fee += $item->accumulation_fund_company_fee;
$annual_inspection_fee += $item->annual_inspection_fee;
$annuity += $item->annuity;
$office_rental_fee += $item->office_rental_fee;
$assistant_fee += $item->assistant_fee;
}
$paid_amount = $basic_salary + $special_additional + $social_company_fee + $accumulation_fund_company_fee + $annual_inspection_fee + $annuity + $office_rental_fee + $assistant_fee;
}
return $paid_amount;
}
/**
* 贴票金额
* commission_rate 提成比例
* ticket_ratio 贴票比例
*/
public static function getPostingTicketsMoney($lawyer_id, $year, $commission_rate, $ticket_ratio)
{
$ticket = 0;
$received_money = CovenantReceivePayment::getReceivedMoney($lawyer_id, $year); //创收已收款
$paid_amount = LawyerCost::getPaidAmount($lawyer_id, $year); //已支付款项
$commission = $received_money * ($commission_rate / 100); //提成
if ($commission_rate == 80) {
if ($commission > 300000) {
$ticket = ($received_money - $paid_amount) * ($ticket_ratio / 100);
}
} elseif ($commission_rate == 85) {
if ($commission > 200000) {
$ticket = ($received_money - $paid_amount) * ($ticket_ratio / 100);
}
} elseif ($commission_rate == 88 || $commission_rate == 90) {
if ($commission > 200000) {
$ticket = ($received_money - $paid_amount) * ($ticket_ratio / 100);
}
}
return $ticket;
}
}
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