bookWithNote($userId, $day, $workTypeId, $quarters, __('sales.orders.hours_note', ['number' => $pickupNumber])); } public function book(int $sellerId, DateTimeImmutable $day, int $workTypeId, int $quarters, int $saleId): bool { return $this->bookWithNote($sellerId, $day, $workTypeId, $quarters, __('sales.hours_note', ['number' => $saleId])); } private function bookWithNote(int $sellerId, DateTimeImmutable $day, int $workTypeId, int $quarters, string $note): bool { $year = (int) $day->format('Y'); try { $taskId = $this->tasks->execute($year, $workTypeId, $sellerId, __('sales.job_name', ['year' => $year])); $this->addHours->execute( $sellerId, $taskId, $day->format('Y-m-d'), number_format($quarters / 4, 2, ',', ''), $note, ); } catch (DomainException) { // Approved or locked hours, or a day over 24 hours: the sale stands without them. return false; } return true; } }