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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tostasmistas
Copy link

@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 49be922
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/67c09fa180c28b0008c09354
😎 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.07 MB → 8.04 MB (+994.8 kB) +13.75%
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/wide.js 102.9 kB → 1.07 MB (+994.8 kB) +966.78%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/es.js 60.58 kB 0%
static/js/en.js 103.18 kB 0%
static/js/nl.js 97.78 kB 0%
static/js/en-GB.js 98.67 kB 0%
static/js/de.js 114.35 kB 0%
static/js/fr.js 88.87 kB 0%
static/js/pt-BR.js 112.83 kB 0%
static/js/uk.js 111.11 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/useAccountPreviewTransactions.js 1.69 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/AppliedFilters.js 10.8 kB 0%
static/js/narrow.js 86.23 kB 0%
static/js/ReportRouter.js 1.59 MB 0%
static/js/index.js 4.35 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/server/accounts/app.ts 📈 +88 B (+0.37%) 23.33 kB → 23.41 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 from 2ad3da4 to 5eaaf45 Compare February 27, 2025 16:58
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
@tostasmistas tostasmistas force-pushed the feat/accounts-last-reconciled branch 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

Walkthrough

The changes integrate tracking and error handling for account reconciliation across multiple areas of the codebase. In the desktop client, the reconciliation process now includes additional error checks to ensure the existence of an account and updates its last_reconciled timestamp when the process is successfully completed. A new helper function converts timestamps into relative time, and UI components have been updated to display reconciliation information. In the backend, the account data model and schema have been extended with a new last_reconciled field, and a corresponding SQL migration modifies the database schema to support this addition. Mocks for offline accounts have also been updated to include the reconciliation timestamp, while the updateAccount function in the server now conditionally handles the new parameter.

Possibly related PRs

Suggested labels

:sparkles: Merged

Suggested reviewers

  • youngcw
  • jfdoming

📜 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 51a53f6 and 49be922.

📒 Files selected for processing (1)
  • packages/loot-core/src/mocks/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/loot-core/src/mocks/index.ts
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Functional
  • GitHub Check: Visual regression
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: Analyze

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.

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
locales[language.replace('-', '') as keyof typeof locales] ??
locales['enUS'];

return formatDistanceToNow(parsed, { addSuffix: true, locale });
Copy link
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".

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
1 participant