mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -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 Exception;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
|
use FireflyIII\Models\Attachment;
|
||||||
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Models\TransactionGroup;
|
use FireflyIII\Models\TransactionGroup;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
@ -66,7 +68,9 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
|||||||
return $this->handleGroup($request, $exception);
|
return $this->handleGroup($request, $exception);
|
||||||
break;
|
break;
|
||||||
case 'attachments.show':
|
case 'attachments.show':
|
||||||
return redirect(route('index'));
|
case 'attachments.edit':
|
||||||
|
// redirect to original attachment holder.
|
||||||
|
return $this->handleAttachment($request, $exception);
|
||||||
break;
|
break;
|
||||||
case 'bills.show':
|
case 'bills.show':
|
||||||
$request->session()->reflash();
|
$request->session()->reflash();
|
||||||
@ -145,6 +149,44 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
|||||||
return redirect(route('accounts.index', [$shortType]));
|
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 $request
|
||||||
* @param Exception $exception
|
* @param Exception $exception
|
||||||
|
@ -70,7 +70,6 @@ class TagFactory
|
|||||||
'longitude' => $longitude,
|
'longitude' => $longitude,
|
||||||
'zoomLevel' => $zoomLevel,
|
'zoomLevel' => $zoomLevel,
|
||||||
];
|
];
|
||||||
|
|
||||||
return Tag::create($array);
|
return Tag::create($array);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +84,7 @@ class TagFactory
|
|||||||
|
|
||||||
/** @var Tag $dbTag */
|
/** @var Tag $dbTag */
|
||||||
$dbTag = $this->user->tags()->where('tag', $tag)->first();
|
$dbTag = $this->user->tags()->where('tag', $tag)->first();
|
||||||
if (null !== $tag) {
|
if (null !== $dbTag) {
|
||||||
return $dbTag;
|
return $dbTag;
|
||||||
}
|
}
|
||||||
$newTag = $this->create(
|
$newTag = $this->create(
|
||||||
|
@ -205,12 +205,12 @@ class ReconcileController extends Controller
|
|||||||
$inverse = true;
|
$inverse = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reconciliation into account? then positive amount:
|
// opening balance into account? then positive amount:
|
||||||
if (TransactionType::RECONCILIATION === $journal['transaction_type_type']) {
|
if (TransactionType::OPENING_BALANCE === $journal['transaction_type_type']
|
||||||
|
&& $account->id === $journal['destination_account_id']) {
|
||||||
$inverse = true;
|
$inverse = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (true === $inverse) {
|
if (true === $inverse) {
|
||||||
$journal['amount'] = app('steam')->positive($journal['amount']);
|
$journal['amount'] = app('steam')->positive($journal['amount']);
|
||||||
if (null !== $journal['foreign_amount']) {
|
if (null !== $journal['foreign_amount']) {
|
||||||
|
@ -73,6 +73,8 @@ class BulkController extends Controller
|
|||||||
{
|
{
|
||||||
$subTitle = (string)trans('firefly.mass_bulk_journals');
|
$subTitle = (string)trans('firefly.mass_bulk_journals');
|
||||||
|
|
||||||
|
$this->rememberPreviousUri('transactions.bulk-edit.uri');
|
||||||
|
|
||||||
// make amounts positive.
|
// make amounts positive.
|
||||||
|
|
||||||
// get list of budgets:
|
// get list of budgets:
|
||||||
@ -127,8 +129,9 @@ class BulkController extends Controller
|
|||||||
* @param array $tags
|
* @param array $tags
|
||||||
* @return bool
|
* @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) {
|
if (true === $ignoreUpdate) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -269,6 +269,7 @@ trait JournalServiceTrait
|
|||||||
*/
|
*/
|
||||||
protected function storeTags(TransactionJournal $journal, ?array $tags): void
|
protected function storeTags(TransactionJournal $journal, ?array $tags): void
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->tagFactory->setUser($journal->user);
|
$this->tagFactory->setUser($journal->user);
|
||||||
$set = [];
|
$set = [];
|
||||||
if (!is_array($tags)) {
|
if (!is_array($tags)) {
|
||||||
|
@ -165,6 +165,7 @@ class JournalUpdateService
|
|||||||
$this->storeBudget($this->transactionJournal, new NullArrayObject($this->data));
|
$this->storeBudget($this->transactionJournal, new NullArrayObject($this->data));
|
||||||
}
|
}
|
||||||
// update tags
|
// update tags
|
||||||
|
|
||||||
if ($this->hasFields(['tags'])) {
|
if ($this->hasFields(['tags'])) {
|
||||||
Log::debug('Will update tags.');
|
Log::debug('Will update tags.');
|
||||||
$tags = $this->data['tags'] ?? null;
|
$tags = $this->data['tags'] ?? null;
|
||||||
|
@ -134,8 +134,21 @@ class LineReader
|
|||||||
$results = $stmt->process($reader);
|
$results = $stmt->process($reader);
|
||||||
$lines = [];
|
$lines = [];
|
||||||
foreach ($results as $line) {
|
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;
|
return $lines;
|
||||||
}
|
}
|
||||||
|
57797
public/v1/js/app.js
vendored
57797
public/v1/js/app.js
vendored
File diff suppressed because one or more lines are too long
@ -354,6 +354,7 @@
|
|||||||
},
|
},
|
||||||
processIncomingGroupRow(transaction) {
|
processIncomingGroupRow(transaction) {
|
||||||
console.log(transaction);
|
console.log(transaction);
|
||||||
|
this.setTransactionType(transaction.type);
|
||||||
this.transactions.push({
|
this.transactions.push({
|
||||||
description: transaction.description,
|
description: transaction.description,
|
||||||
date: transaction.date.substr(0, 10),
|
date: transaction.date.substr(0, 10),
|
||||||
|
Loading…
Reference in New Issue
Block a user