RVRNEXT-30 check if member already has associated transaction
rvr-nextgen/pipeline/pr-master This commit looks good
rvr-nextgen/pipeline/pr-master This commit looks good
This commit is contained in:
2 files changed
+22
No files matched your search
@@ -11,6 +11,7 @@ use RVR\Repository\CommunityRepository;
|
||||
use RVR\Repository\CommunityMemberRepository;
|
||||
use RVR\Repository\CurrencyExchangeRateRepository;
|
||||
use RVR\Repository\CurrencyRepository;
|
||||
use RVR\Repository\TransactionRepository;
|
||||
use RVR\Repository\UserRepository;
|
||||
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||
use SokoWeb\Interfaces\Response\IContent;
|
||||
@@ -29,6 +30,8 @@ class CommunityController implements IAuthenticationRequired
|
||||
|
||||
private CurrencyExchangeRateRepository $currencyExchangeRatesRepository;
|
||||
|
||||
private TransactionRepository $transactionRepository;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->userRepository = new UserRepository();
|
||||
@@ -36,6 +39,7 @@ class CommunityController implements IAuthenticationRequired
|
||||
$this->communityMemberRepository = new CommunityMemberRepository();
|
||||
$this->currencyRepository = new CurrencyRepository();
|
||||
$this->currencyExchangeRatesRepository = new CurrencyExchangeRateRepository();
|
||||
$this->transactionRepository = new TransactionRepository();
|
||||
}
|
||||
|
||||
public function isAuthenticationRequired(): bool
|
||||
@@ -220,6 +224,13 @@ class CommunityController implements IAuthenticationRequired
|
||||
]);
|
||||
}
|
||||
|
||||
\Container::$persistentDataManager->loadRelationsFromDb($communityMember, false, ['user']);
|
||||
if ($this->transactionRepository->isAnyForUser($communityMember->getUser())) {
|
||||
return new JsonContent([
|
||||
'error' => ['errorText' => 'There are transactions where the member is payer or payee!']
|
||||
]);
|
||||
}
|
||||
|
||||
\Container::$persistentDataManager->deleteFromDb($communityMember);
|
||||
|
||||
return new JsonContent(['success' => true]);
|
||||
|
||||
Reference in new issue
Block a user