This commit is contained in:
James Cole 2016-11-12 06:34:54 +01:00
parent 4b42ef0db8
commit 32b5a84a0c
4 changed files with 25 additions and 33 deletions

View File

@ -196,35 +196,33 @@ class MassController extends Controller
$journal = $repository->find(intval($journalId));
if ($journal) {
// get optional fields:
$what = strtolower(TransactionJournal::transactionTypeStr($journal));
$what = strtolower(TransactionJournal::transactionTypeStr($journal));
$sourceAccountId = $request->get('source_account_id')[$journal->id] ?? 0;
$sourceAccountName = $request->get('source_account_name')[$journal->id] ?? '';
$destAccountId = $request->get('destination_account_id')[$journal->id] ?? 0;
$destAccountName = $request->get('destination_account_name')[$journal->id] ?? '';
$budgetId = $journal->budgets->first() ? $journal->budgets->first()->id : 0;
$category = $request->get('category')[$journal->id];
$tags = $journal->tags->pluck('tag')->toArray();
$budgetId = $journal->budgets->first() ? $journal->budgets->first()->id : 0;
$category = $request->get('category')[$journal->id];
$tags = $journal->tags->pluck('tag')->toArray();
// build data array
$data = [
'id' => $journal->id,
'what' => $what,
'description' => $request->get('description')[$journal->id],
'source_account_id' => intval($sourceAccountId),
'source_account_name' => $sourceAccountName,
'destination_account_id' => intval($destAccountId),
'destination_account_name' => $destAccountName,
'amount' => round($request->get('amount')[$journal->id], 4),
'amount_currency_id_amount' => intval($request->get('amount_currency_id_amount_' . $journal->id)),
'date' => new Carbon($request->get('date')[$journal->id]),
'interest_date' => $journal->interest_date,
'book_date' => $journal->book_date,
'process_date' => $journal->process_date,
'budget_id' => $budgetId,
'category' => $category,
'tags' => $tags,
'id' => $journal->id,
'what' => $what,
'description' => $request->get('description')[$journal->id],
'source_account_id' => intval($sourceAccountId),
'source_account_name' => $sourceAccountName,
'destination_account_id' => intval($destAccountId),
'destination_account_name' => $destAccountName,
'amount' => round($request->get('amount')[$journal->id], 4),
'currency_id' => intval($request->get('amount_currency_id_amount_' . $journal->id)),
'date' => new Carbon($request->get('date')[$journal->id]),
'interest_date' => $journal->interest_date,
'book_date' => $journal->book_date,
'process_date' => $journal->process_date,
'budget_id' => $budgetId,
'category' => $category,
'tags' => $tags,
];
// call repository update function.

View File

@ -397,6 +397,7 @@ class JournalRepository implements JournalRepositoryInterface
if (strlen(trim($name)) > 0) {
$tag = Tag::firstOrCreateEncrypted(['tag' => $name, 'user_id' => $journal->user_id]);
if (!is_null($tag)) {
Log::debug(sprintf('Will try to connect tag #%d to journal #%d.', $tag->id, $journal->id));
$tagRepository->connect($journal, $tag);
}
}
@ -733,6 +734,7 @@ class JournalRepository implements JournalRepositoryInterface
// connect each tag to journal (if not yet connected):
/** @var Tag $tag */
foreach ($tags as $tag) {
Log::debug(sprintf('Will try to connect tag #%d to journal #%d.', $tag->id, $journal->id));
$tagRepository->connect($journal, $tag);
}

View File

@ -49,18 +49,10 @@
{{ journal.date.formatLocalized(monthAndDayFormat) }}
</td>
<td>
{% if journal.source_account_type == 'Cash account' %}
<span class="text-success">(cash)</span>
{% else %}
<a href="{{ route('accounts.show',journal.source_account_id) }}">{{ journal.source_account_name }}</a>
{% endif %}
{{ sourceAccount(journal)|raw }}
</td>
<td>
{% if journal.destination_account_type == 'Cash account' %}
<span class="text-success">(cash)</span>
{% else %}
<a href="{{ route('accounts.show',journal.destination_account_id) }}">{{ journal.destination_account_name }}</a>
{% endif %}
{{ destinationAccount(journal)|raw }}
</td>
</tr>
{% endfor %}

View File

@ -90,7 +90,7 @@
</div>
<div class="box-footer">
{% if journals.count > 0 %}
<input type="submit" name="submit" value="{{ trans('form.update_all_journals') }}" class="btn btn-danger pull-right"/>
<input type="submit" name="submit" value="{{ trans('form.update_all_journals') }}" class="btn btn-success pull-right"/>
{% endif %}
<a href="{{ route('index') }}" class="btn-default btn">{{ trans('form.cancel') }}</a>