This commit is contained in:
weiz 2024-01-19 11:10:36 +08:00
parent 1da8d86ec3
commit 4d580cab2a
9 changed files with 608 additions and 415 deletions

View File

@ -1,77 +1,128 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\project;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\project\ProjectTravelReimbursementDetail;
use app\common\lists\ListsSearchInterface;
/**
* 报销明细列表
* Class ProjectTravelReimbursementDetailLists
* @package app\adminapi\listsproject
*/
class ProjectTravelReimbursementDetailLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function setSearch(): array
{
return [
'=' => ['travel_reimbursement_id'],
];
}
/**
* @notes 获取报销明细列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/01/18 13:57
*/
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'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取报销明细数量
* @return int
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function count(): int
{
return ProjectTravelReimbursementDetail::where($this->searchWhere)->count();
}
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
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;
/**
* 报销明细列表
* Class ProjectTravelReimbursementDetailLists
* @package app\adminapi\listsproject
*/
class ProjectTravelReimbursementDetailLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function setSearch(): array
{
return [
'=' => ['travel_reimbursement_id'],
];
}
/**
* @notes 获取报销明细列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function lists(): array
{
$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()->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();
}
/**
* @notes 获取报销明细数量
* @return int
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function count(): int
{
$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();
}
}

View File

@ -1,77 +1,127 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\project;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\project\ProjectTravelReimbursementInvoiceDetail;
use app\common\lists\ListsSearchInterface;
/**
* 发票明细列表
* Class ProjectTravelReimbursementInvoiceDetailLists
* @package app\adminapi\listsproject
*/
class ProjectTravelReimbursementInvoiceDetailLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function setSearch(): array
{
return [
'=' => ['travel_reimbursement_id', 'invoice_type', 'invoice_sn', 'invoice_form'],
];
}
/**
* @notes 获取发票明细列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/01/18 13:57
*/
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'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取发票明细数量
* @return int
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function count(): int
{
return ProjectTravelReimbursementInvoiceDetail::where($this->searchWhere)->count();
}
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
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;
/**
* 发票明细列表
* Class ProjectTravelReimbursementInvoiceDetailLists
* @package app\adminapi\listsproject
*/
class ProjectTravelReimbursementInvoiceDetailLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function setSearch(): array
{
return [
'=' => ['travel_reimbursement_id', 'invoice_type', 'invoice_form'],
'%like%' => ['invoice_sn']
];
}
/**
* @notes 获取发票明细列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function lists(): array
{
$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()->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();
}
/**
* @notes 获取发票明细数量
* @return int
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function count(): int
{
$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();
}
}

View File

@ -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();

View File

@ -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) {
@ -73,16 +75,17 @@ class ProjectTravelReimbursementDetailLogic extends BaseLogic
Db::startTrans();
try {
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'],
'travel_reimbursement_id' => $params['travel_reimbursement_id'],
'project_cost_temp_id' => $params['project_cost_temp_id'],
'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();
}
}

View File

@ -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,20 +74,22 @@ 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([
'travel_reimbursement_id' => $params['travel_reimbursement_id'],
'invoice_type' => $params['invoice_type'],
'invoice_sn' => $params['invoice_sn'],
'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'],
'travel_reimbursement_id' => $params['travel_reimbursement_id'],
'invoice_type' => $params['invoice_type'],
'invoice_sn' => $params['invoice_sn'],
'tax_rate' => $params['tax_rate'],
'invoice_form' => $params['invoice_form'],
'invoice_amount' => $params['invoice_amount'],
'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();
}
}

View File

@ -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();
}

View File

@ -1,108 +1,126 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\project;
use app\common\validate\BaseValidate;
/**
* 报销明细验证器
* Class ProjectTravelReimbursementDetailValidate
* @package app\adminapi\validate\project
*/
class ProjectTravelReimbursementDetailValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
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',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'travel_reimbursement_id' => '差旅报销单id',
'project_cost_temp_id' => '项目费用模板id',
'traffic_fee' => '交通',
'stay_fee' => '住宿',
'restaurant_fee' => '餐饮',
'subsidy_fee' => '补助',
'other_fee' => '其它',
];
/**
* @notes 添加场景
* @return ProjectTravelReimbursementDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneAdd()
{
return $this->only(['travel_reimbursement_id','project_cost_temp_id','traffic_fee','stay_fee','restaurant_fee','subsidy_fee','other_fee']);
}
/**
* @notes 编辑场景
* @return ProjectTravelReimbursementDetailValidate
* @author likeadmin
* @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']);
}
/**
* @notes 删除场景
* @return ProjectTravelReimbursementDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return ProjectTravelReimbursementDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneDetail()
{
return $this->only(['id']);
}
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\project;
use app\common\model\project\ProjectCostTempSet;
use app\common\model\project\ProjectTravelReimbursement;
use app\common\validate\BaseValidate;
/**
* 报销明细验证器
* Class ProjectTravelReimbursementDetailValidate
* @package app\adminapi\validate\project
*/
class ProjectTravelReimbursementDetailValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => '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',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'travel_reimbursement_id' => '差旅报销单id',
'project_cost_temp_id' => '项目费用模板id',
'traffic_fee' => '交通费用',
'stay_fee' => '住宿费用',
'restaurant_fee' => '餐饮费用',
'subsidy_fee' => '补助费用',
'other_fee' => '其它费用',
];
/**
* @notes 添加场景
* @return ProjectTravelReimbursementDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return ProjectTravelReimbursementDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return ProjectTravelReimbursementDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return ProjectTravelReimbursementDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneDetail()
{
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;
}
}

View File

@ -1,108 +1,152 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\project;
use app\common\validate\BaseValidate;
/**
* 发票明细验证器
* Class ProjectTravelReimbursementInvoiceDetailValidate
* @package app\adminapi\validate\project
*/
class ProjectTravelReimbursementInvoiceDetailValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'travel_reimbursement_id' => 'require',
'invoice_type' => 'require',
'invoice_sn' => 'require',
'tax_rate' => 'require',
'invoice_form' => 'require',
'invoice_amount' => 'require',
'tax_amount' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'travel_reimbursement_id' => '差旅报销id',
'invoice_type' => '发票类型',
'invoice_sn' => '发票号',
'tax_rate' => '发票税率',
'invoice_form' => '发票形式',
'invoice_amount' => '发票金额',
'tax_amount' => '发票税额',
];
/**
* @notes 添加场景
* @return ProjectTravelReimbursementInvoiceDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneAdd()
{
return $this->only(['travel_reimbursement_id','invoice_type','invoice_sn','tax_rate','invoice_form','invoice_amount','tax_amount']);
}
/**
* @notes 编辑场景
* @return ProjectTravelReimbursementInvoiceDetailValidate
* @author likeadmin
* @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']);
}
/**
* @notes 删除场景
* @return ProjectTravelReimbursementInvoiceDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return ProjectTravelReimbursementInvoiceDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneDetail()
{
return $this->only(['id']);
}
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\project;
use app\common\model\dict\DictData;
use app\common\model\project\ProjectTravelReimbursement;
use app\common\validate\BaseValidate;
/**
* 发票明细验证器
* Class ProjectTravelReimbursementInvoiceDetailValidate
* @package app\adminapi\validate\project
*/
class ProjectTravelReimbursementInvoiceDetailValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'travel_reimbursement_id' => 'require|checkTravelReimbursement',
'invoice_type' => 'require|checkInvoiceType',
'invoice_sn' => 'require',
'tax_rate' => 'require|checkTaxRate',
'invoice_form' => 'require|checkInvoiceForm',
'invoice_amount' => 'require|float|gt:0',
'annex' => 'checkAnnex',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'travel_reimbursement_id' => '差旅报销id',
'invoice_type' => '发票类型',
'invoice_sn' => '发票号',
'tax_rate' => '发票税率',
'invoice_form' => '发票形式',
'invoice_amount' => '发票金额',
];
/**
* @notes 添加场景
* @return ProjectTravelReimbursementInvoiceDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return ProjectTravelReimbursementInvoiceDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return ProjectTravelReimbursementInvoiceDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return ProjectTravelReimbursementInvoiceDetailValidate
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function sceneDetail()
{
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;
}
}

View File

@ -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']] : '';
}
}