$sales The day's sales, credits included. * * @throws CashDayClosed */ public function close(array $sales, int $closedBy, DateTimeImmutable $now): void { $this->ensureOpen(); $this->balance = CashDayBalance::of($sales); $this->closedBy = $closedBy; $this->closedAt = $now; } /** * @throws CashDayNotClosed */ public function reopen(int $reopenedBy, DateTimeImmutable $now): void { if (! $this->isClosed()) { throw new CashDayNotClosed; } $this->balance = null; $this->closedBy = null; $this->closedAt = null; $this->reopenedBy = $reopenedBy; $this->reopenedAt = $now; } /** * @throws CashDayClosed */ public function ensureOpen(): void { if ($this->isClosed()) { throw new CashDayClosed; } } public function isClosed(): bool { return $this->closedAt !== null; } public function id(): ?int { return $this->id; } public function day(): DateTimeImmutable { return $this->day; } public function balance(): ?CashDayBalance { return $this->balance; } public function closedBy(): ?int { return $this->closedBy; } public function closedAt(): ?DateTimeImmutable { return $this->closedAt; } public function reopenedBy(): ?int { return $this->reopenedBy; } public function reopenedAt(): ?DateTimeImmutable { return $this->reopenedAt; } }