Code cleanup that (hopefully) matches style CI

This commit is contained in:
James Cole
2020-03-17 14:57:04 +01:00
parent b0c9fc0792
commit bd2f064eeb
30 changed files with 318 additions and 298 deletions

View File

@@ -20,6 +20,7 @@
*/
namespace FireflyIII\Exceptions;
use Exception;
/**
@@ -27,5 +28,4 @@ use Exception;
*/
class DuplicateTransactionException extends Exception
{
}

View File

@@ -28,6 +28,7 @@ use Exception;
/**
* Class FireflyException.
*
* @codeCoverageIgnore
*/
class FireflyException extends Exception

View File

@@ -33,8 +33,11 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\User;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Log;
use Symfony\Component\HttpFoundation\Response;
/**
* Class GracefulNotFoundHandler
@@ -134,7 +137,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
* @param Request $request
* @param Exception $exception
*
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
* @return \Illuminate\Http\Response|Response
*/
private function handleAccount($request, Exception $exception)
{
@@ -199,7 +202,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
* @param $request
* @param Exception $exception
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Routing\Redirector|\Symfony\Component\HttpFoundation\Response
* @return RedirectResponse|\Illuminate\Http\Response|Redirector|Response
*/
private function handleGroup($request, Exception $exception)
{

View File

@@ -82,7 +82,8 @@ class Handler extends ExceptionHandler
'line' => $exception->getLine(),
'file' => $exception->getFile(),
'trace' => $exception->getTrace(),
], 500
],
500
);
}
@@ -91,6 +92,7 @@ class Handler extends ExceptionHandler
if ($exception instanceof NotFoundHttpException) {
$handler = app(GracefulNotFoundHandler::class);
return $handler->render($request, $exception);
}
@@ -113,13 +115,12 @@ class Handler extends ExceptionHandler
*
* @param Exception $exception
*
* @throws Exception
* @return mixed|void
*
* @throws Exception
*/
public function report(Exception $exception)
{
$doMailError = config('firefly.send_error_message');
// if the user wants us to mail:
if (true === $doMailError

View File

@@ -28,6 +28,7 @@ use Exception;
/**
* Class NotImplementedException.
*
* @codeCoverageIgnore
*/
class NotImplementedException extends Exception

View File

@@ -28,6 +28,7 @@ use Exception;
/**
* Class ValidationExceptions.
*
* @codeCoverageIgnore
*/
class ValidationException extends Exception

View File

@@ -27,7 +27,6 @@ namespace FireflyIII\Factory;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Location;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Services\Internal\Support\AccountServiceTrait;
use FireflyIII\Services\Internal\Support\LocationServiceTrait;
@@ -45,18 +44,16 @@ class AccountFactory
/** @var AccountRepositoryInterface */
protected $accountRepository;
/** @var User */
private $user;
/** @var array */
private $canHaveVirtual;
/** @var array */
protected $validAssetFields = ['account_role', 'account_number', 'currency_id', 'BIC', 'include_net_worth'];
/** @var array */
protected $validCCFields = ['account_role', 'cc_monthly_payment_date', 'cc_type', 'account_number', 'currency_id', 'BIC', 'include_net_worth'];
/** @var array */
protected $validFields = ['account_number', 'currency_id', 'BIC', 'interest', 'interest_period', 'include_net_worth'];
/** @var array */
private $canHaveVirtual;
/** @var User */
private $user;
/**
* AccountFactory constructor.
@@ -75,8 +72,8 @@ class AccountFactory
/**
* @param array $data
*
* @return Account
* @throws FireflyException
* @return Account
*/
public function create(array $data): Account
{
@@ -159,8 +156,8 @@ class AccountFactory
* @param string $accountName
* @param string $accountType
*
* @return Account
* @throws FireflyException
* @return Account
*/
public function findOrCreate(string $accountName, string $accountType): Account
{

View File

@@ -36,6 +36,7 @@ class AccountMetaFactory
{
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()

View File

@@ -41,6 +41,7 @@ class AttachmentFactory
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
@@ -53,8 +54,8 @@ class AttachmentFactory
/**
* @param array $data
*
* @return Attachment|null
* @throws FireflyException
* @return Attachment|null
*/
public function create(array $data): ?Attachment
{

View File

@@ -44,6 +44,7 @@ class BillFactory
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
@@ -56,8 +57,8 @@ class BillFactory
/**
* @param array $data
*
* @return Bill|null
* @throws FireflyException
* @return Bill|null
*/
public function create(array $data): ?Bill
{

View File

@@ -38,6 +38,7 @@ class BudgetFactory
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()

View File

@@ -40,6 +40,7 @@ class CategoryFactory
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
@@ -63,8 +64,8 @@ class CategoryFactory
* @param int|null $categoryId
* @param null|string $categoryName
*
* @return Category|null
* @throws FireflyException
* @return Category|null
*/
public function findOrCreate(?int $categoryId, ?string $categoryName): ?Category
{

View File

@@ -39,6 +39,7 @@ class PiggyBankEventFactory
{
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
@@ -60,6 +61,7 @@ class PiggyBankEventFactory
Log::debug(sprintf('Now in PiggyBankEventCreate for a %s', $journal->transactionType->type));
if (null === $piggyBank) {
Log::debug('Piggy bank is null');
return null;
}

View File

@@ -38,6 +38,7 @@ class PiggyBankFactory
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()

View File

@@ -39,16 +39,16 @@ use Log;
*/
class RecurrenceFactory
{
/** @var User */
private $user;
/** @var MessageBag */
private $errors;
/** @var User */
private $user;
use TransactionTypeTrait, RecurringTransactionTrait;
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
@@ -62,8 +62,8 @@ class RecurrenceFactory
/**
* @param array $data
*
* @return Recurrence
* @throws FireflyException
* @return Recurrence
*/
public function create(array $data): Recurrence
{

View File

@@ -42,6 +42,7 @@ class TagFactory
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()

View File

@@ -52,8 +52,8 @@ class TransactionCurrencyFactory
/**
* @param array $data
*
* @return TransactionCurrency
* @throws FireflyException
* @return TransactionCurrency
*/
public function create(array $data): TransactionCurrency
{

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Factory;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
@@ -39,21 +38,22 @@ use Log;
*/
class TransactionFactory
{
/** @var TransactionJournal */
private $journal;
/** @var Account */
private $account;
/** @var TransactionCurrency */
private $currency;
/** @var TransactionCurrency */
private $foreignCurrency;
/** @var User */
private $user;
/** @var TransactionJournal */
private $journal;
/** @var bool */
private $reconciled;
/** @var User */
private $user;
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
@@ -64,50 +64,14 @@ class TransactionFactory
$this->reconciled = false;
}
/**
* @param bool $reconciled
* @codeCoverageIgnore
*/
public function setReconciled(bool $reconciled): void
{
$this->reconciled = $reconciled;
}
/**
* @param Account $account
* @codeCoverageIgnore
*/
public function setAccount(Account $account): void
{
$this->account = $account;
}
/**
* @param TransactionCurrency $currency
* @codeCoverageIgnore
*/
public function setCurrency(TransactionCurrency $currency): void
{
$this->currency = $currency;
}
/**
* @param TransactionCurrency $foreignCurrency |null
* @codeCoverageIgnore
*/
public function setForeignCurrency(?TransactionCurrency $foreignCurrency): void
{
$this->foreignCurrency = $foreignCurrency;
}
/**
* Create transaction with negative amount (for source accounts).
*
* @param string $amount
* @param string|null $foreignAmount
*
* @return Transaction
* @throws FireflyException
* @return Transaction
*/
public function createNegative(string $amount, ?string $foreignAmount): Transaction
{
@@ -127,8 +91,8 @@ class TransactionFactory
* @param string $amount
* @param string|null $foreignAmount
*
* @return Transaction
* @throws FireflyException
* @return Transaction
*/
public function createPositive(string $amount, ?string $foreignAmount): Transaction
{
@@ -138,12 +102,43 @@ class TransactionFactory
if (null !== $foreignAmount) {
$foreignAmount = app('steam')->positive($foreignAmount);
}
return $this->create(app('steam')->positive($amount), $foreignAmount);
}
/**
* @param Account $account
*
* @codeCoverageIgnore
*/
public function setAccount(Account $account): void
{
$this->account = $account;
}
/**
* @param TransactionCurrency $currency
*
* @codeCoverageIgnore
*/
public function setCurrency(TransactionCurrency $currency): void
{
$this->currency = $currency;
}
/**
* @param TransactionCurrency $foreignCurrency |null
*
* @codeCoverageIgnore
*/
public function setForeignCurrency(?TransactionCurrency $foreignCurrency): void
{
$this->foreignCurrency = $foreignCurrency;
}
/**
* @param TransactionJournal $journal
*
* @codeCoverageIgnore
*/
public function setJournal(TransactionJournal $journal): void
@@ -151,8 +146,19 @@ class TransactionFactory
$this->journal = $journal;
}
/**
* @param bool $reconciled
*
* @codeCoverageIgnore
*/
public function setReconciled(bool $reconciled): void
{
$this->reconciled = $reconciled;
}
/**
* @param User $user
*
* @codeCoverageIgnore
*/
public function setUser(User $user): void
@@ -164,8 +170,8 @@ class TransactionFactory
* @param string $amount
* @param string|null $foreignAmount
*
* @return Transaction
* @throws FireflyException
* @return Transaction
*/
private function create(string $amount, ?string $foreignAmount): Transaction
{
@@ -200,7 +206,11 @@ class TransactionFactory
if (null !== $result) {
Log::debug(
sprintf(
'Created transaction #%d (%s %s, account %s), part of journal #%d', $result->id, $this->currency->code, $amount, $this->account->name,
'Created transaction #%d (%s %s, account %s), part of journal #%d',
$result->id,
$this->currency->code,
$amount,
$this->account->name,
$this->journal->id
)
);
@@ -209,7 +219,6 @@ class TransactionFactory
if (null !== $this->foreignCurrency && null !== $foreignAmount && $this->foreignCurrency->id !== $this->currency->id && '' !== $foreignAmount) {
$result->foreign_currency_id = $this->foreignCurrency->id;
$result->foreign_amount = $foreignAmount;
}
$result->save();
}

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Factory;
use FireflyIII\Exceptions\DuplicateTransactionException;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\User;
use Log;
@@ -54,8 +53,8 @@ class TransactionGroupFactory
*
* @param array $data
*
* @return TransactionGroup
* @throws DuplicateTransactionException
* @return TransactionGroup
*/
public function create(array $data): TransactionGroup
{

View File

@@ -64,6 +64,8 @@ class TransactionJournalFactory
private $billRepository;
/** @var CurrencyRepositoryInterface */
private $currencyRepository;
/** @var bool */
private $errorOnHash;
/** @var array */
private $fields;
/** @var PiggyBankEventFactory */
@@ -76,8 +78,6 @@ class TransactionJournalFactory
private $typeRepository;
/** @var User The user */
private $user;
/** @var bool */
private $errorOnHash;
/**
* Constructor.
@@ -125,9 +125,9 @@ class TransactionJournalFactory
*
* @param array $data
*
* @return Collection
* @throws DuplicateTransactionException
* @throws FireflyException
* @return Collection
*/
public function create(array $data): Collection
{
@@ -171,6 +171,17 @@ class TransactionJournalFactory
return $collection;
}
/**
* @param bool $errorOnHash
*/
public function setErrorOnHash(bool $errorOnHash): void
{
$this->errorOnHash = $errorOnHash;
if (true === $errorOnHash) {
Log::info('Will trigger duplication alert for this journal.');
}
}
/**
* Set the user.
*
@@ -212,9 +223,9 @@ class TransactionJournalFactory
/**
* @param NullArrayObject $row
*
* @return TransactionJournal|null
* @throws FireflyException
* @throws DuplicateTransactionException
* @return TransactionJournal|null
*/
private function createJournal(NullArrayObject $row): ?TransactionJournal
{
@@ -584,16 +595,5 @@ class TransactionJournalFactory
}
}
/**
* @param bool $errorOnHash
*/
public function setErrorOnHash(bool $errorOnHash): void
{
$this->errorOnHash = $errorOnHash;
if (true === $errorOnHash) {
Log::info('Will trigger duplication alert for this journal.');
}
}
}

View File

@@ -36,6 +36,7 @@ class TransactionJournalMetaFactory
{
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()

View File

@@ -35,6 +35,7 @@ class TransactionTypeFactory
{
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()

View File

@@ -51,9 +51,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Generates the report.
*
* @return string
* @throws FireflyException
* @codeCoverageIgnore
* @return string
*/
public function generate(): string
{
@@ -100,9 +100,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
* @param Account $account
* @param Carbon $date
*
* @throws FireflyException
* @return array
*
* @throws FireflyException
*/
public function getAuditReport(Account $account, Carbon $date): array
{

View File

@@ -39,9 +39,9 @@ class ReportGeneratorFactory
* @param Carbon $start
* @param Carbon $end
*
* @throws FireflyException
* @return ReportGeneratorInterface
*
* @throws FireflyException
*/
public static function reportGenerator(string $type, Carbon $start, Carbon $end): ReportGeneratorInterface
{

View File

@@ -76,7 +76,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
// render!
try {
$result = view(
'reports.tag.month', compact('accountIds', 'reportType', 'tagIds')
'reports.tag.month',
compact('accountIds', 'reportType', 'tagIds')
)->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage()));
@@ -177,6 +178,4 @@ class MonthReportGenerator implements ReportGeneratorInterface
return $this;
}
}

View File

@@ -58,10 +58,12 @@ class GroupCollector implements GroupCollectorInterface
private $hasBudgetInformation;
/** @var bool Will be true if query result contains category info. */
private $hasCatInformation;
/** @var bool Will be true of the query has the tag info tables joined. */
private $hasJoinedTagTables;
/** @var bool Will be true for attachments */
private $hasJoinedAttTables;
/** @var bool Will be true of the query has the tag info tables joined. */
private $hasJoinedTagTables;
/** @var array */
private $integerFields;
/** @var int The maximum number of results. */
private $limit;
/** @var int The page to return. */
@@ -72,8 +74,6 @@ class GroupCollector implements GroupCollectorInterface
private $total;
/** @var User The user object. */
private $user;
/** @var array */
private $integerFields;
/**
* Group collector constructor.
@@ -210,7 +210,6 @@ class GroupCollector implements GroupCollectorInterface
*/
public function dumpQuery(): void
{
echo $this->query->toSql();
echo '<pre>';
print_r($this->query->getBindings());
@@ -304,7 +303,6 @@ class GroupCollector implements GroupCollectorInterface
}
return $collection;
}
/**
@@ -510,6 +508,24 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
/**
* Collect transactions created on a specific date.
*
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
public function setCreatedAt(Carbon $date): GroupCollectorInterface
{
$after = $date->format('Y-m-d 00:00:00');
$before = $date->format('Y-m-d 23:59:59');
$this->query->where('transaction_journals.created_at', '>=', $after);
$this->query->where('transaction_journals.created_at', '<=', $before);
Log::debug(sprintf('GroupCollector created_at is now after %s (inclusive)', $after));
return $this;
}
/**
* Limit results to a specific currency, either foreign or normal one.
*
@@ -742,6 +758,24 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
/**
* Collect transactions updated on a specific date.
*
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
public function setUpdatedAt(Carbon $date): GroupCollectorInterface
{
$after = $date->format('Y-m-d 00:00:00');
$before = $date->format('Y-m-d 23:59:59');
$this->query->where('transaction_journals.updated_at', '>=', $after);
$this->query->where('transaction_journals.updated_at', '<=', $before);
Log::debug(sprintf('GroupCollector created_at is now after %s (inclusive)', $after));
return $this;
}
/**
* Set the user object and start the query.
*
@@ -757,6 +791,43 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
/**
* Either account can be set, but NOT both. This effectively excludes internal transfers.
*
* @param Collection $accounts
*
* @return GroupCollectorInterface
*/
public function setXorAccounts(Collection $accounts): GroupCollectorInterface
{
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
static function (EloquentBuilder $q1) use ($accountIds) {
// sourceAccount is in the set, and destination is NOT.
$q1->where(
static function (EloquentBuilder $q2) use ($accountIds) {
$q2->whereIn('source.account_id', $accountIds);
$q2->whereNotIn('destination.account_id', $accountIds);
}
);
// destination is in the set, and source is NOT
$q1->orWhere(
static function (EloquentBuilder $q3) use ($accountIds) {
$q3->whereNotIn('source.account_id', $accountIds);
$q3->whereIn('destination.account_id', $accountIds);
}
);
}
);
app('log')->debug(sprintf('GroupCollector: setXorAccounts: %s', implode(', ', $accountIds)));
}
return $this;
}
/**
* Automatically include all stuff required to make API calls work.
*
@@ -810,6 +881,17 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
/**
* @inheritDoc
*/
public function withAttachmentInformation(): GroupCollectorInterface
{
$this->fields[] = 'attachments.id as attachment_id';
$this->joinAttachmentTables();
return $this;
}
/**
* Will include bill name + ID, if any.
*
@@ -939,19 +1021,6 @@ class GroupCollector implements GroupCollectorInterface
return $array;
}
/**
* Join table to get tag information.
*/
private function joinTagTables(): void
{
if (false === $this->hasJoinedTagTables) {
// join some extra tables:
$this->hasJoinedTagTables = true;
$this->query->leftJoin('tag_transaction_journal', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id');
$this->query->leftJoin('tags', 'tag_transaction_journal.tag_id', '=', 'tags.id');
}
}
/**
* Join table to get attachment information.
*/
@@ -970,6 +1039,38 @@ class GroupCollector implements GroupCollectorInterface
}
}
/**
* Join table to get tag information.
*/
private function joinTagTables(): void
{
if (false === $this->hasJoinedTagTables) {
// join some extra tables:
$this->hasJoinedTagTables = true;
$this->query->leftJoin('tag_transaction_journal', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id');
$this->query->leftJoin('tags', 'tag_transaction_journal.tag_id', '=', 'tags.id');
}
}
/**
* @param array $existingJournal
* @param TransactionJournal $newJournal
*
* @return array
*/
private function mergeAttachments(array $existingJournal, TransactionJournal $newJournal): array
{
$newArray = $newJournal->toArray();
if (isset($newArray['attachment_id'])) {
$attachmentId = (int) $newJournal['tag_id'];
$existingJournal['attachments'][$attachmentId] = [
'id' => $attachmentId,
];
}
return $existingJournal;
}
/**
* @param array $existingJournal
* @param TransactionJournal $newJournal
@@ -1000,26 +1101,6 @@ class GroupCollector implements GroupCollectorInterface
return $existingJournal;
}
/**
* @param array $existingJournal
* @param TransactionJournal $newJournal
*
* @return array
*/
private function mergeAttachments(array $existingJournal, TransactionJournal $newJournal): array
{
$newArray = $newJournal->toArray();
if (isset($newArray['attachment_id'])) {
$attachmentId = (int)$newJournal['tag_id'];
$existingJournal['attachments'][$attachmentId] = [
'id' => $attachmentId,
];
}
return $existingJournal;
}
/**
* @param Collection $collection
*
@@ -1063,8 +1144,6 @@ class GroupCollector implements GroupCollectorInterface
// create second, third, fourth split:
$groups[$groupId]['transactions'][$journalId] = $this->parseAugmentedJournal($augumentedJournal);
}
}
$groups = $this->parseSums($groups);
@@ -1160,7 +1239,8 @@ class GroupCollector implements GroupCollectorInterface
$groups[$groudId]['sums'][$currencyId]['amount'] = '0';
}
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd(
$groups[$groudId]['sums'][$currencyId]['amount'], $transaction['foreign_amount'] ?? '0'
$groups[$groudId]['sums'][$currencyId]['amount'],
$transaction['foreign_amount'] ?? '0'
);
}
}
@@ -1183,14 +1263,16 @@ class GroupCollector implements GroupCollectorInterface
// join source transaction.
->leftJoin(
'transactions as source', function (JoinClause $join) {
'transactions as source',
function (JoinClause $join) {
$join->on('source.transaction_journal_id', '=', 'transaction_journals.id')
->where('source.amount', '<', 0);
}
)
// join destination transaction
->leftJoin(
'transactions as destination', function (JoinClause $join) {
'transactions as destination',
function (JoinClause $join) {
$join->on('destination.transaction_journal_id', '=', 'transaction_journals.id')
->where('destination.amount', '>', 0);
}
@@ -1209,88 +1291,4 @@ class GroupCollector implements GroupCollectorInterface
->orderBy('transaction_journals.description', 'DESC')
->orderBy('source.amount', 'DESC');
}
/**
* Either account can be set, but NOT both. This effectively excludes internal transfers.
*
* @param Collection $accounts
*
* @return GroupCollectorInterface
*/
public function setXorAccounts(Collection $accounts): GroupCollectorInterface
{
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
static function (EloquentBuilder $q1) use ($accountIds) {
// sourceAccount is in the set, and destination is NOT.
$q1->where(
static function (EloquentBuilder $q2) use ($accountIds) {
$q2->whereIn('source.account_id', $accountIds);
$q2->whereNotIn('destination.account_id', $accountIds);
}
);
// destination is in the set, and source is NOT
$q1->orWhere(
static function (EloquentBuilder $q3) use ($accountIds) {
$q3->whereNotIn('source.account_id', $accountIds);
$q3->whereIn('destination.account_id', $accountIds);
}
);
}
);
app('log')->debug(sprintf('GroupCollector: setXorAccounts: %s', implode(', ', $accountIds)));
}
return $this;
}
/**
* Collect transactions created on a specific date.
*
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
public function setCreatedAt(Carbon $date): GroupCollectorInterface
{
$after = $date->format('Y-m-d 00:00:00');
$before = $date->format('Y-m-d 23:59:59');
$this->query->where('transaction_journals.created_at', '>=', $after);
$this->query->where('transaction_journals.created_at', '<=', $before);
Log::debug(sprintf('GroupCollector created_at is now after %s (inclusive)', $after));
return $this;
}
/**
* Collect transactions updated on a specific date.
*
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
public function setUpdatedAt(Carbon $date): GroupCollectorInterface
{
$after = $date->format('Y-m-d 00:00:00');
$before = $date->format('Y-m-d 23:59:59');
$this->query->where('transaction_journals.updated_at', '>=', $after);
$this->query->where('transaction_journals.updated_at', '<=', $before);
Log::debug(sprintf('GroupCollector created_at is now after %s (inclusive)', $after));
return $this;
}
/**
* @inheritDoc
*/
public function withAttachmentInformation(): GroupCollectorInterface
{
$this->fields[] = 'attachments.id as attachment_id';
$this->joinAttachmentTables();
return $this;
}
}