clock->today(); return $this->transactions->run(function () use ($saleId, $actorUserId, $today): int { $original = $this->sales->findById($saleId) ?? throw new QuickSaleNotFound($saleId); $this->cashDays->lockForDay($today)->ensureOpen(); if ($this->sales->isCredited($saleId)) { throw new QuickSaleAlreadyCredited; } $credit = QuickSale::creditFor($original, $actorUserId, $this->clock->now(), $today); return (int) $this->sales->add($credit)->id(); }); } }