|
|
@@ -54,9 +54,9 @@ class ProcurementController extends Controller
|
|
|
$procurement_code .= date ("ymd").str_pad($number_id>99999?$number_id%99999:$number_id,4,"0",STR_PAD_LEFT);
|
|
|
/** @var ProcurementService $procurementService*/
|
|
|
$procurementService=app(ProcurementService::class);
|
|
|
- $deadline=$procurementService->computeDeadline($procurement->created_at);
|
|
|
+ $deadline=$procurementService->computeDeadline(Carbon::now()->toDateTimeString());
|
|
|
$procurement->update(['code'=>$procurement_code,'deadline'=>$deadline]);
|
|
|
- if ($procurement->type==0) dispatch(new ProcurementEnquiry($procurement))->delay($deadline); //采购单创建时 推送到队列中
|
|
|
+ if ($procurement->type==0) dispatch(new ProcurementEnquiry($procurement))->delay(Carbon::parse($deadline)); //采购单创建时 推送到队列中
|
|
|
dispatch(new ProcurementConfirmInform($procurement)); //推送发送订单通知消息模板 队列
|
|
|
return $procurement;
|
|
|
}
|
|
|
@@ -71,7 +71,11 @@ class ProcurementController extends Controller
|
|
|
->filter($filters)
|
|
|
->with(['initiator','ownerMaterial.file','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
|
|
|
$query->with('customer')->whereIn('id',$owner_ids);
|
|
|
- }])->paginate($param['paginate'] ?? 50);
|
|
|
+ },'procurementDeliveries'])->paginate($param['paginate'] ?? 50);
|
|
|
+ foreach ($procurements as $procurement){
|
|
|
+ if (empty($procurement->procurementDeliveries))continue;
|
|
|
+ $procurement->deliver_amount=$procurement->procurementDeliveries->sum('amount');
|
|
|
+ }
|
|
|
/** @var OwnerMaterialService $ownerMaterialService*/
|
|
|
$ownerMaterialService=app(OwnerMaterialService::class);
|
|
|
$owners=$ownerMaterialService->getOwnerPermittingWithMaterial();
|
|
|
@@ -275,31 +279,6 @@ class ProcurementController extends Controller
|
|
|
if (!empty($collect)) return ['success' => true,'data' => $collect];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- public function show(Procurement $procurement)
|
|
|
- {
|
|
|
- //
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public function edit(Procurement $procurement)
|
|
|
- {
|
|
|
- //
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public function update(Request $request, Procurement $procurement)
|
|
|
- {
|
|
|
- //
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public function destroy(Procurement $procurement)
|
|
|
- {
|
|
|
- //
|
|
|
- }
|
|
|
-
|
|
|
public function checkBill(Request $request,ProcurementCheckSheetFilters $filters)
|
|
|
{
|
|
|
if(!Gate::allows('采购管理-财务-对账单')){ return ["success"=>false,"data"=>"您无此权限操作!"]; }
|
|
|
@@ -312,7 +291,8 @@ class ProcurementController extends Controller
|
|
|
$materials=Material::query()->select('id','name')->get();
|
|
|
return view('procurement/finance/checkBill',compact('procurementCheckSheets','suppliers','paginateParams','materials'));
|
|
|
}
|
|
|
- public function fillInvoice(Request $request){
|
|
|
+ public function fillInvoice(Request $request): array
|
|
|
+ {
|
|
|
$this->gate('采购管理-财务-对账单');
|
|
|
$id=$request->input('procurementCheckSheetId');
|
|
|
$invoice_number=$request->input('invoice_number');
|
|
|
@@ -338,12 +318,14 @@ class ProcurementController extends Controller
|
|
|
->with(['initiator','supplier','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
|
|
|
/** @var Builder $query */
|
|
|
$query->with('customer')->whereIn('id',$owner_ids);
|
|
|
- },'procurementDeliveries'=>function($builder){
|
|
|
- /** @var Builder $builder */
|
|
|
- $builder->orderByDesc('id')->first();
|
|
|
- }])
|
|
|
+ },'procurementDeliveries'])
|
|
|
->where('type',0) //只取采购单
|
|
|
->paginate($param['paginate'] ?? 50);
|
|
|
+ foreach ($procurements as $procurement){
|
|
|
+ if (empty($procurement->procurementDeliveries))continue;
|
|
|
+ $procurement->deliver_amount=$procurement->procurementDeliveries->sum('amount');
|
|
|
+ $procurement->signed_at=$procurement->procurementDeliveries->first()['signed_at'];
|
|
|
+ }
|
|
|
return view('procurement/finance/procurementBill',compact('suppliers','materials','owners','paginateParams','procurements'));
|
|
|
}
|
|
|
|
|
|
@@ -365,8 +347,11 @@ class ProcurementController extends Controller
|
|
|
->filter($filters)
|
|
|
->with(['initiator','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
|
|
|
$query->with('customer')->whereIn('id',$owner_ids);
|
|
|
- }])->get();
|
|
|
-
|
|
|
+ },'procurementDeliveries'])->get();
|
|
|
+ foreach ($procurements as $procurement){
|
|
|
+ if (empty($procurement->procurementDeliveries))continue;
|
|
|
+ $procurement->deliver_amount=$procurement->procurementDeliveries->sum('amount');
|
|
|
+ }
|
|
|
$procurementStatus=Procurement::status;
|
|
|
$procurementType=Procurement::type;
|
|
|
$row = ['采购编号','项目','单据类型','采购公司','耗材编号','耗材','尺寸大小','特殊要求','材质规格','采购数量','销售单价(元)','送货数量','销售总价(元)','采购单状态','联系方式'];
|
|
|
@@ -384,7 +369,7 @@ class ProcurementController extends Controller
|
|
|
$procurement->ownerMaterial ? $procurement->ownerMaterial->specification :'',
|
|
|
$procurement->quantity,
|
|
|
$procurement->unit_price,
|
|
|
- '',//送货数量
|
|
|
+ $procurement->deliver_amount ? $procurement->deliver_amount :'',//送货数量
|
|
|
$procurement->unit_price*$procurement->amount,//销售总价=销售数量*销售单价
|
|
|
is_null($procurement->status) ? '' :$procurementStatus[$procurement->status],
|
|
|
$procurement->ownerMaterial->owner->customer ? $procurement->ownerMaterial->owner->customer->phone :'',
|
|
|
@@ -427,9 +412,17 @@ class ProcurementController extends Controller
|
|
|
$owner_ids=app('UserService')->getPermittingOwnerIds(auth()->user());
|
|
|
$procurements = Procurement::query()
|
|
|
->filter($filters)
|
|
|
- ->with(['initiator','supplier','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
|
|
|
+ ->with(['supplier','initiator','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
|
|
|
+ /** @var Builder $query */
|
|
|
$query->with('customer')->whereIn('id',$owner_ids);
|
|
|
- }])->get();
|
|
|
+ },'procurementDeliveries'])
|
|
|
+ ->where('type',0) //只取采购单
|
|
|
+ ->paginate($param['paginate'] ?? 50);
|
|
|
+ foreach ($procurements as $procurement){
|
|
|
+ if (empty($procurement->procurementDeliveries))continue;
|
|
|
+ $procurement->receive_amount=$procurement->procurementDeliveries->sum('receipt_amount');
|
|
|
+ $procurement->signed_at=$procurement->procurementDeliveries->first()['signed_at'];
|
|
|
+ }
|
|
|
|
|
|
$procurementStatus=Procurement::status;
|
|
|
$row = ['采购编号','采购日期','接单日期','签收日期','项目名称','采购公司','供应商','耗材编号','耗材','尺寸大小','特殊要求',
|
|
|
@@ -439,8 +432,8 @@ class ProcurementController extends Controller
|
|
|
$list[] = [
|
|
|
$procurement->code,
|
|
|
$procurement->created_at,
|
|
|
- '',//接单日期
|
|
|
- '',//签收日期
|
|
|
+ $procurement->deadline ? $procurement->deadline : '',//接单日期
|
|
|
+ $procurement->signed_at ? $procurement->signed_at : '',//签收日期
|
|
|
$procurement->ownerMaterial->owner ? $procurement->ownerMaterial->owner->name :'',
|
|
|
$procurement->ownerMaterial->owner->customer ? $procurement->ownerMaterial->owner->customer->company_name :'',
|
|
|
$procurement->supplier ? $procurement->supplier->name :'',
|
|
|
@@ -451,11 +444,11 @@ class ProcurementController extends Controller
|
|
|
$procurement->ownerMaterial ? $procurement->ownerMaterial->specification :'',
|
|
|
$procurement->quantity,
|
|
|
$procurement->amount,
|
|
|
- '',//收货数量
|
|
|
+ $procurement->receive_amount ? $procurement->receive_amount : '',//收货数量
|
|
|
$procurement->cost_price,
|
|
|
$procurement->unit_price,
|
|
|
- '',//应收金额
|
|
|
- '',//应付金额
|
|
|
+ $procurement->amount*$procurement->cost_price,//应收金额
|
|
|
+ $procurement->quantity*$procurement->unit_price,//应付金额
|
|
|
is_null($procurement->status) ? '' :$procurementStatus[$procurement->status],
|
|
|
];
|
|
|
}
|