mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix #8632
This commit is contained in:
parent
955ab38a85
commit
0597255c08
@ -34,6 +34,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ReconcileController
|
* Class ReconcileController
|
||||||
@ -73,7 +74,6 @@ class ReconcileController extends Controller
|
|||||||
$accountCurrency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
|
$accountCurrency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
|
||||||
$amount = '0';
|
$amount = '0';
|
||||||
$clearedAmount = '0';
|
$clearedAmount = '0';
|
||||||
$route = '';
|
|
||||||
|
|
||||||
if (null === $start && null === $end) {
|
if (null === $start && null === $end) {
|
||||||
throw new FireflyException('Invalid dates submitted.');
|
throw new FireflyException('Invalid dates submitted.');
|
||||||
@ -103,14 +103,11 @@ class ReconcileController extends Controller
|
|||||||
$clearedJournals = $collector->getExtractedJournals();
|
$clearedJournals = $collector->getExtractedJournals();
|
||||||
}
|
}
|
||||||
|
|
||||||
app('log')->debug('Start transaction loop');
|
|
||||||
|
|
||||||
/** @var array $journal */
|
/** @var array $journal */
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$amount = $this->processJournal($account, $accountCurrency, $journal, $amount);
|
$amount = $this->processJournal($account, $accountCurrency, $journal, $amount);
|
||||||
}
|
}
|
||||||
app('log')->debug(sprintf('Final amount is %s', $amount));
|
app('log')->debug(sprintf('Final amount is %s', $amount));
|
||||||
app('log')->debug('End transaction loop');
|
|
||||||
|
|
||||||
/** @var array $journal */
|
/** @var array $journal */
|
||||||
foreach ($clearedJournals as $journal) {
|
foreach ($clearedJournals as $journal) {
|
||||||
@ -118,35 +115,17 @@ class ReconcileController extends Controller
|
|||||||
$clearedAmount = $this->processJournal($account, $accountCurrency, $journal, $clearedAmount);
|
$clearedAmount = $this->processJournal($account, $accountCurrency, $journal, $clearedAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\Log::debug(sprintf('Start balance: "%s"', $startBalance));
|
Log::debug(sprintf('Start balance: "%s"', $startBalance));
|
||||||
\Log::debug(sprintf('End balance: "%s"', $endBalance));
|
Log::debug(sprintf('End balance: "%s"', $endBalance));
|
||||||
\Log::debug(sprintf('Cleared amount: "%s"', $clearedAmount));
|
Log::debug(sprintf('Cleared amount: "%s"', $clearedAmount));
|
||||||
\Log::debug(sprintf('Amount: "%s"', $amount));
|
Log::debug(sprintf('Amount: "%s"', $amount));
|
||||||
$difference = bcadd(bcadd(bcsub($startBalance, $endBalance), $clearedAmount), $amount);
|
$difference = bcadd(bcadd(bcsub($startBalance, $endBalance), $clearedAmount), $amount);
|
||||||
$diffCompare = bccomp($difference, '0');
|
$diffCompare = bccomp($difference, '0');
|
||||||
$countCleared = count($clearedJournals);
|
$countCleared = count($clearedJournals);
|
||||||
|
|
||||||
$reconSum = bcadd(bcadd($startBalance, $amount), $clearedAmount);
|
$reconSum = bcadd(bcadd($startBalance, $amount), $clearedAmount);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$view = view(
|
$view = view('accounts.reconcile.overview', compact('account', 'start', 'diffCompare', 'difference', 'end', 'clearedAmount', 'startBalance', 'endBalance', 'amount', 'route', 'countCleared', 'reconSum', 'selectedIds'))->render();
|
||||||
'accounts.reconcile.overview',
|
|
||||||
compact(
|
|
||||||
'account',
|
|
||||||
'start',
|
|
||||||
'diffCompare',
|
|
||||||
'difference',
|
|
||||||
'end',
|
|
||||||
'clearedAmount',
|
|
||||||
'startBalance',
|
|
||||||
'endBalance',
|
|
||||||
'amount',
|
|
||||||
'route',
|
|
||||||
'countCleared',
|
|
||||||
'reconSum',
|
|
||||||
'selectedIds'
|
|
||||||
)
|
|
||||||
)->render();
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
app('log')->debug(sprintf('View error: %s', $e->getMessage()));
|
app('log')->debug(sprintf('View error: %s', $e->getMessage()));
|
||||||
app('log')->error($e->getTraceAsString());
|
app('log')->error($e->getTraceAsString());
|
||||||
@ -155,10 +134,7 @@ class ReconcileController extends Controller
|
|||||||
throw new FireflyException($view, 0, $e);
|
throw new FireflyException($view, 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = [
|
$return = ['post_url' => $route, 'html' => $view];
|
||||||
'post_url' => $route,
|
|
||||||
'html' => $view,
|
|
||||||
];
|
|
||||||
|
|
||||||
return response()->json($return);
|
return response()->json($return);
|
||||||
}
|
}
|
||||||
|
@ -73,15 +73,17 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
private CurrencyRepositoryInterface $currencyRepository;
|
private CurrencyRepositoryInterface $currencyRepository;
|
||||||
private array $excludeTags;
|
private array $excludeTags;
|
||||||
private array $includeTags;
|
private array $includeTags;
|
||||||
private array $invalidOperators;
|
// added to fix #8632
|
||||||
private int $limit;
|
private array $includeAnyTags;
|
||||||
private Collection $operators;
|
private array $invalidOperators;
|
||||||
private int $page;
|
private int $limit;
|
||||||
private array $prohibitedWords;
|
private Collection $operators;
|
||||||
private float $startTime;
|
private int $page;
|
||||||
private TagRepositoryInterface $tagRepository;
|
private array $prohibitedWords;
|
||||||
private array $validOperators;
|
private float $startTime;
|
||||||
private array $words;
|
private TagRepositoryInterface $tagRepository;
|
||||||
|
private array $validOperators;
|
||||||
|
private array $words;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OperatorQuerySearch constructor.
|
* OperatorQuerySearch constructor.
|
||||||
@ -93,6 +95,7 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$this->page = 1;
|
$this->page = 1;
|
||||||
$this->words = [];
|
$this->words = [];
|
||||||
$this->excludeTags = [];
|
$this->excludeTags = [];
|
||||||
|
$this->includeAnyTags = [];
|
||||||
$this->includeTags = [];
|
$this->includeTags = [];
|
||||||
$this->prohibitedWords = [];
|
$this->prohibitedWords = [];
|
||||||
$this->invalidOperators = [];
|
$this->invalidOperators = [];
|
||||||
@ -1112,8 +1115,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$this->collector->findNothing();
|
$this->collector->findNothing();
|
||||||
}
|
}
|
||||||
if ($tags->count() > 0) {
|
if ($tags->count() > 0) {
|
||||||
$ids = array_values($tags->pluck('id')->toArray());
|
// changed from includeTags to includeAnyTags for #8632
|
||||||
$this->includeTags = array_unique(array_merge($this->includeTags, $ids));
|
$ids = array_values($tags->pluck('id')->toArray());
|
||||||
|
$this->includeAnyTags = array_unique(array_merge($this->includeAnyTags, $ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1125,8 +1129,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$this->collector->findNothing();
|
$this->collector->findNothing();
|
||||||
}
|
}
|
||||||
if ($tags->count() > 0) {
|
if ($tags->count() > 0) {
|
||||||
$ids = array_values($tags->pluck('id')->toArray());
|
// changed from includeTags to includeAnyTags for #8632
|
||||||
$this->includeTags = array_unique(array_merge($this->includeTags, $ids));
|
$ids = array_values($tags->pluck('id')->toArray());
|
||||||
|
$this->includeAnyTags = array_unique(array_merge($this->includeAnyTags, $ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -2725,6 +2730,19 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
}
|
}
|
||||||
$this->collector->setAllTags($collection);
|
$this->collector->setAllTags($collection);
|
||||||
}
|
}
|
||||||
|
// if include ANY tags, include them: (see #8632)
|
||||||
|
if (count($this->includeAnyTags) > 0) {
|
||||||
|
app('log')->debug(sprintf('%d include ANY tag(s)', count($this->includeAnyTags)));
|
||||||
|
$collection = new Collection();
|
||||||
|
foreach ($this->includeAnyTags as $tagId) {
|
||||||
|
$tag = $this->tagRepository->find($tagId);
|
||||||
|
if (null !== $tag) {
|
||||||
|
app('log')->debug(sprintf('Include ANY tag "%s"', $tag->tag));
|
||||||
|
$collection->push($tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->collector->setTags($collection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWords(): array
|
public function getWords(): array
|
||||||
|
Loading…
Reference in New Issue
Block a user