mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Remove static references
This commit is contained in:
@@ -165,17 +165,17 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
Log::debug(sprintf('Searching for account named "%s" (of user #%d) of the following type(s)', $name, $this->user->id), ['types' => $types]);
|
||||
app('log')->debug(sprintf('Searching for account named "%s" (of user #%d) of the following type(s)', $name, $this->user->id), ['types' => $types]);
|
||||
|
||||
$query->where('accounts.name', $name);
|
||||
/** @var Account $account */
|
||||
$account = $query->first(['accounts.*']);
|
||||
if (null === $account) {
|
||||
Log::debug(sprintf('There is no account with name "%s" of types', $name), $types);
|
||||
app('log')->debug(sprintf('There is no account with name "%s" of types', $name), $types);
|
||||
|
||||
return null;
|
||||
}
|
||||
Log::debug(sprintf('Found #%d (%s) with type id %d', $account->id, $account->name, $account->account_type_id));
|
||||
app('log')->debug(sprintf('Found #%d (%s) with type id %d', $account->id, $account->name, $account->account_type_id));
|
||||
|
||||
return $account;
|
||||
}
|
||||
@@ -568,14 +568,14 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
];
|
||||
if (array_key_exists(ucfirst($type), $sets)) {
|
||||
$order = (int)$this->getAccountsByType($sets[ucfirst($type)])->max('order');
|
||||
Log::debug(sprintf('Return max order of "%s" set: %d', $type, $order));
|
||||
app('log')->debug(sprintf('Return max order of "%s" set: %d', $type, $order));
|
||||
|
||||
return $order;
|
||||
}
|
||||
$specials = [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION];
|
||||
|
||||
$order = (int)$this->getAccountsByType($specials)->max('order');
|
||||
Log::debug(sprintf('Return max order of "%s" set (specials!): %d', $type, $order));
|
||||
app('log')->debug(sprintf('Return max order of "%s" set (specials!): %d', $type, $order));
|
||||
|
||||
return $order;
|
||||
}
|
||||
@@ -670,7 +670,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
continue;
|
||||
}
|
||||
if ($index !== (int)$account->order) {
|
||||
Log::debug(sprintf('Account #%d ("%s"): order should %d be but is %d.', $account->id, $account->name, $index, $account->order));
|
||||
app('log')->debug(sprintf('Account #%d ("%s"): order should %d be but is %d.', $account->id, $account->name, $index, $account->order));
|
||||
$account->order = $index;
|
||||
$account->save();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class AccountTasker implements AccountTaskerInterface
|
||||
$yesterday->subDay();
|
||||
$startSet = app('steam')->balancesByAccounts($accounts, $yesterday);
|
||||
$endSet = app('steam')->balancesByAccounts($accounts, $end);
|
||||
Log::debug('Start of accountreport');
|
||||
app('log')->debug('Start of accountreport');
|
||||
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
@@ -99,9 +99,9 @@ class AccountTasker implements AccountTaskerInterface
|
||||
|
||||
// first journal exists, and is on start, then this is the actual opening balance:
|
||||
if (null !== $first && $first->date->isSameDay($start) && TransactionType::OPENING_BALANCE === $first->transactionType->type) {
|
||||
Log::debug(sprintf('Date of first journal for %s is %s', $account->name, $first->date->format('Y-m-d')));
|
||||
app('log')->debug(sprintf('Date of first journal for %s is %s', $account->name, $first->date->format('Y-m-d')));
|
||||
$entry['start_balance'] = $first->transactions()->where('account_id', $account->id)->first()->amount;
|
||||
Log::debug(sprintf('Account %s was opened on %s, so opening balance is %f', $account->name, $start->format('Y-m-d'), $entry['start_balance']));
|
||||
app('log')->debug(sprintf('Account %s was opened on %s, so opening balance is %f', $account->name, $start->format('Y-m-d'), $entry['start_balance']));
|
||||
}
|
||||
$return['sums'][$currency->id]['start'] = bcadd($return['sums'][$currency->id]['start'], $entry['start_balance']);
|
||||
$return['sums'][$currency->id]['end'] = bcadd($return['sums'][$currency->id]['end'], $entry['end_balance']);
|
||||
@@ -190,7 +190,7 @@ class AccountTasker implements AccountTaskerInterface
|
||||
];
|
||||
$report['accounts'][$key]['sum'] = bcadd($report['accounts'][$key]['sum'], $journal['amount']);
|
||||
|
||||
Log::debug(sprintf('Sum for %s is now %s', $journal['destination_account_name'], $report['accounts'][$key]['sum']));
|
||||
app('log')->debug(sprintf('Sum for %s is now %s', $journal['destination_account_name'], $report['accounts'][$key]['sum']));
|
||||
|
||||
++$report['accounts'][$key]['count'];
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
|
||||
try {
|
||||
$unencryptedContent = Crypt::decrypt($encryptedContent); // verified
|
||||
} catch (DecryptException $e) {
|
||||
Log::debug(sprintf('Could not decrypt attachment #%d but this is fine: %s', $attachment->id, $e->getMessage()));
|
||||
app('log')->debug(sprintf('Could not decrypt attachment #%d but this is fine: %s', $attachment->id, $e->getMessage()));
|
||||
$unencryptedContent = $encryptedContent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
if (null !== $billId) {
|
||||
$searchResult = $this->find((int)$billId);
|
||||
if (null !== $searchResult) {
|
||||
Log::debug(sprintf('Found bill based on #%d, will return it.', $billId));
|
||||
app('log')->debug(sprintf('Found bill based on #%d, will return it.', $billId));
|
||||
|
||||
return $searchResult;
|
||||
}
|
||||
@@ -148,12 +148,12 @@ class BillRepository implements BillRepositoryInterface
|
||||
if (null !== $billName) {
|
||||
$searchResult = $this->findByName((string)$billName);
|
||||
if (null !== $searchResult) {
|
||||
Log::debug(sprintf('Found bill based on "%s", will return it.', $billName));
|
||||
app('log')->debug(sprintf('Found bill based on "%s", will return it.', $billName));
|
||||
|
||||
return $searchResult;
|
||||
}
|
||||
}
|
||||
Log::debug('Found nothing');
|
||||
app('log')->debug('Found nothing');
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -373,7 +373,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
*/
|
||||
public function getPaidDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
//Log::debug('Now in getPaidDatesInRange()');
|
||||
//app('log')->debug('Now in getPaidDatesInRange()');
|
||||
|
||||
return $bill->transactionJournals()
|
||||
->before($end)->after($start)->get(
|
||||
@@ -498,7 +498,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
$journal = $bill->user->transactionJournals()->find((int)$transaction['transaction_journal_id']);
|
||||
$journal->bill_id = $bill->id;
|
||||
$journal->save();
|
||||
Log::debug(sprintf('Linked journal #%d to bill #%d', $journal->id, $bill->id));
|
||||
app('log')->debug(sprintf('Linked journal #%d to bill #%d', $journal->id, $bill->id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,12 +522,12 @@ class BillRepository implements BillRepositoryInterface
|
||||
}
|
||||
// find the most recent date for this bill NOT in the future. Cache this date:
|
||||
$start = clone $bill->date;
|
||||
Log::debug('nextExpectedMatch: Start is ' . $start->format('Y-m-d'));
|
||||
app('log')->debug('nextExpectedMatch: Start is ' . $start->format('Y-m-d'));
|
||||
|
||||
while ($start < $date) {
|
||||
Log::debug(sprintf('$start (%s) < $date (%s)', $start->format('Y-m-d'), $date->format('Y-m-d')));
|
||||
app('log')->debug(sprintf('$start (%s) < $date (%s)', $start->format('Y-m-d'), $date->format('Y-m-d')));
|
||||
$start = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);
|
||||
Log::debug('Start is now ' . $start->format('Y-m-d'));
|
||||
app('log')->debug('Start is now ' . $start->format('Y-m-d'));
|
||||
}
|
||||
|
||||
$end = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);
|
||||
@@ -537,12 +537,12 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
if ($journalCount > 0) {
|
||||
// this period had in fact a bill. The new start is the current end, and we create a new end.
|
||||
Log::debug(sprintf('Journal count is %d, so start becomes %s', $journalCount, $end->format('Y-m-d')));
|
||||
app('log')->debug(sprintf('Journal count is %d, so start becomes %s', $journalCount, $end->format('Y-m-d')));
|
||||
$start = clone $end;
|
||||
$end = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);
|
||||
}
|
||||
Log::debug('nextExpectedMatch: Final start is ' . $start->format('Y-m-d'));
|
||||
Log::debug('nextExpectedMatch: Matching end is ' . $end->format('Y-m-d'));
|
||||
app('log')->debug('nextExpectedMatch: Final start is ' . $start->format('Y-m-d'));
|
||||
app('log')->debug('nextExpectedMatch: Matching end is ' . $end->format('Y-m-d'));
|
||||
|
||||
$cache->store($start);
|
||||
|
||||
@@ -708,21 +708,21 @@ class BillRepository implements BillRepositoryInterface
|
||||
{
|
||||
$set = new Collection();
|
||||
$currentStart = clone $start;
|
||||
//Log::debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq));
|
||||
//Log::debug(sprintf('First currentstart is %s', $currentStart->format('Y-m-d')));
|
||||
//app('log')->debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq));
|
||||
//app('log')->debug(sprintf('First currentstart is %s', $currentStart->format('Y-m-d')));
|
||||
|
||||
while ($currentStart <= $end) {
|
||||
//Log::debug(sprintf('Currentstart is now %s.', $currentStart->format('Y-m-d')));
|
||||
//app('log')->debug(sprintf('Currentstart is now %s.', $currentStart->format('Y-m-d')));
|
||||
$nextExpectedMatch = $this->nextDateMatch($bill, $currentStart);
|
||||
//Log::debug(sprintf('Next Date match after %s is %s', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));
|
||||
//app('log')->debug(sprintf('Next Date match after %s is %s', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));
|
||||
if ($nextExpectedMatch > $end) {// If nextExpectedMatch is after end, we continue
|
||||
break;
|
||||
}
|
||||
$set->push(clone $nextExpectedMatch);
|
||||
//Log::debug(sprintf('Now %d dates in set.', $set->count()));
|
||||
//app('log')->debug(sprintf('Now %d dates in set.', $set->count()));
|
||||
$nextExpectedMatch->addDay();
|
||||
|
||||
//Log::debug(sprintf('Currentstart (%s) has become %s.', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));
|
||||
//app('log')->debug(sprintf('Currentstart (%s) has become %s.', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));
|
||||
|
||||
$currentStart = clone $nextExpectedMatch;
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
if (null !== $limit) {
|
||||
throw new FireflyException('200027: Budget limit already exists.');
|
||||
}
|
||||
Log::debug('No existing budget limit, create a new one');
|
||||
app('log')->debug('No existing budget limit, create a new one');
|
||||
|
||||
// or create one and return it.
|
||||
$limit = new BudgetLimit();
|
||||
@@ -325,7 +325,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
$limit->amount = $data['amount'];
|
||||
$limit->transaction_currency_id = $currency->id;
|
||||
$limit->save();
|
||||
Log::debug(sprintf('Created new budget limit with ID #%d and amount %s', $limit->id, $data['amount']));
|
||||
app('log')->debug(sprintf('Created new budget limit with ID #%d and amount %s', $limit->id, $data['amount']));
|
||||
|
||||
return $limit;
|
||||
}
|
||||
@@ -399,7 +399,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00'))
|
||||
->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00'))
|
||||
->count(['budget_limits.*']);
|
||||
Log::debug(sprintf('Found %d budget limits.', $limits));
|
||||
app('log')->debug(sprintf('Found %d budget limits.', $limits));
|
||||
|
||||
// there might be a budget limit for these dates:
|
||||
/** @var BudgetLimit $limit */
|
||||
@@ -410,7 +410,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
|
||||
// if more than 1 limit found, delete the others:
|
||||
if ($limits > 1 && null !== $limit) {
|
||||
Log::debug(sprintf('Found more than 1, delete all except #%d', $limit->id));
|
||||
app('log')->debug(sprintf('Found more than 1, delete all except #%d', $limit->id));
|
||||
$budget->budgetlimits()
|
||||
->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00'))
|
||||
->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00'))
|
||||
@@ -421,20 +421,20 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
// Returns 0 if the two operands are equal,
|
||||
// 1 if the left_operand is larger than the right_operand, -1 otherwise.
|
||||
if (null !== $limit && bccomp($amount, '0') <= 0) {
|
||||
Log::debug(sprintf('%s is zero, delete budget limit #%d', $amount, $limit->id));
|
||||
app('log')->debug(sprintf('%s is zero, delete budget limit #%d', $amount, $limit->id));
|
||||
$limit->delete();
|
||||
|
||||
return null;
|
||||
}
|
||||
// update if exists:
|
||||
if (null !== $limit) {
|
||||
Log::debug(sprintf('Existing budget limit is #%d, update this to amount %s', $limit->id, $amount));
|
||||
app('log')->debug(sprintf('Existing budget limit is #%d, update this to amount %s', $limit->id, $amount));
|
||||
$limit->amount = $amount;
|
||||
$limit->save();
|
||||
|
||||
return $limit;
|
||||
}
|
||||
Log::debug('No existing budget limit, create a new one');
|
||||
app('log')->debug('No existing budget limit, create a new one');
|
||||
// or create one and return it.
|
||||
$limit = new BudgetLimit();
|
||||
$limit->budget()->associate($budget);
|
||||
@@ -442,7 +442,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
$limit->end_date = $end->startOfDay();
|
||||
$limit->amount = $amount;
|
||||
$limit->save();
|
||||
Log::debug(sprintf('Created new budget limit with ID #%d and amount %s', $limit->id, $amount));
|
||||
app('log')->debug(sprintf('Created new budget limit with ID #%d and amount %s', $limit->id, $amount));
|
||||
|
||||
return $limit;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
*/
|
||||
public function budgetedInPeriod(Carbon $start, Carbon $end): array
|
||||
{
|
||||
Log::debug(sprintf('Now in budgetedInPeriod("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
app('log')->debug(sprintf('Now in budgetedInPeriod("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
$return = [];
|
||||
/** @var BudgetLimitRepository $limitRepository */
|
||||
$limitRepository = app(BudgetLimitRepository::class);
|
||||
@@ -99,11 +99,11 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$budgets = $this->getActiveBudgets();
|
||||
/** @var Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
Log::debug(sprintf('Budget #%d: "%s"', $budget->id, $budget->name));
|
||||
app('log')->debug(sprintf('Budget #%d: "%s"', $budget->id, $budget->name));
|
||||
$limits = $limitRepository->getBudgetLimits($budget, $start, $end);
|
||||
/** @var BudgetLimit $limit */
|
||||
foreach ($limits as $limit) {
|
||||
Log::debug(sprintf('Budget limit #%d', $limit->id));
|
||||
app('log')->debug(sprintf('Budget limit #%d', $limit->id));
|
||||
$currency = $limit->transactionCurrency;
|
||||
$return[$currency->id] = $return[$currency->id] ?? [
|
||||
'id' => (string)$currency->id,
|
||||
@@ -116,20 +116,20 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
// same period
|
||||
if ($limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end)) {
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);
|
||||
Log::debug(sprintf('Add full amount [1]: %s', $limit->amount));
|
||||
app('log')->debug(sprintf('Add full amount [1]: %s', $limit->amount));
|
||||
continue;
|
||||
}
|
||||
// limit is inside of date range
|
||||
if ($start->lte($limit->start_date) && $end->gte($limit->end_date)) {
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);
|
||||
Log::debug(sprintf('Add full amount [2]: %s', $limit->amount));
|
||||
app('log')->debug(sprintf('Add full amount [2]: %s', $limit->amount));
|
||||
continue;
|
||||
}
|
||||
$total = $limit->start_date->diffInDays($limit->end_date) + 1; // include the day itself.
|
||||
$days = $this->daysInOverlap($limit, $start, $end);
|
||||
$amount = bcmul(bcdiv((string)$limit->amount, (string)$total), (string)$days);
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);
|
||||
Log::debug(
|
||||
app('log')->debug(
|
||||
sprintf(
|
||||
'Amount per day: %s (%s over %d days). Total amount for %d days: %s',
|
||||
bcdiv((string)$limit->amount, (string)$total),
|
||||
@@ -209,17 +209,17 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
*/
|
||||
public function budgetedInPeriodForBudget(Budget $budget, Carbon $start, Carbon $end): array
|
||||
{
|
||||
Log::debug(sprintf('Now in budgetedInPeriod(#%d, "%s", "%s")', $budget->id, $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
app('log')->debug(sprintf('Now in budgetedInPeriod(#%d, "%s", "%s")', $budget->id, $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
$return = [];
|
||||
/** @var BudgetLimitRepository $limitRepository */
|
||||
$limitRepository = app(BudgetLimitRepository::class);
|
||||
$limitRepository->setUser($this->user);
|
||||
|
||||
Log::debug(sprintf('Budget #%d: "%s"', $budget->id, $budget->name));
|
||||
app('log')->debug(sprintf('Budget #%d: "%s"', $budget->id, $budget->name));
|
||||
$limits = $limitRepository->getBudgetLimits($budget, $start, $end);
|
||||
/** @var BudgetLimit $limit */
|
||||
foreach ($limits as $limit) {
|
||||
Log::debug(sprintf('Budget limit #%d', $limit->id));
|
||||
app('log')->debug(sprintf('Budget limit #%d', $limit->id));
|
||||
$currency = $limit->transactionCurrency;
|
||||
$return[$currency->id] = $return[$currency->id] ?? [
|
||||
'id' => (string)$currency->id,
|
||||
@@ -232,20 +232,20 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
// same period
|
||||
if ($limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end)) {
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);
|
||||
Log::debug(sprintf('Add full amount [1]: %s', $limit->amount));
|
||||
app('log')->debug(sprintf('Add full amount [1]: %s', $limit->amount));
|
||||
continue;
|
||||
}
|
||||
// limit is inside of date range
|
||||
if ($start->lte($limit->start_date) && $end->gte($limit->end_date)) {
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);
|
||||
Log::debug(sprintf('Add full amount [2]: %s', $limit->amount));
|
||||
app('log')->debug(sprintf('Add full amount [2]: %s', $limit->amount));
|
||||
continue;
|
||||
}
|
||||
$total = $limit->start_date->diffInDays($limit->end_date) + 1; // include the day itself.
|
||||
$days = $this->daysInOverlap($limit, $start, $end);
|
||||
$amount = bcmul(bcdiv((string)$limit->amount, (string)$total), (string)$days);
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);
|
||||
Log::debug(
|
||||
app('log')->debug(
|
||||
sprintf(
|
||||
'Amount per day: %s (%s over %d days). Total amount for %d days: %s',
|
||||
bcdiv((string)$limit->amount, (string)$total),
|
||||
@@ -291,7 +291,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
*/
|
||||
public function update(Budget $budget, array $data): Budget
|
||||
{
|
||||
Log::debug('Now in update()');
|
||||
app('log')->debug('Now in update()');
|
||||
|
||||
$oldName = $budget->name;
|
||||
if (array_key_exists('name', $data)) {
|
||||
@@ -342,12 +342,12 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
->whereIn('rule_actions.action_type', $types)
|
||||
->where('rule_actions.action_value', $oldName)
|
||||
->get(['rule_actions.*']);
|
||||
Log::debug(sprintf('Found %d actions to update.', $actions->count()));
|
||||
app('log')->debug(sprintf('Found %d actions to update.', $actions->count()));
|
||||
/** @var RuleAction $action */
|
||||
foreach ($actions as $action) {
|
||||
$action->action_value = $newName;
|
||||
$action->save();
|
||||
Log::debug(sprintf('Updated action %d: %s', $action->id, $action->action_value));
|
||||
app('log')->debug(sprintf('Updated action %d: %s', $action->id, $action->action_value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,12 +363,12 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
->whereIn('rule_triggers.trigger_type', $types)
|
||||
->where('rule_triggers.trigger_value', $oldName)
|
||||
->get(['rule_triggers.*']);
|
||||
Log::debug(sprintf('Found %d triggers to update.', $triggers->count()));
|
||||
app('log')->debug(sprintf('Found %d triggers to update.', $triggers->count()));
|
||||
/** @var RuleTrigger $trigger */
|
||||
foreach ($triggers as $trigger) {
|
||||
$trigger->trigger_value = $newName;
|
||||
$trigger->save();
|
||||
Log::debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value));
|
||||
app('log')->debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,17 +526,17 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
*/
|
||||
public function findBudget(?int $budgetId, ?string $budgetName): ?Budget
|
||||
{
|
||||
Log::debug('Now in findBudget()');
|
||||
Log::debug(sprintf('Searching for budget with ID #%d...', $budgetId));
|
||||
app('log')->debug('Now in findBudget()');
|
||||
app('log')->debug(sprintf('Searching for budget with ID #%d...', $budgetId));
|
||||
$result = $this->find((int)$budgetId);
|
||||
if (null === $result && null !== $budgetName && '' !== $budgetName) {
|
||||
Log::debug(sprintf('Searching for budget with name %s...', $budgetName));
|
||||
app('log')->debug(sprintf('Searching for budget with name %s...', $budgetName));
|
||||
$result = $this->findByName((string)$budgetName);
|
||||
}
|
||||
if (null !== $result) {
|
||||
Log::debug(sprintf('Found budget #%d: %s', $result->id, $result->name));
|
||||
app('log')->debug(sprintf('Found budget #%d: %s', $result->id, $result->name));
|
||||
}
|
||||
Log::debug(sprintf('Found result is null? %s', var_export(null === $result, true)));
|
||||
app('log')->debug(sprintf('Found result is null? %s', var_export(null === $result, true)));
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -665,7 +665,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
*/
|
||||
public function spentInPeriod(Carbon $start, Carbon $end): array
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
$start->startOfDay();
|
||||
$end->endOfDay();
|
||||
|
||||
@@ -728,7 +728,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
*/
|
||||
public function spentInPeriodForBudget(Budget $budget, Carbon $start, Carbon $end): array
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
$start->startOfDay();
|
||||
$end->endOfDay();
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
*/
|
||||
public function budgetedPerDay(Budget $budget): string
|
||||
{
|
||||
Log::debug(sprintf('Now with budget #%d "%s"', $budget->id, $budget->name));
|
||||
app('log')->debug(sprintf('Now with budget #%d "%s"', $budget->id, $budget->name));
|
||||
$total = '0';
|
||||
$count = 0;
|
||||
foreach ($budget->budgetlimits as $limit) {
|
||||
@@ -63,13 +63,13 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
$perDay = bcdiv($amount, (string)$diff);
|
||||
$total = bcadd($total, $perDay);
|
||||
$count++;
|
||||
Log::debug(sprintf('Found %d budget limits. Per day is %s, total is %s', $count, $perDay, $total));
|
||||
app('log')->debug(sprintf('Found %d budget limits. Per day is %s, total is %s', $count, $perDay, $total));
|
||||
}
|
||||
$avg = $total;
|
||||
if ($count > 0) {
|
||||
$avg = bcdiv($total, (string)$count);
|
||||
}
|
||||
Log::debug(sprintf('%s / %d = %s = average.', $total, $count, $avg));
|
||||
app('log')->debug(sprintf('%s / %d = %s = average.', $total, $count, $avg));
|
||||
|
||||
return $avg;
|
||||
}
|
||||
@@ -299,7 +299,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
?Collection $budgets = null,
|
||||
?TransactionCurrency $currency = null
|
||||
): array {
|
||||
//Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
//app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
$start->startOfDay();
|
||||
$end->endOfDay();
|
||||
|
||||
@@ -341,7 +341,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
|
||||
// same but for foreign currencies:
|
||||
if (null !== $currency) {
|
||||
//Log::debug(sprintf('Currency is "%s".', $currency->name));
|
||||
//app('log')->debug(sprintf('Currency is "%s".', $currency->name));
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])
|
||||
@@ -351,7 +351,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
$collector->setAccounts($accounts);
|
||||
}
|
||||
$result = $collector->getExtractedJournals();
|
||||
//Log::debug(sprintf('Found %d journals with currency %s.', count($result), $currency->code));
|
||||
//app('log')->debug(sprintf('Found %d journals with currency %s.', count($result), $currency->code));
|
||||
// do not use array_merge because you want keys to overwrite (otherwise you get double results):
|
||||
$journals = $result + $journals;
|
||||
}
|
||||
|
||||
@@ -125,11 +125,11 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*/
|
||||
public function findCategory(?int $categoryId, ?string $categoryName): ?Category
|
||||
{
|
||||
Log::debug('Now in findCategory()');
|
||||
Log::debug(sprintf('Searching for category with ID #%d...', $categoryId));
|
||||
app('log')->debug('Now in findCategory()');
|
||||
app('log')->debug(sprintf('Searching for category with ID #%d...', $categoryId));
|
||||
$result = $this->find((int)$categoryId);
|
||||
if (null === $result) {
|
||||
Log::debug(sprintf('Searching for category with name %s...', $categoryName));
|
||||
app('log')->debug(sprintf('Searching for category with name %s...', $categoryName));
|
||||
$result = $this->findByName((string)$categoryName);
|
||||
if (null === $result && '' !== (string)$categoryName) {
|
||||
// create it!
|
||||
@@ -137,9 +137,9 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
}
|
||||
}
|
||||
if (null !== $result) {
|
||||
Log::debug(sprintf('Found category #%d: %s', $result->id, $result->name));
|
||||
app('log')->debug(sprintf('Found category #%d: %s', $result->id, $result->name));
|
||||
}
|
||||
Log::debug(sprintf('Found category result is null? %s', var_export(null === $result, true)));
|
||||
app('log')->debug(sprintf('Found category result is null? %s', var_export(null === $result, true)));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
->where('to_currency_id', $toCurrency->id)
|
||||
->where('date', $date->format('Y-m-d'))->first();
|
||||
if (null !== $rate) {
|
||||
Log::debug(sprintf('Found cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d')));
|
||||
app('log')->debug(sprintf('Found cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d')));
|
||||
|
||||
return $rate;
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
*/
|
||||
public function findLink(TransactionJournal $one, TransactionJournal $two): bool
|
||||
{
|
||||
Log::debug(sprintf('Now in findLink(%d, %d)', $one->id, $two->id));
|
||||
app('log')->debug(sprintf('Now in findLink(%d, %d)', $one->id, $two->id));
|
||||
$count = TransactionJournalLink::whereDestinationId($one->id)->whereSourceId($two->id)->count();
|
||||
$opposingCount = TransactionJournalLink::whereDestinationId($two->id)->whereSourceId($one->id)->count();
|
||||
|
||||
@@ -263,13 +263,13 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
$link = new TransactionJournalLink();
|
||||
$link->linkType()->associate($linkType);
|
||||
if ('inward' === $information['direction']) {
|
||||
Log::debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->inward, $inward->id, $outward->id));
|
||||
app('log')->debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->inward, $inward->id, $outward->id));
|
||||
$link->source()->associate($inward);
|
||||
$link->destination()->associate($outward);
|
||||
}
|
||||
|
||||
if ('outward' === $information['direction']) {
|
||||
Log::debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->outward, $outward->id, $inward->id));
|
||||
app('log')->debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->outward, $outward->id, $inward->id));
|
||||
$link->source()->associate($outward);
|
||||
$link->destination()->associate($inward);
|
||||
}
|
||||
|
||||
@@ -114,13 +114,13 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
|
||||
*/
|
||||
public function resetOrder(): void
|
||||
{
|
||||
Log::debug('Now in resetOrder');
|
||||
app('log')->debug('Now in resetOrder');
|
||||
$list = $this->get();
|
||||
$index = 1;
|
||||
/** @var ObjectGroup $objectGroup */
|
||||
foreach ($list as $objectGroup) {
|
||||
if ($index !== (int)$objectGroup->order) {
|
||||
Log::debug(
|
||||
app('log')->debug(
|
||||
sprintf('objectGroup #%d ("%s"): order should %d be but is %d.', $objectGroup->id, $objectGroup->title, $index, $objectGroup->order)
|
||||
);
|
||||
$objectGroup->order = $index;
|
||||
@@ -203,7 +203,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
|
||||
$objectGroup->save();
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Objectgroup #%d order is now %d', $objectGroup->id, $newOrder));
|
||||
app('log')->debug(sprintf('Objectgroup #%d order is now %d', $objectGroup->id, $newOrder));
|
||||
|
||||
return $objectGroup;
|
||||
}
|
||||
|
||||
@@ -53,13 +53,13 @@ trait ModifiesPiggyBanks
|
||||
*/
|
||||
public function addAmountToRepetition(PiggyBankRepetition $repetition, string $amount, TransactionJournal $journal): void
|
||||
{
|
||||
Log::debug(sprintf('addAmountToRepetition: %s', $amount));
|
||||
app('log')->debug(sprintf('addAmountToRepetition: %s', $amount));
|
||||
if (-1 === bccomp($amount, '0')) {
|
||||
Log::debug('Remove amount.');
|
||||
app('log')->debug('Remove amount.');
|
||||
$this->removeAmount($repetition->piggyBank, bcmul($amount, '-1'), $journal);
|
||||
}
|
||||
if (1 === bccomp($amount, '0')) {
|
||||
Log::debug('Add amount.');
|
||||
app('log')->debug('Add amount.');
|
||||
$this->addAmount($repetition->piggyBank, $amount, $journal);
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ trait ModifiesPiggyBanks
|
||||
$repetition->currentamount = bcsub($repetition->currentamount, $amount);
|
||||
$repetition->save();
|
||||
|
||||
Log::debug('addAmount [a]: Trigger change for negative amount.');
|
||||
app('log')->debug('addAmount [a]: Trigger change for negative amount.');
|
||||
event(new ChangedAmount($piggyBank, bcmul($amount, '-1'), $journal, null));
|
||||
|
||||
return true;
|
||||
@@ -103,7 +103,7 @@ trait ModifiesPiggyBanks
|
||||
$repetition->currentamount = bcadd($currentAmount, $amount);
|
||||
$repetition->save();
|
||||
|
||||
Log::debug('addAmount [b]: Trigger change for positive amount.');
|
||||
app('log')->debug('addAmount [b]: Trigger change for positive amount.');
|
||||
event(new ChangedAmount($piggyBank, $amount, $journal, null));
|
||||
|
||||
return true;
|
||||
@@ -131,11 +131,11 @@ trait ModifiesPiggyBanks
|
||||
$compare = bccomp($amount, $maxAmount);
|
||||
$result = $compare <= 0;
|
||||
|
||||
Log::debug(sprintf('Left on account: %s on %s', $leftOnAccount, $today->format('Y-m-d')));
|
||||
Log::debug(sprintf('Saved so far: %s', $savedSoFar));
|
||||
Log::debug(sprintf('Left to save: %s', $leftToSave));
|
||||
Log::debug(sprintf('Maximum amount: %s', $maxAmount));
|
||||
Log::debug(sprintf('Compare <= 0? %d, so %s', $compare, var_export($result, true)));
|
||||
app('log')->debug(sprintf('Left on account: %s on %s', $leftOnAccount, $today->format('Y-m-d')));
|
||||
app('log')->debug(sprintf('Saved so far: %s', $savedSoFar));
|
||||
app('log')->debug(sprintf('Left to save: %s', $leftToSave));
|
||||
app('log')->debug(sprintf('Maximum amount: %s', $maxAmount));
|
||||
app('log')->debug(sprintf('Compare <= 0? %d, so %s', $compare, var_export($result, true)));
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -202,11 +202,11 @@ trait ModifiesPiggyBanks
|
||||
$repetition->save();
|
||||
|
||||
if (-1 === bccomp($difference, '0')) {
|
||||
Log::debug('addAmount [c]: Trigger change for negative amount.');
|
||||
app('log')->debug('addAmount [c]: Trigger change for negative amount.');
|
||||
event(new ChangedAmount($piggyBank, $difference, null, null));
|
||||
}
|
||||
if (1 === bccomp($difference, '0')) {
|
||||
Log::debug('addAmount [d]: Trigger change for positive amount.');
|
||||
app('log')->debug('addAmount [d]: Trigger change for positive amount.');
|
||||
event(new ChangedAmount($piggyBank, $difference, null, null));
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ trait ModifiesPiggyBanks
|
||||
$current = 1;
|
||||
foreach ($set as $piggyBank) {
|
||||
if ((int)$piggyBank->order !== $current) {
|
||||
Log::debug(sprintf('Piggy bank #%d ("%s") was at place %d but should be on %d', $piggyBank->id, $piggyBank->name, $piggyBank->order, $current));
|
||||
app('log')->debug(sprintf('Piggy bank #%d ("%s") was at place %d but should be on %d', $piggyBank->id, $piggyBank->name, $piggyBank->order, $current));
|
||||
$piggyBank->order = $current;
|
||||
$piggyBank->save();
|
||||
}
|
||||
@@ -313,13 +313,13 @@ trait ModifiesPiggyBanks
|
||||
public function setOrder(PiggyBank $piggyBank, int $newOrder): bool
|
||||
{
|
||||
$oldOrder = (int)$piggyBank->order;
|
||||
//Log::debug(sprintf('Will move piggy bank #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
|
||||
//app('log')->debug(sprintf('Will move piggy bank #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
|
||||
if ($newOrder > $oldOrder) {
|
||||
$this->user->piggyBanks()->where('piggy_banks.order', '<=', $newOrder)->where('piggy_banks.order', '>', $oldOrder)
|
||||
->where('piggy_banks.id', '!=', $piggyBank->id)
|
||||
->decrement('piggy_banks.order');
|
||||
$piggyBank->order = $newOrder;
|
||||
Log::debug(sprintf('[1] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
|
||||
app('log')->debug(sprintf('[1] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
|
||||
$piggyBank->save();
|
||||
|
||||
return true;
|
||||
@@ -329,7 +329,7 @@ trait ModifiesPiggyBanks
|
||||
->where('piggy_banks.id', '!=', $piggyBank->id)
|
||||
->increment('piggy_banks.order');
|
||||
$piggyBank->order = $newOrder;
|
||||
Log::debug(sprintf('[2] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
|
||||
app('log')->debug(sprintf('[2] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
|
||||
$piggyBank->save();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -66,12 +66,12 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
*/
|
||||
public function findPiggyBank(?int $piggyBankId, ?string $piggyBankName): ?PiggyBank
|
||||
{
|
||||
Log::debug('Searching for piggy information.');
|
||||
app('log')->debug('Searching for piggy information.');
|
||||
|
||||
if (null !== $piggyBankId) {
|
||||
$searchResult = $this->find((int)$piggyBankId);
|
||||
if (null !== $searchResult) {
|
||||
Log::debug(sprintf('Found piggy based on #%d, will return it.', $piggyBankId));
|
||||
app('log')->debug(sprintf('Found piggy based on #%d, will return it.', $piggyBankId));
|
||||
|
||||
return $searchResult;
|
||||
}
|
||||
@@ -79,12 +79,12 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
if (null !== $piggyBankName) {
|
||||
$searchResult = $this->findByName((string)$piggyBankName);
|
||||
if (null !== $searchResult) {
|
||||
Log::debug(sprintf('Found piggy based on "%s", will return it.', $piggyBankName));
|
||||
app('log')->debug(sprintf('Found piggy based on "%s", will return it.', $piggyBankName));
|
||||
|
||||
return $searchResult;
|
||||
}
|
||||
}
|
||||
Log::debug('Found nothing');
|
||||
app('log')->debug('Found nothing');
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -183,7 +183,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
*/
|
||||
public function getExactAmount(PiggyBank $piggyBank, PiggyBankRepetition $repetition, TransactionJournal $journal): string
|
||||
{
|
||||
Log::debug(sprintf('Now in getExactAmount(%d, %d, %d)', $piggyBank->id, $repetition->id, $journal->id));
|
||||
app('log')->debug(sprintf('Now in getExactAmount(%d, %d, %d)', $piggyBank->id, $repetition->id, $journal->id));
|
||||
|
||||
$operator = null;
|
||||
$currency = null;
|
||||
@@ -198,7 +198,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
$defaultCurrency = app('amount')->getDefaultCurrencyByUser($this->user);
|
||||
$piggyBankCurrency = $accountRepos->getAccountCurrency($piggyBank->account) ?? $defaultCurrency;
|
||||
|
||||
Log::debug(sprintf('Piggy bank #%d currency is %s', $piggyBank->id, $piggyBankCurrency->code));
|
||||
app('log')->debug(sprintf('Piggy bank #%d currency is %s', $piggyBank->id, $piggyBankCurrency->code));
|
||||
|
||||
/** @var Transaction $source */
|
||||
$source = $journal->transactions()->with(['account'])->where('amount', '<', 0)->first();
|
||||
@@ -209,17 +209,17 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
if ($source->account_id === $piggyBank->account_id) {
|
||||
$operator = 'negative';
|
||||
$currency = $accountRepos->getAccountCurrency($source->account) ?? $defaultCurrency;
|
||||
Log::debug(sprintf('Currency will draw money out of piggy bank. Source currency is %s', $currency->code));
|
||||
app('log')->debug(sprintf('Currency will draw money out of piggy bank. Source currency is %s', $currency->code));
|
||||
}
|
||||
|
||||
// matches destination, which means amount will be added to piggy.
|
||||
if ($destination->account_id === $piggyBank->account_id) {
|
||||
$operator = 'positive';
|
||||
$currency = $accountRepos->getAccountCurrency($destination->account) ?? $defaultCurrency;
|
||||
Log::debug(sprintf('Currency will add money to piggy bank. Destination currency is %s', $currency->code));
|
||||
app('log')->debug(sprintf('Currency will add money to piggy bank. Destination currency is %s', $currency->code));
|
||||
}
|
||||
if (null === $operator || null === $currency) {
|
||||
Log::debug('Currency is NULL and operator is NULL, return "0".');
|
||||
app('log')->debug('Currency is NULL and operator is NULL, return "0".');
|
||||
|
||||
return '0';
|
||||
}
|
||||
@@ -227,46 +227,46 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
// which amount from the transaction matches?
|
||||
$amount = null;
|
||||
if ((int)$source->transaction_currency_id === (int)$currency->id) {
|
||||
Log::debug('Use normal amount');
|
||||
app('log')->debug('Use normal amount');
|
||||
$amount = app('steam')->$operator($source->amount);
|
||||
}
|
||||
if ((int)$source->foreign_currency_id === (int)$currency->id) {
|
||||
Log::debug('Use foreign amount');
|
||||
app('log')->debug('Use foreign amount');
|
||||
$amount = app('steam')->$operator($source->foreign_amount);
|
||||
}
|
||||
if (null === $amount) {
|
||||
Log::debug('No match on currency, so amount remains null, return "0".');
|
||||
app('log')->debug('No match on currency, so amount remains null, return "0".');
|
||||
|
||||
return '0';
|
||||
}
|
||||
|
||||
Log::debug(sprintf('The currency is %s and the amount is %s', $currency->code, $amount));
|
||||
app('log')->debug(sprintf('The currency is %s and the amount is %s', $currency->code, $amount));
|
||||
$room = bcsub((string)$piggyBank->targetamount, (string)$repetition->currentamount);
|
||||
$compare = bcmul($repetition->currentamount, '-1');
|
||||
|
||||
if (bccomp((string)$piggyBank->targetamount, '0') === 0) {
|
||||
// amount is zero? then the "room" is positive amount of we wish to add or remove.
|
||||
$room = app('steam')->positive($amount);
|
||||
Log::debug(sprintf('Room is now %s', $room));
|
||||
app('log')->debug(sprintf('Room is now %s', $room));
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Will add/remove %f to piggy bank #%d ("%s")', $amount, $piggyBank->id, $piggyBank->name));
|
||||
app('log')->debug(sprintf('Will add/remove %f to piggy bank #%d ("%s")', $amount, $piggyBank->id, $piggyBank->name));
|
||||
|
||||
// if the amount is positive, make sure it fits in piggy bank:
|
||||
if (1 === bccomp($amount, '0') && bccomp($room, $amount) === -1) {
|
||||
// amount is positive and $room is smaller than $amount
|
||||
Log::debug(sprintf('Room in piggy bank for extra money is %f', $room));
|
||||
Log::debug(sprintf('There is NO room to add %f to piggy bank #%d ("%s")', $amount, $piggyBank->id, $piggyBank->name));
|
||||
Log::debug(sprintf('New amount is %f', $room));
|
||||
app('log')->debug(sprintf('Room in piggy bank for extra money is %f', $room));
|
||||
app('log')->debug(sprintf('There is NO room to add %f to piggy bank #%d ("%s")', $amount, $piggyBank->id, $piggyBank->name));
|
||||
app('log')->debug(sprintf('New amount is %f', $room));
|
||||
|
||||
return $room;
|
||||
}
|
||||
|
||||
// amount is negative and $currentamount is smaller than $amount
|
||||
if (bccomp($amount, '0') === -1 && 1 === bccomp($compare, $amount)) {
|
||||
Log::debug(sprintf('Max amount to remove is %f', $repetition->currentamount));
|
||||
Log::debug(sprintf('Cannot remove %f from piggy bank #%d ("%s")', $amount, $piggyBank->id, $piggyBank->name));
|
||||
Log::debug(sprintf('New amount is %f', $compare));
|
||||
app('log')->debug(sprintf('Max amount to remove is %f', $repetition->currentamount));
|
||||
app('log')->debug(sprintf('Cannot remove %f from piggy bank #%d ("%s")', $amount, $piggyBank->id, $piggyBank->name));
|
||||
app('log')->debug(sprintf('New amount is %f', $compare));
|
||||
|
||||
return $compare;
|
||||
}
|
||||
|
||||
@@ -78,14 +78,14 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
foreach ($set as $journalMeta) {
|
||||
$count = TransactionJournalMeta::where(function (Builder $q2) use ($date) {
|
||||
$string = (string)$date;
|
||||
Log::debug(sprintf('Search for date: %s', json_encode($string)));
|
||||
app('log')->debug(sprintf('Search for date: %s', json_encode($string)));
|
||||
$q2->where('name', 'recurrence_date');
|
||||
$q2->where('data', json_encode($string));
|
||||
})
|
||||
->where('transaction_journal_id', $journalMeta->transaction_journal_id)
|
||||
->count();
|
||||
if ($count > 0) {
|
||||
Log::debug(sprintf('Looks like journal #%d was already created', $journalMeta->transaction_journal_id));
|
||||
app('log')->debug(sprintf('Looks like journal #%d was already created', $journalMeta->transaction_journal_id));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -437,7 +437,7 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
*/
|
||||
public function getXOccurrencesSince(RecurrenceRepetition $repetition, Carbon $date, Carbon $afterDate, int $count): array
|
||||
{
|
||||
Log::debug('Now in getXOccurrencesSince()');
|
||||
app('log')->debug('Now in getXOccurrencesSince()');
|
||||
$skipMod = $repetition->repetition_skip + 1;
|
||||
$occurrences = [];
|
||||
if ('daily' === $repetition->repetition_type) {
|
||||
@@ -496,7 +496,7 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
*/
|
||||
public function repetitionDescription(RecurrenceRepetition $repetition): string
|
||||
{
|
||||
Log::debug('Now in repetitionDescription()');
|
||||
app('log')->debug('Now in repetitionDescription()');
|
||||
/** @var Preference $pref */
|
||||
$pref = app('preferences')->getForUser($this->user, 'language', config('firefly.default_language', 'en_US'));
|
||||
$language = $pref->data;
|
||||
@@ -622,8 +622,8 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
$mutator = clone $start;
|
||||
$mutator->startOfDay();
|
||||
$skipMod = $repetition->repetition_skip + 1;
|
||||
Log::debug(sprintf('Calculating occurrences for rep type "%s"', $repetition->repetition_type));
|
||||
Log::debug(sprintf('Mutator is now: %s', $mutator->format('Y-m-d')));
|
||||
app('log')->debug(sprintf('Calculating occurrences for rep type "%s"', $repetition->repetition_type));
|
||||
app('log')->debug(sprintf('Mutator is now: %s', $mutator->format('Y-m-d')));
|
||||
|
||||
if ('daily' === $repetition->repetition_type) {
|
||||
$occurrences = $this->getDailyInRange($mutator, $end, $skipMod);
|
||||
|
||||
@@ -298,9 +298,9 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
|
||||
// reset order:
|
||||
$this->resetRuleOrder($ruleGroup);
|
||||
Log::debug('Done with resetting.');
|
||||
app('log')->debug('Done with resetting.');
|
||||
if (array_key_exists('order', $data)) {
|
||||
Log::debug(sprintf('User has submitted order %d', $data['order']));
|
||||
app('log')->debug(sprintf('User has submitted order %d', $data['order']));
|
||||
$this->setOrder($rule, $data['order']);
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
$groupId = (int)$rule->rule_group_id;
|
||||
$maxOrder = $this->maxOrder($rule->ruleGroup);
|
||||
$newOrder = $newOrder > $maxOrder ? $maxOrder + 1 : $newOrder;
|
||||
Log::debug(sprintf('New order will be %d', $newOrder));
|
||||
app('log')->debug(sprintf('New order will be %d', $newOrder));
|
||||
|
||||
if ($newOrder > $oldOrder) {
|
||||
$this->user->rules()
|
||||
@@ -391,7 +391,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
->where('rules.id', '!=', $rule->id)
|
||||
->decrement('rules.order');
|
||||
$rule->order = $newOrder;
|
||||
Log::debug(sprintf('Order of rule #%d ("%s") is now %d', $rule->id, $rule->title, $newOrder));
|
||||
app('log')->debug(sprintf('Order of rule #%d ("%s") is now %d', $rule->id, $rule->title, $newOrder));
|
||||
$rule->save();
|
||||
|
||||
return;
|
||||
@@ -404,7 +404,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
->where('rules.id', '!=', $rule->id)
|
||||
->increment('rules.order');
|
||||
$rule->order = $newOrder;
|
||||
Log::debug(sprintf('Order of rule #%d ("%s") is now %d', $rule->id, $rule->title, $newOrder));
|
||||
app('log')->debug(sprintf('Order of rule #%d ("%s") is now %d', $rule->id, $rule->title, $newOrder));
|
||||
$rule->save();
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
/** @var Rule $entry */
|
||||
foreach ($set as $entry) {
|
||||
if ((int)$entry->order !== $count) {
|
||||
Log::debug(sprintf('Rule #%d was on spot %d but must be on spot %d', $entry->id, $entry->order, $count));
|
||||
app('log')->debug(sprintf('Rule #%d was on spot %d but must be on spot %d', $entry->id, $entry->order, $count));
|
||||
$entry->order = $count;
|
||||
$entry->save();
|
||||
}
|
||||
@@ -182,7 +182,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
if ((int)$action->order !== $index) {
|
||||
$action->order = $index;
|
||||
$action->save();
|
||||
Log::debug(sprintf('Rule action #%d was on spot %d but must be on spot %d', $action->id, $action->order, $index));
|
||||
app('log')->debug(sprintf('Rule action #%d was on spot %d but must be on spot %d', $action->id, $action->order, $index));
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
@@ -205,7 +205,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
if ($order !== $index) {
|
||||
$trigger->order = $index;
|
||||
$trigger->save();
|
||||
Log::debug(sprintf('Rule trigger #%d was on spot %d but must be on spot %d', $trigger->id, $order, $index));
|
||||
app('log')->debug(sprintf('Rule trigger #%d was on spot %d but must be on spot %d', $trigger->id, $order, $index));
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
@@ -319,23 +319,23 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
if (null === $filter) {
|
||||
return $groups;
|
||||
}
|
||||
Log::debug(sprintf('Will filter getRuleGroupsWithRules on "%s".', $filter));
|
||||
app('log')->debug(sprintf('Will filter getRuleGroupsWithRules on "%s".', $filter));
|
||||
|
||||
return $groups->map(
|
||||
function (RuleGroup $group) use ($filter) {
|
||||
Log::debug(sprintf('Now filtering group #%d', $group->id));
|
||||
app('log')->debug(sprintf('Now filtering group #%d', $group->id));
|
||||
// filter the rules in the rule group:
|
||||
$group->rules = $group->rules->filter(
|
||||
function (Rule $rule) use ($filter) {
|
||||
Log::debug(sprintf('Now filtering rule #%d', $rule->id));
|
||||
app('log')->debug(sprintf('Now filtering rule #%d', $rule->id));
|
||||
foreach ($rule->ruleTriggers as $trigger) {
|
||||
if ('user_action' === $trigger->trigger_type && $filter === $trigger->trigger_value) {
|
||||
Log::debug(sprintf('Rule #%d triggers on %s, include it.', $rule->id, $filter));
|
||||
app('log')->debug(sprintf('Rule #%d triggers on %s, include it.', $rule->id, $filter));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Log::debug(sprintf('Rule #%d does not trigger on %s, do not include it.', $rule->id, $filter));
|
||||
app('log')->debug(sprintf('Rule #%d does not trigger on %s, do not include it.', $rule->id, $filter));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -382,23 +382,23 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
if (null === $filter) {
|
||||
return $groups;
|
||||
}
|
||||
Log::debug(sprintf('Will filter getRuleGroupsWithRules on "%s".', $filter));
|
||||
app('log')->debug(sprintf('Will filter getRuleGroupsWithRules on "%s".', $filter));
|
||||
|
||||
return $groups->map(
|
||||
function (RuleGroup $group) use ($filter) {
|
||||
Log::debug(sprintf('Now filtering group #%d', $group->id));
|
||||
app('log')->debug(sprintf('Now filtering group #%d', $group->id));
|
||||
// filter the rules in the rule group:
|
||||
$group->rules = $group->rules->filter(
|
||||
function (Rule $rule) use ($filter) {
|
||||
Log::debug(sprintf('Now filtering rule #%d', $rule->id));
|
||||
app('log')->debug(sprintf('Now filtering rule #%d', $rule->id));
|
||||
foreach ($rule->ruleTriggers as $trigger) {
|
||||
if ('user_action' === $trigger->trigger_type && $filter === $trigger->trigger_value) {
|
||||
Log::debug(sprintf('Rule #%d triggers on %s, include it.', $rule->id, $filter));
|
||||
app('log')->debug(sprintf('Rule #%d triggers on %s, include it.', $rule->id, $filter));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Log::debug(sprintf('Rule #%d does not trigger on %s, do not include it.', $rule->id, $filter));
|
||||
app('log')->debug(sprintf('Rule #%d does not trigger on %s, do not include it.', $rule->id, $filter));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -491,7 +491,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
->where('rule_groups.id', '!=', $ruleGroup->id)
|
||||
->decrement('order');
|
||||
$ruleGroup->order = $newOrder;
|
||||
Log::debug(sprintf('Order of group #%d ("%s") is now %d', $ruleGroup->id, $ruleGroup->title, $newOrder));
|
||||
app('log')->debug(sprintf('Order of group #%d ("%s") is now %d', $ruleGroup->id, $ruleGroup->title, $newOrder));
|
||||
$ruleGroup->save();
|
||||
|
||||
return;
|
||||
@@ -501,7 +501,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
->where('rule_groups.id', '!=', $ruleGroup->id)
|
||||
->increment('order');
|
||||
$ruleGroup->order = $newOrder;
|
||||
Log::debug(sprintf('Order of group #%d ("%s") is now %d', $ruleGroup->id, $ruleGroup->title, $newOrder));
|
||||
app('log')->debug(sprintf('Order of group #%d ("%s") is now %d', $ruleGroup->id, $ruleGroup->title, $newOrder));
|
||||
$ruleGroup->save();
|
||||
}
|
||||
|
||||
|
||||
@@ -183,12 +183,12 @@ class TagRepository implements TagRepositoryInterface
|
||||
|
||||
// add date range (or not):
|
||||
if (null === $year) {
|
||||
Log::debug('Get tags without a date.');
|
||||
app('log')->debug('Get tags without a date.');
|
||||
$tagQuery->whereNull('tags.date');
|
||||
}
|
||||
|
||||
if (null !== $year) {
|
||||
Log::debug(sprintf('Get tags with year %s.', $year));
|
||||
app('log')->debug(sprintf('Get tags with year %s.', $year));
|
||||
$tagQuery->where('tags.date', '>=', $year . '-01-01 00:00:00')->where('tags.date', '<=', $year . '-12-31 23:59:59');
|
||||
}
|
||||
$collection = $tagQuery->get();
|
||||
|
||||
@@ -86,7 +86,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
*/
|
||||
public function destroy(TransactionGroup $group): void
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
$service = new TransactionGroupDestroyService();
|
||||
$service->destroy($group);
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ class TransactionTypeRepository implements TransactionTypeRepositoryInterface
|
||||
*/
|
||||
public function findTransactionType(?TransactionType $type, ?string $typeString): TransactionType
|
||||
{
|
||||
Log::debug('Now looking for a transaction type.');
|
||||
app('log')->debug('Now looking for a transaction type.');
|
||||
if (null !== $type) {
|
||||
Log::debug(sprintf('Found $type in parameters, its %s. Will return it.', $type->type));
|
||||
app('log')->debug(sprintf('Found $type in parameters, its %s. Will return it.', $type->type));
|
||||
|
||||
return $type;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class TransactionTypeRepository implements TransactionTypeRepositoryInterface
|
||||
if (null === $search) {
|
||||
$search = $this->findByType(TransactionType::WITHDRAWAL);
|
||||
}
|
||||
Log::debug(sprintf('Tried to search for "%s", came up with "%s". Will return it.', $typeString, $search->type));
|
||||
app('log')->debug(sprintf('Tried to search for "%s", came up with "%s". Will return it.', $typeString, $search->type));
|
||||
|
||||
return $search;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class UserRepository implements UserRepositoryInterface
|
||||
*/
|
||||
public function deleteInvite(InvitedUser $invite): void
|
||||
{
|
||||
Log::debug(sprintf('Deleting invite #%d', $invite->id));
|
||||
app('log')->debug(sprintf('Deleting invite #%d', $invite->id));
|
||||
$invite->delete();
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ class UserRepository implements UserRepositoryInterface
|
||||
*/
|
||||
public function destroy(User $user): bool
|
||||
{
|
||||
Log::debug(sprintf('Calling delete() on user %d', $user->id));
|
||||
app('log')->debug(sprintf('Calling delete() on user %d', $user->id));
|
||||
|
||||
$user->groupMemberships()->delete();
|
||||
$user->delete();
|
||||
|
||||
@@ -51,17 +51,17 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
Log::debug(sprintf('Searching for account named "%s" (of user #%d) of the following type(s)', $name, $this->user->id), ['types' => $types]);
|
||||
app('log')->debug(sprintf('Searching for account named "%s" (of user #%d) of the following type(s)', $name, $this->user->id), ['types' => $types]);
|
||||
|
||||
$query->where('accounts.name', $name);
|
||||
/** @var Account $account */
|
||||
$account = $query->first(['accounts.*']);
|
||||
if (null === $account) {
|
||||
Log::debug(sprintf('There is no account with name "%s" of types', $name), $types);
|
||||
app('log')->debug(sprintf('There is no account with name "%s" of types', $name), $types);
|
||||
|
||||
return null;
|
||||
}
|
||||
Log::debug(sprintf('Found #%d (%s) with type id %d', $account->id, $account->name, $account->account_type_id));
|
||||
app('log')->debug(sprintf('Found #%d (%s) with type id %d', $account->id, $account->name, $account->account_type_id));
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
@@ -193,21 +193,21 @@ class BillRepository implements BillRepositoryInterface
|
||||
{
|
||||
$set = new Collection();
|
||||
$currentStart = clone $start;
|
||||
//Log::debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq));
|
||||
//Log::debug(sprintf('First currentstart is %s', $currentStart->format('Y-m-d')));
|
||||
//app('log')->debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq));
|
||||
//app('log')->debug(sprintf('First currentstart is %s', $currentStart->format('Y-m-d')));
|
||||
|
||||
while ($currentStart <= $end) {
|
||||
//Log::debug(sprintf('Currentstart is now %s.', $currentStart->format('Y-m-d')));
|
||||
//app('log')->debug(sprintf('Currentstart is now %s.', $currentStart->format('Y-m-d')));
|
||||
$nextExpectedMatch = $this->nextDateMatch($bill, $currentStart);
|
||||
//Log::debug(sprintf('Next Date match after %s is %s', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));
|
||||
//app('log')->debug(sprintf('Next Date match after %s is %s', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));
|
||||
if ($nextExpectedMatch > $end) {// If nextExpectedMatch is after end, we continue
|
||||
break;
|
||||
}
|
||||
$set->push(clone $nextExpectedMatch);
|
||||
//Log::debug(sprintf('Now %d dates in set.', $set->count()));
|
||||
//app('log')->debug(sprintf('Now %d dates in set.', $set->count()));
|
||||
$nextExpectedMatch->addDay();
|
||||
|
||||
//Log::debug(sprintf('Currentstart (%s) has become %s.', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));
|
||||
//app('log')->debug(sprintf('Currentstart (%s) has become %s.', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d')));
|
||||
|
||||
$currentStart = clone $nextExpectedMatch;
|
||||
}
|
||||
|
||||
@@ -262,17 +262,17 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
$result = $this->findCurrencyNull($currencyId, $currencyCode);
|
||||
|
||||
if (null === $result) {
|
||||
Log::debug('Grabbing default currency for this user...');
|
||||
app('log')->debug('Grabbing default currency for this user...');
|
||||
$result = app('amount')->getDefaultCurrencyByUser($this->user);
|
||||
}
|
||||
|
||||
if (null === $result) {
|
||||
Log::debug('Grabbing EUR as fallback.');
|
||||
app('log')->debug('Grabbing EUR as fallback.');
|
||||
$result = $this->findByCode('EUR');
|
||||
}
|
||||
Log::debug(sprintf('Final result: %s', $result->code));
|
||||
app('log')->debug(sprintf('Final result: %s', $result->code));
|
||||
if (false === $result->enabled) {
|
||||
Log::debug(sprintf('Also enabled currency %s', $result->code));
|
||||
app('log')->debug(sprintf('Also enabled currency %s', $result->code));
|
||||
$this->enable($result);
|
||||
}
|
||||
|
||||
@@ -289,14 +289,14 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
*/
|
||||
public function findCurrencyNull(?int $currencyId, ?string $currencyCode): ?TransactionCurrency
|
||||
{
|
||||
Log::debug('Now in findCurrencyNull()');
|
||||
app('log')->debug('Now in findCurrencyNull()');
|
||||
$result = $this->find((int)$currencyId);
|
||||
if (null === $result) {
|
||||
Log::debug(sprintf('Searching for currency with code %s...', $currencyCode));
|
||||
app('log')->debug(sprintf('Searching for currency with code %s...', $currencyCode));
|
||||
$result = $this->findByCode((string)$currencyCode);
|
||||
}
|
||||
if (null !== $result && false === $result->enabled) {
|
||||
Log::debug(sprintf('Also enabled currency %s', $result->code));
|
||||
app('log')->debug(sprintf('Also enabled currency %s', $result->code));
|
||||
$this->enable($result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user