mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 04:03:26 +00:00
Fix tests for account
This commit is contained in:
@@ -120,7 +120,13 @@ trait AccountServiceTrait
|
||||
if (null === $data['account_role']) {
|
||||
$data['account_role'] = $this->accountRepository->getMetaValue($account, 'account_role');
|
||||
}
|
||||
if ($account->accountType->type === AccountType::ASSET && isset($data['account_role']) && 'ccAsset' === $data['account_role']) {
|
||||
|
||||
// only asset account may have a role:
|
||||
if ($account->accountType->type !== AccountType::ASSET) {
|
||||
$data['account_role'] = '';
|
||||
}
|
||||
|
||||
if ($account->accountType->type === AccountType::ASSET && array_key_exists('account_role', $data) && 'ccAsset' === $data['account_role']) {
|
||||
$fields = $this->validCCFields; // @codeCoverageIgnore
|
||||
}
|
||||
/** @var AccountMetaFactory $factory */
|
||||
|
@@ -119,15 +119,23 @@ class AccountUpdateService
|
||||
private function updateAccount(Account $account, array $data): Account
|
||||
{
|
||||
// update the account itself:
|
||||
$account->name = $data['name'] ?? $account->name;
|
||||
$account->active = $data['active'] ?? $account->active;
|
||||
$account->iban = $data['iban'] ?? $account->iban;
|
||||
if(array_key_exists('name', $data)) {
|
||||
$account->name = $data['name'];
|
||||
}
|
||||
if(array_key_exists('active', $data)) {
|
||||
$account->active = $data['active'];
|
||||
}
|
||||
if(array_key_exists('iban', $data)) {
|
||||
$account->iban = $data['iban'];
|
||||
}
|
||||
|
||||
// liability stuff:
|
||||
$liabilityType = $data['liability_type'] ?? '';
|
||||
if ($this->isLiability($account) && $this->isLiabilityType($liabilityType)) {
|
||||
$type = $this->getAccountType($liabilityType);
|
||||
$account->account_type_id = $type->id;
|
||||
// set liability, but account must already be a liability.
|
||||
//$liabilityType = $data['liability_type'] ?? '';
|
||||
if ($this->isLiability($account) && array_key_exists('liability_type', $data)) {
|
||||
$type = $this->getAccountType($data['liability_type']);
|
||||
if(null !== $type) {
|
||||
$account->account_type_id = $type->id;
|
||||
}
|
||||
}
|
||||
|
||||
// update virtual balance (could be set to zero if empty string).
|
||||
|
Reference in New Issue
Block a user