diff --git a/src/Internal/Assembler/TransactionDtoAssembler.php b/src/Internal/Assembler/TransactionDtoAssembler.php index e183d60c3..93b0a6e4c 100644 --- a/src/Internal/Assembler/TransactionDtoAssembler.php +++ b/src/Internal/Assembler/TransactionDtoAssembler.php @@ -6,13 +6,15 @@ use Bavix\Wallet\Internal\Dto\TransactionDto; use Bavix\Wallet\Internal\Dto\TransactionDtoInterface; +use Bavix\Wallet\Internal\Service\ClockServiceInterface; use Bavix\Wallet\Internal\Service\UuidFactoryServiceInterface; use Illuminate\Database\Eloquent\Model; final readonly class TransactionDtoAssembler implements TransactionDtoAssemblerInterface { public function __construct( - private UuidFactoryServiceInterface $uuidService + private UuidFactoryServiceInterface $uuidService, + private ClockServiceInterface $clockService, ) { } @@ -33,7 +35,9 @@ public function create( $type, $amount, $confirmed, - $meta + $meta, + $this->clockService->now(), + $this->clockService->now(), ); } } diff --git a/src/Internal/Assembler/TransferDtoAssembler.php b/src/Internal/Assembler/TransferDtoAssembler.php index 280580f3b..12ca43016 100644 --- a/src/Internal/Assembler/TransferDtoAssembler.php +++ b/src/Internal/Assembler/TransferDtoAssembler.php @@ -6,13 +6,15 @@ use Bavix\Wallet\Internal\Dto\TransferDto; use Bavix\Wallet\Internal\Dto\TransferDtoInterface; +use Bavix\Wallet\Internal\Service\ClockServiceInterface; use Bavix\Wallet\Internal\Service\UuidFactoryServiceInterface; use Illuminate\Database\Eloquent\Model; final readonly class TransferDtoAssembler implements TransferDtoAssemblerInterface { public function __construct( - private UuidFactoryServiceInterface $uuidService + private UuidFactoryServiceInterface $uuidService, + private ClockServiceInterface $clockService, ) { } @@ -34,7 +36,9 @@ public function create( $fromModel->getKey(), $toModel->getKey(), $discount, - $fee + $fee, + $this->clockService->now(), + $this->clockService->now(), ); } } diff --git a/src/Internal/Dto/TransactionDto.php b/src/Internal/Dto/TransactionDto.php index f74d5aeec..4261cfe1a 100644 --- a/src/Internal/Dto/TransactionDto.php +++ b/src/Internal/Dto/TransactionDto.php @@ -9,10 +9,6 @@ /** @immutable */ final readonly class TransactionDto implements TransactionDtoInterface { - private DateTimeImmutable $createdAt; - - private DateTimeImmutable $updatedAt; - /** * @param array|null $meta */ @@ -24,10 +20,10 @@ public function __construct( private string $type, private float|int|string $amount, private bool $confirmed, - private ?array $meta + private ?array $meta, + private DateTimeImmutable $createdAt, + private DateTimeImmutable $updatedAt, ) { - $this->createdAt = new DateTimeImmutable(); - $this->updatedAt = new DateTimeImmutable(); } public function getUuid(): string diff --git a/src/Internal/Dto/TransferDto.php b/src/Internal/Dto/TransferDto.php index 2f95d88d9..cf604e4d0 100644 --- a/src/Internal/Dto/TransferDto.php +++ b/src/Internal/Dto/TransferDto.php @@ -9,10 +9,6 @@ /** @immutable */ final readonly class TransferDto implements TransferDtoInterface { - private DateTimeImmutable $createdAt; - - private DateTimeImmutable $updatedAt; - public function __construct( private string $uuid, private int $depositId, @@ -21,10 +17,10 @@ public function __construct( private int $fromId, private int $toId, private int $discount, - private string $fee + private string $fee, + private DateTimeImmutable $createdAt, + private DateTimeImmutable $updatedAt, ) { - $this->createdAt = new DateTimeImmutable(); - $this->updatedAt = new DateTimeImmutable(); } public function getUuid(): string