chore: reformat code.

This commit is contained in:
James Cole
2023-06-21 12:34:58 +02:00
parent 8d87abde64
commit 3dcb35710b
799 changed files with 23319 additions and 22173 deletions

View File

@@ -36,7 +36,7 @@ trait AccountCollection
/**
* These accounts must not be included.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return GroupCollectorInterface
*/
@@ -56,7 +56,7 @@ trait AccountCollection
/**
* These accounts must not be destination accounts.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return GroupCollectorInterface
*/
@@ -75,7 +75,7 @@ trait AccountCollection
/**
* These accounts must not be source accounts.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return GroupCollectorInterface
*/
@@ -94,7 +94,7 @@ trait AccountCollection
/**
* Define which accounts can be part of the source and destination transactions.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return GroupCollectorInterface
*/
@@ -117,7 +117,7 @@ trait AccountCollection
/**
* Both source AND destination must be in this list of accounts.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return GroupCollectorInterface
*/
@@ -140,7 +140,7 @@ trait AccountCollection
/**
* Define which accounts can be part of the source and destination transactions.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return GroupCollectorInterface
*/
@@ -159,7 +159,7 @@ trait AccountCollection
/**
* Define which accounts can NOT be part of the source and destination transactions.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return GroupCollectorInterface
*/
@@ -182,7 +182,7 @@ trait AccountCollection
/**
* Define which accounts can be part of the source and destination transactions.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return GroupCollectorInterface
*/
@@ -201,7 +201,7 @@ trait AccountCollection
/**
* Either account can be set, but NOT both. This effectively excludes internal transfers.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return GroupCollectorInterface
*/

View File

@@ -35,7 +35,7 @@ trait AmountCollection
/**
* Get transactions with a specific amount.
*
* @param string $amount
* @param string $amount
*
* @return GroupCollectorInterface
*/
@@ -67,7 +67,7 @@ trait AmountCollection
/**
* Get transactions where the amount is less than.
*
* @param string $amount
* @param string $amount
*
* @return GroupCollectorInterface
*/
@@ -85,7 +85,7 @@ trait AmountCollection
/**
* Get transactions where the amount is more than.
*
* @param string $amount
* @param string $amount
*
* @return GroupCollectorInterface
*/
@@ -103,7 +103,7 @@ trait AmountCollection
/**
* Get transactions with a specific foreign amount.
*
* @param string $amount
* @param string $amount
*
* @return GroupCollectorInterface
*/
@@ -122,7 +122,7 @@ trait AmountCollection
/**
* Get transactions with a specific foreign amount.
*
* @param string $amount
* @param string $amount
*
* @return GroupCollectorInterface
*/
@@ -141,7 +141,7 @@ trait AmountCollection
/**
* Get transactions where the amount is less than.
*
* @param string $amount
* @param string $amount
*
* @return GroupCollectorInterface
*/
@@ -160,7 +160,7 @@ trait AmountCollection
/**
* Get transactions where the amount is more than.
*
* @param string $amount
* @param string $amount
*
* @return GroupCollectorInterface
*/

View File

@@ -37,7 +37,7 @@ use Illuminate\Support\Facades\Log;
trait AttachmentCollection
{
/**
* @param string $name
* @param string $name
* @return GroupCollectorInterface
*/
public function attachmentNameContains(string $name): GroupCollectorInterface
@@ -115,7 +115,7 @@ trait AttachmentCollection
}
/**
* @param string $name
* @param string $name
* @return GroupCollectorInterface
*/
public function attachmentNameDoesNotContain(string $name): GroupCollectorInterface
@@ -144,7 +144,7 @@ trait AttachmentCollection
}
/**
* @param string $name
* @param string $name
* @return GroupCollectorInterface
*/
public function attachmentNameDoesNotEnd(string $name): GroupCollectorInterface
@@ -173,7 +173,7 @@ trait AttachmentCollection
}
/**
* @param string $name
* @param string $name
* @return GroupCollectorInterface
*/
public function attachmentNameDoesNotStart(string $name): GroupCollectorInterface
@@ -202,7 +202,7 @@ trait AttachmentCollection
}
/**
* @param string $name
* @param string $name
* @return GroupCollectorInterface
*/
public function attachmentNameEnds(string $name): GroupCollectorInterface
@@ -231,7 +231,7 @@ trait AttachmentCollection
}
/**
* @param string $name
* @param string $name
* @return GroupCollectorInterface
*/
public function attachmentNameIs(string $name): GroupCollectorInterface
@@ -257,7 +257,7 @@ trait AttachmentCollection
}
/**
* @param string $name
* @param string $name
* @return GroupCollectorInterface
*/
public function attachmentNameIsNot(string $name): GroupCollectorInterface
@@ -283,7 +283,7 @@ trait AttachmentCollection
}
/**
* @param string $name
* @param string $name
* @return GroupCollectorInterface
*/
public function attachmentNameStarts(string $name): GroupCollectorInterface
@@ -312,7 +312,7 @@ trait AttachmentCollection
}
/**
* @param string $value
* @param string $value
* @return GroupCollectorInterface
*/
public function attachmentNotesAre(string $value): GroupCollectorInterface
@@ -338,7 +338,7 @@ trait AttachmentCollection
}
/**
* @param string $value
* @param string $value
* @return GroupCollectorInterface
*/
public function attachmentNotesAreNot(string $value): GroupCollectorInterface
@@ -364,7 +364,7 @@ trait AttachmentCollection
}
/**
* @param string $value
* @param string $value
* @return GroupCollectorInterface
*/
public function attachmentNotesContains(string $value): GroupCollectorInterface
@@ -390,7 +390,7 @@ trait AttachmentCollection
}
/**
* @param string $value
* @param string $value
* @return GroupCollectorInterface
*/
public function attachmentNotesDoNotContain(string $value): GroupCollectorInterface
@@ -416,7 +416,7 @@ trait AttachmentCollection
}
/**
* @param string $value
* @param string $value
* @return GroupCollectorInterface
*/
public function attachmentNotesDoNotEnd(string $value): GroupCollectorInterface
@@ -442,7 +442,7 @@ trait AttachmentCollection
}
/**
* @param string $value
* @param string $value
* @return GroupCollectorInterface
*/
public function attachmentNotesDoNotStart(string $value): GroupCollectorInterface
@@ -468,7 +468,7 @@ trait AttachmentCollection
}
/**
* @param string $value
* @param string $value
* @return GroupCollectorInterface
*/
public function attachmentNotesEnds(string $value): GroupCollectorInterface
@@ -494,7 +494,7 @@ trait AttachmentCollection
}
/**
* @param string $value
* @param string $value
* @return GroupCollectorInterface
*/
public function attachmentNotesStarts(string $value): GroupCollectorInterface

View File

@@ -53,10 +53,29 @@ trait MetaCollection
return $this;
}
/**
* Will include bill name + ID, if any.
*
* @return GroupCollectorInterface
*/
public function withBillInformation(): GroupCollectorInterface
{
if (false === $this->hasBillInformation) {
// join bill table
$this->query->leftJoin('bills', 'bills.id', '=', 'transaction_journals.bill_id');
// add fields
$this->fields[] = 'bills.id as bill_id';
$this->fields[] = 'bills.name as bill_name';
$this->hasBillInformation = true;
}
return $this;
}
/**
* Exclude a specific budget.
*
* @param Budget $budget
* @param Budget $budget
*
* @return GroupCollectorInterface
*/
@@ -72,6 +91,27 @@ trait MetaCollection
return $this;
}
/**
* Will include budget ID + name, if any.
*
* @return GroupCollectorInterface
*/
public function withBudgetInformation(): GroupCollectorInterface
{
if (false === $this->hasBudgetInformation) {
// join link table
$this->query->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id');
// join cat table
$this->query->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id');
// add fields
$this->fields[] = 'budgets.id as budget_id';
$this->fields[] = 'budgets.name as budget_name';
$this->hasBudgetInformation = true;
}
return $this;
}
/**
* @inheritDoc
*/
@@ -104,10 +144,31 @@ trait MetaCollection
return $this;
}
/**
* Will include category ID + name, if any.
*
* @return GroupCollectorInterface
*/
public function withCategoryInformation(): GroupCollectorInterface
{
if (false === $this->hasCatInformation) {
// join link table
$this->query->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id');
// join cat table
$this->query->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id');
// add fields
$this->fields[] = 'categories.id as category_id';
$this->fields[] = 'categories.name as category_name';
$this->hasCatInformation = true;
}
return $this;
}
/**
* Exclude a specific category.
*
* @param Category $category
* @param Category $category
*
* @return GroupCollectorInterface
*/
@@ -135,6 +196,19 @@ trait MetaCollection
return $this;
}
/**
* Join table to get tag information.
*/
protected function joinMetaDataTables(): void
{
if (false === $this->hasJoinedMetaTables) {
$this->hasJoinedMetaTables = true;
$this->query->leftJoin('journal_meta', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id');
$this->fields[] = 'journal_meta.name as meta_name';
$this->fields[] = 'journal_meta.data as meta_data';
}
}
/**
* @inheritDoc
*/
@@ -245,7 +319,7 @@ trait MetaCollection
}
/**
* @param string $url
* @param string $url
* @return GroupCollectorInterface
*/
public function externalUrlContains(string $url): GroupCollectorInterface
@@ -260,7 +334,7 @@ trait MetaCollection
}
/**
* @param string $url
* @param string $url
* @return GroupCollectorInterface
*/
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
@@ -275,7 +349,7 @@ trait MetaCollection
}
/**
* @param string $url
* @param string $url
* @return GroupCollectorInterface
*/
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
@@ -290,7 +364,7 @@ trait MetaCollection
}
/**
* @param string $url
* @param string $url
* @return GroupCollectorInterface
*/
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
@@ -307,7 +381,7 @@ trait MetaCollection
}
/**
* @param string $url
* @param string $url
* @return GroupCollectorInterface
*/
public function externalUrlEnds(string $url): GroupCollectorInterface
@@ -322,7 +396,7 @@ trait MetaCollection
}
/**
* @param string $url
* @param string $url
* @return GroupCollectorInterface
*/
public function externalUrlStarts(string $url): GroupCollectorInterface
@@ -351,6 +425,37 @@ trait MetaCollection
return $this;
}
/**
* @return GroupCollectorInterface
*/
public function withTagInformation(): GroupCollectorInterface
{
$this->fields[] = 'tags.id as tag_id';
$this->fields[] = 'tags.tag as tag_name';
$this->fields[] = 'tags.date as tag_date';
$this->fields[] = 'tags.description as tag_description';
$this->fields[] = 'tags.latitude as tag_latitude';
$this->fields[] = 'tags.longitude as tag_longitude';
$this->fields[] = 'tags.zoomLevel as tag_zoom_level';
$this->joinTagTables();
return $this;
}
/**
* Join table to get tag information.
*/
protected 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');
}
}
/**
* @inheritDoc
*/
@@ -424,7 +529,7 @@ trait MetaCollection
}
/**
* @param string $value
* @param string $value
*
* @return GroupCollectorInterface
*/
@@ -437,7 +542,30 @@ trait MetaCollection
}
/**
* @param string $value
* @inheritDoc
*/
public function withNotes(): GroupCollectorInterface
{
if (false === $this->hasNotesInformation) {
// join bill table
$this->query->leftJoin(
'notes',
static function (JoinClause $join) {
$join->on('notes.noteable_id', '=', 'transaction_journals.id');
$join->where('notes.noteable_type', '=', 'FireflyIII\Models\TransactionJournal');
$join->whereNull('notes.deleted_at');
}
);
// add fields
$this->fields[] = 'notes.text as notes';
$this->hasNotesInformation = true;
}
return $this;
}
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
@@ -453,7 +581,7 @@ trait MetaCollection
}
/**
* @param string $value
* @param string $value
*
* @return GroupCollectorInterface
*/
@@ -469,7 +597,7 @@ trait MetaCollection
}
/**
* @param string $value
* @param string $value
*
* @return GroupCollectorInterface
*/
@@ -485,7 +613,7 @@ trait MetaCollection
}
/**
* @param string $value
* @param string $value
*
* @return GroupCollectorInterface
*/
@@ -498,7 +626,7 @@ trait MetaCollection
}
/**
* @param string $value
* @param string $value
*
* @return GroupCollectorInterface
*/
@@ -511,7 +639,7 @@ trait MetaCollection
}
/**
* @param string $value
* @param string $value
*
* @return GroupCollectorInterface
*/
@@ -527,7 +655,7 @@ trait MetaCollection
}
/**
* @param string $value
* @param string $value
*
* @return GroupCollectorInterface
*/
@@ -542,7 +670,7 @@ trait MetaCollection
/**
* Limit the search to a specific bill.
*
* @param Bill $bill
* @param Bill $bill
*
* @return GroupCollectorInterface
*/
@@ -557,7 +685,7 @@ trait MetaCollection
/**
* Limit the search to a specific set of bills.
*
* @param Collection $bills
* @param Collection $bills
*
* @return GroupCollectorInterface
*/
@@ -572,7 +700,7 @@ trait MetaCollection
/**
* Limit the search to a specific budget.
*
* @param Budget $budget
* @param Budget $budget
*
* @return GroupCollectorInterface
*/
@@ -587,7 +715,7 @@ trait MetaCollection
/**
* Limit the search to a specific set of budgets.
*
* @param Collection $budgets
* @param Collection $budgets
*
* @return GroupCollectorInterface
*/
@@ -604,7 +732,7 @@ trait MetaCollection
/**
* Limit the search to a specific bunch of categories.
*
* @param Collection $categories
* @param Collection $categories
*
* @return GroupCollectorInterface
*/
@@ -621,7 +749,7 @@ trait MetaCollection
/**
* Limit the search to a specific category.
*
* @param Category $category
* @param Category $category
*
* @return GroupCollectorInterface
*/
@@ -698,7 +826,7 @@ trait MetaCollection
/**
* Limit results to a specific tag.
*
* @param Tag $tag
* @param Tag $tag
*
* @return GroupCollectorInterface
*/
@@ -713,7 +841,7 @@ trait MetaCollection
/**
* Limit results to a specific set of tags.
*
* @param Collection $tags
* @param Collection $tags
*
* @return GroupCollectorInterface
*/
@@ -728,7 +856,7 @@ trait MetaCollection
/**
* Without tags
*
* @param Collection $tags
* @param Collection $tags
*
* @return GroupCollectorInterface
*/
@@ -778,25 +906,6 @@ trait MetaCollection
return $this;
}
/**
* Will include bill name + ID, if any.
*
* @return GroupCollectorInterface
*/
public function withBillInformation(): GroupCollectorInterface
{
if (false === $this->hasBillInformation) {
// join bill table
$this->query->leftJoin('bills', 'bills.id', '=', 'transaction_journals.bill_id');
// add fields
$this->fields[] = 'bills.id as bill_id';
$this->fields[] = 'bills.name as bill_name';
$this->hasBillInformation = true;
}
return $this;
}
/**
* Limit results to a transactions without a budget..
*
@@ -810,27 +919,6 @@ trait MetaCollection
return $this;
}
/**
* Will include budget ID + name, if any.
*
* @return GroupCollectorInterface
*/
public function withBudgetInformation(): GroupCollectorInterface
{
if (false === $this->hasBudgetInformation) {
// join link table
$this->query->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id');
// join cat table
$this->query->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id');
// add fields
$this->fields[] = 'budgets.id as budget_id';
$this->fields[] = 'budgets.name as budget_name';
$this->hasBudgetInformation = true;
}
return $this;
}
/**
* Limit results to a transactions without a category.
*
@@ -844,27 +932,6 @@ trait MetaCollection
return $this;
}
/**
* Will include category ID + name, if any.
*
* @return GroupCollectorInterface
*/
public function withCategoryInformation(): GroupCollectorInterface
{
if (false === $this->hasCatInformation) {
// join link table
$this->query->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id');
// join cat table
$this->query->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id');
// add fields
$this->fields[] = 'categories.id as category_id';
$this->fields[] = 'categories.name as category_name';
$this->hasCatInformation = true;
}
return $this;
}
/**
* @inheritDoc
*/
@@ -889,47 +956,6 @@ trait MetaCollection
return $this;
}
/**
* @inheritDoc
*/
public function withNotes(): GroupCollectorInterface
{
if (false === $this->hasNotesInformation) {
// join bill table
$this->query->leftJoin(
'notes',
static function (JoinClause $join) {
$join->on('notes.noteable_id', '=', 'transaction_journals.id');
$join->where('notes.noteable_type', '=', 'FireflyIII\Models\TransactionJournal');
$join->whereNull('notes.deleted_at');
}
);
// add fields
$this->fields[] = 'notes.text as notes';
$this->hasNotesInformation = true;
}
return $this;
}
/**
* @return GroupCollectorInterface
*/
public function withTagInformation(): GroupCollectorInterface
{
$this->fields[] = 'tags.id as tag_id';
$this->fields[] = 'tags.tag as tag_name';
$this->fields[] = 'tags.date as tag_date';
$this->fields[] = 'tags.description as tag_description';
$this->fields[] = 'tags.latitude as tag_latitude';
$this->fields[] = 'tags.longitude as tag_longitude';
$this->fields[] = 'tags.zoomLevel as tag_zoom_level';
$this->joinTagTables();
return $this;
}
/**
* Limit results to a transactions without a bill.
*
@@ -1036,30 +1062,4 @@ trait MetaCollection
return $this;
}
/**
* Join table to get tag information.
*/
protected function joinMetaDataTables(): void
{
if (false === $this->hasJoinedMetaTables) {
$this->hasJoinedMetaTables = true;
$this->query->leftJoin('journal_meta', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id');
$this->fields[] = 'journal_meta.name as meta_name';
$this->fields[] = 'journal_meta.data as meta_data';
}
}
/**
* Join table to get tag information.
*/
protected 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');
}
}
}

View File

@@ -33,7 +33,7 @@ use FireflyIII\Helpers\Collector\GroupCollectorInterface;
trait TimeCollection
{
/**
* @param string $day
* @param string $day
* @return GroupCollectorInterface
*/
public function dayAfter(string $day): GroupCollectorInterface
@@ -43,7 +43,7 @@ trait TimeCollection
}
/**
* @param string $day
* @param string $day
* @return GroupCollectorInterface
*/
public function dayBefore(string $day): GroupCollectorInterface
@@ -53,7 +53,7 @@ trait TimeCollection
}
/**
* @param string $day
* @param string $day
* @return GroupCollectorInterface
*/
public function dayIs(string $day): GroupCollectorInterface
@@ -63,7 +63,7 @@ trait TimeCollection
}
/**
* @param string $day
* @param string $day
* @return GroupCollectorInterface
*/
public function dayIsNot(string $day): GroupCollectorInterface
@@ -73,9 +73,9 @@ trait TimeCollection
}
/**
* @param Carbon $start
* @param Carbon $end
* @param string $field
* @param Carbon $start
* @param Carbon $end
* @param string $field
* @return GroupCollectorInterface
*/
public function excludeMetaDateRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
@@ -103,9 +103,21 @@ trait TimeCollection
}
/**
* @param Carbon $start
* @param Carbon $end
* @param string $field
* @inheritDoc
*/
public function withMetaDate(string $field): GroupCollectorInterface
{
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', $field);
$this->query->whereNotNull('journal_meta.data');
return $this;
}
/**
* @param Carbon $start
* @param Carbon $end
* @param string $field
* @return GroupCollectorInterface
*/
public function excludeObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
@@ -120,8 +132,8 @@ trait TimeCollection
}
/**
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
* @return GroupCollectorInterface
*/
public function excludeRange(Carbon $start, Carbon $end): GroupCollectorInterface
@@ -139,8 +151,8 @@ trait TimeCollection
}
/**
* @param string $day
* @param string $field
* @param string $day
* @param string $field
* @return GroupCollectorInterface
*/
public function metaDayAfter(string $day, string $field): GroupCollectorInterface
@@ -162,8 +174,8 @@ trait TimeCollection
}
/**
* @param string $day
* @param string $field
* @param string $day
* @param string $field
* @return GroupCollectorInterface
*/
public function metaDayBefore(string $day, string $field): GroupCollectorInterface
@@ -185,8 +197,8 @@ trait TimeCollection
}
/**
* @param string $day
* @param string $field
* @param string $day
* @param string $field
* @return GroupCollectorInterface
*/
public function metaDayIs(string $day, string $field): GroupCollectorInterface
@@ -207,8 +219,8 @@ trait TimeCollection
}
/**
* @param string $day
* @param string $field
* @param string $day
* @param string $field
* @return GroupCollectorInterface
*/
public function metaDayIsNot(string $day, string $field): GroupCollectorInterface
@@ -229,8 +241,8 @@ trait TimeCollection
}
/**
* @param string $month
* @param string $field
* @param string $month
* @param string $field
* @return GroupCollectorInterface
*/
public function metaMonthAfter(string $month, string $field): GroupCollectorInterface
@@ -252,8 +264,8 @@ trait TimeCollection
}
/**
* @param string $month
* @param string $field
* @param string $month
* @param string $field
* @return GroupCollectorInterface
*/
public function metaMonthBefore(string $month, string $field): GroupCollectorInterface
@@ -275,8 +287,8 @@ trait TimeCollection
}
/**
* @param string $month
* @param string $field
* @param string $month
* @param string $field
* @return GroupCollectorInterface
*/
public function metaMonthIs(string $month, string $field): GroupCollectorInterface
@@ -297,8 +309,8 @@ trait TimeCollection
}
/**
* @param string $month
* @param string $field
* @param string $month
* @param string $field
* @return GroupCollectorInterface
*/
public function metaMonthIsNot(string $month, string $field): GroupCollectorInterface
@@ -319,8 +331,8 @@ trait TimeCollection
}
/**
* @param string $year
* @param string $field
* @param string $year
* @param string $field
* @return GroupCollectorInterface
*/
public function metaYearAfter(string $year, string $field): GroupCollectorInterface
@@ -342,8 +354,8 @@ trait TimeCollection
}
/**
* @param string $year
* @param string $field
* @param string $year
* @param string $field
* @return GroupCollectorInterface
*/
public function metaYearBefore(string $year, string $field): GroupCollectorInterface
@@ -365,8 +377,8 @@ trait TimeCollection
}
/**
* @param string $year
* @param string $field
* @param string $year
* @param string $field
* @return GroupCollectorInterface
*/
public function metaYearIs(string $year, string $field): GroupCollectorInterface
@@ -388,8 +400,8 @@ trait TimeCollection
}
/**
* @param string $year
* @param string $field
* @param string $year
* @param string $field
* @return GroupCollectorInterface
*/
public function metaYearIsNot(string $year, string $field): GroupCollectorInterface
@@ -410,7 +422,7 @@ trait TimeCollection
}
/**
* @param string $month
* @param string $month
* @return GroupCollectorInterface
*/
public function monthAfter(string $month): GroupCollectorInterface
@@ -420,7 +432,7 @@ trait TimeCollection
}
/**
* @param string $month
* @param string $month
* @return GroupCollectorInterface
*/
public function monthBefore(string $month): GroupCollectorInterface
@@ -430,7 +442,7 @@ trait TimeCollection
}
/**
* @param string $month
* @param string $month
* @return GroupCollectorInterface
*/
public function monthIs(string $month): GroupCollectorInterface
@@ -440,7 +452,7 @@ trait TimeCollection
}
/**
* @param string $month
* @param string $month
* @return GroupCollectorInterface
*/
public function monthIsNot(string $month): GroupCollectorInterface
@@ -450,8 +462,8 @@ trait TimeCollection
}
/**
* @param string $day
* @param string $field
* @param string $day
* @param string $field
* @return GroupCollectorInterface
*/
public function objectDayAfter(string $day, string $field): GroupCollectorInterface
@@ -461,8 +473,8 @@ trait TimeCollection
}
/**
* @param string $day
* @param string $field
* @param string $day
* @param string $field
* @return GroupCollectorInterface
*/
public function objectDayBefore(string $day, string $field): GroupCollectorInterface
@@ -472,8 +484,8 @@ trait TimeCollection
}
/**
* @param string $day
* @param string $field
* @param string $day
* @param string $field
* @return GroupCollectorInterface
*/
public function objectDayIs(string $day, string $field): GroupCollectorInterface
@@ -483,8 +495,8 @@ trait TimeCollection
}
/**
* @param string $day
* @param string $field
* @param string $day
* @param string $field
* @return GroupCollectorInterface
*/
public function objectDayIsNot(string $day, string $field): GroupCollectorInterface
@@ -494,8 +506,8 @@ trait TimeCollection
}
/**
* @param string $month
* @param string $field
* @param string $month
* @param string $field
* @return GroupCollectorInterface
*/
public function objectMonthAfter(string $month, string $field): GroupCollectorInterface
@@ -505,8 +517,8 @@ trait TimeCollection
}
/**
* @param string $month
* @param string $field
* @param string $month
* @param string $field
* @return GroupCollectorInterface
*/
public function objectMonthBefore(string $month, string $field): GroupCollectorInterface
@@ -516,8 +528,8 @@ trait TimeCollection
}
/**
* @param string $month
* @param string $field
* @param string $month
* @param string $field
* @return GroupCollectorInterface
*/
public function objectMonthIs(string $month, string $field): GroupCollectorInterface
@@ -527,8 +539,8 @@ trait TimeCollection
}
/**
* @param string $month
* @param string $field
* @param string $month
* @param string $field
* @return GroupCollectorInterface
*/
public function objectMonthIsNot(string $month, string $field): GroupCollectorInterface
@@ -538,8 +550,8 @@ trait TimeCollection
}
/**
* @param string $year
* @param string $field
* @param string $year
* @param string $field
* @return GroupCollectorInterface
*/
public function objectYearAfter(string $year, string $field): GroupCollectorInterface
@@ -549,8 +561,8 @@ trait TimeCollection
}
/**
* @param string $year
* @param string $field
* @param string $year
* @param string $field
* @return GroupCollectorInterface
*/
public function objectYearBefore(string $year, string $field): GroupCollectorInterface
@@ -560,8 +572,8 @@ trait TimeCollection
}
/**
* @param string $year
* @param string $field
* @param string $year
* @param string $field
* @return GroupCollectorInterface
*/
public function objectYearIs(string $year, string $field): GroupCollectorInterface
@@ -571,8 +583,8 @@ trait TimeCollection
}
/**
* @param string $year
* @param string $field
* @param string $year
* @param string $field
* @return GroupCollectorInterface
*/
public function objectYearIsNot(string $year, string $field): GroupCollectorInterface
@@ -584,7 +596,7 @@ trait TimeCollection
/**
* Collect transactions after a specific date.
*
* @param Carbon $date
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
@@ -599,7 +611,7 @@ trait TimeCollection
/**
* Collect transactions before a specific date.
*
* @param Carbon $date
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
@@ -614,7 +626,7 @@ trait TimeCollection
/**
* Collect transactions created on a specific date.
*
* @param Carbon $date
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
@@ -629,8 +641,8 @@ trait TimeCollection
}
/**
* @param Carbon $date
* @param string $field
* @param Carbon $date
* @param string $field
* @return GroupCollectorInterface
*/
public function setMetaAfter(Carbon $date, string $field): GroupCollectorInterface
@@ -653,8 +665,8 @@ trait TimeCollection
}
/**
* @param Carbon $date
* @param string $field
* @param Carbon $date
* @param string $field
* @return GroupCollectorInterface
*/
public function setMetaBefore(Carbon $date, string $field): GroupCollectorInterface
@@ -676,9 +688,9 @@ trait TimeCollection
}
/**
* @param Carbon $start
* @param Carbon $end
* @param string $field
* @param Carbon $start
* @param Carbon $end
* @param string $field
* @return GroupCollectorInterface
*/
public function setMetaDateRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
@@ -706,8 +718,8 @@ trait TimeCollection
}
/**
* @param Carbon $date
* @param string $field
* @param Carbon $date
* @param string $field
* @return GroupCollectorInterface
*/
public function setObjectAfter(Carbon $date, string $field): GroupCollectorInterface
@@ -719,8 +731,8 @@ trait TimeCollection
}
/**
* @param Carbon $date
* @param string $field
* @param Carbon $date
* @param string $field
* @return GroupCollectorInterface
*/
public function setObjectBefore(Carbon $date, string $field): GroupCollectorInterface
@@ -731,9 +743,9 @@ trait TimeCollection
}
/**
* @param Carbon $start
* @param Carbon $end
* @param string $field
* @param Carbon $start
* @param Carbon $end
* @param string $field
* @return GroupCollectorInterface
*/
public function setObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
@@ -749,8 +761,8 @@ trait TimeCollection
/**
* Set the start and end time of the results to return.
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return GroupCollectorInterface
*/
@@ -772,7 +784,7 @@ trait TimeCollection
/**
* Collect transactions updated on a specific date.
*
* @param Carbon $date
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
@@ -787,19 +799,7 @@ trait TimeCollection
}
/**
* @inheritDoc
*/
public function withMetaDate(string $field): GroupCollectorInterface
{
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', $field);
$this->query->whereNotNull('journal_meta.data');
return $this;
}
/**
* @param string $year
* @param string $year
* @return GroupCollectorInterface
*/
public function yearAfter(string $year): GroupCollectorInterface
@@ -809,7 +809,7 @@ trait TimeCollection
}
/**
* @param string $year
* @param string $year
* @return GroupCollectorInterface
*/
public function yearBefore(string $year): GroupCollectorInterface
@@ -819,7 +819,7 @@ trait TimeCollection
}
/**
* @param string $year
* @param string $year
* @return GroupCollectorInterface
*/
public function yearIs(string $year): GroupCollectorInterface
@@ -829,7 +829,7 @@ trait TimeCollection
}
/**
* @param string $year
* @param string $year
* @return GroupCollectorInterface
*/
public function yearIsNot(string $year): GroupCollectorInterface

View File

@@ -316,7 +316,7 @@ class GroupCollector implements GroupCollectorInterface
/**
* Limit results to NOT a specific currency, either foreign or normal one.
*
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
*
* @return GroupCollectorInterface
*/
@@ -353,7 +353,7 @@ class GroupCollector implements GroupCollectorInterface
/**
* Limit the result to NOT a set of specific transaction groups.
*
* @param array $groupIds
* @param array $groupIds
*
* @return GroupCollectorInterface
*/
@@ -367,7 +367,7 @@ class GroupCollector implements GroupCollectorInterface
/**
* Limit the result to NOT a set of specific journals.
*
* @param array $journalIds
* @param array $journalIds
*
* @return GroupCollectorInterface
*/
@@ -387,7 +387,7 @@ class GroupCollector implements GroupCollectorInterface
/**
* Search for words in descriptions.
*
* @param array $array
* @param array $array
*
* @return GroupCollectorInterface
*/
@@ -505,313 +505,7 @@ class GroupCollector implements GroupCollectorInterface
}
/**
* Same as getGroups but everything is in a paginator.
*
* @return LengthAwarePaginator
*/
public function getPaginatedGroups(): LengthAwarePaginator
{
$set = $this->getGroups();
if (0 === $this->limit) {
$this->setLimit(50);
}
return new LengthAwarePaginator($set, $this->total, $this->limit, $this->page);
}
/**
* @inheritDoc
*/
public function isNotReconciled(): GroupCollectorInterface
{
$this->query->where('source.reconciled', 0)->where('destination.reconciled', 0);
return $this;
}
/**
* @inheritDoc
*/
public function isReconciled(): GroupCollectorInterface
{
$this->query->where('source.reconciled', 1)->where('destination.reconciled', 1);
return $this;
}
/**
* Limit results to a specific currency, either foreign or normal one.
*
* @param TransactionCurrency $currency
*
* @return GroupCollectorInterface
*/
public function setCurrency(TransactionCurrency $currency): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($currency) {
$q->where('source.transaction_currency_id', $currency->id);
$q->orWhere('source.foreign_currency_id', $currency->id);
}
);
return $this;
}
/**
* @inheritDoc
*/
public function setForeignCurrency(TransactionCurrency $currency): GroupCollectorInterface
{
$this->query->where('source.foreign_currency_id', $currency->id);
return $this;
}
/**
* Limit the result to a set of specific transaction groups.
*
* @param array $groupIds
*
* @return GroupCollectorInterface
*/
public function setIds(array $groupIds): GroupCollectorInterface
{
$this->query->whereIn('transaction_groups.id', $groupIds);
return $this;
}
/**
* Limit the result to a set of specific journals.
*
* @param array $journalIds
*
* @return GroupCollectorInterface
*/
public function setJournalIds(array $journalIds): GroupCollectorInterface
{
if (0 !== count($journalIds)) {
// make all integers.
$integerIDs = array_map('intval', $journalIds);
$this->query->whereIn('transaction_journals.id', $integerIDs);
}
return $this;
}
/**
* Limit the number of returned entries.
*
* @param int $limit
*
* @return GroupCollectorInterface
*/
public function setLimit(int $limit): GroupCollectorInterface
{
$this->limit = $limit;
app('log')->debug(sprintf('GroupCollector: The limit is now %d', $limit));
return $this;
}
/**
* Set the page to get.
*
* @param int $page
*
* @return GroupCollectorInterface
*/
public function setPage(int $page): GroupCollectorInterface
{
$page = 0 === $page ? 1 : $page;
$this->page = $page;
app('log')->debug(sprintf('GroupCollector: page is now %d', $page));
return $this;
}
/**
* Search for words in descriptions.
*
* @param array $array
*
* @return GroupCollectorInterface
*/
public function setSearchWords(array $array): GroupCollectorInterface
{
if (0 === count($array)) {
return $this;
}
$this->query->where(
static function (EloquentBuilder $q) use ($array) {
$q->where(
static function (EloquentBuilder $q1) use ($array) {
foreach ($array as $word) {
$keyword = sprintf('%%%s%%', $word);
$q1->where('transaction_journals.description', 'LIKE', $keyword);
}
}
);
$q->orWhere(
static function (EloquentBuilder $q2) use ($array) {
foreach ($array as $word) {
$keyword = sprintf('%%%s%%', $word);
$q2->where('transaction_groups.title', 'LIKE', $keyword);
}
}
);
}
);
return $this;
}
/**
* Limit the search to one specific transaction group.
*
* @param TransactionGroup $transactionGroup
*
* @return GroupCollectorInterface
*/
public function setTransactionGroup(TransactionGroup $transactionGroup): GroupCollectorInterface
{
$this->query->where('transaction_groups.id', $transactionGroup->id);
return $this;
}
/**
* Limit the included transaction types.
*
* @param array $types
*
* @return GroupCollectorInterface
*/
public function setTypes(array $types): GroupCollectorInterface
{
$this->query->whereIn('transaction_types.type', $types);
return $this;
}
/**
* Set the user object and start the query.
*
* @param User $user
*
* @return GroupCollectorInterface
*/
public function setUser(User $user): GroupCollectorInterface
{
if (null === $this->user) {
$this->user = $user;
$this->startQuery();
}
return $this;
}
/**
* Automatically include all stuff required to make API calls work.
*
* @return GroupCollectorInterface
*/
public function withAPIInformation(): GroupCollectorInterface
{
// include source + destination account name and type.
$this->withAccountInformation()
// include category ID + name (if any)
->withCategoryInformation()
// include budget ID + name (if any)
->withBudgetInformation()
// include bill ID + name (if any)
->withBillInformation();
return $this;
}
/**
* Convert a selected set of fields to arrays.
*
* @param array $array
*
* @return array
*/
private function convertToInteger(array $array): array
{
foreach ($this->integerFields as $field) {
$array[$field] = array_key_exists($field, $array) ? (int)$array[$field] : null;
}
return $array;
}
/**
* @param array $array
* @return array
*/
private function convertToStrings(array $array): array
{
foreach ($this->stringFields as $field) {
$array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (string)$array[$field] : null;
}
return $array;
}
/**
* @param array $existingJournal
* @param TransactionJournal $newJournal
*
* @return array
*/
private function mergeAttachments(array $existingJournal, TransactionJournal $newJournal): array
{
$newArray = $newJournal->toArray();
if (array_key_exists('attachment_id', $newArray)) {
$attachmentId = (int)$newJournal['attachment_id'];
$existingJournal['attachments'][$attachmentId] = [
'id' => $attachmentId,
];
}
return $existingJournal;
}
/**
* @param array $existingJournal
* @param TransactionJournal $newJournal
*
* @return array
*/
private function mergeTags(array $existingJournal, TransactionJournal $newJournal): array
{
$newArray = $newJournal->toArray();
if (array_key_exists('tag_id', $newArray)) { // assume the other fields are present as well.
$tagId = (int)$newJournal['tag_id'];
$tagDate = null;
try {
$tagDate = Carbon::parse($newArray['tag_date']);
} catch (InvalidFormatException $e) {
Log::debug(sprintf('Could not parse date: %s', $e->getMessage()));
}
$existingJournal['tags'][$tagId] = [
'id' => (int)$newArray['tag_id'],
'name' => $newArray['tag_name'],
'date' => $tagDate,
'description' => $newArray['tag_description'],
];
}
return $existingJournal;
}
/**
* @param Collection $collection
* @param Collection $collection
*
* @return Collection
* @throws FireflyException
@@ -864,7 +558,7 @@ class GroupCollector implements GroupCollectorInterface
}
/**
* @param TransactionJournal $augumentedJournal
* @param TransactionJournal $augumentedJournal
*
* @return array
* @throws FireflyException
@@ -952,14 +646,93 @@ class GroupCollector implements GroupCollectorInterface
}
/**
* @param array $groups
* Convert a selected set of fields to arrays.
*
* @param array $array
*
* @return array
*/
private function convertToInteger(array $array): array
{
foreach ($this->integerFields as $field) {
$array[$field] = array_key_exists($field, $array) ? (int)$array[$field] : null;
}
return $array;
}
/**
* @param array $array
* @return array
*/
private function convertToStrings(array $array): array
{
foreach ($this->stringFields as $field) {
$array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (string)$array[$field] : null;
}
return $array;
}
/**
* @param array $existingJournal
* @param TransactionJournal $newJournal
*
* @return array
*/
private function mergeTags(array $existingJournal, TransactionJournal $newJournal): array
{
$newArray = $newJournal->toArray();
if (array_key_exists('tag_id', $newArray)) { // assume the other fields are present as well.
$tagId = (int)$newJournal['tag_id'];
$tagDate = null;
try {
$tagDate = Carbon::parse($newArray['tag_date']);
} catch (InvalidFormatException $e) {
Log::debug(sprintf('Could not parse date: %s', $e->getMessage()));
}
$existingJournal['tags'][$tagId] = [
'id' => (int)$newArray['tag_id'],
'name' => $newArray['tag_name'],
'date' => $tagDate,
'description' => $newArray['tag_description'],
];
}
return $existingJournal;
}
/**
* @param array $existingJournal
* @param TransactionJournal $newJournal
*
* @return array
*/
private function mergeAttachments(array $existingJournal, TransactionJournal $newJournal): array
{
$newArray = $newJournal->toArray();
if (array_key_exists('attachment_id', $newArray)) {
$attachmentId = (int)$newJournal['attachment_id'];
$existingJournal['attachments'][$attachmentId] = [
'id' => $attachmentId,
];
}
return $existingJournal;
}
/**
* @param array $groups
*
* @return array
*/
private function parseSums(array $groups): array
{
/**
* @var int $groudId
* @var int $groudId
* @var array $group
*/
foreach ($groups as $groudId => $group) {
@@ -997,7 +770,7 @@ class GroupCollector implements GroupCollectorInterface
}
/**
* @param Collection $collection
* @param Collection $collection
* @return Collection
*/
private function postFilterCollection(Collection $collection): Collection
@@ -1012,7 +785,7 @@ class GroupCollector implements GroupCollectorInterface
// and save it (or not) in the new collection.
// that new collection is the next current collection
/**
* @var int $ii
* @var int $ii
* @var array $item
*/
foreach ($currentCollection as $ii => $item) {
@@ -1028,6 +801,214 @@ class GroupCollector implements GroupCollectorInterface
return $currentCollection;
}
/**
* Same as getGroups but everything is in a paginator.
*
* @return LengthAwarePaginator
*/
public function getPaginatedGroups(): LengthAwarePaginator
{
$set = $this->getGroups();
if (0 === $this->limit) {
$this->setLimit(50);
}
return new LengthAwarePaginator($set, $this->total, $this->limit, $this->page);
}
/**
* Limit the number of returned entries.
*
* @param int $limit
*
* @return GroupCollectorInterface
*/
public function setLimit(int $limit): GroupCollectorInterface
{
$this->limit = $limit;
app('log')->debug(sprintf('GroupCollector: The limit is now %d', $limit));
return $this;
}
/**
* @inheritDoc
*/
public function isNotReconciled(): GroupCollectorInterface
{
$this->query->where('source.reconciled', 0)->where('destination.reconciled', 0);
return $this;
}
/**
* @inheritDoc
*/
public function isReconciled(): GroupCollectorInterface
{
$this->query->where('source.reconciled', 1)->where('destination.reconciled', 1);
return $this;
}
/**
* Limit results to a specific currency, either foreign or normal one.
*
* @param TransactionCurrency $currency
*
* @return GroupCollectorInterface
*/
public function setCurrency(TransactionCurrency $currency): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($currency) {
$q->where('source.transaction_currency_id', $currency->id);
$q->orWhere('source.foreign_currency_id', $currency->id);
}
);
return $this;
}
/**
* @inheritDoc
*/
public function setForeignCurrency(TransactionCurrency $currency): GroupCollectorInterface
{
$this->query->where('source.foreign_currency_id', $currency->id);
return $this;
}
/**
* Limit the result to a set of specific transaction groups.
*
* @param array $groupIds
*
* @return GroupCollectorInterface
*/
public function setIds(array $groupIds): GroupCollectorInterface
{
$this->query->whereIn('transaction_groups.id', $groupIds);
return $this;
}
/**
* Limit the result to a set of specific journals.
*
* @param array $journalIds
*
* @return GroupCollectorInterface
*/
public function setJournalIds(array $journalIds): GroupCollectorInterface
{
if (0 !== count($journalIds)) {
// make all integers.
$integerIDs = array_map('intval', $journalIds);
$this->query->whereIn('transaction_journals.id', $integerIDs);
}
return $this;
}
/**
* Set the page to get.
*
* @param int $page
*
* @return GroupCollectorInterface
*/
public function setPage(int $page): GroupCollectorInterface
{
$page = 0 === $page ? 1 : $page;
$this->page = $page;
app('log')->debug(sprintf('GroupCollector: page is now %d', $page));
return $this;
}
/**
* Search for words in descriptions.
*
* @param array $array
*
* @return GroupCollectorInterface
*/
public function setSearchWords(array $array): GroupCollectorInterface
{
if (0 === count($array)) {
return $this;
}
$this->query->where(
static function (EloquentBuilder $q) use ($array) {
$q->where(
static function (EloquentBuilder $q1) use ($array) {
foreach ($array as $word) {
$keyword = sprintf('%%%s%%', $word);
$q1->where('transaction_journals.description', 'LIKE', $keyword);
}
}
);
$q->orWhere(
static function (EloquentBuilder $q2) use ($array) {
foreach ($array as $word) {
$keyword = sprintf('%%%s%%', $word);
$q2->where('transaction_groups.title', 'LIKE', $keyword);
}
}
);
}
);
return $this;
}
/**
* Limit the search to one specific transaction group.
*
* @param TransactionGroup $transactionGroup
*
* @return GroupCollectorInterface
*/
public function setTransactionGroup(TransactionGroup $transactionGroup): GroupCollectorInterface
{
$this->query->where('transaction_groups.id', $transactionGroup->id);
return $this;
}
/**
* Limit the included transaction types.
*
* @param array $types
*
* @return GroupCollectorInterface
*/
public function setTypes(array $types): GroupCollectorInterface
{
$this->query->whereIn('transaction_types.type', $types);
return $this;
}
/**
* Set the user object and start the query.
*
* @param User $user
*
* @return GroupCollectorInterface
*/
public function setUser(User $user): GroupCollectorInterface
{
if (null === $this->user) {
$this->user = $user;
$this->startQuery();
}
return $this;
}
/**
* Build the query.
*/
@@ -1070,4 +1051,23 @@ class GroupCollector implements GroupCollectorInterface
->orderBy('transaction_journals.description', 'DESC')
->orderBy('source.amount', 'DESC');
}
/**
* Automatically include all stuff required to make API calls work.
*
* @return GroupCollectorInterface
*/
public function withAPIInformation(): GroupCollectorInterface
{
// include source + destination account name and type.
$this->withAccountInformation()
// include category ID + name (if any)
->withCategoryInformation()
// include budget ID + name (if any)
->withBudgetInformation()
// include bill ID + name (if any)
->withBillInformation();
return $this;
}
}

File diff suppressed because it is too large Load Diff