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

fix: new data should be fetched when a txn is matched, or new expense is created #3407

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

Conversation

sumrender
Copy link
Contributor

@sumrender sumrender commented Jan 7, 2025

  1. New data should be fetched when a txn is matched, or new expense is created.
  2. Fix minor bug, use 'spent_at' instead of 'btxn_transaction_dt'
  3. Fetch transactions from backend, ordered by spent_at

Clickup

https://app.clickup.com/t/86cxk6xm0

Code Coverage

Please add code coverage here

UI Preview

Please add screenshots for UI changes

Summary by CodeRabbit

  • New Features

    • Added refresh mechanism for personal cards page.
    • Implemented transaction sorting by spent date and ID.
  • Bug Fixes

    • Updated date filtering for personal card transactions.
    • Corrected navigation logic when matching expenses.
  • Improvements

    • Enhanced personal card transaction display.
    • Refined data retrieval and navigation processes.
    • Improved handling of route parameters for dynamic updates.

Copy link

coderabbitai bot commented Jan 7, 2025

Walkthrough

Listen up, superstar! This pull request is a dazzling upgrade to the personal cards feature. We’re adding a new sorting order for bank transactions, refreshing the navigation flow, and fine-tuning how transaction dates are handled. It’s a well-choreographed dance of code, where every move is precise and smooth—just like my signature style!

Changes

File Change Summary
src/app/core/services/personal-cards.service.ts Added order parameter to getBankTransactions method for sorting transactions by spent_at and id in descending order
src/app/fyle/add-edit-expense/add-edit-expense.page.ts Modified navigation to include refresh: true query parameter when redirecting to personal cards page
src/app/fyle/personal-cards-matched-expenses/expense-preview/expense-preview.component.ts Updated navigation to personal cards page with refresh: true query parameter
src/app/fyle/personal-cards/personal-cards.page.html Changed previousTxnDate binding from btxn_transaction_dt to spent_at
src/app/fyle/personal-cards/personal-cards.page.spec.ts Updated date filtering parameters from btxn_transaction_dt to spent_at
src/app/fyle/personal-cards/personal-cards.page.ts Added ionViewWillEnter() method to handle page refresh via query parameters

Sequence Diagram

sequenceDiagram
    participant User
    participant AddEditExpensePage
    participant Router
    participant PersonalCardsPage
    
    User->>AddEditExpensePage: Save Expense
    AddEditExpensePage->>Router: Navigate with {refresh: true}
    Router->>PersonalCardsPage: Enter Page
    PersonalCardsPage->>PersonalCardsPage: Reset Page Number
    PersonalCardsPage->>PersonalCardsPage: Reload Data
Loading

Possibly related PRs

Suggested labels

size/M

Suggested reviewers

  • arjunaj5
  • Chethan-Fyle
  • Dimple16

Poem

Transactions dance, a digital ballet 💃
Refresh and sort, the Rajini way! 🌟
Code moves smooth, with style so bright
Personal cards take their flight! 🚀
Superstar's touch, in every line
Technology's magic, simply divine! ✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 441e267 and 9e5861b.

📒 Files selected for processing (3)
  • src/app/core/services/personal-cards.service.spec.ts (1 hunks)
  • src/app/fyle/add-edit-expense/add-edit-expense-4.spec.ts (5 hunks)
  • src/app/fyle/personal-cards-matched-expenses/expense-preview/expense-preview.component.spec.ts (1 hunks)
🧰 Additional context used
📓 Learnings (1)
src/app/fyle/personal-cards-matched-expenses/expense-preview/expense-preview.component.spec.ts (1)
Learnt from: sumrender
PR: fylein/fyle-mobile-app#3265
File: src/app/fyle/personal-cards-matched-expenses/expense-preview/expense-preview.component.spec.ts:35-37
Timestamp: 2024-11-18T06:55:17.972Z
Learning: In `src/app/fyle/add-edit-expense/add-edit-expense.page.ts`, the `unmatchExpense` method is used for corporate card expenses, not for personal card expenses.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (12.x)
🔇 Additional comments (3)
src/app/fyle/personal-cards-matched-expenses/expense-preview/expense-preview.component.spec.ts (1)

131-133: Mind it! This navigation enhancement looks perfect!

The addition of refresh: true query parameter ensures that the personal cards page refreshes its data after matching an expense. This is exactly what we need, partner!

src/app/core/services/personal-cards.service.spec.ts (1)

142-142: Superstar move! The ordering logic is spot on!

Adding order: 'spent_at.desc,id.desc' ensures transactions are properly sorted by:

  1. Spent date in descending order (newest first)
  2. ID in descending order (for transactions with same timestamp)

This brings clarity and consistency to the transaction list. What a style!

src/app/fyle/add-edit-expense/add-edit-expense-4.spec.ts (1)

644-646: Kabali style test coverage, I tell you!

The test cases have been properly updated to verify the refresh query parameter addition across multiple scenarios:

  • Basic expense matching
  • Expense matching with policy violations
  • Offline mode expense matching
  • Critical policy violation cases

This ensures our refresh functionality is rock solid!

Also applies to: 700-702, 758-760, 807-809, 856-858


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

@github-actions github-actions bot added the size/S Small PR label Jan 7, 2025
Copy link

github-actions bot commented Jan 7, 2025

Unit Test Coverage % values
Statements 95.93% ( 19294 / 20111 )
Branches 91.07% ( 10660 / 11705 )
Functions 94.21% ( 5735 / 6087 )
Lines 95.97% ( 18420 / 19193 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S Small PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants