mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various code cleanup.
This commit is contained in:
@@ -74,6 +74,7 @@ class BillController extends Controller
|
||||
public function destroy(Bill $bill)
|
||||
{
|
||||
$this->repository->destroy($bill);
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,8 +85,8 @@ class Import extends Command
|
||||
$monolog->pushHandler($handler);
|
||||
|
||||
// actually start job:
|
||||
$type = 'csv' === $job->file_type ? 'file' : $job->file_type;
|
||||
$key = sprintf('import.routine.%s', $type);
|
||||
$type = 'csv' === $job->file_type ? 'file' : $job->file_type;
|
||||
$key = sprintf('import.routine.%s', $type);
|
||||
$className = config($key);
|
||||
if (null === $className || !class_exists($className)) {
|
||||
throw new FireflyException(sprintf('Cannot find import routine class for job of type "%s".', $type)); // @codeCoverageIgnore
|
||||
|
||||
@@ -252,6 +252,7 @@ class JournalCollector implements JournalCollectorInterface
|
||||
$cache->addProperty($key);
|
||||
if ($cache->has()) {
|
||||
Log::debug(sprintf('Return cache of query with ID "%s".', $key));
|
||||
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
@@ -290,9 +290,6 @@ class AccountController extends Controller
|
||||
if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
|
||||
return $this->redirectToOriginalAccount($account);
|
||||
}
|
||||
if ($end < $start) {
|
||||
throw new FireflyException('End is after start!');
|
||||
}
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
if (null === $start) {
|
||||
$start = session('start');
|
||||
@@ -300,6 +297,9 @@ class AccountController extends Controller
|
||||
if (null === $end) {
|
||||
$end = app('navigation')->endOfPeriod($start, $range);
|
||||
}
|
||||
if ($end < $start) {
|
||||
throw new FireflyException('End is after start!');
|
||||
}
|
||||
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
||||
$page = intval($request->get('page'));
|
||||
|
||||
@@ -75,6 +75,7 @@ class ResetPasswordController extends Controller
|
||||
if (true === $singleUserMode && $userCount > 0) {
|
||||
$allowRegistration = false;
|
||||
}
|
||||
|
||||
return view('auth.passwords.reset')->with(
|
||||
['token' => $token, 'email' => $request->email, 'allowRegistration' => $allowRegistration]
|
||||
);
|
||||
|
||||
@@ -35,7 +35,6 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
@@ -142,7 +141,7 @@ class BulkController extends Controller
|
||||
$ignoreCategory = intval($request->get('ignore_category')) === 1;
|
||||
$ignoreBudget = intval($request->get('ignore_budget')) === 1;
|
||||
$ignoreTags = intval($request->get('ignore_tags')) === 1;
|
||||
$count = 0;
|
||||
$count = 0;
|
||||
if (is_array($journalIds)) {
|
||||
foreach ($journalIds as $journalId) {
|
||||
$journal = $repository->find(intval($journalId));
|
||||
|
||||
@@ -78,7 +78,7 @@ class LinkController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournalLink $link
|
||||
* @param TransactionJournalLink $link
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
@@ -93,8 +93,8 @@ class LinkController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param JournalLinkRequest $request
|
||||
* @param TransactionJournal $journal
|
||||
* @param JournalLinkRequest $request
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
@@ -123,7 +123,7 @@ class LinkController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournalLink $link
|
||||
* @param TransactionJournalLink $link
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace FireflyIII\Http\Controllers\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\MassDeleteJournalRequest;
|
||||
use FireflyIII\Http\Requests\MassEditJournalRequest;
|
||||
use FireflyIII\Http\Requests\MassEditBulkJournalRequest;
|
||||
use FireflyIII\Http\Requests\MassEditJournalRequest;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace FireflyIII\Http;
|
||||
|
||||
use FireflyIII\Http\Middleware\Authenticate;
|
||||
use FireflyIII\Http\Middleware\AuthenticateTwoFactor;
|
||||
use FireflyIII\Http\Middleware\EncryptCookies;
|
||||
use FireflyIII\Http\Middleware\Binder;
|
||||
use FireflyIII\Http\Middleware\EncryptCookies;
|
||||
use FireflyIII\Http\Middleware\IsAdmin;
|
||||
use FireflyIII\Http\Middleware\Range;
|
||||
use FireflyIII\Http\Middleware\RedirectIfAuthenticated;
|
||||
|
||||
@@ -40,6 +40,16 @@ class Request extends FormRequest
|
||||
return 1 === intval($this->input($field));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function integer(string $field): int
|
||||
{
|
||||
return intval($this->get($field));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
*
|
||||
@@ -137,14 +147,4 @@ class Request extends FormRequest
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function integer(string $field): int
|
||||
{
|
||||
return intval($this->get($field));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +263,7 @@ class FileConfigurator implements ConfiguratorInterface
|
||||
* Shorthand method to set the extended status.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param array $extended
|
||||
*/
|
||||
private function setExtendedStatus(array $extended): void
|
||||
|
||||
@@ -125,6 +125,7 @@ class CsvProcessor implements FileProcessorInterface
|
||||
* Shorthand method to set the extended status.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param array $array
|
||||
*/
|
||||
public function setExtendedStatus(array $array)
|
||||
|
||||
@@ -67,9 +67,10 @@ class FilePrerequisites implements PrerequisitesInterface
|
||||
*/
|
||||
public function hasPrerequisites(): bool
|
||||
{
|
||||
if($this->user->hasRole('demo')) {
|
||||
if ($this->user->hasRole('demo')) {
|
||||
throw new FireflyException('Apologies, the demo user cannot import files.');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,6 @@ class FileRoutine implements RoutineInterface
|
||||
Log::debug('Back in run()');
|
||||
|
||||
|
||||
|
||||
Log::debug('Updated job...');
|
||||
Log::debug(sprintf('%d journals in $storage->journals', $storage->journals->count()));
|
||||
$this->journals = $storage->journals;
|
||||
@@ -177,6 +176,16 @@ class FileRoutine implements RoutineInterface
|
||||
$this->repository->addStepsDone($this->job, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorthand
|
||||
*
|
||||
* @param int $steps
|
||||
*/
|
||||
private function addTotalSteps(int $steps)
|
||||
{
|
||||
$this->repository->addTotalSteps($this->job, $steps);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -194,7 +203,7 @@ class FileRoutine implements RoutineInterface
|
||||
/** @var TagRepositoryInterface $repository */
|
||||
$repository = app(TagRepositoryInterface::class);
|
||||
$repository->setUser($this->job->user);
|
||||
$data = [
|
||||
$data = [
|
||||
'tag' => trans('import.import_with_key', ['key' => $this->job->key]),
|
||||
'date' => new Carbon,
|
||||
'description' => null,
|
||||
@@ -203,7 +212,7 @@ class FileRoutine implements RoutineInterface
|
||||
'zoomLevel' => null,
|
||||
'tagMode' => 'nothing',
|
||||
];
|
||||
$tag = $repository->store($data);
|
||||
$tag = $repository->store($data);
|
||||
$this->addStep();
|
||||
$extended = $this->getExtendedStatus();
|
||||
$extended['tag'] = $tag->id;
|
||||
@@ -220,6 +229,7 @@ class FileRoutine implements RoutineInterface
|
||||
}
|
||||
Log::info(sprintf('Linked %d journals to tag #%d ("%s")', $this->journals->count(), $tag->id, $tag->tag));
|
||||
$this->addStep();
|
||||
|
||||
return $tag;
|
||||
}
|
||||
|
||||
@@ -281,16 +291,6 @@ class FileRoutine implements RoutineInterface
|
||||
$this->repository->setTotalSteps($this->job, $steps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorthand
|
||||
*
|
||||
* @param int $steps
|
||||
*/
|
||||
private function addTotalSteps(int $steps)
|
||||
{
|
||||
$this->repository->addTotalSteps($this->job, $steps);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $objects
|
||||
*
|
||||
|
||||
@@ -308,8 +308,8 @@ class ImportStorage
|
||||
return false;
|
||||
}
|
||||
|
||||
$amount = app('steam')->positive($parameters['amount']);
|
||||
$names = [$parameters['asset'], $parameters['opposing']];
|
||||
$amount = app('steam')->positive($parameters['amount']);
|
||||
$names = [$parameters['asset'], $parameters['opposing']];
|
||||
|
||||
sort($names);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use Illuminate\Contracts\Auth\Factory as Auth;
|
||||
|
||||
/**
|
||||
* Class Bill.
|
||||
*/
|
||||
|
||||
@@ -22,15 +22,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Trait UpdateJournalsTrait.
|
||||
|
||||
@@ -32,14 +32,6 @@ use Illuminate\Support\Collection;
|
||||
interface UserRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $displayName
|
||||
* @param string $description
|
||||
*
|
||||
* @return Role
|
||||
*/
|
||||
public function createRole(string $name, string $displayName, string $description): Role;
|
||||
/**
|
||||
* Returns a collection of all users.
|
||||
*
|
||||
@@ -47,13 +39,6 @@ interface UserRepositoryInterface
|
||||
*/
|
||||
public function all(): Collection;
|
||||
|
||||
/**
|
||||
* @param string $role
|
||||
*
|
||||
* @return Role|null
|
||||
*/
|
||||
public function getRole(string $role): ?Role;
|
||||
|
||||
/**
|
||||
* Gives a user a role.
|
||||
*
|
||||
@@ -101,6 +86,15 @@ interface UserRepositoryInterface
|
||||
*/
|
||||
public function count(): int;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $displayName
|
||||
* @param string $description
|
||||
*
|
||||
* @return Role
|
||||
*/
|
||||
public function createRole(string $name, string $displayName, string $description): Role;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
@@ -129,6 +123,13 @@ interface UserRepositoryInterface
|
||||
*/
|
||||
public function first(): ?User;
|
||||
|
||||
/**
|
||||
* @param string $role
|
||||
*
|
||||
* @return Role|null
|
||||
*/
|
||||
public function getRole(string $role): ?Role;
|
||||
|
||||
/**
|
||||
* Return basic user information.
|
||||
*
|
||||
|
||||
@@ -57,14 +57,6 @@ class Transaction extends SpectreObject
|
||||
/** @var Carbon */
|
||||
private $updatedAt;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transaction constructor.
|
||||
*
|
||||
@@ -87,39 +79,6 @@ class Transaction extends SpectreObject
|
||||
$this->updatedAt = new Carbon($data['updated_at']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMode(): string
|
||||
{
|
||||
return $this->mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDuplicated(): bool
|
||||
{
|
||||
return $this->duplicated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TransactionExtra
|
||||
*/
|
||||
public function getExtra(): TransactionExtra
|
||||
{
|
||||
return $this->extra;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -152,6 +111,14 @@ class Transaction extends SpectreObject
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TransactionExtra
|
||||
*/
|
||||
public function getExtra(): TransactionExtra
|
||||
{
|
||||
return $this->extra;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -177,6 +144,14 @@ class Transaction extends SpectreObject
|
||||
return $hashed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Carbon
|
||||
*/
|
||||
@@ -185,5 +160,29 @@ class Transaction extends SpectreObject
|
||||
return $this->madeOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMode(): string
|
||||
{
|
||||
return $this->mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDuplicated(): bool
|
||||
{
|
||||
return $this->duplicated;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Services\Spectre\Request;
|
||||
use FireflyIII\Services\Spectre\Object\Customer;
|
||||
use FireflyIII\Services\Spectre\Object\Login;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class ListLoginsRequest
|
||||
*/
|
||||
@@ -37,14 +38,6 @@ class ListLoginsRequest extends SpectreRequest
|
||||
/** @var array */
|
||||
private $logins = [];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getLogins(): array
|
||||
{
|
||||
return $this->logins;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -79,6 +72,14 @@ class ListLoginsRequest extends SpectreRequest
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getLogins(): array
|
||||
{
|
||||
return $this->logins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Customer $customer
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Services\Spectre\Request;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Services\Spectre\Exception\DuplicatedCustomerException;
|
||||
use FireflyIII\Services\Spectre\Exception\SpectreException;
|
||||
use FireflyIII\User;
|
||||
use Log;
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace FireflyIII\Support;
|
||||
use Amount as Amt;
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use RuntimeException;
|
||||
|
||||
@@ -88,6 +88,7 @@ class Transaction extends Twig_Extension
|
||||
$currency->decimal_places = $transaction->foreign_currency_dp;
|
||||
$str .= ' (' . sprintf($format, app('amount')->formatAnything($currency, $amount, $coloured)) . ')';
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
@@ -115,6 +116,7 @@ class Transaction extends Twig_Extension
|
||||
$fakeCurrency->symbol = $transaction['foreign_currency_symbol'];
|
||||
$string .= ' (' . app('amount')->formatAnything($fakeCurrency, $amount, true) . ')';
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
@@ -201,6 +203,7 @@ class Transaction extends Twig_Extension
|
||||
}
|
||||
|
||||
$txt = '';
|
||||
|
||||
return $txt;
|
||||
}
|
||||
|
||||
@@ -350,10 +353,12 @@ class Transaction extends Twig_Extension
|
||||
$count = TransactionModel::where('transaction_journal_id', $journalId)->whereNull('deleted_at')->count();
|
||||
if ($count > 2) {
|
||||
$res = '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>';
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
$res = '';
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -403,6 +408,7 @@ class Transaction extends Twig_Extension
|
||||
}
|
||||
|
||||
$txt = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($name), route('accounts.show', [$transactionId]));
|
||||
|
||||
return $txt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class AttachmentTransformer extends TransformerAbstract
|
||||
'rel' => 'self',
|
||||
'uri' => '/attachment/' . $attachment->id,
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -48,12 +48,12 @@ class NoteTransformer extends TransformerAbstract
|
||||
'title' => $note->title,
|
||||
'text' => $note->text,
|
||||
'markdown' => $converter->convertToHtml($note->text),
|
||||
'links' => [
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/note/' . $note->id,
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user