diff --git a/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php index 5abe023d..99ebf9c1 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php @@ -397,11 +397,14 @@ class FetchOrderListsFromYdPortalProcessor $packingList->save(); } - $signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture; - foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){ - $this->updatesContractObligations->execute($signature, $step->obligation_hash_id); - $step->update(['status' => ApprovalStatus::COMPLETED]); + if ($allow_contract) { + $signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture; + foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){ + $this->updatesContractObligations->execute($signature, $step->obligation_hash_id); + $step->update(['status' => ApprovalStatus::COMPLETED]); + } } + } } } @@ -416,10 +419,14 @@ class FetchOrderListsFromYdPortalProcessor $transport = $this->createsTransport->execute($transportObject, $packingList); $this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED)); - $deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first(); - $signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture; - $this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id); - $deliveryStep->update(['status' => ApprovalStatus::COMPLETED]); + + if ($allow_contract) { + $deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first(); + $signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture; + $this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id); + $deliveryStep->update(['status' => ApprovalStatus::COMPLETED]); + } + } echo 'successful';