Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix last minute issues.
James Colec7af25ac38d5
diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.phpindex ae509f6b91..26074416c4 100644--- a/app/Http/Controllers/TagController.php+++ b/app/Http/Controllers/TagController.php@@ -31,7 +31,6 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Http\Request;use Illuminate\Support\Collection;-use Preferences;use View;/**@@ -109,7 +108,7 @@ class TagController extends Controller$this->repository->destroy($tag);session()->flash('success', (string)trans('firefly.deleted_tag', ['tag' => $tagName]));- Preferences::mark();+ app('preferences')->mark();return redirect($this->getPreviousUri('tags.delete.uri'));}@@ -177,8 +176,8 @@ class TagController extends Controller$subTitle = $tag->tag;$subTitleIcon = 'fa-tag';$page = (int)$request->get('page');- $pageSize = (int)Preferences::get('listPageSize', 50)->data;- $range = Preferences::get('viewRange', '1M')->data;+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $range = app('preferences')->get('viewRange', '1M')->data;$start = null;$end = null;$periods = new Collection;@@ -193,7 +192,7 @@ class TagController extends Controller}// prep for "specific date" view.- if (\strlen($moment) > 0 && 'all' !== $moment) {+ if ('all' !== $moment && \strlen($moment) > 0) {$start = new Carbon($moment);$end = app('navigation')->endOfPeriod($start, $range);$subTitle = trans(@@ -206,7 +205,7 @@ class TagController extends Controller}// prep for current period- if (0 === \strlen($moment)) {+ if ('' === $moment) {/** @var Carbon $start */$start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range));/** @var Carbon $end */@@ -241,7 +240,7 @@ class TagController extends Controller$this->repository->store($data);session()->flash('success', (string)trans('firefly.created_tag', ['tag' => $data['tag']]));- Preferences::mark();+ app('preferences')->mark();if (1 === (int)$request->get('create_another')) {// @codeCoverageIgnoreStart@@ -266,7 +265,7 @@ class TagController extends Controller$this->repository->update($tag, $data);session()->flash('success', (string)trans('firefly.updated_tag', ['tag' => $data['tag']]));- Preferences::mark();+ app('preferences')->mark();if (1 === (int)$request->get('return_to_edit')) {// @codeCoverageIgnoreStart@@ -288,9 +287,10 @@ class TagController extends Controllerprivate function getPeriodOverview(Tag $tag): Collection{// get first and last tag date from tag:- $range = Preferences::get('viewRange', '1M')->data;- $start = app('navigation')->startOfPeriod($this->repository->firstUseDate($tag), $range)->startOfMonth();- $end = app('navigation')->endOfPeriod($this->repository->lastUseDate($tag), $range)->endOfMonth();+ $range = app('preferences')->get('viewRange', '1M')->data;+ $end = app('navigation')->endOfX($this->repository->lastUseDate($tag), $range, null);+ $start = $this->repository->firstUseDate($tag);+// properties for entries with their amounts.$cache = new CacheProperties;@@ -304,22 +304,23 @@ class TagController extends Controller}$collection = new Collection;-+ $currentEnd = clone $end;// while end larger or equal to start- while ($end >= $start) {- $currentEnd = app('navigation')->endOfPeriod($end, $range);+ while ($currentEnd >= $start) {+ $currentStart = app('navigation')->startOfPeriod($currentEnd, $range);// get expenses and what-not in this period and this tag.$arr = ['string' => $end->format('Y-m-d'),- 'name' => app('navigation')->periodShow($end, $range),+ 'name' => app('navigation')->periodShow($currentEnd, $range),'date' => clone $end,- 'spent' => $this->repository->spentInPeriod($tag, $end, $currentEnd),- 'earned' => $this->repository->earnedInPeriod($tag, $end, $currentEnd),+ 'spent' => $this->repository->spentInPeriod($tag, $currentStart, $currentEnd),+ 'earned' => $this->repository->earnedInPeriod($tag, $currentStart, $currentEnd),];$collection->push($arr);- $end = app('navigation')->subtractPeriod($end, $range, 1);+ $currentEnd = clone $currentStart;+ $currentEnd->subDay();}$cache->store($collection);diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.phpindex 3375d38cad..06d29aefa0 100644--- a/app/Repositories/Rule/RuleRepository.php+++ b/app/Repositories/Rule/RuleRepository.php@@ -98,7 +98,7 @@ class RuleRepository implements RuleRepositoryInterfacepublic function getForImport(): Collection{return Rule::distinct()- ->where('rules.user_id', $this->user->user_id)+ ->where('rules.user_id', $this->user->id)->leftJoin('rule_groups', 'rule_groups.id', '=', 'rules.rule_group_id')->leftJoin('rule_triggers', 'rules.id', '=', 'rule_triggers.rule_id')->where('rule_groups.active', 1)diff --git a/tests/Feature/Controllers/TagControllerTest.php b/tests/Feature/Controllers/TagControllerTest.phpindex b8aef54bc9..7152e7fd48 100644--- a/tests/Feature/Controllers/TagControllerTest.php+++ b/tests/Feature/Controllers/TagControllerTest.php@@ -156,10 +156,10 @@ class TagControllerTest extends TestCase$collector = $this->mock(JournalCollectorInterface::class);$journalRepos = $this->mock(JournalRepositoryInterface::class);$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);- $repository->shouldReceive('spentInPeriod')->andReturn('-1')->times(3);+ $repository->shouldReceive('spentInPeriod')->andReturn('-1')->times(1);$repository->shouldReceive('firstUseDate')->andReturn(new Carbon)->once();$repository->shouldReceive('lastUseDate')->andReturn(new Carbon)->once();- $repository->shouldReceive('earnedInPeriod')->andReturn('1')->times(3);+ $repository->shouldReceive('earnedInPeriod')->andReturn('1')->times(1);$repository->shouldReceive('sumsOfTag')->andReturn($amounts)->once();$collector->shouldReceive('removeFilter')->andReturnSelf()->once();@@ -225,10 +225,10 @@ class TagControllerTest extends TestCase$collector = $this->mock(JournalCollectorInterface::class);$journalRepos = $this->mock(JournalRepositoryInterface::class);$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);- $repository->shouldReceive('spentInPeriod')->andReturn('-1')->times(3);+ $repository->shouldReceive('spentInPeriod')->andReturn('-1')->times(1);$repository->shouldReceive('firstUseDate')->andReturn(new Carbon)->once();$repository->shouldReceive('lastUseDate')->andReturn(new Carbon)->once();- $repository->shouldReceive('earnedInPeriod')->andReturn('1')->times(3);+ $repository->shouldReceive('earnedInPeriod')->andReturn('1')->times(1);$collector->shouldReceive('removeFilter')->andReturnSelf()->once();$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();