Code and tests for #1450

This commit is contained in:
James Cole
2018-09-15 13:43:57 +02:00
parent fa347f5f75
commit 57b4a5be08
16 changed files with 1089 additions and 18 deletions

View File

@@ -230,6 +230,31 @@ class AutoCompleteController extends Controller
return response()->json($return);
}
/**
* List of revenue accounts.
*
* @param AccountRepositoryInterface $repository
*
* @return JsonResponse
*/
public function assetAccounts(AccountRepositoryInterface $repository): JsonResponse
{
$set = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$filtered = $set->filter(
function (Account $account) {
if (true === $account->active) {
return $account;
}
return false; // @codeCoverageIgnore
}
);
$return = array_unique($filtered->pluck('name')->toArray());
sort($return);
return response()->json($return);
}
/**
* Returns a JSON list of all beneficiaries.
*