Skip to content

Firefly III: a personal finances manager

Various small fixes.

James Colec049d5cfa62a
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index dd2e83e25e..c41e03e366 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -150,11 +150,8 @@ class HomeController extends Controller
foreach ($accounts as $account) {
$collector = app(JournalCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit(10)->setPage(1);
- $set = $collector->getJournals();
-
- if (count($set) > 0) {
- $transactions[] = [$set, $account];
- }
+ $set = $collector->getJournals();
+ $transactions[] = [$set, $account];
}
return view(
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index b980e3337d..4326b8c2af 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -25,6 +25,7 @@ use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Collection;
use Preferences;
use Response;
+use Session;
use View;
/**
@@ -145,6 +146,7 @@ class ReportController extends Controller
if ($end < $start) {
return view('error')->with('message', trans('firefly.end_after_start_date'));
}
+
if ($start < session('first')) {
$start = session('first');
}
@@ -174,7 +176,6 @@ class ReportController extends Controller
*/
public function index(AccountRepositoryInterface $repository)
{
-
/** @var Carbon $start */
$start = clone session('first');
$months = $this->helper->listOfMonths($start);
@@ -220,6 +221,12 @@ class ReportController extends Controller
$accounts = join(',', $request->getAccountList()->pluck('id')->toArray());
$categories = join(',', $request->getCategoryList()->pluck('id')->toArray());
+ if ($request->getAccountList()->count() === 0) {
+ Session::flash('error', trans('firefly.select_more_than_one_account'));
+
+ return redirect(route('reports.index'));
+ }
+
if ($end < $start) {
return view('error')->with('message', trans('firefly.end_after_start_date'));
}
diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php
index 803971fe52..ae3481bfcd 100644
--- a/app/Http/Controllers/Transaction/SingleController.php
+++ b/app/Http/Controllers/Transaction/SingleController.php
@@ -155,7 +155,7 @@ class SingleController extends Controller
}
$type = TransactionJournal::transactionTypeStr($transactionJournal);
- Session::flash('success', strval(trans('firefly.deleted_' . $type, ['description' => e($transactionJournal->description)])));
+ Session::flash('success', strval(trans('firefly.deleted_' . strtolower($type), ['description' => e($transactionJournal->description)])));
$repository->delete($transactionJournal);
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
index 62f2636336..fdcf61b5dd 100755
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -18,6 +18,7 @@ use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankRepetition;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Models\TransactionJournalMeta;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Log;
@@ -137,13 +138,21 @@ class EventServiceProvider extends ServiceProvider
TransactionJournal::deleted(
function (TransactionJournal $journal) {
- Log::debug('Now triggered journal delete response #' . $journal->id);
+ Log::debug(sprintf('Now triggered journal delete response #%d', $journal->id));
/** @var Transaction $transaction */
foreach ($journal->transactions()->get() as $transaction) {
- Log::debug('Will now delete transaction #' . $transaction->id);
+ Log::debug(sprintf('Will now delete transaction #%d', $transaction->id));
$transaction->delete();
}
+
+ // also delete journal_meta entries.
+
+ /** @var TransactionJournalMeta $meta */
+ foreach ($journal->transactionJournalMeta()->get() as $meta) {
+ Log::debug(sprintf('Will now delete meta-entry #%d', $meta->id));
+ $meta->delete();
+ }
}
);
diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php
index 44f709de98..ef653e2563 100644
--- a/app/Support/Preferences.php
+++ b/app/Support/Preferences.php
@@ -16,6 +16,7 @@ namespace FireflyIII\Support;
use Cache;
use FireflyIII\Models\Preference;
use FireflyIII\User;
+use Session;
/**
* Class Preferences
@@ -128,6 +129,7 @@ class Preferences
public function mark(): bool
{
$this->set('lastActivity', microtime());
+ Session::forget('first');
return true;
}
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index 73362cc316..f40af9d8d3 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -521,6 +521,9 @@ return [
'stored_new_account' => 'New account ":name" stored!',
'updated_account' => 'Updated account ":name"',
'credit_card_options' => 'Credit card options',
+ 'no_transactions_account' => 'There are no transactions (in this period) for asset account ":name".',
+ 'no_data_for_chart' => 'There is not enough information (yet) to generate this chart.',
+ 'select_more_than_one_account' => 'Please select more than one account',
// categories:
'new_category' => 'New category',
diff --git a/resources/lang/en_US/form.php b/resources/lang/en_US/form.php
index 8933321f5d..5418b22d8b 100644
--- a/resources/lang/en_US/form.php
+++ b/resources/lang/en_US/form.php
@@ -25,6 +25,8 @@ return [
'match' => 'Matches on',
'repeat_freq' => 'Repeats',
'journal_currency_id' => 'Currency',
+ 'currency_id' => 'Currency',
+ 'attachments' => 'Attachments',
'journal_amount' => 'Amount',
'journal_asset_source_account' => 'Asset account (source)',
'journal_source_account_name' => 'Revenue account (source)',
diff --git a/resources/views/index.twig b/resources/views/index.twig
index 737c74873d..a1443b6e18 100644
--- a/resources/views/index.twig
+++ b/resources/views/index.twig
@@ -82,9 +82,21 @@
</div>
- <div class="box-body no-padding">
- {% include 'list.journals-tiny-tasker' with {'transactions': data[0],'account': data[1]} %}
- </div>
+
+ {% if data[0].count > 0 %}
+ <div class="box-body no-padding">
+ {% include 'list.journals-tiny-tasker' with {'transactions': data[0],'account': data[1]} %}
+ </div>
+ {% else %}
+ <div class="box-body">
+ <p>
+ <em>
+ {{ trans('firefly.no_transactions_account', {name: data[1].name}) }}
+ </em>
+ </p>
+ </div>
+ {% endif %}
+
<div class="box-footer clearfix">
<a class="btn btn-sm btn-default btn-flat pull-right"
href="{{ route('accounts.show',data[1].id) }}">{{ (data[1]|balance)|formatAmountPlain }}</a>