mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-26 16:26:35 -06:00
Some code cleanup. Fixes the tests.
This commit is contained in:
parent
53c80aaef8
commit
eb5e55a272
@ -9,9 +9,9 @@
|
||||
|
||||
namespace FireflyIII\Bootstrap;
|
||||
|
||||
use Illuminate\Log\Writer;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Foundation\Bootstrap\ConfigureLogging as IlluminateConfigureLogging;
|
||||
use Illuminate\Log\Writer;
|
||||
|
||||
/**
|
||||
* Class ConfigureLogging
|
||||
@ -26,7 +26,7 @@ class ConfigureLogging extends IlluminateConfigureLogging
|
||||
*/
|
||||
protected function configureSingleHandler(Application $app, Writer $log)
|
||||
{
|
||||
$log->useFiles($app->storagePath().'/logs/firefly-iii.log');
|
||||
$log->useFiles($app->storagePath() . '/logs/firefly-iii.log');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -36,7 +36,7 @@ class ConfigureLogging extends IlluminateConfigureLogging
|
||||
protected function configureDailyHandler(Application $app, Writer $log)
|
||||
{
|
||||
$log->useDailyFiles(
|
||||
$app->storagePath().'/logs/firefly-iii.log',
|
||||
$app->storagePath() . '/logs/firefly-iii.log',
|
||||
$app->make('config')->get('app.log_max_files', 5)
|
||||
);
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
|
||||
$this->exportDisk->put($file, $this->explanationString);
|
||||
Log::debug('Also put explanation file "' . $file . '" in the zip.');
|
||||
$this->getFiles()->push($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
|
||||
foreach ($files as $entry) {
|
||||
$this->processOldUpload($entry);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ class CsvExporter extends BasicExporter implements ExporterInterface
|
||||
|
||||
}
|
||||
$writer->insertAll($rows);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@ class Processor
|
||||
$attachmentCollector = app('FireflyIII\Export\Collector\AttachmentCollector', [$this->job]);
|
||||
$attachmentCollector->run();
|
||||
$this->files = $this->files->merge($attachmentCollector->getFiles());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ class Processor
|
||||
*/
|
||||
public function collectJournals(): bool
|
||||
{
|
||||
$args = [$this->accounts, Auth::user(), $this->settings['startDate'], $this->settings['endDate']];
|
||||
$args = [$this->accounts, Auth::user(), $this->settings['startDate'], $this->settings['endDate']];
|
||||
/** @var JournalCollector $journalCollector */
|
||||
$journalCollector = app('FireflyIII\Repositories\Journal\JournalCollector', $args);
|
||||
$this->journals = $journalCollector->collect();
|
||||
@ -100,6 +101,7 @@ class Processor
|
||||
$this->settings['endDate']->format('Y-m-d')
|
||||
. ').'
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -112,6 +114,7 @@ class Processor
|
||||
$uploadCollector->run();
|
||||
|
||||
$this->files = $this->files->merge($uploadCollector->getFiles());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -127,6 +130,7 @@ class Processor
|
||||
$count++;
|
||||
}
|
||||
Log::debug('Converted ' . $count . ' journals to "Entry" objects.');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -137,6 +141,7 @@ class Processor
|
||||
{
|
||||
$this->configurationMaker = app('FireflyIII\Export\ConfigurationFile', [$this->job]);
|
||||
$this->files->push($this->configurationMaker->make());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -173,6 +178,7 @@ class Processor
|
||||
$disk->delete($file);
|
||||
}
|
||||
Log::debug('Done!');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -188,6 +194,7 @@ class Processor
|
||||
$exporter->run();
|
||||
$this->files->push($exporter->getFileName());
|
||||
Log::debug('Added "' . $exporter->getFileName() . '" to the list of files to include in the zip.');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ class SendRegistrationMail
|
||||
} catch (Swift_TransportException $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ class UserConfirmation
|
||||
$user = $event->user;
|
||||
$ipAddress = $event->ipAddress;
|
||||
$this->doConfirm($user, $ipAddress);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -62,6 +63,7 @@ class UserConfirmation
|
||||
$user = $event->user;
|
||||
$ipAddress = $event->ipAddress;
|
||||
$this->doConfirm($user, $ipAddress);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class UserEventListener
|
||||
{
|
||||
/**
|
||||
* Handle user logout events.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onUserLogout(): bool
|
||||
|
@ -73,6 +73,7 @@ class Data
|
||||
|
||||
/**
|
||||
* FIXME may return null
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCsvFileLocation(): string
|
||||
@ -92,6 +93,7 @@ class Data
|
||||
|
||||
/**
|
||||
* FIXME may return null
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDateFormat(): string
|
||||
@ -111,6 +113,7 @@ class Data
|
||||
|
||||
/**
|
||||
* FIXME may return null
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDelimiter(): string
|
||||
|
@ -95,8 +95,8 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
||||
{
|
||||
$line = new BalanceLine;
|
||||
$line->setBudget($budget);
|
||||
$line->setStartDate($budget->startdate); // returned by getBudgetsAndLimitsInRange
|
||||
$line->setEndDate($budget->enddate); // returned by getBudgetsAndLimitsInRange
|
||||
$line->setStartDate($budget->startdate); // returned by getBudgetsAndLimitsInRange()
|
||||
$line->setEndDate($budget->enddate); // returned by getBudgetsAndLimitsInRange()
|
||||
|
||||
// loop accounts:
|
||||
foreach ($accounts as $account) {
|
||||
|
@ -120,7 +120,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
||||
$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
$budgets = $repository->getActiveBudgets();
|
||||
|
||||
$set = new Collection;
|
||||
$set = new Collection;
|
||||
/** @var Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
$expenses = $repository->getExpensesPerDay($budget, $start, $end, $accounts);
|
||||
|
@ -174,9 +174,9 @@ class BillController extends Controller
|
||||
*/
|
||||
public function show(BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||
$journals = $repository->getJournals($bill, $page, $pageSize);
|
||||
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||
$journals = $repository->getJournals($bill, $page, $pageSize);
|
||||
$journals->setPath('/bills/show/' . $bill->id);
|
||||
$bill->nextExpectedMatch = $repository->nextExpectedMatch($bill);
|
||||
$hideBill = true;
|
||||
|
@ -149,7 +149,6 @@ class BudgetController extends Controller
|
||||
$budgeted = '0';
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
$repeatFreq = Config::get('firefly.range_to_repeat_freq.' . $range);
|
||||
/** @var Carbon $date */
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', new Carbon);
|
||||
/** @var Carbon $end */
|
||||
|
@ -7,7 +7,6 @@ use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
use Response;
|
||||
|
||||
|
||||
|
@ -100,9 +100,9 @@ class ReportController extends Controller
|
||||
break;
|
||||
case ($role === BalanceLine::ROLE_DIFFROLE):
|
||||
// journals no budget, not corrected by a tag.
|
||||
$journals = $budgetRepository->getAllWithoutBudget($account, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||
$journals = $budgetRepository->getAllWithoutBudget($account, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||
$budget->name = strval(trans('firefly.leftUnbalanced'));
|
||||
$journals = $journals->filter(
|
||||
$journals = $journals->filter(
|
||||
function (TransactionJournal $journal) {
|
||||
$tags = $journal->tags()->where('tagMode', 'balancingAct')->count();
|
||||
if ($tags === 0) {
|
||||
|
@ -138,7 +138,7 @@ class PreferencesController extends Controller
|
||||
|
||||
// save page size:
|
||||
$transactionPageSize = intval(Input::get('transactionPageSize'));
|
||||
if($transactionPageSize > 0 && $transactionPageSize < 1337) {
|
||||
if ($transactionPageSize > 0 && $transactionPageSize < 1337) {
|
||||
Preferences::set('transactionPageSize', $transactionPageSize);
|
||||
} else {
|
||||
Preferences::set('transactionPageSize', 50);
|
||||
|
@ -36,15 +36,16 @@ class Kernel extends HttpKernel
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $bootstrappers = [
|
||||
'Illuminate\Foundation\Bootstrap\DetectEnvironment',
|
||||
'Illuminate\Foundation\Bootstrap\LoadConfiguration',
|
||||
'FireflyIII\Bootstrap\ConfigureLogging',
|
||||
'Illuminate\Foundation\Bootstrap\HandleExceptions',
|
||||
'Illuminate\Foundation\Bootstrap\RegisterFacades',
|
||||
'Illuminate\Foundation\Bootstrap\RegisterProviders',
|
||||
'Illuminate\Foundation\Bootstrap\BootProviders',
|
||||
];
|
||||
protected $bootstrappers
|
||||
= [
|
||||
'Illuminate\Foundation\Bootstrap\DetectEnvironment',
|
||||
'Illuminate\Foundation\Bootstrap\LoadConfiguration',
|
||||
'FireflyIII\Bootstrap\ConfigureLogging',
|
||||
'Illuminate\Foundation\Bootstrap\HandleExceptions',
|
||||
'Illuminate\Foundation\Bootstrap\RegisterFacades',
|
||||
'Illuminate\Foundation\Bootstrap\RegisterProviders',
|
||||
'Illuminate\Foundation\Bootstrap\BootProviders',
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
@ -144,7 +145,7 @@ class Kernel extends HttpKernel
|
||||
// MUST be confirmed.
|
||||
// MUST have owner role
|
||||
// (this group includes the other Firefly middleware)
|
||||
'admin' => [
|
||||
'admin' => [
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
StartSession::class,
|
||||
|
@ -31,14 +31,14 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournalMeta whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournalMeta whereData($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string $hash
|
||||
* @property string $hash
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournalMeta whereHash($value)
|
||||
*/
|
||||
class TransactionJournalMeta extends Model
|
||||
{
|
||||
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
protected $fillable = ['transaction_journal_id', 'name', 'data','hash'];
|
||||
protected $fillable = ['transaction_journal_id', 'name', 'data', 'hash'];
|
||||
protected $table = 'journal_meta';
|
||||
|
||||
/**
|
||||
|
@ -3,9 +3,10 @@ declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Providers;
|
||||
|
||||
use Config;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Log;
|
||||
use Config;
|
||||
|
||||
/**
|
||||
* Class AppServiceProvider
|
||||
*
|
||||
|
@ -81,7 +81,7 @@ class FireflyServiceProvider extends ServiceProvider
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
$this->app->bind('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface', 'FireflyIII\Repositories\Currency\CurrencyRepository');
|
||||
$this->app->bind('FireflyIII\Support\Search\SearchInterface', 'FireflyIII\Support\Search\Search');
|
||||
$this->app->bind('FireflyIII\Repositories\User\UserRepositoryInterface', 'FireflyIII\Repositories\User\UserRepository');
|
||||
|
@ -124,7 +124,8 @@ interface AccountRepositoryInterface
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param int $page
|
||||
* @param int $pageSize
|
||||
* @param int $pageSize
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getJournals(Account $account, int $page, int $pageSize = 50): LengthAwarePaginator;
|
||||
|
@ -327,6 +327,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
/**
|
||||
* Get all journals that were recorded on this bill between these dates.
|
||||
*
|
||||
* @param Bill $bill
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
|
@ -83,7 +83,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
||||
/**
|
||||
*
|
||||
* FIXME this may return null
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return ExportJob|null
|
||||
|
@ -119,6 +119,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
$rule->order = ($rule->order + 1);
|
||||
$rule->save();
|
||||
$this->resetRulesInGroupOrder($rule->ruleGroup);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -141,6 +142,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
$rule->order = ($rule->order - 1);
|
||||
$rule->save();
|
||||
$this->resetRulesInGroupOrder($rule->ruleGroup);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -342,6 +344,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
|
||||
$this->storeAction($rule, $actionValues);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -349,6 +352,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
/**
|
||||
* @param Rule $rule
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function storeTriggers(Rule $rule, array $data): bool
|
||||
@ -378,6 +382,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
$this->storeTrigger($rule, $triggerValues);
|
||||
$order++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +133,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
$ruleGroup->order = ($ruleGroup->order + 1);
|
||||
$ruleGroup->save();
|
||||
$this->resetRuleGroupOrder();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -155,6 +156,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
$ruleGroup->order = ($ruleGroup->order - 1);
|
||||
$ruleGroup->save();
|
||||
$this->resetRuleGroupOrder();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ namespace FireflyIII\Repositories\Tag;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
|
@ -4,7 +4,6 @@ declare(strict_types = 1);
|
||||
namespace FireflyIII\Repositories\Tag;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Support\Collection;
|
||||
|
@ -286,7 +286,7 @@ class ExpandedForm
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
|
@ -111,9 +111,10 @@ class Preferences
|
||||
$user = Auth::user();
|
||||
if (is_null($user)) {
|
||||
// make new preference, return it:
|
||||
$pref = new Preference;
|
||||
$pref = new Preference;
|
||||
$pref->name = $name;
|
||||
$pref->data = $value;
|
||||
|
||||
return $pref;
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,9 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
* @property string $password
|
||||
* @property string $remember_token
|
||||
* @property string $reset
|
||||
* @property bool $activated
|
||||
* @property bool $isAdmin
|
||||
* @property bool $has2FA
|
||||
* @property bool $activated
|
||||
* @property bool $isAdmin
|
||||
* @property bool $has2FA
|
||||
* @property boolean $blocked
|
||||
* @property string $blocked_code
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Account[] $accounts
|
||||
|
@ -63,6 +63,7 @@ return [
|
||||
'1M' => 'monthly',
|
||||
'3M' => 'quarterly',
|
||||
'6M' => 'half-year',
|
||||
'1Y' => 'yearly',
|
||||
'custom' => 'monthly',
|
||||
],
|
||||
'subTitlesByIdentifier' =>
|
||||
|
@ -74,19 +74,4 @@ class ChartBudgetControllerTest extends TestCase
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::year
|
||||
*/
|
||||
public function testYear()
|
||||
{
|
||||
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
$repository->shouldReceive('getBudgetsAndExpensesPerMonth')->once()->andReturn([]);
|
||||
$repository->shouldReceive('getWithoutBudgetSum')->times(12)->andReturn('0');
|
||||
|
||||
$this->be($this->user());
|
||||
$this->call('GET', '/chart/budget/year/default/20150101/20151231/1');
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user