mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 01:06:46 +00:00
Move some methods around, refactoring.
This commit is contained in:
@@ -17,7 +17,7 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
@@ -97,12 +97,13 @@ class JsonController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ARI $accountRepository
|
||||
* @param AccountCrudInterface $crud
|
||||
* @param AccountTaskerInterface $accountTasker
|
||||
* @param AccountCrudInterface $crud
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @internal param ARI $accountRepository
|
||||
*/
|
||||
public function boxIn(ARI $accountRepository, AccountCrudInterface $crud)
|
||||
public function boxIn(AccountTaskerInterface $accountTasker, AccountCrudInterface $crud)
|
||||
{
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
@@ -116,7 +117,8 @@ class JsonController extends Controller
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::CASH]);
|
||||
$amount = $accountRepository->earnedInPeriod($accounts, $start, $end);
|
||||
$assets = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||
$amount = $accountTasker->amountInInPeriod($accounts, $assets, $start, $end);
|
||||
$data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||
$cache->store($data);
|
||||
|
||||
@@ -124,12 +126,13 @@ class JsonController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ARI $accountRepository
|
||||
* @param AccountCrudInterface $crud
|
||||
* @param AccountCrudInterface $crud
|
||||
* @param AccountTaskerInterface $accountTasker
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @internal param ARI $accountRepository
|
||||
*/
|
||||
public function boxOut(ARI $accountRepository, AccountCrudInterface $crud)
|
||||
public function boxOut(AccountCrudInterface $crud, AccountTaskerInterface $accountTasker)
|
||||
{
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
@@ -144,7 +147,8 @@ class JsonController extends Controller
|
||||
}
|
||||
|
||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::CASH]);
|
||||
$amount = $accountRepository->spentInPeriod($accounts, $start, $end);
|
||||
$assets = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||
$amount = $accountTasker->amountOutInPeriod($accounts, $assets, $start, $end);
|
||||
|
||||
$data = ['box' => 'out', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||
$cache->store($data);
|
||||
|
Reference in New Issue
Block a user