mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various code cleanup.
This commit is contained in:
parent
1d979778e8
commit
5d0cdc4ffa
@ -81,7 +81,7 @@ class CreateImport extends Command
|
|||||||
/** @var ImportJobRepositoryInterface $jobRepository */
|
/** @var ImportJobRepositoryInterface $jobRepository */
|
||||||
$jobRepository = app(ImportJobRepositoryInterface::class);
|
$jobRepository = app(ImportJobRepositoryInterface::class);
|
||||||
$jobRepository->setUser($user);
|
$jobRepository->setUser($user);
|
||||||
$job = $jobRepository->create($type);
|
$job = $jobRepository->create($type);
|
||||||
$this->line(sprintf('Created job "%s"...', $job->key));
|
$this->line(sprintf('Created job "%s"...', $job->key));
|
||||||
|
|
||||||
Artisan::call('firefly:encrypt', ['file' => $file, 'key' => $job->key]);
|
Artisan::call('firefly:encrypt', ['file' => $file, 'key' => $job->key]);
|
||||||
|
@ -84,21 +84,8 @@ class UpgradeFireflyInstructions extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function installInstructions()
|
||||||
* Show a line
|
|
||||||
*/
|
|
||||||
private function showLine()
|
|
||||||
{
|
{
|
||||||
$line = '+';
|
|
||||||
for ($i = 0; $i < 78; $i++) {
|
|
||||||
$line .= '-';
|
|
||||||
}
|
|
||||||
$line .= '+';
|
|
||||||
$this->line($line);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private function installInstructions() {
|
|
||||||
/** @var string $version */
|
/** @var string $version */
|
||||||
$version = config('firefly.version');
|
$version = config('firefly.version');
|
||||||
$config = config('upgrade.text.install');
|
$config = config('upgrade.text.install');
|
||||||
@ -120,6 +107,7 @@ class UpgradeFireflyInstructions extends Command
|
|||||||
$this->boxed('Firefly III should be ready for use.');
|
$this->boxed('Firefly III should be ready for use.');
|
||||||
$this->boxed('');
|
$this->boxed('');
|
||||||
$this->showLine();
|
$this->showLine();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +117,20 @@ class UpgradeFireflyInstructions extends Command
|
|||||||
$this->showLine();
|
$this->showLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a line
|
||||||
|
*/
|
||||||
|
private function showLine()
|
||||||
|
{
|
||||||
|
$line = '+';
|
||||||
|
for ($i = 0; $i < 78; $i++) {
|
||||||
|
$line .= '-';
|
||||||
|
}
|
||||||
|
$line .= '+';
|
||||||
|
$this->line($line);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private function updateInstructions()
|
private function updateInstructions()
|
||||||
{
|
{
|
||||||
/** @var string $version */
|
/** @var string $version */
|
||||||
@ -152,6 +154,7 @@ class UpgradeFireflyInstructions extends Command
|
|||||||
$this->boxed('Firefly III should be ready for use.');
|
$this->boxed('Firefly III should be ready for use.');
|
||||||
$this->boxed('');
|
$this->boxed('');
|
||||||
$this->showLine();
|
$this->showLine();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ namespace FireflyIII\Export\Collector;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Crypt;
|
use Crypt;
|
||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Models\ExportJob;
|
|
||||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
@ -33,13 +33,6 @@ interface CollectorInterface
|
|||||||
*/
|
*/
|
||||||
public function run(): bool;
|
public function run(): bool;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ExportJob $job
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function setJob(ExportJob $job);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection $entries
|
* @param Collection $entries
|
||||||
*
|
*
|
||||||
@ -48,4 +41,11 @@ interface CollectorInterface
|
|||||||
*/
|
*/
|
||||||
public function setEntries(Collection $entries);
|
public function setEntries(Collection $entries);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ExportJob $job
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function setJob(ExportJob $job);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->maxUploadSize = intval(config('firefly.maxUploadSize'));
|
$this->maxUploadSize = intval(config('firefly.maxUploadSize'));
|
||||||
$this->allowedMimes = (array) config('firefly.allowedMimes');
|
$this->allowedMimes = (array)config('firefly.allowedMimes');
|
||||||
$this->errors = new MessageBag;
|
$this->errors = new MessageBag;
|
||||||
$this->messages = new MessageBag;
|
$this->messages = new MessageBag;
|
||||||
$this->uploadDisk = Storage::disk('upload');
|
$this->uploadDisk = Storage::disk('upload');
|
||||||
|
@ -503,6 +503,7 @@ class JournalCollector implements JournalCollectorInterface
|
|||||||
public function withOpposingAccount(): JournalCollectorInterface
|
public function withOpposingAccount(): JournalCollectorInterface
|
||||||
{
|
{
|
||||||
$this->joinOpposingTables();
|
$this->joinOpposingTables();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,9 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
|||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
$balanceEntry = new BalanceEntry;
|
$balanceEntry = new BalanceEntry;
|
||||||
$balanceEntry->setAccount($account);
|
$balanceEntry->setAccount($account);
|
||||||
$spent = $this->budgetRepository->spentInPeriod(new Collection([$budgetLimit->budget]), new Collection([$account]), $budgetLimit->start_date, $budgetLimit->end_date);
|
$spent = $this->budgetRepository->spentInPeriod(
|
||||||
|
new Collection([$budgetLimit->budget]), new Collection([$account]), $budgetLimit->start_date, $budgetLimit->end_date
|
||||||
|
);
|
||||||
$balanceEntry->setSpent($spent);
|
$balanceEntry->setSpent($spent);
|
||||||
$line->addBalanceEntry($balanceEntry);
|
$line->addBalanceEntry($balanceEntry);
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,12 @@ namespace FireflyIII\Helpers\Report;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Helpers\Collection\Bill as BillCollection;
|
use FireflyIII\Helpers\Collection\Bill as BillCollection;
|
||||||
use FireflyIII\Helpers\Collection\BillLine;
|
use FireflyIII\Helpers\Collection\BillLine;
|
||||||
use FireflyIII\Helpers\Collection\Category as CategoryCollection;
|
|
||||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||||
use FireflyIII\Helpers\FiscalHelperInterface;
|
use FireflyIII\Helpers\FiscalHelperInterface;
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Models\Category;
|
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,7 +15,6 @@ namespace FireflyIII\Helpers\Report;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Helpers\Collection\Bill as BillCollection;
|
use FireflyIII\Helpers\Collection\Bill as BillCollection;
|
||||||
use FireflyIII\Helpers\Collection\Category as CategoryCollection;
|
|
||||||
use FireflyIII\Helpers\Collection\Expense;
|
use FireflyIII\Helpers\Collection\Expense;
|
||||||
use FireflyIII\Helpers\Collection\Income;
|
use FireflyIII\Helpers\Collection\Income;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
@ -116,9 +116,9 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param AccountRepositoryInterface $repository
|
* @param AccountRepositoryInterface $repository
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
@ -190,8 +190,8 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountRepositoryInterface $repository
|
* @param AccountRepositoryInterface $repository
|
||||||
* @param string $what
|
* @param string $what
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
@ -260,9 +260,9 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param AccountRepositoryInterface $repository
|
* @param AccountRepositoryInterface $repository
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
@ -323,8 +323,8 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountFormRequest $request
|
* @param AccountFormRequest $request
|
||||||
* @param AccountRepositoryInterface $repository
|
* @param AccountRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*
|
*
|
||||||
@ -356,9 +356,9 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountFormRequest $request
|
* @param AccountFormRequest $request
|
||||||
* @param AccountRepositoryInterface $repository
|
* @param AccountRepositoryInterface $repository
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
|
@ -23,7 +23,6 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Route;
|
|
||||||
use Session;
|
use Session;
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
@ -91,7 +90,7 @@ class HomeController extends Controller
|
|||||||
public function flush(Request $request)
|
public function flush(Request $request)
|
||||||
{
|
{
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
$request->session()->forget(['start', 'end','_previous', 'viewRange', 'range', 'is_custom_range']);
|
$request->session()->forget(['start', 'end', '_previous', 'viewRange', 'range', 'is_custom_range']);
|
||||||
Artisan::call('cache:clear');
|
Artisan::call('cache:clear');
|
||||||
|
|
||||||
return redirect(route('index'));
|
return redirect(route('index'));
|
||||||
|
@ -98,42 +98,6 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Collection $accounts
|
|
||||||
* @param Collection $tags
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
|
|
||||||
{
|
|
||||||
if ($end < $start) {
|
|
||||||
return view('error')->with('message', trans('firefly.end_after_start_date'));
|
|
||||||
}
|
|
||||||
if ($start < session('first')) {
|
|
||||||
$start = session('first');
|
|
||||||
}
|
|
||||||
|
|
||||||
View::share(
|
|
||||||
'subTitle', trans(
|
|
||||||
'firefly.report_tag',
|
|
||||||
[
|
|
||||||
'start' => $start->formatLocalized($this->monthFormat),
|
|
||||||
'end' => $end->formatLocalized($this->monthFormat),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$generator = ReportGeneratorFactory::reportGenerator('Tag', $start, $end);
|
|
||||||
$generator->setAccounts($accounts);
|
|
||||||
$generator->setTags($tags);
|
|
||||||
$result = $generator->generate();
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection $accounts
|
* @param Collection $accounts
|
||||||
* @param Collection $budgets
|
* @param Collection $budgets
|
||||||
@ -357,6 +321,42 @@ class ReportController extends Controller
|
|||||||
return redirect($uri);
|
return redirect($uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Collection $tags
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
|
||||||
|
{
|
||||||
|
if ($end < $start) {
|
||||||
|
return view('error')->with('message', trans('firefly.end_after_start_date'));
|
||||||
|
}
|
||||||
|
if ($start < session('first')) {
|
||||||
|
$start = session('first');
|
||||||
|
}
|
||||||
|
|
||||||
|
View::share(
|
||||||
|
'subTitle', trans(
|
||||||
|
'firefly.report_tag',
|
||||||
|
[
|
||||||
|
'start' => $start->formatLocalized($this->monthFormat),
|
||||||
|
'end' => $end->formatLocalized($this->monthFormat),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$generator = ReportGeneratorFactory::reportGenerator('Tag', $start, $end);
|
||||||
|
$generator->setAccounts($accounts);
|
||||||
|
$generator->setTags($tags);
|
||||||
|
$result = $generator->generate();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -17,7 +17,6 @@ use Amount;
|
|||||||
use App;
|
use App;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Closure;
|
use Closure;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Illuminate\Contracts\Auth\Guard;
|
use Illuminate\Contracts\Auth\Guard;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
@ -14,7 +14,6 @@ namespace FireflyIII\Http\Middleware;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Session\Middleware\StartSession;
|
use Illuminate\Session\Middleware\StartSession;
|
||||||
use Illuminate\Session\SessionManager;
|
use Illuminate\Session\SessionManager;
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class StartFireflySession
|
* Class StartFireflySession
|
||||||
|
@ -12,9 +12,10 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Middleware;
|
namespace FireflyIII\Http\Middleware;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
|
||||||
use Symfony\Component\HttpFoundation\Cookie;
|
use Symfony\Component\HttpFoundation\Cookie;
|
||||||
use Carbon\Carbon;
|
|
||||||
/**
|
/**
|
||||||
* Class VerifyCsrfToken
|
* Class VerifyCsrfToken
|
||||||
*
|
*
|
||||||
@ -35,8 +36,9 @@ class VerifyCsrfToken extends BaseVerifier
|
|||||||
/**
|
/**
|
||||||
* Add the CSRF token to the response cookies.
|
* Add the CSRF token to the response cookies.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @param \Symfony\Component\HttpFoundation\Response $response
|
* @param \Symfony\Component\HttpFoundation\Response $response
|
||||||
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
protected function addCookieToResponse($request, $response)
|
protected function addCookieToResponse($request, $response)
|
||||||
|
@ -87,7 +87,7 @@ class Request extends FormRequest
|
|||||||
*/
|
*/
|
||||||
protected function string(string $field): string
|
protected function string(string $field): string
|
||||||
{
|
{
|
||||||
$string = $this->get($field) ?? '';
|
$string = $this->get($field) ?? '';
|
||||||
$search = [
|
$search = [
|
||||||
"\u{0001}", // start of heading
|
"\u{0001}", // start of heading
|
||||||
"\u{0002}", // start of text
|
"\u{0002}", // start of text
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,7 +162,7 @@ class ImportStorage
|
|||||||
/** @var TagRepositoryInterface $repository */
|
/** @var TagRepositoryInterface $repository */
|
||||||
$repository = app(TagRepositoryInterface::class);
|
$repository = app(TagRepositoryInterface::class);
|
||||||
$repository->setUser($this->user);
|
$repository->setUser($this->user);
|
||||||
$data = [
|
$data = [
|
||||||
'tag' => trans('firefly.import_with_key', ['key' => $this->job->key]),
|
'tag' => trans('firefly.import_with_key', ['key' => $this->job->key]),
|
||||||
'date' => new Carbon,
|
'date' => new Carbon,
|
||||||
'description' => null,
|
'description' => null,
|
||||||
@ -171,7 +171,7 @@ class ImportStorage
|
|||||||
'zoomLevel' => null,
|
'zoomLevel' => null,
|
||||||
'tagMode' => 'nothing',
|
'tagMode' => 'nothing',
|
||||||
];
|
];
|
||||||
$tag = $repository->store($data);
|
$tag = $repository->store($data);
|
||||||
|
|
||||||
return $tag;
|
return $tag;
|
||||||
}
|
}
|
||||||
|
@ -182,8 +182,8 @@ class CsvSetup implements SetupInterface
|
|||||||
{
|
{
|
||||||
/** @var AccountRepositoryInterface $repository */
|
/** @var AccountRepositoryInterface $repository */
|
||||||
$repository = app(AccountRepositoryInterface::class);
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
$importId = $data['csv_import_account'] ?? 0;
|
$importId = $data['csv_import_account'] ?? 0;
|
||||||
$account = $repository->find(intval($importId));
|
$account = $repository->find(intval($importId));
|
||||||
|
|
||||||
$hasHeaders = isset($data['has_headers']) && intval($data['has_headers']) === 1 ? true : false;
|
$hasHeaders = isset($data['has_headers']) && intval($data['has_headers']) === 1 ? true : false;
|
||||||
$config = $this->job->configuration;
|
$config = $this->job->configuration;
|
||||||
|
@ -44,7 +44,7 @@ class Budget extends Model
|
|||||||
'encrypted' => 'boolean',
|
'encrypted' => 'boolean',
|
||||||
];
|
];
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||||
protected $fillable = ['user_id', 'name', 'active'];
|
protected $fillable = ['user_id', 'name', 'active'];
|
||||||
protected $hidden = ['encrypted'];
|
protected $hidden = ['encrypted'];
|
||||||
protected $rules = ['name' => 'required|between:1,200',];
|
protected $rules = ['name' => 'required|between:1,200',];
|
||||||
|
@ -122,14 +122,14 @@ class FireflyServiceProvider extends ServiceProvider
|
|||||||
$this->app->bind(MetaPieChartInterface::class, MetaPieChart::class);
|
$this->app->bind(MetaPieChartInterface::class, MetaPieChart::class);
|
||||||
|
|
||||||
// other generators
|
// other generators
|
||||||
$this->app->bind(ProcessorInterface::class,Processor::class);
|
$this->app->bind(ProcessorInterface::class, Processor::class);
|
||||||
$this->app->bind(ImportProcedureInterface::class,ImportProcedure::class);
|
$this->app->bind(ImportProcedureInterface::class, ImportProcedure::class);
|
||||||
$this->app->bind(UserRepositoryInterface::class, UserRepository::class);
|
$this->app->bind(UserRepositoryInterface::class, UserRepository::class);
|
||||||
$this->app->bind(AttachmentHelperInterface::class, AttachmentHelper::class);
|
$this->app->bind(AttachmentHelperInterface::class, AttachmentHelper::class);
|
||||||
|
|
||||||
$this->app->bind(HelpInterface::class, Help::class);
|
$this->app->bind(HelpInterface::class, Help::class);
|
||||||
$this->app->bind(ReportHelperInterface::class, ReportHelper::class);
|
$this->app->bind(ReportHelperInterface::class, ReportHelper::class);
|
||||||
$this->app->bind(FiscalHelperInterface::class,FiscalHelper::class);
|
$this->app->bind(FiscalHelperInterface::class, FiscalHelper::class);
|
||||||
$this->app->bind(BalanceReportHelperInterface::class, BalanceReportHelper::class);
|
$this->app->bind(BalanceReportHelperInterface::class, BalanceReportHelper::class);
|
||||||
$this->app->bind(BudgetReportHelperInterface::class, BudgetReportHelper::class);
|
$this->app->bind(BudgetReportHelperInterface::class, BudgetReportHelper::class);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Providers;
|
namespace FireflyIII\Providers;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepository;
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepository;
|
||||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
@ -53,6 +52,7 @@ class PiggyBankServiceProvider extends ServiceProvider
|
|||||||
if ($app->auth->check()) {
|
if ($app->auth->check()) {
|
||||||
$repository->setUser(auth()->user());
|
$repository->setUser(auth()->user());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $repository;
|
return $repository;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -51,6 +51,7 @@ class RuleServiceProvider extends ServiceProvider
|
|||||||
if ($app->auth->check()) {
|
if ($app->auth->check()) {
|
||||||
$repository->setUser(auth()->user());
|
$repository->setUser(auth()->user());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $repository;
|
return $repository;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -30,14 +30,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param User $user
|
|
||||||
*/
|
|
||||||
public function setUser(User $user)
|
|
||||||
{
|
|
||||||
$this->user = $user;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionCurrency $currency
|
* @param TransactionCurrency $currency
|
||||||
*
|
*
|
||||||
@ -186,6 +178,14 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
return $preferred;
|
return $preferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param User $user
|
||||||
|
*/
|
||||||
|
public function setUser(User $user)
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
|
@ -43,14 +43,6 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
/** @var array */
|
/** @var array */
|
||||||
private $validMetaFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date', 'internal_reference', 'notes'];
|
private $validMetaFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date', 'internal_reference', 'notes'];
|
||||||
|
|
||||||
/**
|
|
||||||
* @param User $user
|
|
||||||
*/
|
|
||||||
public function setUser(User $user)
|
|
||||||
{
|
|
||||||
$this->user = $user;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
* @param TransactionType $type
|
* @param TransactionType $type
|
||||||
@ -143,6 +135,14 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
return TransactionType::orderBy('type', 'ASC')->get();
|
return TransactionType::orderBy('type', 'ASC')->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param User $user
|
||||||
|
*/
|
||||||
|
public function setUser(User $user)
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
|
@ -34,14 +34,6 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param User $user
|
|
||||||
*/
|
|
||||||
public function setUser(User $user)
|
|
||||||
{
|
|
||||||
$this->user = $user;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
@ -88,6 +80,25 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Tag $tag
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function earnedInPeriod(Tag $tag, Carbon $start, Carbon $end): string
|
||||||
|
{
|
||||||
|
/** @var JournalCollectorInterface $collector */
|
||||||
|
$collector = app(JournalCollectorInterface::class);
|
||||||
|
$collector->setUser($this->user);
|
||||||
|
$collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAllAssetAccounts()->setTag($tag);
|
||||||
|
$set = $collector->getJournals();
|
||||||
|
$sum = strval($set->sum('transaction_amount'));
|
||||||
|
|
||||||
|
return $sum;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $tagId
|
* @param int $tagId
|
||||||
*
|
*
|
||||||
@ -167,6 +178,33 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
return new Carbon;
|
return new Carbon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param User $user
|
||||||
|
*/
|
||||||
|
public function setUser(User $user)
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Tag $tag
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function spentInPeriod(Tag $tag, Carbon $start, Carbon $end): string
|
||||||
|
{
|
||||||
|
/** @var JournalCollectorInterface $collector */
|
||||||
|
$collector = app(JournalCollectorInterface::class);
|
||||||
|
$collector->setUser($this->user);
|
||||||
|
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setAllAssetAccounts()->setTag($tag);
|
||||||
|
$set = $collector->getJournals();
|
||||||
|
$sum = strval($set->sum('transaction_amount'));
|
||||||
|
|
||||||
|
return $sum;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
@ -383,42 +421,4 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Tag $tag
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function earnedInPeriod(Tag $tag, Carbon $start, Carbon $end): string
|
|
||||||
{
|
|
||||||
/** @var JournalCollectorInterface $collector */
|
|
||||||
$collector = app(JournalCollectorInterface::class);
|
|
||||||
$collector->setUser($this->user);
|
|
||||||
$collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAllAssetAccounts()->setTag($tag);
|
|
||||||
$set = $collector->getJournals();
|
|
||||||
$sum = strval($set->sum('transaction_amount'));
|
|
||||||
|
|
||||||
return $sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Tag $tag
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function spentInPeriod(Tag $tag, Carbon $start, Carbon $end): string
|
|
||||||
{
|
|
||||||
/** @var JournalCollectorInterface $collector */
|
|
||||||
$collector = app(JournalCollectorInterface::class);
|
|
||||||
$collector->setUser($this->user);
|
|
||||||
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setAllAssetAccounts()->setTag($tag);
|
|
||||||
$set = $collector->getJournals();
|
|
||||||
$sum = strval($set->sum('transaction_amount'));
|
|
||||||
|
|
||||||
return $sum;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,9 @@ class SetBudget implements ActionInterface
|
|||||||
/** @var BudgetRepositoryInterface $repository */
|
/** @var BudgetRepositoryInterface $repository */
|
||||||
$repository = app(BudgetRepositoryInterface::class);
|
$repository = app(BudgetRepositoryInterface::class);
|
||||||
$repository->setUser($journal->user);
|
$repository->setUser($journal->user);
|
||||||
$search = $this->action->action_value;
|
$search = $this->action->action_value;
|
||||||
$budgets = $repository->getActiveBudgets();
|
$budgets = $repository->getActiveBudgets();
|
||||||
$budget = $budgets->filter(
|
$budget = $budgets->filter(
|
||||||
function (Budget $current) use ($search) {
|
function (Budget $current) use ($search) {
|
||||||
return $current->name == $search;
|
return $current->name == $search;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class SetDestinationAccount implements ActionInterface
|
|||||||
$this->journal = $journal;
|
$this->journal = $journal;
|
||||||
$this->repository = app(AccountRepositoryInterface::class);
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
$this->repository->setUser($journal->user);
|
$this->repository->setUser($journal->user);
|
||||||
$count = $journal->transactions()->count();
|
$count = $journal->transactions()->count();
|
||||||
if ($count > 2) {
|
if ($count > 2) {
|
||||||
Log::error(sprintf('Cannot change destination account of journal #%d because it is a split journal.', $journal->id));
|
Log::error(sprintf('Cannot change destination account of journal #%d because it is a split journal.', $journal->id));
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class SetSourceAccount implements ActionInterface
|
|||||||
$this->journal = $journal;
|
$this->journal = $journal;
|
||||||
$this->repository = app(AccountRepositoryInterface::class);
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
$this->repository->setUser($journal->user);
|
$this->repository->setUser($journal->user);
|
||||||
$count = $journal->transactions()->count();
|
$count = $journal->transactions()->count();
|
||||||
if ($count > 2) {
|
if ($count > 2) {
|
||||||
Log::error(sprintf('Cannot change source account of journal #%d because it is a split journal.', $journal->id));
|
Log::error(sprintf('Cannot change source account of journal #%d because it is a split journal.', $journal->id));
|
||||||
|
|
||||||
|
@ -75,7 +75,6 @@ class AbstractTrigger
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
|
@ -30,11 +30,6 @@ interface SearchInterface
|
|||||||
*/
|
*/
|
||||||
public function searchAccounts(array $words): Collection;
|
public function searchAccounts(array $words): Collection;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param User $user
|
|
||||||
*/
|
|
||||||
public function setUser(User $user);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $words
|
* @param array $words
|
||||||
*
|
*
|
||||||
@ -63,4 +58,9 @@ interface SearchInterface
|
|||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function searchTransactions(array $words): Collection;
|
public function searchTransactions(array $words): Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param User $user
|
||||||
|
*/
|
||||||
|
public function setUser(User $user);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user