mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-06 04:34:00 +00:00
Various code cleanup.
This commit is contained in:
@@ -14,7 +14,6 @@ declare(strict_types = 1);
|
|||||||
namespace FireflyIII\Export\Collector;
|
namespace FireflyIII\Export\Collector;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Crypt;
|
|
||||||
use DB;
|
use DB;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use Illuminate\Database\Query\JoinClause;
|
use Illuminate\Database\Query\JoinClause;
|
||||||
|
@@ -13,7 +13,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Export\Entry;
|
namespace FireflyIII\Export\Entry;
|
||||||
|
|
||||||
use Crypt;
|
|
||||||
use Steam;
|
use Steam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -80,6 +80,26 @@ class Support
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getTopExpenses(): Collection
|
||||||
|
{
|
||||||
|
$transactions = $this->getExpenses()->sortBy('transaction_amount');
|
||||||
|
|
||||||
|
return $transactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getTopIncome(): Collection
|
||||||
|
{
|
||||||
|
$transactions = $this->getIncome()->sortByDesc('transaction_amount');
|
||||||
|
|
||||||
|
return $transactions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection $collection
|
* @param Collection $collection
|
||||||
* @param int $sortFlag
|
* @param int $sortFlag
|
||||||
@@ -162,26 +182,6 @@ class Support
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getTopExpenses(): Collection
|
|
||||||
{
|
|
||||||
$transactions = $this->getExpenses()->sortBy('transaction_amount');
|
|
||||||
|
|
||||||
return $transactions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getTopIncome(): Collection
|
|
||||||
{
|
|
||||||
$transactions = $this->getIncome()->sortByDesc('transaction_amount');
|
|
||||||
|
|
||||||
return $transactions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection $collection
|
* @param Collection $collection
|
||||||
*
|
*
|
||||||
|
@@ -44,6 +44,8 @@ interface AttachmentHelperInterface
|
|||||||
/**
|
/**
|
||||||
* @param Model $model
|
* @param Model $model
|
||||||
*
|
*
|
||||||
|
* @param array $files
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function saveAttachmentsForModel(Model $model, array $files = null): bool;
|
public function saveAttachmentsForModel(Model $model, array $files = null): bool;
|
||||||
|
@@ -430,6 +430,20 @@ class JournalCollector implements JournalCollectorInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $tags
|
||||||
|
*
|
||||||
|
* @return JournalCollectorInterface
|
||||||
|
*/
|
||||||
|
public function setTags(Collection $tags): JournalCollectorInterface
|
||||||
|
{
|
||||||
|
$this->joinTagTables();
|
||||||
|
$tagIds = $tags->pluck('id')->toArray();
|
||||||
|
$this->query->whereIn('tag_transaction_journal.tag_id', $tagIds);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $types
|
* @param array $types
|
||||||
*
|
*
|
||||||
@@ -712,18 +726,4 @@ class JournalCollector implements JournalCollectorInterface
|
|||||||
$this->query->leftJoin('tag_transaction_journal', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id');
|
$this->query->leftJoin('tag_transaction_journal', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Collection $tags
|
|
||||||
*
|
|
||||||
* @return JournalCollectorInterface
|
|
||||||
*/
|
|
||||||
public function setTags(Collection $tags): JournalCollectorInterface
|
|
||||||
{
|
|
||||||
$this->joinTagTables();
|
|
||||||
$tagIds = $tags->pluck('id')->toArray();
|
|
||||||
$this->query->whereIn('tag_transaction_journal.tag_id', $tagIds);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -122,12 +122,15 @@ class RegisterController extends Controller
|
|||||||
*/
|
*/
|
||||||
protected function create(array $data)
|
protected function create(array $data)
|
||||||
{
|
{
|
||||||
return User::create(
|
/** @var User $user */
|
||||||
|
$user = User::create(
|
||||||
[
|
[
|
||||||
'email' => $data['email'],
|
'email' => $data['email'],
|
||||||
'password' => bcrypt($data['password']),
|
'password' => bcrypt($data['password']),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -79,9 +79,11 @@ class TwoFactorController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TokenFormRequest $request
|
* @param TokenFormRequest $request
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation.
|
* @param CookieJar $cookieJar
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function postIndex(TokenFormRequest $request, CookieJar $cookieJar)
|
public function postIndex(TokenFormRequest $request, CookieJar $cookieJar)
|
||||||
{
|
{
|
||||||
|
@@ -105,6 +105,7 @@ class BudgetController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param Request $request
|
||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
@@ -214,6 +215,8 @@ class BudgetController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param BudgetIncomeRequest $request
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function postUpdateIncome(BudgetIncomeRequest $request)
|
public function postUpdateIncome(BudgetIncomeRequest $request)
|
||||||
|
@@ -203,6 +203,7 @@ class BudgetReportController extends Controller
|
|||||||
* Returns the budget limits belonging to the given budget and valid on the given day.
|
* Returns the budget limits belonging to the given budget and valid on the given day.
|
||||||
*
|
*
|
||||||
* @param Collection $budgetLimits
|
* @param Collection $budgetLimits
|
||||||
|
* @param Budget $budget
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
@@ -268,21 +269,4 @@ class BudgetReportController extends Controller
|
|||||||
return $grouped;
|
return $grouped;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Collection $set
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function groupByOpposingAccount(Collection $set): array
|
|
||||||
{
|
|
||||||
$grouped = [];
|
|
||||||
/** @var Transaction $transaction */
|
|
||||||
foreach ($set as $transaction) {
|
|
||||||
$accountId = $transaction->opposing_account_id;
|
|
||||||
$grouped[$accountId] = $grouped[$accountId] ?? '0';
|
|
||||||
$grouped[$accountId] = bcadd($transaction->transaction_amount, $grouped[$accountId]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $grouped;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@ use FireflyIII\Http\Controllers\Controller;
|
|||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI;
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Navigation;
|
use Navigation;
|
||||||
@@ -50,13 +50,13 @@ class CategoryController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Show an overview for a category for all time, per month/week/year.
|
* Show an overview for a category for all time, per month/week/year.
|
||||||
*
|
*
|
||||||
* @param CRI $repository
|
* @param CategoryRepositoryInterface $repository
|
||||||
* @param AccountRepositoryInterface $accountRepository
|
* @param AccountRepositoryInterface $accountRepository
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function all(CRI $repository, AccountRepositoryInterface $accountRepository, Category $category)
|
public function all(CategoryRepositoryInterface $repository, AccountRepositoryInterface $accountRepository, Category $category)
|
||||||
{
|
{
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$cache->addProperty('chart.category.all');
|
$cache->addProperty('chart.category.all');
|
||||||
@@ -106,12 +106,12 @@ class CategoryController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CRI $repository
|
* @param CategoryRepositoryInterface $repository
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function currentPeriod(CRI $repository, Category $category)
|
public function currentPeriod(CategoryRepositoryInterface $repository, Category $category)
|
||||||
{
|
{
|
||||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||||
$end = session('end', Carbon::now()->endOfMonth());
|
$end = session('end', Carbon::now()->endOfMonth());
|
||||||
@@ -121,12 +121,12 @@ class CategoryController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CRI $repository
|
* @param CategoryRepositoryInterface $repository
|
||||||
* @param AccountRepositoryInterface $accountRepository
|
* @param AccountRepositoryInterface $accountRepository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function frontpage(CRI $repository, AccountRepositoryInterface $accountRepository)
|
public function frontpage(CategoryRepositoryInterface $repository, AccountRepositoryInterface $accountRepository)
|
||||||
{
|
{
|
||||||
$start = session('start', Carbon::now()->startOfMonth());
|
$start = session('start', Carbon::now()->startOfMonth());
|
||||||
$end = session('end', Carbon::now()->endOfMonth());
|
$end = session('end', Carbon::now()->endOfMonth());
|
||||||
@@ -161,7 +161,7 @@ class CategoryController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CRI $repository
|
* @param CategoryRepositoryInterface $repository
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
* @param Collection $accounts
|
* @param Collection $accounts
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
@@ -169,7 +169,7 @@ class CategoryController extends Controller
|
|||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse|mixed
|
* @return \Illuminate\Http\JsonResponse|mixed
|
||||||
*/
|
*/
|
||||||
public function reportPeriod(CRI $repository, Category $category, Collection $accounts, Carbon $start, Carbon $end)
|
public function reportPeriod(CategoryRepositoryInterface $repository, Category $category, Collection $accounts, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
@@ -210,14 +210,14 @@ class CategoryController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CRI $repository
|
* @param CategoryRepositoryInterface $repository
|
||||||
* @param Collection $accounts
|
* @param Collection $accounts
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse|mixed
|
* @return \Illuminate\Http\JsonResponse|mixed
|
||||||
*/
|
*/
|
||||||
public function reportPeriodNoCategory(CRI $repository, Collection $accounts, Carbon $start, Carbon $end)
|
public function reportPeriodNoCategory(CategoryRepositoryInterface $repository, Collection $accounts, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
@@ -257,14 +257,14 @@ class CategoryController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CRI $repository
|
* @param CategoryRepositoryInterface $repository
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
*
|
*
|
||||||
* @param $date
|
* @param $date
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function specificPeriod(CRI $repository, Category $category, $date)
|
public function specificPeriod(CategoryRepositoryInterface $repository, Category $category, $date)
|
||||||
{
|
{
|
||||||
$carbon = new Carbon($date);
|
$carbon = new Carbon($date);
|
||||||
$range = Preferences::get('viewRange', '1M')->data;
|
$range = Preferences::get('viewRange', '1M')->data;
|
||||||
@@ -277,14 +277,14 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CRI $repository
|
* @param CategoryRepositoryInterface $repository
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function makePeriodChart(CRI $repository, Category $category, Carbon $start, Carbon $end)
|
private function makePeriodChart(CategoryRepositoryInterface $repository, Category $category, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
|
@@ -50,6 +50,8 @@ class CurrencyController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function create(Request $request)
|
public function create(Request $request)
|
||||||
@@ -90,6 +92,7 @@ class CurrencyController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param Request $request
|
||||||
* @param CurrencyRepositoryInterface $repository
|
* @param CurrencyRepositoryInterface $repository
|
||||||
* @param TransactionCurrency $currency
|
* @param TransactionCurrency $currency
|
||||||
*
|
*
|
||||||
@@ -115,6 +118,7 @@ class CurrencyController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param Request $request
|
||||||
* @param CurrencyRepositoryInterface $repository
|
* @param CurrencyRepositoryInterface $repository
|
||||||
* @param TransactionCurrency $currency
|
* @param TransactionCurrency $currency
|
||||||
*
|
*
|
||||||
|
@@ -55,9 +55,10 @@ class ExportController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param EJRI $repository
|
||||||
* @param ExportJob $job
|
* @param ExportJob $job
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response|\Illuminate\Contracts\Routing\ResponseFactory
|
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function download(ExportJobRepositoryInterface $repository, ExportJob $job)
|
public function download(ExportJobRepositoryInterface $repository, ExportJob $job)
|
||||||
|
@@ -27,7 +27,9 @@ class JavascriptController extends Controller
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param Request $request
|
||||||
*
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function variables(Request $request)
|
public function variables(Request $request)
|
||||||
{
|
{
|
||||||
|
@@ -329,7 +329,9 @@ class JsonController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param JournalRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function transactionTypes(JournalRepositoryInterface $repository)
|
public function transactionTypes(JournalRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
|
@@ -219,7 +219,7 @@ class TagController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('tags.index', compact('title', 'mainTitleIcon', 'types', 'collection','count'));
|
return view('tags.index', compact('title', 'mainTitleIcon', 'types', 'collection', 'count'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -14,11 +14,11 @@ declare(strict_types = 1);
|
|||||||
namespace FireflyIII\Http\Middleware;
|
namespace FireflyIII\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Cookie;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use Log;
|
|
||||||
use Cookie;
|
|
||||||
/**
|
/**
|
||||||
* Class RedirectIfTwoFactorAuthenticated
|
* Class RedirectIfTwoFactorAuthenticated
|
||||||
*
|
*
|
||||||
|
@@ -35,6 +35,7 @@ class Sandstorm
|
|||||||
* @param string|null $guard
|
* @param string|null $guard
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next, $guard = null)
|
public function handle(Request $request, Closure $next, $guard = null)
|
||||||
{
|
{
|
||||||
@@ -62,6 +63,7 @@ class Sandstorm
|
|||||||
$user = User::first();
|
$user = User::first();
|
||||||
Auth::guard($guard)->login($user);
|
Auth::guard($guard)->login($user);
|
||||||
View::share('SANDSTORM_ANON', false);
|
View::share('SANDSTORM_ANON', false);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,12 +72,14 @@ class Sandstorm
|
|||||||
$user = User::first();
|
$user = User::first();
|
||||||
Auth::guard($guard)->login($user);
|
Auth::guard($guard)->login($user);
|
||||||
View::share('SANDSTORM_ANON', true);
|
View::share('SANDSTORM_ANON', true);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($count === 0 && strlen($userId) > 0) {
|
if ($count === 0 && strlen($userId) > 0) {
|
||||||
// create new user.
|
// create new user.
|
||||||
$email = $userId . '@firefly';
|
$email = $userId . '@firefly';
|
||||||
|
/** @var User $user */
|
||||||
$user = User::create(
|
$user = User::create(
|
||||||
[
|
[
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
@@ -83,6 +87,7 @@ class Sandstorm
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
Auth::guard($guard)->login($user);
|
Auth::guard($guard)->login($user);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,30 +96,7 @@ class Sandstorm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($count > 1) {
|
if ($count > 1) {
|
||||||
die('Cannot happen.');
|
throw new FireflyException('Your Firefly III installation has more than one user, which is weird.');
|
||||||
}
|
|
||||||
exit;
|
|
||||||
|
|
||||||
if (strlen($userId) > 0) {
|
|
||||||
// find user?
|
|
||||||
$email = $userId . '@firefly';
|
|
||||||
$user = User::whereEmail($email)->first();
|
|
||||||
if (is_null($user)) {
|
|
||||||
$user = User::create(
|
|
||||||
[
|
|
||||||
'email' => $email,
|
|
||||||
'password' => str_random(16),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// login user:
|
|
||||||
Auth::guard($guard)->login($user);
|
|
||||||
} else {
|
|
||||||
echo 'user id no length, guest?';
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Import\Mapper;
|
namespace FireflyIII\Import\Mapper;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionCurrency as TC;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TransactionCurrencies
|
* Class TransactionCurrencies
|
||||||
@@ -28,7 +28,7 @@ class TransactionCurrencies implements MapperInterface
|
|||||||
*/
|
*/
|
||||||
public function getMap(): array
|
public function getMap(): array
|
||||||
{
|
{
|
||||||
$currencies = TC::get();
|
$currencies = TransactionCurrency::get();
|
||||||
$list = [];
|
$list = [];
|
||||||
foreach ($currencies as $currency) {
|
foreach ($currencies as $currency) {
|
||||||
$list[$currency->id] = $currency->name . ' (' . $currency->code . ')';
|
$list[$currency->id] = $currency->name . ' (' . $currency->code . ')';
|
||||||
|
@@ -16,7 +16,6 @@ namespace FireflyIII\Models;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class LimitRepetition
|
* Class LimitRepetition
|
||||||
@@ -42,26 +41,6 @@ class LimitRepetition extends Model
|
|||||||
protected $dates = ['created_at', 'updated_at', 'startdate', 'enddate'];
|
protected $dates = ['created_at', 'updated_at', 'startdate', 'enddate'];
|
||||||
protected $hidden = ['amount_encrypted'];
|
protected $hidden = ['amount_encrypted'];
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $value
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function routeBinder($value)
|
|
||||||
{
|
|
||||||
if (auth()->check()) {
|
|
||||||
$object = self::where('limit_repetitions.id', $value)
|
|
||||||
->leftJoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')
|
|
||||||
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
|
|
||||||
->where('budgets.user_id', auth()->user()->id)
|
|
||||||
->first(['limit_repetitions.*']);
|
|
||||||
if ($object) {
|
|
||||||
return $object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new NotFoundHttpException;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
*/
|
*/
|
||||||
|
@@ -108,6 +108,19 @@ class PiggyBank extends Model
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSuggestedMonthlyAmount()
|
||||||
|
{
|
||||||
|
if ($this->targetdate && $this->currentRelevantRep()->currentamount < $this->targetamount) {
|
||||||
|
$thisMonth = Carbon::now()->month;
|
||||||
|
$targetMonth = $this->targetdate->month;
|
||||||
|
$remainingAmount = $this->targetamount - $this->currentRelevantRep()->currentamount;
|
||||||
|
|
||||||
|
return $thisMonth < $targetMonth ? $remainingAmount / ($targetMonth - $thisMonth) : $remainingAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
@@ -129,17 +142,6 @@ class PiggyBank extends Model
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSuggestedMonthlyAmount()
|
|
||||||
{
|
|
||||||
if ($this->targetdate && $this->currentRelevantRep()->currentamount < $this->targetamount) {
|
|
||||||
$thisMonth = Carbon::now()->month;
|
|
||||||
$targetMonth = $this->targetdate->month;
|
|
||||||
$remainingAmount = $this->targetamount - $this->currentRelevantRep()->currentamount;
|
|
||||||
return $thisMonth < $targetMonth ? $remainingAmount / ($targetMonth - $thisMonth) : $remainingAmount ;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all of the piggy bank's notes.
|
* Get all of the piggy bank's notes.
|
||||||
*/
|
*/
|
||||||
|
@@ -457,6 +457,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
$name = $data['name'];
|
$name = $data['name'];
|
||||||
$opposing = $this->storeOpposingAccount($name);
|
$opposing = $this->storeOpposingAccount($name);
|
||||||
$transactionType = TransactionType::whereType(TransactionType::OPENING_BALANCE)->first();
|
$transactionType = TransactionType::whereType(TransactionType::OPENING_BALANCE)->first();
|
||||||
|
/** @var TransactionJournal $journal */
|
||||||
$journal = TransactionJournal::create(
|
$journal = TransactionJournal::create(
|
||||||
[
|
[
|
||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
|
@@ -525,8 +525,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function store(array $data): Bill
|
public function store(array $data): Bill
|
||||||
{
|
{
|
||||||
|
/** @var Bill $bill */
|
||||||
|
|
||||||
$bill = Bill::create(
|
$bill = Bill::create(
|
||||||
[
|
[
|
||||||
'name' => $data['name'],
|
'name' => $data['name'],
|
||||||
|
@@ -193,6 +193,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function store(array $data): TransactionCurrency
|
public function store(array $data): TransactionCurrency
|
||||||
{
|
{
|
||||||
|
/** @var TransactionCurrency $currency */
|
||||||
$currency = TransactionCurrency::create(
|
$currency = TransactionCurrency::create(
|
||||||
[
|
[
|
||||||
'name' => $data['name'],
|
'name' => $data['name'],
|
||||||
|
@@ -40,6 +40,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function createEvent(PiggyBank $piggyBank, string $amount): PiggyBankEvent
|
public function createEvent(PiggyBank $piggyBank, string $amount): PiggyBankEvent
|
||||||
{
|
{
|
||||||
|
/** @var PiggyBankEvent $event */
|
||||||
$event = PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]);
|
$event = PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]);
|
||||||
|
|
||||||
return $event;
|
return $event;
|
||||||
@@ -173,6 +174,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
|||||||
public function store(array $data): PiggyBank
|
public function store(array $data): PiggyBank
|
||||||
{
|
{
|
||||||
$data['order'] = $this->getMaxOrder() + 1;
|
$data['order'] = $this->getMaxOrder() + 1;
|
||||||
|
/** @var PiggyBank $piggyBank */
|
||||||
$piggyBank = PiggyBank::create($data);
|
$piggyBank = PiggyBank::create($data);
|
||||||
|
|
||||||
$this->updateNote($piggyBank, $data['note']);
|
$this->updateNote($piggyBank, $data['note']);
|
||||||
|
@@ -14,7 +14,6 @@ declare(strict_types = 1);
|
|||||||
namespace FireflyIII\Support\Twig;
|
namespace FireflyIII\Support\Twig;
|
||||||
|
|
||||||
use Amount;
|
use Amount;
|
||||||
use Crypt;
|
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Transaction as TransactionModel;
|
use FireflyIII\Models\Transaction as TransactionModel;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
|
@@ -79,7 +79,7 @@ function showDownload() {
|
|||||||
function showError(text) {
|
function showError(text) {
|
||||||
"use strict";
|
"use strict";
|
||||||
$('#export-error').show();
|
$('#export-error').show();
|
||||||
$('#export-error>p').text(text);
|
$('#export-error').find('p').text(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
function callExport() {
|
function callExport() {
|
||||||
|
@@ -24,7 +24,7 @@ $(function () {
|
|||||||
$('.addMoney').on('click', addMoney);
|
$('.addMoney').on('click', addMoney);
|
||||||
$('.removeMoney').on('click', removeMoney);
|
$('.removeMoney').on('click', removeMoney);
|
||||||
|
|
||||||
$('#sortable-piggy tbody').sortable(
|
$('#sortable-piggy').find('tbody').sortable(
|
||||||
{
|
{
|
||||||
helper: fixHelper,
|
helper: fixHelper,
|
||||||
stop: stopSorting,
|
stop: stopSorting,
|
||||||
|
@@ -29,10 +29,10 @@ $(function () {
|
|||||||
{
|
{
|
||||||
locale: {
|
locale: {
|
||||||
format: 'YYYY-MM-DD',
|
format: 'YYYY-MM-DD',
|
||||||
firstDay: 1,
|
firstDay: 1
|
||||||
},
|
},
|
||||||
minDate: minDate,
|
minDate: minDate,
|
||||||
drops: 'up',
|
drops: 'up'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -300,7 +300,7 @@ function testRuleTriggers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show the modal dialog
|
// Show the modal dialog
|
||||||
$("#testTriggerModal").modal();
|
modal.modal();
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
alert('Cannot get transactions for given triggers.');
|
alert('Cannot get transactions for given triggers.');
|
||||||
});
|
});
|
||||||
|
@@ -25,7 +25,7 @@ $(function () {
|
|||||||
{
|
{
|
||||||
helper: fixHelper,
|
helper: fixHelper,
|
||||||
stop: sortStop,
|
stop: sortStop,
|
||||||
cursor: "move",
|
cursor: "move"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -35,8 +35,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
function updateDescription() {
|
function updateDescription() {
|
||||||
$.getJSON('json/transaction-journals/' + what).done(function (data) {
|
$.getJSON('json/transaction-journals/' + what).done(function (data) {
|
||||||
$('input[name="description"]').typeahead('destroy');
|
$('input[name="description"]').typeahead('destroy').typeahead({source: data});
|
||||||
$('input[name="description"]').typeahead({source: data});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,9 +10,7 @@
|
|||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
||||||
|
|
||||||
class ExampleTest extends TestCase
|
class ExampleTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@@ -3,8 +3,7 @@
|
|||||||
namespace Tests\Unit;
|
namespace Tests\Unit;
|
||||||
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
||||||
|
|
||||||
class ExampleTest extends TestCase
|
class ExampleTest extends TestCase
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user