|
|
@@ -0,0 +1,433 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Http\Controllers;
|
|
|
+
|
|
|
+use App\Components\AsyncResponse;
|
|
|
+use App\Configuration;
|
|
|
+use App\Filters\ProcurementCheckSheetFilters;
|
|
|
+use App\Filters\ProcurementFilters;
|
|
|
+use App\Http\Requests\Procurement\EnquiryRequest;
|
|
|
+use App\Http\Requests\Procurement\ProcurementAmountRequest;
|
|
|
+use App\Http\Requests\Procurement\ProcurementRequest;
|
|
|
+use App\Http\Requests\Procurement\ProofRequest;
|
|
|
+use App\Material;
|
|
|
+use App\Procurement;
|
|
|
+use App\ProcurementCheckSheet;
|
|
|
+use App\ProcurementDeliverie;
|
|
|
+use App\ProcurementTotalBill;
|
|
|
+use App\Services\common\ExportService;
|
|
|
+use App\Services\OwnerMaterialService;
|
|
|
+use App\Services\ProcurementService;
|
|
|
+use App\Services\ProcurementTotalBillService;
|
|
|
+use App\Supplier;
|
|
|
+use Carbon\Traits\Date;
|
|
|
+use Illuminate\Http\Request;
|
|
|
+use Illuminate\Support\Facades\Auth;
|
|
|
+use Illuminate\Support\Facades\Gate;
|
|
|
+
|
|
|
+class ProcurementController extends Controller
|
|
|
+{
|
|
|
+ use AsyncResponse;
|
|
|
+
|
|
|
+ private function newProcurement($param){
|
|
|
+ $procurement=new Procurement([
|
|
|
+ 'owner_material_id'=>$param['owner_material_id'],
|
|
|
+ 'quantity'=>$param['quantity'],
|
|
|
+ 'amount'=>$param['amount'],
|
|
|
+ 'unit_price'=>$param['unit_price'],
|
|
|
+ 'initiator'=>Auth::user()['id'],
|
|
|
+ 'type'=>0,
|
|
|
+ ]);
|
|
|
+ $procurement->save();
|
|
|
+ $number_id=$procurement['id'];
|
|
|
+ $procurement_code='BSHC';
|
|
|
+ $procurement_code .= date ("ymd").str_pad($number_id>99999?$number_id%99999:$number_id,4,"0",STR_PAD_LEFT);
|
|
|
+ $procurement->update(['code'=>$procurement_code]);
|
|
|
+ return $procurement;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function index(Request $request,ProcurementFilters $filters)
|
|
|
+ {
|
|
|
+ if(!Gate::allows('采购管理-采购-查询')){ return ["success"=>false,"data"=>"您无此权限操作!"]; }
|
|
|
+ $paginateParams=$request->input();
|
|
|
+ $owner_ids=app('UserService')->getPermittingOwnerIds(auth()->user());
|
|
|
+ $procurements = Procurement::query()
|
|
|
+ ->filter($filters)
|
|
|
+ ->with(['initiator','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
|
|
|
+ $query->with('customer')->whereIn('id',$owner_ids);
|
|
|
+ }])->paginate($param['paginate'] ?? 50);
|
|
|
+ /** @var OwnerMaterialService $ownerMaterialService*/
|
|
|
+ $ownerMaterialService=app(OwnerMaterialService::class);
|
|
|
+ $owners=$ownerMaterialService->getOwnerPermittingWithMaterial();
|
|
|
+ $materials=Material::query()->select('id','name')->get();
|
|
|
+ $date=date('Y-m-d');
|
|
|
+ $countReceive=ProcurementDeliverie::query()->where('signed_at',$date)->count();
|
|
|
+ $countProcurement=Procurement::query()->where('type',0)->where('created_at','like',$date.'%')->count();
|
|
|
+ return view('procurement/procurement/index',compact('procurements','owners','materials','paginateParams','countReceive','countProcurement'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function create()
|
|
|
+ {
|
|
|
+ if(!Gate::allows('采购管理-采购-新建')){ return ["success"=>false,"data"=>"您无此权限操作!"]; }
|
|
|
+ /** @var OwnerMaterialService $ownerMaterialService*/
|
|
|
+ $ownerMaterialService=app(OwnerMaterialService::class);
|
|
|
+ $owners=$ownerMaterialService->getOwnerPermittingWithMaterial();
|
|
|
+ return view('procurement/procurement/create',compact('owners'));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function store(Request $request)
|
|
|
+ {
|
|
|
+ $this->gate('采购管理-采购-新建');
|
|
|
+ $param=$request->all(['owner_material_id','quantity','amount','unit_price']);
|
|
|
+ $procurement=$this->newProcurement($param);
|
|
|
+ return redirect('procurement/procurement/index')->with('successTip','新采购单“'.$procurement->code.'”添加成功');
|
|
|
+ }
|
|
|
+ public function createProcurement(ProcurementRequest $request)
|
|
|
+ {
|
|
|
+ $this->gate('采购管理-采购-新建');
|
|
|
+ $request->validated();
|
|
|
+ $param=$request->all(['owner_material_id','quantity','amount','unit_price']);
|
|
|
+ try {
|
|
|
+ $procurement=$this->newProcurement($param);
|
|
|
+ $procurement = $procurement->loadMissing(['initiator','ownerMaterial.material','ownerMaterial.owner.customer']);
|
|
|
+ if ($procurement) return ['success' => true,'data' => $procurement];
|
|
|
+ else return ['success' => false, 'message' => '添加失败'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return ['success' => false,'message' => $e->getMessage()];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //新增询价
|
|
|
+ public function createEnquiry(EnquiryRequest $request)
|
|
|
+ {
|
|
|
+ $this->gate('采购管理-采购-新建');
|
|
|
+ $request->validated();
|
|
|
+ $param=$request->all(['owner_material_id']);
|
|
|
+ try {
|
|
|
+ $procurement=new Procurement([
|
|
|
+ 'owner_material_id'=>$param['owner_material_id'],
|
|
|
+ 'quantity'=>0,
|
|
|
+ 'amount'=>0,
|
|
|
+ 'unit_price'=>0,
|
|
|
+ 'initiator'=>Auth::user()['id'],
|
|
|
+ 'type'=>1,
|
|
|
+ 'status'=>9,
|
|
|
+ //'is_enquiry'=>'是',
|
|
|
+ ]);
|
|
|
+ $procurement->save();
|
|
|
+ $number_id=$procurement['id'];
|
|
|
+ $procurement_code='BSHC';
|
|
|
+ $procurement_code .= date ("ymd").str_pad($number_id>99999?$number_id%99999:$number_id,4,"0",STR_PAD_LEFT);
|
|
|
+ $procurement->update(['code'=>$procurement_code]);
|
|
|
+ $procurement = $procurement->loadMissing(['initiator','ownerMaterial.material','ownerMaterial.owner.customer']);
|
|
|
+ if ($procurement) return ['success' => true,'data' => $procurement];
|
|
|
+ else return ['success' => false, 'message' => '添加失败'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return ['success' => false,'message' => $e->getMessage()];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //新增打样
|
|
|
+ public function createProof(ProofRequest $request)
|
|
|
+ {
|
|
|
+ $this->gate('采购管理-采购-新建');
|
|
|
+ $request->validated();
|
|
|
+ $param=$request->all(['owner_material_id']);
|
|
|
+ try {
|
|
|
+ $procurement=new Procurement([
|
|
|
+ 'owner_material_id'=>$param['owner_material_id'],
|
|
|
+ 'quantity'=>1,
|
|
|
+ 'amount'=>0,
|
|
|
+ 'unit_price'=>0,
|
|
|
+ 'initiator'=>Auth::user()['id'],
|
|
|
+ 'type'=>2,
|
|
|
+ ]);
|
|
|
+ $procurement->save();
|
|
|
+ $number_id=$procurement['id'];
|
|
|
+ $procurement_code='BSHC';
|
|
|
+ $procurement_code .= date ("ymd").str_pad($number_id>99999?$number_id%99999:$number_id,4,"0",STR_PAD_LEFT);
|
|
|
+ $procurement->update(['code'=>$procurement_code]);
|
|
|
+ $procurement = $procurement->loadMissing(['initiator','ownerMaterial.material','ownerMaterial.owner.customer']);
|
|
|
+ if ($procurement) return ['success' => true,'data' => $procurement];
|
|
|
+ else return ['success' => false, 'message' => '添加失败'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return ['success' => false,'message' => $e->getMessage()];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function cancel($id){
|
|
|
+ $this->gate('采购管理-采购-编辑');
|
|
|
+ try {
|
|
|
+ $procurement=Procurement::query()->find($id);
|
|
|
+ $procurement->update(['status'=>3]);
|
|
|
+ $procurement = $procurement->loadMissing(['initiator','ownerMaterial.material','ownerMaterial.owner.customer']);
|
|
|
+ if ($procurement) return ['success' => true,'data' => $procurement];
|
|
|
+ else return ['success' => false, 'message' => '取消失败'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return ['success' => false,'message' => $e->getMessage()];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //询价单提交采购申请
|
|
|
+ public function submitProcurement(ProcurementAmountRequest $request){
|
|
|
+ $this->gate('采购管理-采购-编辑');
|
|
|
+ $request->validated();
|
|
|
+ $param=$request->all();
|
|
|
+ try {
|
|
|
+ $procurement=Procurement::query()->find($param['id']);
|
|
|
+ $unit_price=$param['unit_price'];
|
|
|
+ if (!$unit_price){
|
|
|
+ $priceCoefficient=Configuration::query()->where('name','priceCoefficient')->value('value');
|
|
|
+ $unit_price=$priceCoefficient*$param['offer'];
|
|
|
+ }
|
|
|
+ $procurement->update([
|
|
|
+ 'type'=>0,
|
|
|
+ 'status'=>0,
|
|
|
+ 'quantity'=>$param['quantity'],
|
|
|
+ 'amount'=>$param['amount'],
|
|
|
+ 'unit_price'=>$unit_price,
|
|
|
+ 'cost_price'=>$param['offer'],
|
|
|
+ 'supplier_id'=>$param['supplier_id'],
|
|
|
+ ]);
|
|
|
+ $procurement = $procurement->loadMissing(['initiator','ownerMaterial.material','ownerMaterial.owner.customer']);
|
|
|
+ if ($procurement) return ['success' => true,'data' => $procurement];
|
|
|
+ else return ['success' => false, 'message' => '发起采购失败'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return ['success' => false,'message' => $e->getMessage()];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function initiateProcurement(Request $request){
|
|
|
+ $this->gate('采购管理-采购-编辑');
|
|
|
+ $id=$request->input('id');
|
|
|
+ /** @var ProcurementService $procurementService*/
|
|
|
+ $procurementService=app(ProcurementService::class);
|
|
|
+ try {
|
|
|
+ $procurementQuotation=$procurementService->screenLowestQuotation($id);
|
|
|
+ if ($procurementQuotation) return ['success' => true,'data' => $procurementQuotation];
|
|
|
+ else return ['success' => false, 'message' => '暂无供应商报价!'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return ['success' => false,'message' => $e->getMessage()];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function costPrice(Request $request){
|
|
|
+ $this->gate('采购管理-财务-采购账单');
|
|
|
+ $id=$request->input('id');
|
|
|
+ $cost_price=$request->input('cost_price');
|
|
|
+ try {
|
|
|
+ $procurement=Procurement::query()->find($id);
|
|
|
+ if ($procurement->cost_price!=$cost_price)$procurement->update(['cost_price'=>$cost_price]);
|
|
|
+ $procurement = $procurement->loadMissing(['initiator','supplier','ownerMaterial.material','ownerMaterial.owner.customer']);
|
|
|
+ if ($procurement) return ['success' => true,'data' => $procurement];
|
|
|
+ else return ['success' => false, 'message' => '修改采购单价失败!'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return ['success' => false,'message' => $e->getMessage()];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 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"=>"您无此权限操作!"]; }
|
|
|
+ $paginateParams=$request->input();
|
|
|
+ $procurementCheckSheets=ProcurementCheckSheet::query()
|
|
|
+ ->filter($filters)
|
|
|
+ ->with(['procurementDelivery.procurement.supplier','procurementDelivery.procurement.ownerMaterial.material','procurementDelivery.receiver'])
|
|
|
+ ->paginate($param['paginate'] ?? 50);
|
|
|
+ $suppliers=Supplier::query()->select('id','name')->get();
|
|
|
+ $materials=Material::query()->select('id','name')->get();
|
|
|
+ return view('procurement/finance/checkBill',compact('procurementCheckSheets','suppliers','paginateParams','materials'));
|
|
|
+ }
|
|
|
+ public function fillInvoice(Request $request){
|
|
|
+ $this->gate('采购管理-财务-对账单');
|
|
|
+ $id=$request->input('procurementCheckSheetId');
|
|
|
+ $invoice_number=$request->input('invoice_number');
|
|
|
+ try {
|
|
|
+ $procurementCheckSheet=ProcurementCheckSheet::query()->where('id',$id)->update(['invoice_number'=>$invoice_number]);
|
|
|
+ if ($procurementCheckSheet) return ['success' => true,'data' => $invoice_number];
|
|
|
+ else return ['success' => false, 'message' => '添加失败'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return ['success' => false,'message' => $e->getMessage()];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function procurementBill(Request $request,ProcurementFilters $filters)
|
|
|
+ {
|
|
|
+ if(!Gate::allows('采购管理-财务-采购账单')){ return ["success"=>false,"data"=>"您无此权限操作!"]; }
|
|
|
+ $paginateParams=$request->input();
|
|
|
+ $owner_ids=app('UserService')->getPermittingOwnerIds(auth()->user());
|
|
|
+ $owners=app("OwnerService")->getIntersectPermitting();
|
|
|
+ $materials=Material::query()->select('id','name')->get();
|
|
|
+ $suppliers=Supplier::query()->select('id','name')->get();
|
|
|
+ $procurements = Procurement::query()
|
|
|
+ ->filter($filters)
|
|
|
+ ->with(['initiator','supplier','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
|
|
|
+ $query->with('customer')->whereIn('id',$owner_ids);
|
|
|
+ }])
|
|
|
+ ->where('type',0) //只取采购单
|
|
|
+ ->paginate($param['paginate'] ?? 50);
|
|
|
+ return view('procurement/finance/procurementBill',compact('suppliers','materials','owners','paginateParams','procurements'));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function monthlyBillReport(Request $request)
|
|
|
+ {
|
|
|
+ if(!Gate::allows('采购管理-财务-月账单报表')){ return ["success"=>false,"data"=>"您无此权限操作!"]; }
|
|
|
+ $paginateParams=$request->input();
|
|
|
+ /** @var ProcurementTotalBillService $procurementTotalBillService*/
|
|
|
+ $procurementTotalBillService=app(ProcurementTotalBillService::class);
|
|
|
+ $procurementTotalBills=$procurementTotalBillService->paginate($paginateParams);
|
|
|
+ $suppliers=Supplier::query()->select('id','name')->get();
|
|
|
+ return view('procurement/finance/monthlyBillReport',compact('suppliers','procurementTotalBills','paginateParams'));
|
|
|
+ }
|
|
|
+ //采购导出
|
|
|
+ public function procurementExport(Request $request,ProcurementFilters $filters){
|
|
|
+ $this->gate('采购管理-采购-查询');
|
|
|
+ $owner_ids=app('UserService')->getPermittingOwnerIds(auth()->user());
|
|
|
+ $procurements = Procurement::query()
|
|
|
+ ->filter($filters)
|
|
|
+ ->with(['initiator','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
|
|
|
+ $query->with('customer')->whereIn('id',$owner_ids);
|
|
|
+ }])->get();
|
|
|
+
|
|
|
+ $procurementStatus=Procurement::status;
|
|
|
+ $procurementType=Procurement::type;
|
|
|
+ $row = ['采购编号','项目','单据类型','采购公司','耗材编号','耗材','尺寸大小','特殊要求','材质规格','采购数量','销售单价(元)','送货数量','销售总价(元)','采购单状态','联系方式'];
|
|
|
+ $list = [];
|
|
|
+ foreach ($procurements as $procurement){
|
|
|
+ $list[] = [
|
|
|
+ $procurement->code,
|
|
|
+ $procurement->ownerMaterial->owner ? $procurement->ownerMaterial->owner->name :'',
|
|
|
+ is_null($procurement->type) ? '' :$procurementType[$procurement->type],
|
|
|
+ $procurement->ownerMaterial->owner->customer ? $procurement->ownerMaterial->owner->customer->company_name :'',
|
|
|
+ $procurement->ownerMaterial->material ? $procurement->ownerMaterial->material->code :'',
|
|
|
+ $procurement->ownerMaterial->material ? $procurement->ownerMaterial->material->name :'',
|
|
|
+ $procurement->ownerMaterial ? $procurement->ownerMaterial->size :'',
|
|
|
+ $procurement->ownerMaterial ? $procurement->ownerMaterial->special :'',
|
|
|
+ $procurement->ownerMaterial ? $procurement->ownerMaterial->specification :'',
|
|
|
+ $procurement->quantity,
|
|
|
+ $procurement->unit_price,
|
|
|
+ '',//送货数量
|
|
|
+ '',//销售总价
|
|
|
+ is_null($procurement->status) ? '' :$procurementStatus[$procurement->status],
|
|
|
+ $procurement->ownerMaterial->owner->customer ? $procurement->ownerMaterial->owner->customer->phone :'',
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return app(ExportService::class)->json($row,$list,"采购管理-采购报表记录");
|
|
|
+ }
|
|
|
+ //对账单报表导出
|
|
|
+ public function checkBillExport(Request $request,ProcurementCheckSheetFilters $filters){
|
|
|
+ $this->gate('采购管理-财务-对账单');
|
|
|
+ $procurementCheckSheets=ProcurementCheckSheet::query()
|
|
|
+ ->filter($filters)
|
|
|
+ ->with(['procurementDelivery.procurement.supplier','procurementDelivery.procurement.ownerMaterial.material','procurementDelivery.receiver'])
|
|
|
+ ->get();
|
|
|
+ $procurementCheckSheetStatus=ProcurementCheckSheet::status;
|
|
|
+ $row = ['采购编号','采购日期','送货日期','供应商名称','耗材编号','耗材','采购数量','送货数量','签收人','签收日期','应付金额','发票号','状态'];
|
|
|
+ $list = [];
|
|
|
+ foreach ($procurementCheckSheets as $procurementCheckSheet){
|
|
|
+ $list[] = [
|
|
|
+ $procurementCheckSheet->procurementDelivery->procurement ? $procurementCheckSheet->procurementDelivery->procurement->code : '',
|
|
|
+ $procurementCheckSheet->procurementDelivery->procurement ? $procurementCheckSheet->procurementDelivery->procurement->created_at :'',
|
|
|
+ $procurementCheckSheet->procurementDelivery ? $procurementCheckSheet->procurementDelivery->created_at :'',
|
|
|
+ $procurementCheckSheet->procurementDelivery->procurement->supplier ? $procurementCheckSheet->procurementDelivery->procurement->supplier->name :'',
|
|
|
+ $procurementCheckSheet->procurementDelivery->procurement->ownerMaterial->material ? $procurementCheckSheet->procurementDelivery->procurement->ownerMaterial->material->code :'',
|
|
|
+ $procurementCheckSheet->procurementDelivery->procurement->ownerMaterial->material ? $procurementCheckSheet->procurementDelivery->procurement->ownerMaterial->material->name :'',
|
|
|
+ $procurementCheckSheet->procurementDelivery->procurement ? $procurementCheckSheet->procurementDelivery->procurement->quantity :'',
|
|
|
+ $procurementCheckSheet->procurementDelivery ? $procurementCheckSheet->procurementDelivery->amount :'',
|
|
|
+ $procurementCheckSheet->procurementDelivery->receiver ? $procurementCheckSheet->procurementDelivery->receiver->name :'',
|
|
|
+ $procurementCheckSheet->procurementDelivery ? $procurementCheckSheet->procurementDelivery->signed_at :'',
|
|
|
+ $procurementCheckSheet->account_payable,
|
|
|
+ $procurementCheckSheet->invoice_number,
|
|
|
+ is_null($procurementCheckSheet->status) ? '' :$procurementCheckSheetStatus[$procurementCheckSheet->status],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return app(ExportService::class)->json($row,$list,"采购管理-对账单报表记录");
|
|
|
+ }
|
|
|
+ //采购账单导出
|
|
|
+ public function procurementBillExport(Request $request,ProcurementFilters $filters){
|
|
|
+ $this->gate('采购管理-财务-采购账单');
|
|
|
+ $owner_ids=app('UserService')->getPermittingOwnerIds(auth()->user());
|
|
|
+ $procurements = Procurement::query()
|
|
|
+ ->filter($filters)
|
|
|
+ ->with(['initiator','supplier','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
|
|
|
+ $query->with('customer')->whereIn('id',$owner_ids);
|
|
|
+ }])->get();
|
|
|
+
|
|
|
+ $procurementStatus=Procurement::status;
|
|
|
+ $row = ['采购编号','采购日期','接单日期','签收日期','项目名称','采购公司','供应商','耗材编号','耗材','尺寸大小','特殊要求',
|
|
|
+ '材质规格','采购数量','销售数量','收货数量','采购单价(元)','销售单价(元)','应收金额(元)','应付金额(元)','状态'];
|
|
|
+ $list = [];
|
|
|
+ foreach ($procurements as $procurement){
|
|
|
+ $list[] = [
|
|
|
+ $procurement->code,
|
|
|
+ $procurement->created_at,
|
|
|
+ '',//接单日期
|
|
|
+ '',//签收日期
|
|
|
+ $procurement->ownerMaterial->owner ? $procurement->ownerMaterial->owner->name :'',
|
|
|
+ $procurement->ownerMaterial->owner->customer ? $procurement->ownerMaterial->owner->customer->company_name :'',
|
|
|
+ $procurement->supplier ? $procurement->supplier->name :'',
|
|
|
+ $procurement->ownerMaterial->material ? $procurement->ownerMaterial->material->code :'',
|
|
|
+ $procurement->ownerMaterial->material ? $procurement->ownerMaterial->material->name :'',
|
|
|
+ $procurement->ownerMaterial ? $procurement->ownerMaterial->size :'',
|
|
|
+ $procurement->ownerMaterial ? $procurement->ownerMaterial->special :'',
|
|
|
+ $procurement->ownerMaterial ? $procurement->ownerMaterial->specification :'',
|
|
|
+ $procurement->quantity,
|
|
|
+ $procurement->amount,
|
|
|
+ '',//收货数量
|
|
|
+ $procurement->cost_price,
|
|
|
+ $procurement->unit_price,
|
|
|
+ '',//应收金额
|
|
|
+ '',//应付金额
|
|
|
+ is_null($procurement->status) ? '' :$procurementStatus[$procurement->status],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return app(ExportService::class)->json($row,$list,"采购账单报表记录");
|
|
|
+ }
|
|
|
+ //月账单报表导出
|
|
|
+ public function procurementTotalBillExport(Request $request){
|
|
|
+ $this->gate('采购管理-财务-月账单报表');
|
|
|
+ /** @var ProcurementTotalBillService $procurementTotalBillService*/
|
|
|
+ $procurementTotalBillService=app(ProcurementTotalBillService::class);
|
|
|
+ if ($request->input('checkAllSign')){
|
|
|
+ $params = $request->input();
|
|
|
+ unset($params["checkAllSign"]);
|
|
|
+ $procurementTotalBills=$procurementTotalBillService->get($params);
|
|
|
+ }else{
|
|
|
+ $procurementTotalBills=$procurementTotalBillService->get(["id"=>$request->data]);
|
|
|
+ }
|
|
|
+ $procurementTotalBillStatus=ProcurementTotalBill::status;
|
|
|
+ $row = ['对账编号','账单日期','提交日期','供应商','总金额','状态'];
|
|
|
+ $list = [];
|
|
|
+ foreach ($procurementTotalBills as $procurementTotalBill){
|
|
|
+ $list[] = [
|
|
|
+ $procurementTotalBill->id,
|
|
|
+ $procurementTotalBill->counting_month,
|
|
|
+ $procurementTotalBill->created_at,
|
|
|
+ $procurementTotalBill->supplier ? $procurementTotalBill->supplier :'',
|
|
|
+ $procurementTotalBill->total_payable,
|
|
|
+ $procurementTotalBill->status ? $procurementTotalBillStatus[$procurementTotalBill->status] :'',
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return app(ExportService::class)->json($row,$list,"采购管理-月账单报表记录");
|
|
|
+ }
|
|
|
+}
|