From e76075e29f962bcf9a0af360d434d6595edbbd7a Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 22 Dec 2016 18:19:50 +0100 Subject: [PATCH] Various small fixes. --- app/Support/ExpandedForm.php | 7 +++++++ app/Support/Twig/Journal.php | 4 ++-- tests/acceptance/Controllers/BudgetControllerTest.php | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index 2b6a2f0486..50e3398f26 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -503,6 +503,13 @@ class ExpandedForm $currencies = Amt::getAllCurrencies(); unset($options['currency']); unset($options['placeholder']); + + // make sure value is formatted nicely: + if (!is_null($value) && $value !== '') { + $value = round($value, 2); + } + + $html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render(); return $html; diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.php index e98f0ee070..65aac8e818 100644 --- a/app/Support/Twig/Journal.php +++ b/app/Support/Twig/Journal.php @@ -16,6 +16,7 @@ namespace FireflyIII\Support\Twig; use Amount; use FireflyIII\Models\Account; +use FireflyIII\Models\AccountType; use FireflyIII\Models\Budget as ModelBudget; use FireflyIII\Models\Category; use FireflyIII\Models\TransactionJournal; @@ -142,7 +143,7 @@ class Journal extends Twig_Extension $array = []; /** @var Account $entry */ foreach ($list as $entry) { - if ($entry->accountType->type == 'Cash account') { + if ($entry->accountType->type == AccountType::CASH) { $array[] = '(cash)'; continue; } @@ -153,7 +154,6 @@ class Journal extends Twig_Extension $cache->store($result); return $result; - } ); } diff --git a/tests/acceptance/Controllers/BudgetControllerTest.php b/tests/acceptance/Controllers/BudgetControllerTest.php index 06d86c3bd1..cef5c1cb2e 100644 --- a/tests/acceptance/Controllers/BudgetControllerTest.php +++ b/tests/acceptance/Controllers/BudgetControllerTest.php @@ -129,10 +129,10 @@ class BudgetControllerTest extends TestCase public function testPostUpdateIncome() { $data = [ - 'amount' => 200, + 'amount' => '200', ]; $this->be($this->user()); - $this->call('post', route('budgets.income.post', [1]), $data); + $this->call('post', route('budgets.income.post'), $data); $this->assertResponseStatus(302); }