update
This commit is contained in:
parent
1da8d86ec3
commit
4d580cab2a
@ -16,8 +16,12 @@ namespace app\adminapi\lists\project;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectCostTempSet;
|
||||
use app\common\model\project\ProjectTravelReimbursement;
|
||||
use app\common\model\project\ProjectTravelReimbursementDetail;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\project\ProjectTripApply;
|
||||
|
||||
|
||||
/**
|
||||
@ -54,11 +58,42 @@ class ProjectTravelReimbursementDetailLists extends BaseAdminDataLists implement
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return ProjectTravelReimbursementDetail::where($this->searchWhere)
|
||||
->field(['id', 'travel_reimbursement_id', 'project_cost_temp_id', 'traffic_fee', 'stay_fee', 'restaurant_fee', 'subsidy_fee', 'other_fee', 'remark'])
|
||||
$params = $this->request->get(['trip_reimbursement_code','project_code','trip_apply_code']);
|
||||
$where = [];
|
||||
if(isset($params['trip_reimbursement_code']) && $params['trip_reimbursement_code']){
|
||||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_reimbursement_code','like','%'.$params['trip_reimbursement_code'].'%')->column('id');
|
||||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||||
}
|
||||
if(isset($params['project_code']) && $params['project_code']){
|
||||
$project_ids = Project::where('project_code','like','%'.$params['project_code'].'%')->column('id');
|
||||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('project_id','in',$project_ids)->column('id');
|
||||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||||
}
|
||||
if(isset($params['trip_apply_code']) && $params['trip_apply_code']){
|
||||
$trip_apply_ids = ProjectTripApply::where('trip_apply_code','like','%'.$params['trip_apply_code'].'%')->column('id');
|
||||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_apply_id','in',$trip_apply_ids)->column('id');
|
||||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||||
}
|
||||
return ProjectTravelReimbursementDetail::where($this->searchWhere)->where($where)
|
||||
->field('id,travel_reimbursement_id,project_cost_temp_id,traffic_fee,stay_fee,restaurant_fee,subsidy_fee,other_fee,total_amount,remark')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->select()->each(function($data){
|
||||
$travel_reimbursement = ProjectTravelReimbursement::field('trip_reimbursement_code,trip_apply_id,project_id,apply_user,apply_date')->where('id',$data['travel_reimbursement_id'])->findOrEmpty();
|
||||
$project_cost_temp = ProjectCostTempSet::field('first_level_subject,second_level_subject,third_level_subject')->where('id',$data['project_cost_temp_id'])->findOrEmpty();
|
||||
$trip_apply = ProjectTripApply::field('trip_apply_code')->where('id',$travel_reimbursement['trip_apply_id'])->findOrEmpty();
|
||||
$project = Project::field('name,project_code')->where('id',$travel_reimbursement['project_id'])->findOrEmpty();
|
||||
$data['trip_apply_code'] = $trip_apply['trip_apply_code'];
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['trip_reimbursement_code'] = $travel_reimbursement['trip_reimbursement_code'];
|
||||
$data['apply_user'] = $travel_reimbursement['apply_user'];
|
||||
$data['apply_date'] = $travel_reimbursement['apply_date'];
|
||||
$data['first_level_subject'] = $project_cost_temp['first_level_subject'];
|
||||
$data['second_level_subject'] = $project_cost_temp['second_level_subject'];
|
||||
$data['third_level_subject'] = $project_cost_temp['third_level_subject'];
|
||||
return $data;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
@ -71,7 +106,23 @@ class ProjectTravelReimbursementDetailLists extends BaseAdminDataLists implement
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return ProjectTravelReimbursementDetail::where($this->searchWhere)->count();
|
||||
$params = $this->request->get(['trip_reimbursement_code','project_code','trip_apply_code']);
|
||||
$where = [];
|
||||
if(isset($params['trip_reimbursement_code']) && $params['trip_reimbursement_code']){
|
||||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_reimbursement_code','like','%'.$params['trip_reimbursement_code'].'%')->column('id');
|
||||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||||
}
|
||||
if(isset($params['project_code']) && $params['project_code']){
|
||||
$project_ids = Project::where('project_code','like','%'.$params['project_code'].'%')->column('id');
|
||||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('project_id','in',$project_ids)->column('id');
|
||||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||||
}
|
||||
if(isset($params['trip_apply_code']) && $params['trip_apply_code']){
|
||||
$trip_apply_ids = ProjectTripApply::where('trip_apply_code','like','%'.$params['trip_apply_code'].'%')->column('id');
|
||||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_apply_id','in',$trip_apply_ids)->column('id');
|
||||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||||
}
|
||||
return ProjectTravelReimbursementDetail::where($this->searchWhere)->where($where)->count();
|
||||
}
|
||||
|
||||
}
|
@ -16,8 +16,11 @@ namespace app\adminapi\lists\project;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectTravelReimbursement;
|
||||
use app\common\model\project\ProjectTravelReimbursementInvoiceDetail;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\project\ProjectTripApply;
|
||||
|
||||
|
||||
/**
|
||||
@ -38,7 +41,8 @@ class ProjectTravelReimbursementInvoiceDetailLists extends BaseAdminDataLists im
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['travel_reimbursement_id', 'invoice_type', 'invoice_sn', 'invoice_form'],
|
||||
'=' => ['travel_reimbursement_id', 'invoice_type', 'invoice_form'],
|
||||
'%like%' => ['invoice_sn']
|
||||
];
|
||||
}
|
||||
|
||||
@ -54,11 +58,41 @@ class ProjectTravelReimbursementInvoiceDetailLists extends BaseAdminDataLists im
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return ProjectTravelReimbursementInvoiceDetail::where($this->searchWhere)
|
||||
->field(['id', 'travel_reimbursement_id', 'invoice_type', 'invoice_sn', 'tax_rate', 'invoice_form', 'invoice_amount', 'tax_amount', 'annex', 'remark'])
|
||||
$params = $this->request->get(['trip_reimbursement_code','project_code','trip_apply_code']);
|
||||
$where = [];
|
||||
if(isset($params['trip_reimbursement_code']) && $params['trip_reimbursement_code']){
|
||||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_reimbursement_code','like','%'.$params['trip_reimbursement_code'].'%')->column('id');
|
||||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||||
}
|
||||
if(isset($params['project_code']) && $params['project_code']){
|
||||
$project_ids = Project::where('project_code','like','%'.$params['project_code'].'%')->column('id');
|
||||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('project_id','in',$project_ids)->column('id');
|
||||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||||
}
|
||||
if(isset($params['trip_apply_code']) && $params['trip_apply_code']){
|
||||
$trip_apply_ids = ProjectTripApply::where('trip_apply_code','like','%'.$params['trip_apply_code'].'%')->column('id');
|
||||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_apply_id','in',$trip_apply_ids)->column('id');
|
||||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||||
}
|
||||
return ProjectTravelReimbursementInvoiceDetail::where($this->searchWhere)->where($where)
|
||||
->field(['id', 'travel_reimbursement_id', 'invoice_type', 'invoice_sn', 'tax_rate', 'invoice_form', 'invoice_amount', 'tax_amount', 'remark'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->select()->each(function($data){
|
||||
$travel_reimbursement = ProjectTravelReimbursement::field('trip_reimbursement_code,trip_apply_id,project_id,apply_user,apply_date')->where('id',$data['travel_reimbursement_id'])->findOrEmpty();
|
||||
$trip_apply = ProjectTripApply::field('trip_apply_code')->where('id',$travel_reimbursement['trip_apply_id'])->findOrEmpty();
|
||||
$project = Project::field('name,project_code')->where('id',$travel_reimbursement['project_id'])->findOrEmpty();
|
||||
$data['trip_apply_code'] = $trip_apply['trip_apply_code'];
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['trip_reimbursement_code'] = $travel_reimbursement['trip_reimbursement_code'];
|
||||
$data['apply_user'] = $travel_reimbursement['apply_user'];
|
||||
$data['apply_date'] = $travel_reimbursement['apply_date'];
|
||||
$data['invoice_type'] = $data->invoice_type_text;
|
||||
$data['tax_rate'] = $data->tax_rate_text;
|
||||
$data['invoice_form'] = $data->invoice_form_text;
|
||||
return $data;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
@ -71,7 +105,23 @@ class ProjectTravelReimbursementInvoiceDetailLists extends BaseAdminDataLists im
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return ProjectTravelReimbursementInvoiceDetail::where($this->searchWhere)->count();
|
||||
$params = $this->request->get(['trip_reimbursement_code','project_code','trip_apply_code']);
|
||||
$where = [];
|
||||
if(isset($params['trip_reimbursement_code']) && $params['trip_reimbursement_code']){
|
||||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_reimbursement_code','like','%'.$params['trip_reimbursement_code'].'%')->column('id');
|
||||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||||
}
|
||||
if(isset($params['project_code']) && $params['project_code']){
|
||||
$project_ids = Project::where('project_code','like','%'.$params['project_code'].'%')->column('id');
|
||||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('project_id','in',$project_ids)->column('id');
|
||||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||||
}
|
||||
if(isset($params['trip_apply_code']) && $params['trip_apply_code']){
|
||||
$trip_apply_ids = ProjectTripApply::where('trip_apply_code','like','%'.$params['trip_apply_code'].'%')->column('id');
|
||||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_apply_id','in',$trip_apply_ids)->column('id');
|
||||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||||
}
|
||||
return ProjectTravelReimbursementInvoiceDetail::where($this->searchWhere)->where($where)->count();
|
||||
}
|
||||
|
||||
}
|
@ -22,6 +22,7 @@ use app\common\model\project\ProjectLoanApply;
|
||||
use app\common\model\project\ProjectManagerAppointment;
|
||||
use app\common\model\project\ProjectTravelReimbursement;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\project\ProjectTravelReimbursementDetail;
|
||||
use app\common\model\project\ProjectTripApply;
|
||||
|
||||
|
||||
@ -60,7 +61,7 @@ class ProjectTravelReimbursementLists extends BaseAdminDataLists implements List
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$field = 'id,trip_apply_id,project_id,trip_reimbursement_code,reimbursement_type,loan_apply_id,reimbursement_amount,actual_reimbursement_amount,offset_loan_amount,apply_user,apply_date,remark';
|
||||
$field = 'id,trip_apply_id,project_id,trip_reimbursement_code,reimbursement_type,loan_apply_id,offset_loan_amount,apply_user,apply_date,remark';
|
||||
return ProjectTravelReimbursement::where($this->searchWhere)
|
||||
->field($field)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
@ -83,6 +84,8 @@ class ProjectTravelReimbursementLists extends BaseAdminDataLists implements List
|
||||
$data['loan_amount'] = !$loan_apply->isEmpty() ? $loan_apply['loan_amount'] : '---';
|
||||
$data['reimbursement_type'] = $data->reimbursement_type_text;
|
||||
unset($data['trip_apply_id'],$data['loan_apply_id']);
|
||||
$data['total_amount'] = ProjectTravelReimbursementDetail::where('travel_reimbursement_id',$data['id'])->sum('total_amount');
|
||||
$data['pay_amount'] = $data['total_amount'] - $data['offset_loan_amount'];
|
||||
return $data;
|
||||
})
|
||||
->toArray();
|
||||
|
@ -15,6 +15,8 @@
|
||||
namespace app\adminapi\logic\project;
|
||||
|
||||
|
||||
use app\common\model\project\ProjectCostTempSet;
|
||||
use app\common\model\project\ProjectTravelReimbursement;
|
||||
use app\common\model\project\ProjectTravelReimbursementDetail;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
@ -43,14 +45,14 @@ class ProjectTravelReimbursementDetailLogic extends BaseLogic
|
||||
ProjectTravelReimbursementDetail::create([
|
||||
'travel_reimbursement_id' => $params['travel_reimbursement_id'],
|
||||
'project_cost_temp_id' => $params['project_cost_temp_id'],
|
||||
'traffic_fee' => $params['traffic_fee'],
|
||||
'stay_fee' => $params['stay_fee'],
|
||||
'restaurant_fee' => $params['restaurant_fee'],
|
||||
'subsidy_fee' => $params['subsidy_fee'],
|
||||
'other_fee' => $params['other_fee'],
|
||||
'remark' => $params['remark'],
|
||||
'traffic_fee' => $params['traffic_fee'] ?? 0,
|
||||
'stay_fee' => $params['stay_fee'] ?? 0,
|
||||
'restaurant_fee' => $params['restaurant_fee'] ?? 0,
|
||||
'subsidy_fee' => $params['subsidy_fee'] ?? 0,
|
||||
'other_fee' => $params['other_fee'] ?? 0,
|
||||
'total_amount' => $params['traffic_fee'] + $params['stay_fee'] + $params['restaurant_fee'] + $params['subsidy_fee'] + $params['other_fee'],
|
||||
'remark' => $params['remark'] ?? '',
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -75,14 +77,15 @@ class ProjectTravelReimbursementDetailLogic extends BaseLogic
|
||||
ProjectTravelReimbursementDetail::where('id', $params['id'])->update([
|
||||
'travel_reimbursement_id' => $params['travel_reimbursement_id'],
|
||||
'project_cost_temp_id' => $params['project_cost_temp_id'],
|
||||
'traffic_fee' => $params['traffic_fee'],
|
||||
'stay_fee' => $params['stay_fee'],
|
||||
'restaurant_fee' => $params['restaurant_fee'],
|
||||
'subsidy_fee' => $params['subsidy_fee'],
|
||||
'other_fee' => $params['other_fee'],
|
||||
'remark' => $params['remark'],
|
||||
'traffic_fee' => $params['traffic_fee'] ?? 0,
|
||||
'stay_fee' => $params['stay_fee'] ?? 0,
|
||||
'restaurant_fee' => $params['restaurant_fee'] ?? 0,
|
||||
'subsidy_fee' => $params['subsidy_fee'] ?? 0,
|
||||
'other_fee' => $params['other_fee'] ?? 0,
|
||||
'total_amount' => $params['traffic_fee'] + $params['stay_fee'] + $params['restaurant_fee'] + $params['subsidy_fee'] + $params['other_fee'],
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'update_time' => time(),
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -115,6 +118,13 @@ class ProjectTravelReimbursementDetailLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return ProjectTravelReimbursementDetail::findOrEmpty($params['id'])->toArray();
|
||||
$data = ProjectTravelReimbursementDetail::field('id,travel_reimbursement_id,project_cost_temp_id,traffic_fee,stay_fee,restaurant_fee,subsidy_fee,other_fee,total_amount,remark')->findOrEmpty($params['id']);
|
||||
$travel_reimbursement = ProjectTravelReimbursement::field('trip_reimbursement_code')->where('id',$data['travel_reimbursement_id'])->findOrEmpty();
|
||||
$project_cost_temp = ProjectCostTempSet::field('first_level_subject,second_level_subject,third_level_subject')->where('id',$data['project_cost_temp_id'])->findOrEmpty();
|
||||
$data['trip_reimbursement_code'] = $travel_reimbursement['trip_reimbursement_code'];
|
||||
$data['first_level_subject'] = $project_cost_temp['first_level_subject'];
|
||||
$data['second_level_subject'] = $project_cost_temp['second_level_subject'];
|
||||
$data['third_level_subject'] = $project_cost_temp['third_level_subject'];
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -15,6 +15,8 @@
|
||||
namespace app\adminapi\logic\project;
|
||||
|
||||
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\project\ProjectTravelReimbursement;
|
||||
use app\common\model\project\ProjectTravelReimbursementInvoiceDetail;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
@ -38,6 +40,8 @@ class ProjectTravelReimbursementInvoiceDetailLogic extends BaseLogic
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
//获取税率
|
||||
$tax_rate = DictData::where('type_value','tax_rate')->column('name','value');
|
||||
Db::startTrans();
|
||||
try {
|
||||
ProjectTravelReimbursementInvoiceDetail::create([
|
||||
@ -47,11 +51,10 @@ class ProjectTravelReimbursementInvoiceDetailLogic extends BaseLogic
|
||||
'tax_rate' => $params['tax_rate'],
|
||||
'invoice_form' => $params['invoice_form'],
|
||||
'invoice_amount' => $params['invoice_amount'],
|
||||
'tax_amount' => $params['tax_amount'],
|
||||
'annex' => $params['annex'],
|
||||
'remark' => $params['remark'],
|
||||
'tax_amount' => $tax_rate[$params['tax_rate']] / 100 * $params['invoice_amount'],
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
'remark' => $params['remark'] ?? '',
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -71,6 +74,8 @@ class ProjectTravelReimbursementInvoiceDetailLogic extends BaseLogic
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
//获取税率
|
||||
$tax_rate = DictData::where('type_value','tax_rate')->column('name','value');
|
||||
Db::startTrans();
|
||||
try {
|
||||
ProjectTravelReimbursementInvoiceDetail::where('id', $params['id'])->update([
|
||||
@ -80,11 +85,11 @@ class ProjectTravelReimbursementInvoiceDetailLogic extends BaseLogic
|
||||
'tax_rate' => $params['tax_rate'],
|
||||
'invoice_form' => $params['invoice_form'],
|
||||
'invoice_amount' => $params['invoice_amount'],
|
||||
'tax_amount' => $params['tax_amount'],
|
||||
'annex' => $params['annex'],
|
||||
'remark' => $params['remark'],
|
||||
'tax_amount' => $tax_rate[$params['tax_rate']] / 100 * $params['invoice_amount'],
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'update_time' => time(),
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -117,6 +122,12 @@ class ProjectTravelReimbursementInvoiceDetailLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return ProjectTravelReimbursementInvoiceDetail::findOrEmpty($params['id'])->toArray();
|
||||
$data = ProjectTravelReimbursementInvoiceDetail::field('id,travel_reimbursement_id,invoice_type,invoice_sn,tax_rate,invoice_form,invoice_amount,tax_amount,annex,remark')->findOrEmpty($params['id']);
|
||||
$travel_reimbursement = ProjectTravelReimbursement::field('trip_reimbursement_code')->where('id',$data['travel_reimbursement_id'])->findOrEmpty();
|
||||
$data['trip_reimbursement_code'] = $travel_reimbursement['trip_reimbursement_code'];
|
||||
$data['invoice_type_text'] = $data->invoice_type_text;
|
||||
$data['tax_rate_text'] = $data->tax_rate_text;
|
||||
$data['invoice_form_text'] = $data->invoice_form_text;
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -48,11 +48,6 @@ class ProjectTravelReimbursementLogic extends BaseLogic
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
$trip_apply = ProjectTripApply::field('project_id')->where('id',$params['trip_apply_id'])->findOrEmpty();
|
||||
//初始报销金额 = 所有报销明细中的交通、住宿、餐饮、补助、其他金额之和
|
||||
$reimbursement_amount = 0;
|
||||
foreach($params['reimbursement_detail'] as $v){
|
||||
$reimbursement_amount += ($v['traffic_fee'] + $v['stay_fee'] + $v['restaurant_fee'] + $v['subsidy_fee'] + $v['other_fee']);
|
||||
}
|
||||
//获取税率
|
||||
$tax_rate = DictData::where('type_value','tax_rate')->column('name','value');
|
||||
Db::startTrans();
|
||||
@ -63,8 +58,6 @@ class ProjectTravelReimbursementLogic extends BaseLogic
|
||||
'project_id' => $trip_apply['project_id'],
|
||||
'reimbursement_type' => $params['reimbursement_type'],
|
||||
'loan_apply_id' => $params['loan_apply_id'] ?? 0,
|
||||
'reimbursement_amount' => $reimbursement_amount,//初始报销金额
|
||||
'actual_reimbursement_amount' => $reimbursement_amount - $params['offset_loan_amount'],//实际报销金额
|
||||
'offset_loan_amount' => $params['offset_loan_amount'] ?? 0,//冲抵借款金额
|
||||
'apply_user' => $params['apply_user'],
|
||||
'apply_date' => strtotime($params['apply_date']),
|
||||
@ -121,11 +114,6 @@ class ProjectTravelReimbursementLogic extends BaseLogic
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
$trip_apply = ProjectTripApply::field('project_id')->where('id',$params['trip_apply_id'])->findOrEmpty();
|
||||
//初始报销金额 = 所有报销明细中的交通、住宿、餐饮、补助、其他金额之和
|
||||
$reimbursement_amount = 0;
|
||||
foreach($params['reimbursement_detail'] as $v){
|
||||
$reimbursement_amount += ($v['traffic_fee'] + $v['stay_fee'] + $v['restaurant_fee'] + $v['subsidy_fee'] + $v['other_fee']);
|
||||
}
|
||||
//获取税率
|
||||
$tax_rate = DictData::where('type_value','tax_rate')->column('name','value');
|
||||
Db::startTrans();
|
||||
@ -135,8 +123,6 @@ class ProjectTravelReimbursementLogic extends BaseLogic
|
||||
'project_id' => $trip_apply['project_id'],
|
||||
'reimbursement_type' => $params['reimbursement_type'],
|
||||
'loan_apply_id' => $params['loan_apply_id'] ?? 0,
|
||||
'reimbursement_amount' => $reimbursement_amount,//初始报销金额
|
||||
'actual_reimbursement_amount' => $reimbursement_amount - $params['offset_loan_amount'],//实际报销金额
|
||||
'offset_loan_amount' => $params['offset_loan_amount'] ?? 0,//冲抵借款金额
|
||||
'apply_user' => $params['apply_user'],
|
||||
'apply_date' => strtotime($params['apply_date']),
|
||||
@ -236,7 +222,7 @@ class ProjectTravelReimbursementLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$field = 'id,trip_apply_id,project_id,trip_reimbursement_code,reimbursement_type,loan_apply_id,reimbursement_amount,actual_reimbursement_amount,offset_loan_amount,apply_user,apply_date,payee_name,payee_bank,payee_account,remark,annex,bank_account_id';
|
||||
$field = 'id,trip_apply_id,project_id,trip_reimbursement_code,reimbursement_type,loan_apply_id,offset_loan_amount,apply_user,apply_date,payee_name,payee_bank,payee_account,remark,annex,bank_account_id';
|
||||
$data = ProjectTravelReimbursement::field($field)
|
||||
->findOrEmpty($params['id']);
|
||||
$trip_apply = ProjectTripApply::field('trip_apply_code')->where('id',$data['trip_apply_id'])->findOrEmpty();
|
||||
@ -255,6 +241,8 @@ class ProjectTravelReimbursementLogic extends BaseLogic
|
||||
$data['loan_apply_code'] = !$loan_apply->isEmpty() ? $loan_apply['loan_apply_code'] : '---';
|
||||
$data['loan_amount'] = !$loan_apply->isEmpty() ? $loan_apply['loan_amount'] : '---';
|
||||
$data['reimbursement_type_text'] = $data->reimbursement_type_text;
|
||||
$data['total_amount'] = ProjectTravelReimbursementDetail::where('travel_reimbursement_id',$data['id'])->sum('total_amount');
|
||||
$data['pay_amount'] = $data['total_amount'] - $data['offset_loan_amount'];
|
||||
$data['bank_account'] = BankAccount::field('account_sn,deposit_bank,account_name,account')->where('id',$data['bank_account_id'])->findOrEmpty();
|
||||
return $data->toArray();
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
namespace app\adminapi\validate\project;
|
||||
|
||||
|
||||
use app\common\model\project\ProjectCostTempSet;
|
||||
use app\common\model\project\ProjectTravelReimbursement;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
@ -32,13 +34,13 @@ class ProjectTravelReimbursementDetailValidate extends BaseValidate
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'travel_reimbursement_id' => 'require',
|
||||
'project_cost_temp_id' => 'require',
|
||||
'traffic_fee' => 'require',
|
||||
'stay_fee' => 'require',
|
||||
'restaurant_fee' => 'require',
|
||||
'subsidy_fee' => 'require',
|
||||
'other_fee' => 'require',
|
||||
'travel_reimbursement_id' => 'require|checkTravelReimbursement',
|
||||
'project_cost_temp_id' => 'require|checkProjectCostTemp',
|
||||
'traffic_fee' => 'require|float|egt:0',
|
||||
'stay_fee' => 'require|float|egt:0',
|
||||
'restaurant_fee' => 'require|float|egt:0',
|
||||
'subsidy_fee' => 'require|float|egt:0',
|
||||
'other_fee' => 'require|float|egt:0',
|
||||
];
|
||||
|
||||
|
||||
@ -50,11 +52,11 @@ class ProjectTravelReimbursementDetailValidate extends BaseValidate
|
||||
'id' => 'id',
|
||||
'travel_reimbursement_id' => '差旅报销单id',
|
||||
'project_cost_temp_id' => '项目费用模板id',
|
||||
'traffic_fee' => '交通',
|
||||
'stay_fee' => '住宿',
|
||||
'restaurant_fee' => '餐饮',
|
||||
'subsidy_fee' => '补助',
|
||||
'other_fee' => '其它',
|
||||
'traffic_fee' => '交通费用',
|
||||
'stay_fee' => '住宿费用',
|
||||
'restaurant_fee' => '餐饮费用',
|
||||
'subsidy_fee' => '补助费用',
|
||||
'other_fee' => '其它费用',
|
||||
];
|
||||
|
||||
|
||||
@ -66,7 +68,7 @@ class ProjectTravelReimbursementDetailValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['travel_reimbursement_id','project_cost_temp_id','traffic_fee','stay_fee','restaurant_fee','subsidy_fee','other_fee']);
|
||||
return $this->remove('id',true);
|
||||
}
|
||||
|
||||
|
||||
@ -77,9 +79,7 @@ class ProjectTravelReimbursementDetailValidate extends BaseValidate
|
||||
* @date 2024/01/18 13:57
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','travel_reimbursement_id','project_cost_temp_id','traffic_fee','stay_fee','restaurant_fee','subsidy_fee','other_fee']);
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
@ -105,4 +105,22 @@ class ProjectTravelReimbursementDetailValidate extends BaseValidate
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkTravelReimbursement($value): bool|string
|
||||
{
|
||||
$data = ProjectTravelReimbursement::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '差旅报销申请信息不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkProjectCostTemp($value): bool|string
|
||||
{
|
||||
$data = ProjectCostTempSet::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '项目费用模板信息不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -15,6 +15,8 @@
|
||||
namespace app\adminapi\validate\project;
|
||||
|
||||
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\project\ProjectTravelReimbursement;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
@ -32,13 +34,13 @@ class ProjectTravelReimbursementInvoiceDetailValidate extends BaseValidate
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'travel_reimbursement_id' => 'require',
|
||||
'invoice_type' => 'require',
|
||||
'travel_reimbursement_id' => 'require|checkTravelReimbursement',
|
||||
'invoice_type' => 'require|checkInvoiceType',
|
||||
'invoice_sn' => 'require',
|
||||
'tax_rate' => 'require',
|
||||
'invoice_form' => 'require',
|
||||
'invoice_amount' => 'require',
|
||||
'tax_amount' => 'require',
|
||||
'tax_rate' => 'require|checkTaxRate',
|
||||
'invoice_form' => 'require|checkInvoiceForm',
|
||||
'invoice_amount' => 'require|float|gt:0',
|
||||
'annex' => 'checkAnnex',
|
||||
];
|
||||
|
||||
|
||||
@ -54,7 +56,6 @@ class ProjectTravelReimbursementInvoiceDetailValidate extends BaseValidate
|
||||
'tax_rate' => '发票税率',
|
||||
'invoice_form' => '发票形式',
|
||||
'invoice_amount' => '发票金额',
|
||||
'tax_amount' => '发票税额',
|
||||
];
|
||||
|
||||
|
||||
@ -66,7 +67,7 @@ class ProjectTravelReimbursementInvoiceDetailValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['travel_reimbursement_id','invoice_type','invoice_sn','tax_rate','invoice_form','invoice_amount','tax_amount']);
|
||||
return $this->remove('id',true);
|
||||
}
|
||||
|
||||
|
||||
@ -77,9 +78,7 @@ class ProjectTravelReimbursementInvoiceDetailValidate extends BaseValidate
|
||||
* @date 2024/01/18 13:57
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','travel_reimbursement_id','invoice_type','invoice_sn','tax_rate','invoice_form','invoice_amount','tax_amount']);
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
@ -105,4 +104,49 @@ class ProjectTravelReimbursementInvoiceDetailValidate extends BaseValidate
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkTravelReimbursement($value): bool|string
|
||||
{
|
||||
$data = ProjectTravelReimbursement::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '差旅报销申请信息不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkInvoiceType($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value','invoice_type')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
return '发票类型数据值无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkTaxRate($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value','tax_rate')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
return '发票税率数据值无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkInvoiceForm($value){
|
||||
$dict = DictData::where('type_value','invoice_form')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
return '发票形式数据值无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAnnex($value): bool|string
|
||||
{
|
||||
if(!empty($value) && $value != ''){
|
||||
if(!is_array($value)){
|
||||
return '附件格式错误';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,7 @@ namespace app\common\model\project;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\dict\DictData;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
@ -30,5 +31,22 @@ class ProjectTravelReimbursementInvoiceDetail extends BaseModel
|
||||
protected $name = 'project_travel_reimbursement_invoice_detail';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getAnnexAttr($value){
|
||||
return !empty($value) ? json_decode($value,true) : '';
|
||||
}
|
||||
|
||||
public function getInvoiceTypeTextAttr($value,$data){
|
||||
$dict = DictData::where('type_value','invoice_type')->column('name','value');
|
||||
return !empty($data['invoice_type']) ? $dict[$data['invoice_type']] : '';
|
||||
}
|
||||
|
||||
public function getTaxRateTextAttr($value,$data){
|
||||
$dict = DictData::where('type_value','tax_rate')->column('name','value');
|
||||
return !empty($data['tax_rate']) ? $dict[$data['tax_rate']] : '';
|
||||
}
|
||||
|
||||
public function getInvoiceFormTextAttr($value,$data){
|
||||
$dict = DictData::where('type_value','invoice_form')->column('name','value');
|
||||
return !empty($data['invoice_form']) ? $dict[$data['invoice_form']] : '';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user