mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Fix phpstan issues
This commit is contained in:
@@ -140,10 +140,10 @@ class AdminEventHandler
|
||||
|
||||
break;
|
||||
|
||||
case 'ntfy':
|
||||
$class = OwnerTestNotificationNtfy::class;
|
||||
|
||||
break;
|
||||
// case 'ntfy':
|
||||
// $class = OwnerTestNotificationNtfy::class;
|
||||
//
|
||||
// break;
|
||||
|
||||
case 'pushover':
|
||||
$class = OwnerTestNotificationPushover::class;
|
||||
|
@@ -411,10 +411,10 @@ class UserEventHandler
|
||||
|
||||
break;
|
||||
|
||||
case 'ntfy':
|
||||
$class = UserTestNotificationNtfy::class;
|
||||
|
||||
break;
|
||||
// case 'ntfy':
|
||||
// $class = UserTestNotificationNtfy::class;
|
||||
//
|
||||
// break;
|
||||
|
||||
case 'pushover':
|
||||
$class = UserTestNotificationPushover::class;
|
||||
|
@@ -38,6 +38,7 @@ use FireflyIII\Repositories\Budget\NoBudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Chart\Budget\FrontpageChartGenerator;
|
||||
use FireflyIII\Support\Facades\Navigation;
|
||||
use FireflyIII\Support\Http\Controllers\AugumentData;
|
||||
use FireflyIII\Support\Http\Controllers\DateCalculation;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -102,14 +103,14 @@ class BudgetController extends Controller
|
||||
$collection = new Collection([$budget]);
|
||||
$chartData = [];
|
||||
$loopStart = clone $start;
|
||||
$loopStart = app('navigation')->startOfPeriod($loopStart, $step);
|
||||
$loopStart = Navigation::startOfPeriod($loopStart, $step);
|
||||
$currencies = [];
|
||||
$defaultEntries = [];
|
||||
while ($end >= $loopStart) {
|
||||
/** @var Carbon $loopEnd */
|
||||
$loopEnd = app('navigation')->endOfPeriod($loopStart, $step);
|
||||
$loopEnd = Navigation::endOfPeriod($loopStart, $step);
|
||||
$spent = $this->opsRepository->sumExpenses($loopStart, $loopEnd, null, $collection); // this method already converts to primary currency.
|
||||
$label = trim((string) app('navigation')->periodShow($loopStart, $step));
|
||||
$label = trim(Navigation::periodShow($loopStart, $step));
|
||||
|
||||
foreach ($spent as $row) {
|
||||
$currencyId = $row['currency_id'];
|
||||
@@ -496,8 +497,8 @@ class BudgetController extends Controller
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$titleFormat = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||
$preferredRange = app('navigation')->preferredRangeFormat($start, $end);
|
||||
$titleFormat = Navigation::preferredCarbonLocalizedFormat($start, $end);
|
||||
$preferredRange = Navigation::preferredRangeFormat($start, $end);
|
||||
$chartData = [
|
||||
[
|
||||
'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $currency->name]),
|
||||
@@ -517,9 +518,9 @@ class BudgetController extends Controller
|
||||
|
||||
$currentStart = clone $start;
|
||||
while ($currentStart <= $end) {
|
||||
$currentStart = app('navigation')->startOfPeriod($currentStart, $preferredRange);
|
||||
$currentStart = Navigation::startOfPeriod($currentStart, $preferredRange);
|
||||
$title = $currentStart->isoFormat($titleFormat);
|
||||
$currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
|
||||
$currentEnd = Navigation::endOfPeriod($currentStart, $preferredRange);
|
||||
|
||||
// default limit is no limit:
|
||||
$chartData[0]['entries'][$title] = 0;
|
||||
@@ -565,17 +566,17 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
// the expenses:
|
||||
$titleFormat = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||
$titleFormat = Navigation::preferredCarbonLocalizedFormat($start, $end);
|
||||
$chartData = [];
|
||||
$currentStart = clone $start;
|
||||
$preferredRange = app('navigation')->preferredRangeFormat($start, $end);
|
||||
$preferredRange = Navigation::preferredRangeFormat($start, $end);
|
||||
while ($currentStart <= $end) {
|
||||
$currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
|
||||
$currentEnd = Navigation::endOfPeriod($currentStart, $preferredRange);
|
||||
$title = $currentStart->isoFormat($titleFormat);
|
||||
$sum = $this->nbRepository->sumExpenses($currentStart, $currentEnd, $accounts, $currency);
|
||||
$amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0');
|
||||
$chartData[$title] = app('steam')->bcround($amount, $currency->decimal_places);
|
||||
$currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0);
|
||||
$currentStart = Navigation::addPeriod($currentStart, $preferredRange, 0);
|
||||
}
|
||||
|
||||
$data = $this->generator->singleSet((string) trans('firefly.spent'), $chartData);
|
||||
|
@@ -29,6 +29,8 @@ use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Navigation;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Controllers\AugumentData;
|
||||
use FireflyIII\Support\Http\Controllers\TransactionCalculation;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -84,8 +86,8 @@ class BudgetReportController extends Controller
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
foreach ($budget['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,8 +116,8 @@ class BudgetReportController extends Controller
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,8 +146,8 @@ class BudgetReportController extends Controller
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,7 +164,7 @@ class BudgetReportController extends Controller
|
||||
{
|
||||
$chartData = [];
|
||||
$spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection([$budget]));
|
||||
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||
$format = Navigation::preferredCarbonLocalizedFormat($start, $end);
|
||||
|
||||
// loop expenses.
|
||||
foreach ($spent as $currency) {
|
||||
@@ -184,9 +186,9 @@ class BudgetReportController extends Controller
|
||||
foreach ($currency['budgets'] as $currentBudget) {
|
||||
foreach ($currentBudget['transaction_journals'] as $journal) {
|
||||
$key = $journal['date']->isoFormat($format);
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$chartData[$spentKey]['entries'][$key] ??= '0';
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], (string) $amount);
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,11 +201,11 @@ class BudgetReportController extends Controller
|
||||
private function makeEntries(Carbon $start, Carbon $end): array
|
||||
{
|
||||
$return = [];
|
||||
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||
$preferredRange = app('navigation')->preferredRangeFormat($start, $end);
|
||||
$format = Navigation::preferredCarbonLocalizedFormat($start, $end);
|
||||
$preferredRange = Navigation::preferredRangeFormat($start, $end);
|
||||
$currentStart = clone $start;
|
||||
while ($currentStart <= $end) {
|
||||
$currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
|
||||
$currentEnd = Navigation::endOfPeriod($currentStart, $preferredRange);
|
||||
$key = $currentStart->isoFormat($format);
|
||||
$return[$key] = '0';
|
||||
$currentStart = clone $currentEnd;
|
||||
@@ -232,8 +234,8 @@ class BudgetReportController extends Controller
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ use FireflyIII\Repositories\Category\OperationsRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Chart\Category\FrontpageChartGenerator;
|
||||
use FireflyIII\Support\Chart\Category\WholePeriodChartGenerator;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Controllers\AugumentData;
|
||||
use FireflyIII\Support\Http\Controllers\ChartGeneration;
|
||||
use FireflyIII\Support\Http\Controllers\DateCalculation;
|
||||
@@ -211,19 +212,19 @@ class CategoryController extends Controller
|
||||
// loop income and expenses for this category.:
|
||||
$outSet = $expenses[$currencyId]['categories'][$categoryId] ?? ['transaction_journals' => []];
|
||||
foreach ($outSet['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$date = $journal['date']->isoFormat($format);
|
||||
$chartData[$outKey]['entries'][$date] ??= '0';
|
||||
|
||||
$chartData[$outKey]['entries'][$date] = bcadd((string) $amount, $chartData[$outKey]['entries'][$date]);
|
||||
$chartData[$outKey]['entries'][$date] = bcadd($amount, $chartData[$outKey]['entries'][$date]);
|
||||
}
|
||||
|
||||
$inSet = $income[$currencyId]['categories'][$categoryId] ?? ['transaction_journals' => []];
|
||||
foreach ($inSet['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$date = $journal['date']->isoFormat($format);
|
||||
$chartData[$inKey]['entries'][$date] ??= '0';
|
||||
$chartData[$inKey]['entries'][$date] = bcadd((string) $amount, $chartData[$inKey]['entries'][$date]);
|
||||
$chartData[$inKey]['entries'][$date] = bcadd($amount, $chartData[$inKey]['entries'][$date]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,6 +28,7 @@ use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\OperationsRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Controllers\AugumentData;
|
||||
use FireflyIII\Support\Http\Controllers\TransactionCalculation;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -82,8 +83,8 @@ class CategoryReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,8 +110,8 @@ class CategoryReportController extends Controller
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
foreach ($category['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,8 +138,8 @@ class CategoryReportController extends Controller
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
foreach ($category['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,8 +166,8 @@ class CategoryReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,8 +194,8 @@ class CategoryReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,9 +231,9 @@ class CategoryReportController extends Controller
|
||||
foreach ($currency['categories'] as $currentCategory) {
|
||||
foreach ($currentCategory['transaction_journals'] as $journal) {
|
||||
$key = $journal['date']->isoFormat($format);
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$chartData[$spentKey]['entries'][$key] ??= '0';
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], (string) $amount);
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,9 +258,9 @@ class CategoryReportController extends Controller
|
||||
foreach ($currency['categories'] as $currentCategory) {
|
||||
foreach ($currentCategory['transaction_journals'] as $journal) {
|
||||
$key = $journal['date']->isoFormat($format);
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$chartData[$spentKey]['entries'][$key] ??= '0';
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], (string) $amount);
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,8 +307,8 @@ class CategoryReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -334,8 +335,8 @@ class CategoryReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Account\OperationsRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
@@ -81,8 +82,8 @@ class DoubleReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,8 +109,8 @@ class DoubleReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +136,8 @@ class DoubleReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,9 +177,9 @@ class DoubleReportController extends Controller
|
||||
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$key = $journal['date']->isoFormat($format);
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$chartData[$spentKey]['entries'][$key] ??= '0';
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], (string) $amount);
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
|
||||
}
|
||||
}
|
||||
// loop income.
|
||||
@@ -202,9 +203,9 @@ class DoubleReportController extends Controller
|
||||
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$key = $journal['date']->isoFormat($format);
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$chartData[$earnedKey]['entries'][$key] ??= '0';
|
||||
$chartData[$earnedKey]['entries'][$key] = bcadd($chartData[$earnedKey]['entries'][$key], (string) $amount);
|
||||
$chartData[$earnedKey]['entries'][$key] = bcadd($chartData[$earnedKey]['entries'][$key], $amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,8 +275,8 @@ class DoubleReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
|
||||
// loop each tag:
|
||||
@@ -293,8 +294,8 @@ class DoubleReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -327,8 +328,8 @@ class DoubleReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
|
||||
// loop each tag:
|
||||
@@ -346,8 +347,8 @@ class DoubleReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Controllers\BasicDataSupport;
|
||||
use FireflyIII\Support\Http\Controllers\ChartGeneration;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -73,7 +74,7 @@ class ReportController extends Controller
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$locale = app('steam')->getLocale();
|
||||
$locale = Steam::getLocale();
|
||||
$current = clone $start;
|
||||
$chartData = [];
|
||||
|
||||
@@ -193,7 +194,7 @@ class ReportController extends Controller
|
||||
];
|
||||
// in our outgoing?
|
||||
$key = 'spent';
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
|
||||
// deposit = incoming
|
||||
// transfer or reconcile or opening balance, and these accounts are the destination.
|
||||
@@ -207,7 +208,7 @@ class ReportController extends Controller
|
||||
&& in_array($journal['destination_account_id'], $ids, true))) {
|
||||
$key = 'earned';
|
||||
}
|
||||
$data[$currencyId][$period][$key] = bcadd((string) $data[$currencyId][$period][$key], (string) $amount);
|
||||
$data[$currencyId][$period][$key] = bcadd((string) $data[$currencyId][$period][$key], $amount);
|
||||
}
|
||||
|
||||
// loop this data, make chart bars for each currency:
|
||||
@@ -250,8 +251,8 @@ class ReportController extends Controller
|
||||
$title = $currentStart->isoFormat($titleFormat);
|
||||
// #8663 make sure the period exists in the data previously collected.
|
||||
if (array_key_exists($key, $currency)) {
|
||||
$income['entries'][$title] = app('steam')->bcround($currency[$key]['earned'] ?? '0', $currency['currency_decimal_places']);
|
||||
$expense['entries'][$title] = app('steam')->bcround($currency[$key]['spent'] ?? '0', $currency['currency_decimal_places']);
|
||||
$income['entries'][$title] = Steam::bcround($currency[$key]['earned'] ?? '0', $currency['currency_decimal_places']);
|
||||
$expense['entries'][$title] = Steam::bcround($currency[$key]['spent'] ?? '0', $currency['currency_decimal_places']);
|
||||
}
|
||||
// #9477 if the period is not in the data, add it with zero values.
|
||||
if (!array_key_exists($key, $currency)) {
|
||||
|
@@ -28,6 +28,7 @@ use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Repositories\Tag\OperationsRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Controllers\AugumentData;
|
||||
use FireflyIII\Support\Http\Controllers\TransactionCalculation;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -82,8 +83,8 @@ class TagReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,8 +111,8 @@ class TagReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,8 +139,8 @@ class TagReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,8 +167,8 @@ class TagReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,8 +195,8 @@ class TagReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,9 +236,9 @@ class TagReportController extends Controller
|
||||
foreach ($currency['tags'] as $currentTag) {
|
||||
foreach ($currentTag['transaction_journals'] as $journal) {
|
||||
$key = $journal['date']->isoFormat($format);
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$chartData[$spentKey]['entries'][$key] ??= '0';
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], (string) $amount);
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -262,9 +263,9 @@ class TagReportController extends Controller
|
||||
foreach ($currency['tags'] as $currentTag) {
|
||||
foreach ($currentTag['transaction_journals'] as $journal) {
|
||||
$key = $journal['date']->isoFormat($format);
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$chartData[$spentKey]['entries'][$key] ??= '0';
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], (string) $amount);
|
||||
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,8 +312,8 @@ class TagReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,8 +340,8 @@ class TagReportController extends Controller
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -366,8 +367,8 @@ class TagReportController extends Controller
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
foreach ($tag['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -392,8 +393,8 @@ class TagReportController extends Controller
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
foreach ($tag['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], (string) $amount);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -95,8 +95,8 @@ abstract class Controller extends BaseController
|
||||
View::share('logoutUrl', $logoutUrl);
|
||||
|
||||
// upload size
|
||||
$maxFileSize = Steam::phpBytes((string) ini_get('upload_max_filesize'));
|
||||
$maxPostSize = Steam::phpBytes((string) ini_get('post_max_size'));
|
||||
$maxFileSize = Steam::phpBytes( ini_get('upload_max_filesize'));
|
||||
$maxPostSize = Steam::phpBytes( ini_get('post_max_size'));
|
||||
$uploadSize = min($maxFileSize, $maxPostSize);
|
||||
View::share('uploadSize', $uploadSize);
|
||||
|
||||
|
@@ -151,13 +151,13 @@ class DebugController extends Controller
|
||||
}
|
||||
if ('' !== $logContent) {
|
||||
// last few lines
|
||||
$logContent = 'Truncated from this point <----|'.substr((string) $logContent, -16384);
|
||||
$logContent = 'Truncated from this point <----|'.substr($logContent, -16384);
|
||||
}
|
||||
|
||||
return view('debug', compact('table', 'now', 'logContent'));
|
||||
}
|
||||
|
||||
public function apiTest()
|
||||
public function apiTest(): View
|
||||
{
|
||||
return view('test.api-test');
|
||||
}
|
||||
@@ -175,8 +175,8 @@ class DebugController extends Controller
|
||||
|
||||
private function getSystemInformation(): array
|
||||
{
|
||||
$maxFileSize = Steam::phpBytes((string) ini_get('upload_max_filesize'));
|
||||
$maxPostSize = Steam::phpBytes((string) ini_get('post_max_size'));
|
||||
$maxFileSize = Steam::phpBytes( ini_get('upload_max_filesize'));
|
||||
$maxPostSize = Steam::phpBytes( ini_get('post_max_size'));
|
||||
$drivers = DB::availableDrivers();
|
||||
$currentDriver = DB::getDriverName();
|
||||
|
||||
@@ -208,7 +208,7 @@ class DebugController extends Controller
|
||||
|
||||
try {
|
||||
if (file_exists('/var/www/counter-main.txt')) {
|
||||
$return['build'] = trim((string) file_get_contents('/var/www/counter-main.txt'));
|
||||
$return['build'] = trim( file_get_contents('/var/www/counter-main.txt'));
|
||||
app('log')->debug(sprintf('build is now "%s"', $return['build']));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
@@ -218,7 +218,7 @@ class DebugController extends Controller
|
||||
|
||||
try {
|
||||
if (file_exists('/var/www/build-date-main.txt')) {
|
||||
$return['build_date'] = trim((string) file_get_contents('/var/www/build-date-main.txt'));
|
||||
$return['build_date'] = trim( file_get_contents('/var/www/build-date-main.txt'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
app('log')->debug('Could not check build date, but thats ok.');
|
||||
|
@@ -82,6 +82,7 @@ class ShowController extends Controller
|
||||
$admin = auth()->user();
|
||||
$enrichment = new PiggyBankEnrichment();
|
||||
$enrichment->setUser($admin);
|
||||
/** @var PiggyBank $piggyBank */
|
||||
$piggyBank = $enrichment->enrichSingle($piggyBank);
|
||||
|
||||
/** @var PiggyBankTransformer $transformer */
|
||||
|
@@ -155,7 +155,7 @@ class PreferencesController extends Controller
|
||||
// list of locales also has "equal" which makes it equal to whatever the language is.
|
||||
|
||||
try {
|
||||
$locales = json_decode((string) file_get_contents(resource_path(sprintf('locales/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR);
|
||||
$locales = json_decode(file_get_contents(resource_path(sprintf('locales/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR);
|
||||
} catch (JsonException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
$locales = [];
|
||||
|
@@ -207,7 +207,7 @@ class ProfileController extends Controller
|
||||
$existing = $repository->findByEmail($newEmail);
|
||||
if ($existing instanceof User) {
|
||||
// force user logout.
|
||||
Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
|
||||
Auth::guard()->logout();
|
||||
$request->session()->invalidate();
|
||||
|
||||
session()->flash('success', (string) trans('firefly.email_changed'));
|
||||
@@ -221,7 +221,7 @@ class ProfileController extends Controller
|
||||
event(new UserChangedEmail($user, $newEmail, $oldEmail));
|
||||
|
||||
// force user logout.
|
||||
Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
|
||||
Auth::guard()->logout();
|
||||
$request->session()->invalidate();
|
||||
session()->flash('success', (string) trans('firefly.email_changed'));
|
||||
|
||||
|
@@ -49,7 +49,7 @@ class CreateController extends Controller
|
||||
private AttachmentHelperInterface $attachments;
|
||||
private BillRepositoryInterface $billRepository;
|
||||
private BudgetRepositoryInterface $budgetRepos;
|
||||
private RecurringRepositoryInterface $recurring;
|
||||
private RecurringRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* CreateController constructor.
|
||||
@@ -65,8 +65,8 @@ class CreateController extends Controller
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
app('view')->share('subTitle', (string) trans('firefly.create_new_recurrence'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
$this->repository = app(RecurringRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
$this->billRepository = app(BillRepositoryInterface::class);
|
||||
|
||||
@@ -221,7 +221,7 @@ class CreateController extends Controller
|
||||
$data = $request->getAll();
|
||||
|
||||
try {
|
||||
$recurrence = $this->recurring->store($data);
|
||||
$recurrence = $this->repository->store($data);
|
||||
} catch (FireflyException $e) {
|
||||
session()->flash('error', $e->getMessage());
|
||||
|
||||
|
@@ -38,8 +38,7 @@ use Illuminate\View\View;
|
||||
*/
|
||||
class DeleteController extends Controller
|
||||
{
|
||||
/** @var RecurringRepositoryInterface Recurring repository */
|
||||
private $recurring;
|
||||
private RecurringRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* DeleteController constructor.
|
||||
@@ -54,7 +53,7 @@ class DeleteController extends Controller
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->repository = app(RecurringRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
@@ -72,7 +71,7 @@ class DeleteController extends Controller
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('recurrences.delete.url');
|
||||
|
||||
$journalsCreated = $this->recurring->getTransactions($recurrence)->count();
|
||||
$journalsCreated = $this->repository->getTransactions($recurrence)->count();
|
||||
|
||||
return view('recurring.delete', compact('recurrence', 'subTitle', 'journalsCreated'));
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ class EditController extends Controller
|
||||
private AttachmentHelperInterface $attachments;
|
||||
private BillRepositoryInterface $billRepository;
|
||||
private BudgetRepositoryInterface $budgetRepos;
|
||||
private RecurringRepositoryInterface $recurring;
|
||||
private RecurringRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* EditController constructor.
|
||||
@@ -70,8 +70,8 @@ class EditController extends Controller
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
app('view')->share('subTitle', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
$this->repository = app(RecurringRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
$this->billRepository = app(BillRepositoryInterface::class);
|
||||
|
||||
@@ -100,6 +100,7 @@ class EditController extends Controller
|
||||
$admin = auth()->user();
|
||||
$enrichment = new RecurringEnrichment();
|
||||
$enrichment->setUser($admin);
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $enrichment->enrichSingle($recurrence);
|
||||
|
||||
/** @var RecurrenceTransformer $transformer */
|
||||
@@ -180,7 +181,7 @@ class EditController extends Controller
|
||||
public function update(RecurrenceFormRequest $request, Recurrence $recurrence)
|
||||
{
|
||||
$data = $request->getAll();
|
||||
$this->recurring->update($recurrence, $data);
|
||||
$this->repository->update($recurrence, $data);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.updated_recurrence', ['title' => $recurrence->title]));
|
||||
Log::channel('audit')->info(sprintf('Updated recurrence #%d.', $recurrence->id), $data);
|
||||
|
@@ -45,7 +45,7 @@ class IndexController extends Controller
|
||||
{
|
||||
use GetConfigurationData;
|
||||
|
||||
private RecurringRepositoryInterface $recurringRepos;
|
||||
private RecurringRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* IndexController constructor.
|
||||
@@ -60,7 +60,7 @@ class IndexController extends Controller
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurringRepos = app(RecurringRepositoryInterface::class);
|
||||
$this->repository = app(RecurringRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class IndexController extends Controller
|
||||
{
|
||||
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$collection = $this->recurringRepos->get();
|
||||
$collection = $this->repository->get();
|
||||
$today = today(config('app.timezone'));
|
||||
$year = today(config('app.timezone'));
|
||||
|
||||
|
@@ -47,8 +47,7 @@ class ShowController extends Controller
|
||||
{
|
||||
use GetConfigurationData;
|
||||
|
||||
/** @var RecurringRepositoryInterface Recurring repository */
|
||||
private $recurring;
|
||||
private RecurringRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* IndexController constructor.
|
||||
@@ -64,7 +63,7 @@ class ShowController extends Controller
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->repository = app(RecurringRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
@@ -87,6 +86,7 @@ class ShowController extends Controller
|
||||
$admin = auth()->user();
|
||||
$enrichment = new RecurringEnrichment();
|
||||
$enrichment->setUser($admin);
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $enrichment->enrichSingle($recurrence);
|
||||
|
||||
/** @var RecurrenceTransformer $transformer */
|
||||
@@ -95,10 +95,10 @@ class ShowController extends Controller
|
||||
|
||||
$array = $transformer->transform($recurrence);
|
||||
|
||||
$groups = $this->recurring->getTransactions($recurrence);
|
||||
$groups = $this->repository->getTransactions($recurrence);
|
||||
$today = today(config('app.timezone'));
|
||||
$array['repeat_until'] = null !== $array['repeat_until'] ? new Carbon($array['repeat_until']) : null;
|
||||
$array['journal_count'] = $this->recurring->getJournalCount($recurrence);
|
||||
$array['journal_count'] = $this->repository->getJournalCount($recurrence);
|
||||
|
||||
// transform dates back to Carbon objects and expand information
|
||||
foreach ($array['repetitions'] as $index => $repetition) {
|
||||
@@ -106,8 +106,8 @@ class ShowController extends Controller
|
||||
$date = new Carbon($occurrence)->startOfDay();
|
||||
$set = [
|
||||
'date' => $date,
|
||||
'fired' => $this->recurring->createdPreviously($recurrence, $date)
|
||||
|| $this->recurring->getJournalCount($recurrence, $date) > 0,
|
||||
'fired' => $this->repository->createdPreviously($recurrence, $date)
|
||||
|| $this->repository->getJournalCount($recurrence, $date) > 0,
|
||||
];
|
||||
$array['repetitions'][$index]['occurrences'][$item] = $set;
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\TriggerRecurrenceRequest;
|
||||
use FireflyIII\Jobs\CreateRecurringTransactions;
|
||||
use FireflyIII\Models\Recurrence;
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -37,6 +38,28 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class TriggerController extends Controller
|
||||
{
|
||||
private RecurringRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* IndexController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
app('view')->share('showCategory', true);
|
||||
|
||||
// translations:
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->repository = app(RecurringRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
}
|
||||
public function trigger(Recurrence $recurrence, TriggerRecurrenceRequest $request): RedirectResponse
|
||||
{
|
||||
$all = $request->getAll();
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Transaction;
|
||||
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use Exception;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
@@ -337,8 +338,9 @@ class ConvertController extends Controller
|
||||
'type' => $transactionType->type,
|
||||
];
|
||||
|
||||
/** @var Transaction|null $sourceTransaction */
|
||||
$sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
$amount = $sourceTransaction?->amount ?? '0';
|
||||
$amount = $sourceTransaction->amount ?? '0';
|
||||
|
||||
// also set the currency to the currency of the source account, in case you're converting a deposit into a transfer.
|
||||
if (TransactionTypeEnum::TRANSFER->value === $transactionType->type && TransactionTypeEnum::DEPOSIT->value === $journal->transactionType->type) {
|
||||
|
@@ -92,7 +92,7 @@ class ShowController extends Controller
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($admin)->setTransactionGroup($transactionGroup)->withAPIInformation();
|
||||
|
||||
/** @var TransactionGroup $selectedGroup */
|
||||
/** @var TransactionGroup|null $selectedGroup */
|
||||
$selectedGroup = $collector->getGroups()->first();
|
||||
if (null === $selectedGroup) {
|
||||
throw new NotFoundHttpException();
|
||||
@@ -119,6 +119,7 @@ class ShowController extends Controller
|
||||
// enrich
|
||||
$enrichment = new TransactionGroupEnrichment();
|
||||
$enrichment->setUser($admin);
|
||||
/** @var array $selectedGroup */
|
||||
$selectedGroup = $enrichment->enrichSingle($selectedGroup);
|
||||
|
||||
/** @var TransactionGroupTransformer $transformer */
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
@@ -101,12 +102,12 @@ class Range
|
||||
private function configureView(): void
|
||||
{
|
||||
// get locale preference:
|
||||
$language = app('steam')->getLanguage();
|
||||
$locale = app('steam')->getLocale();
|
||||
$language = Steam::getLanguage();
|
||||
$locale = Steam::getLocale();
|
||||
App::setLocale($language);
|
||||
Carbon::setLocale(substr((string) $locale, 0, 2));
|
||||
Carbon::setLocale(substr($locale, 0, 2));
|
||||
|
||||
$localeArray = app('steam')->getLocaleArray($locale);
|
||||
$localeArray = Steam::getLocaleArray($locale);
|
||||
|
||||
setlocale(LC_TIME, $localeArray);
|
||||
$moneyResult = setlocale(LC_MONETARY, $localeArray);
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Location;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Rules\IsValidPositiveAmount;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Rules\IsValidPositiveAmount;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Rules\IsValidPositiveAmount;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Rules\IsValidPositiveAmount;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Rules\IsValidPositiveAmount;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Models\LinkType;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Rules\IsValidAmount;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Models\ObjectGroup;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Rules\IsValidPositiveAmount;
|
||||
@@ -32,6 +32,7 @@ use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
/**
|
||||
* Class PiggyBankStoreRequest.
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Rules\IsValidAmount;
|
||||
use FireflyIII\Rules\ValidJournals;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\CategoryFactory;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -146,7 +146,7 @@ class ReportFormRequest extends FormRequest
|
||||
// if regex for YYYY-MM-DD:
|
||||
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/';
|
||||
$result = preg_match($pattern, $string);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
if (0 !== $result) {
|
||||
try {
|
||||
$date = new Carbon($parts[1]);
|
||||
} catch (Exception $e) { // intentional generic exception
|
||||
@@ -184,7 +184,7 @@ class ReportFormRequest extends FormRequest
|
||||
// if regex for YYYY-MM-DD:
|
||||
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/';
|
||||
$result = preg_match($pattern, $string);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
if (0 !== $result) {
|
||||
try {
|
||||
$date = new Carbon($parts[0]);
|
||||
} catch (Exception $e) { // intentional generic exception
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Rules\IsValidActionExpression;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Rules\IsBoolean;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Models\Location;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Support\Request\AppendsLocationData;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\GetRuleConfiguration;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@@ -129,7 +129,7 @@ class MailError extends Job implements ShouldQueue
|
||||
}
|
||||
if (file_exists($file)) {
|
||||
Log::debug(sprintf('Read file in "%s"', $file));
|
||||
$limits = json_decode((string) file_get_contents($file), true);
|
||||
$limits = json_decode( file_get_contents($file), true);
|
||||
}
|
||||
// limit reached?
|
||||
foreach ($types as $type => $info) {
|
||||
|
@@ -171,6 +171,7 @@ class WarnAboutBills implements ShouldQueue
|
||||
$enrichment->setUser($bill->user);
|
||||
$enrichment->setStart($start);
|
||||
$enrichment->setEnd($end);
|
||||
/** @var Bill $single */
|
||||
$single = $enrichment->enrichSingle($bill);
|
||||
|
||||
return [
|
||||
|
@@ -45,7 +45,11 @@ class InvitationMail extends Mailable
|
||||
*/
|
||||
public function __construct(public string $invitee, public string $admin, public string $url)
|
||||
{
|
||||
$this->host = (string) parse_url($this->url, PHP_URL_HOST);
|
||||
$host = parse_url($this->url, PHP_URL_HOST);
|
||||
if(is_array($host)) {
|
||||
$host ='';
|
||||
}
|
||||
$this->host = (string) $host;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -40,8 +40,6 @@ class Configuration extends Model
|
||||
|
||||
/**
|
||||
* TODO can be replaced with native laravel code.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function data(): Attribute
|
||||
{
|
||||
|
@@ -41,15 +41,12 @@ class TransactionJournalMeta extends Model
|
||||
|
||||
protected $table = 'journal_meta';
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function data(): Attribute
|
||||
{
|
||||
return Attribute::make(get: fn ($value) => json_decode((string) $value, false), set: function ($value) {
|
||||
$data = json_encode($value);
|
||||
|
||||
return ['data' => $data, 'hash' => hash('sha256', (string) $data)];
|
||||
return ['data' => $data, 'hash' => hash('sha256', $data)];
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -68,20 +68,21 @@ class UnknownUserLoginAttempt extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
*/
|
||||
public function toNtfy(OwnerNotifiable $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'owner', null);
|
||||
$message = new Message();
|
||||
$ip = Request::ip();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.unknown_user_subject'));
|
||||
$message->body((string) trans('email.unknown_user_message', ['address' => $this->address, 'ip' => $ip]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// /**
|
||||
// * @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
// */
|
||||
//
|
||||
// public function toNtfy(OwnerNotifiable $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'owner', null);
|
||||
// $message = new Message();
|
||||
// $ip = Request::ip();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.unknown_user_subject'));
|
||||
// $message->body((string) trans('email.unknown_user_message', ['address' => $this->address, 'ip' => $ip]));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -73,20 +73,20 @@ class UserInvitation extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
*/
|
||||
public function toNtfy(OwnerNotifiable $notifiable): Message
|
||||
{
|
||||
Log::debug('Now in toNtfy() for UserInvitation');
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'owner', null);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.invitation_created_subject'));
|
||||
$message->body((string) trans('email.invitation_created_body', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// /**
|
||||
// * @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
// */
|
||||
// public function toNtfy(OwnerNotifiable $notifiable): Message
|
||||
// {
|
||||
// Log::debug('Now in toNtfy() for UserInvitation');
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'owner', null);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.invitation_created_subject'));
|
||||
// $message->body((string) trans('email.invitation_created_body', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email]));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -72,20 +72,20 @@ class UserRegistration extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
*/
|
||||
public function toNtfy(OwnerNotifiable $notifiable): Message
|
||||
{
|
||||
Log::debug('Now in toNtfy() for (Admin) UserRegistration');
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'owner', null);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.registered_subject_admin'));
|
||||
$message->body((string) trans('email.admin_new_user_registered', ['email' => $this->user->email, 'invitee' => $this->user->email]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// /**
|
||||
// * @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
// */
|
||||
// public function toNtfy(OwnerNotifiable $notifiable): Message
|
||||
// {
|
||||
// Log::debug('Now in toNtfy() for (Admin) UserRegistration');
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'owner', null);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.registered_subject_admin'));
|
||||
// $message->body((string) trans('email.admin_new_user_registered', ['email' => $this->user->email, 'invitee' => $this->user->email]));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -64,20 +64,20 @@ class VersionCheckResult extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
*/
|
||||
public function toNtfy(OwnerNotifiable $notifiable): Message
|
||||
{
|
||||
Log::debug('Now in toNtfy() for VersionCheckResult');
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'owner', null);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.new_version_email_subject'));
|
||||
$message->body($this->message);
|
||||
|
||||
return $message;
|
||||
}
|
||||
// /**
|
||||
// * @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
// */
|
||||
// public function toNtfy(OwnerNotifiable $notifiable): Message
|
||||
// {
|
||||
// Log::debug('Now in toNtfy() for VersionCheckResult');
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'owner', null);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.new_version_email_subject'));
|
||||
// $message->body($this->message);
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -28,7 +28,7 @@ use FireflyIII\Support\Notifications\UrlValidator;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use NotificationChannels\Pushover\PushoverChannel;
|
||||
use Wijourdil\NtfyNotificationChannel\Channels\NtfyChannel;
|
||||
//use Wijourdil\NtfyNotificationChannel\Channels\NtfyChannel;
|
||||
|
||||
class ReturnsAvailableChannels
|
||||
{
|
||||
@@ -58,16 +58,16 @@ class ReturnsAvailableChannels
|
||||
}
|
||||
}
|
||||
|
||||
if (true === config('notifications.channels.ntfy.enabled', false)) {
|
||||
// validate presence of of Ntfy settings.
|
||||
if ('' !== (string) app('fireflyconfig')->getEncrypted('ntfy_topic', '')->data) {
|
||||
Log::debug('Enabled ntfy.');
|
||||
$channels[] = NtfyChannel::class;
|
||||
}
|
||||
if ('' === (string) app('fireflyconfig')->getEncrypted('ntfy_topic', '')->data) {
|
||||
Log::warning('No topic name for Ntfy, channel is disabled.');
|
||||
}
|
||||
}
|
||||
// if (true === config('notifications.channels.ntfy.enabled', false)) {
|
||||
// // validate presence of of Ntfy settings.
|
||||
// if ('' !== (string) app('fireflyconfig')->getEncrypted('ntfy_topic', '')->data) {
|
||||
// Log::debug('Enabled ntfy.');
|
||||
// $channels[] = NtfyChannel::class;
|
||||
// }
|
||||
// if ('' === (string) app('fireflyconfig')->getEncrypted('ntfy_topic', '')->data) {
|
||||
// Log::warning('No topic name for Ntfy, channel is disabled.');
|
||||
// }
|
||||
// }
|
||||
|
||||
// pushover
|
||||
if (true === config('notifications.channels.pushover.enabled', false)) {
|
||||
@@ -99,17 +99,17 @@ class ReturnsAvailableChannels
|
||||
}
|
||||
}
|
||||
|
||||
// validate presence of of Ntfy settings.
|
||||
if (true === config('notifications.channels.nfy.enabled', false)) {
|
||||
$ntfyTopic = (string) app('preferences')->getEncryptedForUser($user, 'ntfy_topic', '')->data;
|
||||
if ('' !== $ntfyTopic) {
|
||||
Log::debug(sprintf('Enabled ntfy, "%s"', $ntfyTopic));
|
||||
$channels[] = NtfyChannel::class;
|
||||
}
|
||||
if ('' === (string) app('preferences')->getEncryptedForUser($user, 'ntfy_topic', '')->data) {
|
||||
Log::warning('No topic name for Ntfy, channel is disabled.');
|
||||
}
|
||||
}
|
||||
// // validate presence of of Ntfy settings.
|
||||
// if (true === config('notifications.channels.nfy.enabled', false)) {
|
||||
// $ntfyTopic = (string) app('preferences')->getEncryptedForUser($user, 'ntfy_topic', '')->data;
|
||||
// if ('' !== $ntfyTopic) {
|
||||
// Log::debug(sprintf('Enabled ntfy, "%s"', $ntfyTopic));
|
||||
// $channels[] = NtfyChannel::class;
|
||||
// }
|
||||
// if ('' === (string) app('preferences')->getEncryptedForUser($user, 'ntfy_topic', '')->data) {
|
||||
// Log::warning('No topic name for Ntfy, channel is disabled.');
|
||||
// }
|
||||
// }
|
||||
|
||||
// pushover
|
||||
if (true === config('notifications.channels.slack.enabled', false)) {
|
||||
|
@@ -65,16 +65,16 @@ class DisabledMFANotification extends Notification
|
||||
return new MailMessage()->markdown('emails.security.disabled-mfa', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.disabled_mfa_subject'));
|
||||
$message->body((string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.disabled_mfa_subject'));
|
||||
// $message->body((string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -65,16 +65,16 @@ class EnabledMFANotification extends Notification
|
||||
return new MailMessage()->markdown('emails.security.enabled-mfa', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.enabled_mfa_subject'));
|
||||
$message->body((string) trans('email.enabled_mfa_slack', ['email' => $this->user->email]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.enabled_mfa_subject'));
|
||||
// $message->body((string) trans('email.enabled_mfa_slack', ['email' => $this->user->email]));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -65,16 +65,16 @@ class MFABackupFewLeftNotification extends Notification
|
||||
return new MailMessage()->markdown('emails.security.few-backup-codes', ['user' => $this->user, 'count' => $this->count, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.mfa_few_backups_left_subject'));
|
||||
$message->body((string) trans('email.mfa_few_backups_left_slack', ['email' => $this->user->email, 'count' => $this->count]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.mfa_few_backups_left_subject'));
|
||||
// $message->body((string) trans('email.mfa_few_backups_left_slack', ['email' => $this->user->email, 'count' => $this->count]));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -65,16 +65,16 @@ class MFABackupNoLeftNotification extends Notification
|
||||
return new MailMessage()->markdown('emails.security.no-backup-codes', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.mfa_no_backups_left_subject'));
|
||||
$message->body((string) trans('email.mfa_no_backups_left_slack', ['email' => $this->user->email]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.mfa_no_backups_left_subject'));
|
||||
// $message->body((string) trans('email.mfa_no_backups_left_slack', ['email' => $this->user->email]));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -62,16 +62,16 @@ class MFAManyFailedAttemptsNotification extends Notification
|
||||
return new MailMessage()->markdown('emails.security.many-failed-attempts', ['user' => $this->user, 'count' => $this->count, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.mfa_many_failed_subject'));
|
||||
$message->body((string) trans('email.mfa_many_failed_slack', ['email' => $this->user->email, 'count' => $this->count]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.mfa_many_failed_subject'));
|
||||
// $message->body((string) trans('email.mfa_many_failed_slack', ['email' => $this->user->email, 'count' => $this->count]));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -65,16 +65,16 @@ class MFAUsedBackupCodeNotification extends Notification
|
||||
return new MailMessage()->markdown('emails.security.used-backup-code', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.used_backup_code_subject'));
|
||||
$message->body((string) trans('email.used_backup_code_slack', ['email' => $this->user->email]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.used_backup_code_subject'));
|
||||
// $message->body((string) trans('email.used_backup_code_slack', ['email' => $this->user->email]));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -65,16 +65,16 @@ class NewBackupCodesNotification extends Notification
|
||||
return new MailMessage()->markdown('emails.security.new-backup-codes', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.new_backup_codes_subject'));
|
||||
$message->body((string) trans('email.new_backup_codes_slack', ['email' => $this->user->email]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.new_backup_codes_subject'));
|
||||
// $message->body((string) trans('email.new_backup_codes_slack', ['email' => $this->user->email]));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -63,17 +63,17 @@ class UserFailedLoginAttempt extends Notification
|
||||
return new MailMessage()->markdown('emails.security.failed-login', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$ip = Request::ip();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.failed_login_subject'));
|
||||
$message->body((string) trans('email.failed_login_message', ['ip' => $ip, 'email' => $this->user->email]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $ip = Request::ip();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.failed_login_subject'));
|
||||
// $message->body((string) trans('email.failed_login_message', ['ip' => $ip, 'email' => $this->user->email]));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -49,26 +49,20 @@ class OwnerTestNotificationNtfy extends Notification
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
*/
|
||||
public function toNtfy(OwnerNotifiable $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'owner', null);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.admin_test_subject'));
|
||||
$message->body((string) trans('email.admin_test_message', ['channel' => 'ntfy']));
|
||||
$message->tags(['white_check_mark']);
|
||||
// public function toNtfy(OwnerNotifiable $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'owner', null);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.admin_test_subject'));
|
||||
// $message->body((string) trans('email.admin_test_message', ['channel' => 'ntfy']));
|
||||
// $message->tags(['white_check_mark']);
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
*/
|
||||
public function via(OwnerNotifiable $notifiable): array
|
||||
{
|
||||
return [NtfyChannel::class];
|
||||
}
|
||||
// public function via(OwnerNotifiable $notifiable): array
|
||||
// {
|
||||
// return [NtfyChannel::class];
|
||||
// }
|
||||
}
|
||||
|
@@ -49,26 +49,20 @@ class UserTestNotificationNtfy extends Notification
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
*/
|
||||
public function toNtfy(User $user): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $user);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.admin_test_subject'));
|
||||
$message->body((string) trans('email.admin_test_message', ['channel' => 'ntfy']));
|
||||
$message->tags(['white_check_mark']);
|
||||
// public function toNtfy(User $user): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $user);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.admin_test_subject'));
|
||||
// $message->body((string) trans('email.admin_test_message', ['channel' => 'ntfy']));
|
||||
// $message->tags(['white_check_mark']);
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
*/
|
||||
public function via(User $user): array
|
||||
{
|
||||
return [NtfyChannel::class];
|
||||
}
|
||||
// public function via(User $user): array
|
||||
// {
|
||||
// return [NtfyChannel::class];
|
||||
// }
|
||||
}
|
||||
|
@@ -73,16 +73,16 @@ class BillReminder extends Notification
|
||||
return (string) trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title($this->getSubject());
|
||||
$message->body((string) trans('email.bill_warning_please_action'));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title($this->getSubject());
|
||||
// $message->body((string) trans('email.bill_warning_please_action'));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -68,16 +68,16 @@ class NewAccessToken extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.access_token_created_subject'));
|
||||
$message->body((string) trans('email.access_token_created_body'));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.access_token_created_subject'));
|
||||
// $message->body((string) trans('email.access_token_created_body'));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -65,15 +65,15 @@ class RuleActionFailed extends Notification
|
||||
];
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->body($this->message);
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->body($this->message);
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -87,16 +87,16 @@ class SubscriptionsOverdueReminder extends Notification
|
||||
return (string)trans('email.subscriptions_overdue_subject_single');
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title($this->getSubject());
|
||||
$message->body((string)trans('email.bill_warning_please_action'));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title($this->getSubject());
|
||||
// $message->body((string)trans('email.bill_warning_please_action'));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -65,18 +65,18 @@ class UserLogin extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$ip = Request::ip();
|
||||
$host = Steam::getHostName($ip);
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->title((string) trans('email.login_from_new_ip'));
|
||||
$message->body((string) trans('email.slack_login_from_new_ip', ['ip' => $ip, 'host' => $host]));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $ip = Request::ip();
|
||||
// $host = Steam::getHostName($ip);
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->title((string) trans('email.login_from_new_ip'));
|
||||
// $message->body((string) trans('email.slack_login_from_new_ip', ['ip' => $ip, 'host' => $host]));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -70,15 +70,15 @@ class UserNewPassword extends Notification
|
||||
;
|
||||
}
|
||||
|
||||
public function toNtfy(User $notifiable): Message
|
||||
{
|
||||
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
$message = new Message();
|
||||
$message->topic($settings['ntfy_topic']);
|
||||
$message->body((string) trans('email.reset_pw_message'));
|
||||
|
||||
return $message;
|
||||
}
|
||||
// public function toNtfy(User $notifiable): Message
|
||||
// {
|
||||
// $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
|
||||
// $message = new Message();
|
||||
// $message->topic($settings['ntfy_topic']);
|
||||
// $message->body((string) trans('email.reset_pw_message'));
|
||||
//
|
||||
// return $message;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
|
@@ -83,7 +83,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
||||
];
|
||||
|
||||
$array[$currencyId]['transaction_journals'][$journalId] = [
|
||||
'amount' => app('steam')->{$direction}((string) $journal['amount']), // @phpstan-ignore-line
|
||||
'amount' => Steam::{$direction}((string) $journal['amount']), // @phpstan-ignore-line
|
||||
'date' => $journal['date'],
|
||||
'transaction_journal_id' => $journalId,
|
||||
'budget_name' => $journal['budget_name'],
|
||||
@@ -331,7 +331,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
||||
$currencyId = $journal['currency_id'];
|
||||
$sourceKey = sprintf('%d-%d', $currencyId, $sourceId);
|
||||
$destKey = sprintf('%d-%d', $currencyId, $destinationId);
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$amount = Steam::positive($journal['amount']);
|
||||
|
||||
// source first
|
||||
$return[$sourceKey] ??= [
|
||||
@@ -366,7 +366,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
||||
$return[$sourceKey]['difference'] = bcadd($return[$sourceKey]['out'], (string) $return[$sourceKey]['in']);
|
||||
|
||||
// destination account? money comes in:
|
||||
$return[$destKey]['in'] = bcadd((string) $return[$destKey]['in'], (string) $amount);
|
||||
$return[$destKey]['in'] = bcadd((string) $return[$destKey]['in'], $amount);
|
||||
$return[$destKey]['difference'] = bcadd((string) $return[$destKey]['out'], $return[$destKey]['in']);
|
||||
|
||||
// foreign currency
|
||||
@@ -374,7 +374,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
||||
$currencyId = $journal['foreign_currency_id'];
|
||||
$sourceKey = sprintf('%d-%d', $currencyId, $sourceId);
|
||||
$destKey = sprintf('%d-%d', $currencyId, $destinationId);
|
||||
$amount = app('steam')->positive($journal['foreign_amount']);
|
||||
$amount = Steam::positive($journal['foreign_amount']);
|
||||
|
||||
// same as above:
|
||||
// source first
|
||||
@@ -409,7 +409,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
||||
$return[$sourceKey]['difference'] = bcadd($return[$sourceKey]['out'], (string) $return[$sourceKey]['in']);
|
||||
|
||||
// destination account? money comes in:
|
||||
$return[$destKey]['in'] = bcadd((string) $return[$destKey]['in'], (string) $amount);
|
||||
$return[$destKey]['in'] = bcadd((string) $return[$destKey]['in'], $amount);
|
||||
$return[$destKey]['difference'] = bcadd((string) $return[$destKey]['out'], $return[$destKey]['in']);
|
||||
}
|
||||
|
||||
|
@@ -310,10 +310,10 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
|
||||
|
||||
return $budget;
|
||||
}
|
||||
if (0 === $autoBudgetType && !$autoBudget instanceof AutoBudget) {
|
||||
if (0 === $autoBudgetType) {
|
||||
return $budget;
|
||||
}
|
||||
if (null === $autoBudgetType && !$autoBudget instanceof AutoBudget) {
|
||||
if (null === $autoBudgetType) {
|
||||
return $budget;
|
||||
}
|
||||
$this->updateAutoBudget($budget, $data);
|
||||
|
@@ -267,10 +267,9 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
|
||||
|
||||
return $result;
|
||||
}
|
||||
if (null === $result) {
|
||||
Log::debug(sprintf('Searching for currency with code "%s"...', $currencyCode));
|
||||
$result = $this->findByCode((string) $currencyCode);
|
||||
}
|
||||
Log::debug(sprintf('Searching for currency with code "%s"...', $currencyCode));
|
||||
$result = $this->findByCode((string) $currencyCode);
|
||||
|
||||
if ($result instanceof TransactionCurrency && false === $result->enabled) {
|
||||
Log::debug(sprintf('Also enabled currency %s', $result->code));
|
||||
$this->enable($result);
|
||||
|
@@ -182,7 +182,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn
|
||||
$query = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->groupBy('transaction_journals.id')
|
||||
;
|
||||
$result = $query->get(['transaction_journals.id as id', DB::raw('count(transactions.id) as transaction_count')]); // @phpstan-ignore-line
|
||||
$result = $query->get(['transaction_journals.id as id', DB::raw('count(transactions.id) as transaction_count')]);
|
||||
$journalIds = [];
|
||||
|
||||
/** @var stdClass $row */
|
||||
|
@@ -67,7 +67,7 @@ trait ModifiesPiggyBanks
|
||||
{
|
||||
$currentAmount = $this->getCurrentAmount($piggyBank, $account);
|
||||
$pivot = $piggyBank->accounts()->where('accounts.id', $account->id)->first()->pivot;
|
||||
$pivot->current_amount = bcsub((string)$currentAmount, $amount);
|
||||
$pivot->current_amount = bcsub($currentAmount, $amount);
|
||||
$pivot->native_current_amount = null;
|
||||
|
||||
// also update native_current_amount.
|
||||
@@ -90,7 +90,7 @@ trait ModifiesPiggyBanks
|
||||
{
|
||||
$currentAmount = $this->getCurrentAmount($piggyBank, $account);
|
||||
$pivot = $piggyBank->accounts()->where('accounts.id', $account->id)->first()->pivot;
|
||||
$pivot->current_amount = bcadd((string)$currentAmount, $amount);
|
||||
$pivot->current_amount = bcadd($currentAmount, $amount);
|
||||
$pivot->native_current_amount = null;
|
||||
|
||||
// also update native_current_amount.
|
||||
@@ -122,13 +122,13 @@ trait ModifiesPiggyBanks
|
||||
|
||||
|
||||
if (0 !== bccomp($piggyBank->target_amount, '0')) {
|
||||
$leftToSave = bcsub($piggyBank->target_amount, (string)$savedSoFar);
|
||||
$maxAmount = 1 === bccomp((string)$leftOnAccount, $leftToSave) ? $leftToSave : $leftOnAccount;
|
||||
$leftToSave = bcsub($piggyBank->target_amount, $savedSoFar);
|
||||
$maxAmount = 1 === bccomp($leftOnAccount, $leftToSave) ? $leftToSave : $leftOnAccount;
|
||||
Log::debug(sprintf('Left to save: %s', $leftToSave));
|
||||
Log::debug(sprintf('Maximum amount: %s', $maxAmount));
|
||||
}
|
||||
|
||||
$compare = bccomp($amount, (string)$maxAmount);
|
||||
$compare = bccomp($amount, $maxAmount);
|
||||
$result = $compare <= 0;
|
||||
|
||||
Log::debug(sprintf('Compare <= 0? %d, so canAddAmount is %s', $compare, var_export($result, true)));
|
||||
@@ -140,7 +140,7 @@ trait ModifiesPiggyBanks
|
||||
{
|
||||
$savedSoFar = $this->getCurrentAmount($piggyBank, $account);
|
||||
|
||||
return bccomp($amount, (string)$savedSoFar) <= 0;
|
||||
return bccomp($amount, $savedSoFar) <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,9 +234,9 @@ trait ModifiesPiggyBanks
|
||||
// if the piggy bank is now smaller than the sum of the money saved,
|
||||
// remove money from all accounts until the piggy bank is the right amount.
|
||||
$currentAmount = $this->getCurrentAmount($piggyBank);
|
||||
if (1 === bccomp((string)$currentAmount, (string)$piggyBank->target_amount) && 0 !== bccomp((string)$piggyBank->target_amount, '0')) {
|
||||
if (1 === bccomp($currentAmount, (string)$piggyBank->target_amount) && 0 !== bccomp((string)$piggyBank->target_amount, '0')) {
|
||||
Log::debug(sprintf('Current amount is %s, target amount is %s', $currentAmount, $piggyBank->target_amount));
|
||||
$difference = bcsub((string)$piggyBank->target_amount, (string)$currentAmount);
|
||||
$difference = bcsub((string)$piggyBank->target_amount, $currentAmount);
|
||||
|
||||
// an amount will be removed, create "negative" event:
|
||||
// Log::debug(sprintf('ChangedAmount: is triggered with difference "%s"', $difference));
|
||||
|
@@ -67,12 +67,12 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
|
||||
|
||||
public function findPiggyBank(?int $piggyBankId, ?string $piggyBankName): ?PiggyBank
|
||||
{
|
||||
app('log')->debug('Searching for piggy information.');
|
||||
Log::debug('Searching for piggy information.');
|
||||
|
||||
if (null !== $piggyBankId) {
|
||||
$searchResult = $this->find($piggyBankId);
|
||||
if ($searchResult instanceof PiggyBank) {
|
||||
app('log')->debug(sprintf('Found piggy based on #%d, will return it.', $piggyBankId));
|
||||
Log::debug(sprintf('Found piggy based on #%d, will return it.', $piggyBankId));
|
||||
|
||||
return $searchResult;
|
||||
}
|
||||
@@ -80,12 +80,12 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
|
||||
if (null !== $piggyBankName) {
|
||||
$searchResult = $this->findByName($piggyBankName);
|
||||
if ($searchResult instanceof PiggyBank) {
|
||||
app('log')->debug(sprintf('Found piggy based on "%s", will return it.', $piggyBankName));
|
||||
Log::debug(sprintf('Found piggy based on "%s", will return it.', $piggyBankName));
|
||||
|
||||
return $searchResult;
|
||||
}
|
||||
}
|
||||
app('log')->debug('Found no piggy bank.');
|
||||
Log::debug('Found no piggy bank.');
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
|
||||
*/
|
||||
public function getExactAmount(PiggyBank $piggyBank, TransactionJournal $journal): string
|
||||
{
|
||||
app('log')->debug(sprintf('Now in getExactAmount(%d, %d)', $piggyBank->id, $journal->id));
|
||||
Log::debug(sprintf('Now in getExactAmount(%d, %d)', $piggyBank->id, $journal->id));
|
||||
|
||||
$operator = null;
|
||||
$currency = null;
|
||||
@@ -173,7 +173,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
|
||||
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
|
||||
app('log')->debug(sprintf('Piggy bank #%d currency is %s', $piggyBank->id, $piggyBank->transactionCurrency->code));
|
||||
Log::debug(sprintf('Piggy bank #%d currency is %s', $piggyBank->id, $piggyBank->transactionCurrency->code));
|
||||
|
||||
/** @var Transaction $source */
|
||||
$source = $journal->transactions()->with(['account'])->where('amount', '<', 0)->first();
|
||||
@@ -187,26 +187,26 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
|
||||
if ($account->id === $source->account_id) {
|
||||
$operator = 'negative';
|
||||
$currency = $accountRepos->getAccountCurrency($source->account) ?? $primaryCurrency;
|
||||
app('log')->debug(sprintf('Currency will draw money out of piggy bank. Source currency is %s', $currency->code));
|
||||
Log::debug(sprintf('Currency will draw money out of piggy bank. Source currency is %s', $currency->code));
|
||||
++$hits;
|
||||
}
|
||||
// matches destination, which means amount will be added to piggy.
|
||||
if ($account->id === $destination->account_id) {
|
||||
$operator = 'positive';
|
||||
$currency = $accountRepos->getAccountCurrency($destination->account) ?? $primaryCurrency;
|
||||
app('log')->debug(sprintf('Currency will add money to piggy bank. Destination currency is %s', $currency->code));
|
||||
Log::debug(sprintf('Currency will add money to piggy bank. Destination currency is %s', $currency->code));
|
||||
++$hits;
|
||||
}
|
||||
}
|
||||
if ($hits > 1) {
|
||||
app('log')->debug(sprintf('Transaction journal is related to %d of the accounts, cannot determine what to do. Return "0".', $hits));
|
||||
Log::debug(sprintf('Transaction journal is related to %d of the accounts, cannot determine what to do. Return "0".', $hits));
|
||||
|
||||
return '0';
|
||||
}
|
||||
|
||||
|
||||
if (null === $operator || null === $currency) {
|
||||
app('log')->debug('Currency is NULL and operator is NULL, return "0".');
|
||||
Log::debug('Currency is NULL and operator is NULL, return "0".');
|
||||
|
||||
return '0';
|
||||
}
|
||||
@@ -214,52 +214,52 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
|
||||
// which amount from the transaction matches?
|
||||
$amount = null;
|
||||
if ((int) $source->transaction_currency_id === $currency->id) {
|
||||
app('log')->debug('Use normal amount');
|
||||
$amount = app('steam')->{$operator}($source->amount); // @phpstan-ignore-line
|
||||
Log::debug('Use normal amount');
|
||||
$amount = Steam::{$operator}($source->amount); // @phpstan-ignore-line
|
||||
}
|
||||
if ((int) $source->foreign_currency_id === $currency->id) {
|
||||
app('log')->debug('Use foreign amount');
|
||||
$amount = app('steam')->{$operator}($source->foreign_amount); // @phpstan-ignore-line
|
||||
Log::debug('Use foreign amount');
|
||||
$amount = Steam::{$operator}($source->foreign_amount); // @phpstan-ignore-line
|
||||
}
|
||||
if (null === $amount) {
|
||||
app('log')->debug('No match on currency, so amount remains null, return "0".');
|
||||
Log::debug('No match on currency, so amount remains null, return "0".');
|
||||
|
||||
return '0';
|
||||
}
|
||||
|
||||
app('log')->debug(sprintf('The currency is %s and the amount is %s', $currency->code, $amount));
|
||||
Log::debug(sprintf('The currency is %s and the amount is %s', $currency->code, $amount));
|
||||
$currentAmount = $this->getCurrentAmount($piggyBank);
|
||||
$room = bcsub($piggyBank->target_amount, $currentAmount);
|
||||
$compare = bcmul($currentAmount, '-1');
|
||||
|
||||
if (0 === bccomp($piggyBank->target_amount, '0')) {
|
||||
// amount is zero? then the "room" is positive amount of we wish to add or remove.
|
||||
$room = app('steam')->positive($amount);
|
||||
app('log')->debug(sprintf('Room is now %s', $room));
|
||||
$room = Steam::positive($amount);
|
||||
Log::debug(sprintf('Room is now %s', $room));
|
||||
}
|
||||
|
||||
app('log')->debug(sprintf('Will add/remove %f to piggy bank #%d ("%s")', $amount, $piggyBank->id, $piggyBank->name));
|
||||
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') && -1 === bccomp((string) $room, $amount)) {
|
||||
if (1 === bccomp($amount, '0') && -1 === bccomp( $room, $amount)) {
|
||||
// amount is positive and $room is smaller than $amount
|
||||
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));
|
||||
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));
|
||||
|
||||
return $room;
|
||||
}
|
||||
|
||||
// amount is negative and $currentAmount is smaller than $amount
|
||||
if (-1 === bccomp($amount, '0') && 1 === bccomp($compare, $amount)) {
|
||||
app('log')->debug(sprintf('Max amount to remove is %f', $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));
|
||||
Log::debug(sprintf('Max amount to remove is %f', $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));
|
||||
|
||||
return $compare;
|
||||
}
|
||||
|
||||
return (string) $amount;
|
||||
return $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -31,6 +31,7 @@ use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Location;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupInterface;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -268,12 +269,12 @@ class TagRepository implements TagRepositoryInterface, UserGroupInterface
|
||||
];
|
||||
|
||||
// add amount to correct type:
|
||||
$amount = app('steam')->positive((string) $journal['amount']);
|
||||
$amount = Steam::positive((string) $journal['amount']);
|
||||
$type = $journal['transaction_type_type'];
|
||||
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
|
||||
$amount = bcmul((string) $amount, '-1');
|
||||
$amount = bcmul( $amount, '-1');
|
||||
}
|
||||
$sums[$currencyId][$type] = bcadd((string) $sums[$currencyId][$type], (string) $amount);
|
||||
$sums[$currencyId][$type] = bcadd((string) $sums[$currencyId][$type], $amount);
|
||||
|
||||
$foreignCurrencyId = $journal['foreign_currency_id'];
|
||||
if (null !== $foreignCurrencyId && 0 !== $foreignCurrencyId) {
|
||||
@@ -289,11 +290,11 @@ class TagRepository implements TagRepositoryInterface, UserGroupInterface
|
||||
TransactionTypeEnum::OPENING_BALANCE->value => '0',
|
||||
];
|
||||
// add foreign amount to correct type:
|
||||
$amount = app('steam')->positive((string) $journal['foreign_amount']);
|
||||
$amount = Steam::positive((string) $journal['foreign_amount']);
|
||||
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
|
||||
$amount = bcmul((string) $amount, '-1');
|
||||
$amount = bcmul( $amount, '-1');
|
||||
}
|
||||
$sums[$foreignCurrencyId][$type] = bcadd((string) $sums[$foreignCurrencyId][$type], (string) $amount);
|
||||
$sums[$foreignCurrencyId][$type] = bcadd((string) $sums[$foreignCurrencyId][$type], $amount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Repositories\TransactionGroup;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\DuplicateTransactionException;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -42,14 +43,13 @@ use FireflyIII\Models\TransactionJournalLink;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Destroy\TransactionGroupDestroyService;
|
||||
use FireflyIII\Services\Internal\Update\GroupUpdateService;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\NullArrayObject;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupInterface;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Exception;
|
||||
|
||||
use function Safe\json_decode;
|
||||
|
||||
/**
|
||||
@@ -143,22 +143,21 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
||||
{
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($this->user);
|
||||
$journals = $group->transactionJournals->pluck('id')->toArray();
|
||||
$set = Attachment::whereIn('attachable_id', $journals)
|
||||
->where('attachable_type', TransactionJournal::class)
|
||||
->where('uploaded', true)
|
||||
->whereNull('deleted_at')->get()
|
||||
;
|
||||
$journals = $group->transactionJournals->pluck('id')->toArray();
|
||||
$set = Attachment::whereIn('attachable_id', $journals)
|
||||
->where('attachable_type', TransactionJournal::class)
|
||||
->where('uploaded', true)
|
||||
->whereNull('deleted_at')->get();
|
||||
|
||||
$result = [];
|
||||
$result = [];
|
||||
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($set as $attachment) {
|
||||
$journalId = $attachment->attachable_id;
|
||||
$result[$journalId] ??= [];
|
||||
$current = $attachment->toArray();
|
||||
$current['file_exists'] = true;
|
||||
$current['notes'] = $repository->getNoteText($attachment);
|
||||
$journalId = $attachment->attachable_id;
|
||||
$result[$journalId] ??= [];
|
||||
$current = $attachment->toArray();
|
||||
$current['file_exists'] = true;
|
||||
$current['notes'] = $repository->getNoteText($attachment);
|
||||
// already determined that this attachable is a TransactionJournal.
|
||||
$current['journal_title'] = $attachment->attachable->description;
|
||||
$result[$journalId][] = $current;
|
||||
@@ -174,9 +173,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
||||
{
|
||||
/** @var null|Note $note */
|
||||
$note = Note::where('noteable_id', $journalId)
|
||||
->where('noteable_type', TransactionJournal::class)
|
||||
->first()
|
||||
;
|
||||
->where('noteable_type', TransactionJournal::class)
|
||||
->first();
|
||||
if (null === $note) {
|
||||
return null;
|
||||
}
|
||||
@@ -197,14 +195,13 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
||||
$q->orWhereIn('destination_id', $journals);
|
||||
}
|
||||
)
|
||||
->with(['source', 'destination', 'source.transactions'])
|
||||
->leftJoin('link_types', 'link_types.id', '=', 'journal_links.link_type_id')
|
||||
->get(['journal_links.*', 'link_types.inward', 'link_types.outward', 'link_types.editable'])
|
||||
;
|
||||
->with(['source', 'destination', 'source.transactions'])
|
||||
->leftJoin('link_types', 'link_types.id', '=', 'journal_links.link_type_id')
|
||||
->get(['journal_links.*', 'link_types.inward', 'link_types.outward', 'link_types.editable']);
|
||||
|
||||
/** @var TransactionJournalLink $entry */
|
||||
foreach ($set as $entry) {
|
||||
$journalId = in_array($entry->source_id, $journals, true) ? $entry->source_id : $entry->destination_id;
|
||||
$journalId = in_array($entry->source_id, $journals, true) ? $entry->source_id : $entry->destination_id;
|
||||
$return[$journalId] ??= [];
|
||||
|
||||
// phpstan: the editable field is provided by the query.
|
||||
@@ -248,13 +245,9 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
||||
$type = $journal->transactionType->type;
|
||||
$amount = app('steam')->positive($transaction->amount);
|
||||
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
|
||||
return app('amount')->formatAnything($currency, app('steam')->negative($amount));
|
||||
return Amount::formatAnything($currency, app('steam')->negative($amount));
|
||||
}
|
||||
if (TransactionTypeEnum::WITHDRAWAL->value !== $type) {
|
||||
return app('amount')->formatAnything($currency, $amount);
|
||||
}
|
||||
|
||||
return '';
|
||||
return Amount::formatAnything($currency, $amount);
|
||||
}
|
||||
|
||||
private function getFormattedForeignAmount(TransactionJournal $journal): string
|
||||
@@ -264,20 +257,18 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
||||
if (null === $transaction->foreign_amount || '' === $transaction->foreign_amount) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (0 === bccomp('0', (string)$transaction->foreign_amount)) {
|
||||
return '';
|
||||
}
|
||||
$currency = $transaction->foreignCurrency;
|
||||
$type = $journal->transactionType->type;
|
||||
$amount = app('steam')->positive($transaction->foreign_amount);
|
||||
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
|
||||
return app('amount')->formatAnything($currency, app('steam')->negative($amount));
|
||||
}
|
||||
if (TransactionTypeEnum::WITHDRAWAL->value !== $type) {
|
||||
return app('amount')->formatAnything($currency, $amount);
|
||||
}
|
||||
|
||||
return '';
|
||||
$currency = $transaction->foreignCurrency;
|
||||
$type = $journal->transactionType->type;
|
||||
$amount = app('steam')->positive($transaction->foreign_amount);
|
||||
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
|
||||
return Amount::formatAnything($currency, app('steam')->negative($amount));
|
||||
}
|
||||
return Amount::formatAnything($currency, $amount);
|
||||
}
|
||||
|
||||
public function getLocation(int $journalId): ?Location
|
||||
@@ -297,11 +288,10 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
||||
public function getMetaDateFields(int $journalId, array $fields): NullArrayObject
|
||||
{
|
||||
$query = DB::table('journal_meta')
|
||||
->where('transaction_journal_id', $journalId)
|
||||
->whereIn('name', $fields)
|
||||
->whereNull('deleted_at')
|
||||
->get(['name', 'data'])
|
||||
;
|
||||
->where('transaction_journal_id', $journalId)
|
||||
->whereIn('name', $fields)
|
||||
->whereNull('deleted_at')
|
||||
->get(['name', 'data']);
|
||||
$return = [];
|
||||
|
||||
foreach ($query as $row) {
|
||||
@@ -317,11 +307,10 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
||||
public function getMetaFields(int $journalId, array $fields): NullArrayObject
|
||||
{
|
||||
$query = DB::table('journal_meta')
|
||||
->where('transaction_journal_id', $journalId)
|
||||
->whereIn('name', $fields)
|
||||
->whereNull('deleted_at')
|
||||
->get(['name', 'data'])
|
||||
;
|
||||
->where('transaction_journal_id', $journalId)
|
||||
->whereIn('name', $fields)
|
||||
->whereNull('deleted_at')
|
||||
->get(['name', 'data']);
|
||||
$return = [];
|
||||
|
||||
foreach ($query as $row) {
|
||||
@@ -340,11 +329,10 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
||||
{
|
||||
$return = [];
|
||||
$journals = $group->transactionJournals->pluck('id')->toArray();
|
||||
$currency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$currency = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$data = PiggyBankEvent::whereIn('transaction_journal_id', $journals)
|
||||
->with('piggyBank', 'piggyBank.account')
|
||||
->get(['piggy_bank_events.*'])
|
||||
;
|
||||
->with('piggyBank', 'piggyBank.account')
|
||||
->get(['piggy_bank_events.*']);
|
||||
|
||||
/** @var PiggyBankEvent $row */
|
||||
foreach ($data as $row) {
|
||||
@@ -352,20 +340,19 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
||||
continue;
|
||||
}
|
||||
// get currency preference.
|
||||
$currencyPreference = AccountMeta::where('account_id', $row->piggyBank->account_id)
|
||||
->where('name', 'currency_id')
|
||||
->first()
|
||||
;
|
||||
$currencyPreference = AccountMeta::where('account_id', $row->piggyBank->account_id)
|
||||
->where('name', 'currency_id')
|
||||
->first();
|
||||
if (null !== $currencyPreference) {
|
||||
$currency = TransactionCurrency::where('id', $currencyPreference->data)->first();
|
||||
}
|
||||
$journalId = $row->transaction_journal_id;
|
||||
$journalId = $row->transaction_journal_id;
|
||||
$return[$journalId] ??= [];
|
||||
|
||||
$return[$journalId][] = [
|
||||
'piggy' => $row->piggyBank->name,
|
||||
'piggy_id' => $row->piggy_bank_id,
|
||||
'amount' => app('amount')->formatAnything($currency, $row->amount),
|
||||
'amount' => Amount::formatAnything($currency, $row->amount),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -386,11 +373,10 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
||||
public function getTags(int $journalId): array
|
||||
{
|
||||
$result = DB::table('tag_transaction_journal')
|
||||
->leftJoin('tags', 'tag_transaction_journal.tag_id', '=', 'tags.id')
|
||||
->where('tag_transaction_journal.transaction_journal_id', $journalId)
|
||||
->orderBy('tags.tag', 'ASC')
|
||||
->get(['tags.tag'])
|
||||
;
|
||||
->leftJoin('tags', 'tag_transaction_journal.tag_id', '=', 'tags.id')
|
||||
->where('tag_transaction_journal.transaction_journal_id', $journalId)
|
||||
->orderBy('tags.tag', 'ASC')
|
||||
->get(['tags.tag']);
|
||||
|
||||
return $result->pluck('tag')->toArray();
|
||||
}
|
||||
@@ -445,7 +431,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
if (-1 === bccomp('0', (string)$transaction->amount)) {
|
||||
$sum = bcadd($sum, (string) $transaction->amount);
|
||||
$sum = bcadd($sum, (string)$transaction->amount);
|
||||
$names = sprintf('%s%s', $names, $transaction->account->name);
|
||||
}
|
||||
}
|
||||
|
@@ -169,6 +169,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
{
|
||||
$account = $this->user->accounts()->find($accountId);
|
||||
if (null === $account) {
|
||||
/** @var null|Account */
|
||||
return $this->userGroup->accounts()->find($accountId);
|
||||
}
|
||||
|
||||
@@ -242,11 +243,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
#[Override]
|
||||
public function getLastActivity(Collection $accounts): array
|
||||
{
|
||||
return Transaction::whereIn('account_id', $accounts->pluck('id')->toArray())
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')
|
||||
->groupBy('transactions.account_id')
|
||||
->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) as date_max')])->toArray() // @phpstan-ignore-line
|
||||
;
|
||||
return Transaction::whereIn('account_id', $accounts->pluck('id')->toArray())->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')->groupBy('transactions.account_id')->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) as date_max')])->toArray();
|
||||
}
|
||||
|
||||
#[Override]
|
||||
|
@@ -96,7 +96,7 @@ class IsValidBulkClause implements ValidationRule
|
||||
'value' => $this->rules[$clause][$arrayKey],
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
$this->error = sprintf('%s: %s: %s', $clause, $arrayKey, implode(', ', $validator->errors()->get('value')));
|
||||
$this->error = sprintf('%s: %s: %s', $clause, $arrayKey, implode(', ', $validator->errors()->get('value'))); // @phpstan-ignore-line
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -108,10 +108,7 @@ class AccountDestroyService
|
||||
app('log')->debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id));
|
||||
DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);
|
||||
|
||||
$collection = Transaction::groupBy('transaction_journal_id', 'account_id')
|
||||
->where('account_id', $moveTo->id)
|
||||
->get(['transaction_journal_id', 'account_id', DB::raw('count(*) as the_count')]) // @phpstan-ignore-line
|
||||
;
|
||||
$collection = Transaction::groupBy('transaction_journal_id', 'account_id')->where('account_id', $moveTo->id)->get(['transaction_journal_id', 'account_id', DB::raw('count(*) as the_count')]);
|
||||
if (0 === $collection->count()) {
|
||||
return;
|
||||
}
|
||||
|
@@ -277,66 +277,66 @@ class CreditRecalculateService
|
||||
if ($isSameAccount && $isCredit && $this->isWithdrawalIn($usedAmount, $type)) { // case 1
|
||||
$usedAmount = app('steam')->positive($usedAmount);
|
||||
|
||||
return bcadd($leftOfDebt, (string) $usedAmount);
|
||||
return bcadd($leftOfDebt, $usedAmount);
|
||||
// Log::debug(sprintf('Case 1 (withdrawal into credit liability): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2)));
|
||||
}
|
||||
|
||||
if ($isSameAccount && $isCredit && $this->isWithdrawalOut($usedAmount, $type)) { // case 2
|
||||
$usedAmount = app('steam')->positive($usedAmount);
|
||||
|
||||
return bcsub($leftOfDebt, (string) $usedAmount);
|
||||
return bcsub($leftOfDebt, $usedAmount);
|
||||
// Log::debug(sprintf('Case 2 (withdrawal away from liability): %s - %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2)));
|
||||
}
|
||||
|
||||
if ($isSameAccount && $isCredit && $this->isDepositOut($usedAmount, $type)) { // case 3
|
||||
$usedAmount = app('steam')->positive($usedAmount);
|
||||
|
||||
return bcsub($leftOfDebt, (string) $usedAmount);
|
||||
return bcsub($leftOfDebt, $usedAmount);
|
||||
// Log::debug(sprintf('Case 3 (deposit away from liability): %s - %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2)));
|
||||
}
|
||||
|
||||
if ($isSameAccount && $isCredit && $this->isDepositIn($usedAmount, $type)) { // case 4
|
||||
$usedAmount = app('steam')->positive($usedAmount);
|
||||
|
||||
return bcadd($leftOfDebt, (string) $usedAmount);
|
||||
return bcadd($leftOfDebt, $usedAmount);
|
||||
// Log::debug(sprintf('Case 4 (deposit into credit liability): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2)));
|
||||
}
|
||||
if ($isSameAccount && $isCredit && $this->isTransferIn($usedAmount, $type)) { // case 5
|
||||
$usedAmount = app('steam')->positive($usedAmount);
|
||||
|
||||
return bcadd($leftOfDebt, (string) $usedAmount);
|
||||
return bcadd($leftOfDebt, $usedAmount);
|
||||
// Log::debug(sprintf('Case 5 (transfer into credit liability): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2)));
|
||||
}
|
||||
if ($isSameAccount && $isDebit && $this->isWithdrawalIn($usedAmount, $type)) { // case 6
|
||||
$usedAmount = app('steam')->positive($usedAmount);
|
||||
|
||||
return bcsub($leftOfDebt, (string) $usedAmount);
|
||||
return bcsub($leftOfDebt, $usedAmount);
|
||||
// Log::debug(sprintf('Case 6 (withdrawal into debit liability): %s - %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2)));
|
||||
}
|
||||
if ($isSameAccount && $isDebit && $this->isDepositOut($usedAmount, $type)) { // case 7
|
||||
$usedAmount = app('steam')->positive($usedAmount);
|
||||
|
||||
return bcadd($leftOfDebt, (string) $usedAmount);
|
||||
return bcadd($leftOfDebt, $usedAmount);
|
||||
// Log::debug(sprintf('Case 7 (deposit away from liability): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2)));
|
||||
}
|
||||
if ($isSameAccount && $isDebit && $this->isWithdrawalOut($usedAmount, $type)) { // case 8
|
||||
$usedAmount = app('steam')->positive($usedAmount);
|
||||
|
||||
return bcadd($leftOfDebt, (string) $usedAmount);
|
||||
return bcadd($leftOfDebt, $usedAmount);
|
||||
// Log::debug(sprintf('Case 8 (withdrawal away from liability): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2)));
|
||||
}
|
||||
|
||||
if ($isSameAccount && $isDebit && $this->isTransferIn($usedAmount, $type)) { // case 9
|
||||
$usedAmount = app('steam')->positive($usedAmount);
|
||||
|
||||
return bcsub($leftOfDebt, (string) $usedAmount);
|
||||
return bcsub($leftOfDebt, $usedAmount);
|
||||
// 2024-10-05, #9225 this used to say you would owe more, but a transfer INTO a debit from wherever means you owe LESS.
|
||||
// Log::debug(sprintf('Case 9 (transfer into debit liability, means you owe LESS): %s - %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2)));
|
||||
}
|
||||
if ($isSameAccount && $isDebit && $this->isTransferOut($usedAmount, $type)) { // case 10
|
||||
$usedAmount = app('steam')->positive($usedAmount);
|
||||
|
||||
return bcadd($leftOfDebt, (string) $usedAmount);
|
||||
return bcadd($leftOfDebt, $usedAmount);
|
||||
// 2024-10-05, #9225 this used to say you would owe less, but a transfer OUT OF a debit from wherever means you owe MORE.
|
||||
// Log::debug(sprintf('Case 10 (transfer out of debit liability, means you owe MORE): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2)));
|
||||
}
|
||||
@@ -345,7 +345,7 @@ class CreditRecalculateService
|
||||
if (in_array($type, [TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::DEPOSIT->value, TransactionTypeEnum::TRANSFER->value], true)) {
|
||||
$usedAmount = app('steam')->negative($usedAmount);
|
||||
|
||||
return bcadd($leftOfDebt, (string) $usedAmount);
|
||||
return bcadd($leftOfDebt, $usedAmount);
|
||||
// Log::debug(sprintf('Case X (all other cases): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2)));
|
||||
}
|
||||
|
||||
|
@@ -780,10 +780,10 @@ class JournalUpdateService
|
||||
|
||||
private function isBetweenAssetAndLiability(): bool
|
||||
{
|
||||
/** @var Transaction $sourceTransaction */
|
||||
/** @var Transaction|null $sourceTransaction */
|
||||
$sourceTransaction = $this->transactionJournal->transactions()->where('amount', '<', 0)->first();
|
||||
|
||||
/** @var Transaction $destinationTransaction */
|
||||
/** @var Transaction|null $destinationTransaction */
|
||||
$destinationTransaction = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();
|
||||
if (null === $sourceTransaction || null === $destinationTransaction) {
|
||||
Log::warning('Either transaction is false, stop.');
|
||||
|
@@ -33,6 +33,7 @@ use FireflyIII\Support\Singleton\PreferencesSingleton;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use NumberFormatter;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
|
||||
/**
|
||||
* Class Amount.
|
||||
@@ -58,8 +59,8 @@ class Amount
|
||||
*/
|
||||
public function formatFlat(string $symbol, int $decimalPlaces, string $amount, ?bool $coloured = null): string
|
||||
{
|
||||
$locale = app('steam')->getLocale();
|
||||
$rounded = app('steam')->bcround($amount, $decimalPlaces);
|
||||
$locale = Steam::getLocale();
|
||||
$rounded = Steam::bcround($amount, $decimalPlaces);
|
||||
$coloured ??= true;
|
||||
|
||||
$fmt = new NumberFormatter($locale, NumberFormatter::CURRENCY);
|
||||
@@ -69,10 +70,10 @@ class Amount
|
||||
$result = (string)$fmt->format((float)$rounded); // intentional float
|
||||
|
||||
if (true === $coloured) {
|
||||
if (1 === bccomp((string)$rounded, '0')) {
|
||||
if (1 === bccomp($rounded, '0')) {
|
||||
return sprintf('<span class="text-success money-positive">%s</span>', $result);
|
||||
}
|
||||
if (-1 === bccomp((string)$rounded, '0')) {
|
||||
if (-1 === bccomp($rounded, '0')) {
|
||||
return sprintf('<span class="text-danger money-negative">%s</span>', $result);
|
||||
}
|
||||
|
||||
@@ -242,8 +243,8 @@ class Amount
|
||||
private function getLocaleInfo(): array
|
||||
{
|
||||
// get config from preference, not from translation:
|
||||
$locale = app('steam')->getLocale();
|
||||
$array = app('steam')->getLocaleArray($locale);
|
||||
$locale = Steam::getLocale();
|
||||
$array = Steam::getLocaleArray($locale);
|
||||
|
||||
setlocale(LC_MONETARY, $array);
|
||||
$info = localeconv();
|
||||
|
@@ -85,7 +85,7 @@ class ExportDataGenerator
|
||||
private bool $exportTransactions;
|
||||
private Carbon $start;
|
||||
private User $user;
|
||||
private UserGroup $userGroup;
|
||||
private UserGroup $userGroup; // @phpstan-ignore-line
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user