<?php


namespace Tests\Services\RejectedBillService;


use App\OracleDOCASNHeader;
use App\Services\OwnerService;
use App\Services\RejectedBillService;
use App\Services\StoreItemService;
use App\Services\StoreService;
use App\Services\WarehouseService;
use App\Store;
use Carbon\Carbon;
use Tests\TestCase;

class SyncLoadedStatusByAsnHeaderTest extends TestCase
{
    /**
     * @var RejectedBillService $service
     *
     */
    public $service;
    public $asnHeaders;
    public function setUp(): void
    {
        parent::setUp(); // TODO: Change the autogenerated stub
        $startDate = \Illuminate\Support\Carbon::now()->subSeconds(300);
        $this->service=app(RejectedBillService::class);
        $this->asnHeaders=OracleDOCASNHeader::query()
            ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
                $query->with(['lineStatus', 'qualityStatus','basSku']);
            }])
            ->where('addTime', '>=', $startDate)
            ->get();
    }
    public function testSyncLoadedStatusByAsnHeaderTest(){
        if (empty($this->asnHeaders))return null;
        $updateCollect=$this->service->getUpdateCollect($this->asnHeaders);
        if ($updateCollect->isEmpty())return null;
        $logisticNumberReturn=$this->service->getLogisticNumberReturn($updateCollect);
        $rejectedBills=$this->service->getRejectedBills($logisticNumberReturn);
        if ($rejectedBills->isEmpty())return null;
        $this->assertNull($rejectedBills);
        $this->service->syncLoadedStatusByAsnHerder($this->asnHeaders);
        $this->assertNull($logisticNumberReturn);
    }
}
