Make sure the convert controller works again.

This commit is contained in:
James Cole
2019-07-05 19:43:16 +02:00
parent 3c5c14ff5a
commit 7fd3f77c3e
17 changed files with 703 additions and 275 deletions

View File

@@ -93,6 +93,37 @@ class AutoCompleteController extends Controller
return response()->json($return);
}
/**
* An auto-complete specifically for revenue accounts, used when converting transactions mostly.
* @param Request $request
*
* @return JsonResponse
*/
public function revenueAccounts(Request $request): JsonResponse
{
$search = $request->get('search');
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
// filter the account types:
$allowedAccountTypes = [AccountType::REVENUE];
Log::debug('Now in accounts(). Filtering results.', $allowedAccountTypes);
$return = [];
$result = $repository->searchAccount((string)$search, $allowedAccountTypes);
/** @var Account $account */
foreach ($result as $account) {
$return[] = [
'id' => $account->id,
'name' => $account->name,
'type' => $account->accountType->type,
];
}
return response()->json($return);
}
/**
* Searches in the titles of all transaction journals.
* The result is limited to the top 15 unique results.