Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add "last reconciled" timestamp to accounts #4459

Merged

Conversation

tostasmistas
Copy link
Contributor

@tostasmistas tostasmistas commented Feb 26, 2025

⚠️ This PR contains a migration ⚠️


This PR resolves #2967.

It adds a last_reconciled column to the accounts table, which stores a UNIX timestamp indicating when each account was last reconciled. Upon initial release, all accounts will display "Not yet reconciled"; however, after completing reconciliation and pressing the "Done reconciling" button, the timestamp will be updated accordingly.


imagem

imagem

imagem

imagem


Copy link

netlify bot commented Feb 26, 2025

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 7b263f7
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/67c5b8f3ba8230000999e22d
😎 Deploy Preview https://deploy-preview-4459.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 site configuration.

Copy link
Contributor

github-actions bot commented Feb 26, 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
18 7.08 MB → 8.05 MB (+994.19 kB) +13.71%
Changeset (largest 100 files by percent change)
File Δ Size
node_modules/date-fns/esm/locale/be/_lib/formatDistance/index.js 🆕 +8.53 kB 0 B → 8.53 kB
node_modules/date-fns/esm/locale/be-tarask/_lib/formatDistance/index.js 🆕 +8.53 kB 0 B → 8.53 kB
node_modules/date-fns/esm/formatDistance/index.js 🆕 +8.22 kB 0 B → 8.22 kB
node_modules/date-fns/esm/locale/ru/_lib/formatDistance/index.js 🆕 +8.21 kB 0 B → 8.21 kB
node_modules/date-fns/esm/locale/uk/_lib/formatDistance/index.js 🆕 +7.93 kB 0 B → 7.93 kB
node_modules/date-fns/esm/locale/sl/_lib/formatDistance/index.js 🆕 +7.91 kB 0 B → 7.91 kB
node_modules/date-fns/esm/locale/kk/_lib/formatDistance/index.js 🆕 +7.58 kB 0 B → 7.58 kB
node_modules/date-fns/esm/locale/ta/_lib/formatDistance/index.js 🆕 +7.47 kB 0 B → 7.47 kB
node_modules/date-fns/esm/locale/cs/_lib/formatDistance/index.js 🆕 +7.38 kB 0 B → 7.38 kB
node_modules/date-fns/esm/locale/ca/_lib/localize/index.js 🆕 +6.92 kB 0 B → 6.92 kB
node_modules/date-fns/esm/locale/kn/_lib/formatDistance/index.js 🆕 +6.34 kB 0 B → 6.34 kB
node_modules/date-fns/esm/locale/vi/_lib/localize/index.js 🆕 +6.15 kB 0 B → 6.15 kB
node_modules/date-fns/esm/locale/bn/_lib/localize/index.js 🆕 +5.99 kB 0 B → 5.99 kB
node_modules/date-fns/esm/locale/hi/_lib/localize/index.js 🆕 +5.22 kB 0 B → 5.22 kB
node_modules/date-fns/esm/locale/te/_lib/formatDistance/index.js 🆕 +5.14 kB 0 B → 5.14 kB
node_modules/date-fns/esm/locale/be-tarask/_lib/localize/index.js 🆕 +4.98 kB 0 B → 4.98 kB
node_modules/date-fns/esm/locale/be/_lib/localize/index.js 🆕 +4.95 kB 0 B → 4.95 kB
node_modules/date-fns/esm/locale/lb/_lib/formatDistance/index.js 🆕 +4.92 kB 0 B → 4.92 kB
node_modules/date-fns/esm/locale/sr/_lib/formatDistance/index.js 🆕 +4.91 kB 0 B → 4.91 kB
node_modules/date-fns/esm/locale/bn/_lib/match/index.js 🆕 +4.84 kB 0 B → 4.84 kB
node_modules/date-fns/esm/locale/te/_lib/localize/index.js 🆕 +4.74 kB 0 B → 4.74 kB
node_modules/date-fns/esm/locale/ta/_lib/localize/index.js 🆕 +4.61 kB 0 B → 4.61 kB
node_modules/date-fns/esm/locale/sk/_lib/formatDistance/index.js 🆕 +4.6 kB 0 B → 4.6 kB
node_modules/date-fns/esm/locale/gu/_lib/localize/index.js 🆕 +4.59 kB 0 B → 4.59 kB
node_modules/date-fns/esm/locale/kn/_lib/localize/index.js 🆕 +4.52 kB 0 B → 4.52 kB
node_modules/date-fns/esm/locale/ka/_lib/localize/index.js 🆕 +4.47 kB 0 B → 4.47 kB
node_modules/date-fns/esm/locale/km/_lib/localize/index.js 🆕 +4.36 kB 0 B → 4.36 kB
node_modules/date-fns/esm/locale/bs/_lib/formatDistance/index.js 🆕 +4.36 kB 0 B → 4.36 kB
node_modules/date-fns/esm/locale/mn/_lib/localize/index.js 🆕 +4.35 kB 0 B → 4.35 kB
node_modules/date-fns/esm/locale/hr/_lib/formatDistance/index.js 🆕 +4.35 kB 0 B → 4.35 kB
node_modules/date-fns/esm/locale/sr-Latn/_lib/formatDistance/index.js 🆕 +4.34 kB 0 B → 4.34 kB
node_modules/date-fns/esm/locale/te/_lib/match/index.js 🆕 +4.3 kB 0 B → 4.3 kB
node_modules/date-fns/esm/locale/th/_lib/localize/index.js 🆕 +4.23 kB 0 B → 4.23 kB
node_modules/date-fns/esm/locale/uk/_lib/localize/index.js 🆕 +4.23 kB 0 B → 4.23 kB
node_modules/date-fns/esm/formatDistanceToNow/index.js 🆕 +4.21 kB 0 B → 4.21 kB
node_modules/date-fns/esm/locale/th/_lib/match/index.js 🆕 +4.19 kB 0 B → 4.19 kB
node_modules/date-fns/esm/locale/lt/_lib/localize/index.js 🆕 +4.15 kB 0 B → 4.15 kB
node_modules/date-fns/esm/locale/lv/_lib/localize/index.js 🆕 +4.14 kB 0 B → 4.14 kB
node_modules/date-fns/esm/locale/ta/_lib/match/index.js 🆕 +4.13 kB 0 B → 4.13 kB
node_modules/date-fns/esm/locale/kn/_lib/match/index.js 🆕 +4.06 kB 0 B → 4.06 kB
node_modules/date-fns/esm/locale/ru/_lib/localize/index.js 🆕 +4.05 kB 0 B → 4.05 kB
node_modules/date-fns/esm/locale/vi/_lib/match/index.js 🆕 +4.03 kB 0 B → 4.03 kB
node_modules/date-fns/esm/locale/km/_lib/match/index.js 🆕 +4.03 kB 0 B → 4.03 kB
node_modules/date-fns/esm/locale/lv/_lib/formatDistance/index.js 🆕 +4.02 kB 0 B → 4.02 kB
node_modules/date-fns/esm/locale/hi/_lib/match/index.js 🆕 +3.99 kB 0 B → 3.99 kB
node_modules/date-fns/esm/locale/he/_lib/localize/index.js 🆕 +3.98 kB 0 B → 3.98 kB
node_modules/date-fns/esm/locale/fa-IR/_lib/match/index.js 🆕 +3.96 kB 0 B → 3.96 kB
node_modules/date-fns/esm/locale/cy/_lib/localize/index.js 🆕 +3.93 kB 0 B → 3.93 kB
node_modules/date-fns/esm/locale/mn/_lib/match/index.js 🆕 +3.91 kB 0 B → 3.91 kB
node_modules/date-fns/esm/locale/kk/_lib/match/index.js 🆕 +3.9 kB 0 B → 3.9 kB
node_modules/date-fns/esm/locale/lt/_lib/formatDistance/index.js 🆕 +3.88 kB 0 B → 3.88 kB
node_modules/date-fns/esm/locale/kk/_lib/localize/index.js 🆕 +3.87 kB 0 B → 3.87 kB
node_modules/date-fns/esm/locale/ja-Hira/_lib/localize/index.js 🆕 +3.86 kB 0 B → 3.86 kB
node_modules/date-fns/esm/locale/et/_lib/formatDistance/index.js 🆕 +3.86 kB 0 B → 3.86 kB
node_modules/date-fns/esm/locale/sr/_lib/localize/index.js 🆕 +3.81 kB 0 B → 3.81 kB
node_modules/date-fns/esm/locale/ka/_lib/formatDistance/index.js 🆕 +3.77 kB 0 B → 3.77 kB
node_modules/date-fns/esm/locale/de/_lib/formatDistance/index.js 🆕 +3.75 kB 0 B → 3.75 kB
node_modules/date-fns/esm/locale/hy/_lib/localize/index.js 🆕 +3.74 kB 0 B → 3.74 kB
node_modules/date-fns/esm/locale/ug/_lib/localize/index.js 🆕 +3.72 kB 0 B → 3.72 kB
node_modules/date-fns/esm/locale/el/_lib/match/index.js 🆕 +3.72 kB 0 B → 3.72 kB
node_modules/date-fns/esm/locale/pl/_lib/localize/index.js 🆕 +3.68 kB 0 B → 3.68 kB
node_modules/date-fns/esm/locale/be-tarask/_lib/match/index.js 🆕 +3.67 kB 0 B → 3.67 kB
node_modules/date-fns/esm/locale/uk/_lib/match/index.js 🆕 +3.67 kB 0 B → 3.67 kB
node_modules/date-fns/esm/locale/gu/_lib/match/index.js 🆕 +3.66 kB 0 B → 3.66 kB
node_modules/date-fns/esm/locale/be/_lib/match/index.js 🆕 +3.65 kB 0 B → 3.65 kB
node_modules/date-fns/esm/locale/az/_lib/match/index.js 🆕 +3.63 kB 0 B → 3.63 kB
node_modules/date-fns/esm/locale/de/_lib/localize/index.js 🆕 +3.63 kB 0 B → 3.63 kB
node_modules/date-fns/esm/locale/az/_lib/localize/index.js 🆕 +3.62 kB 0 B → 3.62 kB
node_modules/date-fns/esm/locale/de-AT/_lib/localize/index.js 🆕 +3.62 kB 0 B → 3.62 kB
node_modules/date-fns/esm/locale/hy/_lib/match/index.js 🆕 +3.62 kB 0 B → 3.62 kB
node_modules/date-fns/esm/locale/ru/_lib/match/index.js 🆕 +3.61 kB 0 B → 3.61 kB
node_modules/date-fns/esm/locale/gd/_lib/localize/index.js 🆕 +3.6 kB 0 B → 3.6 kB
node_modules/date-fns/esm/locale/ar/_lib/match/index.js 🆕 +3.6 kB 0 B → 3.6 kB
node_modules/date-fns/esm/locale/lt/_lib/match/index.js 🆕 +3.6 kB 0 B → 3.6 kB
node_modules/date-fns/esm/locale/pl/_lib/match/index.js 🆕 +3.58 kB 0 B → 3.58 kB
node_modules/date-fns/esm/locale/ar-EG/_lib/match/index.js 🆕 +3.57 kB 0 B → 3.57 kB
node_modules/date-fns/esm/locale/oc/_lib/localize/index.js 🆕 +3.54 kB 0 B → 3.54 kB
node_modules/date-fns/esm/locale/el/_lib/localize/index.js 🆕 +3.53 kB 0 B → 3.53 kB
node_modules/date-fns/esm/locale/ca/_lib/match/index.js 🆕 +3.52 kB 0 B → 3.52 kB
node_modules/date-fns/esm/locale/fa-IR/_lib/localize/index.js 🆕 +3.52 kB 0 B → 3.52 kB
node_modules/date-fns/esm/locale/he/_lib/match/index.js 🆕 +3.51 kB 0 B → 3.51 kB
node_modules/date-fns/esm/locale/sk/_lib/localize/index.js 🆕 +3.49 kB 0 B → 3.49 kB
node_modules/date-fns/esm/locale/ar-TN/_lib/match/index.js 🆕 +3.48 kB 0 B → 3.48 kB
node_modules/date-fns/esm/locale/ja/_lib/localize/index.js 🆕 +3.48 kB 0 B → 3.48 kB
node_modules/date-fns/esm/locale/ar-TN/_lib/localize/index.js 🆕 +3.44 kB 0 B → 3.44 kB
node_modules/date-fns/esm/locale/ar/_lib/localize/index.js 🆕 +3.43 kB 0 B → 3.43 kB
node_modules/date-fns/esm/locale/cs/_lib/localize/index.js 🆕 +3.43 kB 0 B → 3.43 kB
node_modules/date-fns/esm/locale/ar-SA/_lib/formatDistance/index.js 🆕 +3.42 kB 0 B → 3.42 kB
node_modules/date-fns/esm/locale/ar/_lib/formatDistance/index.js 🆕 +3.41 kB 0 B → 3.41 kB
node_modules/date-fns/esm/locale/ar-DZ/_lib/match/index.js 🆕 +3.41 kB 0 B → 3.41 kB
node_modules/date-fns/esm/locale/ar-DZ/_lib/formatDistance/index.js 🆕 +3.4 kB 0 B → 3.4 kB
node_modules/date-fns/esm/locale/ar-MA/_lib/formatDistance/index.js 🆕 +3.4 kB 0 B → 3.4 kB
node_modules/date-fns/esm/locale/sr/_lib/match/index.js 🆕 +3.4 kB 0 B → 3.4 kB
node_modules/date-fns/esm/locale/sq/_lib/localize/index.js 🆕 +3.4 kB 0 B → 3.4 kB
node_modules/date-fns/esm/locale/pl/_lib/formatDistance/index.js 🆕 +3.38 kB 0 B → 3.38 kB
node_modules/date-fns/esm/locale/eu/_lib/match/index.js 🆕 +3.37 kB 0 B → 3.37 kB
node_modules/date-fns/esm/locale/ug/_lib/match/index.js 🆕 +3.37 kB 0 B → 3.37 kB
node_modules/date-fns/esm/locale/cs/_lib/match/index.js 🆕 +3.37 kB 0 B → 3.37 kB
node_modules/date-fns/esm/locale/ar-EG/_lib/localize/index.js 🆕 +3.35 kB 0 B → 3.35 kB
node_modules/date-fns/esm/locale/hr/_lib/localize/index.js 🆕 +3.33 kB 0 B → 3.33 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 4.36 MB → 5.33 MB (+993.41 kB) +22.28%
static/js/wide.js 102.9 kB → 103.68 kB (+796 B) +0.76%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/en-GB.js 96.59 kB 0%
static/js/de.js 112.69 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/es.js 58.26 kB 0%
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/nl.js 95.56 kB 0%
static/js/uk.js 111.11 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/en.js 103.63 kB 0%
static/js/pt-BR.js 110.57 kB 0%
static/js/fr.js 113.61 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/narrow.js 86.26 kB 0%
static/js/AppliedFilters.js 10.8 kB 0%
static/js/useAccountPreviewTransactions.js 1.69 kB 0%
static/js/ReportRouter.js 1.59 MB 0%

Copy link
Contributor

github-actions bot commented Feb 26, 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 1.34 MB → 1.34 MB (+73 B) +0.01%
Changeset
File Δ Size
packages/loot-core/src/shared/util.ts 📈 +402 B (+3.55%) 11.07 kB → 11.46 kB
packages/loot-core/src/server/accounts/app.ts 📈 +88 B (+0.35%) 24.21 kB → 24.3 kB
packages/loot-core/src/server/aql/schema/index.ts 📈 +38 B (+0.25%) 14.78 kB → 14.81 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
kcab.worker.js 1.34 MB → 1.34 MB (+73 B) +0.01%

Smaller

No assets were smaller

Unchanged

No assets were unchanged

@tostasmistas tostasmistas force-pushed the feat/accounts-last-reconciled branch 2 times, most recently from 5eaaf45 to 51a53f6 Compare February 27, 2025 17:00
@tostasmistas tostasmistas changed the title [WIP] feat: add "last reconciled" timestamp to accounts feat: add "last reconciled" timestamp to accounts Feb 27, 2025
Copy link
Contributor

coderabbitai bot commented Feb 27, 2025

Warning

Rate limit exceeded

@tostasmistas has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d131dde and 7b263f7.

📒 Files selected for processing (3)
  • packages/desktop-client/src/components/accounts/Balance.tsx (1 hunks)
  • packages/desktop-client/src/components/accounts/Header.tsx (4 hunks)
  • packages/loot-core/src/shared/util.ts (2 hunks)

Walkthrough

The changes enhance the reconciliation process for accounts across various components of the codebase. In the desktop client, the onDoneReconciling method in the AccountInternal class now includes error handling to verify the existence of an account using the provided accountId, throwing an error if not found. Additionally, it updates the last_reconciled timestamp of the account upon successful reconciliation. The Balances component has been modified to conditionally render additional balance information. The backend has been updated to include a new last_reconciled field in the account data model and schema, supported by a SQL migration. Mocks for offline accounts have been adjusted to include this new timestamp, and the updateAccount function has been modified to accept this parameter. A new utility function for converting timestamps to relative time has also been introduced.

Possibly related PRs

Suggested labels

:sparkles: Merged

Suggested reviewers

  • youngcw
  • matt-fidd

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/loot-core/src/mocks/index.ts (1)

25-25: Consider initializing last_reconciled to null for new accounts.

Currently, all mock accounts are initialized with the current timestamp as their last_reconciled value, implying they've already been reconciled. This doesn't match the expected behavior where new accounts would start with a "Not yet reconciled" status.

- last_reconciled: new Date().getTime().toString(),
+ last_reconciled: null,
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 398ada0 and 51a53f6.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/4459.md is excluded by !**/*.md
📒 Files selected for processing (8)
  • packages/desktop-client/src/components/accounts/Account.tsx (2 hunks)
  • packages/desktop-client/src/components/accounts/Balance.tsx (5 hunks)
  • packages/desktop-client/src/components/spreadsheet/index.ts (1 hunks)
  • packages/loot-core/migrations/1740506588539_add_last_reconciled_at.sql (1 hunks)
  • packages/loot-core/src/mocks/index.ts (1 hunks)
  • packages/loot-core/src/server/accounts/app.ts (1 hunks)
  • packages/loot-core/src/server/aql/schema/index.ts (1 hunks)
  • packages/loot-core/src/types/models/account.d.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/loot-core/migrations/1740506588539_add_last_reconciled_at.sql
🧰 Additional context used
🧠 Learnings (1)
packages/desktop-client/src/components/accounts/Account.tsx (1)
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/accounts/Account.tsx:655-665
Timestamp: 2024-11-10T16:45:31.225Z
Learning: The Account component in 'packages/desktop-client/src/components/accounts/Account.tsx' is being rewritten in a separate PR.
🔇 Additional comments (10)
packages/desktop-client/src/components/spreadsheet/index.ts (1)

17-17: LGTM: Properly typed new property for account reconciliation.

The lastReconciled property has been correctly added to the account type with the appropriate string | null type, allowing it to represent both reconciled accounts (with timestamp strings) and unreconciled accounts (with null values).

packages/loot-core/src/types/models/account.d.ts (1)

7-7: LGTM: Properly typed core data model property.

The last_reconciled property has been correctly added to the AccountEntity type with the appropriate string | null type, consistent with other timestamp fields in the model and allowing for accounts that haven't been reconciled yet.

packages/loot-core/src/server/aql/schema/index.ts (1)

77-77: LGTM: Schema field added with correct type.

The last_reconciled field has been correctly added to the schema with the string type, which aligns with the type definition in the AccountEntity interface.

packages/loot-core/src/server/accounts/app.ts (1)

64-74: Good implementation for conditional field updates.

The function signature has been properly updated to accept the new last_reconciled field using TypeScript's utility types, and the implementation uses a conditional spread operator to only include the field when it's provided. This maintains backward compatibility with existing code while supporting the new functionality.

packages/desktop-client/src/components/accounts/Account.tsx (2)

1013-1018: Good defensive programming with account existence check.

Adding this account existence check before attempting to update the last_reconciled timestamp helps prevent potential runtime errors and provides a clear error message for debugging.


1044-1049: Last reconciled timestamp implementation looks good.

The code properly captures the current timestamp and updates the account record with the reconciliation time when the user completes reconciliation. This ensures the timestamp is updated in the database for future reference.

packages/desktop-client/src/components/accounts/Balance.tsx (4)

7-8: Appropriate imports for date handling.

The date-fns library is a good choice for handling relative time formatting and provides good localization support.


150-159: Well-implemented relative time formatter.

The tsToRelativeTime function handles null values gracefully, correctly parses the timestamp, and properly applies localization based on the user's preferred language.

One small suggestion: Add a fallback for invalid date parsing that could occur if the timestamp format changes in the future.

const tsToRelativeTime = (ts: string | null, language: string): string => {
  if (!ts) return 'Unknown';

  const parsed = new Date(parseInt(ts, 10));
+ if (isNaN(parsed.getTime())) return 'Unknown';

  const locale =
    locales[language.replace('-', '') as keyof typeof locales] ??
    locales['enUS'];

  return formatDistanceToNow(parsed, { addSuffix: true, locale });
};

188-208: Good UI implementation for reconciliation status.

The UI element is consistent with the existing design language and provides useful information to the user about the reconciliation status of the account.


294-299: Proper prop passing for the reconciliation status.

The code correctly passes the last_reconciled property from the account object to the MoreBalances component, maintaining the data flow.

locales[language.replace('-', '') as keyof typeof locales] ??
locales['enUS'];

return formatDistanceToNow(parsed, { addSuffix: true, locale });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can also use formatDistanceToNowStrict which will not include the prefix "about".

matt-fidd
matt-fidd previously approved these changes Mar 1, 2025
Copy link
Contributor

@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.

I really like this, thank you! I might even steal that tsToRelative function for the bank sync page.

Leaving this open for a little before merging to get a second opinion on the location, I don't mind it but could see it being a point of contention.

@youngcw
Copy link
Member

youngcw commented Mar 1, 2025

I was thinking about the location. I don't love that it's always there if you want to view the cleared amounts, but I don't have any better ideas yet

@matt-fidd
Copy link
Contributor

I was thinking about the location. I don't love that it's always there if you want to view the cleared amounts, but I don't have any better ideas yet

What about a popover when you hover the reconcile button? Downside is that it's not as prominent or discoverable.

@deathblade666
Copy link
Contributor

just a thought, what about an open padlock icon when no recon has been performed, closed once it has, and the last recon date in the tool tip?

Could also be not very noticeable tho

@tostasmistas
Copy link
Contributor Author

Yeah, I completely understand all the opinions, I too couldn't come up with a better place for it. I also don't know if it's something people prefer to always have visible at a glance, which would be the issue with having it in a tooltip.

@Teprifer
Copy link

Teprifer commented Mar 2, 2025

Tool tip would be best imo, plenty of people never use reconcile, but do monitor cleared vs not.

add a `last_reconciled` column to the `accounts` table, which stores a UNIX timestamp indicating when each account was last reconciled
upon initial release, all accounts will display "Not yet reconciled"; however, after completing reconciliation and pressing the "Done reconciling" button, the timestamp will be updated accordingly
generate mock accounts with the `last_reconciled` value set to `null`, to match the expected behaviour that new accounts will start with a "Not yet reconciled" status
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
packages/loot-core/src/shared/util.ts (1)

490-499: Function implementation looks good, but could be more robust.

The timestamp conversion function is well-implemented with proper error handling and locale support. However, there are a few improvements that could be made:

Consider these enhancements:

export function tsToRelativeTime(ts: string | null, language: string): string {
-  if (!ts) return 'Unknown';
+  if (!ts || ts === '0') return 'Unknown';

-  const parsed = new Date(parseInt(ts, 10));
+  const timestamp = parseInt(ts, 10);
+  if (isNaN(timestamp) || timestamp <= 0) return 'Unknown';
+  const parsed = new Date(timestamp);

  const locale =
    locales[language.replace('-', '') as keyof typeof locales] ??
    locales['enUS'];

-  return formatDistanceToNow(parsed, { addSuffix: true, locale });
+  try {
+    return formatDistanceToNow(parsed, { addSuffix: true, locale });
+  } catch (error) {
+    console.error('Error formatting relative time:', error);
+    return 'Unknown';
+  }
}

This improves error handling for invalid timestamps and wraps the date formatting in a try-catch block to prevent potential runtime errors.

packages/desktop-client/src/components/accounts/Header.tsx (3)

390-393: Consider extracting tooltip content to a separate function.

For better readability and maintainability, consider extracting the tooltip content logic to a separate function.

+ const getReconciliationTooltipContent = (account: AccountEntity | undefined, language: string) => {
+   return account?.last_reconciled
+     ? `${t('Reconciled')} ${tsToRelativeTime(account?.last_reconciled, language || 'en-US')}`
+     : t('Not yet reconciled');
+ };

// Then in the JSX:
content={getReconciliationTooltipContent(account, language)}

391-391: Check for possible null reference.

There's a potential null reference issue when accessing account?.last_reconciled while also using the optional chaining operator within the tsToRelativeTime function call.

-`${t('Reconciled')} ${tsToRelativeTime(account?.last_reconciled, language || 'en-US')}`
+`${t('Reconciled')} ${tsToRelativeTime(account.last_reconciled, language || 'en-US')}`

Since you're already checking if account?.last_reconciled exists in the conditional, you can safely use account.last_reconciled within the function call.


408-410: Unnecessary View wrapper around the icon.

The SvgLockClosed icon is wrapped in a View component that doesn't provide any styling or functionality.

-<View>
  <SvgLockClosed width={14} height={14} />
-</View>

Removing the unnecessary View component would simplify the code without changing the functionality.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 49be922 and 5347320.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/4459.md is excluded by !**/*.md
📒 Files selected for processing (10)
  • packages/desktop-client/src/components/accounts/Account.tsx (2 hunks)
  • packages/desktop-client/src/components/accounts/Balance.tsx (1 hunks)
  • packages/desktop-client/src/components/accounts/Header.tsx (5 hunks)
  • packages/desktop-client/src/components/spreadsheet/index.ts (1 hunks)
  • packages/loot-core/migrations/1740506588539_add_last_reconciled_at.sql (1 hunks)
  • packages/loot-core/src/mocks/index.ts (1 hunks)
  • packages/loot-core/src/server/accounts/app.ts (1 hunks)
  • packages/loot-core/src/server/aql/schema/index.ts (1 hunks)
  • packages/loot-core/src/shared/util.ts (2 hunks)
  • packages/loot-core/src/types/models/account.d.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/desktop-client/src/components/accounts/Balance.tsx
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/loot-core/src/types/models/account.d.ts
  • packages/loot-core/migrations/1740506588539_add_last_reconciled_at.sql
  • packages/desktop-client/src/components/spreadsheet/index.ts
  • packages/loot-core/src/server/aql/schema/index.ts
  • packages/loot-core/src/mocks/index.ts
  • packages/loot-core/src/server/accounts/app.ts
  • packages/desktop-client/src/components/accounts/Account.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Functional
  • GitHub Check: Visual regression
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: Analyze
🔇 Additional comments (3)
packages/desktop-client/src/components/accounts/Header.tsx (3)

17-17: New imports look good.

Appropriate imports added for the new functionality.

Also applies to: 20-20, 28-28


191-192: Good use of global preferences.

Correctly uses the useGlobalPref hook to get the user's language preference for localized timestamp display.


384-425: Great enhancement to the reconciliation UI.

The tooltip implementation adds valuable context about the account's reconciliation status without cluttering the interface. The conditional rendering and placement are well thought out.

Nicely done with:

  1. Conditionally showing either "Reconciled X time ago" or "Not yet reconciled"
  2. Disabling the tooltip when the reconciliation menu is open to avoid UI conflicts
  3. Proper positioning of the tooltip ("top start")
  4. Leveraging the new tsToRelativeTime utility with localization support

@tostasmistas
Copy link
Contributor Author

tostasmistas commented Mar 3, 2025

I have relocated the timestamp from the account balances header to a tooltip displayed when hovering over the "Reconcile" button. I think this looks good and is practical for those that make use of reconciliation.

image

image

image

@tostasmistas tostasmistas force-pushed the feat/accounts-last-reconciled branch from 5347320 to 6f0d8d2 Compare March 3, 2025 13:33
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (5)
packages/loot-core/src/shared/util.ts (3)

490-499: Add error handling for timestamp parsing and consider more robust date validation

The function works correctly for valid timestamps, but could be improved with better error handling and validation.

export function tsToRelativeTime(ts: string | null, language: string): string {
  if (!ts) return 'Unknown';

-  const parsed = new Date(parseInt(ts, 10));
+  // Handle potential parsing errors and invalid dates
+  try {
+    const parsedTimestamp = parseInt(ts, 10);
+    if (isNaN(parsedTimestamp)) return 'Unknown';
+    
+    const parsed = new Date(parsedTimestamp);
+    if (isNaN(parsed.getTime())) return 'Unknown';
+    
+    const locale =
+      locales[language.replace('-', '') as keyof typeof locales] ??
+      locales['enUS'];
+
+    return formatDistanceToNow(parsed, { addSuffix: true, locale });
+  } catch (error) {
+    console.error('Error parsing timestamp:', error);
+    return 'Unknown';
+  }
-  const locale =
-    locales[language.replace('-', '') as keyof typeof locales] ??
-    locales['enUS'];
-
-  return formatDistanceToNow(parsed, { addSuffix: true, locale });
}

488-489: Add JSDoc comments for the date utilities section

Adding documentation for the new date utilities section would improve code maintainability.

// Date utilities
+/**
+ * Date-related utility functions for formatting and displaying dates
+ */

490-490: Add JSDoc comments for the tsToRelativeTime function

Adding documentation for the new function would improve code usability and maintainability.

+/**
+ * Converts a UNIX timestamp string to a human-readable relative time format
+ * @param ts - UNIX timestamp in milliseconds as a string, or null
+ * @param language - Language code (e.g., 'en-US', 'fr-FR') for localization
+ * @returns A localized string describing the relative time (e.g., "2 days ago") or "Unknown" if invalid
+ */
export function tsToRelativeTime(ts: string | null, language: string): string {
packages/desktop-client/src/components/accounts/Header.tsx (2)

384-398: Improve tooltip configuration for better accessibility and user experience

The current tooltip implementation could be enhanced for better accessibility and user experience, especially considering the discussions about visibility preferences mentioned in the PR objectives.

Consider adding a delay to the tooltip to prevent it from appearing too quickly when users hover over the button unintentionally:

<Tooltip
  style={{
    ...styles.tooltip,
    marginBottom: 10,
  }}
  content={
    account?.last_reconciled
      ? `${t('Reconciled')} ${tsToRelativeTime(account.last_reconciled, language || 'en-US')}`
      : t('Not yet reconciled')
  }
  placement="top start"
+ delay={500}
  triggerProps={{
    isDisabled: reconcileOpen,
  }}
>

391-392: Ensure consistent translation approach for reconciliation timestamp display

While the implementation correctly uses the translation function for static text, the combined message could be improved to ensure proper localization.

Consider using a translation parameter instead of string concatenation to allow for different sentence structures in different languages:

content={
  account?.last_reconciled
-   ? `${t('Reconciled')} ${tsToRelativeTime(account.last_reconciled, language || 'en-US')}`
+   ? t('Reconciled {{timeAgo}}', { 
+       timeAgo: tsToRelativeTime(account.last_reconciled, language || 'en-US') 
+     })
    : t('Not yet reconciled')
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5347320 and 6f0d8d2.

📒 Files selected for processing (3)
  • packages/desktop-client/src/components/accounts/Balance.tsx (1 hunks)
  • packages/desktop-client/src/components/accounts/Header.tsx (5 hunks)
  • packages/loot-core/src/shared/util.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/desktop-client/src/components/accounts/Balance.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Functional
  • GitHub Check: Visual regression
  • GitHub Check: build (windows-latest)
  • GitHub Check: Analyze
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (2)
packages/loot-core/src/shared/util.ts (1)

2-3: Optimize bundle size by importing specific date-fns locales

Following up on the previous review, importing all locales from 'date-fns/locale' will significantly increase your bundle size. Since we can see you're using it selectively based on language in the tsToRelativeTime function, you should consider importing only the specific locales needed.

import { formatDistanceToNow } from 'date-fns';
-import * as locales from 'date-fns/locale';
+// Import only the locales you need or use dynamic imports
+import { enUS } from 'date-fns/locale';
+// Other commonly used locales can be imported as needed

If you need to support multiple locales dynamically, consider implementing a more efficient approach such as dynamic imports or a locale registry pattern.

packages/desktop-client/src/components/accounts/Header.tsx (1)

384-425: Implementation successfully addresses the PR objectives

The tooltip implementation provides an elegant solution to show the reconciliation status without cluttering the interface. This aligns well with the discussion points in the PR comments, where users expressed concerns about constant visibility and preferences for more flexible solutions.

The tooltip approach provides:

  1. Information about reconciliation status that's discoverable but not always visible
  2. A non-intrusive way to display the timestamp
  3. Localized relative time formatting that's easily understood

This implementation balances visibility and minimalism effectively, addressing the concerns raised in the PR discussion.

@tostasmistas tostasmistas force-pushed the feat/accounts-last-reconciled branch from 6f0d8d2 to d131dde Compare March 3, 2025 14:03
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/loot-core/src/shared/util.ts (1)

488-499: Improve error handling and type safety in the new timestamp utility

The current implementation works for valid timestamps but could be improved with better error handling and type safety.

export function tsToRelativeTime(ts: string | null, language: string): string {
  if (!ts) return 'Unknown';

-  const parsed = new Date(parseInt(ts, 10));
+  try {
+    const timestamp = parseInt(ts, 10);
+    
+    // Check if the parsed timestamp is valid
+    if (isNaN(timestamp)) {
+      return 'Invalid date';
+    }
+    
+    const parsed = new Date(timestamp);
+    
+    // Normalize language code to match date-fns locale format
+    const localeKey = language.replace('-', '') as keyof typeof locales;
+    const locale = locales[localeKey] ?? locales['enUS'];
-  const locale =
-    locales[language.replace('-', '') as keyof typeof locales] ??
-    locales['enUS'];

-  return formatDistanceToNow(parsed, { addSuffix: true, locale });
+    return formatDistanceToNow(parsed, { addSuffix: true, locale });
+  } catch (error) {
+    console.error('Error formatting relative time:', error);
+    return 'Unknown';
+  }
}

This implementation:

  1. Adds a try/catch block to handle any unexpected errors
  2. Validates the parsed timestamp before creating a Date object
  3. Improves code readability
  4. Provides better error recovery
packages/desktop-client/src/components/accounts/Header.tsx (1)

390-393: Consider adding fallback text for internationalization

The conditional rendering for the tooltip content is good, but should provide a fallback for missing translations.

content={
  account?.last_reconciled
-    ? `${t('Reconciled')} ${tsToRelativeTime(account.last_reconciled, language || 'en-US')}`
-    : t('Not yet reconciled')
+    ? `${t('Reconciled', 'Reconciled')} ${tsToRelativeTime(account.last_reconciled, language || 'en-US')}`
+    : t('Not yet reconciled', 'Not yet reconciled')
}

This ensures that even if translations are missing, the user will still see readable text.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6f0d8d2 and d131dde.

📒 Files selected for processing (3)
  • packages/desktop-client/src/components/accounts/Balance.tsx (1 hunks)
  • packages/desktop-client/src/components/accounts/Header.tsx (4 hunks)
  • packages/loot-core/src/shared/util.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/desktop-client/src/components/accounts/Balance.tsx
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: Analyze
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (4)
packages/loot-core/src/shared/util.ts (1)

2-3: Bundle size optimization needed for date-fns imports

The current implementation imports all locales from date-fns, which will significantly increase bundle size.

Per the previous review comment, instead of importing all locales, consider importing only the specific locales needed or implement dynamic imports to improve tree-shaking and reduce bundle size.

import { formatDistanceToNow } from 'date-fns';
-import * as locales from 'date-fns/locale';
+// Import only specific locales that are needed
+import { enUS, de, fr } from 'date-fns/locale';
+
+// Create a map of supported locales
+const supportedLocales: Record<string, Locale> = { enUS, de, fr };
packages/desktop-client/src/components/accounts/Header.tsx (3)

17-17: LGTM! Appropriate imports for the new functionality.

The imports are correctly added to support the tooltip functionality and relative time display.

Also applies to: 20-20, 28-28


191-192: LGTM! Clean implementation of language preference.

Using useGlobalPref('language') is the appropriate way to access user language settings for localization.


382-426: Good improvement to the reconciliation UX with tooltip

This tooltip implementation provides valuable context about reconciliation status to users, making the feature more intuitive and informative.

The tooltip is well-implemented with:

  • Clear conditional content based on reconciliation status
  • Proper positioning above the button
  • Appropriate disabling when the reconciliation menu is open

One small suggestion to consider: add a simple fade-in animation to make the tooltip appearance more polished.

relocate the "last reconciled" timestamp from the account balances header to a tooltip displayed when hovering over the "Reconcile" button
@tostasmistas tostasmistas force-pushed the feat/accounts-last-reconciled branch from d131dde to 7b263f7 Compare March 3, 2025 14:13
@tostasmistas tostasmistas requested a review from matt-fidd March 3, 2025 14:26
@lelemm
Copy link
Contributor

lelemm commented Mar 3, 2025

Since this uses locales would be good to use the hook useLocale from this PR #4211

Copy link
Member

@youngcw youngcw left a comment

Choose a reason for hiding this comment

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

I like the new location better. Ill let the others decide if we need to wait for @lelemm's PR first.

Copy link
Contributor

@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.

I like the tooltip.

I don't think we should block this for now, when lelemm's change goes in we can refactor with the new function if needed.

@youngcw youngcw merged commit 5ebbff4 into actualbudget:master Mar 3, 2025
21 checks passed
@tostasmistas tostasmistas deleted the feat/accounts-last-reconciled branch March 4, 2025 09:02
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.

[Feature] Display "last reconcilation timestamp" for each account
6 participants