mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix summary and dates, also fix #5770
This commit is contained in:
parent
f2849c8058
commit
abb1095cef
@ -150,7 +150,9 @@ class BasicController extends Controller
|
||||
foreach ($set as $transactionJournal) {
|
||||
$currencyId = (int)$transactionJournal['currency_id'];
|
||||
$incomes[$currencyId] = $incomes[$currencyId] ?? '0';
|
||||
$incomes[$currencyId] = bcadd($incomes[$currencyId], bcmul($transactionJournal['amount'], '-1'));
|
||||
$incomes[$currencyId] = bcadd($incomes[$currencyId],
|
||||
bcmul($transactionJournal['amount'], '-1')
|
||||
);
|
||||
$sums[$currencyId] = $sums[$currencyId] ?? '0';
|
||||
$sums[$currencyId] = bcadd($sums[$currencyId], bcmul($transactionJournal['amount'], '-1'));
|
||||
}
|
||||
|
@ -50,14 +50,9 @@ class AccountController extends Controller
|
||||
{
|
||||
use DateCalculation, AugumentData, ChartGeneration;
|
||||
|
||||
/** @var GeneratorInterface Chart generation methods. */
|
||||
protected $generator;
|
||||
|
||||
/** @var AccountRepositoryInterface Account repository. */
|
||||
private $accountRepository;
|
||||
|
||||
/** @var CurrencyRepositoryInterface */
|
||||
private $currencyRepository;
|
||||
protected GeneratorInterface $generator;
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
private CurrencyRepositoryInterface $currencyRepository;
|
||||
|
||||
/**
|
||||
* AccountController constructor.
|
||||
@ -440,7 +435,7 @@ class AccountController extends Controller
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($account->id);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
//return response()->json($cache->get());
|
||||
}
|
||||
$currencies = $this->accountRepository->getUsedCurrencies($account);
|
||||
|
||||
@ -487,7 +482,7 @@ class AccountController extends Controller
|
||||
break;
|
||||
case '1D':
|
||||
// per day the entire period, balance for every day.
|
||||
$format = (string)trans('config.month_and_day', [], $locale);
|
||||
$format = (string) trans('config.month_and_day_js', [], $locale);
|
||||
$range = app('steam')->balanceInRange($account, $start, $end, $currency);
|
||||
$previous = array_values($range)[0];
|
||||
while ($end >= $current) {
|
||||
|
@ -93,7 +93,7 @@ abstract class Controller extends BaseController
|
||||
$locale = app('steam')->getLocale();
|
||||
// translations for specific strings:
|
||||
$this->monthFormat = (string)trans('config.month_js', [], $locale);
|
||||
$this->monthAndDayFormat = (string)trans('config.month_and_day_moment_js', [], $locale);
|
||||
$this->monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);
|
||||
$this->dateTimeFormat = (string)trans('config.date_time_js', [], $locale);
|
||||
|
||||
// get shown-intro-preference:
|
||||
|
@ -74,7 +74,7 @@ class BoxController extends Controller
|
||||
$cache->addProperty($today);
|
||||
$cache->addProperty('box-available');
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
//return response()->json($cache->get());
|
||||
}
|
||||
$leftPerDayAmount = '0';
|
||||
$leftToSpendAmount = '0';
|
||||
|
@ -25,9 +25,11 @@ namespace FireflyIII\Repositories\Budget;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
@ -279,13 +281,35 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
* @return array
|
||||
*/
|
||||
public function sumExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $budgets = null, ?TransactionCurrency $currency = null
|
||||
): array {
|
||||
): array
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
$start->startOfDay();
|
||||
$end->endOfDay();
|
||||
|
||||
// this collector excludes all transfers TO
|
||||
// liabilities (which are also withdrawals)
|
||||
// because those expenses only become expenses
|
||||
// once they move from the liability to the friend.
|
||||
// TODO this filter must be somewhere in AccountRepositoryInterface because I suspect its needed more often (A113)
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$repository->setUser($this->user);
|
||||
$accounts = $repository->getAccountsByType(config('firefly.valid_liabilities'));
|
||||
$selection = new Collection;
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
if ('credit' === $repository->getMetaValue($account, 'liability_direction')) {
|
||||
$selection->push($account);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL]);
|
||||
$collector->setUser($this->user)
|
||||
->setRange($start, $end)
|
||||
->excludeDestinationAccounts($selection)
|
||||
->setTypes([TransactionType::WITHDRAWAL]);
|
||||
|
||||
if (null !== $accounts) {
|
||||
$collector->setAccounts($accounts);
|
||||
|
@ -229,6 +229,6 @@ class FrontpageChartGenerator
|
||||
$this->opsRepository->setUser($user);
|
||||
|
||||
$locale = app('steam')->getLocale();
|
||||
$this->monthAndDayFormat = (string)trans('config.month_and_day', [], $locale);
|
||||
$this->monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ trait PeriodOverview
|
||||
$cache->addProperty('account-show-period-entries');
|
||||
$cache->addProperty($account->id);
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
// return $cache->get();
|
||||
}
|
||||
/** @var array $dates */
|
||||
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
||||
|
@ -340,17 +340,17 @@ class Navigation
|
||||
// define period to increment
|
||||
$increment = 'addDay';
|
||||
$format = $this->preferredCarbonFormat($start, $end);
|
||||
$displayFormat = (string)trans('config.month_and_day', [], $locale);
|
||||
$displayFormat = (string)trans('config.month_and_day_js', [], $locale);
|
||||
// increment by month (for year)
|
||||
if ($start->diffInMonths($end) > 1) {
|
||||
$increment = 'addMonth';
|
||||
$displayFormat = (string)trans('config.month');
|
||||
$displayFormat = (string)trans('config.month_js');
|
||||
}
|
||||
|
||||
// increment by year (for multi year)
|
||||
if ($start->diffInMonths($end) > 12) {
|
||||
$increment = 'addYear';
|
||||
$displayFormat = (string)trans('config.year');
|
||||
$displayFormat = (string)trans('config.year_js');
|
||||
}
|
||||
$begin = clone $start;
|
||||
$entries = [];
|
||||
@ -397,19 +397,19 @@ class Navigation
|
||||
{
|
||||
$date = clone $theDate;
|
||||
$formatMap = [
|
||||
'1D' => (string)trans('config.specific_day'),
|
||||
'daily' => (string)trans('config.specific_day'),
|
||||
'custom' => (string)trans('config.specific_day'),
|
||||
'1W' => (string)trans('config.week_in_year'),
|
||||
'week' => (string)trans('config.week_in_year'),
|
||||
'weekly' => (string)trans('config.week_in_year'),
|
||||
'1M' => (string)trans('config.month'),
|
||||
'month' => (string)trans('config.month'),
|
||||
'monthly' => (string)trans('config.month'),
|
||||
'1Y' => (string)trans('config.year'),
|
||||
'year' => (string)trans('config.year'),
|
||||
'yearly' => (string)trans('config.year'),
|
||||
'6M' => (string)trans('config.half_year'),
|
||||
'1D' => (string)trans('config.specific_day_js'),
|
||||
'daily' => (string)trans('config.specific_day_js'),
|
||||
'custom' => (string)trans('config.specific_day_js'),
|
||||
'1W' => (string)trans('config.week_in_year_js'),
|
||||
'week' => (string)trans('config.week_in_year_js'),
|
||||
'weekly' => (string)trans('config.week_in_year_js'),
|
||||
'1M' => (string)trans('config.month_js'),
|
||||
'month' => (string)trans('config.month_js'),
|
||||
'monthly' => (string)trans('config.month_js'),
|
||||
'1Y' => (string)trans('config.year_js'),
|
||||
'year' => (string)trans('config.year_js'),
|
||||
'yearly' => (string)trans('config.year_js'),
|
||||
'6M' => (string)trans('config.half_year_js'),
|
||||
];
|
||||
|
||||
if (array_key_exists($repeatFrequency, $formatMap)) {
|
||||
|
@ -114,8 +114,8 @@ try {
|
||||
if (null !== $start && null !== $end) {
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb',
|
||||
['start' => $start->formatLocalized((string)trans('config.month_and_day')),
|
||||
'end' => $end->formatLocalized((string)trans('config.month_and_day')),]
|
||||
['start' => $start->isoFormat((string)trans('config.month_and_day_js')),
|
||||
'end' => $end->isoFormat((string)trans('config.month_and_day_js')),]
|
||||
);
|
||||
$breadcrumbs->push($title, route('accounts.show', $account));
|
||||
}
|
||||
@ -443,8 +443,8 @@ try {
|
||||
if (null !== $start && null !== $end) {
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb',
|
||||
['start' => $start->formatLocalized((string)trans('config.month_and_day')),
|
||||
'end' => $end->formatLocalized((string)trans('config.month_and_day')),]
|
||||
['start' => $start->isoFormat((string)trans('config.month_and_day_js')),
|
||||
'end' => $end->isoFormat((string)trans('config.month_and_day_js')),]
|
||||
);
|
||||
$breadcrumbs->push($title, route('budgets.no-budget'));
|
||||
}
|
||||
@ -477,8 +477,8 @@ try {
|
||||
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb',
|
||||
['start' => $budgetLimit->start_date->formatLocalized((string)trans('config.month_and_day')),
|
||||
'end' => $budgetLimit->end_date->formatLocalized((string)trans('config.month_and_day')),]
|
||||
['start' => $budgetLimit->start_date->isoFormat((string)trans('config.month_and_day_js')),
|
||||
'end' => $budgetLimit->end_date->isoFormat((string)trans('config.month_and_day_js')),]
|
||||
);
|
||||
|
||||
$breadcrumbs->push(
|
||||
@ -527,8 +527,8 @@ try {
|
||||
if (null !== $start && null !== $end) {
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb',
|
||||
['start' => $start->formatLocalized((string)trans('config.month_and_day')),
|
||||
'end' => $end->formatLocalized((string)trans('config.month_and_day')),]
|
||||
['start' => $start->isoFormat((string)trans('config.month_and_day_js')),
|
||||
'end' => $end->isoFormat((string)trans('config.month_and_day_js')),]
|
||||
);
|
||||
$breadcrumbs->push($title, route('categories.show', [$category->id]));
|
||||
}
|
||||
@ -552,8 +552,8 @@ try {
|
||||
if (null !== $start && null !== $end) {
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb',
|
||||
['start' => $start->formatLocalized((string)trans('config.month_and_day')),
|
||||
'end' => $end->formatLocalized((string)trans('config.month_and_day')),]
|
||||
['start' => $start->isoFormat((string)trans('config.month_and_day_js')),
|
||||
'end' => $end->isoFormat((string)trans('config.month_and_day_js')),]
|
||||
);
|
||||
$breadcrumbs->push($title, route('categories.no-category'));
|
||||
}
|
||||
@ -747,9 +747,9 @@ try {
|
||||
static function (Generator $breadcrumbs, string $accountIds, Carbon $start, Carbon $end) {
|
||||
$breadcrumbs->parent('reports.index');
|
||||
|
||||
$monthFormat = (string)trans('config.month_and_day');
|
||||
$startString = $start->formatLocalized($monthFormat);
|
||||
$endString = $end->formatLocalized($monthFormat);
|
||||
$monthFormat = (string)trans('config.month_and_day_js');
|
||||
$startString = $start->isoFormat($monthFormat);
|
||||
$endString = $end->isoFormat($monthFormat);
|
||||
$title = (string)trans('firefly.report_audit', ['start' => $startString, 'end' => $endString]);
|
||||
|
||||
$breadcrumbs->push($title, route('reports.report.audit', [$accountIds, $start->format('Ymd'), $end->format('Ymd')]));
|
||||
@ -760,9 +760,9 @@ try {
|
||||
static function (Generator $breadcrumbs, string $accountIds, string $budgetIds, Carbon $start, Carbon $end) {
|
||||
$breadcrumbs->parent('reports.index');
|
||||
|
||||
$monthFormat = (string)trans('config.month_and_day');
|
||||
$startString = $start->formatLocalized($monthFormat);
|
||||
$endString = $end->formatLocalized($monthFormat);
|
||||
$monthFormat = (string)trans('config.month_and_day_js');
|
||||
$startString = $start->isoFormat($monthFormat);
|
||||
$endString = $end->isoFormat($monthFormat);
|
||||
$title = (string)trans('firefly.report_budget', ['start' => $startString, 'end' => $endString]);
|
||||
|
||||
$breadcrumbs->push($title, route('reports.report.budget', [$accountIds, $budgetIds, $start->format('Ymd'), $end->format('Ymd')]));
|
||||
@ -774,9 +774,9 @@ try {
|
||||
static function (Generator $breadcrumbs, string $accountIds, string $tagTags, Carbon $start, Carbon $end) {
|
||||
$breadcrumbs->parent('reports.index');
|
||||
|
||||
$monthFormat = (string)trans('config.month_and_day');
|
||||
$startString = $start->formatLocalized($monthFormat);
|
||||
$endString = $end->formatLocalized($monthFormat);
|
||||
$monthFormat = (string)trans('config.month_and_day_js');
|
||||
$startString = $start->isoFormat($monthFormat);
|
||||
$endString = $end->isoFormat($monthFormat);
|
||||
$title = (string)trans('firefly.report_tag', ['start' => $startString, 'end' => $endString]);
|
||||
|
||||
$breadcrumbs->push($title, route('reports.report.tag', [$accountIds, $tagTags, $start->format('Ymd'), $end->format('Ymd')]));
|
||||
@ -788,9 +788,9 @@ try {
|
||||
static function (Generator $breadcrumbs, string $accountIds, string $categoryIds, Carbon $start, Carbon $end) {
|
||||
$breadcrumbs->parent('reports.index');
|
||||
|
||||
$monthFormat = (string)trans('config.month_and_day');
|
||||
$startString = $start->formatLocalized($monthFormat);
|
||||
$endString = $end->formatLocalized($monthFormat);
|
||||
$monthFormat = (string)trans('config.month_and_day_js');
|
||||
$startString = $start->isoFormat($monthFormat);
|
||||
$endString = $end->isoFormat($monthFormat);
|
||||
$title = (string)trans('firefly.report_category', ['start' => $startString, 'end' => $endString]);
|
||||
|
||||
$breadcrumbs->push($title, route('reports.report.category', [$accountIds, $categoryIds, $start->format('Ymd'), $end->format('Ymd')]));
|
||||
@ -802,9 +802,9 @@ try {
|
||||
static function (Generator $breadcrumbs, string $accountIds, string $doubleIds, Carbon $start, Carbon $end) {
|
||||
$breadcrumbs->parent('reports.index');
|
||||
|
||||
$monthFormat = (string)trans('config.month_and_day');
|
||||
$startString = $start->formatLocalized($monthFormat);
|
||||
$endString = $end->formatLocalized($monthFormat);
|
||||
$monthFormat = (string)trans('config.month_and_day_js');
|
||||
$startString = $start->isoFormat($monthFormat);
|
||||
$endString = $end->isoFormat($monthFormat);
|
||||
$title = (string)trans('firefly.report_double', ['start' => $startString, 'end' => $endString]);
|
||||
|
||||
$breadcrumbs->push($title, route('reports.report.double', [$accountIds, $doubleIds, $start->format('Ymd'), $end->format('Ymd')]));
|
||||
@ -816,9 +816,9 @@ try {
|
||||
static function (Generator $breadcrumbs, string $accountIds, Carbon $start, Carbon $end) {
|
||||
$breadcrumbs->parent('reports.index');
|
||||
|
||||
$monthFormat = (string)trans('config.month_and_day');
|
||||
$startString = $start->formatLocalized($monthFormat);
|
||||
$endString = $end->formatLocalized($monthFormat);
|
||||
$monthFormat = (string)trans('config.month_and_day_js');
|
||||
$startString = $start->isoFormat($monthFormat);
|
||||
$endString = $end->isoFormat($monthFormat);
|
||||
$title = (string)trans('firefly.report_default', ['start' => $startString, 'end' => $endString]);
|
||||
|
||||
$breadcrumbs->push($title, route('reports.report.default', [$accountIds, $start->format('Ymd'), $end->format('Ymd')]));
|
||||
@ -1029,8 +1029,8 @@ try {
|
||||
if (null !== $start && null !== $end) {
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb',
|
||||
['start' => $start->formatLocalized((string)trans('config.month_and_day')),
|
||||
'end' => $end->formatLocalized((string)trans('config.month_and_day')),]
|
||||
['start' => $start->isoFormat((string)trans('config.month_and_day_js')),
|
||||
'end' => $end->isoFormat((string)trans('config.month_and_day_js')),]
|
||||
);
|
||||
$breadcrumbs->push($title, route('tags.show', [$tag->id, $start, $end]));
|
||||
}
|
||||
@ -1059,8 +1059,8 @@ try {
|
||||
// add date range:
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb',
|
||||
['start' => $start->formatLocalized((string)trans('config.month_and_day')),
|
||||
'end' => $end->formatLocalized((string)trans('config.month_and_day')),]
|
||||
['start' => $start->isoFormat((string)trans('config.month_and_day_js')),
|
||||
'end' => $end->isoFormat((string)trans('config.month_and_day_js')),]
|
||||
);
|
||||
$breadcrumbs->push($title, route('transactions.index', [$what, $start, $end]));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user