diff --git a/app/Export/Collector/AttachmentCollector.php b/app/Export/Collector/AttachmentCollector.php index 785adfbd51..c4c52cbf29 100644 --- a/app/Export/Collector/AttachmentCollector.php +++ b/app/Export/Collector/AttachmentCollector.php @@ -52,7 +52,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface */ public function __construct() { - // @var AttachmentRepositoryInterface repository + /** @var AttachmentRepositoryInterface repository */ $this->repository = app(AttachmentRepositoryInterface::class); // make storage: $this->uploadDisk = Storage::disk('upload'); diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.php index d46c872d58..9bdf1b28be 100644 --- a/app/Generator/Report/Audit/MonthReportGenerator.php +++ b/app/Generator/Report/Audit/MonthReportGenerator.php @@ -26,6 +26,7 @@ use Carbon\Carbon; use FireflyIII\Generator\Report\ReportGeneratorInterface; use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Models\Account; +use FireflyIII\Models\Transaction; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use Illuminate\Support\Collection; use Steam; @@ -173,7 +174,7 @@ class MonthReportGenerator implements ReportGeneratorInterface $startBalance = $dayBeforeBalance; $currency = $currencyRepos->find(intval($account->getMeta('currency_id'))); - // @var Transaction $journal + /** @var Transaction $transaction */ foreach ($journals as $transaction) { $transaction->before = $startBalance; $transactionAmount = $transaction->transaction_amount; diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.php index de3f0f57dc..7491bd34a2 100644 --- a/app/Http/Controllers/Report/CategoryController.php +++ b/app/Http/Controllers/Report/CategoryController.php @@ -129,12 +129,12 @@ class CategoryController extends Controller $report = []; /** @var Category $category */ foreach ($categories as $category) { - $spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $end); - if (0 !== bccomp($spent, '0')) { - $report[$category->id] = ['name' => $category->name, 'spent' => $spent, 'id' => $category->id]; + $spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $end); + $earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $start, $end); + if (0 !== bccomp($spent, '0') || 0 !== bccomp($earned, '0')) { + $report[$category->id] = ['name' => $category->name, 'spent' => $spent, 'earned' => $earned, 'id' => $category->id]; } } - // sort the result // Obtain a list of columns $sum = []; diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index 51904e9f9d..2140c33b8b 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -158,7 +158,7 @@ class PiggyBank extends Model public function leftOnAccount(Carbon $date): string { $balance = Steam::balanceIgnoreVirtual($this->account, $date); - // @var PiggyBank $p + /** @var PiggyBank $piggyBank */ foreach ($this->account->piggyBanks as $piggyBank) { $currentAmount = $piggyBank->currentRelevantRep()->currentamount ?? '0'; diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index 9d18a137cb..901d43221c 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -126,7 +126,7 @@ class TagRepository implements TagRepositoryInterface public function findByTag(string $tag): Tag { $tags = $this->user->tags()->get(); - // @var Tag $tag + /** @var Tag $databaseTag */ foreach ($tags as $databaseTag) { if ($databaseTag->tag === $tag) { return $databaseTag; diff --git a/resources/views/reports/partials/categories.twig b/resources/views/reports/partials/categories.twig index c59ad3d3cd..f5d0385606 100644 --- a/resources/views/reports/partials/categories.twig +++ b/resources/views/reports/partials/categories.twig @@ -2,14 +2,17 @@ {{ 'category'|_ }} + {{ 'earned'|_ }} {{ 'spent'|_ }}   - {% set sum = 0 %} + {% set sumSpent = 0 %} + {% set sumEarned = 0 %} {% for index, category in report %} - {% set sum = sum + category.spent %} + {% set sumSpent = sumSpent + category.spent %} + {% set sumEarned = sumEarned + category.earned %} {% if loop.index > listLength %} {% else %} @@ -18,6 +21,7 @@ {{ category.name }} + {{ 0|formatAmount }} {{ category.spent|formatAmount }} {{ 'sum'|_ }} - {{ sum|formatAmount }} + {{ sumEarned|formatAmount }} + {{ sumSpent|formatAmount }}