Merge laravel 5.4 into develop.

This commit is contained in:
James Cole
2017-02-05 16:20:02 +01:00
162 changed files with 1063 additions and 6274 deletions

View File

@@ -79,7 +79,8 @@ class CreateImport extends Command
$this->info(sprintf('Type of import: %s', $type)); $this->info(sprintf('Type of import: %s', $type));
/** @var ImportJobRepositoryInterface $jobRepository */ /** @var ImportJobRepositoryInterface $jobRepository */
$jobRepository = app(ImportJobRepositoryInterface::class, [$user]); $jobRepository = app(ImportJobRepositoryInterface::class);
$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));

View File

@@ -39,9 +39,9 @@ class Kernel extends ConsoleKernel
*/ */
protected $bootstrappers protected $bootstrappers
= [ = [
'Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables',
'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\LoadConfiguration',
'FireflyIII\Bootstrap\ConfigureLogging', //'FireflyIII\Bootstrap\ConfigureLogging',
'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\HandleExceptions',
'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterFacades',
'Illuminate\Foundation\Bootstrap\SetRequestForConsole', 'Illuminate\Foundation\Bootstrap\SetRequestForConsole',

View File

@@ -43,10 +43,8 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
/** /**
* AttachmentCollector constructor. * AttachmentCollector constructor.
*
* @param ExportJob $job
*/ */
public function __construct(ExportJob $job) public function __construct()
{ {
/** @var AttachmentRepositoryInterface repository */ /** @var AttachmentRepositoryInterface repository */
$this->repository = app(AttachmentRepositoryInterface::class); $this->repository = app(AttachmentRepositoryInterface::class);
@@ -54,7 +52,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
$this->uploadDisk = Storage::disk('upload'); $this->uploadDisk = Storage::disk('upload');
$this->exportDisk = Storage::disk('export'); $this->exportDisk = Storage::disk('export');
parent::__construct($job); parent::__construct();
} }
/** /**

View File

@@ -31,13 +31,10 @@ class BasicCollector
/** /**
* BasicCollector constructor. * BasicCollector constructor.
*
* @param ExportJob $job
*/ */
public function __construct(ExportJob $job) public function __construct()
{ {
$this->entries = new Collection; $this->entries = new Collection;
$this->job = $job;
} }
/** /**
@@ -56,5 +53,13 @@ class BasicCollector
$this->entries = $entries; $this->entries = $entries;
} }
/**
* @param ExportJob $job
*/
public function setJob(ExportJob $job)
{
$this->job = $job;
}
} }

View File

@@ -13,6 +13,7 @@ declare(strict_types = 1);
namespace FireflyIII\Export\Collector; namespace FireflyIII\Export\Collector;
use FireflyIII\Models\ExportJob;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -32,6 +33,13 @@ 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
* *

View File

@@ -14,7 +14,6 @@ declare(strict_types = 1);
namespace FireflyIII\Export\Collector; namespace FireflyIII\Export\Collector;
use Crypt; use Crypt;
use FireflyIII\Models\ExportJob;
use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Contracts\Encryption\DecryptException;
use Log; use Log;
use Storage; use Storage;
@@ -35,22 +34,12 @@ class UploadCollector extends BasicCollector implements CollectorInterface
/** /**
* AttachmentCollector constructor. * AttachmentCollector constructor.
*
* @param ExportJob $job
*/ */
public function __construct(ExportJob $job) public function __construct()
{ {
parent::__construct($job); parent::__construct();
Log::debug('Going to collect attachments', ['key' => $job->key]);
// make storage:
$this->uploadDisk = Storage::disk('upload'); $this->uploadDisk = Storage::disk('upload');
$this->exportDisk = Storage::disk('export'); $this->exportDisk = Storage::disk('export');
// file names associated with the old import routine.
$this->vintageFormat = sprintf('csv-upload-%d-', auth()->user()->id);
} }
/** /**
@@ -60,6 +49,11 @@ class UploadCollector extends BasicCollector implements CollectorInterface
*/ */
public function run(): bool public function run(): bool
{ {
Log::debug('Going to collect attachments', ['key' => $this->job->key]);
// file names associated with the old import routine.
$this->vintageFormat = sprintf('csv-upload-%d-', $this->job->user->id);
// collect old upload files (names beginning with "csv-upload". // collect old upload files (names beginning with "csv-upload".
$this->collectVintageUploads(); $this->collectVintageUploads();

View File

@@ -26,17 +26,15 @@ class BasicExporter
{ {
/** @var ExportJob */ /** @var ExportJob */
protected $job; protected $job;
/** @var Collection */
private $entries; private $entries;
/** /**
* BasicExporter constructor. * BasicExporter constructor.
*
* @param ExportJob $job
*/ */
public function __construct(ExportJob $job) public function __construct()
{ {
$this->entries = new Collection; $this->entries = new Collection;
$this->job = $job;
} }
/** /**
@@ -55,5 +53,13 @@ class BasicExporter
$this->entries = $entries; $this->entries = $entries;
} }
/**
* @param ExportJob $job
*/
public function setJob(ExportJob $job)
{
$this->job = $job;
}
} }

View File

@@ -14,7 +14,6 @@ declare(strict_types = 1);
namespace FireflyIII\Export\Exporter; namespace FireflyIII\Export\Exporter;
use FireflyIII\Export\Entry\Entry; use FireflyIII\Export\Entry\Entry;
use FireflyIII\Models\ExportJob;
use League\Csv\Writer; use League\Csv\Writer;
use SplFileObject; use SplFileObject;
@@ -30,13 +29,10 @@ class CsvExporter extends BasicExporter implements ExporterInterface
/** /**
* CsvExporter constructor. * CsvExporter constructor.
*
* @param ExportJob $job
*/ */
public function __construct(ExportJob $job) public function __construct()
{ {
parent::__construct($job); parent::__construct();
} }
/** /**

View File

@@ -13,6 +13,7 @@ declare(strict_types = 1);
namespace FireflyIII\Export\Exporter; namespace FireflyIII\Export\Exporter;
use FireflyIII\Models\ExportJob;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -45,4 +46,9 @@ interface ExporterInterface
*/ */
public function setEntries(Collection $entries); public function setEntries(Collection $entries);
/**
* @param ExportJob $job
*/
public function setJob(ExportJob $job);
} }

View File

@@ -19,7 +19,6 @@ use FireflyIII\Export\Collector\JournalExportCollector;
use FireflyIII\Export\Collector\UploadCollector; use FireflyIII\Export\Collector\UploadCollector;
use FireflyIII\Export\Entry\Entry; use FireflyIII\Export\Entry\Entry;
use FireflyIII\Models\ExportJob; use FireflyIII\Models\ExportJob;
use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use Storage; use Storage;
@@ -54,18 +53,9 @@ class Processor implements ProcessorInterface
/** /**
* Processor constructor. * Processor constructor.
*
* @param array $settings
*/ */
public function __construct(array $settings) public function __construct()
{ {
// save settings
$this->settings = $settings;
$this->accounts = $settings['accounts'];
$this->exportFormat = $settings['exportFormat'];
$this->includeAttachments = $settings['includeAttachments'];
$this->includeOldUploads = $settings['includeOldUploads'];
$this->job = $settings['job'];
$this->journals = new Collection; $this->journals = new Collection;
$this->exportEntries = new Collection; $this->exportEntries = new Collection;
$this->files = new Collection; $this->files = new Collection;
@@ -78,7 +68,8 @@ class Processor implements ProcessorInterface
public function collectAttachments(): bool public function collectAttachments(): bool
{ {
/** @var AttachmentCollector $attachmentCollector */ /** @var AttachmentCollector $attachmentCollector */
$attachmentCollector = app(AttachmentCollector::class, [$this->job]); $attachmentCollector = app(AttachmentCollector::class);
$attachmentCollector->setJob($this->job);
$attachmentCollector->setDates($this->settings['startDate'], $this->settings['endDate']); $attachmentCollector->setDates($this->settings['startDate'], $this->settings['endDate']);
$attachmentCollector->run(); $attachmentCollector->run();
$this->files = $this->files->merge($attachmentCollector->getEntries()); $this->files = $this->files->merge($attachmentCollector->getEntries());
@@ -92,7 +83,8 @@ class Processor implements ProcessorInterface
public function collectJournals(): bool public function collectJournals(): bool
{ {
/** @var JournalExportCollector $collector */ /** @var JournalExportCollector $collector */
$collector = app(JournalExportCollector::class, [$this->job]); $collector = app(JournalExportCollector::class);
$collector->setJob($this->job);
$collector->setDates($this->settings['startDate'], $this->settings['endDate']); $collector->setDates($this->settings['startDate'], $this->settings['endDate']);
$collector->setAccounts($this->settings['accounts']); $collector->setAccounts($this->settings['accounts']);
$collector->run(); $collector->run();
@@ -108,7 +100,8 @@ class Processor implements ProcessorInterface
public function collectOldUploads(): bool public function collectOldUploads(): bool
{ {
/** @var UploadCollector $uploadCollector */ /** @var UploadCollector $uploadCollector */
$uploadCollector = app(UploadCollector::class, [$this->job]); $uploadCollector = app(UploadCollector::class);
$uploadCollector->setJob($this->job);
$uploadCollector->run(); $uploadCollector->run();
$this->files = $this->files->merge($uploadCollector->getEntries()); $this->files = $this->files->merge($uploadCollector->getEntries());
@@ -166,7 +159,8 @@ class Processor implements ProcessorInterface
public function exportJournals(): bool public function exportJournals(): bool
{ {
$exporterClass = config('firefly.export_formats.' . $this->exportFormat); $exporterClass = config('firefly.export_formats.' . $this->exportFormat);
$exporter = app($exporterClass, [$this->job]); $exporter = app($exporterClass);
$exporter->setJob($this->job);
$exporter->setEntries($this->exportEntries); $exporter->setEntries($this->exportEntries);
$exporter->run(); $exporter->run();
$this->files->push($exporter->getFileName()); $this->files->push($exporter->getFileName());
@@ -182,6 +176,20 @@ class Processor implements ProcessorInterface
return $this->files; return $this->files;
} }
/**
* @param array $settings
*/
public function setSettings(array $settings)
{
// save settings
$this->settings = $settings;
$this->accounts = $settings['accounts'];
$this->exportFormat = $settings['exportFormat'];
$this->includeAttachments = $settings['includeAttachments'];
$this->includeOldUploads = $settings['includeOldUploads'];
$this->job = $settings['job'];
}
/** /**
* *
*/ */

View File

@@ -25,11 +25,8 @@ interface ProcessorInterface
/** /**
* Processor constructor. * Processor constructor.
*
* @param array $settings
*
*/ */
public function __construct(array $settings); public function __construct();
/** /**
* @return bool * @return bool
@@ -65,4 +62,9 @@ interface ProcessorInterface
* @return Collection * @return Collection
*/ */
public function getFiles(): Collection; public function getFiles(): Collection;
/**
* @param array $settings
*/
public function setSettings(array $settings);
} }

View File

@@ -139,7 +139,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end); $collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end);
$journals = $collector->getJournals(); $journals = $collector->getJournals();
$journals = $journals->reverse(); $journals = $journals->reverse();

View File

@@ -185,7 +185,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end) $collector->setAccounts($this->accounts)->setRange($this->start, $this->end)
->setTypes([TransactionType::WITHDRAWAL]) ->setTypes([TransactionType::WITHDRAWAL])
->setBudgets($this->budgets)->withOpposingAccount()->disableFilter(); ->setBudgets($this->budgets)->withOpposingAccount()->disableFilter();

View File

@@ -195,7 +195,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end) $collector->setAccounts($this->accounts)->setRange($this->start, $this->end)
->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER]) ->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])
->setCategories($this->categories)->withOpposingAccount()->disableFilter(); ->setCategories($this->categories)->withOpposingAccount()->disableFilter();
@@ -218,7 +219,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
} }
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end) $collector->setAccounts($this->accounts)->setRange($this->start, $this->end)
->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER]) ->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
->setCategories($this->categories)->withOpposingAccount(); ->setCategories($this->categories)->withOpposingAccount();

View File

@@ -85,7 +85,8 @@ class MetaPieChart implements MetaPieChartInterface
// also collect all other transactions // also collect all other transactions
if ($this->collectOtherObjects && $direction === 'expense') { if ($this->collectOtherObjects && $direction === 'expense') {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [$this->user]); $collector = app(JournalCollectorInterface::class);
$collector->setUser($this->user);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::WITHDRAWAL]); $collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::WITHDRAWAL]);
$journals = $collector->getJournals(); $journals = $collector->getJournals();
$sum = strval($journals->sum('transaction_amount')); $sum = strval($journals->sum('transaction_amount'));
@@ -96,7 +97,8 @@ class MetaPieChart implements MetaPieChartInterface
if ($this->collectOtherObjects && $direction === 'income') { if ($this->collectOtherObjects && $direction === 'income') {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::DEPOSIT]); $collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::DEPOSIT]);
$journals = $collector->getJournals(); $journals = $collector->getJournals();
$sum = strval($journals->sum('transaction_amount')); $sum = strval($journals->sum('transaction_amount'));
@@ -201,7 +203,8 @@ class MetaPieChart implements MetaPieChartInterface
$modifier = 1; $modifier = 1;
} }
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts($this->accounts); $collector->setAccounts($this->accounts);
$collector->setRange($this->start, $this->end); $collector->setRange($this->start, $this->end);
$collector->setTypes($types); $collector->setTypes($types);
@@ -258,7 +261,8 @@ class MetaPieChart implements MetaPieChartInterface
{ {
$chartData = []; $chartData = [];
$names = []; $names = [];
$repository = app($this->repositories[$type], [$this->user]); $repository = app($this->repositories[$type]);
$repository->setUser($this->user);
foreach ($array as $objectId => $amount) { foreach ($array as $objectId => $amount) {
if (!isset($names[$objectId])) { if (!isset($names[$objectId])) {
$object = $repository->find(intval($objectId)); $object = $repository->find(intval($objectId));

View File

@@ -96,17 +96,6 @@ class JournalCollector implements JournalCollectorInterface
/** @var User */ /** @var User */
private $user; private $user;
/**
* JournalCollector constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
$this->query = $this->startQuery();
}
/** /**
* @return int * @return int
* @throws FireflyException * @throws FireflyException
@@ -244,7 +233,8 @@ class JournalCollector implements JournalCollectorInterface
public function setAllAssetAccounts(): JournalCollectorInterface public function setAllAssetAccounts(): JournalCollectorInterface
{ {
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [$this->user]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
$accounts = $repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]); $accounts = $repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
if ($accounts->count() > 0) { if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray(); $accountIds = $accounts->pluck('id')->toArray();
@@ -456,6 +446,37 @@ class JournalCollector implements JournalCollectorInterface
return $this; return $this;
} }
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
/**
*
*/
public function startQuery()
{
/** @var EloquentBuilder $query */
$query = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('transaction_currencies', 'transaction_currencies.id', 'transaction_journals.transaction_currency_id')
->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')
->leftJoin('bills', 'bills.id', 'transaction_journals.bill_id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'accounts.account_type_id', 'account_types.id')
->whereNull('transactions.deleted_at')
->whereNull('transaction_journals.deleted_at')
->where('transaction_journals.user_id', $this->user->id)
->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC');
$this->query = $query;
}
/** /**
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
@@ -729,27 +750,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');
} }
} }
/**
* @return EloquentBuilder
*/
private function startQuery(): EloquentBuilder
{
/** @var EloquentBuilder $query */
$query = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('transaction_currencies', 'transaction_currencies.id', 'transaction_journals.transaction_currency_id')
->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')
->leftJoin('bills', 'bills.id', 'transaction_journals.bill_id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'accounts.account_type_id', 'account_types.id')
->whereNull('transactions.deleted_at')
->whereNull('transaction_journals.deleted_at')
->where('transaction_journals.user_id', $this->user->id)
->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC');
return $query;
}
} }

View File

@@ -17,6 +17,7 @@ use Carbon\Carbon;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use FireflyIII\User;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@@ -27,7 +28,6 @@ use Illuminate\Support\Collection;
*/ */
interface JournalCollectorInterface interface JournalCollectorInterface
{ {
/** /**
* @return int * @return int
*/ */
@@ -84,7 +84,6 @@ interface JournalCollectorInterface
*/ */
public function setBudget(Budget $budget): JournalCollectorInterface; public function setBudget(Budget $budget): JournalCollectorInterface;
/** /**
* @param Collection $budgets * @param Collection $budgets
* *
@@ -149,6 +148,13 @@ interface JournalCollectorInterface
*/ */
public function setTypes(array $types): JournalCollectorInterface; public function setTypes(array $types): JournalCollectorInterface;
public function setUser(User $user);
/**
*
*/
public function startQuery();
/** /**
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */

View File

@@ -68,7 +68,8 @@ class ReportHelper implements ReportHelperInterface
/** @var BillRepositoryInterface $repository */ /** @var BillRepositoryInterface $repository */
$repository = app(BillRepositoryInterface::class); $repository = app(BillRepositoryInterface::class);
$bills = $repository->getBillsForAccounts($accounts); $bills = $repository->getBillsForAccounts($accounts);
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts($accounts)->setRange($start, $end)->setBills($bills); $collector->setAccounts($accounts)->setRange($start, $end)->setBills($bills);
$journals = $collector->getJournals(); $journals = $collector->getJournals();
$collection = new BillCollection; $collection = new BillCollection;

View File

@@ -23,7 +23,6 @@ use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
use FireflyIII\Repositories\Account\AccountTaskerInterface; use FireflyIII\Repositories\Account\AccountTaskerInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
@@ -96,12 +95,12 @@ class AccountController extends Controller
} }
/** /**
* @param ARI $repository * @param AccountRepositoryInterface $repository
* @param Account $account * @param Account $account
* *
* @return View * @return View
*/ */
public function delete(ARI $repository, Account $account) public function delete(AccountRepositoryInterface $repository, Account $account)
{ {
$typeName = config('firefly.shortNamesByFullName.' . $account->accountType->type); $typeName = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$subTitle = trans('firefly.delete_' . $typeName . '_account', ['name' => $account->name]); $subTitle = trans('firefly.delete_' . $typeName . '_account', ['name' => $account->name]);
@@ -118,12 +117,12 @@ class AccountController extends Controller
/** /**
* @param Request $request * @param Request $request
* @param ARI $repository * @param AccountRepositoryInterface $repository
* @param Account $account * @param Account $account
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/ */
public function destroy(Request $request, ARI $repository, Account $account) public function destroy(Request $request, AccountRepositoryInterface $repository, Account $account)
{ {
$type = $account->accountType->type; $type = $account->accountType->type;
$typeName = config('firefly.shortNamesByFullName.' . $type); $typeName = config('firefly.shortNamesByFullName.' . $type);
@@ -191,12 +190,12 @@ class AccountController extends Controller
} }
/** /**
* @param ARI $repository * @param AccountRepositoryInterface $repository
* @param string $what * @param string $what
* *
* @return View * @return View
*/ */
public function index(ARI $repository, string $what) public function index(AccountRepositoryInterface $repository, string $what)
{ {
$what = $what ?? 'asset'; $what = $what ?? 'asset';
$subTitle = trans('firefly.' . $what . '_accounts'); $subTitle = trans('firefly.' . $what . '_accounts');
@@ -262,7 +261,7 @@ class AccountController extends Controller
/** /**
* @param Request $request * @param Request $request
* @param ARI $repository * @param AccountRepositoryInterface $repository
* @param Account $account * @param Account $account
* *
* @return View * @return View
@@ -276,7 +275,8 @@ class AccountController extends Controller
// replace with journal collector: // replace with journal collector:
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page); $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);
$journals = $collector->getPaginatedJournals(); $journals = $collector->getPaginatedJournals();
$journals->setPath('accounts/show/' . $account->id . '/all'); $journals->setPath('accounts/show/' . $account->id . '/all');
@@ -310,7 +310,8 @@ class AccountController extends Controller
// replace with journal collector: // replace with journal collector:
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit($pageSize)->setPage($page); $collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit($pageSize)->setPage($page);
$journals = $collector->getPaginatedJournals(); $journals = $collector->getPaginatedJournals();
$journals->setPath('accounts/show/' . $account->id . '/' . $date); $journals->setPath('accounts/show/' . $account->id . '/' . $date);
@@ -324,12 +325,12 @@ class AccountController extends Controller
/** /**
* @param AccountFormRequest $request * @param AccountFormRequest $request
* @param ARI $repository * @param AccountRepositoryInterface $repository
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* *
*/ */
public function store(AccountFormRequest $request, ARI $repository) public function store(AccountFormRequest $request, AccountRepositoryInterface $repository)
{ {
$data = $request->getAccountData(); $data = $request->getAccountData();
$account = $repository->store($data); $account = $repository->store($data);
@@ -357,12 +358,12 @@ class AccountController extends Controller
/** /**
* @param AccountFormRequest $request * @param AccountFormRequest $request
* @param ARI $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
*/ */
public function update(AccountFormRequest $request, ARI $repository, Account $account) public function update(AccountFormRequest $request, AccountRepositoryInterface $repository, Account $account)
{ {
$data = $request->getAccountData(); $data = $request->getAccountData();
$repository->update($account, $data); $repository->update($account, $data);
@@ -409,8 +410,8 @@ class AccountController extends Controller
*/ */
private function periodEntries(Account $account): Collection private function periodEntries(Account $account): Collection
{ {
/** @var ARI $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(ARI::class); $repository = app(AccountRepositoryInterface::class);
/** @var AccountTaskerInterface $tasker */ /** @var AccountTaskerInterface $tasker */
$tasker = app(AccountTaskerInterface::class); $tasker = app(AccountTaskerInterface::class);

View File

@@ -208,7 +208,8 @@ class BillController extends Controller
// use collector: // use collector:
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAllAssetAccounts()->setBills(new Collection([$bill]))->setLimit($pageSize)->setPage($page)->withBudgetInformation() $collector->setAllAssetAccounts()->setBills(new Collection([$bill]))->setLimit($pageSize)->setPage($page)->withBudgetInformation()
->withCategoryInformation(); ->withCategoryInformation();
$journals = $collector->getPaginatedJournals(); $journals = $collector->getPaginatedJournals();

View File

@@ -202,7 +202,8 @@ class BudgetController extends Controller
// collector // collector
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutBudget(); $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutBudget();
$journals = $collector->getPaginatedJournals(); $journals = $collector->getPaginatedJournals();
$journals->setPath('/budgets/list/noBudget'); $journals->setPath('/budgets/list/noBudget');
@@ -243,7 +244,8 @@ class BudgetController extends Controller
$repetition = null; $repetition = null;
// collector: // collector:
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAllAssetAccounts()->setRange($start, $end)->setBudget($budget)->setLimit($pageSize)->setPage($page)->withCategoryInformation(); $collector->setAllAssetAccounts()->setRange($start, $end)->setBudget($budget)->setLimit($pageSize)->setPage($page)->withCategoryInformation();
$journals = $collector->getPaginatedJournals(); $journals = $collector->getPaginatedJournals();
$journals->setPath('/budgets/show/' . $budget->id); $journals->setPath('/budgets/show/' . $budget->id);
@@ -280,7 +282,8 @@ class BudgetController extends Controller
// collector: // collector:
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAllAssetAccounts()->setRange($budgetLimit->start_date, $budgetLimit->end_date) $collector->setAllAssetAccounts()->setRange($budgetLimit->start_date, $budgetLimit->end_date)
->setBudget($budget)->setLimit($pageSize)->setPage($page)->withCategoryInformation(); ->setBudget($budget)->setLimit($pageSize)->setPage($page)->withCategoryInformation();
$journals = $collector->getPaginatedJournals(); $journals = $collector->getPaginatedJournals();

View File

@@ -157,7 +157,8 @@ class CategoryController extends Controller
// new collector: // new collector:
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAllAssetAccounts()->setRange($start, $end)->withoutCategory();//->groupJournals(); $collector->setAllAssetAccounts()->setRange($start, $end)->withoutCategory();//->groupJournals();
$journals = $collector->getJournals(); $journals = $collector->getJournals();
$subTitle = trans( $subTitle = trans(

View File

@@ -416,7 +416,8 @@ class BudgetController extends Controller
{ {
// collector // collector
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$types = [TransactionType::WITHDRAWAL]; $types = [TransactionType::WITHDRAWAL];
$collector->setAllAssetAccounts()->setTypes($types)->setRange($start, $end)->withoutBudget(); $collector->setAllAssetAccounts()->setTypes($types)->setRange($start, $end)->withoutBudget();
$journals = $collector->getJournals(); $journals = $collector->getJournals();

View File

@@ -239,7 +239,8 @@ class BudgetReportController extends Controller
private function getExpenses(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end): Collection private function getExpenses(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end): Collection
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER]) $collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])
->setBudgets($budgets)->withOpposingAccount()->disableFilter(); ->setBudgets($budgets)->withOpposingAccount()->disableFilter();
$accountIds = $accounts->pluck('id')->toArray(); $accountIds = $accounts->pluck('id')->toArray();

View File

@@ -284,7 +284,8 @@ class CategoryReportController extends Controller
private function getExpenses(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): Collection private function getExpenses(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): Collection
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER]) $collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])
->setCategories($categories)->withOpposingAccount()->disableFilter(); ->setCategories($categories)->withOpposingAccount()->disableFilter();
$accountIds = $accounts->pluck('id')->toArray(); $accountIds = $accounts->pluck('id')->toArray();
@@ -305,7 +306,8 @@ class CategoryReportController extends Controller
private function getIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): Collection private function getIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): Collection
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER]) $collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
->setCategories($categories)->withOpposingAccount(); ->setCategories($categories)->withOpposingAccount();
$accountIds = $accounts->pluck('id')->toArray(); $accountIds = $accounts->pluck('id')->toArray();

View File

@@ -150,7 +150,8 @@ class ExportController extends Controller
$jobs->changeStatus($job, 'export_status_make_exporter'); $jobs->changeStatus($job, 'export_status_make_exporter');
/** @var ProcessorInterface $processor */ /** @var ProcessorInterface $processor */
$processor = app(ProcessorInterface::class, [$settings]); $processor = app(ProcessorInterface::class);
$processor->setSettings($settings);
/* /*
* Collect journals: * Collect journals:

View File

@@ -103,7 +103,8 @@ class ReportController extends Controller
switch (true) { switch (true) {
case ($role === BalanceLine::ROLE_DEFAULTROLE && !is_null($budget->id)): case ($role === BalanceLine::ROLE_DEFAULTROLE && !is_null($budget->id)):
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector $collector
->setAccounts(new Collection([$account])) ->setAccounts(new Collection([$account]))
->setRange($attributes['startDate'], $attributes['endDate']) ->setRange($attributes['startDate'], $attributes['endDate'])
@@ -114,7 +115,8 @@ class ReportController extends Controller
case ($role === BalanceLine::ROLE_DEFAULTROLE && is_null($budget->id)): case ($role === BalanceLine::ROLE_DEFAULTROLE && is_null($budget->id)):
$budget->name = strval(trans('firefly.no_budget')); $budget->name = strval(trans('firefly.no_budget'));
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector $collector
->setAccounts(new Collection([$account])) ->setAccounts(new Collection([$account]))
->setTypes($types) ->setTypes($types)
@@ -124,7 +126,8 @@ class ReportController extends Controller
break; break;
case ($role === BalanceLine::ROLE_DIFFROLE): case ($role === BalanceLine::ROLE_DIFFROLE):
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector $collector
->setAccounts(new Collection([$account])) ->setAccounts(new Collection([$account]))
->setTypes($types) ->setTypes($types)
@@ -169,7 +172,8 @@ class ReportController extends Controller
$repository = app(BudgetRepositoryInterface::class); $repository = app(BudgetRepositoryInterface::class);
$budget = $repository->find(intval($attributes['budgetId'])); $budget = $repository->find(intval($attributes['budgetId']));
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector $collector
->setAccounts($attributes['accounts']) ->setAccounts($attributes['accounts'])
@@ -203,7 +207,8 @@ class ReportController extends Controller
$category = $repository->find(intval($attributes['categoryId'])); $category = $repository->find(intval($attributes['categoryId']));
$types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER]; $types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER];
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts($attributes['accounts'])->setTypes($types) $collector->setAccounts($attributes['accounts'])->setTypes($types)
->setRange($attributes['startDate'], $attributes['endDate']) ->setRange($attributes['startDate'], $attributes['endDate'])
->setCategory($category); ->setCategory($category);
@@ -230,7 +235,8 @@ class ReportController extends Controller
$account = $repository->find(intval($attributes['accountId'])); $account = $repository->find(intval($attributes['accountId']));
$types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER]; $types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER];
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts(new Collection([$account]))->setRange($attributes['startDate'], $attributes['endDate'])->setTypes($types); $collector->setAccounts(new Collection([$account]))->setRange($attributes['startDate'], $attributes['endDate'])->setTypes($types);
$journals = $collector->getJournals(); $journals = $collector->getJournals();
$report = $attributes['accounts']->pluck('id')->toArray(); // accounts used in this report $report = $attributes['accounts']->pluck('id')->toArray(); // accounts used in this report
@@ -266,7 +272,8 @@ class ReportController extends Controller
$account = $repository->find(intval($attributes['accountId'])); $account = $repository->find(intval($attributes['accountId']));
$types = [TransactionType::DEPOSIT, TransactionType::TRANSFER]; $types = [TransactionType::DEPOSIT, TransactionType::TRANSFER];
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts(new Collection([$account]))->setRange($attributes['startDate'], $attributes['endDate'])->setTypes($types); $collector->setAccounts(new Collection([$account]))->setRange($attributes['startDate'], $attributes['endDate'])->setTypes($types);
$journals = $collector->getJournals(); $journals = $collector->getJournals();
$report = $attributes['accounts']->pluck('id')->toArray(); // accounts used in this report $report = $attributes['accounts']->pluck('id')->toArray(); // accounts used in this report

View File

@@ -289,7 +289,7 @@ class RuleController extends Controller
$range = config('firefly.test-triggers.range'); $range = config('firefly.test-triggers.range');
/** @var TransactionMatcher $matcher */ /** @var TransactionMatcher $matcher */
$matcher = app('FireflyIII\Rules\TransactionMatcher'); $matcher = app(TransactionMatcher::class);
$matcher->setLimit($limit); $matcher->setLimit($limit);
$matcher->setRange($range); $matcher->setRange($range);
$matcher->setTriggers($triggers); $matcher->setTriggers($triggers);
@@ -352,7 +352,7 @@ class RuleController extends Controller
private function createDefaultRule() private function createDefaultRule()
{ {
/** @var RuleRepositoryInterface $repository */ /** @var RuleRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Rule\RuleRepositoryInterface'); $repository = app(RuleRepositoryInterface::class);
if ($repository->count() === 0) { if ($repository->count() === 0) {
$data = [ $data = [

View File

@@ -72,7 +72,8 @@ class TransactionController extends Controller
$end = session('end', Navigation::endOfPeriod(new Carbon, $range)); $end = session('end', Navigation::endOfPeriod(new Carbon, $range));
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setTypes($types)->setLimit($pageSize)->setPage($page)->setAllAssetAccounts(); $collector->setTypes($types)->setLimit($pageSize)->setPage($page)->setAllAssetAccounts();
$collector->setRange($start, $end)->withBudgetInformation()->withCategoryInformation(); $collector->setRange($start, $end)->withBudgetInformation()->withCategoryInformation();
@@ -122,7 +123,8 @@ class TransactionController extends Controller
$subTitle = sprintf('%s (%s)', trans('firefly.title_' . $what), strtolower(trans('firefly.everything'))); $subTitle = sprintf('%s (%s)', trans('firefly.title_' . $what), strtolower(trans('firefly.everything')));
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page')); $page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setTypes($types)->setLimit($pageSize)->setPage($page)->setAllAssetAccounts()->withBudgetInformation()->withCategoryInformation(); $collector->setTypes($types)->setLimit($pageSize)->setPage($page)->setAllAssetAccounts()->withBudgetInformation()->withCategoryInformation();
// do not filter transfers if $what = transfer. // do not filter transfers if $what = transfer.
@@ -161,7 +163,8 @@ class TransactionController extends Controller
Log::debug(sprintf('Transaction index by date will show between %s and %s', $start->format('Y-m-d'), $end->format('Y-m-d'))); Log::debug(sprintf('Transaction index by date will show between %s and %s', $start->format('Y-m-d'), $end->format('Y-m-d')));
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setTypes($types)->setLimit($pageSize)->setPage($page)->setAllAssetAccounts(); $collector->setTypes($types)->setLimit($pageSize)->setPage($page)->setAllAssetAccounts();
$collector->setRange($start, $end)->withBudgetInformation()->withCategoryInformation(); $collector->setRange($start, $end)->withBudgetInformation()->withCategoryInformation();

View File

@@ -49,9 +49,9 @@ class Kernel extends HttpKernel
*/ */
protected $bootstrappers protected $bootstrappers
= [ = [
'Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables',
'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\LoadConfiguration',
'FireflyIII\Bootstrap\ConfigureLogging', //'FireflyIII\Bootstrap\ConfigureLogging',
'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\HandleExceptions',
'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterFacades',
'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\RegisterProviders',

View File

@@ -49,7 +49,8 @@ class RuleGroupFormRequest extends Request
public function rules() public function rules()
{ {
/** @var RuleGroupRepositoryInterface $repository */ /** @var RuleGroupRepositoryInterface $repository */
$repository = app(RuleGroupRepositoryInterface::class, [auth()->user()]); $repository = app(RuleGroupRepositoryInterface::class);
$repository->setUser(auth()->user());
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title'; $titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title';
if (!is_null($repository->find(intval($this->get('id')))->id)) { if (!is_null($repository->find(intval($this->get('id')))->id)) {
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,' . intval($this->get('id')); $titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,' . intval($this->get('id'));

View File

@@ -40,7 +40,8 @@ class AccountId extends BasicConverter implements ConverterInterface
return new Account; return new Account;
} }
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [$this->user]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {
Log::debug('Found account in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); Log::debug('Found account in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);

View File

@@ -43,7 +43,8 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
} }
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [$this->user]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {

View File

@@ -43,7 +43,8 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
} }
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [$this->user]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {

View File

@@ -41,7 +41,8 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
} }
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [$this->user]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {

View File

@@ -42,7 +42,8 @@ class BillId extends BasicConverter implements ConverterInterface
} }
/** @var BillRepositoryInterface $repository */ /** @var BillRepositoryInterface $repository */
$repository = app(BillRepositoryInterface::class, [$this->user]); $repository = app(BillRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {
Log::debug('Found bill in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); Log::debug('Found bill in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);

View File

@@ -44,7 +44,8 @@ class BillName extends BasicConverter implements ConverterInterface
} }
/** @var BillRepositoryInterface $repository */ /** @var BillRepositoryInterface $repository */
$repository = app(BillRepositoryInterface::class, [$this->user]); $repository = app(BillRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {
Log::debug('Found bill in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); Log::debug('Found bill in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);

View File

@@ -42,7 +42,8 @@ class BudgetId extends BasicConverter implements ConverterInterface
} }
/** @var BudgetRepositoryInterface $repository */ /** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepositoryInterface::class, [$this->user]); $repository = app(BudgetRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {
Log::debug('Found budget in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); Log::debug('Found budget in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);

View File

@@ -42,7 +42,8 @@ class BudgetName extends BasicConverter implements ConverterInterface
} }
/** @var BudgetRepositoryInterface $repository */ /** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepositoryInterface::class, [$this->user]); $repository = app(BudgetRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {
Log::debug('Found budget in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); Log::debug('Found budget in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);

View File

@@ -42,7 +42,8 @@ class CategoryId extends BasicConverter implements ConverterInterface
} }
/** @var CategoryRepositoryInterface $repository */ /** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class, [$this->user]); $repository = app(CategoryRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {
Log::debug('Found category in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); Log::debug('Found category in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);

View File

@@ -42,7 +42,8 @@ class CategoryName extends BasicConverter implements ConverterInterface
} }
/** @var CategoryRepositoryInterface $repository */ /** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class, [$this->user]); $repository = app(CategoryRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {
Log::debug('Found category in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); Log::debug('Found category in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);

View File

@@ -36,6 +36,7 @@ class CurrencyCode extends BasicConverter implements ConverterInterface
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class); $repository = app(CurrencyRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {
Log::debug('Found currency in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); Log::debug('Found currency in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);

View File

@@ -42,7 +42,8 @@ class CurrencyId extends BasicConverter implements ConverterInterface
} }
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class, [$this->user]); $repository = app(CurrencyRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {
Log::debug('Found currency in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); Log::debug('Found currency in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);

View File

@@ -42,7 +42,8 @@ class CurrencyName extends BasicConverter implements ConverterInterface
} }
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class, [$this->user]); $repository = app(CurrencyRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {
Log::debug('Found currency in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); Log::debug('Found currency in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);

View File

@@ -42,7 +42,8 @@ class CurrencySymbol extends BasicConverter implements ConverterInterface
} }
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class, [$this->user]); $repository = app(CurrencyRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {
Log::debug('Found currency in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); Log::debug('Found currency in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);

View File

@@ -43,7 +43,8 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
} }
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [$this->user]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {

View File

@@ -42,7 +42,8 @@ class OpposingAccountName extends BasicConverter implements ConverterInterface
} }
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [$this->user]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {

View File

@@ -43,7 +43,8 @@ class OpposingAccountNumber extends BasicConverter implements ConverterInterface
} }
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [$this->user]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
if (isset($this->mapping[$value])) { if (isset($this->mapping[$value])) {

View File

@@ -39,7 +39,8 @@ class TagSplit
Log::debug('Exploded parts.', $parts); Log::debug('Exploded parts.', $parts);
/** @var TagRepositoryInterface $repository */ /** @var TagRepositoryInterface $repository */
$repository = app(TagRepositoryInterface::class, [$user]); $repository = app(TagRepositoryInterface::class);
$repository->setUser($user);
/** @var string $part */ /** @var string $part */

View File

@@ -58,7 +58,8 @@ class ImportProcedure implements ImportProcedureInterface
if ($job->configuration['import-account'] != 0) { if ($job->configuration['import-account'] != 0) {
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [$job->user]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($job->user);
$validator->setDefaultImportAccount($repository->find($job->configuration['import-account'])); $validator->setDefaultImportAccount($repository->find($job->configuration['import-account']));
} }

View File

@@ -159,7 +159,8 @@ class ImportStorage
private function createImportTag(): Tag private function createImportTag(): Tag
{ {
/** @var TagRepositoryInterface $repository */ /** @var TagRepositoryInterface $repository */
$repository = app(TagRepositoryInterface::class, [$this->user]); $repository = app(TagRepositoryInterface::class);
$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,

View File

@@ -177,7 +177,8 @@ class ImportValidator
// find it first by new type: // find it first by new type:
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [$this->user]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
$result = $repository->findByName($account->name, [$type]); $result = $repository->findByName($account->name, [$type]);
if (is_null($result->id)) { if (is_null($result->id)) {
@@ -214,7 +215,8 @@ class ImportValidator
{ {
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [$this->user]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
$name = 'Unknown expense account'; $name = 'Unknown expense account';
$result = $repository->findByName($name, [AccountType::EXPENSE]); $result = $repository->findByName($name, [AccountType::EXPENSE]);
@@ -235,7 +237,8 @@ class ImportValidator
{ {
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [$this->user]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($this->user);
$name = 'Unknown revenue account'; $name = 'Unknown revenue account';
$result = $repository->findByName($name, [AccountType::REVENUE]); $result = $repository->findByName($name, [AccountType::REVENUE]);
@@ -382,7 +385,8 @@ class ImportValidator
{ {
if (is_null($entry->fields['currency'])) { if (is_null($entry->fields['currency'])) {
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class, [$this->user]); $repository = app(CurrencyRepositoryInterface::class);
$repository->setUser($this->user);
// is the default currency for the user or the system // is the default currency for the user or the system
$defaultCode = Preferences::getForUser($this->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data; $defaultCode = Preferences::getForUser($this->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data;

View File

@@ -181,7 +181,8 @@ class CsvSetup implements SetupInterface
public function saveImportConfiguration(array $data, FileBag $files): bool public function saveImportConfiguration(array $data, FileBag $files): bool
{ {
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class, [auth()->user()]); $repository = app(AccountRepositoryInterface::class);
$repository->setUser(auth()->user());
$importId = $data['csv_import_account'] ?? 0; $importId = $data['csv_import_account'] ?? 0;
$account = $repository->find(intval($importId)); $account = $repository->find(intval($importId));

View File

@@ -156,7 +156,8 @@ class ExecuteRuleGroupOnExistingTransactions extends Job implements ShouldQueue
protected function collectJournals() protected function collectJournals()
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [auth()->user()]); $collector = app(JournalCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->setAccounts($this->accounts)->setRange($this->startDate, $this->endDate); $collector->setAccounts($this->accounts)->setRange($this->startDate, $this->endDate);
return $collector->getJournals(); return $collector->getJournals();

View File

@@ -14,7 +14,10 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\Account\AccountRepository;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Account\AccountTasker;
use FireflyIII\Repositories\Account\AccountTaskerInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -44,8 +47,6 @@ class AccountServiceProvider extends ServiceProvider
{ {
$this->registerRepository(); $this->registerRepository();
$this->registerTasker(); $this->registerTasker();
} }
/** /**
@@ -54,16 +55,16 @@ class AccountServiceProvider extends ServiceProvider
private function registerRepository() private function registerRepository()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Account\AccountRepositoryInterface', AccountRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var AccountRepositoryInterface $repository */
return app('FireflyIII\Repositories\Account\AccountRepository', [auth()->user()]); $repository = app(AccountRepository::class);
}
if (!isset($arguments[0]) && !$app->auth->check()) { if ($app->auth->check()) {
throw new FireflyException('There is no user present.'); $repository->setUser(auth()->user());
} }
return app('FireflyIII\Repositories\Account\AccountRepository', $arguments); return $repository;
} }
); );
} }
@@ -74,16 +75,16 @@ class AccountServiceProvider extends ServiceProvider
private function registerTasker() private function registerTasker()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Account\AccountTaskerInterface', AccountTaskerInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var AccountTaskerInterface $tasker */
return app('FireflyIII\Repositories\Account\AccountTasker', [auth()->user()]); $tasker = app(AccountTasker::class);
}
if (!isset($arguments[0]) && !$app->auth->check()) { if ($app->auth->check()) {
throw new FireflyException('There is no user present.'); $tasker->setUser(auth()->user());
} }
return app('FireflyIII\Repositories\Account\AccountTasker', $arguments); return $tasker;
} }
); );
} }

View File

@@ -14,7 +14,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\Attachment\AttachmentRepository;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -43,16 +44,15 @@ class AttachmentServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface', AttachmentRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var AttachmentRepositoryInterface $repository */
return app('FireflyIII\Repositories\Attachment\AttachmentRepository', [auth()->user()]); $repository = app(AttachmentRepository::class);
} if ($app->auth->check()) {
if (!isset($arguments[0]) && !$app->auth->check()) { $repository->setUser(auth()->user());
throw new FireflyException('There is no user present.');
} }
return app('FireflyIII\Repositories\Attachment\AttachmentRepository', $arguments); return $repository;
} }
); );
} }

View File

@@ -14,7 +14,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\Bill\BillRepository;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -43,16 +44,16 @@ class BillServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Bill\BillRepositoryInterface', BillRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var BillRepositoryInterface $repository */
return app('FireflyIII\Repositories\Bill\BillRepository', [auth()->user()]); $repository = app(BillRepository::class);
}
if (!isset($arguments[0]) && !$app->auth->check()) { if ($app->auth->check()) {
throw new FireflyException('There is no user present.'); $repository->setUser(auth()->user());
} }
return app('FireflyIII\Repositories\Bill\BillRepository', $arguments); return $repository;
} }
); );
} }

View File

@@ -14,7 +14,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\Budget\BudgetRepository;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -43,16 +44,15 @@ class BudgetServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Budget\BudgetRepositoryInterface', BudgetRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var BudgetRepositoryInterface $repository */
return app('FireflyIII\Repositories\Budget\BudgetRepository', [auth()->user()]); $repository = app(BudgetRepository::class);
} if ($app->auth->check()) {
if (!isset($arguments[0]) && !$app->auth->check()) { $repository->setUser(auth()->user());
throw new FireflyException('There is no user present.');
} }
return app('FireflyIII\Repositories\Budget\BudgetRepository', $arguments); return $repository;
} }
); );
} }

View File

@@ -14,7 +14,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\Category\CategoryRepository;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -43,16 +44,15 @@ class CategoryServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Category\CategoryRepositoryInterface', CategoryRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var CategoryRepository $repository */
return app('FireflyIII\Repositories\Category\CategoryRepository', [auth()->user()]); $repository = app(CategoryRepository::class);
} if ($app->auth->check()) {
if (!isset($arguments[0]) && !$app->auth->check()) { $repository->setUser(auth()->user());
throw new FireflyException('There is no user present.');
} }
return app('FireflyIII\Repositories\Category\CategoryRepository', $arguments); return $repository;
} }
); );

View File

@@ -1,64 +0,0 @@
<?php
/**
* CrudServiceProvider.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types = 1);
namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider;
/**
* Class CrudServiceProvider
*
* @package FireflyIII\Providers
*/
class CrudServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->registerJournal();
}
private function registerJournal()
{
$this->app->bind(
'FireflyIII\Crud\Split\JournalInterface',
function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Crud\Split\Journal', [auth()->user()]);
}
if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.');
}
return app('FireflyIII\Crud\Split\Journal', $arguments);
}
);
}
}

View File

@@ -14,7 +14,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\Currency\CurrencyRepository;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -43,16 +44,15 @@ class CurrencyServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Currency\CurrencyRepositoryInterface', CurrencyRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var CurrencyRepository $repository */
return app('FireflyIII\Repositories\Currency\CurrencyRepository', [auth()->user()]); $repository = app(CurrencyRepository::class);
} if ($app->auth->check()) {
if (!isset($arguments[0]) && !$app->auth->check()) { $repository->setUser(auth()->user());
throw new FireflyException('There is no user present.');
} }
return app('FireflyIII\Repositories\Currency\CurrencyRepository', $arguments); return $repository;
} }
); );
} }

View File

@@ -14,7 +14,10 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\ExportJob\ExportJobRepository;
use FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface;
use FireflyIII\Repositories\ImportJob\ImportJobRepository;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -33,8 +36,7 @@ class ExportJobServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
$this->exportJob();
$this->importJob();
} }
@@ -45,7 +47,8 @@ class ExportJobServiceProvider extends ServiceProvider
*/ */
public function register() public function register()
{ {
// $this->exportJob();
$this->importJob();
} }
/** /**
@@ -53,18 +56,16 @@ class ExportJobServiceProvider extends ServiceProvider
*/ */
private function exportJob() private function exportJob()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface', ExportJobRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var ExportJobRepository $repository */
return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', [auth()->user()]); $repository = app(ExportJobRepository::class);
} if ($app->auth->check()) {
if (!isset($arguments[0]) && !$app->auth->check()) { $repository->setUser(auth()->user());
throw new FireflyException('There is no user present.');
} }
return app('FireflyIII\Repositories\ExportJob\ExportJobRepository', $arguments); return $repository;
} }
); );
} }
@@ -72,16 +73,15 @@ class ExportJobServiceProvider extends ServiceProvider
private function importJob() private function importJob()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface', ImportJobRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var ImportJobRepository $repository */
return app('FireflyIII\Repositories\ImportJob\ImportJobRepository', [auth()->user()]); $repository = app(ImportJobRepository::class);
} if ($app->auth->check()) {
if (!isset($arguments[0]) && !$app->auth->check()) { $repository->setUser(auth()->user());
throw new FireflyException('There is no user present.');
} }
return app('FireflyIII\Repositories\ImportJob\ImportJobRepository', $arguments); return $repository;
} }
); );
} }

View File

@@ -13,6 +13,28 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Export\Processor;
use FireflyIII\Export\ProcessorInterface;
use FireflyIII\Generator\Chart\Basic\ChartJsGenerator;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Attachments\AttachmentHelper;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Helpers\Chart\MetaPieChart;
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Helpers\FiscalHelper;
use FireflyIII\Helpers\FiscalHelperInterface;
use FireflyIII\Helpers\Help\Help;
use FireflyIII\Helpers\Help\HelpInterface;
use FireflyIII\Helpers\Report\BalanceReportHelper;
use FireflyIII\Helpers\Report\BalanceReportHelperInterface;
use FireflyIII\Helpers\Report\BudgetReportHelper;
use FireflyIII\Helpers\Report\BudgetReportHelperInterface;
use FireflyIII\Helpers\Report\ReportHelper;
use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Import\ImportProcedure;
use FireflyIII\Import\ImportProcedureInterface;
use FireflyIII\Repositories\User\UserRepository;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Support\Amount; use FireflyIII\Support\Amount;
use FireflyIII\Support\ExpandedForm; use FireflyIII\Support\ExpandedForm;
use FireflyIII\Support\FireflyConfig; use FireflyIII\Support\FireflyConfig;
@@ -94,22 +116,22 @@ class FireflyServiceProvider extends ServiceProvider
); );
// chart generator: // chart generator:
$this->app->bind('FireflyIII\Generator\Chart\Basic\GeneratorInterface', 'FireflyIII\Generator\Chart\Basic\ChartJsGenerator'); $this->app->bind(GeneratorInterface::class, ChartJsGenerator::class);
// chart builder // chart builder
$this->app->bind('FireflyIII\Helpers\Chart\MetaPieChartInterface', 'FireflyIII\Helpers\Chart\MetaPieChart'); $this->app->bind(MetaPieChartInterface::class, MetaPieChart::class);
// other generators // other generators
$this->app->bind('FireflyIII\Export\ProcessorInterface', 'FireflyIII\Export\Processor'); $this->app->bind(ProcessorInterface::class,Processor::class);
$this->app->bind('FireflyIII\Import\ImportProcedureInterface', 'FireflyIII\Import\ImportProcedure'); $this->app->bind(ImportProcedureInterface::class,ImportProcedure::class);
$this->app->bind('FireflyIII\Repositories\User\UserRepositoryInterface', 'FireflyIII\Repositories\User\UserRepository'); $this->app->bind(UserRepositoryInterface::class, UserRepository::class);
$this->app->bind('FireflyIII\Helpers\Attachments\AttachmentHelperInterface', 'FireflyIII\Helpers\Attachments\AttachmentHelper'); $this->app->bind(AttachmentHelperInterface::class, AttachmentHelper::class);
$this->app->bind('FireflyIII\Helpers\Help\HelpInterface', 'FireflyIII\Helpers\Help\Help'); $this->app->bind(HelpInterface::class, Help::class);
$this->app->bind('FireflyIII\Helpers\Report\ReportHelperInterface', 'FireflyIII\Helpers\Report\ReportHelper'); $this->app->bind(ReportHelperInterface::class, ReportHelper::class);
$this->app->bind('FireflyIII\Helpers\FiscalHelperInterface', 'FireflyIII\Helpers\FiscalHelper'); $this->app->bind(FiscalHelperInterface::class,FiscalHelper::class);
$this->app->bind('FireflyIII\Helpers\Report\BalanceReportHelperInterface', 'FireflyIII\Helpers\Report\BalanceReportHelper'); $this->app->bind(BalanceReportHelperInterface::class, BalanceReportHelper::class);
$this->app->bind('FireflyIII\Helpers\Report\BudgetReportHelperInterface', 'FireflyIII\Helpers\Report\BudgetReportHelper'); $this->app->bind(BudgetReportHelperInterface::class, BudgetReportHelper::class);
} }
} }

View File

@@ -14,7 +14,12 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Collector\JournalCollector;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Repositories\Journal\JournalRepository;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalTasker;
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -50,16 +55,16 @@ class JournalServiceProvider extends ServiceProvider
private function registerCollector() private function registerCollector()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Helpers\Collector\JournalCollectorInterface', JournalCollectorInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var JournalCollectorInterface $collector */
return app('FireflyIII\Helpers\Collector\JournalCollector', [auth()->user()]); $collector = app(JournalCollector::class);
} if ($app->auth->check()) {
if (!isset($arguments[0]) && !$app->auth->check()) { $collector->setUser(auth()->user());
throw new FireflyException('There is no user present.');
} }
$collector->startQuery();
return app('FireflyIII\Helpers\Collector\JournalCollector', $arguments); return $collector;
} }
); );
} }
@@ -67,16 +72,16 @@ class JournalServiceProvider extends ServiceProvider
private function registerRepository() private function registerRepository()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Journal\JournalRepositoryInterface', JournalRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var JournalRepositoryInterface $repository */
return app('FireflyIII\Repositories\Journal\JournalRepository', [auth()->user()]); $repository = app(JournalRepository::class);
} if ($app->auth->check()) {
if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.'); $repository->setUser(auth()->user());
} }
return app('FireflyIII\Repositories\Journal\JournalRepository', $arguments); return $repository;
} }
); );
} }
@@ -84,16 +89,16 @@ class JournalServiceProvider extends ServiceProvider
private function registerTasker() private function registerTasker()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Journal\JournalTaskerInterface', JournalTaskerInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var JournalTaskerInterface $tasker */
return app('FireflyIII\Repositories\Journal\JournalTasker', [auth()->user()]); $tasker = app(JournalTasker::class);
}
if (!isset($arguments[0]) && !$app->auth->check()) { if ($app->auth->check()) {
throw new FireflyException('There is no user present.'); $tasker->setUser(auth()->user());
} }
return app('FireflyIII\Repositories\Journal\JournalTasker', $arguments); return $tasker;
} }
); );
} }

View File

@@ -0,0 +1,53 @@
<?php
/**
* LogServiceProvider.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types = 1);
namespace FireflyIII\Providers;
use Illuminate\Log\LogServiceProvider as LaravelLogServiceProvider;
use Illuminate\Log\Writer;
/**
* Class LogServiceProvider
*
* @package FireflyIII\Providers
*/
class LogServiceProvider extends LaravelLogServiceProvider
{
/**
* Configure the Monolog handlers for the application.
*
* @param \Illuminate\Log\Writer $log
*
* @return void
*/
protected function configureDailyHandler(Writer $log)
{
$log->useDailyFiles(
$this->app->storagePath() . '/logs/firefly-iii.log', $this->maxFiles(),
$this->logLevel()
);
}
/**
* Configure the Monolog handlers for the application.
*
* @param \Illuminate\Log\Writer $log
*
* @return void
*/
protected function configureSingleHandler(Writer $log)
{
$log->useFiles(
$this->app->storagePath() . '/logs/firefly-iii.log',
$this->logLevel()
);
}
}

View File

@@ -15,6 +15,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepository;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -44,16 +46,14 @@ class PiggyBankServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface', PiggyBankRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var PiggyBankRepository $repository */
return app('FireflyIII\Repositories\PiggyBank\PiggyBankRepository', [auth()->user()]); $repository = app(PiggyBankRepository::class);
if ($app->auth->check()) {
$repository->setUser(auth()->user());
} }
if (!isset($arguments[0]) && !$app->auth->check()) { return $repository;
throw new FireflyException('There is no user present.');
}
return app('FireflyIII\Repositories\PiggyBank\PiggyBankRepository', $arguments);
} }
); );
} }

View File

@@ -14,7 +14,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\RuleGroup\RuleGroupRepository;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -44,16 +45,15 @@ class RuleGroupServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface', RuleGroupRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var RuleGroupRepository $repository */
return app('FireflyIII\Repositories\RuleGroup\RuleGroupRepository', [auth()->user()]); $repository = app(RuleGroupRepository::class);
} if ($app->auth->check()) {
if (!isset($arguments[0]) && !$app->auth->check()) { $repository->setUser(auth()->user());
throw new FireflyException('There is no user present.');
} }
return app('FireflyIII\Repositories\RuleGroup\RuleGroupRepository', $arguments); return $repository;
} }
); );
} }

View File

@@ -14,7 +14,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\Rule\RuleRepository;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -43,16 +44,14 @@ class RuleServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Rule\RuleRepositoryInterface', RuleRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var RuleRepository $repository */
return app('FireflyIII\Repositories\Rule\RuleRepository', [auth()->user()]); $repository = app(RuleRepository::class);
if ($app->auth->check()) {
$repository->setUser(auth()->user());
} }
if (!isset($arguments[0]) && !$app->auth->check()) { return $repository;
throw new FireflyException('There is no user present.');
}
return app('FireflyIII\Repositories\Rule\RuleRepository', $arguments);
} }
); );
} }

View File

@@ -14,7 +14,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Support\Search\Search;
use FireflyIII\Support\Search\SearchInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -43,16 +44,15 @@ class SearchServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Support\Search\SearchInterface', SearchInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var Search $search */
return app('FireflyIII\Support\Search\Search', [auth()->user()]); $search = app(Search::class);
} if ($app->auth->check()) {
if (!isset($arguments[0]) && !$app->auth->check()) { $search->setUser(auth()->user());
throw new FireflyException('There is no user present.');
} }
return app('FireflyIII\Support\Search\Search', $arguments); return $search;
} }
); );
} }

View File

@@ -14,7 +14,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers; namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Repositories\Tag\TagRepository;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -43,16 +44,16 @@ class TagServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->bind( $this->app->bind(
'FireflyIII\Repositories\Tag\TagRepositoryInterface', TagRepositoryInterface::class,
function (Application $app, array $arguments) { function (Application $app) {
if (!isset($arguments[0]) && $app->auth->check()) { /** @var TagRepository $repository */
return app('FireflyIII\Repositories\Tag\TagRepository', [auth()->user()]); $repository = app(TagRepository::class);
}
if (!isset($arguments[0]) && !$app->auth->check()) { if ($app->auth->check()) {
throw new FireflyException('There is no user present.'); $repository->setUser(auth()->user());
} }
return app('FireflyIII\Repositories\Tag\TagRepository', $arguments); return $repository;
} }
); );
} }

View File

@@ -43,16 +43,6 @@ class AccountRepository implements AccountRepositoryInterface
/** @var array */ /** @var array */
private $validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType', 'accountNumber', 'currency_id', 'BIC']; private $validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType', 'accountNumber', 'currency_id', 'BIC'];
/**
* AttachmentRepository constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/** /**
* Moved here from account CRUD * Moved here from account CRUD
* *
@@ -323,6 +313,14 @@ class AccountRepository implements AccountRepositoryInterface
return $journal->date; return $journal->date;
} }
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
/** /**
* @param array $data * @param array $data
* *

View File

@@ -16,6 +16,7 @@ namespace FireflyIII\Repositories\Account;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -124,6 +125,11 @@ interface AccountRepositoryInterface
*/ */
public function oldestJournalDate(Account $account): Carbon; public function oldestJournalDate(Account $account): Carbon;
/**
* @param User $user
*/
public function setUser(User $user);
/** /**
* @param array $data * @param array $data
* *

View File

@@ -31,16 +31,6 @@ class AccountTasker implements AccountTaskerInterface
/** @var User */ /** @var User */
private $user; private $user;
/**
* AttachmentRepository constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/** /**
* @see self::amountInPeriod * @see self::amountInPeriod
* *
@@ -155,6 +145,14 @@ class AccountTasker implements AccountTaskerInterface
return $return; return $return;
} }
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
/** /**
* Will return how much money has been going out (ie. spent) by the given account(s). * Will return how much money has been going out (ie. spent) by the given account(s).
* Alternatively, will return how much money has been coming in (ie. earned) by the given accounts. * Alternatively, will return how much money has been coming in (ie. earned) by the given accounts.

View File

@@ -14,6 +14,7 @@ declare(strict_types = 1);
namespace FireflyIII\Repositories\Account; namespace FireflyIII\Repositories\Account;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -23,7 +24,6 @@ use Illuminate\Support\Collection;
*/ */
interface AccountTaskerInterface interface AccountTaskerInterface
{ {
/** /**
* @param Collection $accounts * @param Collection $accounts
* @param Collection $excluded * @param Collection $excluded
@@ -57,4 +57,9 @@ interface AccountTaskerInterface
*/ */
public function getAccountReport(Collection $accounts, Carbon $start, Carbon $end): array; public function getAccountReport(Collection $accounts, Carbon $start, Carbon $end): array;
/**
* @param User $user
*/
public function setUser(User $user);
} }

View File

@@ -14,12 +14,12 @@ declare(strict_types = 1);
namespace FireflyIII\Repositories\Attachment; namespace FireflyIII\Repositories\Attachment;
use Carbon\Carbon; use Carbon\Carbon;
use Crypt;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Models\Attachment; use FireflyIII\Models\Attachment;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Storage; use Storage;
use Crypt;
/** /**
* Class AttachmentRepository * Class AttachmentRepository
@@ -31,16 +31,6 @@ class AttachmentRepository implements AttachmentRepositoryInterface
/** @var User */ /** @var User */
private $user; private $user;
/**
* AttachmentRepository constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/** /**
* @param Attachment $attachment * @param Attachment $attachment
* *
@@ -117,6 +107,14 @@ class AttachmentRepository implements AttachmentRepositoryInterface
return ''; return '';
} }
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
/** /**
* @param Attachment $attachment * @param Attachment $attachment
* @param array $data * @param array $data

View File

@@ -15,6 +15,7 @@ namespace FireflyIII\Repositories\Attachment;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Models\Attachment; use FireflyIII\Models\Attachment;
use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -59,6 +60,11 @@ interface AttachmentRepositoryInterface
*/ */
public function getContent(Attachment $attachment): string; public function getContent(Attachment $attachment): string;
/**
* @param User $user
*/
public function setUser(User $user);
/** /**
* @param Attachment $attachment * @param Attachment $attachment
* @param array $attachmentData * @param array $attachmentData

View File

@@ -37,16 +37,6 @@ class BillRepository implements BillRepositoryInterface
/** @var User */ /** @var User */
private $user; private $user;
/**
* BillRepository constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/** /**
* @param Bill $bill * @param Bill $bill
* *
@@ -520,6 +510,14 @@ class BillRepository implements BillRepositoryInterface
} }
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
/** /**
* @param array $data * @param array $data
* *

View File

@@ -16,6 +16,7 @@ namespace FireflyIII\Repositories\Bill;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Models\Bill; use FireflyIII\Models\Bill;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -25,7 +26,6 @@ use Illuminate\Support\Collection;
*/ */
interface BillRepositoryInterface interface BillRepositoryInterface
{ {
/** /**
* @param Bill $bill * @param Bill $bill
* *
@@ -159,6 +159,11 @@ interface BillRepositoryInterface
*/ */
public function scan(Bill $bill, TransactionJournal $journal): bool; public function scan(Bill $bill, TransactionJournal $journal): bool;
/**
* @param User $user
*/
public function setUser(User $user);
/** /**
* @param array $data * @param array $data
* *

View File

@@ -38,16 +38,6 @@ class BudgetRepository implements BudgetRepositoryInterface
/** @var User */ /** @var User */
private $user; private $user;
/**
* BudgetRepository constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/** /**
* @return bool * @return bool
*/ */
@@ -433,6 +423,14 @@ class BudgetRepository implements BudgetRepositoryInterface
return true; return true;
} }
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
/** /**
* @param Collection $budgets * @param Collection $budgets
* @param Collection $accounts * @param Collection $accounts
@@ -444,7 +442,8 @@ class BudgetRepository implements BudgetRepositoryInterface
public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [$this->user]); $collector = app(JournalCollectorInterface::class);
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setBudgets($budgets); $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setBudgets($budgets);
if ($accounts->count() > 0) { if ($accounts->count() > 0) {
@@ -470,7 +469,8 @@ class BudgetRepository implements BudgetRepositoryInterface
public function spentInPeriodWoBudget(Collection $accounts, Carbon $start, Carbon $end): string public function spentInPeriodWoBudget(Collection $accounts, Carbon $start, Carbon $end): string
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [$this->user]); $collector = app(JournalCollectorInterface::class);
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->withoutBudget(); $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->withoutBudget();
if ($accounts->count() > 0) { if ($accounts->count() > 0) {

View File

@@ -17,6 +17,7 @@ use Carbon\Carbon;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -26,7 +27,6 @@ use Illuminate\Support\Collection;
*/ */
interface BudgetRepositoryInterface interface BudgetRepositoryInterface
{ {
/** /**
* @return bool * @return bool
*/ */
@@ -149,6 +149,11 @@ interface BudgetRepositoryInterface
*/ */
public function setAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end, string $amount): bool; public function setAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end, string $amount): bool;
/**
* @param User $user
*/
public function setUser(User $user);
/** /**
* @param Collection $budgets * @param Collection $budgets
* @param Collection $accounts * @param Collection $accounts

View File

@@ -34,16 +34,6 @@ class CategoryRepository implements CategoryRepositoryInterface
/** @var User */ /** @var User */
private $user; private $user;
/**
* CategoryRepository constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/** /**
* @param Category $category * @param Category $category
* *
@@ -67,7 +57,8 @@ class CategoryRepository implements CategoryRepositoryInterface
public function earnedInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string public function earnedInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [$this->user]); $collector = app(JournalCollectorInterface::class);
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAccounts($accounts)->setCategories($categories); $collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAccounts($accounts)->setCategories($categories);
$set = $collector->getJournals(); $set = $collector->getJournals();
$sum = strval($set->sum('transaction_amount')); $sum = strval($set->sum('transaction_amount'));
@@ -384,6 +375,14 @@ class CategoryRepository implements CategoryRepositoryInterface
return $result; return $result;
} }
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
/** /**
* @param Collection $categories * @param Collection $categories
* @param Collection $accounts * @param Collection $accounts
@@ -395,7 +394,8 @@ class CategoryRepository implements CategoryRepositoryInterface
public function spentInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string public function spentInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [$this->user]); $collector = app(JournalCollectorInterface::class);
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setCategories($categories); $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setCategories($categories);
@@ -423,7 +423,8 @@ class CategoryRepository implements CategoryRepositoryInterface
public function spentInPeriodWithoutCategory(Collection $accounts, Carbon $start, Carbon $end): string public function spentInPeriodWithoutCategory(Collection $accounts, Carbon $start, Carbon $end): string
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [$this->user]); $collector = app(JournalCollectorInterface::class);
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->withoutCategory(); $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->withoutCategory();
if ($accounts->count() > 0) { if ($accounts->count() > 0) {

View File

@@ -15,6 +15,7 @@ namespace FireflyIII\Repositories\Category;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -121,6 +122,11 @@ interface CategoryRepositoryInterface
*/ */
public function periodIncomeNoCategory(Collection $accounts, Carbon $start, Carbon $end): array; public function periodIncomeNoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
/**
* @param User $user
*/
public function setUser(User $user);
/** /**
* @param Collection $categories * @param Collection $categories
* @param Collection $accounts * @param Collection $accounts

View File

@@ -31,11 +31,9 @@ class CurrencyRepository implements CurrencyRepositoryInterface
private $user; private $user;
/** /**
* CategoryRepository constructor.
*
* @param User $user * @param User $user
*/ */
public function __construct(User $user) public function setUser(User $user)
{ {
$this->user = $user; $this->user = $user;
} }

View File

@@ -16,6 +16,7 @@ namespace FireflyIII\Repositories\Currency;
use FireflyIII\Models\Preference; use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -94,6 +95,11 @@ interface CurrencyRepositoryInterface
*/ */
public function getCurrencyByPreference(Preference $preference): TransactionCurrency; public function getCurrencyByPreference(Preference $preference): TransactionCurrency;
/**
* @param User $user
*/
public function setUser(User $user);
/** /**
* @param array $data * @param array $data
* *

View File

@@ -29,16 +29,6 @@ class ExportJobRepository implements ExportJobRepositoryInterface
/** @var User */ /** @var User */
private $user; private $user;
/**
* ExportJobRepository constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/** /**
* @param ExportJob $job * @param ExportJob $job
* @param string $status * @param string $status
@@ -149,4 +139,12 @@ class ExportJobRepository implements ExportJobRepositoryInterface
return $content; return $content;
} }
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
} }

View File

@@ -14,6 +14,7 @@ declare(strict_types = 1);
namespace FireflyIII\Repositories\ExportJob; namespace FireflyIII\Repositories\ExportJob;
use FireflyIII\Models\ExportJob; use FireflyIII\Models\ExportJob;
use FireflyIII\User;
/** /**
* Interface ExportJobRepositoryInterface * Interface ExportJobRepositoryInterface
@@ -61,4 +62,9 @@ interface ExportJobRepositoryInterface
*/ */
public function getContent(ExportJob $job): string; public function getContent(ExportJob $job): string;
/**
* @param User $user
*/
public function setUser(User $user);
} }

View File

@@ -28,16 +28,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
/** @var User */ /** @var User */
private $user; private $user;
/**
* ExportJobRepository constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/** /**
* @param string $fileType * @param string $fileType
* *
@@ -95,4 +85,12 @@ class ImportJobRepository implements ImportJobRepositoryInterface
return $result; return $result;
} }
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
} }

View File

@@ -14,6 +14,7 @@ declare(strict_types = 1);
namespace FireflyIII\Repositories\ImportJob; namespace FireflyIII\Repositories\ImportJob;
use FireflyIII\Models\ImportJob; use FireflyIII\Models\ImportJob;
use FireflyIII\User;
/** /**
* Interface ImportJobRepositoryInterface * Interface ImportJobRepositoryInterface
@@ -35,4 +36,9 @@ interface ImportJobRepositoryInterface
* @return ImportJob * @return ImportJob
*/ */
public function findByKey(string $key): ImportJob; public function findByKey(string $key): ImportJob;
/**
* @param User $user
*/
public function setUser(User $user);
} }

View File

@@ -44,11 +44,9 @@ class JournalRepository implements JournalRepositoryInterface
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'];
/** /**
* JournalRepository constructor.
*
* @param User $user * @param User $user
*/ */
public function __construct(User $user) public function setUser(User $user)
{ {
$this->user = $user; $this->user = $user;
} }

View File

@@ -16,6 +16,7 @@ namespace FireflyIII\Repositories\Journal;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
@@ -26,7 +27,6 @@ use Illuminate\Support\MessageBag;
*/ */
interface JournalRepositoryInterface interface JournalRepositoryInterface
{ {
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param TransactionType $type * @param TransactionType $type
@@ -37,11 +37,6 @@ interface JournalRepositoryInterface
*/ */
public function convert(TransactionJournal $journal, TransactionType $type, Account $source, Account $destination): MessageBag; public function convert(TransactionJournal $journal, TransactionType $type, Account $source, Account $destination): MessageBag;
/**
* @return Collection
*/
public function getTransactionTypes(): Collection;
/** /**
* Deletes a journal. * Deletes a journal.
* *
@@ -67,6 +62,15 @@ interface JournalRepositoryInterface
*/ */
public function first(): TransactionJournal; public function first(): TransactionJournal;
/**
* @return Collection
*/
public function getTransactionTypes(): Collection;
/**
* @param User $user
*/
public function setUser(User $user);
/** /**
* @param array $data * @param array $data

View File

@@ -35,15 +35,6 @@ class JournalTasker implements JournalTaskerInterface
/** @var User */ /** @var User */
private $user; private $user;
/**
* JournalRepository constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
@@ -152,6 +143,14 @@ class JournalTasker implements JournalTaskerInterface
return $transactions; return $transactions;
} }
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
/** /**
* Collect the balance of an account before the given transaction has hit. This is tricky, because * Collect the balance of an account before the given transaction has hit. This is tricky, because
* the balance does not depend on the transaction itself but the journal it's part of. And of course * the balance does not depend on the transaction itself but the journal it's part of. And of course

View File

@@ -15,6 +15,7 @@ namespace FireflyIII\Repositories\Journal;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -24,7 +25,6 @@ use Illuminate\Support\Collection;
*/ */
interface JournalTaskerInterface interface JournalTaskerInterface
{ {
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *
@@ -41,4 +41,9 @@ interface JournalTaskerInterface
* @return array * @return array
*/ */
public function getTransactionsOverview(TransactionJournal $journal): array; public function getTransactionsOverview(TransactionJournal $journal): array;
/**
* @param User $user
*/
public function setUser(User $user);
} }

View File

@@ -32,16 +32,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
/** @var User */ /** @var User */
private $user; private $user;
/**
* PiggyBankRepository constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/** /**
* @param PiggyBank $piggyBank * @param PiggyBank $piggyBank
* @param string $amount * @param string $amount
@@ -167,6 +157,14 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return true; return true;
} }
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
/** /**
* @param array $data * @param array $data
* *

View File

@@ -15,6 +15,7 @@ namespace FireflyIII\Repositories\PiggyBank;
use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent; use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -98,6 +99,10 @@ interface PiggyBankRepositoryInterface
*/ */
public function setOrder(int $piggyBankId, int $order): bool; public function setOrder(int $piggyBankId, int $order): bool;
/**
* @param User $user
*/
public function setUser(User $user);
/** /**
* Store new piggy bank. * Store new piggy bank.

View File

@@ -30,16 +30,6 @@ class RuleRepository implements RuleRepositoryInterface
/** @var User */ /** @var User */
private $user; private $user;
/**
* BillRepository constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/** /**
* @return int * @return int
*/ */
@@ -218,6 +208,14 @@ class RuleRepository implements RuleRepositoryInterface
} }
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
/** /**
* @param array $data * @param array $data
* *

View File

@@ -17,6 +17,7 @@ use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleAction; use FireflyIII\Models\RuleAction;
use FireflyIII\Models\RuleGroup; use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\RuleTrigger; use FireflyIII\Models\RuleTrigger;
use FireflyIII\User;
/** /**
* Interface RuleRepositoryInterface * Interface RuleRepositoryInterface
@@ -25,7 +26,6 @@ use FireflyIII\Models\RuleTrigger;
*/ */
interface RuleRepositoryInterface interface RuleRepositoryInterface
{ {
/** /**
* @return int * @return int
*/ */
@@ -94,6 +94,11 @@ interface RuleRepositoryInterface
*/ */
public function resetRulesInGroupOrder(RuleGroup $ruleGroup): bool; public function resetRulesInGroupOrder(RuleGroup $ruleGroup): bool;
/**
* @param User $user
*/
public function setUser(User $user);
/** /**
* @param array $data * @param array $data
* *

View File

@@ -31,11 +31,9 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
private $user; private $user;
/** /**
* BillRepository constructor.
*
* @param User $user * @param User $user
*/ */
public function __construct(User $user) public function setUser(User $user)
{ {
$this->user = $user; $this->user = $user;
} }

View File

@@ -26,7 +26,6 @@ use Illuminate\Support\Collection;
interface RuleGroupRepositoryInterface interface RuleGroupRepositoryInterface
{ {
/** /**
* *
* *
@@ -92,6 +91,11 @@ interface RuleGroupRepositoryInterface
*/ */
public function resetRulesInGroupOrder(RuleGroup $ruleGroup): bool; public function resetRulesInGroupOrder(RuleGroup $ruleGroup): bool;
/**
* @param User $user
*/
public function setUser(User $user);
/** /**
* @param array $data * @param array $data
* *

View File

@@ -35,11 +35,9 @@ class TagRepository implements TagRepositoryInterface
private $user; private $user;
/** /**
* TagRepository constructor.
*
* @param User $user * @param User $user
*/ */
public function __construct(User $user) public function setUser(User $user)
{ {
$this->user = $user; $this->user = $user;
} }
@@ -396,7 +394,8 @@ class TagRepository implements TagRepositoryInterface
public function earnedInPeriod(Tag $tag, Carbon $start, Carbon $end): string public function earnedInPeriod(Tag $tag, Carbon $start, Carbon $end): string
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [$this->user]); $collector = app(JournalCollectorInterface::class);
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAllAssetAccounts()->setTag($tag); $collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAllAssetAccounts()->setTag($tag);
$set = $collector->getJournals(); $set = $collector->getJournals();
$sum = strval($set->sum('transaction_amount')); $sum = strval($set->sum('transaction_amount'));
@@ -414,7 +413,8 @@ class TagRepository implements TagRepositoryInterface
public function spentInPeriod(Tag $tag, Carbon $start, Carbon $end): string public function spentInPeriod(Tag $tag, Carbon $start, Carbon $end): string
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [$this->user]); $collector = app(JournalCollectorInterface::class);
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setAllAssetAccounts()->setTag($tag); $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setAllAssetAccounts()->setTag($tag);
$set = $collector->getJournals(); $set = $collector->getJournals();
$sum = strval($set->sum('transaction_amount')); $sum = strval($set->sum('transaction_amount'));

View File

@@ -16,6 +16,7 @@ namespace FireflyIII\Repositories\Tag;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@@ -89,6 +90,11 @@ interface TagRepositoryInterface
*/ */
public function lastUseDate(Tag $tag): Carbon; public function lastUseDate(Tag $tag): Carbon;
/**
* @param User $user
*/
public function setUser(User $user);
/** /**
* @param Tag $tag * @param Tag $tag
* @param Carbon $start * @param Carbon $start

Some files were not shown because too many files have changed in this diff Show More