format('Y-m-d') > $this->clock->today()->format('Y-m-d')) { throw new CashDayInFuture; } $this->transactions->run(function () use ($day, $actorUserId): void { $cashDay = $this->cashDays->lockForDay($day); $cashDay->close($this->sales->forDay($day), $actorUserId, $this->clock->now()); $this->cashDays->save($cashDay); }); } }