Fix filters and other methods that used deprecated methods.

This commit is contained in:
James Cole
2016-05-20 08:09:53 +02:00
parent dda3082c7e
commit 70d936bb8f
10 changed files with 81 additions and 18 deletions

View File

@@ -215,6 +215,9 @@ class TagRepository implements TagRepositoryInterface
}
/**
* The incoming journal ($journal)'s accounts (source accounts for a withdrawal, destination accounts for a deposit)
* must match the already existing transaction's accounts exactly.
*
* @param TransactionJournal $journal
* @param Tag $tag
*
@@ -223,16 +226,21 @@ class TagRepository implements TagRepositoryInterface
*/
protected function matchAll(TransactionJournal $journal, Tag $tag): bool
{
$checkSources = join(',', TransactionJournal::sourceAccountList($journal)->pluck('id')->toArray());
$checkDestinations = join(',', TransactionJournal::destinationAccountList($journal)->pluck('id')->toArray());
$match = true;
/** @var TransactionJournal $check */
foreach ($tag->transactionjournals as $check) {
// $checkAccount is the source_account for a withdrawal
// $checkAccount is the destination_account for a deposit
$thisSources = join(',', TransactionJournal::sourceAccountList($check)->pluck('id')->toArray());
$thisDestinations = join(',', TransactionJournal::destinationAccountList($check)->pluck('id')->toArray());
if ($check->isWithdrawal() && TransactionJournal::sourceAccount($check)->id != TransactionJournal::destinationAccount($journal)->id) {
if ($check->isWithdrawal() && $thisSources !== $checkSources) {
$match = false;
}
if ($check->isDeposit() && TransactionJournal::destinationAccount($check)->id != TransactionJournal::destinationAccount($journal)->id) {
if ($check->isDeposit() && $thisDestinations !== $checkDestinations) {
$match = false;
}