Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Update for bug fix release.
James Colebcdb849b4607
diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.phpindex d87905a05d..f1c96b4055 100644--- a/app/Http/Controllers/Account/ReconcileController.php+++ b/app/Http/Controllers/Account/ReconcileController.php@@ -117,7 +117,8 @@ class ReconcileController extends Controller* @param Carbon|null $end** @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View- *+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)* @throws FireflyException*/public function reconcile(Account $account, Carbon $start = null, Carbon $end = null)@@ -201,6 +202,9 @@ class ReconcileController extends Controller** @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector* @throws FireflyException+ *+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)*/public function submit(ReconciliationStoreRequest $request, Account $account, Carbon $start, Carbon $end){@@ -217,16 +221,13 @@ class ReconcileController extends Controllerif ('create' === $data['reconcile']) {// get "opposing" account.$reconciliation = $this->accountRepos->getReconciliation($account);--- $difference = $data['difference'];- $source = $reconciliation;- $destination = $account;+ $difference = $data['difference'];+ $source = $reconciliation;+ $destination = $account;if (1 === bccomp($difference, '0')) {// amount is positive. Add it to reconciliation?$source = $account;$destination = $reconciliation;-}// data for journal@@ -271,9 +272,7 @@ class ReconcileController extends Controller$this->repository->store($journalData);}Log::debug('End of routine.');-app('preferences')->mark();-session()->flash('success', trans('firefly.reconciliation_stored'));return redirect(route('accounts.show', [$account->id]));diff --git a/changelog.md b/changelog.mdindex 6358b2b40b..6cb3e19b97 100644--- a/changelog.md+++ b/changelog.md@@ -2,6 +2,17 @@All notable changes to this project will be documented in this file.This project adheres to [Semantic Versioning](http://semver.org/).++## [4.7.5.1] - 2018-07-13+### Fixed+- #1531, the database routine incorrectly reports empty categories.+- #1532, broken dropdown for autosuggest things.+- #1533, fix where the import could not import category names.+- #1538, fix a bug where Spectre would not work when ignoring rules.+- #1542, fix a bug where the importer was incapable of generating new currencies.+- #1541, no longer ignore composer.lock in Docker ignore.+- Bills are stored inactive.+## [4.7.5] - 2018-07-02### Added- A new feature called "recurring transactions" that will make Firefly III automatically create transactions for you.diff --git a/config/firefly.php b/config/firefly.phpindex 3ce05abf00..d1d8476010 100644--- a/config/firefly.php+++ b/config/firefly.php@@ -88,8 +88,8 @@ return ['is_demo_site' => false,],'encryption' => null === env('USE_ENCRYPTION') || env('USE_ENCRYPTION') === true,- 'version' => '4.7.5',- 'api_version' => '0.4',+ 'version' => '4.7.5.1',+ 'api_version' => '0.5','db_version' => 4,'maxUploadSize' => 15242880,'allowedMimes' => [diff --git a/tests/Api/V1/Controllers/CurrencyControllerTest.php b/tests/Api/V1/Controllers/CurrencyControllerTest.phpindex c90dada382..b9f0f64fb6 100644--- a/tests/Api/V1/Controllers/CurrencyControllerTest.php+++ b/tests/Api/V1/Controllers/CurrencyControllerTest.php@@ -163,7 +163,7 @@ class CurrencyControllerTest extends TestCase'code' => 'ABC','symbol' => 'A','decimal_places' => 2,- 'default' => 'false',+ 'default' => '0',];// test API@@ -200,7 +200,7 @@ class CurrencyControllerTest extends TestCase'code' => 'ABC','symbol' => 'A','decimal_places' => 2,- 'default' => 'true',+ 'default' => '1',];// test API@@ -232,7 +232,7 @@ class CurrencyControllerTest extends TestCase'code' => 'ABC','symbol' => '$E','decimal_places' => '2',- 'default' => 'false',+ 'default' => '0',];// test API@@ -270,7 +270,7 @@ class CurrencyControllerTest extends TestCase'code' => 'ABC','symbol' => '$E','decimal_places' => '2',- 'default' => 'true',+ 'default' => '1',];// test APIdiff --git a/tests/Api/V1/Controllers/UserControllerTest.php b/tests/Api/V1/Controllers/UserControllerTest.phpindex d5ef6b81ab..457b1e0e4c 100644--- a/tests/Api/V1/Controllers/UserControllerTest.php+++ b/tests/Api/V1/Controllers/UserControllerTest.php@@ -28,6 +28,7 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;use FireflyIII\User;use Laravel\Passport\Passport;use Log;+use Mockery;use Tests\TestCase;/**@@ -94,6 +95,7 @@ class UserControllerTest extends TestCase$users = factory(User::class, 10)->create();// mock stuff:$repository = $this->mock(UserRepositoryInterface::class);+ $repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->once()->andReturn(true);// mock calls:$repository->shouldReceive('all')->withAnyArgs()->andReturn($users)->once();@@ -116,7 +118,9 @@ class UserControllerTest extends TestCase*/public function testShow(): void{- $user = User::first();+ $user = User::first();+ $repository = $this->mock(UserRepositoryInterface::class);+ $repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->once()->andReturn(true);// test API$response = $this->get('/api/v1/users/' . $user->id);@@ -139,7 +143,7 @@ class UserControllerTest extends TestCase// mock$userRepos = $this->mock(UserRepositoryInterface::class);- $userRepos->shouldReceive('hasRole')->once()->andReturn(true);+ $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->twice()->andReturn(true);$userRepos->shouldReceive('store')->once()->andReturn($this->user());// test API@@ -163,7 +167,7 @@ class UserControllerTest extends TestCase// mock$userRepos = $this->mock(UserRepositoryInterface::class);- $userRepos->shouldReceive('hasRole')->once()->andReturn(true);+ $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->twice()->andReturn(true);// test API$response = $this->post('/api/v1/users', $data, ['Accept' => 'application/json']);$response->assertStatus(422);@@ -199,7 +203,7 @@ class UserControllerTest extends TestCase// mock$userRepos = $this->mock(UserRepositoryInterface::class);$userRepos->shouldReceive('update')->once()->andReturn($user);- $userRepos->shouldReceive('hasRole')->once()->andReturn(true);+ $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->twice()->andReturn(true);// call API$response = $this->put('/api/v1/users/' . $user->id, $data);diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.phpindex 617cab8e2a..7d5185ddb4 100644--- a/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php+++ b/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php@@ -24,6 +24,7 @@ namespace Tests\Unit\TransactionRules\Triggers;use FireflyIII\Models\TransactionJournal;use FireflyIII\TransactionRules\Triggers\FromAccountStarts;+use Log;use Tests\TestCase;/**@@ -31,19 +32,35 @@ use Tests\TestCase;*/class FromAccountStartsTest extends TestCase{+ /**+ *+ */+ public function setUp()+ {+ parent::setUp();+ Log::debug(sprintf('Now in %s.', \get_class($this)));+ }+/*** @covers \FireflyIII\TransactionRules\Triggers\FromAccountStarts::triggered*/public function testTriggered(): void{- $count = 0;+ Log::debug('In testTriggered()');+ $loops = 0; // FINAL LOOP METHOD.do {- $journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();- $transaction = $journal->transactions()->where('amount', '<', 0)->first();- $transactionCount = $journal->transactions()->count();- $account = $transaction->account;- $count++;- } while ($account === null && $count < 30 && $transactionCount !== 2);+ /** @var TransactionJournal $journal */+ $journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();+ $transaction = $journal->transactions()->where('amount', '<', 0)->first();+ $account = $transaction->account;+ $count = $journal->transactions()->count();++ Log::debug(sprintf('Loop: %d, transaction count: %d, account is null: %d', $loops, $count, (int)null===$account));++ $loops++;++ // do this until: account is not null, journal has two transactions, loops is below 30+ } while (!(null !== $account && 2 === $count && $loops < 30));$trigger = FromAccountStarts::makeFromStrings(substr($account->name, 0, -3), false);$result = $trigger->triggered($journal);@@ -55,14 +72,21 @@ class FromAccountStartsTest extends TestCase*/public function testTriggeredLonger(): void{- $count = 0;+ Log::debug('In testTriggeredLonger()');+ $loops = 0; // FINAL LOOP METHOD.do {- $journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();- $transaction = $journal->transactions()->where('amount', '<', 0)->first();- $transactionCount = $journal->transactions()->count();- $account = $transaction->account;- $count++;- } while ($account === null && $count < 30 && $transactionCount !== 2);+ /** @var TransactionJournal $journal */+ $journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();+ $transaction = $journal->transactions()->where('amount', '<', 0)->first();+ $account = $transaction->account;+ $count = $journal->transactions()->count();++ Log::debug(sprintf('Loop: %d, transaction count: %d, account is null: %d', $loops, $count, (int)null===$account));++ $loops++;++ // do this until: account is not null, journal has two transactions, loops is below 30+ } while (!(null !== $account && 2 === $count && $loops < 30));$trigger = FromAccountStarts::makeFromStrings('bla-bla-bla' . $account->name, false);$result = $trigger->triggered($journal);diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.phpindex dfa3f641bb..6794feb281 100644--- a/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php+++ b/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php@@ -38,19 +38,20 @@ class ToAccountStartsTest extends TestCasepublic function testTriggered(): void{Log::debug('Now in testTriggered');-$loopCount = 0;$account = null;do {Log::debug(sprintf('Count of loop: %d', $loopCount));+$journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();$count = $journal->transactions()->where('amount', '>', 0)->count();$transaction = $journal->transactions()->where('amount', '>', 0)->first();$account = null === $transaction ? null : $transaction->account;+Log::debug(sprintf('Journal with id #%d', $journal->id));Log::debug(sprintf('Count of transactions is %d', $count));Log::debug(sprintf('Account is null: %s', var_export(null === $account, true)));- } while ($loopCount < 30 && $count !== 1 && null !== $account);+ } while ($loopCount < 30 && $count < 1 && null !== $account);$trigger = ToAccountStarts::makeFromStrings(substr($account->name, 0, -3), false);