Parcourir la source

Merge branch 'Haozi' of ssh://was.baoshi56.com:10022/var/git/bswas

LD il y a 4 ans
Parent
commit
3fbb959b62

+ 5 - 3
app/Filters/ProcurementCheckSheetFilters.php

@@ -33,9 +33,10 @@ class ProcurementCheckSheetFilters
     public function apply($builder)
     {
         $this->queryBuilder = $builder;
-        $filters = array_filter($this->request->only($this->filters));
+        $filters = array_filter($this->request->only($this->filters),function($item){
+            return $item == null ? false : true;
+        });
         $this->beforeApply();
-
         foreach ($filters as $filter => $value) {
             if (method_exists($this, $filter)) {
                 $this->$filter($value, $this->queryBuilder);
@@ -95,7 +96,8 @@ class ProcurementCheckSheetFilters
     }
     public function signed_at($signed_at)
     {
-        $this->getProcurementDeliveryQuery()->where('signed_at','>=',"{$signed_at} 00:00:00")->where('signed_at','<=',"{$signed_at} 23:59:59");
+//        $this->getProcurementDeliveryQuery()->where('signed_at','>=',"{$signed_at} 00:00:00")->where('signed_at','<=',"{$signed_at} 23:59:59");
+        $this->getProcurementDeliveryQuery()->where('signed_at','like',$signed_at.'%');
     }
 
     public function beforeApply()

+ 35 - 3
app/Http/Controllers/ProcurementController.php

@@ -298,9 +298,33 @@ class ProcurementController extends Controller
         $this->gate('采购管理-财务-对账单');
         $id=$request->input('procurementCheckSheetId');
         $invoice_number=$request->input('invoice_number');
-        $procurementCheckSheet=ProcurementCheckSheet::query()->where('id',$id)->update(['invoice_number'=>$invoice_number]);
-        if ($procurementCheckSheet) return ['success' => true,'data' => $invoice_number];
-        else return ['success' => false, 'message' => '添加失败'];
+        $procurementCheckSheet=ProcurementCheckSheet::query()->find($id);
+        $procurementTotalBill=null;
+        $procurementCheckSheet->update([
+                'invoice_number'=>$invoice_number,
+                'status'=>3,//3 已完结
+            ]);
+        $supplier_id = $procurementCheckSheet->procurementDelivery->procurement->supplier_id ?? null;
+        $ProcurementQuery = Procurement::query()->select("id")
+            ->where('supplier_id',$supplier_id);
+        $procurementDeliveryQuery= ProcurementDeliverie::query()->select('id')
+            ->whereIn("procurement_id",$ProcurementQuery)
+            ->where("created_at","like",Carbon::parse($procurementCheckSheet['procurementDelivery']['created_at'])->format('Y-m')."%");
+        $count=ProcurementCheckSheet::query()
+            ->with(['procurementDelivery.procurement.ownerMaterial.material','procurementDelivery.procurement.supplier'])
+            ->whereIn('procurement_delivery_id',$procurementDeliveryQuery)->where('status','!=',3)->count();
+        if($count==0){
+            $procurementTotalBill=ProcurementTotalBill::query()
+                ->where('counting_month','like',Carbon::parse($procurementCheckSheet['procurementDelivery']['created_at'])->format('Y-m')."%")
+                ->where('supplier_id',$supplier_id)
+                ->update(['status'=>2]);
+        }
+        if ($procurementTotalBill) {
+            return ['success' => true,'data' => $invoice_number,'status'=>3,'totalStatus'=>2];
+        }
+        elseif ($procurementCheckSheet){
+            return ['success' => true,'data' => $invoice_number,'status'=>3];
+        }else return ['success' => false, 'message' => '添加失败'];
 
     }
 
@@ -344,6 +368,14 @@ class ProcurementController extends Controller
         $suppliers=Supplier::query()->select('id','name')->get();
         return view('procurement/finance/monthlyBillReport',compact('suppliers','procurementTotalBills','paginateParams'));
     }
+    public function getCheckBillMonth(Request $request)
+    {
+        if(!Gate::allows('采购管理-财务-月账单报表')){ return ["success"=>false,"data"=>"您无此权限操作!"];  }
+        $procurementTotalBill=ProcurementTotalBill::query()->find($request->input('procurement_total_bill_id'));
+        /** @var  ProcurementTotalBill $procurementTotalBill */
+        $procurementTotalBill->setCurrentMothProcurements();
+        return ["success"=>true,"data"=>$procurementTotalBill->procurementCheckSheets??[]];
+    }
     //采购导出
     public function procurementExport(Request $request,ProcurementFilters $filters){
         $this->gate('采购管理-采购-查询');

+ 6 - 2
app/ProcurementTotalBill.php

@@ -43,15 +43,19 @@ class ProcurementTotalBill extends Model
     public function  setCurrentMothProcurements(){
         $ProcurementQuery = Procurement::query()->select("id")
             ->where('supplier_id',$this->supplier_id);
-//            ->where("created_at","like",$this->counting_month."%");
          $procurementDeliveryQuery= ProcurementDeliverie::query()->select('id')
             ->whereIn("procurement_id",$ProcurementQuery)
             ->where("created_at","like",$this->counting_month."%");
         $this->relations["procurementCheckSheets"]=ProcurementCheckSheet::query()
-            ->with(['procurementDelivery.procurement.ownerMaterial.material'])
+            ->with(['procurementDelivery.procurement.ownerMaterial.material','procurementDelivery.procurement.supplier'])
             ->whereIn('procurement_delivery_id',$procurementDeliveryQuery)->get();
     }
 
+    public function checkSheet()
+    {
+
+    }
+
     protected static function booted()
     {
         /** @var User $user */

+ 1 - 1
resources/views/personnel/checking-in/createReplenishClock.blade.php

@@ -6,7 +6,7 @@
         @component('personnel.checking-in.menuChecking-in')@endcomponent
     </div>
     <div class="container-fluid" id="list">
-        <div class="card col-md-10 offset-1">
+        <div class="card">
             <div class="card-body">
                 <div class="form-group row">
                     <input v-model="full_name" class="col-6 offset-2 form-control" type="text" placeholder="按名称搜索临时工">

+ 1 - 1
resources/views/personnel/discharge/facilitator/index.blade.php

@@ -110,7 +110,7 @@
                     window.axios.post(url,data).then(res=>{
                         if(res.data.success){
                             this.$set(this.facilitatorStatements[index],'subjection',res.data.data);
-                            facilitatorStatement['showSubject'] = true;selectAll
+                            facilitatorStatement['showSubject'] = true;/*selectAll*/
                             $("#Statement"+index).slideToggle();
                             $($e.target).html('点击收起');
                             this.$forceUpdate();

+ 5 - 4
resources/views/procurement/finance/checkBill.blade.php

@@ -106,16 +106,16 @@
                 $('#list').removeClass('d-none');
                 let data = [
                     [
-                        {name: 'signed_at', type: 'dateTime', tip: '选择显示指定的签收日期'},
+                        {name: 'signed_at', type: 'dateMonth', tip: '选择显示指定的签收日期'},
                         {
                             name: 'supplier_id', type: 'select_multiple_select', tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的供应商'],
                             placeholder: ['供应商', '定位或多选供应商'], data: this.suppliers
                         },
                         {
                             name: 'status', type: 'select',
-                            tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的耗材'],
+                            tip: '输入关键词快速定位下拉列表,回车确定',
                             placeholder: '对账单状态',
-                            data: [{name:0,value:'未出账'},{name:1,value:'已出账'},{name:2,value:'已完结'},],
+                            data: [{name:0,value:'未出账'},{name:1,value:'待出账'},{name:2,value:'已出账'},{name:3,value:'已完结'},],
                         },
                     ],
                 ];
@@ -172,7 +172,8 @@
                         }else {
                             _this.procurementCheckSheets.forEach(function (procurementCheckSheet) {
                                 if (procurementCheckSheet.id===_this.procurementCheckSheetId){
-                                    procurementCheckSheet.invoice_number=_this.invoice_number;
+                                    procurementCheckSheet.invoice_number=res.data.data;
+                                    procurementCheckSheet.status=res.data.status;
                                 }
                             });
                             $("#fill-invoice-number").modal('hide');

+ 4 - 4
resources/views/procurement/finance/menu.blade.php

@@ -4,17 +4,17 @@
     <div class="container-fluid nav3">
         <div class="card menu-third" >
             <ul class="nav nav-pills">
-                @can('采购管理-财务-对账单')
+                @can('采购管理-财务-月账单报表')
                     <li class="nav-item">
-                        <a class="nav-link" href="{{url('procurement/finance/checkBill')}}" :class="{active:isActive('checkBill',3)}">对账单</a>
+                        <a  class="nav-link" href="{{url('procurement/finance/monthlyBillReport')}}" :class="{active:isActive('monthlyBillReport',3)}">月账单报表</a>
                     </li> @endcan
                 @can('采购管理-财务-采购账单')
                     <li class="nav-item">
                         <a  class="nav-link" href="{{url('procurement/finance/procurementBill')}}" :class="{active:isActive('procurementBill',3)}">采购账单</a>
                     </li> @endcan
-                    @can('采购管理-财务-月账单报表')
+                @can('采购管理-财务-对账单')
                     <li class="nav-item">
-                        <a  class="nav-link" href="{{url('procurement/finance/monthlyBillReport')}}" :class="{active:isActive('monthlyBillReport',3)}">月账单报表</a>
+                        <a class="nav-link" href="{{url('procurement/finance/checkBill')}}" :class="{active:isActive('checkBill',3)}">对账单</a>
                     </li> @endcan
             </ul>
         </div>

+ 141 - 8
resources/views/procurement/finance/monthlyBillReport.blade.php

@@ -18,18 +18,84 @@
         </span>
         </div>
         <table class="table table-sm table-striped table-bordered table-hover text-nowrap card-body mt-2 td-min-width-80" id="table">
-            <tr v-for="(procurementTotalBill,i) in procurementTotalBills">
-                <td>
+            <template  v-for="(procurementTotalBill,i) in procurementTotalBills">
+            <tr>
+                <td >
                     <input class="checkItem" type="checkbox" :value="procurementTotalBill.id">
                 </td>
-                <td><span>@{{ procurementTotalBill.id }}</span></td>
-                <td class="text-muted"><span>@{{ procurementTotalBill.counting_month }}</span></td>
-                <td class="text-muted"><span>@{{ procurementTotalBill.created_at.substr(0,10) }}</span></td>
-                <td class="text-muted"><span>@{{ procurementTotalBill.supplier_name }}</span></td>
-                <td><span>@{{ procurementTotalBill.total_payable }}</span></td>
-                <td><span>@{{ procurement_total_bill_status[procurementTotalBill.status] }}</span></td>
+                <td class="text-center"><span>@{{ procurementTotalBill.id }}</span></td>
+                <td class="text-muted text-center"><span>@{{ procurementTotalBill.counting_month }}</span></td>
+                <td class="text-muted text-center"><span>@{{ procurementTotalBill.created_at.substr(0,10) }}</span></td>
+                <td class="text-muted text-center"><span>@{{ procurementTotalBill.supplier_name }}</span></td>
+                <td class="text-center"><span>@{{ procurementTotalBill.total_payable }}</span></td>
+                <td class="text-center"><span>@{{ procurement_total_bill_status[procurementTotalBill.status] }}</span></td>
+                <td class="text-center">
+                    <button class="btn btn-sm btn-outline-info" @click="getCheckBill(procurementTotalBill,i,$event)">点击展开</button>
+                </td>
+            </tr>
+            <tr v-if="procurementTotalBill.showSubject" class="p-0 up" >
+                <td></td>
+                <td colspan="7" class="p-0 m-0">
+                    <div class="p-0 " :id="'Statement' + i">
+                        <table class="table table-bordered m-0">
+                            <thead class="thead-light">
+                            <tr>
+                                <th>采购编号</th>
+                                <th>采购日期</th>
+                                <th>送货日期</th>
+                                <th>供应商</th>
+                                <th>耗材编号</th>
+                                <th>耗材</th>
+                                <th>采购数量</th>
+                                <th>送货数量</th>
+                                <th>签收人</th>
+                                <th>签收日期</th>
+                                <th>应付金额</th>
+                                <th>发票号</th>
+                                <th>状态</th>
+                                <th>填写发票号</th>
+                            </tr>
+                            </thead>
+                            <tbody>
+                            <tr v-for="(procurementCheckSheet,i) in procurementTotalBill.procurementCheckSheets">
+                                <td>
+                                    <span v-if="procurementCheckSheet.procurement_delivery.procurement">@{{ procurementCheckSheet.procurement_delivery.procurement.code }}</span></td>
+                                <td class="text-muted">
+                                    <span v-if="procurementCheckSheet.procurement_delivery.procurement">@{{ procurementCheckSheet.procurement_delivery.procurement.created_at }}</span></td>
+                                <td class="text-muted">
+                                    <span v-if="procurementCheckSheet.procurement_delivery">@{{ procurementCheckSheet.procurement_delivery.created_at }}</span></td>
+                                <td class="text-muted">
+                                    <span v-if="procurementCheckSheet.procurement_delivery.procurement.supplier">@{{ procurementCheckSheet.procurement_delivery.procurement.supplier.name }}</span></td>
+                                <td class="tooltipTarget" style="max-width: 200px;overflow:hidden">
+                                    <span  v-if="procurementCheckSheet.procurement_delivery.procurement.owner_material">@{{ procurementCheckSheet.procurement_delivery.procurement.owner_material.material_code }}</span></td>
+                                <td class="text-muted">
+                                    <span v-if="procurementCheckSheet.procurement_delivery.procurement.owner_material">@{{ procurementCheckSheet.procurement_delivery.procurement.owner_material.material.name }}</span></td>
+                                <td class="text-muted">
+                                    <span v-if="procurementCheckSheet.procurement_delivery.procurement">@{{ procurementCheckSheet.procurement_delivery.procurement.quantity }}</span></td>
+                                <td class="text-muted">
+                                    <span v-if="procurementCheckSheet.procurement_delivery">@{{ procurementCheckSheet.procurement_delivery.amount }}</span></td>
+                                <td class="text-muted">
+                                    <span v-if="procurementCheckSheet.procurement_delivery.receiver">@{{ procurementCheckSheet.procurement_delivery.receiver.name }}</span></td>
+                                <td class="text-muted">
+                                    <span v-if="procurementCheckSheet.procurement_delivery">@{{ procurementCheckSheet.procurement_delivery.signed_at }}</span></td>
+                                <td class="text-muted"><span >@{{ procurementCheckSheet.account_payable }}</span></td>
+                                <td><span>@{{ procurementCheckSheet.invoice_number }}</span></td>
+                                <td><span>@{{ procurement_check_sheet_status[procurementCheckSheet.status] }}</span></td>
+                                <td class="text-center">
+                                    <a class="text-primary" @click="fillInvoiceNumber(procurementCheckSheet.id)" v-if="!procurementCheckSheet.invoice_number">填写发票号</a>
+                                    <span v-else>-</span>
+                                </td>
+                            </tr>
+                            </tbody>
+                        </table>
+                    </div>
+                </td>
             </tr>
+            </template>
         </table>
+        @can('采购管理-财务-对账单')
+            @include('procurement.finance._fillInvoiceNumber')
+        @endcan
         <div class="text-info h5 btn btn">{{$procurementTotalBills->count()}}/@{{ sum }}</div>
         <div>{{$procurementTotalBills->appends($paginateParams)->links()}}</div>
     </div>
@@ -46,6 +112,7 @@
                     @foreach($procurementTotalBills as $procurementTotalBill)
                     {
                         id:'{{$procurementTotalBill->id ?? ''}}',counting_month:'{{$procurementTotalBill->counting_month ?? ''}}',
+                        showSubject:false,procurementCheckSheets:[],
                         created_at:'{{$procurementTotalBill->created_at ?? ''}}',status:'{{$procurementTotalBill->status ?? ''}}',total_payable:'{{$procurementTotalBill->total_payable ?? ''}}',
                             @if($procurementTotalBill->supplier)
                             supplier_id:'{{$procurementTotalBill->supplier->id ?? ''}}',supplier_name:'{{$procurementTotalBill->supplier->name ?? ''}}',@endif
@@ -59,9 +126,12 @@
                 ],
                 sum:{!! $procurementTotalBills->total() !!},
                 procurement_total_bill_status:{!! json_encode(\App\ProcurementTotalBill::status,JSON_UNESCAPED_UNICODE) !!},
+                procurement_check_sheet_status:{!! json_encode(\App\ProcurementCheckSheet::status,JSON_UNESCAPED_UNICODE) !!},
+                invoice_number:'',procurementCheckSheetId:null,index:'',
 
             },
             mounted: function () {
+                $(".up").slideUp();
                 $(".tooltipTarget").tooltip({'trigger': 'hover'});
                 $('#list').removeClass('d-none');
                 let data = [
@@ -85,6 +155,7 @@
                     {name: 'supplier', value: '供应商',class: 'text-center'},
                     {name: 'total_payable', value: '总金额',class: 'text-center'},
                     {name: 'status', value: '状态',class: 'text-center'},
+                    {name: 'detail', value: '月账单详情',class: 'text-center'},
                 ];
                 new Header({
                     el: "table",
@@ -100,6 +171,68 @@
                     let token='{{ csrf_token() }}';
                     excelExport(selectAll,checkData,url,this.sum,token);
                 },
+                getCheckBill(procurementTotalBill,index,$e){
+                    this.index=index;
+                    if(procurementTotalBill.showSubject){
+                        procurementTotalBill.showSubject=false;
+                        $($e.target).html('点击展开');
+                        return;
+                    }
+                    $($e.target).html('加载中...');
+                    let url = '{{url('procurement/finance/getCheckBillMonth')}}'
+                    let data = {
+                        'procurement_total_bill_id':procurementTotalBill['id'],
+                    };
+                    window.axios.post(url,data).then(res=>{
+                        if(res.data.success){
+                            // this.$set(this.procurementTotalBills[index],'subjection',res.data.data);
+                            this.procurementTotalBills[index].procurementCheckSheets=res.data.data;
+                            procurementTotalBill['showSubject'] = true;
+                            $("#Statement"+index).slideToggle();
+                            $($e.target).html('点击收起');
+                            this.$forceUpdate();
+                        }
+                    }).catch(err=>{
+                        $($e.target).html('点击展开');
+                        window.tempTip.show(err);
+                    });
+                },
+                fillInvoiceNumber(id){
+                    let _this=this;
+                    _this.procurementCheckSheetId=id;
+                    $('#fill-invoice-number').modal('show');
+                },
+                fillInvoice(){
+                    let _this=this;
+                    if (!_this.procurementCheckSheetId)return;
+                    if (!_this.invoice_number){
+                        tempTip.setDuration(3000);
+                        tempTip.show('发票号不可为空!');
+                        return;
+                    }
+                    let url = '{{url('procurement/finance/fillInvoice')}}';
+                    let params = {invoice_number:_this.invoice_number,procurementCheckSheetId:_this.procurementCheckSheetId};
+                    window.axios.post(url,params).then(function (res) {
+                        if (!res.data.success){
+                            tempTip.setDuration(3000);
+                            tempTip.show(res.data.message);
+                        }else {
+                            _this.procurementTotalBills[_this.index].procurementCheckSheets.forEach(function (procurementCheckSheet) {
+                                if (procurementCheckSheet.id===_this.procurementCheckSheetId){
+                                    procurementCheckSheet.invoice_number=res.data.data;
+                                    procurementCheckSheet.status=res.data.status;
+                                }
+                            });
+                            if (res.data.totalStatus) _this.procurementTotalBills[_this.index].status=res.data.totalStatus;
+                            $("#fill-invoice-number").modal('hide');
+                            tempTip.setDuration(3000);
+                            tempTip.showSuccess('添加发票号成功!');
+                        }
+                    }).catch(function (err) {
+                        tempTip.setDuration(3000);
+                        tempTip.show('添加发票号失败!网络错误:'+err);
+                    });
+                },
             }
         });
     </script>

+ 1 - 0
routes/web.php

@@ -840,6 +840,7 @@ Route::group(['prefix'=>'procurement'],function () {
         Route::any('procurementBillExport','ProcurementController@procurementBillExport');
         Route::any('checkBillExport','ProcurementController@checkBillExport');
         Route::post('costPrice','ProcurementController@costPrice');
+        Route::post('getCheckBillMonth','ProcurementController@getCheckBillMonth');
     });
     Route::get('relating',function (){return view('procurement.menuProcurement');});
 });

+ 11 - 2
tests/Services/BatchService/AssignTasksTest.php

@@ -4,6 +4,7 @@ namespace Tests\Services\BatchService;
 use App\MaterialBox;
 use App\Order;
 use App\OrderCommodity;
+use App\Owner;
 use App\Services\BatchService;
 use App\Services\ForeignHaiRoboticsService;
 use App\Services\StationTaskBatchService;
@@ -50,9 +51,12 @@ class AssignTasksTest extends TestCase
                 ],
             ]
         ]);
+        $this->data['owner']
+            = factory(Owner::class)
+            ->create();
         $this->data['batches']
             = factory(Batch::class, $this->batchAmount)
-            ->create();
+            ->create(['owner_id'=>$this->data['owner']['id']]);
         $this->data['orders'] =
             factory(Order::class)
                 ->createMany($this->makeArray($this->orderAmount,[
@@ -63,7 +67,7 @@ class AssignTasksTest extends TestCase
             factory(OrderCommodity::class)
                 ->createMany($this->makeArray($this->orderCommodityAmount,[
                     'order_id' => function(){return $this->getTargetFieldCirculately($this->data['orders']);},
-                    'location' => function(){return Uuid::uuid4() . '_' . rand(1, 6);},
+                    'location' => function(){return 'IDE' . rand(1, 6);},
                 ]));
         $this->data['station_rule_batches']
             = factory(StationRuleBatch::class)
@@ -78,6 +82,8 @@ class AssignTasksTest extends TestCase
         $this->service->assignTasks($this->data['batches']);
         ($波次任务指向了波次=function(){
             $this->data['batches']->load('stationTaskBatch');
+            dump(data_get($this->data['batches'],'*.id'),data_get($this->data['batches'],'*.stationTaskBatch.batch_id'));
+            dd(array_diff(data_get($this->data['batches'],'*.id'),data_get($this->data['batches'],'*.stationTaskBatch.batch_id')));
             $this->assertEquals(
                 data_get($this->data['batches'],'*.id'),
                 data_get($this->data['batches'],'*.stationTaskBatch.batch_id')
@@ -114,6 +120,9 @@ class AssignTasksTest extends TestCase
         Batch::query()
             ->whereIn('id',data_get($this->data['batches'],'*.id')??[])
             ->delete();
+        Owner::query()
+            ->whereIn('id',data_get($this->data['owner'],'*.id')??[])
+            ->delete();
         parent::tearDown();
     }
 }