mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-28 09:16:40 -06:00
Various fixes. Sorry, lazy day.
This commit is contained in:
parent
43dbad4e4c
commit
febaab62f7
@ -24,6 +24,8 @@ namespace FireflyIII\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\User;
|
||||
@ -66,7 +68,9 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
return $this->handleGroup($request, $exception);
|
||||
break;
|
||||
case 'attachments.show':
|
||||
return redirect(route('index'));
|
||||
case 'attachments.edit':
|
||||
// redirect to original attachment holder.
|
||||
return $this->handleAttachment($request, $exception);
|
||||
break;
|
||||
case 'bills.show':
|
||||
$request->session()->reflash();
|
||||
@ -145,6 +149,44 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
return redirect(route('accounts.index', [$shortType]));
|
||||
}
|
||||
|
||||
private function handleAttachment(Request $request, Exception $exception)
|
||||
{
|
||||
Log::debug('404 page is probably a deleted attachment. Redirect to parent object.');
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$route = $request->route();
|
||||
$attachmentId = (int)$route->parameter('attachment');
|
||||
/** @var Attachment $attachment */
|
||||
$attachment = $user->attachments()->withTrashed()->find($attachmentId);
|
||||
if (null === $attachment) {
|
||||
Log::error(sprintf('Could not find attachment %d, so give big fat error.', $attachmentId));
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
// get bindable.
|
||||
if (TransactionJournal::class === $attachment->attachable_type) {
|
||||
// is linked to journal, get group of journal (if not also deleted)
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $user->transactionJournals()->withTrashed()->find($attachment->attachable_id);
|
||||
if (null !== $journal) {
|
||||
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||
}
|
||||
|
||||
}
|
||||
if (Bill::class === $attachment->attachable_type) {
|
||||
// is linked to bill.
|
||||
/** @var Bill $bill */
|
||||
$bill = $user->bills()->withTrashed()->find($attachment->attachable_id);
|
||||
if (null !== $bill) {
|
||||
return redirect(route('bills.show', [$bill->id]));
|
||||
}
|
||||
}
|
||||
|
||||
Log::error(sprintf('Could not redirect attachment %d, its linked to a %s.', $attachmentId, $attachment->attachable_type));
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $request
|
||||
* @param Exception $exception
|
||||
|
@ -70,7 +70,6 @@ class TagFactory
|
||||
'longitude' => $longitude,
|
||||
'zoomLevel' => $zoomLevel,
|
||||
];
|
||||
|
||||
return Tag::create($array);
|
||||
}
|
||||
|
||||
@ -85,7 +84,7 @@ class TagFactory
|
||||
|
||||
/** @var Tag $dbTag */
|
||||
$dbTag = $this->user->tags()->where('tag', $tag)->first();
|
||||
if (null !== $tag) {
|
||||
if (null !== $dbTag) {
|
||||
return $dbTag;
|
||||
}
|
||||
$newTag = $this->create(
|
||||
|
@ -205,12 +205,12 @@ class ReconcileController extends Controller
|
||||
$inverse = true;
|
||||
}
|
||||
|
||||
// reconciliation into account? then positive amount:
|
||||
if (TransactionType::RECONCILIATION === $journal['transaction_type_type']) {
|
||||
// opening balance into account? then positive amount:
|
||||
if (TransactionType::OPENING_BALANCE === $journal['transaction_type_type']
|
||||
&& $account->id === $journal['destination_account_id']) {
|
||||
$inverse = true;
|
||||
}
|
||||
|
||||
|
||||
if (true === $inverse) {
|
||||
$journal['amount'] = app('steam')->positive($journal['amount']);
|
||||
if (null !== $journal['foreign_amount']) {
|
||||
|
@ -73,6 +73,8 @@ class BulkController extends Controller
|
||||
{
|
||||
$subTitle = (string)trans('firefly.mass_bulk_journals');
|
||||
|
||||
$this->rememberPreviousUri('transactions.bulk-edit.uri');
|
||||
|
||||
// make amounts positive.
|
||||
|
||||
// get list of budgets:
|
||||
@ -127,8 +129,9 @@ class BulkController extends Controller
|
||||
* @param array $tags
|
||||
* @return bool
|
||||
*/
|
||||
public function updateJournalTags(TransactionJournal $journal, bool $ignoreUpdate, array $tags): bool
|
||||
private function updateJournalTags(TransactionJournal $journal, bool $ignoreUpdate, array $tags): bool
|
||||
{
|
||||
|
||||
if (true === $ignoreUpdate) {
|
||||
return false;
|
||||
}
|
||||
|
@ -269,6 +269,7 @@ trait JournalServiceTrait
|
||||
*/
|
||||
protected function storeTags(TransactionJournal $journal, ?array $tags): void
|
||||
{
|
||||
|
||||
$this->tagFactory->setUser($journal->user);
|
||||
$set = [];
|
||||
if (!is_array($tags)) {
|
||||
|
@ -165,6 +165,7 @@ class JournalUpdateService
|
||||
$this->storeBudget($this->transactionJournal, new NullArrayObject($this->data));
|
||||
}
|
||||
// update tags
|
||||
|
||||
if ($this->hasFields(['tags'])) {
|
||||
Log::debug('Will update tags.');
|
||||
$tags = $this->data['tags'] ?? null;
|
||||
|
@ -134,9 +134,22 @@ class LineReader
|
||||
$results = $stmt->process($reader);
|
||||
$lines = [];
|
||||
foreach ($results as $line) {
|
||||
$lines[] = array_values($line);
|
||||
|
||||
$lineValues = array_values($line);
|
||||
|
||||
// do a first sanity check on whatever comes out of the CSV file.
|
||||
array_walk(
|
||||
$lineValues, static function ($element) {
|
||||
$element = str_replace(' ', ' ', (string)$element);
|
||||
|
||||
return $element;
|
||||
}
|
||||
);
|
||||
|
||||
$lines[] = $lineValues;
|
||||
}
|
||||
|
||||
|
||||
return $lines;
|
||||
}
|
||||
|
||||
|
57797
public/v1/js/app.js
57797
public/v1/js/app.js
File diff suppressed because one or more lines are too long
@ -354,6 +354,7 @@
|
||||
},
|
||||
processIncomingGroupRow(transaction) {
|
||||
console.log(transaction);
|
||||
this.setTransactionType(transaction.type);
|
||||
this.transactions.push({
|
||||
description: transaction.description,
|
||||
date: transaction.date.substr(0, 10),
|
||||
|
Loading…
Reference in New Issue
Block a user