|
@@ -13,6 +13,7 @@ use App\Model\Fee;
|
|
|
use App\Model\Item;
|
|
use App\Model\Item;
|
|
|
use App\Model\ItemDetails;
|
|
use App\Model\ItemDetails;
|
|
|
use App\Model\MonthlyDdOrder;
|
|
use App\Model\MonthlyDdOrder;
|
|
|
|
|
+use App\Model\MonthlyDdOrderDetails;
|
|
|
use App\Model\MonthlyPsOrder;
|
|
use App\Model\MonthlyPsOrder;
|
|
|
use App\Model\MonthlyPsOrderDetails;
|
|
use App\Model\MonthlyPsOrderDetails;
|
|
|
use App\Model\MonthlyPwOrderDetails;
|
|
use App\Model\MonthlyPwOrderDetails;
|
|
@@ -34,7 +35,7 @@ class AuxiliaryAccountService extends Service
|
|
|
private function setCommon($data,$user, $field = []){
|
|
private function setCommon($data,$user, $field = []){
|
|
|
if(empty($field)) $field = AuxiliaryAccount::$field;
|
|
if(empty($field)) $field = AuxiliaryAccount::$field;
|
|
|
$data['top_depart_id'] = $user['top_depart_id'];
|
|
$data['top_depart_id'] = $user['top_depart_id'];
|
|
|
- $model = ExpenseClaims::Clear($user,$data);
|
|
|
|
|
|
|
+ $model = AuxiliaryAccount::Clear($user,$data);
|
|
|
$model = $model->where('del_time',0)
|
|
$model = $model->where('del_time',0)
|
|
|
->select($field)
|
|
->select($field)
|
|
|
->orderby('month', 'desc');
|
|
->orderby('month', 'desc');
|
|
@@ -114,7 +115,7 @@ class AuxiliaryAccountService extends Service
|
|
|
}else{
|
|
}else{
|
|
|
$month_ps_order_id = $month_ps_order_id->id;
|
|
$month_ps_order_id = $month_ps_order_id->id;
|
|
|
}
|
|
}
|
|
|
- $model = MonthlyPsOrderDetails::Clear($user,$data);
|
|
|
|
|
|
|
+ $model = MonthlyDdOrderDetails::Clear($user,$data);
|
|
|
//总金额
|
|
//总金额
|
|
|
$total_amount = $model->where('main_id',$month_ps_order_id)->sum("depreciation_amount");
|
|
$total_amount = $model->where('main_id',$month_ps_order_id)->sum("depreciation_amount");
|
|
|
return [true,[
|
|
return [true,[
|
|
@@ -126,16 +127,16 @@ class AuxiliaryAccountService extends Service
|
|
|
$month_ps_order = ExpenseClaims::Clear($user,$data);
|
|
$month_ps_order = ExpenseClaims::Clear($user,$data);
|
|
|
$month_ps_order_id = $month_ps_order->where('del_time',0)->where("month",$monthStart)->first();
|
|
$month_ps_order_id = $month_ps_order->where('del_time',0)->where("month",$monthStart)->first();
|
|
|
if(empty($month_ps_order_id)){
|
|
if(empty($month_ps_order_id)){
|
|
|
- return [false,"请补充对应月份设备月度折旧信息"];
|
|
|
|
|
|
|
+ return [false,"请补充对应月份费用信息"];
|
|
|
}else{
|
|
}else{
|
|
|
$month_ps_order_id = $month_ps_order_id->id;
|
|
$month_ps_order_id = $month_ps_order_id->id;
|
|
|
}
|
|
}
|
|
|
- $model = MonthlyPsOrderDetails::Clear($user,$data);
|
|
|
|
|
|
|
+ $model = new ExpenseClaimsDetails();
|
|
|
//总金额
|
|
//总金额
|
|
|
$list = $model->where('expense_claims_id',$month_ps_order_id)->select("fee_id","amount","remark","entrust_type")->get()->toArray();
|
|
$list = $model->where('expense_claims_id',$month_ps_order_id)->select("fee_id","amount","remark","entrust_type")->get()->toArray();
|
|
|
///分组
|
|
///分组
|
|
|
$fee_type_list = Fee::Clear($user,$data)->where('del_time',0)->select("title","id","parent_id")->get()->toArray();
|
|
$fee_type_list = Fee::Clear($user,$data)->where('del_time',0)->select("title","id","parent_id")->get()->toArray();
|
|
|
- return $this->groupListByRoot($list,$fee_type_list);
|
|
|
|
|
|
|
+ return [true,$this->groupListByRoot($list,$fee_type_list)];
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -198,14 +199,13 @@ class AuxiliaryAccountService extends Service
|
|
|
$model->code = $this->generateBillNo([
|
|
$model->code = $this->generateBillNo([
|
|
|
'top_depart_id' => $user['top_depart_id'],
|
|
'top_depart_id' => $user['top_depart_id'],
|
|
|
'type' => ExpenseClaims::Order_type,
|
|
'type' => ExpenseClaims::Order_type,
|
|
|
- 'month' => date("Ym", strtotime($data['month']))
|
|
|
|
|
|
|
+ 'period' => date("Ym", strtotime($data['month']))
|
|
|
]);
|
|
]);
|
|
|
$model->month = $data['order_time'] ?? 0;
|
|
$model->month = $data['order_time'] ?? 0;
|
|
|
- $model->type = $data['type'];
|
|
|
|
|
$model->crt_id = $user['id'];
|
|
$model->crt_id = $user['id'];
|
|
|
- $model->top_depart_id = $data['top_depart_id'];
|
|
|
|
|
|
|
+ $model->top_depart_id = $user['top_depart_id'];
|
|
|
$model->save();
|
|
$model->save();
|
|
|
-
|
|
|
|
|
|
|
+ $data['top_depart_id'] = $user['top_depart_id'];
|
|
|
$this->saveDetail($model->id, time(), $data);
|
|
$this->saveDetail($model->id, time(), $data);
|
|
|
|
|
|
|
|
DB::commit();
|
|
DB::commit();
|
|
@@ -235,7 +235,7 @@ class AuxiliaryAccountService extends Service
|
|
|
'entrust2_amount' => $value['entrust2_amount']??0,
|
|
'entrust2_amount' => $value['entrust2_amount']??0,
|
|
|
'aggregation_amount' => $value['aggregation_amount']??00,
|
|
'aggregation_amount' => $value['aggregation_amount']??00,
|
|
|
'total_amount' => $value['total_amount'],
|
|
'total_amount' => $value['total_amount'],
|
|
|
- 'top_depart_id' => $value['top_depart_id'],
|
|
|
|
|
|
|
+ 'top_depart_id' => $data['top_depart_id'],
|
|
|
'crt_time' => $time,
|
|
'crt_time' => $time,
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
@@ -249,7 +249,7 @@ class AuxiliaryAccountService extends Service
|
|
|
$monthStart = strtotime($monthStr); // 2026-03-01 00:00:00
|
|
$monthStart = strtotime($monthStr); // 2026-03-01 00:00:00
|
|
|
// 获取该月最后一秒:下个月 1 号减去 1 秒
|
|
// 获取该月最后一秒:下个月 1 号减去 1 秒
|
|
|
$monthEnd = strtotime("$monthStr +1 month") - 1;
|
|
$monthEnd = strtotime("$monthStr +1 month") - 1;
|
|
|
- foreach ($data['detail'] as $index => $item) {
|
|
|
|
|
|
|
+ foreach ($data['details'] as $index => $item) {
|
|
|
if (!isset($item['voucher_date'])) {
|
|
if (!isset($item['voucher_date'])) {
|
|
|
return [false, "第" . ($index + 1) . "凭证日期缺失"];
|
|
return [false, "第" . ($index + 1) . "凭证日期缺失"];
|
|
|
}
|
|
}
|
|
@@ -269,9 +269,9 @@ class AuxiliaryAccountService extends Service
|
|
|
return [false, "第" . ($index + 1) . "凭证摘要缺失"];
|
|
return [false, "第" . ($index + 1) . "凭证摘要缺失"];
|
|
|
}
|
|
}
|
|
|
// 将报销日期转换为时间戳
|
|
// 将报销日期转换为时间戳
|
|
|
- $claimTime = strtotime($item['claim_date']);
|
|
|
|
|
- // 判断:claim_date 必须早于 month
|
|
|
|
|
- // 如果 claim_date 是 2026-02-28,而 month 是 2026-03-01,则校验通过
|
|
|
|
|
|
|
+ $claimTime = strtotime($item['voucher_date']);
|
|
|
|
|
+ // 判断:voucher_date 必须早于 month
|
|
|
|
|
+ // 如果 voucher_date 是 2026-02-28,而 month 是 2026-03-01,则校验通过
|
|
|
if ($claimTime < $monthStart || $claimTime > $monthEnd) {
|
|
if ($claimTime < $monthStart || $claimTime > $monthEnd) {
|
|
|
return [false, "第" . ($index + 1) . "凭证日期必须早于当前结算月份(" . $data['month'] . ")"];
|
|
return [false, "第" . ($index + 1) . "凭证日期必须早于当前结算月份(" . $data['month'] . ")"];
|
|
|
}
|
|
}
|
|
@@ -293,6 +293,7 @@ class AuxiliaryAccountService extends Service
|
|
|
AuxiliaryAccountDetails::where('del_time',0)
|
|
AuxiliaryAccountDetails::where('del_time',0)
|
|
|
->where('auxiliary_account_id', $model->id)
|
|
->where('auxiliary_account_id', $model->id)
|
|
|
->update(['del_time' => $time]);
|
|
->update(['del_time' => $time]);
|
|
|
|
|
+ $data['top_depart_id'] = $user['top_depart_id'];
|
|
|
$this->saveDetail($model->id, $time, $data);
|
|
$this->saveDetail($model->id, $time, $data);
|
|
|
|
|
|
|
|
DB::commit();
|
|
DB::commit();
|
|
@@ -346,7 +347,7 @@ class AuxiliaryAccountService extends Service
|
|
|
|
|
|
|
|
private function getDetail($id){
|
|
private function getDetail($id){
|
|
|
$data = AuxiliaryAccountDetails::where('del_time',0)
|
|
$data = AuxiliaryAccountDetails::where('del_time',0)
|
|
|
- ->where('expense_claims_id', $id)
|
|
|
|
|
|
|
+ ->where('auxiliary_account_id', $id)
|
|
|
->select('*')
|
|
->select('*')
|
|
|
->get()->toArray();
|
|
->get()->toArray();
|
|
|
return $data;
|
|
return $data;
|