<?php

namespace App\Services;

use App\OracleDOCASNHeader;

Class OracleDocAsnHerderService
{
    public function getWmsAsnOnStartDateCreate($startDate)
    {
        if (!$startDate) return null;
        return OracleDOCASNHeader::query()
            ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
                $query->with(['lineStatus', 'qualityStatus','basSku']);
            }])
            ->select('asnno','asnstatus','asntype','addtime','edittime','customerid','notes','warehouseid','asnreference3')
            ->where('addTime', '>=', $startDate)
            ->get();
    }

    public function getWmsAsnOnStartDateEdit($startDate)
    {
        if (!$startDate) return null;
        $oracleDocAsnHerder= OracleDOCASNHeader::query()
            ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
                $query->with(['lineStatus', 'qualityStatus','basSku']);
            }])
            ->select('asnno','asnstatus','asntype','addtime','edittime','customerid','notes','warehouseid','asnreference3')
            ->where('EditTime', '>=', $startDate)
            ->whereColumn('EditTime', '<>', 'addTime')
            ->get();
        return $oracleDocAsnHerder;
    }

}
