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: poc for date grouping #1174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

feat: poc for date grouping #1174

wants to merge 1 commit into from

Conversation

DhaaraniCIT
Copy link
Contributor

@DhaaraniCIT DhaaraniCIT commented Feb 5, 2025

Description

feat: poc for date grouping

Clickup

Please add link here

Summary by CodeRabbit

  • New Features
    • Enhanced expense export settings with additional date grouping options for credit card and reimbursable expenses, providing more flexible selection choices.
  • Refactor
    • Streamlined the underlying logic for updating grouping options, ensuring a consistent and simplified configuration experience for export settings.

Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

This pull request introduces new static methods in the ExportSettingModel to provide and filter date grouping options for expenses. The changes centralize the logic for both credit card and reimbursable expense grouping by adding methods such as getCreditCardExpenseGroupingDateOptions, getReimbursableExpenseGroupingDateOption, and dateGrouping. Additionally, the QBO export settings component has been updated to utilize the new dateGrouping method, simplifying its internal update methods related to expense grouping.

Changes

File Changes Summary
src/app/core/.../export-settings.model.ts Added three static methods: getCreditCardExpenseGroupingDateOptions, getReimbursableExpenseGroupingDateOption, and dateGrouping to manage expense grouping date options.
src/app/integrations/qbo/.../qbo-export-settings.component.ts Modified updateCCCExpenseGroupingDateOptions and setupCustomDateOptionWatchers to use the centralized ExportSettingModel.dateGrouping method for date options.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Component as QBO Export Settings Component
    participant Model as ExportSettingModel

    User->>Component: Triggers update of expense grouping options
    Component->>Model: Call dateGrouping(exportType, expenseGrouping, showApprovedDate, showVerificationDate)
    Model-->>Component: Returns filtered date options
    Component->>User: Renders updated options
Loading

Suggested labels

size/XS

Suggested reviewers

  • ashwin1111

Poem

I'm a little rabbit, hopping with delight,
New methods sprout in our code, oh what a sight!
Centralized logic in a rhythmic dance,
Date options now given a fair chance.
Cheers to clean code and a hoppin' good night! 🐇✨

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.

@github-actions github-actions bot added the size/M Medium PR label Feb 5, 2025
Copy link

github-actions bot commented Feb 5, 2025

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

1 similar comment
Copy link

github-actions bot commented Feb 5, 2025

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

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 (3)
src/app/core/models/common/export-settings.model.ts (2)

112-135: Fix typo in function name.

The function name should be plural to match its return type.

Apply this diff to fix the typo:

-static getReimbursableExpenseGroupingDateOption(): SelectFormOption[] {
+static getReimbursableExpenseGroupingDateOptions(): SelectFormOption[] {

137-161: Clean up code style and improve type safety.

The function has the following issues:

  1. Inconsistent spacing
  2. Use of 'this' in static context
  3. Unnecessary type assertion in filter callback

Apply this diff to improve the code:

-static dateGrouping(exportType:string, expenseGrouping: string, showApprovedDate: boolean, showVerificationDate: boolean): SelectFormOption[] {
-      
-      const excludedDate = expenseGrouping === 'expense' 
-      ? ExportDateType.LAST_SPENT_AT 
-      : ExportDateType.SPENT_AT;
-      
-      if (exportType === 'CCC') {
-        return this.getCreditCardExpenseGroupingDateOptions().filter(option => option.value !== excludedDate);
-      }
-
-      let dateOptions = this.getReimbursableExpenseGroupingDateOption();
-      let filterOptions: ExportDateType[] = [];
-
-      if (showApprovedDate) {
-        filterOptions.push(ExportDateType.VERIFIED_AT);
-      } else if (showVerificationDate) {
-        filterOptions.push(ExportDateType.APPROVED_AT);
-      }
-
-      filterOptions.push(excludedDate);
-      
-      return dateOptions.filter((item): item is { label: string; value: ExportDateType } =>
-        item.value !== null && !filterOptions.includes(item.value as ExportDateType))
+static dateGrouping(exportType: string, expenseGrouping: string, showApprovedDate: boolean, showVerificationDate: boolean): SelectFormOption[] {
+  const excludedDate = expenseGrouping === 'expense'
+    ? ExportDateType.LAST_SPENT_AT
+    : ExportDateType.SPENT_AT;
+
+  if (exportType === 'CCC') {
+    return ExportSettingModel.getCreditCardExpenseGroupingDateOptions().filter(option => option.value !== excludedDate);
+  }
+
+  const dateOptions = ExportSettingModel.getReimbursableExpenseGroupingDateOptions();
+  const filterOptions: ExportDateType[] = [];
+
+  if (showApprovedDate) {
+    filterOptions.push(ExportDateType.VERIFIED_AT);
+  } else if (showVerificationDate) {
+    filterOptions.push(ExportDateType.APPROVED_AT);
+  }
+
+  filterOptions.push(excludedDate);
+
+  return dateOptions.filter(item => item.value !== null && !filterOptions.includes(item.value));
🧰 Tools
🪛 Biome (1.9.4)

[error] 144-144: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 147-147: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

🪛 ESLint

[error] 138-138: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 139-139: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 140-140: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 142-142: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 147-147: 'dateOptions' is never reassigned. Use 'const' instead.

(prefer-const)


[error] 148-148: 'filterOptions' is never reassigned. Use 'const' instead.

(prefer-const)


[error] 157-157: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 159-160: Missing semicolon.

(semi)

🪛 GitHub Check: lint

[failure] 138-138:
Trailing spaces not allowed


[failure] 139-139:
Trailing spaces not allowed


[failure] 140-140:
Trailing spaces not allowed


[failure] 142-142:
Trailing spaces not allowed


[failure] 147-147:
'dateOptions' is never reassigned. Use 'const' instead


[failure] 148-148:
'filterOptions' is never reassigned. Use 'const' instead


[failure] 157-157:
Trailing spaces not allowed


[failure] 159-159:
Missing semicolon

🪛 GitHub Actions: TypeScript Lint Check

[error] 138-138: Trailing spaces not allowed

src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts (1)

344-359: Clean up commented code and fix semicolons.

  1. Remove commented code as it's tracked in version control.
  2. Add missing semicolons.

Apply this diff to clean up the code:

-      // this.reimbursableExpenseGroupingDateOptions = QBOExportSettingModel.getReimbursableExpenseGroupingDateOptions();
-      // this.reimbursableExpenseGroupingDateOptions = ExportSettingModel.constructGroupingDateOptions(reimbursableExportGroup, this.reimbursableExpenseGroupingDateOptions);
-      this.reimbursableExpenseGroupingDateOptions = ExportSettingModel.dateGrouping('rem', this.exportSettingForm.controls.reimbursableExportGroup.value, true, false)
+      this.reimbursableExpenseGroupingDateOptions = ExportSettingModel.dateGrouping('rem', this.exportSettingForm.controls.reimbursableExportGroup.value, true, false);

-    //     // this.cccExpenseGroupingDateOptions = QBOExportSettingModel.getReimbursableExpenseGroupingDateOptions();
-    //     // this.cccExpenseGroupingDateOptions = ExportSettingModel.constructGroupingDateOptions(creditCardExportGroup, this.cccExpenseGroupingDateOptions);
-        this.cccExpenseGroupingDateOptions = ExportSettingModel.dateGrouping('rem', creditCardExportGroup, true, false)
+        this.cccExpenseGroupingDateOptions = ExportSettingModel.dateGrouping('rem', creditCardExportGroup, true, false);
🧰 Tools
🪛 ESLint

[error] 344-344: Comments should not begin with a lowercase character.

(capitalized-comments)


[error] 345-345: Comments should not begin with a lowercase character.

(capitalized-comments)


[error] 346-347: Missing semicolon.

(semi)


[error] 358-359: Missing semicolon.

(semi)

🪛 GitHub Check: lint

[failure] 344-344:
Comments should not begin with a lowercase character


[failure] 345-345:
Comments should not begin with a lowercase character

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7688c10 and 7110f3a.

📒 Files selected for processing (2)
  • src/app/core/models/common/export-settings.model.ts (2 hunks)
  • src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts (2 hunks)
🧰 Additional context used
🪛 ESLint
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts

[error] 344-344: Comments should not begin with a lowercase character.

(capitalized-comments)


[error] 345-345: Comments should not begin with a lowercase character.

(capitalized-comments)


[error] 346-347: Missing semicolon.

(semi)

src/app/core/models/common/export-settings.model.ts

[error] 138-138: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 139-139: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 140-140: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 142-142: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 147-147: 'dateOptions' is never reassigned. Use 'const' instead.

(prefer-const)


[error] 148-148: 'filterOptions' is never reassigned. Use 'const' instead.

(prefer-const)


[error] 157-157: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 159-160: Missing semicolon.

(semi)

🪛 GitHub Check: lint
src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts

[failure] 344-344:
Comments should not begin with a lowercase character


[failure] 345-345:
Comments should not begin with a lowercase character

src/app/core/models/common/export-settings.model.ts

[failure] 138-138:
Trailing spaces not allowed


[failure] 139-139:
Trailing spaces not allowed


[failure] 140-140:
Trailing spaces not allowed


[failure] 142-142:
Trailing spaces not allowed


[failure] 147-147:
'dateOptions' is never reassigned. Use 'const' instead


[failure] 148-148:
'filterOptions' is never reassigned. Use 'const' instead


[failure] 157-157:
Trailing spaces not allowed


[failure] 159-159:
Missing semicolon

🪛 Biome (1.9.4)
src/app/core/models/common/export-settings.model.ts

[error] 144-144: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 147-147: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

🪛 GitHub Actions: TypeScript Lint Check
src/app/core/models/common/export-settings.model.ts

[error] 138-138: Trailing spaces not allowed

🔇 Additional comments (2)
src/app/core/models/common/export-settings.model.ts (1)

91-110: LGTM! Well-structured date options for credit card expenses.

The function provides a comprehensive set of date options for credit card expense grouping, with proper labels and values.

src/app/integrations/qbo/qbo-shared/qbo-export-settings/qbo-export-settings.component.ts (1)

318-320: LGTM! Consistent usage of the new date grouping method.

The method correctly utilizes ExportSettingModel.dateGrouping with appropriate parameters based on the export type.

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

Successfully merging this pull request may close these issues.

1 participant