mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Replace method calls.
This commit is contained in:
@@ -114,7 +114,7 @@ class FrontpageChartGenerator
|
||||
*/
|
||||
private function noBudgetLimits(array $data, Budget $budget): array
|
||||
{
|
||||
$spent = $this->opsRepository->sumExpenses($this->start, $this->end, null, new Collection([$budget]));
|
||||
$spent = $this->opsRepository->sumExpenses($this->start, $this->end, null, new Collection()->push($budget));
|
||||
|
||||
/** @var array $entry */
|
||||
foreach ($spent as $entry) {
|
||||
@@ -158,7 +158,7 @@ class FrontpageChartGenerator
|
||||
Log::debug(sprintf('Processing limit #%d with %s %s', $limit->id, $limit->transactionCurrency->code, $limit->amount));
|
||||
}
|
||||
|
||||
$spent = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection([$budget]), $currency);
|
||||
$spent = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection()->push($budget), $currency);
|
||||
Log::debug(sprintf('Spent array has %d entries.', count($spent)));
|
||||
|
||||
/** @var array $entry */
|
||||
|
@@ -40,7 +40,7 @@ class WholePeriodChartGenerator
|
||||
|
||||
public function generate(Category $category, Carbon $start, Carbon $end): array
|
||||
{
|
||||
$collection = new Collection([$category]);
|
||||
$collection = new Collection()->push($category);
|
||||
|
||||
/** @var OperationsRepositoryInterface $opsRepository */
|
||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||
|
@@ -191,7 +191,7 @@ trait AugumentData
|
||||
|
||||
$set = $blRepository->getBudgetLimits($budget, $start, $end);
|
||||
|
||||
$budgetCollection = new Collection([$budget]);
|
||||
$budgetCollection = new Collection()->push($budget);
|
||||
|
||||
// merge sets based on a key, in case of convert to primary currency
|
||||
$limits = new Collection();
|
||||
|
@@ -90,7 +90,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
public function enrichSingle(array|Model $model): Account|array
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$collection = new Collection([$model]);
|
||||
$collection = new Collection()->push($model);
|
||||
$collection = $this->enrich($collection);
|
||||
|
||||
return $collection->first();
|
||||
|
@@ -73,7 +73,7 @@ class BudgetEnrichment implements EnrichmentInterface
|
||||
public function enrichSingle(array|Model $model): array|Model
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$collection = new Collection([$model]);
|
||||
$collection = new Collection()->push($model);
|
||||
$collection = $this->enrich($collection);
|
||||
|
||||
return $collection->first();
|
||||
@@ -167,7 +167,7 @@ class BudgetEnrichment implements EnrichmentInterface
|
||||
$opsRepository->setUser($this->user);
|
||||
$opsRepository->setUserGroup($this->userGroup);
|
||||
// $spent = $this->beautify();
|
||||
// $set = $this->opsRepository->sumExpenses($start, $end, null, new Collection([$budget]))
|
||||
// $set = $this->opsRepository->sumExpenses($start, $end, null, new Collection()->push($budget))
|
||||
$expenses = $opsRepository->collectExpenses($this->start, $this->end, null, $this->collection, null);
|
||||
foreach ($this->collection as $item) {
|
||||
$id = (int)$item->id;
|
||||
|
@@ -65,7 +65,7 @@ class CategoryEnrichment implements EnrichmentInterface
|
||||
public function enrichSingle(array|Model $model): array|Model
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$collection = new Collection([$model]);
|
||||
$collection = new Collection()->push($model);
|
||||
$collection = $this->enrich($collection);
|
||||
|
||||
return $collection->first();
|
||||
|
@@ -80,7 +80,7 @@ class PiggyBankEnrichment implements EnrichmentInterface
|
||||
public function enrichSingle(array|Model $model): array|Model
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$collection = new Collection([$model]);
|
||||
$collection = new Collection()->push($model);
|
||||
$collection = $this->enrich($collection);
|
||||
|
||||
return $collection->first();
|
||||
|
@@ -69,7 +69,7 @@ class PiggyBankEventEnrichment implements EnrichmentInterface
|
||||
public function enrichSingle(array|Model $model): array|Model
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$collection = new Collection([$model]);
|
||||
$collection = new Collection()->push($model);
|
||||
$collection = $this->enrich($collection);
|
||||
|
||||
return $collection->first();
|
||||
|
@@ -101,7 +101,7 @@ class RecurringEnrichment implements EnrichmentInterface
|
||||
public function enrichSingle(array|Model $model): array|Model
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$collection = new Collection([$model]);
|
||||
$collection = new Collection()->push($model);
|
||||
$collection = $this->enrich($collection);
|
||||
|
||||
return $collection->first();
|
||||
|
@@ -145,7 +145,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
public function enrichSingle(array|Model $model): array|Model
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$collection = new Collection([$model]);
|
||||
$collection = new Collection()->push($model);
|
||||
$collection = $this->enrich($collection);
|
||||
|
||||
return $collection->first();
|
||||
|
@@ -68,7 +68,7 @@ class TransactionGroupEnrichment implements EnrichmentInterface
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
if (is_array($model)) {
|
||||
$collection = new Collection([$model]);
|
||||
$collection = new Collection()->push($model);
|
||||
$collection = $this->enrich($collection);
|
||||
|
||||
return $collection->first();
|
||||
|
@@ -70,7 +70,7 @@ class WebhookEnrichment implements EnrichmentInterface
|
||||
public function enrichSingle(array|Model $model): array|Model
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$collection = new Collection([$model]);
|
||||
$collection = new Collection()->push($model);
|
||||
$collection = $this->enrich($collection);
|
||||
|
||||
return $collection->first();
|
||||
|
@@ -188,7 +188,7 @@ class BudgetReportGenerator
|
||||
$limitId = $limit->id;
|
||||
$limitCurrency = $limit->transactionCurrency ?? $this->currency;
|
||||
$currencyId = $limitCurrency->id;
|
||||
$expenses = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, $this->accounts, new Collection([$budget]));
|
||||
$expenses = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, $this->accounts, new Collection()->push($budget));
|
||||
$spent = $expenses[$currencyId]['sum'] ?? '0';
|
||||
$left = -1 === bccomp(bcadd($limit->amount, $spent), '0') ? '0' : bcadd($limit->amount, $spent);
|
||||
$overspent = 1 === bccomp(bcmul($spent, '-1'), $limit->amount) ? bcadd($spent, $limit->amount) : '0';
|
||||
|
@@ -28,6 +28,7 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Enums\RecurrenceRepetitionWeekend;
|
||||
use FireflyIII\Models\RecurrenceRepetition;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Trait FiltersWeekends
|
||||
@@ -39,9 +40,9 @@ trait FiltersWeekends
|
||||
*/
|
||||
protected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
if (RecurrenceRepetitionWeekend::WEEKEND_DO_NOTHING->value === $repetition->weekend) {
|
||||
app('log')->debug('Repetition will not be filtered on weekend days.');
|
||||
Log::debug('Repetition will not be filtered on weekend days.');
|
||||
|
||||
return $dates;
|
||||
}
|
||||
@@ -53,7 +54,7 @@ trait FiltersWeekends
|
||||
if (!$isWeekend) {
|
||||
$return[] = clone $date;
|
||||
|
||||
// app('log')->debug(sprintf('Date is %s, not a weekend date.', $date->format('D d M Y')));
|
||||
// Log::debug(sprintf('Date is %s, not a weekend date.', $date->format('D d M Y')));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ trait FiltersWeekends
|
||||
if (RecurrenceRepetitionWeekend::WEEKEND_TO_FRIDAY->value === $repetition->weekend) {
|
||||
$clone = clone $date;
|
||||
$clone->addDays(5 - $date->dayOfWeekIso);
|
||||
app('log')->debug(
|
||||
Log::debug(
|
||||
sprintf('Date is %s, and this is in the weekend, so corrected to %s (Friday).', $date->format('D d M Y'), $clone->format('D d M Y'))
|
||||
);
|
||||
$return[] = clone $clone;
|
||||
@@ -73,23 +74,23 @@ trait FiltersWeekends
|
||||
if (RecurrenceRepetitionWeekend::WEEKEND_TO_MONDAY->value === $repetition->weekend) {
|
||||
$clone = clone $date;
|
||||
$clone->addDays(8 - $date->dayOfWeekIso);
|
||||
app('log')->debug(
|
||||
Log::debug(
|
||||
sprintf('Date is %s, and this is in the weekend, so corrected to %s (Monday).', $date->format('D d M Y'), $clone->format('D d M Y'))
|
||||
);
|
||||
$return[] = $clone;
|
||||
|
||||
continue;
|
||||
}
|
||||
// app('log')->debug(sprintf('Date is %s, removed from final result', $date->format('D d M Y')));
|
||||
// Log::debug(sprintf('Date is %s, removed from final result', $date->format('D d M Y')));
|
||||
}
|
||||
|
||||
// filter unique dates
|
||||
app('log')->debug(sprintf('Count before filtering: %d', count($dates)));
|
||||
Log::debug(sprintf('Count before filtering: %d', count($dates)));
|
||||
$collection = new Collection($return);
|
||||
$filtered = $collection->unique();
|
||||
$return = $filtered->toArray();
|
||||
|
||||
app('log')->debug(sprintf('Count after filtering: %d', count($return)));
|
||||
Log::debug(sprintf('Count after filtering: %d', count($return)));
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@@ -450,7 +450,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
case 'source_account_id':
|
||||
$account = $this->accountRepository->find((int) $value);
|
||||
if (null !== $account) {
|
||||
$this->collector->setSourceAccounts(new Collection([$account]));
|
||||
$this->collector->setSourceAccounts(new Collection()->push($account));
|
||||
}
|
||||
if (null === $account) {
|
||||
// since the source does not exist, cannot return results:
|
||||
@@ -463,7 +463,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
case '-source_account_id':
|
||||
$account = $this->accountRepository->find((int) $value);
|
||||
if (null !== $account) {
|
||||
$this->collector->excludeSourceAccounts(new Collection([$account]));
|
||||
$this->collector->excludeSourceAccounts(new Collection()->push($account));
|
||||
}
|
||||
if (null === $account) {
|
||||
// since the source does not exist, cannot return results:
|
||||
@@ -580,7 +580,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
case 'destination_account_id':
|
||||
$account = $this->accountRepository->find((int) $value);
|
||||
if (null !== $account) {
|
||||
$this->collector->setDestinationAccounts(new Collection([$account]));
|
||||
$this->collector->setDestinationAccounts(new Collection()->push($account));
|
||||
}
|
||||
if (null === $account) {
|
||||
Log::warning('Call to findNothing() because dest account does not exist (destination_account_id).');
|
||||
@@ -592,7 +592,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
case '-destination_account_id':
|
||||
$account = $this->accountRepository->find((int) $value);
|
||||
if (null !== $account) {
|
||||
$this->collector->excludeDestinationAccounts(new Collection([$account]));
|
||||
$this->collector->excludeDestinationAccounts(new Collection()->push($account));
|
||||
}
|
||||
if (null === $account) {
|
||||
Log::warning('Call to findNothing() because dest account does not exist (-destination_account_id).');
|
||||
@@ -652,37 +652,37 @@ class OperatorQuerySearch implements SearchInterface
|
||||
//
|
||||
case 'source_is_cash':
|
||||
$account = $this->getCashAccount();
|
||||
$this->collector->setSourceAccounts(new Collection([$account]));
|
||||
$this->collector->setSourceAccounts(new Collection()->push($account));
|
||||
|
||||
break;
|
||||
|
||||
case '-source_is_cash':
|
||||
$account = $this->getCashAccount();
|
||||
$this->collector->excludeSourceAccounts(new Collection([$account]));
|
||||
$this->collector->excludeSourceAccounts(new Collection()->push($account));
|
||||
|
||||
break;
|
||||
|
||||
case 'destination_is_cash':
|
||||
$account = $this->getCashAccount();
|
||||
$this->collector->setDestinationAccounts(new Collection([$account]));
|
||||
$this->collector->setDestinationAccounts(new Collection()->push($account));
|
||||
|
||||
break;
|
||||
|
||||
case '-destination_is_cash':
|
||||
$account = $this->getCashAccount();
|
||||
$this->collector->excludeDestinationAccounts(new Collection([$account]));
|
||||
$this->collector->excludeDestinationAccounts(new Collection()->push($account));
|
||||
|
||||
break;
|
||||
|
||||
case 'account_is_cash':
|
||||
$account = $this->getCashAccount();
|
||||
$this->collector->setAccounts(new Collection([$account]));
|
||||
$this->collector->setAccounts(new Collection()->push($account));
|
||||
|
||||
break;
|
||||
|
||||
case '-account_is_cash':
|
||||
$account = $this->getCashAccount();
|
||||
$this->collector->excludeAccounts(new Collection([$account]));
|
||||
$this->collector->excludeAccounts(new Collection()->push($account));
|
||||
|
||||
break;
|
||||
|
||||
@@ -1070,7 +1070,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
case '-bill_is':
|
||||
$bill = $this->billRepository->findByName($value);
|
||||
if (null !== $bill) {
|
||||
$this->collector->excludeBills(new Collection([$bill]));
|
||||
$this->collector->excludeBills(new Collection()->push($bill));
|
||||
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user