Skip to content

Conversation

youngcw
Copy link
Member

@youngcw youngcw commented Jul 6, 2025

Make remainder templates respect category limits.

I don't know if the limit should only be for one passed in with a remainder template directly or if it should be like the other templates and any defined limit is respected. Currently any template in the category can define a limit and the remainder will respect it.

This works by looping over the remainder application until either there are no more categories that will accept funds, or the funds run out.

@actual-github-bot actual-github-bot bot changed the title [Goals] limits for remainders [WIP] [Goals] limits for remainders Jul 6, 2025
Copy link
Contributor

github-actions bot commented Jul 6, 2025

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
19 10.37 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/index.js 7.86 MB 0%
static/js/de.js 134.73 kB 0%
static/js/en-GB.js 6.38 kB 0%
static/js/en.js 124.63 kB 0%
static/js/es.js 70.83 kB 0%
static/js/fr.js 133.74 kB 0%
static/js/nl.js 100.58 kB 0%
static/js/pt-BR.js 124.83 kB 0%
static/js/sv.js 65.13 kB 0%
static/js/th.js 190.63 kB 0%
static/js/uk.js 121.11 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 12.94 kB 0%
static/js/workbox-window.prod.es5.js 5.64 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/ReportRouter.js 820.23 kB 0%
static/js/narrow.js 393.84 kB 0%
static/js/wide.js 115.17 kB 0%
static/js/TransactionList.js 10.92 kB 0%

Copy link

netlify bot commented Jul 6, 2025

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 2cdeaf3
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/686d6bee63ca330008b0c463
😎 Deploy Preview https://deploy-preview-5301.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

github-actions bot commented Jul 6, 2025

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 2.26 MB → 2.26 MB (+500 B) +0.02%
Changeset
File Δ Size
packages/loot-core/src/server/budget/goal-template.ts 📈 +193 B (+2.70%) 6.99 kB → 7.18 kB
packages/loot-core/src/server/budget/category-template-context.ts 📈 +216 B (+0.93%) 22.65 kB → 22.86 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
kcab.worker.js 2.26 MB → 2.26 MB (+500 B) +0.02%

Smaller

No assets were smaller

Unchanged

No assets were unchanged

@youngcw youngcw changed the title [WIP] [Goals] limits for remainders [Goals] limits for remainders Jul 6, 2025
Copy link
Contributor

coderabbitai bot commented Jul 6, 2025

Walkthrough

The changes introduce a new public method, hasRemainder(), to the CategoryTemplateContext class, which checks for a positive remainder weight and whether a spending limit has been met. The runRemainder method is refactored to remove early returns and now includes additional logic to adjust allocations based on spending limits. The checkLimit method is updated to accept a templates parameter and operates on it directly, enforcing constraints and recalculating limits. In goal-template.ts, the remainder allocation logic is restructured to use a loop that continues distributing budget as long as eligible contexts remain, recalculating weights and allocations each iteration.

Suggested labels

:sparkles: merged

Suggested reviewers

  • matt-fidd

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 425ef83 and 2cdeaf3.

📒 Files selected for processing (1)
  • packages/loot-core/src/server/budget/category-template-context.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/loot-core/src/server/budget/category-template-context.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: Analyze
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: Wait for Netlify build to finish
  • GitHub Check: Functional Desktop App
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

matt-fidd
matt-fidd previously approved these changes Jul 8, 2025
Copy link
Member

@matt-fidd matt-fidd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, I think the current "any template can specify" is good for now. If it causes confusion we can look at changing it but once we manage to get the UI in this sort of edge case can be handled more obviously.

@gschmidl
Copy link

gschmidl commented Jul 8, 2025

Sounds good to me!

@youngcw
Copy link
Member Author

youngcw commented Jul 8, 2025

This LGTM, I think the current "any template can specify" is good for now. If it causes confusion we can look at changing it but once we manage to get the UI in this sort of edge case can be handled more obviously.

The more I think about it, the more ok with it I am. Ill still wait a bit longer for more comments though.

@youngcw youngcw requested a review from matt-fidd July 8, 2025 21:32
@youngcw youngcw merged commit dbcfb63 into master Jul 9, 2025
24 checks passed
@youngcw youngcw deleted the youngcw/remainder-limit branch July 9, 2025 14:11
passabilities added a commit to passabilities/actual-budget that referenced this pull request Jul 9, 2025
…raph

* actual/master: (120 commits)
  [Goals] limits for remainders (actualbudget#5301)
  Reword the overspending banner for tracking budget. (actualbudget#5307)
  Fix a few typos mentioned on Weblate (actualbudget#5211)
  no hidden (actualbudget#5305)
  [Goals] upgrade week template to be a periodic template (actualbudget#5295)
  [Goals] Round template amounts if hide decimals is set (actualbudget#5288)
  :electron:  Fix early server-started signification message (actualbudget#5303)
  Customize tags colors (actualbudget#5032)
  Run rules on transactions created by a transfer. (actualbudget#5279)
  add notes to scheduled transactions table (actualbudget#5290)
  💬 Added Discord link to the help menu for discoverability (actualbudget#5286)
  Fixes actualbudget#5278: Applied PrivacyFilter to balance graph display (and added conditionality whether user is hovering on the graph) (actualbudget#5281)
  add some basic linting rules for translation consistency (actualbudget#5212)
  Update contributor points calculation logic (actualbudget#5169)
  feat(currency): add currency setting and format (actualbudget#5167)
  Move remaining `.d.ts` files to `.ts` (actualbudget#5208)
  use correct running balance when adding a new transaction (actualbudget#5207)
  Fix rule templating on date causing crash (actualbudget#5259)
  Fixes actualbudget#5228 - has tag(s) filter now takes values when pressing Enter (actualbudget#5263)
  correctly ignore hidden categories when using "Set Average Budget" (actualbudget#5239)
  ...
RubenOlsen added a commit to actualbudget/docs that referenced this pull request Jul 29, 2025
This adds the documentation for
actualbudget/actual#5288
actualbudget/actual#5295
actualbudget/actual#5301

And also some minor additions in other places.

---------

Co-authored-by: Ruben Olsen Lærk <ruben@lku.no>
Johnn27 pushed a commit to Johnn27/actual that referenced this pull request Aug 12, 2025
* limits for remainders

* round if needed

* handle edge cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants