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

Extract transaction related server handlers from main.ts to server/transactions/app.ts #4221

Merged
merged 12 commits into from
Feb 19, 2025

Conversation

joel-jeremy
Copy link
Contributor

@joel-jeremy joel-jeremy commented Jan 22, 2025

Related to #1113

@actual-github-bot actual-github-bot bot changed the title Move transaction related handlers to server/transactions folder and use the new convention [WIP] Move transaction related handlers to server/transactions folder and use the new convention Jan 22, 2025
Copy link

netlify bot commented Jan 22, 2025

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 12c782c
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/67b60ac70e9c4f00088aa60c
😎 Deploy Preview https://deploy-preview-4221.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 Jan 22, 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
17 6.94 MB 0%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/server/rules/index.ts 🆕 +13.75 kB 0 B → 13.75 kB
home/runner/work/actual/actual/packages/loot-core/src/server/accounts/rules.ts 🔥 -13.75 kB (-100%) 13.75 kB → 0 B
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/en.js 100.65 kB 0%
static/js/en-GB.js 99.42 kB 0%
static/js/de.js 111.72 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/fr.js 72.19 kB 0%
static/js/nl.js 98.54 kB 0%
static/js/pt-BR.js 106.43 kB 0%
static/js/uk.js 111.11 kB 0%
static/js/useAccountPreviewTransactions.js 1.69 kB 0%
static/js/AppliedFilters.js 10.52 kB 0%
static/js/wide.js 102.8 kB 0%
static/js/narrow.js 85.57 kB 0%
static/js/ReportRouter.js 1.59 MB 0%
static/js/index.js 4.31 MB 0%

Copy link
Contributor

github-actions bot commented Jan 22, 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.33 MB → 1.33 MB (+49 B) +0.00%
Changeset
File Δ Size
packages/loot-core/src/server/rules/index.ts 🆕 +34.58 kB 0 B → 34.58 kB
packages/loot-core/src/server/transactions/transaction-rules.ts 🆕 +31.96 kB 0 B → 31.96 kB
packages/loot-core/src/server/transactions/index.ts 🆕 +5.63 kB 0 B → 5.63 kB
packages/loot-core/src/server/transactions/transfer.ts 🆕 +5.15 kB 0 B → 5.15 kB
packages/loot-core/src/server/transactions/import/ofx2json.ts 🆕 +4.52 kB 0 B → 4.52 kB
packages/loot-core/src/server/transactions/import/parse-file.ts 🆕 +4.22 kB 0 B → 4.22 kB
packages/loot-core/src/server/transactions/import/xmlcamt2json.ts 🆕 +3.76 kB 0 B → 3.76 kB
packages/loot-core/src/server/transactions/export/export-to-csv.ts 🆕 +3.57 kB 0 B → 3.57 kB
packages/loot-core/src/server/transactions/import/qif2json.ts 🆕 +2.63 kB 0 B → 2.63 kB
packages/loot-core/src/server/transactions/app.ts 🆕 +2.24 kB 0 B → 2.24 kB
packages/loot-core/src/server/api.ts 📈 +28 B (+0.13%) 21.07 kB → 21.1 kB
packages/loot-core/src/server/filters/app.ts 📈 +4 B (+0.08%) 4.76 kB → 4.77 kB
packages/loot-core/src/server/accounts/sync.ts 📈 +15 B (+0.05%) 27.8 kB → 27.82 kB
packages/loot-core/src/server/schedules/find-schedules.ts 📈 +4 B (+0.03%) 11.35 kB → 11.36 kB
packages/loot-core/src/server/schedules/app.ts 📉 -5 B (-0.03%) 15.67 kB → 15.67 kB
packages/loot-core/src/shared/schedules.ts 📉 -9 B (-0.07%) 12.53 kB → 12.52 kB
packages/loot-core/src/server/tools/app.ts 📉 -9 B (-0.27%) 3.26 kB → 3.25 kB
packages/loot-core/src/server/rules/app.ts 📉 -12 B (-0.34%) 3.41 kB → 3.4 kB
packages/loot-core/src/server/main.ts 📉 -1.69 kB (-2.42%) 69.76 kB → 68.07 kB
packages/loot-core/src/server/accounts/rules.ts 🔥 -34.58 kB (-100%) 34.58 kB → 0 B
packages/loot-core/src/server/accounts/transaction-rules.ts 🔥 -31.97 kB (-100%) 31.97 kB → 0 B
packages/loot-core/src/server/accounts/transactions.ts 🔥 -5.63 kB (-100%) 5.63 kB → 0 B
packages/loot-core/src/server/accounts/transfer.ts 🔥 -5.15 kB (-100%) 5.15 kB → 0 B
packages/loot-core/src/server/accounts/ofx2json.ts 🔥 -4.52 kB (-100%) 4.52 kB → 0 B
packages/loot-core/src/server/accounts/parse-file.ts 🔥 -4.22 kB (-100%) 4.22 kB → 0 B
packages/loot-core/src/server/accounts/xmlcamt2json.ts 🔥 -3.76 kB (-100%) 3.76 kB → 0 B
packages/loot-core/src/server/accounts/export-to-csv.ts 🔥 -3.56 kB (-100%) 3.56 kB → 0 B
packages/loot-core/src/server/accounts/qif2json.ts 🔥 -2.63 kB (-100%) 2.63 kB → 0 B
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
kcab.worker.js 1.33 MB → 1.33 MB (+49 B) +0.00%

Smaller

No assets were smaller

Unchanged

No assets were unchanged

@joel-jeremy joel-jeremy changed the title [WIP] Move transaction related handlers to server/transactions folder and use the new convention [WIP] Move transaction related server handlers to server/transactions folder and use the new convention Jan 23, 2025
@joel-jeremy joel-jeremy force-pushed the server-transaction-handlers branch from 1761118 to 1541fbd Compare January 23, 2025 16:58
@@ -108,56 +106,6 @@ handlers['redo'] = mutator(function () {
return redo();
});

handlers['transactions-batch-update'] = mutator(async function ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These have been moved to server/transactions/app.ts

@joel-jeremy joel-jeremy changed the title [WIP] Move transaction related server handlers to server/transactions folder and use the new convention [WIP] Move transaction related server handlers from main.ts to server/transactions/app.ts folder and use the new convention Jan 23, 2025
@joel-jeremy joel-jeremy changed the title [WIP] Move transaction related server handlers from main.ts to server/transactions/app.ts folder and use the new convention [WIP] Move transaction related server handlers from main.ts to server/transactions/app.ts Jan 23, 2025
@joel-jeremy joel-jeremy force-pushed the server-transaction-handlers branch from 319ed57 to 941adf3 Compare January 23, 2025 21:38
Copy link
Contributor

👋 Hi! It looks like this PR has not had any changes for a week now. Would you like someone to review this PR? If so - please remove the "[WIP]" prefix from the PR title. That will let the community know that this PR is open for a review.

@github-actions github-actions bot added the Stale label Jan 31, 2025
Copy link
Contributor

github-actions bot commented Feb 5, 2025

This PR was closed because it has been stalled for 5 days with no activity.

Copy link
Contributor

👋 Hi! It looks like this PR has not had any changes for a week now. Would you like someone to review this PR? If so - please remove the "[WIP]" prefix from the PR title. That will let the community know that this PR is open for a review.

@github-actions github-actions bot added the Stale label Feb 13, 2025
@joel-jeremy joel-jeremy removed the Stale label Feb 13, 2025
@joel-jeremy joel-jeremy force-pushed the server-transaction-handlers branch from 260bdbe to 19e23f4 Compare February 18, 2025 22:11
@joel-jeremy joel-jeremy force-pushed the server-transaction-handlers branch from 19e23f4 to 275cc02 Compare February 18, 2025 23:12
@joel-jeremy joel-jeremy changed the title [WIP] Move transaction related server handlers from main.ts to server/transactions/app.ts Move transaction related server handlers from main.ts to server/transactions/app.ts Feb 19, 2025
@joel-jeremy joel-jeremy changed the title Move transaction related server handlers from main.ts to server/transactions/app.ts Extract transaction related server handlers from main.ts to server/transactions/app.ts Feb 19, 2025
Copy link
Contributor

coderabbitai bot commented Feb 19, 2025

Warning

Rate limit exceeded

@joel-jeremy has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 41 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 77084d5 and 12c782c.

📒 Files selected for processing (1)
  • packages/loot-core/src/server/transactions/import/parse-file.test.ts (9 hunks)

Walkthrough

The pull request refactors the transaction management system by standardizing module imports and consolidating transaction-related functionalities. Multiple files across the project have been updated to replace legacy import paths (e.g., from accounts/transaction-rules or local paths) with unified paths under the transactions module. Changes include updates to test setups, API endpoint signatures (such as adding an accounts parameter for exports), schedule handlers, and transaction import/export modules. Additionally, obsolete transaction handlers have been removed and replaced with new, modular implementations. These updates aim to improve code organization and consistency without altering the core business logic.

Possibly related PRs

Suggested labels

:sparkles: Merged

Suggested reviewers

  • MikesGlitch
  • youngcw

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. (Beta)
  • @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 (10)
packages/loot-core/src/server/transactions/app.ts (5)

1-17: Consider adding dedicated error handling for imports.
All imports look correct, but there is no centralized error handling if any of these modules fail to load or return unexpected results. For greater robustness, consider a try/catch mechanism around critical imports or validations if these imports are loaded dynamically at runtime (e.g., in serverless environments).


29-43: Add explicit error handling in handleBatchUpdateTransactions.
Currently, this function directly calls batchUpdateTransactions and returns the result. If batchUpdateTransactions throws or returns an unexpected error, it might bubble up unhandled. Consider wrapping the call in a try/catch block or verifying the shape of the returned data to provide clearer error context to consumers.


50-53: Add return data for better user feedback.
While the current pattern returns an empty object, returning newly updated transaction data or success confirmation can enhance the API's usability.


55-58: Consider clarifying delete semantics.
When deleting a transaction, confirm the user truly intends permanent removal. Some systems prefer “soft delete” flags. If that logic is handled downstream, clarifying in-line doc comments here may help future maintainers.


70-82: Exporting CSV structure is straightforward and clear.
The code is straightforward, effectively encapsuling the call to exportToCSV. Ensure large exports are handled efficiently or streamed if file sizes can be massive.

packages/loot-core/src/server/transactions/parse-file.ts (4)

1-3: Maintain type safety instead of @ts-strict-ignore.
If possible, address the underlying TypeScript issues that necessitate @ts-strict-ignore. This ensures stronger type guarantees and helps catch potential runtime issues at compile time.


7-9: Effective separation of import libraries.
Encapsulating specialized import logic (./import/ofx2json, etc.) clarifies the code. Consider documenting the differences among these file formats (QIF, OFX, etc.) for new maintainers.


17-22: Make ParseFileOptions more self-documenting.
Fields like skipLines and hasHeaderRow are helpful. Consider adding clarifying docstrings if usage in other modules becomes more complex.


120-155: parseOFX fallback approach is a nice touch.
Using memo fields when payee data is missing can save data. For user clarity, consider logging a warning if fallback is used frequently.

packages/loot-core/src/server/transactions/export/export-to-csv.ts (1)

13-16: Consider memoizing the ID-to-name mappings.

The reduce operations to create lookup maps could benefit from memoization if the account, category, or payee data rarely changes during export.

+const memoize = <T, R>(fn: (data: T) => R): ((data: T) => R) => {
+  let cache: R | null = null;
+  let lastInput: T | null = null;
+  return (data: T) => {
+    if (lastInput === data) return cache!;
+    lastInput = data;
+    cache = fn(data);
+    return cache;
+  };
+};
+
+const createAccountNamesById = memoize((accounts) =>
   accounts.reduce((reduced, { id, name }) => {
     reduced[id] = name;
     return reduced;
   }, {})
+);
+
+const createCategoryNamesById = memoize((categoryGroups) =>
   categoryGroups.reduce(
     (reduced, { name, categories: subCategories }) => {
       subCategories.forEach(
         subCategory =>
           (reduced[subCategory.id] = `${name}: ${subCategory.name}`),
       );
       return reduced;
     },
     {},
   )
+);
+
+const createPayeeNamesById = memoize((payees) =>
   payees.reduce((reduced, { id, name }) => {
     reduced[id] = name;
     return reduced;
   }, {})
+);

Also applies to: 18-27, 29-32

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a4d3f27 and 77084d5.

⛔ Files ignored due to path filters (4)
  • packages/loot-core/src/server/transactions/__snapshots__/transaction-rules.test.ts.snap is excluded by !**/*.snap
  • packages/loot-core/src/server/transactions/__snapshots__/transfer.test.ts.snap is excluded by !**/*.snap
  • packages/loot-core/src/server/transactions/import/__snapshots__/parse-file.test.ts.snap is excluded by !**/*.snap
  • upcoming-release-notes/4221.md is excluded by !**/*.md
📒 Files selected for processing (26)
  • packages/loot-core/src/mocks/setup.ts (1 hunks)
  • packages/loot-core/src/server/accounts/sync.test.ts (1 hunks)
  • packages/loot-core/src/server/accounts/sync.ts (1 hunks)
  • packages/loot-core/src/server/api.ts (1 hunks)
  • packages/loot-core/src/server/filters/app.ts (1 hunks)
  • packages/loot-core/src/server/main.test.ts (2 hunks)
  • packages/loot-core/src/server/main.ts (3 hunks)
  • packages/loot-core/src/server/rules/app.ts (1 hunks)
  • packages/loot-core/src/server/rules/index.test.ts (1 hunks)
  • packages/loot-core/src/server/rules/types/handlers.ts (1 hunks)
  • packages/loot-core/src/server/schedules/app.test.ts (1 hunks)
  • packages/loot-core/src/server/schedules/app.ts (1 hunks)
  • packages/loot-core/src/server/schedules/find-schedules.ts (1 hunks)
  • packages/loot-core/src/server/tools/app.ts (1 hunks)
  • packages/loot-core/src/server/transactions/app.ts (1 hunks)
  • packages/loot-core/src/server/transactions/export/export-to-csv.ts (1 hunks)
  • packages/loot-core/src/server/transactions/import/ofx2json.ts (1 hunks)
  • packages/loot-core/src/server/transactions/import/parse-file.test.ts (9 hunks)
  • packages/loot-core/src/server/transactions/import/parse-file.ts (2 hunks)
  • packages/loot-core/src/server/transactions/index.ts (1 hunks)
  • packages/loot-core/src/server/transactions/parse-file.ts (1 hunks)
  • packages/loot-core/src/server/transactions/transaction-rules.ts (2 hunks)
  • packages/loot-core/src/shared/schedules.ts (1 hunks)
  • packages/loot-core/src/types/api-handlers.d.ts (2 hunks)
  • packages/loot-core/src/types/handlers.d.ts (2 hunks)
  • packages/loot-core/src/types/server-handlers.d.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/loot-core/src/types/server-handlers.d.ts
✅ Files skipped from review due to trivial changes (7)
  • packages/loot-core/src/server/transactions/index.ts
  • packages/loot-core/src/shared/schedules.ts
  • packages/loot-core/src/server/rules/index.test.ts
  • packages/loot-core/src/server/filters/app.ts
  • packages/loot-core/src/server/transactions/transaction-rules.ts
  • packages/loot-core/src/server/accounts/sync.ts
  • packages/loot-core/src/server/accounts/sync.test.ts
🧰 Additional context used
🧠 Learnings (2)
packages/loot-core/src/server/schedules/app.test.ts (1)
Learnt from: jfdoming
PR: actualbudget/actual#3641
File: packages/loot-core/src/server/accounts/rules.test.ts:524-536
Timestamp: 2024-11-10T16:45:25.627Z
Learning: In `packages/loot-core/src/server/accounts/rules.test.ts`, prefer explicit action definitions over refactoring similar actions into loops or helper functions, even when actions are similar.
packages/loot-core/src/server/rules/app.ts (1)
Learnt from: jfdoming
PR: actualbudget/actual#3641
File: packages/loot-core/src/server/accounts/rules.test.ts:524-536
Timestamp: 2024-11-10T16:45:25.627Z
Learning: In `packages/loot-core/src/server/accounts/rules.test.ts`, prefer explicit action definitions over refactoring similar actions into loops or helper functions, even when actions are similar.
🔇 Additional comments (32)
packages/loot-core/src/server/transactions/import/ofx2json.ts (1)

4-4: LGTM! Import path updated correctly.

The import path adjustment aligns with the PR's objective of reorganizing transaction-related code. The new path correctly reflects the module's location after the restructuring.

packages/loot-core/src/server/transactions/app.ts (6)

18-27: Great introduction of TransactionHandlers type.
This strongly typed approach provides clarity on accepted transaction handler methods. It cleanly associates string-based keys to their respective functions, reducing confusion and improving maintainability.


45-48: Ensure rollback or partial-failure handling when adding a new transaction.
If handleBatchUpdateTransactions fails mid-operation, consider whether you need a rollback or transaction-based approach to avoid inserting partial state.


60-68: Good approach to wrapping parseFile.
Delegating to the specialized parseFile keeps file logic separated, making it easier to maintain. Adding explicit input validation (e.g., checking filepath existence upfront) could be beneficial if not already guaranteed upstream.


84-90: exportTransactionsQuery usage is nicely modular.
Returning exportQueryToCSV(new Query(queryState)) is neat and remains consistent with existing design patterns. No immediate concerns.


92-101: Validate the shape of data in getEarliestTransaction.
The code extracts data[0] directly. If an empty array is returned from the query, you return null, which is good. However, consider logging or tackling unexpected shapes (e.g., if data is undefined or not an array) for defensive coding.


103-116: Modular design for transaction methods.
Registering each transaction method to the app fosters maintainability. Verify that all undo operations and mutators handle errors consistently across all routes.

packages/loot-core/src/server/transactions/parse-file.ts (6)

4-5: Local filesystem usage is consistent.
Confirm that ../../platform/server/fs usage is valid in your deployment environment. Some serverless or container-based deployments might lack guaranteed local disk access.


11-15: Great structured result type.
The ParseFileResult type, containing both errors and transactions, is a good approach for returning partial data even if parsing fails.


24-54: parseFile error states handled well.
The function calls relevant parse routines based on file extension and returns structured errors if unrecognized. Confirm that returning [ ] for transactions when errors occur is acceptable so the system does not mistakenly treat the result as a valid parse of an empty file.


56-90: CSV parse logic is robust.
The usage of csv-parse/lib/sync is straightforward. Double-check performance for large CSV files. The skipLines support is a great addition.


91-119: QIF parse gracefully handles partial data.
Loosely parsing amounts via looselyParseAmount is flexible. If you anticipate locale-specific formatting, confirm the function’s approach to decimal separators is correct.


157-174: parseCAMT coverage.
Make sure any bank-specific CAMT variations are handled or documented if some fields differ. The usage of catch (err) and returning partial data is consistent.

packages/loot-core/src/server/main.ts (3)

18-18: Verify usage of q import.
Line 18 shows re-importing { q }. Confirm that no references implicitly use a previously declared q from other modules.


72-73: Good modular approach with transactionsApp.
Re-locating transaction logic into transactions/app can reduce clutter. This is in line with the PR’s goals of reorganizing transaction handlers.


2392-2392: Combined app usage.
Adding transactionsApp to the final app.combine(...) call is consistent with the refactor. This helps keep all new handlers in a unified location.

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

11-11: LGTM! Changes align with transaction handlers refactoring.

The addition of TransactionHandlers to the Handlers interface and its import from the new location ../server/transactions/app properly reflects the reorganization of transaction-related functionality.

Also applies to: 27-27

packages/loot-core/src/server/rules/types/handlers.ts (1)

2-2: LGTM! Import path updated for consistency.

The import path for Action type has been simplified and aligns with the new module structure.

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

7-7:

❓ Verification inconclusive

LGTM! Verify consistent usage of new import path.

The import path for batchUpdateTransactions has been updated to reflect the new module structure.

Let's verify that all imports of batchUpdateTransactions use the new path consistently:


🏁 Script executed:

#!/bin/bash
# Search for any remaining old import paths
rg "from '\.\./accounts/transactions'" -l

# Search for usage of new import path
rg "from '\.\./transactions'" -l

Length of output: 90


Please verify the consistent usage of the new batchUpdateTransactions import path

The updated import from '../transactions' appears to be in use since no references to the old path '../accounts/transactions' were found. However, the search output didn’t yield detailed results for the new path either. Please perform a manual check in the codebase to ensure that all occurrences of batchUpdateTransactions are importing from the correct module.

  • Confirm that files importing batchUpdateTransactions reference '../transactions' and not the old path.
  • Re-run the searches with additional context if needed to verify no regressions exist.
packages/loot-core/src/server/transactions/export/export-to-csv.ts (1)

4-5: LGTM! Import paths correctly adjusted.

The import paths have been updated to reflect the new file location in the directory structure.

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

7-7: LGTM! Import paths updated correctly.

The import path changes align with the PR objective of reorganizing transaction-related code, maintaining the same functionality while improving code organization.

Also applies to: 12-12

packages/loot-core/src/mocks/setup.ts (1)

14-14: LGTM! Import path updated consistently.

The import path change aligns with the broader codebase reorganization.

packages/loot-core/src/server/transactions/import/parse-file.ts (1)

4-5: LGTM! Import paths updated and type visibility improved.

The changes maintain functionality while:

  1. Updating import paths to reflect the new directory structure
  2. Making ParseFileOptions type exportable, improving module reusability

Also applies to: 17-17

packages/loot-core/src/server/transactions/import/parse-file.test.ts (1)

4-8: LGTM! Import and test file paths updated correctly.

All paths have been updated to reflect the new directory structure while maintaining the same test functionality.

Also applies to: 67-67, 80-80, 92-92, 104-104, 116-116, 122-122, 138-138, 151-151, 164-164

packages/loot-core/src/types/api-handlers.d.ts (2)

10-10: LGTM! Import path updated to match new module structure.

The import path change aligns with the PR objective of moving transaction-related handlers to server/transactions/app.ts.


75-80:

❓ Verification inconclusive

Verify the impact of adding the accounts parameter.

The addition of the accounts parameter to the export method's argument type suggests that account data is now required during export.

Run the following script to verify the usage of the new parameter:


🏁 Script executed:

#!/bin/bash
# Description: Verify that all calls to `api/transactions-export` include the new `accounts` parameter.

# Test: Search for function calls. Expect: All calls include the `accounts` parameter.
rg -A 5 $'api/transactions-export'

Length of output: 33


Manual Verification Required: Update & Confirm accounts Parameter Usage

The change adding the accounts parameter to the export API suggests that calls to api/transactions-export should now supply account data. A preliminary search using:

rg -A 5 'api/transactions-export'

returned no output, which means we couldn't confirm whether calls to this API include the new parameter. Please do one of the following:

  • Manually verify that all invocations of api/transactions-export in the codebase now pass the accounts parameter.
  • Consider expanding the search scope or re-running the command in affected modules to ensure that no call sites are missed.

Once confirmed, update any necessary usage or tests accordingly.

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

8-8: LGTM! Import path updated to match new module structure.

The import path change aligns with the PR objective of moving transaction-related handlers to server/transactions/app.ts.

packages/loot-core/src/server/schedules/find-schedules.ts (1)

13-13: LGTM! Import path updated to match new module structure.

The import path change aligns with the PR objective of moving transaction-related handlers to server/transactions/app.ts.

packages/loot-core/src/server/main.test.ts (2)

3-3: LGTM! Added UUID generation for unique transaction IDs.

The import of uuidv4 from the uuid package is a good practice for generating unique identifiers.


179-180: LGTM! Using UUID for transaction ID in test case.

Using uuidv4() ensures unique transaction IDs in test cases, which is a good practice.

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

26-33: LGTM! Import paths updated to reflect the new module organization.

The import path changes align with the PR objectives to move transaction-related code to a dedicated module. The changes are consistent and maintain the functionality while improving code organization.

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

460-473: LGTM! Enhanced transaction export functionality with account information.

The addition of the accounts parameter to the transactions-export handler is consistent and maintains backward compatibility.

@matt-fidd matt-fidd self-assigned this Feb 19, 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.

LGTM!

@joel-jeremy joel-jeremy merged commit 8d3b046 into master Feb 19, 2025
21 checks passed
@joel-jeremy joel-jeremy deleted the server-transaction-handlers branch February 19, 2025 23:57
lelemm added a commit to lagoom-br/actual that referenced this pull request Feb 20, 2025
* 🐛  Fix Initializing the connection to the local database hang (actualbudget#4375)

* fix initializing to the local db

* release notes

* Add percentage adjustments to schedule templates (actualbudget#4098) (actualbudget#4257)

* add percentage adjustments to schedule templates

* update release note

* remove unecessary parentheses

* Update packages/loot-core/src/server/budget/goalsSchedule.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* PR comments addressed

* Linting fixes

* Updated error handling, added tests

* Linting fixes

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: youngcw <calebyoung94@gmail.com>

* Custom mapping and import settings for bank sync providers (actualbudget#4253)

* barebones UI

* add saving and prefs

* add last sync functionality

* use mapping for synced transactions

* note

* jest -u

* Update VRT

* Coderabbit

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* add new fields

* rename migration, newer in master

* lint

* coderabbit

* update snapshots

* GoCardless handlers fallback and notes

* expose new fields from SimpleFIN

* update tests

* update instructions on GoCardless handlers

* lint

* feedback

* Update VRT

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: youngcw <calebyoung94@gmail.com>

* Add fallback value for payeename: 'undefined' - CBC Bank (actualbudget#4384)

* Add fallback value for payename: 'undefined'

* docs: add release note

* Add fallback value for payename: 'undefined' (for negative amounts)

* [TypeScript] Convert test page models to TS (actualbudget#4218)

* Dummy commit

* Delete js snapshots

* Move extended expect and test to fixtures

* Fix wrong commit

* Update VRT

* Dummy commit to run GH actions

* Convert test page models to TS

* Release notes

* Fix typecheck errors

* New page models to TS

* Fix typecheck error

* Fix page name

* Put awaits on getTableTotals

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* rename two migrations to realign with convention (actualbudget#4343)

* Updating sync server package name to @actual-app/sync-server (actualbudget#4370)

* updating sync server to have a consistent package name

* release notes

* Add today button on mobile budget page (actualbudget#4380)

* feat: today button on mobile budget page

Jumps to the current month

* add release note

* cleaner onCurrentMonth

* Update VRT

* use SvgCalendar from icons/v2

Co-authored-by: Matt Fiddaman <github@m.fiddaman.uk>

* Update VRT

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Fiddaman <github@m.fiddaman.uk>

* Development mode for sync server (React Fast Refresh on port 5006) (actualbudget#4372)

* devmode for sync server

* removed pluggy from this version

* md

* code review

* changed how open browser

* missed this

* linter

* trigger actions

* 🐛 Fix: Error rate limit at user directory page (actualbudget#4397)

* Error rate limit

* md

* 🐛 Fix new proxy middleware dependency missing on prod build (actualbudget#4400)

* fix new proxy middleware not installed on prod build

* release notes

* Remove deprecated imports for several components (actualbudget#4385)

* don't unbudget goals

* lint

* Fixes actualbudget#4069 : Ignore CSV inOutMode during OFX imports (actualbudget#4382)

* Ignore inOutMode during OFX imports

* Add release notes

---------

Co-authored-by: youngcw <calebyoung94@gmail.com>

* fix tooltip translation (actualbudget#4402)

* [TypeScript] Make `db.runQuery` generic to make it easy to type DB query results (actualbudget#4247)

* Make runQuery generic to make it easy to type DB query results.

* Release notes

* typo

* update mapping data for existing synced transactions and always show direction dropdown (actualbudget#4403)

* update sync mapping data for existing transactions on sync

* show payment direction dropdown regardless of sample data

* note

* ignore changes in raw_synced_data

* Fix top-level types of `send` function (actualbudget#4145)

* Add release notes

* Fix types of `send` function

* Fix `send` types in a number of places

* PR feedback

* Foundations for the budget automations UI (actualbudget#4308)

* Foundations for the budget automations UI

* Coderabbit

* Fix react-hooks/exhaustive-deps error on useSelected.tsx (actualbudget#4258)

* Fix react-hooks/exhaustive-deps error on useSelected.tsx

* Release notes

* Fix react-hooks/exhaustive-deps error on usePayees.ts (actualbudget#4260)

* Fix react-hooks/exhaustive-deps error on usePayees.ts

* Rename

* Release notes

* Fix react-hooks/exhaustive-deps error on useAccounts.ts (actualbudget#4262)

* Fix react-hooks/exhaustive-deps error on useAccounts.ts

* Release notes

* Fix react-hooks/exhaustive-deps error on Titlebar.tsx (actualbudget#4273)

* Fix react-hooks/exhaustive-deps error on Titlebar.tsx

* Release notes

* [WIP] BANKS_WITH_LIMITED_HISTORY constant update (actualbudget#4388)

* Fix react-hooks/exhaustive-deps error on useProperFocus.tsx (actualbudget#4259)

* Fix react-hooks/exhaustive-deps error on useProperFocus.tsx

* Remove comment in eslint config

* Release notes

* Fix react-hooks/exhaustive-deps error on TransactionsTable.jsx (actualbudget#4268)

* Fix react-hooks/exhaustive-deps error on TransactionsTable.jsx

* Release notes

* Fix lint

* Fix react-hooks/exhaustive-deps error on table.tsx (actualbudget#4274)

* Fix react-hooks/exhaustive-deps error on table.tsx

* Release notes

* Fix react-hooks/exhaustive-deps error on useCategories.ts (actualbudget#4261)

* Fix react-hooks/exhaustive-deps error on useCategories.ts

* Release notes

* 👷 Typescript: Improving typing of asyncStorage (global-store.json) (actualbudget#4369)

* typing globalprefs

* adding release notes

* unneeded partial

* removing prop that crept in

* 📚 Translation batch #1 (actualbudget#4408)

* Translation batch

* md

* Update packages/desktop-client/src/components/settings/Export.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix code review from coderabbit

* code review

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fix currencyToAmount incorrectly converting input (actualbudget#4383)

* fix: ensure currencyToAmount works regardless of the configured number format

* chore: linting

* docs: add release note

* test: ensure correct amount is entered for debit when adding split transactions

* chore: rename variable thousandsSep to thousandsSeparator

Co-authored-by: Joel Jeremy Marquez <joeljeremy.marquez@gmail.com>

* chore: rename variable decimalSep to decimalSeparator

Co-authored-by: Joel Jeremy Marquez <joeljeremy.marquez@gmail.com>

* chore: rename decimalSep and thousandsSep variables to decimalSeparator and thousandsSeparator

---------

Co-authored-by: Joel Jeremy Marquez <joeljeremy.marquez@gmail.com>

* useDisplayPayee hook to unify payee names in mobile and desktop. (actualbudget#4213)

* useDisplayPayee hook to unify payee logic in mobile and desktop

* Release notes

* Fix typecheck errors

* Fix test

* Update test

* Revert (No payee) color

* Fix tests

* VRT

* Fix category transactions

* Fix lint and VRT

* Update VRT

* Translate

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Extract transaction related server handlers from `main.ts` to `server/transactions/app.ts` (actualbudget#4221)

* Move transaction related handlers to server/transactions folder and use the new convention

* Fix lint and typecheck

* Release notes

* Update handler names

* Move get-earliest-transaction

* Update release notes

* Fix tests

* Fix types

* Fix lint

* Update snapshot

* Remove duplicate parse-file.ts

* Fix lint

* 🐛 Fix `On budget` / `Off budget` underline with translated languages (actualbudget#4417)

* Fix `On budget` / `Off budget` underline

* md

* ajuste para o merge

---------

Co-authored-by: Michael Clark <5285928+MikesGlitch@users.noreply.github.com>
Co-authored-by: Matt Farrell <10377148+MattFaz@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: youngcw <calebyoung94@gmail.com>
Co-authored-by: Matt Fiddaman <github@m.fiddaman.uk>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Martin Michotte <55855805+MMichotte@users.noreply.github.com>
Co-authored-by: Joel Jeremy Marquez <joeljeremy.marquez@gmail.com>
Co-authored-by: Adam Stück <adam@adast.dk>
Co-authored-by: Alberto Cortina Eduarte <albertocortina96@gmail.com>
Co-authored-by: Gabriel J. Michael <gabriel.j.michael@gmail.com>
Co-authored-by: Julian Dominguez-Schatz <julian.dominguezschatz@gmail.com>
Co-authored-by: Michał Gołąb <23549913+michalgolab@users.noreply.github.com>
Co-authored-by: Antoine Taillard <an.taillard@gmail.com>
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.

2 participants