mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 03:08:11 +00:00
Fixes #401
This commit is contained in:
@@ -196,35 +196,33 @@ class MassController extends Controller
|
|||||||
$journal = $repository->find(intval($journalId));
|
$journal = $repository->find(intval($journalId));
|
||||||
if ($journal) {
|
if ($journal) {
|
||||||
// get optional fields:
|
// get optional fields:
|
||||||
$what = strtolower(TransactionJournal::transactionTypeStr($journal));
|
$what = strtolower(TransactionJournal::transactionTypeStr($journal));
|
||||||
|
|
||||||
$sourceAccountId = $request->get('source_account_id')[$journal->id] ?? 0;
|
$sourceAccountId = $request->get('source_account_id')[$journal->id] ?? 0;
|
||||||
$sourceAccountName = $request->get('source_account_name')[$journal->id] ?? '';
|
$sourceAccountName = $request->get('source_account_name')[$journal->id] ?? '';
|
||||||
$destAccountId = $request->get('destination_account_id')[$journal->id] ?? 0;
|
$destAccountId = $request->get('destination_account_id')[$journal->id] ?? 0;
|
||||||
$destAccountName = $request->get('destination_account_name')[$journal->id] ?? '';
|
$destAccountName = $request->get('destination_account_name')[$journal->id] ?? '';
|
||||||
|
$budgetId = $journal->budgets->first() ? $journal->budgets->first()->id : 0;
|
||||||
$budgetId = $journal->budgets->first() ? $journal->budgets->first()->id : 0;
|
$category = $request->get('category')[$journal->id];
|
||||||
$category = $request->get('category')[$journal->id];
|
$tags = $journal->tags->pluck('tag')->toArray();
|
||||||
$tags = $journal->tags->pluck('tag')->toArray();
|
|
||||||
|
|
||||||
// build data array
|
// build data array
|
||||||
$data = [
|
$data = [
|
||||||
'id' => $journal->id,
|
'id' => $journal->id,
|
||||||
'what' => $what,
|
'what' => $what,
|
||||||
'description' => $request->get('description')[$journal->id],
|
'description' => $request->get('description')[$journal->id],
|
||||||
'source_account_id' => intval($sourceAccountId),
|
'source_account_id' => intval($sourceAccountId),
|
||||||
'source_account_name' => $sourceAccountName,
|
'source_account_name' => $sourceAccountName,
|
||||||
'destination_account_id' => intval($destAccountId),
|
'destination_account_id' => intval($destAccountId),
|
||||||
'destination_account_name' => $destAccountName,
|
'destination_account_name' => $destAccountName,
|
||||||
'amount' => round($request->get('amount')[$journal->id], 4),
|
'amount' => round($request->get('amount')[$journal->id], 4),
|
||||||
'amount_currency_id_amount' => intval($request->get('amount_currency_id_amount_' . $journal->id)),
|
'currency_id' => intval($request->get('amount_currency_id_amount_' . $journal->id)),
|
||||||
'date' => new Carbon($request->get('date')[$journal->id]),
|
'date' => new Carbon($request->get('date')[$journal->id]),
|
||||||
'interest_date' => $journal->interest_date,
|
'interest_date' => $journal->interest_date,
|
||||||
'book_date' => $journal->book_date,
|
'book_date' => $journal->book_date,
|
||||||
'process_date' => $journal->process_date,
|
'process_date' => $journal->process_date,
|
||||||
'budget_id' => $budgetId,
|
'budget_id' => $budgetId,
|
||||||
'category' => $category,
|
'category' => $category,
|
||||||
'tags' => $tags,
|
'tags' => $tags,
|
||||||
|
|
||||||
];
|
];
|
||||||
// call repository update function.
|
// call repository update function.
|
||||||
|
@@ -397,6 +397,7 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
if (strlen(trim($name)) > 0) {
|
if (strlen(trim($name)) > 0) {
|
||||||
$tag = Tag::firstOrCreateEncrypted(['tag' => $name, 'user_id' => $journal->user_id]);
|
$tag = Tag::firstOrCreateEncrypted(['tag' => $name, 'user_id' => $journal->user_id]);
|
||||||
if (!is_null($tag)) {
|
if (!is_null($tag)) {
|
||||||
|
Log::debug(sprintf('Will try to connect tag #%d to journal #%d.', $tag->id, $journal->id));
|
||||||
$tagRepository->connect($journal, $tag);
|
$tagRepository->connect($journal, $tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -733,6 +734,7 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
// connect each tag to journal (if not yet connected):
|
// connect each tag to journal (if not yet connected):
|
||||||
/** @var Tag $tag */
|
/** @var Tag $tag */
|
||||||
foreach ($tags as $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);
|
$tagRepository->connect($journal, $tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,18 +49,10 @@
|
|||||||
{{ journal.date.formatLocalized(monthAndDayFormat) }}
|
{{ journal.date.formatLocalized(monthAndDayFormat) }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if journal.source_account_type == 'Cash account' %}
|
{{ sourceAccount(journal)|raw }}
|
||||||
<span class="text-success">(cash)</span>
|
|
||||||
{% else %}
|
|
||||||
<a href="{{ route('accounts.show',journal.source_account_id) }}">{{ journal.source_account_name }}</a>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if journal.destination_account_type == 'Cash account' %}
|
{{ destinationAccount(journal)|raw }}
|
||||||
<span class="text-success">(cash)</span>
|
|
||||||
{% else %}
|
|
||||||
<a href="{{ route('accounts.show',journal.destination_account_id) }}">{{ journal.destination_account_name }}</a>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@@ -90,7 +90,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
{% if journals.count > 0 %}
|
{% 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 %}
|
{% endif %}
|
||||||
<a href="{{ route('index') }}" class="btn-default btn">{{ trans('form.cancel') }}</a>
|
<a href="{{ route('index') }}" class="btn-default btn">{{ trans('form.cancel') }}</a>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user