Fix mortgage payments showing as Uncategorized with zero actual amounts on Balance view #227

Merged
Copilot merged 1 commit from copilot/fix-mortgage-payments-categorization into main 2026-04-24 18:37:32 +00:00
Copilot commented 2026-04-24 10:28:03 +00:00 (Migrated from github.com)

On the monthly Balance view, actualized mortgage payments landed in "Uncategorized" and always showed a zero actual amount — meaning paid periods looked identical to unpaid ones in both the doughnut chart and category list.

Root Cause

BalanceService::getDetailedMonthlyBalance() pushed mortgage interest and principal entries without category, actual_amount, is_virtual, or is_deferred:

// Before — missing fields cause two distinct frontend bugs
$expenseDetails->push((object) [
    'name' => 'Mortgage Interest',
    'amount' => $mortgageInterest,
    'is_mortgage' => true,
]);
  • Uncategorized: transaction.category?.name evaluated to undefined → fell back to 'Uncategorized'
  • Zero actual amount: parseFloat(undefined) returns NaN; NaN || 0 collapses to 0, so actual amounts never rendered

Fix

Added the four missing fields to both mortgage push objects. Since these entries are constructed exclusively from ActualizedMortgage records, actual_amount equals the recorded value and is_virtual/is_deferred are both false:

$expenseDetails->push((object) [
    'name' => 'Mortgage Interest',
    'amount' => $mortgageInterest,
    'expected_amount' => $mortgageInterest,
    'actual_amount' => $mortgageInterest,
    'is_virtual' => false,
    'is_deferred' => false,
    'is_mortgage' => true,
    'category' => (object) ['name' => 'Mortgage'],
]);

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (code change that neither fixes a bug nor adds a feature)
  • Performance improvement
  • Test coverage improvement

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this manually (if applicable)

Code Quality

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors

CI/CD Checks

  • All automated tests pass
  • Code formatting (Pint) passes
  • JavaScript/TypeScript linting passes
  • Build process completes successfully

Additional Notes

Extended the existing 'detailed monthly balance includes mortgage payments separately' test with 6 new assertions covering actual_amount, is_virtual, is_deferred, and category->name for both mortgage entries.

On the monthly Balance view, actualized mortgage payments landed in "Uncategorized" and always showed a zero actual amount — meaning paid periods looked identical to unpaid ones in both the doughnut chart and category list. ## Root Cause `BalanceService::getDetailedMonthlyBalance()` pushed mortgage interest and principal entries without `category`, `actual_amount`, `is_virtual`, or `is_deferred`: ```php // Before — missing fields cause two distinct frontend bugs $expenseDetails->push((object) [ 'name' => 'Mortgage Interest', 'amount' => $mortgageInterest, 'is_mortgage' => true, ]); ``` - **Uncategorized**: `transaction.category?.name` evaluated to `undefined` → fell back to `'Uncategorized'` - **Zero actual amount**: `parseFloat(undefined)` returns `NaN`; `NaN || 0` collapses to `0`, so actual amounts never rendered ## Fix Added the four missing fields to both mortgage push objects. Since these entries are constructed exclusively from `ActualizedMortgage` records, `actual_amount` equals the recorded value and `is_virtual`/`is_deferred` are both `false`: ```php $expenseDetails->push((object) [ 'name' => 'Mortgage Interest', 'amount' => $mortgageInterest, 'expected_amount' => $mortgageInterest, 'actual_amount' => $mortgageInterest, 'is_virtual' => false, 'is_deferred' => false, 'is_mortgage' => true, 'category' => (object) ['name' => 'Mortgage'], ]); ``` ## Type of Change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update - [ ] Refactoring (code change that neither fixes a bug nor adds a feature) - [ ] Performance improvement - [ ] Test coverage improvement ## Testing - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] I have tested this manually (if applicable) ## Code Quality - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [x] My changes generate no new warnings or errors ## CI/CD Checks - [ ] All automated tests pass - [x] Code formatting (Pint) passes - [ ] JavaScript/TypeScript linting passes - [ ] Build process completes successfully ## Additional Notes Extended the existing `'detailed monthly balance includes mortgage payments separately'` test with 6 new assertions covering `actual_amount`, `is_virtual`, `is_deferred`, and `category->name` for both mortgage entries.
coderabbitai[bot] commented 2026-04-24 10:28:17 +00:00 (Migrated from github.com)

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 67967073-5db0-4f35-a2b1-6e0d9c45a655

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands and usage tips.

<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- This is an auto-generated comment: skip review by coderabbit.ai --> > [!IMPORTANT] > ## Review skipped > > Bot user detected. > > To trigger a single review, invoke the `@coderabbitai review` command. > > <details> > <summary>⚙️ Run configuration</summary> > > **Configuration used**: defaults > > **Review profile**: CHILL > > **Plan**: Free > > **Run ID**: `67967073-5db0-4f35-a2b1-6e0d9c45a655` > > </details> > > You can disable this status message by setting the `reviews.review_status` to `false` in the CodeRabbit configuration file. > > Use the checkbox below for a quick retry: > - [ ] <!-- {"checkboxId": "e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review <!-- end of auto-generated comment: skip review by coderabbit.ai --> <!-- tips_start --> --- <sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub> <!-- tips_end -->
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2026-04-24 18:43:21 +00:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes monthly Balance view mortgage entries rendering as “Uncategorized” with 0 actual amounts by ensuring mortgage expense detail objects include the same key fields as other expenses, and adds assertions to prevent regressions.

Changes:

  • Populate mortgage interest/principal detail objects with category, actual_amount, expected_amount, is_virtual, and is_deferred in BalanceService::getDetailedMonthlyBalance().
  • Extend the existing Balance feature test to assert the new fields exist and are correct.
  • Document the fix in DEVLOG.md and CHANGELOG.md.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
app/Services/Finance/BalanceService.php Adds missing fields to mortgage expense detail objects so frontend grouping and actual amounts render correctly.
tests/Feature/BalanceTest.php Extends the existing test with assertions for new mortgage fields to prevent regression.
DEVLOG.md Records implementation details and rationale for the fix.
CHANGELOG.md Adds user-facing changelog entry describing the bug fix.
## Pull request overview > [!NOTE] > Copilot was unable to run its full agentic suite in this review. Fixes monthly Balance view mortgage entries rendering as “Uncategorized” with `0` actual amounts by ensuring mortgage expense detail objects include the same key fields as other expenses, and adds assertions to prevent regressions. **Changes:** - Populate mortgage interest/principal detail objects with `category`, `actual_amount`, `expected_amount`, `is_virtual`, and `is_deferred` in `BalanceService::getDetailedMonthlyBalance()`. - Extend the existing Balance feature test to assert the new fields exist and are correct. - Document the fix in `DEVLOG.md` and `CHANGELOG.md`. ### Reviewed changes Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments. | File | Description | | ---- | ----------- | | app/Services/Finance/BalanceService.php | Adds missing fields to mortgage expense detail objects so frontend grouping and actual amounts render correctly. | | tests/Feature/BalanceTest.php | Extends the existing test with assertions for new mortgage fields to prevent regression. | | DEVLOG.md | Records implementation details and rationale for the fix. | | CHANGELOG.md | Adds user-facing changelog entry describing the bug fix. |
@ -12,2 +17,4 @@
- Updated `.github/workflows/copilot-setup-steps.yml`:
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-04-24 18:43:21 +00:00

This section now contains multiple consecutive blank lines (17–19) and the workflow update bullets (20–21) appear to be orphaned from their prior heading (removed in this diff). Please either reintroduce an appropriate heading for the workflow note, move it under an existing section, or remove it if it’s unrelated to this entry; also collapse the extra blank lines to keep the devlog readable.

### 🤖 Copilot Runner Workflow Updates
This section now contains multiple consecutive blank lines (17–19) and the workflow update bullets (20–21) appear to be orphaned from their prior heading (removed in this diff). Please either reintroduce an appropriate heading for the workflow note, move it under an existing section, or remove it if it’s unrelated to this entry; also collapse the extra blank lines to keep the devlog readable. ```suggestion ### 🤖 Copilot Runner Workflow Updates ```
@ -374,3 +383,4 @@
'is_mortgage' => true,
'category' => (object) ['name' => 'Mortgage'],
]);
}
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-04-24 18:43:21 +00:00

The two push objects duplicate the same set of fields (expected_amount, actual_amount, is_virtual, is_deferred, is_mortgage, category), which increases the risk of future drift (e.g., adding a new required field to one but not the other). Consider extracting a small private helper (or building a shared base array/object and overriding name/amount) and reusing a single $mortgageCategory object/value to keep these entries consistent.

The two push objects duplicate the same set of fields (`expected_amount`, `actual_amount`, `is_virtual`, `is_deferred`, `is_mortgage`, `category`), which increases the risk of future drift (e.g., adding a new required field to one but not the other). Consider extracting a small private helper (or building a shared base array/object and overriding `name`/`amount`) and reusing a single `$mortgageCategory` object/value to keep these entries consistent.
Sign in to join this conversation.
No description provided.