mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-22 03:56:42 +00:00
Replace method calls.
This commit is contained in:
@@ -31,9 +31,7 @@ use FireflyIII\Enums\TransactionTypeEnum;
|
|||||||
use FireflyIII\Enums\UserRoleEnum;
|
use FireflyIII\Enums\UserRoleEnum;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Support\Facades\Amount;
|
|
||||||
use FireflyIII\Support\Http\Api\AccountBalanceGrouped;
|
use FireflyIII\Support\Http\Api\AccountBalanceGrouped;
|
||||||
use FireflyIII\Support\Http\Api\CleansChartData;
|
use FireflyIII\Support\Http\Api\CleansChartData;
|
||||||
use FireflyIII\Support\Http\Api\CollectsAccountsFromFilter;
|
use FireflyIII\Support\Http\Api\CollectsAccountsFromFilter;
|
||||||
|
@@ -114,7 +114,7 @@ class BudgetController extends Controller
|
|||||||
// get all limits:
|
// get all limits:
|
||||||
$limits = $this->blRepository->getBudgetLimits($budget, $start, $end);
|
$limits = $this->blRepository->getBudgetLimits($budget, $start, $end);
|
||||||
$rows = [];
|
$rows = [];
|
||||||
$spent = $this->opsRepository->listExpenses($start, $end, null, new Collection([$budget]));
|
$spent = $this->opsRepository->listExpenses($start, $end, null, new Collection()->push($budget));
|
||||||
$expenses = $this->processExpenses($budget->id, $spent, $start, $end);
|
$expenses = $this->processExpenses($budget->id, $spent, $start, $end);
|
||||||
$converter = new ExchangeRateConverter();
|
$converter = new ExchangeRateConverter();
|
||||||
$currencies = [$this->primaryCurrency->id => $this->primaryCurrency];
|
$currencies = [$this->primaryCurrency->id => $this->primaryCurrency];
|
||||||
@@ -208,7 +208,7 @@ class BudgetController extends Controller
|
|||||||
// */
|
// */
|
||||||
// private function noBudgetLimits(Budget $budget, Carbon $start, Carbon $end): array
|
// private function noBudgetLimits(Budget $budget, Carbon $start, Carbon $end): array
|
||||||
// {
|
// {
|
||||||
// $spent = $this->opsRepository->listExpenses($start, $end, null, new Collection([$budget]));
|
// $spent = $this->opsRepository->listExpenses($start, $end, null, new Collection()->push($budget));
|
||||||
//
|
//
|
||||||
// return $this->processExpenses($budget->id, $spent, $start, $end);
|
// return $this->processExpenses($budget->id, $spent, $start, $end);
|
||||||
// }
|
// }
|
||||||
@@ -290,7 +290,7 @@ class BudgetController extends Controller
|
|||||||
// Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
|
// Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
|
||||||
// $end = clone $limit->end_date;
|
// $end = clone $limit->end_date;
|
||||||
// $end->endOfDay();
|
// $end->endOfDay();
|
||||||
// $spent = $this->opsRepository->listExpenses($limit->start_date, $end, null, new Collection([$budget]));
|
// $spent = $this->opsRepository->listExpenses($limit->start_date, $end, null, new Collection()->push($budget));
|
||||||
// $limitCurrencyId = $limit->transaction_currency_id;
|
// $limitCurrencyId = $limit->transaction_currency_id;
|
||||||
//
|
//
|
||||||
// /** @var array $entry */
|
// /** @var array $entry */
|
||||||
|
@@ -232,8 +232,6 @@ abstract class Controller extends BaseController
|
|||||||
$baseUrl = sprintf('%s/api/v1', request()->getSchemeAndHttpHost());
|
$baseUrl = sprintf('%s/api/v1', request()->getSchemeAndHttpHost());
|
||||||
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
||||||
|
|
||||||
// $transformer->collectMetaData(new Collection([$object]));
|
|
||||||
|
|
||||||
$resource = new Item($object, $transformer, $key);
|
$resource = new Item($object, $transformer, $key);
|
||||||
|
|
||||||
return $manager->createData($resource)->toArray();
|
return $manager->createData($resource)->toArray();
|
||||||
|
@@ -76,7 +76,7 @@ class BudgetController extends Controller
|
|||||||
|
|
||||||
/** @var Budget $budget */
|
/** @var Budget $budget */
|
||||||
foreach ($budgets as $budget) {
|
foreach ($budgets as $budget) {
|
||||||
$expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection([$budget]));
|
$expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection()->push($budget));
|
||||||
|
|
||||||
/** @var array $expense */
|
/** @var array $expense */
|
||||||
foreach ($expenses as $expense) {
|
foreach ($expenses as $expense) {
|
||||||
|
@@ -76,7 +76,7 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
/** @var Category $category */
|
/** @var Category $category */
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
$expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection([$category]));
|
$expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection()->push($category));
|
||||||
|
|
||||||
/** @var array $expense */
|
/** @var array $expense */
|
||||||
foreach ($expenses as $expense) {
|
foreach ($expenses as $expense) {
|
||||||
|
@@ -76,7 +76,7 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
/** @var Category $category */
|
/** @var Category $category */
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
$expenses = $this->opsRepository->sumIncome($start, $end, $assetAccounts, new Collection([$category]));
|
$expenses = $this->opsRepository->sumIncome($start, $end, $assetAccounts, new Collection()->push($category));
|
||||||
|
|
||||||
/** @var array $expense */
|
/** @var array $expense */
|
||||||
foreach ($expenses as $expense) {
|
foreach ($expenses as $expense) {
|
||||||
|
@@ -76,7 +76,7 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
/** @var Category $category */
|
/** @var Category $category */
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
$expenses = $this->opsRepository->sumTransfers($start, $end, $assetAccounts, new Collection([$category]));
|
$expenses = $this->opsRepository->sumTransfers($start, $end, $assetAccounts, new Collection()->push($category));
|
||||||
|
|
||||||
/** @var array $expense */
|
/** @var array $expense */
|
||||||
foreach ($expenses as $expense) {
|
foreach ($expenses as $expense) {
|
||||||
|
@@ -152,7 +152,7 @@ class ListController extends Controller
|
|||||||
// use new group collector:
|
// use new group collector:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setUser($admin)->setAccounts(new Collection([$account]))
|
$collector->setUser($admin)->setAccounts(new Collection()->push($account))
|
||||||
->withAPIInformation()->setLimit($pageSize)->setPage($this->parameters->get('page'))->setTypes($types)
|
->withAPIInformation()->setLimit($pageSize)->setPage($this->parameters->get('page'))->setTypes($types)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@@ -75,7 +75,7 @@ class TriggerController extends Controller
|
|||||||
|
|
||||||
/** @var RuleEngineInterface $ruleEngine */
|
/** @var RuleEngineInterface $ruleEngine */
|
||||||
$ruleEngine = app(RuleEngineInterface::class);
|
$ruleEngine = app(RuleEngineInterface::class);
|
||||||
$ruleEngine->setRules(new Collection([$rule]));
|
$ruleEngine->setRules(new Collection()->push($rule));
|
||||||
|
|
||||||
// overrule the rule(s) if necessary.
|
// overrule the rule(s) if necessary.
|
||||||
if (array_key_exists('start', $parameters) && null !== $parameters['start']) {
|
if (array_key_exists('start', $parameters) && null !== $parameters['start']) {
|
||||||
@@ -129,7 +129,7 @@ class TriggerController extends Controller
|
|||||||
|
|
||||||
/** @var RuleEngineInterface $ruleEngine */
|
/** @var RuleEngineInterface $ruleEngine */
|
||||||
$ruleEngine = app(RuleEngineInterface::class);
|
$ruleEngine = app(RuleEngineInterface::class);
|
||||||
$ruleEngine->setRules(new Collection([$rule]));
|
$ruleEngine->setRules(new Collection()->push($rule));
|
||||||
|
|
||||||
// overrule the rule(s) if necessary.
|
// overrule the rule(s) if necessary.
|
||||||
if (array_key_exists('start', $parameters) && null !== $parameters['start']) {
|
if (array_key_exists('start', $parameters) && null !== $parameters['start']) {
|
||||||
|
@@ -133,7 +133,6 @@ class ConfigurationController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(string $configKey): JsonResponse
|
public function show(string $configKey): JsonResponse
|
||||||
{
|
{
|
||||||
$data = [];
|
|
||||||
$dynamic = $this->getDynamicConfiguration();
|
$dynamic = $this->getDynamicConfiguration();
|
||||||
$shortKey = str_replace('configuration.', '', $configKey);
|
$shortKey = str_replace('configuration.', '', $configKey);
|
||||||
if (str_starts_with($configKey, 'configuration.')) {
|
if (str_starts_with($configKey, 'configuration.')) {
|
||||||
|
@@ -165,9 +165,9 @@ class ShowController extends Controller
|
|||||||
// tell the generator which trigger it should look for
|
// tell the generator which trigger it should look for
|
||||||
$engine->setTrigger(WebhookTrigger::tryFrom($webhook->trigger));
|
$engine->setTrigger(WebhookTrigger::tryFrom($webhook->trigger));
|
||||||
// tell the generator which objects to process
|
// tell the generator which objects to process
|
||||||
$engine->setObjects(new Collection([$group]));
|
$engine->setObjects(new Collection()->push($group));
|
||||||
// set the webhook to trigger
|
// set the webhook to trigger
|
||||||
$engine->setWebhooks(new Collection([$webhook]));
|
$engine->setWebhooks(new Collection()->push($webhook));
|
||||||
// tell the generator to generate the messages
|
// tell the generator to generate the messages
|
||||||
$engine->generateMessages();
|
$engine->generateMessages();
|
||||||
|
|
||||||
|
@@ -58,8 +58,8 @@ class StoreByCurrenciesRequest extends FormRequest
|
|||||||
$data = $validator->getData();
|
$data = $validator->getData();
|
||||||
foreach ($data as $date => $rate) {
|
foreach ($data as $date => $rate) {
|
||||||
try {
|
try {
|
||||||
$date = Carbon::createFromFormat('Y-m-d', $date);
|
Carbon::createFromFormat('Y-m-d', $date);
|
||||||
} catch (InvalidFormatException $e) {
|
} catch (InvalidFormatException) {
|
||||||
$validator->errors()->add('date', trans('validation.date', ['attribute' => 'date']));
|
$validator->errors()->add('date', trans('validation.date', ['attribute' => 'date']));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@@ -88,7 +88,7 @@ class StoreByDateRequest extends FormRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$to = Amount::getTransactionCurrencyByCode((string)$key);
|
Amount::getTransactionCurrencyByCode((string)$key);
|
||||||
} catch (FireflyException) {
|
} catch (FireflyException) {
|
||||||
$validator->errors()->add(sprintf('rates.%s', $key), trans('validation.invalid_currency_code', ['code' => $key]));
|
$validator->errors()->add(sprintf('rates.%s', $key), trans('validation.invalid_currency_code', ['code' => $key]));
|
||||||
}
|
}
|
||||||
|
@@ -270,7 +270,7 @@ class TransactionJournalFactory
|
|||||||
$negative = $transactionFactory->createNegative((string) $row['amount'], (string) $row['foreign_amount']);
|
$negative = $transactionFactory->createNegative((string) $row['amount'], (string) $row['foreign_amount']);
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
Log::error(sprintf('Exception creating negative transaction: %s', $e->getMessage()));
|
Log::error(sprintf('Exception creating negative transaction: %s', $e->getMessage()));
|
||||||
$this->forceDeleteOnError(new Collection([$journal]));
|
$this->forceDeleteOnError(new Collection()->push($journal));
|
||||||
|
|
||||||
throw new FireflyException($e->getMessage(), 0, $e);
|
throw new FireflyException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
@@ -305,7 +305,7 @@ class TransactionJournalFactory
|
|||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
Log::error(sprintf('Exception creating positive transaction: %s', $e->getMessage()));
|
Log::error(sprintf('Exception creating positive transaction: %s', $e->getMessage()));
|
||||||
$this->forceTrDelete($negative);
|
$this->forceTrDelete($negative);
|
||||||
$this->forceDeleteOnError(new Collection([$journal]));
|
$this->forceDeleteOnError(new Collection()->push($journal));
|
||||||
|
|
||||||
throw new FireflyException($e->getMessage(), 0, $e);
|
throw new FireflyException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
@@ -132,7 +132,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
|||||||
|
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end)->withAccountInformation()
|
$collector->setAccounts(new Collection()->push($account))->setRange($this->start, $this->end)->withAccountInformation()
|
||||||
->withBudgetInformation()->withCategoryInformation()->withBillInformation()->withNotes()
|
->withBudgetInformation()->withCategoryInformation()->withBillInformation()->withNotes()
|
||||||
;
|
;
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
|
@@ -52,7 +52,7 @@ class DestroyedGroupEventHandler
|
|||||||
/** @var MessageGeneratorInterface $engine */
|
/** @var MessageGeneratorInterface $engine */
|
||||||
$engine = app(MessageGeneratorInterface::class);
|
$engine = app(MessageGeneratorInterface::class);
|
||||||
$engine->setUser($user);
|
$engine->setUser($user);
|
||||||
$engine->setObjects(new Collection([$group]));
|
$engine->setObjects(new Collection()->push($group));
|
||||||
$engine->setTrigger(WebhookTrigger::DESTROY_TRANSACTION);
|
$engine->setTrigger(WebhookTrigger::DESTROY_TRANSACTION);
|
||||||
$engine->generateMessages();
|
$engine->generateMessages();
|
||||||
Log::debug(sprintf('send event RequestedSendWebhookMessages from %s', __METHOD__));
|
Log::debug(sprintf('send event RequestedSendWebhookMessages from %s', __METHOD__));
|
||||||
|
@@ -116,7 +116,7 @@ class StoredGroupEventHandler
|
|||||||
// tell the generator which trigger it should look for
|
// tell the generator which trigger it should look for
|
||||||
$engine->setTrigger(WebhookTrigger::STORE_TRANSACTION);
|
$engine->setTrigger(WebhookTrigger::STORE_TRANSACTION);
|
||||||
// tell the generator which objects to process
|
// tell the generator which objects to process
|
||||||
$engine->setObjects(new Collection([$group]));
|
$engine->setObjects(new Collection()->push($group));
|
||||||
// tell the generator to generate the messages
|
// tell the generator to generate the messages
|
||||||
$engine->generateMessages();
|
$engine->generateMessages();
|
||||||
|
|
||||||
|
@@ -163,7 +163,7 @@ class UpdatedGroupEventHandler
|
|||||||
/** @var MessageGeneratorInterface $engine */
|
/** @var MessageGeneratorInterface $engine */
|
||||||
$engine = app(MessageGeneratorInterface::class);
|
$engine = app(MessageGeneratorInterface::class);
|
||||||
$engine->setUser($user);
|
$engine->setUser($user);
|
||||||
$engine->setObjects(new Collection([$group]));
|
$engine->setObjects(new Collection()->push($group));
|
||||||
$engine->setTrigger(WebhookTrigger::UPDATE_TRANSACTION);
|
$engine->setTrigger(WebhookTrigger::UPDATE_TRANSACTION);
|
||||||
$engine->generateMessages();
|
$engine->generateMessages();
|
||||||
|
|
||||||
|
@@ -762,7 +762,7 @@ trait MetaCollection
|
|||||||
public function setTag(Tag $tag): GroupCollectorInterface
|
public function setTag(Tag $tag): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$this->withTagInformation();
|
$this->withTagInformation();
|
||||||
$this->setTags(new Collection([$tag]));
|
$this->setTags(new Collection()->push($tag));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@ class PopupReport implements PopupReportInterface
|
|||||||
{
|
{
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))
|
$collector->setAccounts(new Collection()->push($account))
|
||||||
->withAccountInformation()
|
->withAccountInformation()
|
||||||
->withBudgetInformation()
|
->withBudgetInformation()
|
||||||
->withCategoryInformation()
|
->withCategoryInformation()
|
||||||
@@ -72,7 +72,7 @@ class PopupReport implements PopupReportInterface
|
|||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector
|
$collector
|
||||||
->setAccounts(new Collection([$account]))
|
->setAccounts(new Collection()->push($account))
|
||||||
->setTypes([TransactionTypeEnum::WITHDRAWAL->value])
|
->setTypes([TransactionTypeEnum::WITHDRAWAL->value])
|
||||||
->withAccountInformation()
|
->withAccountInformation()
|
||||||
->withCategoryInformation()
|
->withCategoryInformation()
|
||||||
@@ -191,7 +191,7 @@ class PopupReport implements PopupReportInterface
|
|||||||
// $set = $attributes['accounts'] ?? new Collection;
|
// $set = $attributes['accounts'] ?? new Collection;
|
||||||
// $set->push($account);
|
// $set->push($account);
|
||||||
|
|
||||||
$collector->setDestinationAccounts(new Collection([$account]))
|
$collector->setDestinationAccounts(new Collection()->push($account))
|
||||||
->setRange($attributes['startDate'], $attributes['endDate'])
|
->setRange($attributes['startDate'], $attributes['endDate'])
|
||||||
->withAccountInformation()
|
->withAccountInformation()
|
||||||
->withBudgetInformation()
|
->withBudgetInformation()
|
||||||
@@ -218,7 +218,7 @@ class PopupReport implements PopupReportInterface
|
|||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector
|
$collector
|
||||||
->setSourceAccounts(new Collection([$account]))
|
->setSourceAccounts(new Collection()->push($account))
|
||||||
->setDestinationAccounts($attributes['accounts'])
|
->setDestinationAccounts($attributes['accounts'])
|
||||||
->setRange($attributes['startDate'], $attributes['endDate'])
|
->setRange($attributes['startDate'], $attributes['endDate'])
|
||||||
->setTypes([TransactionTypeEnum::DEPOSIT->value, TransactionTypeEnum::TRANSFER->value])
|
->setTypes([TransactionTypeEnum::DEPOSIT->value, TransactionTypeEnum::TRANSFER->value])
|
||||||
|
@@ -143,7 +143,7 @@ class ShowController extends Controller
|
|||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector
|
$collector
|
||||||
->setAccounts(new Collection([$account]))
|
->setAccounts(new Collection()->push($account))
|
||||||
->setLimit($pageSize)
|
->setLimit($pageSize)
|
||||||
->setPage($page)
|
->setPage($page)
|
||||||
->withAttachmentInformation()
|
->withAttachmentInformation()
|
||||||
@@ -221,7 +221,7 @@ class ShowController extends Controller
|
|||||||
|
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page)->withAccountInformation()->withCategoryInformation();
|
$collector->setAccounts(new Collection()->push($account))->setLimit($pageSize)->setPage($page)->withAccountInformation()->withCategoryInformation();
|
||||||
|
|
||||||
// this search will not include transaction groups where this asset account (or liability)
|
// this search will not include transaction groups where this asset account (or liability)
|
||||||
// is just part of ONE of the journals. To force this:
|
// is just part of ONE of the journals. To force this:
|
||||||
|
@@ -203,7 +203,7 @@ class BudgetLimitController extends Controller
|
|||||||
if ($request->expectsJson()) {
|
if ($request->expectsJson()) {
|
||||||
$array = $limit->toArray();
|
$array = $limit->toArray();
|
||||||
// add some extra metadata:
|
// add some extra metadata:
|
||||||
$spentArr = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection([$budget]), $currency);
|
$spentArr = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection()->push($budget), $currency);
|
||||||
$array['spent'] = $spentArr[$currency->id]['sum'] ?? '0';
|
$array['spent'] = $spentArr[$currency->id]['sum'] ?? '0';
|
||||||
$array['left_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount']));
|
$array['left_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount']));
|
||||||
$array['amount_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $limit['amount']);
|
$array['amount_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $limit['amount']);
|
||||||
@@ -264,7 +264,7 @@ class BudgetLimitController extends Controller
|
|||||||
$limit->start_date,
|
$limit->start_date,
|
||||||
$limit->end_date,
|
$limit->end_date,
|
||||||
null,
|
null,
|
||||||
new Collection([$budgetLimit->budget]),
|
new Collection()->push($budgetLimit->budget),
|
||||||
$budgetLimit->transactionCurrency
|
$budgetLimit->transactionCurrency
|
||||||
);
|
);
|
||||||
$daysLeft = $this->activeDaysLeft($limit->start_date, $limit->end_date);
|
$daysLeft = $this->activeDaysLeft($limit->start_date, $limit->end_date);
|
||||||
|
@@ -235,7 +235,7 @@ class IndexController extends Controller
|
|||||||
|
|
||||||
/** @var TransactionCurrency $currency */
|
/** @var TransactionCurrency $currency */
|
||||||
foreach ($currencies as $currency) {
|
foreach ($currencies as $currency) {
|
||||||
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, new Collection([$current]), $currency, false);
|
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, new Collection()->push($current), $currency, false);
|
||||||
if (array_key_exists($currency->id, $spentArr) && array_key_exists('sum', $spentArr[$currency->id])) {
|
if (array_key_exists($currency->id, $spentArr) && array_key_exists('sum', $spentArr[$currency->id])) {
|
||||||
$array['spent'][$currency->id]['spent'] = $spentArr[$currency->id]['sum'];
|
$array['spent'][$currency->id]['spent'] = $spentArr[$currency->id]['sum'];
|
||||||
$array['spent'][$currency->id]['currency_id'] = $currency->id;
|
$array['spent'][$currency->id]['currency_id'] = $currency->id;
|
||||||
|
@@ -235,7 +235,7 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))
|
$collector->setAccounts(new Collection()->push($account))
|
||||||
->setRange($start, $end)
|
->setRange($start, $end)
|
||||||
->withBudgetInformation()->setTypes([TransactionTypeEnum::WITHDRAWAL->value])
|
->withBudgetInformation()->setTypes([TransactionTypeEnum::WITHDRAWAL->value])
|
||||||
;
|
;
|
||||||
@@ -322,7 +322,7 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionTypeEnum::WITHDRAWAL->value]);
|
$collector->setAccounts(new Collection()->push($account))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionTypeEnum::WITHDRAWAL->value]);
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
$result = [];
|
$result = [];
|
||||||
$chartData = [];
|
$chartData = [];
|
||||||
@@ -429,7 +429,7 @@ class AccountController extends Controller
|
|||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
|
||||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionTypeEnum::DEPOSIT->value]);
|
$collector->setAccounts(new Collection()->push($account))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionTypeEnum::DEPOSIT->value]);
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
$result = [];
|
$result = [];
|
||||||
$chartData = [];
|
$chartData = [];
|
||||||
|
@@ -100,7 +100,7 @@ class BudgetController extends Controller
|
|||||||
return response()->json($cache->get());
|
return response()->json($cache->get());
|
||||||
}
|
}
|
||||||
$step = $this->calculateStep($start, $end); // depending on diff, do something with range of chart.
|
$step = $this->calculateStep($start, $end); // depending on diff, do something with range of chart.
|
||||||
$collection = new Collection([$budget]);
|
$collection = new Collection()->push($budget);
|
||||||
$chartData = [];
|
$chartData = [];
|
||||||
$loopStart = clone $start;
|
$loopStart = clone $start;
|
||||||
$loopStart = Navigation::startOfPeriod($loopStart, $step);
|
$loopStart = Navigation::startOfPeriod($loopStart, $step);
|
||||||
@@ -169,7 +169,7 @@ class BudgetController extends Controller
|
|||||||
$locale = app('steam')->getLocale();
|
$locale = app('steam')->getLocale();
|
||||||
$entries = [];
|
$entries = [];
|
||||||
$amount = $budgetLimit->amount ?? '0';
|
$amount = $budgetLimit->amount ?? '0';
|
||||||
$budgetCollection = new Collection([$budget]);
|
$budgetCollection = new Collection()->push($budget);
|
||||||
$currency = $budgetLimit->transactionCurrency;
|
$currency = $budgetLimit->transactionCurrency;
|
||||||
if ($this->convertToPrimary) {
|
if ($this->convertToPrimary) {
|
||||||
$amount = $budgetLimit->native_amount ?? $amount;
|
$amount = $budgetLimit->native_amount ?? $amount;
|
||||||
@@ -535,7 +535,7 @@ class BudgetController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get spent amount in this period for this currency.
|
// get spent amount in this period for this currency.
|
||||||
$sum = $this->opsRepository->sumExpenses($currentStart, $currentEnd, $accounts, new Collection([$budget]), $currency);
|
$sum = $this->opsRepository->sumExpenses($currentStart, $currentEnd, $accounts, new Collection()->push($budget), $currency);
|
||||||
$amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0');
|
$amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0');
|
||||||
$chartData[0]['entries'][$title] = app('steam')->bcround($amount, $currency->decimal_places);
|
$chartData[0]['entries'][$title] = app('steam')->bcround($amount, $currency->decimal_places);
|
||||||
|
|
||||||
|
@@ -163,7 +163,7 @@ class BudgetReportController extends Controller
|
|||||||
public function mainChart(Collection $accounts, Budget $budget, Carbon $start, Carbon $end): JsonResponse
|
public function mainChart(Collection $accounts, Budget $budget, Carbon $start, Carbon $end): JsonResponse
|
||||||
{
|
{
|
||||||
$chartData = [];
|
$chartData = [];
|
||||||
$spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection([$budget]));
|
$spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection()->push($budget));
|
||||||
$format = Navigation::preferredCarbonLocalizedFormat($start, $end);
|
$format = Navigation::preferredCarbonLocalizedFormat($start, $end);
|
||||||
|
|
||||||
// loop expenses.
|
// loop expenses.
|
||||||
|
@@ -174,7 +174,7 @@ class CategoryController extends Controller
|
|||||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
$categoryId = $category->id;
|
$categoryId = $category->id;
|
||||||
// this gives us all currencies
|
// this gives us all currencies
|
||||||
$collection = new Collection([$category]);
|
$collection = new Collection()->push($category);
|
||||||
$expenses = $opsRepository->listExpenses($start, $end, $accounts, $collection);
|
$expenses = $opsRepository->listExpenses($start, $end, $accounts, $collection);
|
||||||
$income = $opsRepository->listIncome($start, $end, $accounts, $collection);
|
$income = $opsRepository->listIncome($start, $end, $accounts, $collection);
|
||||||
}
|
}
|
||||||
|
@@ -208,8 +208,8 @@ class CategoryReportController extends Controller
|
|||||||
public function mainChart(Collection $accounts, Category $category, Carbon $start, Carbon $end): JsonResponse
|
public function mainChart(Collection $accounts, Category $category, Carbon $start, Carbon $end): JsonResponse
|
||||||
{
|
{
|
||||||
$chartData = [];
|
$chartData = [];
|
||||||
$spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection([$category]));
|
$spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection()->push($category));
|
||||||
$earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection([$category]));
|
$earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection()->push($category));
|
||||||
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||||
// loop expenses.
|
// loop expenses.
|
||||||
foreach ($spent as $currency) {
|
foreach ($spent as $currency) {
|
||||||
|
@@ -150,7 +150,7 @@ class DoubleReportController extends Controller
|
|||||||
{
|
{
|
||||||
$chartData = [];
|
$chartData = [];
|
||||||
|
|
||||||
$opposing = $this->repository->expandWithDoubles(new Collection([$account]));
|
$opposing = $this->repository->expandWithDoubles(new Collection()->push($account));
|
||||||
$accounts = $accounts->merge($opposing);
|
$accounts = $accounts->merge($opposing);
|
||||||
$spent = $this->opsRepository->listExpenses($start, $end, $accounts);
|
$spent = $this->opsRepository->listExpenses($start, $end, $accounts);
|
||||||
$earned = $this->opsRepository->listIncome($start, $end, $accounts);
|
$earned = $this->opsRepository->listIncome($start, $end, $accounts);
|
||||||
|
@@ -212,8 +212,8 @@ class TagReportController extends Controller
|
|||||||
public function mainChart(Collection $accounts, Tag $tag, Carbon $start, Carbon $end): JsonResponse
|
public function mainChart(Collection $accounts, Tag $tag, Carbon $start, Carbon $end): JsonResponse
|
||||||
{
|
{
|
||||||
$chartData = [];
|
$chartData = [];
|
||||||
$spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection([$tag]));
|
$spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection()->push($tag));
|
||||||
$earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection([$tag]));
|
$earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection()->push($tag));
|
||||||
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||||
|
|
||||||
// loop expenses.
|
// loop expenses.
|
||||||
|
@@ -170,7 +170,7 @@ class HomeController extends Controller
|
|||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))->withAccountInformation()->setRange($start, $end)->setLimit(10)->setPage(1);
|
$collector->setAccounts(new Collection()->push($account))->withAccountInformation()->setRange($start, $end)->setLimit(10)->setPage(1);
|
||||||
$set = $collector->getExtractedJournals();
|
$set = $collector->getExtractedJournals();
|
||||||
$transactions[] = ['transactions' => $set, 'account' => $account];
|
$transactions[] = ['transactions' => $set, 'account' => $account];
|
||||||
}
|
}
|
||||||
|
@@ -217,7 +217,7 @@ class ReconcileController extends Controller
|
|||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
|
||||||
$collector->setAccounts(new Collection([$account]))
|
$collector->setAccounts(new Collection()->push($account))
|
||||||
->setRange($selectionStart, $selectionEnd)
|
->setRange($selectionStart, $selectionEnd)
|
||||||
->withBudgetInformation()->withCategoryInformation()->withAccountInformation()
|
->withBudgetInformation()->withCategoryInformation()->withAccountInformation()
|
||||||
;
|
;
|
||||||
|
@@ -74,7 +74,7 @@ class TriggerController extends Controller
|
|||||||
|
|
||||||
/** @var CreateRecurringTransactions $job */
|
/** @var CreateRecurringTransactions $job */
|
||||||
$job = app(CreateRecurringTransactions::class);
|
$job = app(CreateRecurringTransactions::class);
|
||||||
$job->setRecurrences(new Collection([$recurrence]));
|
$job->setRecurrences(new Collection()->push($recurrence));
|
||||||
$job->setDate($date);
|
$job->setDate($date);
|
||||||
$job->setForce(false);
|
$job->setForce(false);
|
||||||
$job->handle();
|
$job->handle();
|
||||||
|
@@ -152,7 +152,7 @@ class SelectController extends Controller
|
|||||||
$newRuleEngine = app(RuleEngineInterface::class);
|
$newRuleEngine = app(RuleEngineInterface::class);
|
||||||
|
|
||||||
// set rules:
|
// set rules:
|
||||||
$newRuleEngine->setRules(new Collection([$rule]));
|
$newRuleEngine->setRules(new Collection()->push($rule));
|
||||||
$newRuleEngine->setRefreshTriggers(false);
|
$newRuleEngine->setRefreshTriggers(false);
|
||||||
$collection = $newRuleEngine->find();
|
$collection = $newRuleEngine->find();
|
||||||
$collection = $collection->slice(0, 20);
|
$collection = $collection->slice(0, 20);
|
||||||
@@ -196,7 +196,7 @@ class SelectController extends Controller
|
|||||||
$newRuleEngine = app(RuleEngineInterface::class);
|
$newRuleEngine = app(RuleEngineInterface::class);
|
||||||
|
|
||||||
// set rules:
|
// set rules:
|
||||||
$newRuleEngine->setRules(new Collection([$rule]));
|
$newRuleEngine->setRules(new Collection()->push($rule));
|
||||||
$collection = $newRuleEngine->find();
|
$collection = $newRuleEngine->find();
|
||||||
$collection = $collection->slice(0, 20);
|
$collection = $collection->slice(0, 20);
|
||||||
|
|
||||||
|
@@ -78,7 +78,7 @@ class ExecutionController extends Controller
|
|||||||
|
|
||||||
// set rules:
|
// set rules:
|
||||||
// #10427, file rule group and not the set of rules.
|
// #10427, file rule group and not the set of rules.
|
||||||
$collection = new Collection([$ruleGroup]);
|
$collection = new Collection()->push($ruleGroup);
|
||||||
$newRuleEngine->setRuleGroups($collection);
|
$newRuleEngine->setRuleGroups($collection);
|
||||||
$newRuleEngine->fire();
|
$newRuleEngine->fire();
|
||||||
|
|
||||||
|
@@ -269,7 +269,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
|
|||||||
// if has one, calculate expenses and use that as a base.
|
// if has one, calculate expenses and use that as a base.
|
||||||
$repository = app(OperationsRepositoryInterface::class);
|
$repository = app(OperationsRepositoryInterface::class);
|
||||||
$repository->setUser($autoBudget->budget->user);
|
$repository->setUser($autoBudget->budget->user);
|
||||||
$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency);
|
$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection()->push($autoBudget->budget), $autoBudget->transactionCurrency);
|
||||||
$currencyId = $autoBudget->transaction_currency_id;
|
$currencyId = $autoBudget->transaction_currency_id;
|
||||||
$spentAmount = $spent[$currencyId]['sum'] ?? '0';
|
$spentAmount = $spent[$currencyId]['sum'] ?? '0';
|
||||||
Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));
|
Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));
|
||||||
@@ -329,7 +329,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
|
|||||||
// if has one, calculate expenses and use that as a base.
|
// if has one, calculate expenses and use that as a base.
|
||||||
$repository = app(OperationsRepositoryInterface::class);
|
$repository = app(OperationsRepositoryInterface::class);
|
||||||
$repository->setUser($autoBudget->budget->user);
|
$repository->setUser($autoBudget->budget->user);
|
||||||
$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency);
|
$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection()->push($autoBudget->budget), $autoBudget->transactionCurrency);
|
||||||
$currencyId = $autoBudget->transaction_currency_id;
|
$currencyId = $autoBudget->transaction_currency_id;
|
||||||
$spentAmount = $spent[$currencyId]['sum'] ?? '0';
|
$spentAmount = $spent[$currencyId]['sum'] ?? '0';
|
||||||
Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));
|
Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));
|
||||||
|
@@ -114,7 +114,7 @@ class FrontpageChartGenerator
|
|||||||
*/
|
*/
|
||||||
private function noBudgetLimits(array $data, Budget $budget): array
|
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 */
|
/** @var array $entry */
|
||||||
foreach ($spent as $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));
|
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)));
|
Log::debug(sprintf('Spent array has %d entries.', count($spent)));
|
||||||
|
|
||||||
/** @var array $entry */
|
/** @var array $entry */
|
||||||
|
@@ -40,7 +40,7 @@ class WholePeriodChartGenerator
|
|||||||
|
|
||||||
public function generate(Category $category, Carbon $start, Carbon $end): array
|
public function generate(Category $category, Carbon $start, Carbon $end): array
|
||||||
{
|
{
|
||||||
$collection = new Collection([$category]);
|
$collection = new Collection()->push($category);
|
||||||
|
|
||||||
/** @var OperationsRepositoryInterface $opsRepository */
|
/** @var OperationsRepositoryInterface $opsRepository */
|
||||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
|
@@ -191,7 +191,7 @@ trait AugumentData
|
|||||||
|
|
||||||
$set = $blRepository->getBudgetLimits($budget, $start, $end);
|
$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
|
// merge sets based on a key, in case of convert to primary currency
|
||||||
$limits = new Collection();
|
$limits = new Collection();
|
||||||
|
@@ -90,7 +90,7 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
public function enrichSingle(array|Model $model): Account|array
|
public function enrichSingle(array|Model $model): Account|array
|
||||||
{
|
{
|
||||||
Log::debug(__METHOD__);
|
Log::debug(__METHOD__);
|
||||||
$collection = new Collection([$model]);
|
$collection = new Collection()->push($model);
|
||||||
$collection = $this->enrich($collection);
|
$collection = $this->enrich($collection);
|
||||||
|
|
||||||
return $collection->first();
|
return $collection->first();
|
||||||
|
@@ -73,7 +73,7 @@ class BudgetEnrichment implements EnrichmentInterface
|
|||||||
public function enrichSingle(array|Model $model): array|Model
|
public function enrichSingle(array|Model $model): array|Model
|
||||||
{
|
{
|
||||||
Log::debug(__METHOD__);
|
Log::debug(__METHOD__);
|
||||||
$collection = new Collection([$model]);
|
$collection = new Collection()->push($model);
|
||||||
$collection = $this->enrich($collection);
|
$collection = $this->enrich($collection);
|
||||||
|
|
||||||
return $collection->first();
|
return $collection->first();
|
||||||
@@ -167,7 +167,7 @@ class BudgetEnrichment implements EnrichmentInterface
|
|||||||
$opsRepository->setUser($this->user);
|
$opsRepository->setUser($this->user);
|
||||||
$opsRepository->setUserGroup($this->userGroup);
|
$opsRepository->setUserGroup($this->userGroup);
|
||||||
// $spent = $this->beautify();
|
// $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);
|
$expenses = $opsRepository->collectExpenses($this->start, $this->end, null, $this->collection, null);
|
||||||
foreach ($this->collection as $item) {
|
foreach ($this->collection as $item) {
|
||||||
$id = (int)$item->id;
|
$id = (int)$item->id;
|
||||||
|
@@ -65,7 +65,7 @@ class CategoryEnrichment implements EnrichmentInterface
|
|||||||
public function enrichSingle(array|Model $model): array|Model
|
public function enrichSingle(array|Model $model): array|Model
|
||||||
{
|
{
|
||||||
Log::debug(__METHOD__);
|
Log::debug(__METHOD__);
|
||||||
$collection = new Collection([$model]);
|
$collection = new Collection()->push($model);
|
||||||
$collection = $this->enrich($collection);
|
$collection = $this->enrich($collection);
|
||||||
|
|
||||||
return $collection->first();
|
return $collection->first();
|
||||||
|
@@ -80,7 +80,7 @@ class PiggyBankEnrichment implements EnrichmentInterface
|
|||||||
public function enrichSingle(array|Model $model): array|Model
|
public function enrichSingle(array|Model $model): array|Model
|
||||||
{
|
{
|
||||||
Log::debug(__METHOD__);
|
Log::debug(__METHOD__);
|
||||||
$collection = new Collection([$model]);
|
$collection = new Collection()->push($model);
|
||||||
$collection = $this->enrich($collection);
|
$collection = $this->enrich($collection);
|
||||||
|
|
||||||
return $collection->first();
|
return $collection->first();
|
||||||
|
@@ -69,7 +69,7 @@ class PiggyBankEventEnrichment implements EnrichmentInterface
|
|||||||
public function enrichSingle(array|Model $model): array|Model
|
public function enrichSingle(array|Model $model): array|Model
|
||||||
{
|
{
|
||||||
Log::debug(__METHOD__);
|
Log::debug(__METHOD__);
|
||||||
$collection = new Collection([$model]);
|
$collection = new Collection()->push($model);
|
||||||
$collection = $this->enrich($collection);
|
$collection = $this->enrich($collection);
|
||||||
|
|
||||||
return $collection->first();
|
return $collection->first();
|
||||||
|
@@ -101,7 +101,7 @@ class RecurringEnrichment implements EnrichmentInterface
|
|||||||
public function enrichSingle(array|Model $model): array|Model
|
public function enrichSingle(array|Model $model): array|Model
|
||||||
{
|
{
|
||||||
Log::debug(__METHOD__);
|
Log::debug(__METHOD__);
|
||||||
$collection = new Collection([$model]);
|
$collection = new Collection()->push($model);
|
||||||
$collection = $this->enrich($collection);
|
$collection = $this->enrich($collection);
|
||||||
|
|
||||||
return $collection->first();
|
return $collection->first();
|
||||||
|
@@ -145,7 +145,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
|||||||
public function enrichSingle(array|Model $model): array|Model
|
public function enrichSingle(array|Model $model): array|Model
|
||||||
{
|
{
|
||||||
Log::debug(__METHOD__);
|
Log::debug(__METHOD__);
|
||||||
$collection = new Collection([$model]);
|
$collection = new Collection()->push($model);
|
||||||
$collection = $this->enrich($collection);
|
$collection = $this->enrich($collection);
|
||||||
|
|
||||||
return $collection->first();
|
return $collection->first();
|
||||||
|
@@ -68,7 +68,7 @@ class TransactionGroupEnrichment implements EnrichmentInterface
|
|||||||
{
|
{
|
||||||
Log::debug(__METHOD__);
|
Log::debug(__METHOD__);
|
||||||
if (is_array($model)) {
|
if (is_array($model)) {
|
||||||
$collection = new Collection([$model]);
|
$collection = new Collection()->push($model);
|
||||||
$collection = $this->enrich($collection);
|
$collection = $this->enrich($collection);
|
||||||
|
|
||||||
return $collection->first();
|
return $collection->first();
|
||||||
|
@@ -70,7 +70,7 @@ class WebhookEnrichment implements EnrichmentInterface
|
|||||||
public function enrichSingle(array|Model $model): array|Model
|
public function enrichSingle(array|Model $model): array|Model
|
||||||
{
|
{
|
||||||
Log::debug(__METHOD__);
|
Log::debug(__METHOD__);
|
||||||
$collection = new Collection([$model]);
|
$collection = new Collection()->push($model);
|
||||||
$collection = $this->enrich($collection);
|
$collection = $this->enrich($collection);
|
||||||
|
|
||||||
return $collection->first();
|
return $collection->first();
|
||||||
|
@@ -188,7 +188,7 @@ class BudgetReportGenerator
|
|||||||
$limitId = $limit->id;
|
$limitId = $limit->id;
|
||||||
$limitCurrency = $limit->transactionCurrency ?? $this->currency;
|
$limitCurrency = $limit->transactionCurrency ?? $this->currency;
|
||||||
$currencyId = $limitCurrency->id;
|
$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';
|
$spent = $expenses[$currencyId]['sum'] ?? '0';
|
||||||
$left = -1 === bccomp(bcadd($limit->amount, $spent), '0') ? '0' : bcadd($limit->amount, $spent);
|
$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';
|
$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\Enums\RecurrenceRepetitionWeekend;
|
||||||
use FireflyIII\Models\RecurrenceRepetition;
|
use FireflyIII\Models\RecurrenceRepetition;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trait FiltersWeekends
|
* Trait FiltersWeekends
|
||||||
@@ -39,9 +40,9 @@ trait FiltersWeekends
|
|||||||
*/
|
*/
|
||||||
protected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array
|
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) {
|
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;
|
return $dates;
|
||||||
}
|
}
|
||||||
@@ -53,7 +54,7 @@ trait FiltersWeekends
|
|||||||
if (!$isWeekend) {
|
if (!$isWeekend) {
|
||||||
$return[] = clone $date;
|
$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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ trait FiltersWeekends
|
|||||||
if (RecurrenceRepetitionWeekend::WEEKEND_TO_FRIDAY->value === $repetition->weekend) {
|
if (RecurrenceRepetitionWeekend::WEEKEND_TO_FRIDAY->value === $repetition->weekend) {
|
||||||
$clone = clone $date;
|
$clone = clone $date;
|
||||||
$clone->addDays(5 - $date->dayOfWeekIso);
|
$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'))
|
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;
|
$return[] = clone $clone;
|
||||||
@@ -73,23 +74,23 @@ trait FiltersWeekends
|
|||||||
if (RecurrenceRepetitionWeekend::WEEKEND_TO_MONDAY->value === $repetition->weekend) {
|
if (RecurrenceRepetitionWeekend::WEEKEND_TO_MONDAY->value === $repetition->weekend) {
|
||||||
$clone = clone $date;
|
$clone = clone $date;
|
||||||
$clone->addDays(8 - $date->dayOfWeekIso);
|
$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'))
|
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;
|
$return[] = $clone;
|
||||||
|
|
||||||
continue;
|
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
|
// 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);
|
$collection = new Collection($return);
|
||||||
$filtered = $collection->unique();
|
$filtered = $collection->unique();
|
||||||
$return = $filtered->toArray();
|
$return = $filtered->toArray();
|
||||||
|
|
||||||
app('log')->debug(sprintf('Count after filtering: %d', count($return)));
|
Log::debug(sprintf('Count after filtering: %d', count($return)));
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@@ -450,7 +450,7 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
case 'source_account_id':
|
case 'source_account_id':
|
||||||
$account = $this->accountRepository->find((int) $value);
|
$account = $this->accountRepository->find((int) $value);
|
||||||
if (null !== $account) {
|
if (null !== $account) {
|
||||||
$this->collector->setSourceAccounts(new Collection([$account]));
|
$this->collector->setSourceAccounts(new Collection()->push($account));
|
||||||
}
|
}
|
||||||
if (null === $account) {
|
if (null === $account) {
|
||||||
// since the source does not exist, cannot return results:
|
// since the source does not exist, cannot return results:
|
||||||
@@ -463,7 +463,7 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
case '-source_account_id':
|
case '-source_account_id':
|
||||||
$account = $this->accountRepository->find((int) $value);
|
$account = $this->accountRepository->find((int) $value);
|
||||||
if (null !== $account) {
|
if (null !== $account) {
|
||||||
$this->collector->excludeSourceAccounts(new Collection([$account]));
|
$this->collector->excludeSourceAccounts(new Collection()->push($account));
|
||||||
}
|
}
|
||||||
if (null === $account) {
|
if (null === $account) {
|
||||||
// since the source does not exist, cannot return results:
|
// since the source does not exist, cannot return results:
|
||||||
@@ -580,7 +580,7 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
case 'destination_account_id':
|
case 'destination_account_id':
|
||||||
$account = $this->accountRepository->find((int) $value);
|
$account = $this->accountRepository->find((int) $value);
|
||||||
if (null !== $account) {
|
if (null !== $account) {
|
||||||
$this->collector->setDestinationAccounts(new Collection([$account]));
|
$this->collector->setDestinationAccounts(new Collection()->push($account));
|
||||||
}
|
}
|
||||||
if (null === $account) {
|
if (null === $account) {
|
||||||
Log::warning('Call to findNothing() because dest account does not exist (destination_account_id).');
|
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':
|
case '-destination_account_id':
|
||||||
$account = $this->accountRepository->find((int) $value);
|
$account = $this->accountRepository->find((int) $value);
|
||||||
if (null !== $account) {
|
if (null !== $account) {
|
||||||
$this->collector->excludeDestinationAccounts(new Collection([$account]));
|
$this->collector->excludeDestinationAccounts(new Collection()->push($account));
|
||||||
}
|
}
|
||||||
if (null === $account) {
|
if (null === $account) {
|
||||||
Log::warning('Call to findNothing() because dest account does not exist (-destination_account_id).');
|
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':
|
case 'source_is_cash':
|
||||||
$account = $this->getCashAccount();
|
$account = $this->getCashAccount();
|
||||||
$this->collector->setSourceAccounts(new Collection([$account]));
|
$this->collector->setSourceAccounts(new Collection()->push($account));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '-source_is_cash':
|
case '-source_is_cash':
|
||||||
$account = $this->getCashAccount();
|
$account = $this->getCashAccount();
|
||||||
$this->collector->excludeSourceAccounts(new Collection([$account]));
|
$this->collector->excludeSourceAccounts(new Collection()->push($account));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'destination_is_cash':
|
case 'destination_is_cash':
|
||||||
$account = $this->getCashAccount();
|
$account = $this->getCashAccount();
|
||||||
$this->collector->setDestinationAccounts(new Collection([$account]));
|
$this->collector->setDestinationAccounts(new Collection()->push($account));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '-destination_is_cash':
|
case '-destination_is_cash':
|
||||||
$account = $this->getCashAccount();
|
$account = $this->getCashAccount();
|
||||||
$this->collector->excludeDestinationAccounts(new Collection([$account]));
|
$this->collector->excludeDestinationAccounts(new Collection()->push($account));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'account_is_cash':
|
case 'account_is_cash':
|
||||||
$account = $this->getCashAccount();
|
$account = $this->getCashAccount();
|
||||||
$this->collector->setAccounts(new Collection([$account]));
|
$this->collector->setAccounts(new Collection()->push($account));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '-account_is_cash':
|
case '-account_is_cash':
|
||||||
$account = $this->getCashAccount();
|
$account = $this->getCashAccount();
|
||||||
$this->collector->excludeAccounts(new Collection([$account]));
|
$this->collector->excludeAccounts(new Collection()->push($account));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1070,7 +1070,7 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
case '-bill_is':
|
case '-bill_is':
|
||||||
$bill = $this->billRepository->findByName($value);
|
$bill = $this->billRepository->findByName($value);
|
||||||
if (null !== $bill) {
|
if (null !== $bill) {
|
||||||
$this->collector->excludeBills(new Collection([$bill]));
|
$this->collector->excludeBills(new Collection()->push($bill));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user