Remove unused methods.

This commit is contained in:
James Cole 2018-07-22 21:09:57 +02:00
parent a616e06f9d
commit 67ea825d4a
26 changed files with 13 additions and 929 deletions

View File

@ -28,7 +28,6 @@ use FireflyIII\Events\UpdatedTransactionJournal;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\JournalFormRequest;
use FireflyIII\Models\Note;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
@ -124,15 +123,9 @@ class SingleController extends Controller
'payment_date' => $this->repository->getMetaField($journal, 'payment_date'),
'invoice_date' => $this->repository->getMetaField($journal, 'invoice_date'),
'internal_reference' => $this->repository->getMetaField($journal, 'internal_reference'),
'notes' => '',
'notes' => $this->repository->getNoteText($journal),
];
/** @var Note $note */
$note = $this->repository->getNote($journal);
if (null !== $note) {
$preFilled['notes'] = $note->text;
}
session()->flash('preFilled', $preFilled);
return redirect(route('transactions.create', [strtolower($journal->transactionType->type)]));

View File

@ -108,7 +108,7 @@ class RuleFormRequest extends Request
$contextActions = implode(',', config('firefly.rule-actions-text'));
$titleRule = 'required|between:1,100|uniqueObjectForUser:rules,title';
if (null !== $repository->find((int)$this->get('id'))->id) {
if (null !== $repository->find((int)$this->get('id'))) {
$titleRule = 'required|between:1,100|uniqueObjectForUser:rules,title,' . (int)$this->get('id');
}
$rules = [

View File

@ -64,7 +64,7 @@ class RuleGroupFormRequest extends Request
/** @var RuleGroupRepositoryInterface $repository */
$repository = app(RuleGroupRepositoryInterface::class);
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title';
if (null !== $repository->find((int)$this->get('id'))->id) {
if (null !== $repository->find((int)$this->get('id'))) {
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,' . (int)$this->get('id');
}

View File

@ -42,8 +42,6 @@ use FireflyIII\Helpers\Report\PopupReport;
use FireflyIII\Helpers\Report\PopupReportInterface;
use FireflyIII\Helpers\Report\ReportHelper;
use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Repositories\TransactionType\TransactionTypeRepository;
use FireflyIII\Repositories\TransactionType\TransactionTypeRepositoryInterface;
use FireflyIII\Repositories\User\UserRepository;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Services\Currency\ExchangeRateInterface;
@ -174,7 +172,6 @@ class FireflyServiceProvider extends ServiceProvider
// export:
$this->app->bind(ProcessorInterface::class, ExpandedProcessor::class);
$this->app->bind(UserRepositoryInterface::class, UserRepository::class);
$this->app->bind(TransactionTypeRepositoryInterface::class, TransactionTypeRepository::class);
$this->app->bind(AttachmentHelperInterface::class, AttachmentHelper::class);
// more generators:

View File

@ -161,20 +161,6 @@ class BudgetRepository implements BudgetRepositoryInterface
return $return;
}
/**
* Deletes a budget limit.
*
* @param BudgetLimit $budgetLimit
*/
public function deleteBudgetLimit(BudgetLimit $budgetLimit): void
{
try {
$budgetLimit->delete();
} catch (Exception $e) {
Log::error(sprintf('Could not delete budget limit: %s', $e->getMessage()));
}
}
/**
* @param Budget $budget
*
@ -217,57 +203,6 @@ class BudgetRepository implements BudgetRepositoryInterface
}
}
/**
* Filters entries from the result set generated by getBudgetPeriodReport.
*
* @param Collection $set
* @param int $budgetId
* @param array $periods
*
* @return array
*/
public function filterAmounts(Collection $set, int $budgetId, array $periods): array
{
$arr = [];
$keys = array_keys($periods);
foreach ($keys as $period) {
/** @var stdClass $object */
$result = $set->filter(
function (TransactionJournal $object) use ($budgetId, $period) {
$result = (string)$object->period_marker === (string)$period && $budgetId === (int)$object->budget_id;
return $result;
}
);
$amount = '0';
if (null !== $result->first()) {
$amount = $result->first()->sum_of_period;
}
$arr[$period] = $amount;
}
return $arr;
}
/**
* Find a budget.
*
* @param int $budgetId
*
* @return Budget
* @deprecated
*/
public function find(int $budgetId): Budget
{
$budget = $this->user->budgets()->find($budgetId);
if (null === $budget) {
$budget = new Budget;
}
return $budget;
}
/**
* Find a budget.
*

View File

@ -62,13 +62,6 @@ interface BudgetRepositoryInterface
*/
public function collectBudgetInformation(Collection $budgets, Carbon $start, Carbon $end): array;
/**
* Deletes a budget limit.
*
* @param BudgetLimit $budgetLimit
*/
public function deleteBudgetLimit(BudgetLimit $budgetLimit): void;
/**
* @param Budget $budget
*
@ -88,28 +81,6 @@ interface BudgetRepositoryInterface
*/
public function destroyBudgetLimit(BudgetLimit $budgetLimit): void;
/**
* Filters entries from the result set generated by getBudgetPeriodReport.
*
* @param Collection $set
* @param int $budgetId
* @param array $periods
*
* @return array
*/
public function filterAmounts(Collection $set, int $budgetId, array $periods): array;
/**
* Find a budget.
*
* @param int $budgetId
*
* @deprecated
*
* @return Budget
*/
public function find(int $budgetId): Budget;
/**
* Find a budget.
*

View File

@ -79,24 +79,6 @@ class CategoryRepository implements CategoryRepositoryInterface
return (string)$set->sum('transaction_amount');
}
/**
* Find a category.
*
* @param int $categoryId
*
* @return Category
* @deprecated
*/
public function find(int $categoryId): Category
{
$category = $this->user->categories()->find($categoryId);
if (null === $category) {
$category = new Category;
}
return $category;
}
/**
* Find a category.
*

View File

@ -51,16 +51,6 @@ interface CategoryRepositoryInterface
*/
public function earnedInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string;
/**
* Find a category.
*
* @param int $categoryId
*
* @deprecated
* @return Category
*/
public function find(int $categoryId): Category;
/**
* Find a category.
*

View File

@ -107,44 +107,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface
return true;
}
/**
* Find by ID.
*
* @param int $currencyId
*
* @deprecated
*
* @return TransactionCurrency
*/
public function find(int $currencyId): TransactionCurrency
{
$currency = TransactionCurrency::find($currencyId);
if (null === $currency) {
$currency = new TransactionCurrency;
}
return $currency;
}
/**
* Find by currency code.
*
* @deprecated
*
* @param string $currencyCode
*
* @return TransactionCurrency
*/
public function findByCode(string $currencyCode): TransactionCurrency
{
$currency = TransactionCurrency::where('code', $currencyCode)->first();
if (null === $currency) {
$currency = new TransactionCurrency;
}
return $currency;
}
/**
* Find by currency code, return NULL if unfound.
* Used in Import Currency!
@ -158,25 +120,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface
return TransactionCurrency::where('code', $currencyCode)->first();
}
/**
* Find by currency name.
*
* @param string $currencyName
*
* @deprecated
*
* @return TransactionCurrency
*/
public function findByName(string $currencyName): TransactionCurrency
{
$preferred = TransactionCurrency::whereName($currencyName)->first();
if (null === $preferred) {
$preferred = new TransactionCurrency;
}
return $preferred;
}
/**
* Find by currency name or return null.
* Used in Import Currency!
@ -190,25 +133,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface
return TransactionCurrency::whereName($currencyName)->first();
}
/**
* Find by currency symbol.
*
* @deprecated
*
* @param string $currencySymbol
*
* @return TransactionCurrency
*/
public function findBySymbol(string $currencySymbol): TransactionCurrency
{
$currency = TransactionCurrency::whereSymbol($currencySymbol)->first();
if (null === $currency) {
$currency = new TransactionCurrency;
}
return $currency;
}
/**
* Find by currency symbol or return NULL
* Used in Import Currency!

View File

@ -55,27 +55,6 @@ interface CurrencyRepositoryInterface
*/
public function destroy(TransactionCurrency $currency): bool;
/**
* Find by ID.
*
* @param int $currencyId
*
* @deprecated
* @return TransactionCurrency
*/
public function find(int $currencyId): TransactionCurrency;
/**
* Find by currency code.
*
* @deprecated
*
* @param string $currencyCode
*
* @return TransactionCurrency
*/
public function findByCode(string $currencyCode): TransactionCurrency;
/**
* Find by currency code, return NULL if unfound.
*
@ -85,17 +64,6 @@ interface CurrencyRepositoryInterface
*/
public function findByCodeNull(string $currencyCode): ?TransactionCurrency;
/**
* Find by currency name.
*
* @deprecated
*
* @param string $currencyName
*
* @return TransactionCurrency
*/
public function findByName(string $currencyName): TransactionCurrency;
/**
* Find by currency name.
*
@ -105,17 +73,6 @@ interface CurrencyRepositoryInterface
*/
public function findByNameNull(string $currencyName): ?TransactionCurrency;
/**
* Find by currency symbol.
*
* @deprecated
*
* @param string $currencySymbol
*
* @return TransactionCurrency
*/
public function findBySymbol(string $currencySymbol): TransactionCurrency;
/**
* Find by currency symbol.
*

View File

@ -56,21 +56,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
$this->uploadDisk = Storage::disk('upload');
}
/**
* @param ImportJob $job
* @param int $index
* @param string $error
*
* @return ImportJob
*/
public function addError(ImportJob $job, int $index, string $error): ImportJob
{
$extended = $this->getExtendedStatus($job);
$extended['errors'][$index][] = $error;
return $this->setExtendedStatus($job, $extended);
}
/**
* Add message to job.
*
@ -89,58 +74,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
return $job;
}
/**
* @param ImportJob $job
* @param int $steps
*
* @return ImportJob
*/
public function addStepsDone(ImportJob $job, int $steps = null): ImportJob
{
$steps = $steps ?? 1;
$status = $this->getExtendedStatus($job);
$status['done'] += $steps;
Log::debug(sprintf('Add %d to steps done for job "%s" making steps done %d', $steps, $job->key, $status['done']));
return $this->setExtendedStatus($job, $status);
}
/**
* @param ImportJob $job
* @param int $steps
*
* @return ImportJob
*/
public function addTotalSteps(ImportJob $job, int $steps = null): ImportJob
{
$steps = $steps ?? 1;
$extended = $this->getExtendedStatus($job);
$total = (int)($extended['steps'] ?? 0);
$total += $steps;
$extended['steps'] = $total;
return $this->setExtendedStatus($job, $extended);
}
/**
* Return number of imported rows with this hash value.
*
* @param string $hash
*
* @return int
*/
public function countByHash(string $hash): int
{
$json = json_encode($hash);
$count = TransactionJournalMeta::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
->where('data', $json)
->where('name', 'importHash')
->count();
return $count;
}
/**
* @param string $importProvider
*
@ -243,111 +176,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
return [];
}
/**
* @param ImportJob $job
*
* @return string
*/
public function getStatus(ImportJob $job): string
{
return $job->status;
}
/**
* @param ImportJob $job
* @param UploadedFile $file
*
* @return bool
*/
public function processConfiguration(ImportJob $job, UploadedFile $file): bool
{
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
// demo user's configuration upload is ignored completely.
if (!$repository->hasRole($this->user, 'demo')) {
Log::debug(
'Uploaded configuration file',
['name' => $file->getClientOriginalName(), 'size' => $file->getSize(), 'mime' => $file->getClientMimeType()]
);
$configFileObject = new SplFileObject($file->getRealPath());
$configRaw = $configFileObject->fread($configFileObject->getSize());
$configuration = json_decode($configRaw, true);
Log::debug(sprintf('Raw configuration is %s', $configRaw));
if (null !== $configuration && \is_array($configuration)) {
Log::debug('Found configuration', $configuration);
$this->setConfiguration($job, $configuration);
}
if (null === $configuration) {
Log::error('Uploaded configuration is NULL');
}
if (false === $configuration) {
Log::error('Uploaded configuration is FALSE');
}
}
return true;
}
/**
* @param ImportJob $job
* @param null|UploadedFile $file
*
* @return bool
*
* @throws \Illuminate\Contracts\Encryption\EncryptException
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function processFile(ImportJob $job, ?UploadedFile $file): bool
{
if (null === $file) {
return false;
}
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
$newName = sprintf('%s.upload', $job->key);
$uploaded = new SplFileObject($file->getRealPath());
$content = trim($uploaded->fread($uploaded->getSize()));
// verify content:
$result = mb_detect_encoding($content, 'UTF-8', true);
if (false === $result) {
Log::error(sprintf('Cannot detect encoding for uploaded import file "%s".', $file->getClientOriginalName()));
return false;
}
if ('ASCII' !== $result && 'UTF-8' !== $result) {
Log::error(sprintf('Uploaded import file is %s instead of UTF8!', var_export($result, true)));
return false;
}
$contentEncrypted = Crypt::encrypt($content);
$disk = Storage::disk('upload');
// user is demo user, replace upload with prepared file.
if ($repository->hasRole($this->user, 'demo')) {
$stubsDisk = Storage::disk('stubs');
$content = $stubsDisk->get('demo-import.csv');
$contentEncrypted = Crypt::encrypt($content);
$disk->put($newName, $contentEncrypted);
Log::debug('Replaced upload with demo file.');
// also set up prepared configuration.
$configuration = json_decode($stubsDisk->get('demo-configuration.json'), true);
$this->setConfiguration($job, $configuration);
Log::debug('Set configuration for demo user', $configuration);
}
if (!$repository->hasRole($this->user, 'demo')) {
// user is not demo, process original upload:
$disk->put($newName, $contentEncrypted);
Log::debug('Uploaded file', ['name' => $file->getClientOriginalName(), 'size' => $file->getSize(), 'mime' => $file->getClientMimeType()]);
}
return true;
}
/**
* @param ImportJob $job
* @param array $configuration
@ -368,22 +196,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
return $job;
}
/**
* @param ImportJob $job
* @param array $array
*
* @return ImportJob
*/
public function setExtendedStatus(ImportJob $job, array $array): ImportJob
{
$currentStatus = $job->extended_status;
$newStatus = array_merge($currentStatus, $array);
$job->extended_status = $newStatus;
$job->save();
return $job;
}
/**
* @param ImportJob $job
* @param string $stage
@ -413,21 +225,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
return $job;
}
/**
* @param ImportJob $job
* @param int $steps
*
* @return ImportJob
*/
public function setStepsDone(ImportJob $job, int $steps): ImportJob
{
$status = $this->getExtendedStatus($job);
$status['done'] = $steps;
Log::debug(sprintf('Set steps done for job "%s" to %d', $job->key, $steps));
return $this->setExtendedStatus($job, $status);
}
/**
* @param ImportJob $job
* @param Tag $tag
@ -442,21 +239,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
return $job;
}
/**
* @param ImportJob $job
* @param int $count
*
* @return ImportJob
*/
public function setTotalSteps(ImportJob $job, int $count): ImportJob
{
$status = $this->getExtendedStatus($job);
$status['steps'] = $count;
Log::debug(sprintf('Set total steps for job "%s" to %d', $job->key, $count));
return $this->setExtendedStatus($job, $status);
}
/**
* @param ImportJob $job
* @param array $transactions
@ -599,20 +381,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
return $job;
}
/**
* Return import file content.
*
* @deprecated
*
* @param ImportJob $job
*
* @return string
*/
public function uploadFileContents(ImportJob $job): string
{
return $job->uploadFileContents();
}
/**
* @codeCoverageIgnore
*

View File

@ -35,15 +35,6 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
*/
interface ImportJobRepositoryInterface
{
/**
* @param ImportJob $job
* @param int $index
* @param string $error
*
* @return ImportJob
*/
public function addError(ImportJob $job, int $index, string $error): ImportJob;
/**
* Add message to job.
*
@ -54,31 +45,6 @@ interface ImportJobRepositoryInterface
*/
public function addErrorMessage(ImportJob $job, string $error): ImportJob;
/**
* @param ImportJob $job
* @param int $steps
*
* @return ImportJob
*/
public function addStepsDone(ImportJob $job, int $steps = null): ImportJob;
/**
* @param ImportJob $job
* @param int $steps
*
* @return ImportJob
*/
public function addTotalSteps(ImportJob $job, int $steps = null): ImportJob;
/**
* Return number of imported rows with this hash value.
*
* @param string $hash
*
* @return int
*/
public function countByHash(string $hash): int;
/**
* @param string $importProvider
*
@ -120,29 +86,6 @@ interface ImportJobRepositoryInterface
*/
public function getExtendedStatus(ImportJob $job): array;
/**
* @param ImportJob $job
*
* @return string
*/
public function getStatus(ImportJob $job): string;
/**
* @param ImportJob $job
* @param UploadedFile $file
*
* @return bool
*/
public function processConfiguration(ImportJob $job, UploadedFile $file): bool;
/**
* @param ImportJob $job
* @param null|UploadedFile $file
*
* @return bool
*/
public function processFile(ImportJob $job, ?UploadedFile $file): bool;
/**
* @param ImportJob $job
* @param array $configuration
@ -151,14 +94,6 @@ interface ImportJobRepositoryInterface
*/
public function setConfiguration(ImportJob $job, array $configuration): ImportJob;
/**
* @param ImportJob $job
* @param array $array
*
* @return ImportJob
*/
public function setExtendedStatus(ImportJob $job, array $array): ImportJob;
/**
* @param ImportJob $job
* @param string $stage
@ -175,14 +110,6 @@ interface ImportJobRepositoryInterface
*/
public function setStatus(ImportJob $job, string $status): ImportJob;
/**
* @param ImportJob $job
* @param int $steps
*
* @return ImportJob
*/
public function setStepsDone(ImportJob $job, int $steps): ImportJob;
/**
* @param ImportJob $job
* @param Tag $tag
@ -191,14 +118,6 @@ interface ImportJobRepositoryInterface
*/
public function setTag(ImportJob $job, Tag $tag): ImportJob;
/**
* @param ImportJob $job
* @param int $count
*
* @return ImportJob
*/
public function setTotalSteps(ImportJob $job, int $count): ImportJob;
/**
* @param ImportJob $job
* @param array $transactions
@ -243,12 +162,4 @@ interface ImportJobRepositoryInterface
*/
public function updateStatus(ImportJob $job, string $status): ImportJob;
/**
* Return import file content.
*
* @param ImportJob $job
*
* @return string
*/
public function uploadFileContents(ImportJob $job): string;
}

View File

@ -138,23 +138,6 @@ class JournalRepository implements JournalRepositoryInterface
return true;
}
/**
* @param int $journalId
*
* @return TransactionJournal
* @deprecated
*/
public function find(int $journalId): TransactionJournal
{
/** @var TransactionJournal $journal */
$journal = $this->user->transactionJournals()->where('id', $journalId)->first();
if (null === $journal) {
return new TransactionJournal;
}
return $journal;
}
/**
* Find a journal by its hash.
*
@ -225,24 +208,6 @@ class JournalRepository implements JournalRepositoryInterface
return $transaction;
}
/**
* Get users first transaction journal.
*
* @deprecated
* @return TransactionJournal
*/
public function first(): TransactionJournal
{
/** @var TransactionJournal $entry */
$entry = $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']);
if (null === $entry) {
return new TransactionJournal;
}
return $entry;
}
/**
* Get users first transaction journal or NULL.
*
@ -522,16 +487,6 @@ class JournalRepository implements JournalRepositoryInterface
return $return;
}
/**
* @param TransactionJournal $journal
*
* @return Note|null
*/
public function getNote(TransactionJournal $journal): ?Note
{
return $journal->notes()->first();
}
/**
* Return text of a note attached to journal, or NULL
*
@ -698,27 +653,6 @@ class JournalRepository implements JournalRepositoryInterface
}
/**
* Set meta field for journal that contains string.
*
* @param TransactionJournal $journal
* @param string $name
* @param string $value
*/
public function setMetaString(TransactionJournal $journal, string $name, string $value): void
{
/** @var TransactionJournalMetaFactory $factory */
$factory = app(TransactionJournalMetaFactory::class);
$factory->updateOrCreate(
[
'data' => $value,
'journal' => $journal,
'name' => $name,
]
);
}
/**
* @param TransactionJournal $journal
* @param int $order

View File

@ -66,17 +66,6 @@ interface JournalRepositoryInterface
*/
public function destroy(TransactionJournal $journal): bool;
/**
* Find a specific journal.
*
* @param int $journalId
*
* @deprecated
*
* @return TransactionJournal
*/
public function find(int $journalId): TransactionJournal;
/**
* Find a journal by its hash.
*
@ -109,14 +98,6 @@ interface JournalRepositoryInterface
*/
public function findTransaction(int $transactionid): ?Transaction;
/**
* Get users very first transaction journal.
*
* @deprecated
* @return TransactionJournal
*/
public function first(): TransactionJournal;
/**
* Get users very first transaction journal.
*
@ -216,13 +197,6 @@ interface JournalRepositoryInterface
*/
public function getMetaField(TransactionJournal $journal, string $field): ?string;
/**
* @param TransactionJournal $journal
*
* @return Note|null
*/
public function getNote(TransactionJournal $journal): ?Note;
/**
* Return text of a note attached to journal, or NULL
*
@ -303,15 +277,6 @@ interface JournalRepositoryInterface
*/
public function setMetaDate(TransactionJournal $journal, string $name, Carbon $date): void;
/**
* Set meta field for journal that contains string.
*
* @param TransactionJournal $journal
* @param string $name
* @param string $value
*/
public function setMetaString(TransactionJournal $journal, string $name, string $value): void;
/**
* @param TransactionJournal $journal
* @param int $order

View File

@ -80,22 +80,6 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
return true;
}
/**
* @param int $id
*
* @return LinkType
* @deprecated
*/
public function find(int $id): LinkType
{
$linkType = LinkType::find($id);
if (null === $linkType) {
return new LinkType;
}
return $linkType;
}
/**
* @param string|null $name
*

View File

@ -55,14 +55,6 @@ interface LinkTypeRepositoryInterface
*/
public function destroyLink(TransactionJournalLink $link): bool;
/**
* @param int $id
*
* @deprecated
* @return LinkType
*/
public function find(int $id): LinkType;
/**
* Find link type by name.
*

View File

@ -175,22 +175,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return true;
}
/**
* @param int $piggyBankid
*
* @deprecated
* @return PiggyBank
*/
public function find(int $piggyBankid): PiggyBank
{
$piggyBank = $this->user->piggyBanks()->where('piggy_banks.id', $piggyBankid)->first(['piggy_banks.*']);
if (null !== $piggyBank) {
return $piggyBank;
}
return new PiggyBank();
}
/**
* Find by name or return NULL.
*
@ -425,24 +409,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return true;
}
/**
* Set all piggy banks to order 0.
*
* @return bool
*/
public function reset(): bool
{
// split query to make it work in sqlite:
$set = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.id')
->where('accounts.user_id', $this->user->id)->get(['piggy_banks.*']);
foreach ($set as $e) {
$e->order = 0;
$e->save();
}
return true;
}
/**
* set id of piggy bank.
*

View File

@ -100,14 +100,6 @@ interface PiggyBankRepositoryInterface
*/
public function destroy(PiggyBank $piggyBank): bool;
/**
* @param int $piggyBankid
*
* @deprecated
* @return PiggyBank
*/
public function find(int $piggyBankid): PiggyBank;
/**
* Find by name or return NULL.
*
@ -208,13 +200,6 @@ interface PiggyBankRepositoryInterface
*/
public function removeAmount(PiggyBank $piggyBank, string $amount): bool;
/**
* Set all piggy banks to order 0.
*
* @return bool
*/
public function reset(): bool;
/**
* Set specific piggy bank to specific order.
*

View File

@ -68,13 +68,13 @@ class RuleRepository implements RuleRepositoryInterface
/**
* @param int $ruleId
*
* @return Rule
* @return Rule|null
*/
public function find(int $ruleId): Rule
public function find(int $ruleId): ?Rule
{
$rule = $this->user->rules()->find($ruleId);
if (null === $rule) {
return new Rule;
return null;
}
return $rule;

View File

@ -50,9 +50,9 @@ interface RuleRepositoryInterface
/**
* @param int $ruleId
*
* @return Rule
* @return Rule|null
*/
public function find(int $ruleId): Rule;
public function find(int $ruleId): ?Rule;
/**
* Get all the users rules.

View File

@ -77,13 +77,13 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
/**
* @param int $ruleGroupId
*
* @return RuleGroup
* @return RuleGroup|null
*/
public function find(int $ruleGroupId): RuleGroup
public function find(int $ruleGroupId): ?RuleGroup
{
$group = $this->user->ruleGroups()->find($ruleGroupId);
if (null === $group) {
return new RuleGroup;
return null;
}
return $group;

View File

@ -47,9 +47,9 @@ interface RuleGroupRepositoryInterface
/**
* @param int $ruleGroupId
*
* @return RuleGroup
* @return RuleGroup|null
*/
public function find(int $ruleGroupId): RuleGroup;
public function find(int $ruleGroupId): ?RuleGroup;
/**
* Get all rule groups.

View File

@ -42,27 +42,6 @@ class TagRepository implements TagRepositoryInterface
/** @var User */
private $user;
/**
* @param TransactionJournal $journal
* @param Tag $tag
*
* @return bool
*/
public function connect(TransactionJournal $journal, Tag $tag): bool
{
// Already connected:
if ($journal->tags()->find($tag->id)) {
Log::info(sprintf('Tag #%d is already connected to journal #%d.', $tag->id, $journal->id));
return false;
}
Log::debug(sprintf('Tag #%d connected', $tag->id));
$journal->tags()->save($tag);
$journal->save();
return true;
}
/**
* @return int
*/
@ -177,16 +156,6 @@ class TagRepository implements TagRepositoryInterface
return $tags;
}
/**
* @param string $type
*
* @return Collection
*/
public function getByType(string $type): Collection
{
return $this->user->tags()->where('tagMode', $type)->orderBy('date', 'ASC')->get();
}
/**
* @param Tag $tag
*
@ -267,32 +236,6 @@ class TagRepository implements TagRepositoryInterface
return $tag;
}
/**
* @param Tag $tag
* @param Carbon|null $start
* @param Carbon|null $end
*
* @return string
*/
public function sumOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): string
{
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
if (null !== $start && null !== $end) {
$collector->setRange($start, $end);
}
$collector->setAllAssetAccounts()->setTag($tag);
$journals = $collector->getJournals();
$sum = '0';
foreach ($journals as $journal) {
$sum = bcadd($sum, app('steam')->positive((string)$journal->transaction_amount));
}
return $sum;
}
/**
* @param Tag $tag
* @param Carbon|null $start

View File

@ -33,16 +33,6 @@ use Illuminate\Support\Collection;
*/
interface TagRepositoryInterface
{
/**
* This method will connect a journal with a tag.
*
* @param TransactionJournal $journal
* @param Tag $tag
*
* @return bool
*/
public function connect(TransactionJournal $journal, Tag $tag): bool;
/**
* @return int
*/
@ -102,13 +92,6 @@ interface TagRepositoryInterface
*/
public function get(): Collection;
/**
* @param string $type
*
* @return Collection
*/
public function getByType(string $type): Collection;
/**
* @param Tag $tag
*
@ -153,15 +136,6 @@ interface TagRepositoryInterface
*/
public function store(array $data): Tag;
/**
* @param Tag $tag
* @param Carbon|null $start
* @param Carbon|null $end
*
* @return string
*/
public function sumOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): string;
/**
* Calculates various amounts in tag.
*

View File

@ -1,44 +0,0 @@
<?php
/**
* TransactionTypeRepository.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Repositories\TransactionType;
use FireflyIII\Models\TransactionType;
/**
* Class TransactionTypeRepository
*/
class TransactionTypeRepository implements TransactionTypeRepositoryInterface
{
/**
* Find a transaction type or return NULL.
*
* @param string $type
*
* @return TransactionType|null
*/
public function findByType(string $type): ?TransactionType
{
return TransactionType::where('type', ucfirst($type))->first();
}
}

View File

@ -1,43 +0,0 @@
<?php
/**
* TransactionTypeRepositoryInterface.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Repositories\TransactionType;
use FireflyIII\Models\TransactionType;
/**
* Interface TransactionTypeRepositoryInterface
*
*/
interface TransactionTypeRepositoryInterface
{
/**
* Find a transaction type or return NULL.
*
* @param string $type
*
* @return TransactionType|null
*/
public function findByType(string $type): ?TransactionType;
}