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: new split expense flow across all dimensions #3490

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

Conversation

Sishhhh
Copy link
Contributor

@Sishhhh Sishhhh commented Feb 6, 2025

Clickup

Please add link here

Code Coverage

Please add code coverage here

UI Preview

Please add screenshots for UI changes

Summary by CodeRabbit

  • New Features

    • Updated the split expense page with a static header labeled “Split expense.”
    • New labels now display “No.of splits,” “Total amount,” and “Remaining amount” for clearer information.
    • A date input section with validation has been added, and the footer now offers buttons for adding splits and splitting evenly.
    • Warning messages now indicate that splitting an expense is a permanent action.
  • Style

    • Enhanced card visuals with an icon and refined spacing, margins, and background effects for an improved user experience.

Sishhhh and others added 2 commits February 6, 2025 15:36
* new flow of add-edit expense page

* fix: unit test failure

---------

Co-authored-by: Snehasish <[email protected]>
* fix: update the ui for the new split_expense_page

* minor

* minor color change

* fix: update class name

* minor

* minor

---------

Co-authored-by: Snehasish <[email protected]>
Copy link

coderabbitai bot commented Feb 6, 2025

Walkthrough

The pull request refactors the expense splitting functionality. The openSplitExpenseModal method no longer accepts a splitType parameter. Instead, a splitConfig object is created to encapsulate the visibility and mandatory status of the category, project, and cost center fields. Three individual split handlers have been consolidated into a single splitExpenseHandler. Corresponding test cases have been updated, and the split expense page has received updates in its UI and styling, along with additional theme color variables.

Changes

File(s) Summary
src/app/fyle/add-edit-expense/add-edit-expense-1.spec.ts, src/app/fyle/add-edit-expense/…/add-edit-expense.page.ts Updated openSplitExpenseModal: removed splitType, introduced splitConfig, consolidated handlers; tests modified accordingly.
src/app/fyle/split-expense/split-expense.page.html Replaced dynamic header with a static label, restructured amounts display, added error messages and date input; updated footer buttons.
src/app/fyle/split-expense/split-expense.page.scss Adjusted spacing, margins, colors, and introduced new classes to support UI enhancements.
src/theme/colors.scss Added new color variables: $shadow-xs and $pink-gradient-light-2 for refined styling.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant A as AddEditExpensePage
    participant H as splitExpenseHandler
    participant N as NavigationController
    participant S as SplitExpensePage

    U->>A: Tap split expense button
    A->>A: Build splitConfig object
    A->>H: Invoke splitExpenseHandler
    H->>N: Request navigation with splitConfig
    N->>S: Load SplitExpensePage with configuration
Loading

Possibly related PRs

Suggested labels

size/L

Suggested reviewers

  • Dimple16
  • Chethan-Fyle
  • arjunaj5

Poem

In the realm of code, a transformation so grand,
The split expense flows now by a single command.
With parameters united and handlers refined,
Our app’s stride becomes boldly aligned.
Like the legendary punch, issues vanish in style—
CodeRabbit way, Rajinikanth smile!

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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.

@Sishhhh Sishhhh marked this pull request as draft February 6, 2025 10:09
@github-actions github-actions bot added the size/L Large PR label Feb 6, 2025
Copy link

github-actions bot commented Feb 6, 2025

PR title must start with "fix:", "feat:", "chore:", "refactor:", or "test:" (case-insensitive)

Copy link

github-actions bot commented Feb 6, 2025

PR description must contain a link to a ClickUp (case-insensitive)

Copy link

github-actions bot commented Feb 6, 2025

PR title must start with "fix:", "feat:", "chore:", "refactor:", or "test:" (case-insensitive)

Copy link

github-actions bot commented Feb 6, 2025

PR description must contain a link to a ClickUp (case-insensitive)

Copy link

github-actions bot commented Feb 6, 2025

Unit Test Coverage % values
Statements 96.06% ( 19733 / 20541 )
Branches 91.07% ( 10842 / 11904 )
Functions 94.36% ( 5866 / 6216 )
Lines 96.11% ( 18850 / 19611 )

Copy link

@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: 3

🔭 Outside diff range comments (1)
src/app/fyle/add-edit-expense/add-edit-expense-1.spec.ts (1)

1182-1214: Thalaiva says: Test cases need more power!

The test coverage for splitExpenseHandler could be more comprehensive. Consider adding test cases for:

  • Edge cases with different splitConfig combinations
  • Error scenarios when form validation fails
  • Network error scenarios
 describe('splitExpenseHandler():', () => {
+  it('should handle network errors gracefully', () => {
+    setFormValid();
+    spyOn(component, 'openSplitExpenseModal').and.throwError('Network Error');
+    spyOn(component, 'showErrorMessage');
+    
+    component.splitExpenseHandler();
+    
+    expect(component.showErrorMessage).toHaveBeenCalled();
+  });
+
+  it('should validate splitConfig fields correctly', () => {
+    setFormValid();
+    component.txnFields$ = of({
+      org_category_id: { is_mandatory: true },
+      project_id: { is_mandatory: false },
+      cost_center_id: { is_mandatory: true }
+    });
+    
+    component.splitExpenseHandler();
+    
+    expect(component.openSplitExpenseModal).toHaveBeenCalledWith(
+      jasmine.objectContaining({
+        category: { is_mandatory: true },
+        project: { is_mandatory: false },
+        costCenter: { is_mandatory: true }
+      })
+    );
+  });
 });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a6ddaad and 87370ff.

📒 Files selected for processing (5)
  • src/app/fyle/add-edit-expense/add-edit-expense-1.spec.ts (10 hunks)
  • src/app/fyle/add-edit-expense/add-edit-expense.page.ts (4 hunks)
  • src/app/fyle/split-expense/split-expense.page.html (5 hunks)
  • src/app/fyle/split-expense/split-expense.page.scss (4 hunks)
  • src/theme/colors.scss (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (12.x)
🔇 Additional comments (6)
src/app/fyle/add-edit-expense/add-edit-expense-1.spec.ts (1)

683-699: Mind it! The splitConfig object structure looks solid!

The new splitConfig object elegantly encapsulates field visibility and mandatory status. This is a much better approach than passing individual parameters.

src/theme/colors.scss (1)

48-48: Style it like a boss! New color variables are on point!

The new shadow and gradient variables enhance the visual hierarchy:

  • $shadow-xs: Perfect for subtle elevation effects
  • $pink-gradient-light-2: Adds a soft, elegant gradient for backgrounds

Also applies to: 91-91

src/app/fyle/split-expense/split-expense.page.scss (2)

43-47: These styles are blockbuster material!

The updated padding and gap properties create better visual rhythm. The new gradient background adds a subtle but effective visual hierarchy.

Also applies to: 247-252


272-283: Error messages now have style and substance!

The error message block styling is well-thought-out with:

  • Proper border radius for modern look
  • Consistent padding and line height
  • Clear visual hierarchy with icon
src/app/fyle/split-expense/split-expense.page.html (2)

29-32: Warning message that packs a punch!

Clear and concise warning about the permanent nature of split actions. This helps prevent user mistakes.


34-47: The amount block is now a superstar!

The restructured amount block provides better information hierarchy:

  • Split count display
  • Total amount visibility
  • Remaining amount tracking

Comment on lines +1056 to 1058
text: 'Dimiss as Card Payment',
handler: () => this.markDismissHandler(),
});
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ayyo! There's a typo in 'Dimiss', boss!

The word 'Dimiss' should be corrected to 'Dismiss' in the action sheet option text.

Apply this diff to fix the typo:

-                  text: 'Dimiss as Card Payment',
+                  text: 'Dismiss as Card Payment',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
text: 'Dimiss as Card Payment',
handler: () => this.markDismissHandler(),
});
text: 'Dismiss as Card Payment',
handler: () => this.markDismissHandler(),
});

Comment on lines +778 to +793
category: {
is_visible: !!res.txnFields.org_category_id,
value: formValue.category,
is_mandatory: res.txnFields.org_category_id?.is_mandatory || false,
},
project: {
is_visible: !!res.txnFields.project_id,
value: formValue.project,
is_mandatory: res.txnFields.project_id?.is_mandatory || false,
},
costCenter: {
is_visible: !!res.txnFields.cost_center_id,
value: formValue.costCenter,
is_mandatory: res.txnFields.cost_center_id?.is_mandatory || false,
},
};
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Let's cut down the repetition like a superstar!

The construction of splitConfig for 'category', 'project', and 'costCenter' is repetitive. Refactor it into a helper function to make your code more powerful and maintainable.

Apply this diff to refactor the code:

+            function createSplitConfigField(fieldName, fieldValue) {
+              return {
+                is_visible: !!res.txnFields[fieldName],
+                value: fieldValue,
+                is_mandatory: res.txnFields[fieldName]?.is_mandatory || false,
+              };
+            }

-            const splitConfig = {
-              category: {
-                is_visible: !!res.txnFields.org_category_id,
-                value: formValue.category,
-                is_mandatory: res.txnFields.org_category_id?.is_mandatory || false,
-              },
-              project: {
-                is_visible: !!res.txnFields.project_id,
-                value: formValue.project,
-                is_mandatory: res.txnFields.project_id?.is_mandatory || false,
-              },
-              costCenter: {
-                is_visible: !!res.txnFields.cost_center_id,
-                value: formValue.costCenter,
-                is_mandatory: res.txnFields.cost_center_id?.is_mandatory || false,
-              },
-            };
+            const splitConfig = {
+              category: createSplitConfigField('org_category_id', formValue.category),
+              project: createSplitConfigField('project_id', formValue.project),
+              costCenter: createSplitConfigField('cost_center_id', formValue.costCenter),
+            };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
category: {
is_visible: !!res.txnFields.org_category_id,
value: formValue.category,
is_mandatory: res.txnFields.org_category_id?.is_mandatory || false,
},
project: {
is_visible: !!res.txnFields.project_id,
value: formValue.project,
is_mandatory: res.txnFields.project_id?.is_mandatory || false,
},
costCenter: {
is_visible: !!res.txnFields.cost_center_id,
value: formValue.costCenter,
is_mandatory: res.txnFields.cost_center_id?.is_mandatory || false,
},
};
function createSplitConfigField(fieldName, fieldValue) {
return {
is_visible: !!res.txnFields[fieldName],
value: fieldValue,
is_mandatory: res.txnFields[fieldName]?.is_mandatory || false,
};
}
const splitConfig = {
category: createSplitConfigField('org_category_id', formValue.category),
project: createSplitConfigField('project_id', formValue.project),
costCenter: createSplitConfigField('cost_center_id', formValue.costCenter),
};

Comment on lines +205 to 220
<ion-footer>
<div class="split-expense--more-actions">
<button
class="btn-outline-secondary split-expense--add-more"
*ngIf="splitExpensesFormArray.controls.length < 30"
(click)="add()"
>
<mat-icon class="split-expense--add-more-icon" svgIcon="plus-square"></mat-icon>
<div class="split-expense--add-more-label">Add Split</div>
</button>

<button class="btn-outline-secondary split-expense--split-evenly" (click)="splitEvenly()">
<mat-icon class="split-expense--split-evenly-icon" svgIcon="split"></mat-icon>
<div class="split-expense--split-evenly-label">Split Evenly</div>
</button>
</div>
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Footer actions that mean business!

The new footer design with split actions is more intuitive and user-friendly. However, consider adding tooltips for better accessibility.

 <button class="btn-outline-secondary split-expense--add-more"
   *ngIf="splitExpensesFormArray.controls.length < 30"
+  matTooltip="Add a new split to the expense"
   (click)="add()">
   ...
 </button>

 <button class="btn-outline-secondary split-expense--split-evenly"
+  matTooltip="Divide the amount equally between all splits"
   (click)="splitEvenly()">
   ...
 </button>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<ion-footer>
<div class="split-expense--more-actions">
<button
class="btn-outline-secondary split-expense--add-more"
*ngIf="splitExpensesFormArray.controls.length < 30"
(click)="add()"
>
<mat-icon class="split-expense--add-more-icon" svgIcon="plus-square"></mat-icon>
<div class="split-expense--add-more-label">Add Split</div>
</button>
<button class="btn-outline-secondary split-expense--split-evenly" (click)="splitEvenly()">
<mat-icon class="split-expense--split-evenly-icon" svgIcon="split"></mat-icon>
<div class="split-expense--split-evenly-label">Split Evenly</div>
</button>
</div>
<ion-footer>
<div class="split-expense--more-actions">
<button
class="btn-outline-secondary split-expense--add-more"
*ngIf="splitExpensesFormArray.controls.length < 30"
matTooltip="Add a new split to the expense"
(click)="add()"
>
<mat-icon class="split-expense--add-more-icon" svgIcon="plus-square"></mat-icon>
<div class="split-expense--add-more-label">Add Split</div>
</button>
<button
class="btn-outline-secondary split-expense--split-evenly"
matTooltip="Divide the amount equally between all splits"
(click)="splitEvenly()"
>
<mat-icon class="split-expense--split-evenly-icon" svgIcon="split"></mat-icon>
<div class="split-expense--split-evenly-label">Split Evenly</div>
</button>
</div>
</ion-footer>

@Sishhhh Sishhhh changed the title Feat split expense feat: new split expense flow across mob Feb 6, 2025
Copy link

github-actions bot commented Feb 6, 2025

PR description must contain a link to a ClickUp (case-insensitive)

@Sishhhh Sishhhh changed the title feat: new split expense flow across mob feat: new split expense flow across all dimensions Feb 6, 2025
Copy link

github-actions bot commented Feb 6, 2025

PR description must contain a link to a ClickUp (case-insensitive)

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

Successfully merging this pull request may close these issues.

1 participant