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: support GET and PUT for split_expense_grouping in export settings #672

Conversation

JustARatherRidiculouslyLongUsername
Copy link
Contributor

@JustARatherRidiculouslyLongUsername JustARatherRidiculouslyLongUsername commented Nov 18, 2024

Clickup

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

Summary by CodeRabbit

  • New Features

    • Introduced a new required field, split_expense_grouping, in the Expense Group Settings, enhancing the granularity of expense tracking.
    • Added a bank_transaction_id field to the Expense model for better transaction identification.
    • Enhanced credit card charge handling by allowing batch processing of multiple line items.
  • Bug Fixes

    • None reported.
  • Documentation

    • Updated serializer documentation to reflect the addition of the new fields.

Copy link

coderabbitai bot commented Nov 18, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes introduced in this pull request involve the addition of new fields and modifications to existing methods across several files. Notably, the ExpenseGroupSettingsSerializer now includes a required field split_expense_grouping, and the Expense model has a new field bank_transaction_id. The handling of credit card charge line items has been updated to support multiple items in various methods within the NetSuiteConnector and related classes. Additionally, SQL scripts have been added to update existing records, and test cases have been adjusted to reflect these changes.

Changes

File Path Change Summary
apps/workspaces/apis/export_settings/serializers.py Added required field split_expense_grouping to ExpenseGroupSettingsSerializer. Updated fields list in Meta class.
apps/fyle/models.py Added bank_transaction_id field to Expense model. Introduced split_expense_grouping to ExpenseGroupSettings. Updated create_expense_objects and create_expense_groups_by_report_id_fund_source methods to handle new fields.
tests/test_fyle/fixtures.py Added bank_transaction_id and is_posted_at_null fields to multiple expense dictionaries.
apps/netsuite/connector.py Updated methods to handle lists of CreditCardChargeLineItem objects instead of single instances. Adjusted payload construction for credit card charges.
apps/netsuite/models.py Renamed method create_credit_card_charge_lineitem to create_credit_card_charge_lineitems to process multiple line items. Updated internal logic accordingly.
apps/netsuite/tasks.py Updated create_credit_card_charge method to handle multiple line items. Enhanced error handling for NetSuite operations.
scripts/sql/scripts/030-default-split-expense-grouping-for-old-orgs.sql Added SQL script to update split_expense_grouping for older organizations in the expense_group_settings table.
tests/test_netsuite/conftest.py Renamed method call from create_credit_card_charge_lineitem to create_credit_card_charge_lineitems in fixture.
tests/test_netsuite/test_connector.py Updated tests to reflect handling of multiple credit card charge line items. Enhanced tax balancing and error handling scenarios.
tests/test_netsuite/test_models.py Refactored test_create_credit_card_charge to use create_credit_card_charge_lineitems. Updated assertions for new handling of multiple line items.

Possibly related PRs

Suggested labels

deploy, size/M

Suggested reviewers

  • ashwin1111
  • ruuushhh

Poem

In the fields where expenses roam,
New settings find their place,
With split_expense_grouping to call home,
And bank IDs in the race.
Credit cards now dance in line,
As rabbits hop, all is fine! 🐇✨

Warning

Rate limit exceeded

@github-actions[bot] has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 16 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 aaba448 and 1e79de2.


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

Tests Skipped Failures Errors Time
227 0 💤 3 ❌ 0 🔥 26.092s ⏱️

Copy link

Tests Skipped Failures Errors Time
232 0 💤 4 ❌ 0 🔥 26.367s ⏱️

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: 0

🧹 Outside diff range and nitpick comments (11)
tests/test_fyle/fixtures.py (1)

249-249: Consider using unique bank_transaction_ids for different test cases

The same bank_transaction_id value ('btxnqmATEEBkJ4') is used across multiple test fixtures. While this might work for basic testing, using unique IDs would help catch potential uniqueness constraints or ID-related bugs.

Consider using distinct IDs like:

-'bank_transaction_id': 'btxnqmATEEBkJ4',
+'bank_transaction_id': 'btxn_1234',  // For expense ID 1234
+'bank_transaction_id': 'btxn_1235',  // For expense ID 1235
+'bank_transaction_id': 'btxn_1236',  // For expense ID 1236

Also applies to: 291-291, 333-333, 866-866, 909-909

tests/test_fyle/conftest.py (3)

Line range hint 34-44: Remove duplicate 'report_id' field from corporate_credit_card_expense_group_fields

The 'report_id' field appears twice in the list, which could lead to confusion and potential issues.

Apply this diff to remove the duplicate:

        expense_group_settings.corporate_credit_card_expense_group_fields = [
            'expense_id',
            'claim_number',
            'fund_source',
            'employee_email',
            'report_id',
-           'spent_at',
-           'report_id'
+           'spent_at'
        ]

Line range hint 34-44: Consider adding validation for configuration values

The fixture sets hardcoded values for configurations without validation:

  • 'CREDIT CARD CHARGE' for corporate_credit_card_expenses_object
  • 'SINGLE_LINE_ITEM' for split_expense_grouping

Consider adding constants or enums to validate these values and make the test more maintainable.

Example implementation:

from enum import Enum

class ExpenseObject(str, Enum):
    CREDIT_CARD_CHARGE = 'CREDIT CARD CHARGE'
    BANK_TRANSACTION = 'BANK TRANSACTION'

class ExpenseGrouping(str, Enum):
    SINGLE_LINE_ITEM = 'SINGLE_LINE_ITEM'
    MULTIPLE_LINE_ITEMS = 'MULTIPLE_LINE_ITEMS'

# Then in the fixture:
general_settings.corporate_credit_card_expenses_object = ExpenseObject.CREDIT_CARD_CHARGE.value
expense_group_settings.split_expense_grouping = ExpenseGrouping.SINGLE_LINE_ITEM.value

Line range hint 34-44: Consider adding assertions to verify configuration changes

The fixture modifies configuration but doesn't verify if the changes were applied correctly. Consider adding assertions to ensure the configuration is updated as expected.

Example implementation:

def _update_config_for_split_expense_grouping(general_settings, expense_group_settings):
    general_settings.corporate_credit_card_expenses_object = 'CREDIT CARD CHARGE'
    general_settings.save()
    
    # Verify general settings
    assert general_settings.refresh_from_db() is None, "Failed to save general settings"
    assert general_settings.corporate_credit_card_expenses_object == 'CREDIT CARD CHARGE'
    
    expense_group_settings.split_expense_grouping = 'SINGLE_LINE_ITEM'
    expense_group_settings.corporate_credit_card_expense_group_fields = [
        'expense_id',
        'claim_number',
        'fund_source',
        'employee_email',
        'report_id',
        'spent_at'
    ]
    expense_group_settings.save()
    
    # Verify expense group settings
    assert expense_group_settings.refresh_from_db() is None, "Failed to save expense group settings"
    assert expense_group_settings.split_expense_grouping == 'SINGLE_LINE_ITEM'
    assert 'spent_at' in expense_group_settings.corporate_credit_card_expense_group_fields
tests/test_workspaces/test_apis/test_export_settings/fixtures.py (1)

Test cases for split_expense_grouping field should be added to missing value scenarios

Based on the search results, split_expense_grouping is a required field in the serializer (allow_null=False, allow_blank=False, required=True). The field should be included in all test scenarios to ensure proper validation coverage.

  • Add split_expense_grouping field to export_settings_missing_values_configurations.expense_group_settings
  • Add split_expense_grouping field to export_settings_missing_values_general_mappings.expense_group_settings
🔗 Analysis chain

Line range hint 1-200: Consider adding test cases for split_expense_grouping

The field split_expense_grouping is missing in some test scenarios:

  • Not present in export_settings_missing_values_configurations.expense_group_settings
  • Not present in export_settings_missing_values_general_mappings.expense_group_settings

If this is a required field as indicated by the serializer, we should either:

  1. Add the field to all test scenarios, or
  2. Document why certain test scenarios exclude this field (e.g., if testing validation errors)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the field is required in the serializer
ast-grep --pattern 'split_expense_grouping = serializers.CharField(
  $$$
  required=$_,
  $$$
)'

Length of output: 99


Script:

#!/bin/bash
# Let's search for the serializer definition with a broader pattern
rg -A 5 "split_expense_grouping" --type py

Length of output: 9817

tests/test_fyle/test_models.py (4)

166-166: LGTM! Consider these improvements for better test maintainability.

The addition of .distinct() is correct and necessary to prevent duplicate counting in the query results. However, consider these improvements:

  1. Add detailed docstrings explaining both test scenarios (SINGLE_LINE_ITEM and MULTIPLE_LINE_ITEM)
  2. Use descriptive variable names (e.g., expense_groups instead of groups)
  3. Define test data constants (e.g., EXPECTED_SINGLE_LINE_GROUPS = 2)

204-204: LGTM! Consider restructuring for better readability.

The .distinct() addition is correct. To improve test clarity:

  1. Extract test data setup into helper methods
  2. Use more descriptive assertion messages explaining the expected grouping behavior
  3. Structure the test with clear setup/exercise/verify sections

Example structure:

def test_split_expense_grouping_with_same_and_different_ids(db, update_config_for_split_expense_grouping):
    """Test expense grouping with mixed bank transaction IDs.
    
    Scenario:
    - Two expenses sharing bank_transaction_id='sample_1'
    - One expense with bank_transaction_id='sample_2'
    """
    # SETUP
    workspace_id = 1
    test_expenses = create_test_expenses_with_mixed_transaction_ids()
    
    # EXERCISE
    groups_single_line = create_groups_with_single_line_setting(test_expenses)
    groups_multiple_line = create_groups_with_multiple_line_setting(test_expenses)
    
    # VERIFY
    assert_correct_grouping_for_single_line(groups_single_line)
    assert_correct_grouping_for_multiple_line(groups_multiple_line)

243-245: Fix formatting and consider improvements for clarity.

The .distinct() addition is correct, but there are some issues to address:

  1. Fix formatting: Add space around operator in old_count== 2
  2. Consider renaming test to better describe the scenario (e.g., test_split_expense_grouping_with_paired_transaction_ids)
  3. Apply similar improvements as suggested in previous tests
-    assert len(groups) - old_count== 2, f'Expected 2 groups, got {len(groups) - old_count}'
+    assert len(groups) - old_count == 2, f'Expected 2 groups, got {len(groups) - old_count}'

Line range hint 140-245: Consider using pytest parameterization for better test organization.

The three test functions for split expense grouping share similar patterns and setup code. Consider refactoring them using pytest's parameterization feature to reduce duplication and improve maintainability.

Example approach:

@pytest.mark.parametrize('test_scenario', [
    {
        'name': 'no_bank_transaction_id',
        'expenses': [
            {'bank_transaction_id': None},
            {'bank_transaction_id': None}
        ],
        'expected_single_line_groups': 2,
        'expected_multiple_line_groups': 2
    },
    # Add other scenarios...
])
def test_split_expense_grouping(db, update_config_for_split_expense_grouping, test_scenario):
    """Test expense grouping with different bank transaction ID scenarios."""
    # Common setup and verification logic here
apps/fyle/models.py (2)

75-76: Add docstring to explain the purpose of split expense grouping choices.

Consider adding documentation to explain when to use each option and their implications.

 SPLIT_EXPENSE_GROUPING = (('SINGLE_LINE_ITEM', 'SINGLE_LINE_ITEM'), ('MULTIPLE_LINE_ITEM', 'MULTIPLE_LINE_ITEM'))
+
+"""
+Choices for handling split expenses in expense groups:
+- SINGLE_LINE_ITEM: Consolidates split expenses into a single line item
+- MULTIPLE_LINE_ITEM: Maintains separate line items for split expenses
+"""

Also applies to: 214-216


75-76: Consider documenting performance implications of grouping choices.

The choice between SINGLE_LINE_ITEM and MULTIPLE_LINE_ITEM could have significant implications:

  1. Database query performance
  2. Memory usage when processing large numbers of split expenses
  3. Impact on downstream systems (e.g., NetSuite) when processing grouped vs. individual line items

Consider adding documentation about these trade-offs to help users make informed decisions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cd0b8e6 and aaba448.

📒 Files selected for processing (8)
  • apps/fyle/migrations/0035_support_split_expense_grouping.py (1 hunks)
  • apps/fyle/models.py (6 hunks)
  • apps/workspaces/apis/export_settings/serializers.py (2 hunks)
  • tests/sql_fixtures/reset_db_fixtures/reset_db.sql (7 hunks)
  • tests/test_fyle/conftest.py (1 hunks)
  • tests/test_fyle/fixtures.py (7 hunks)
  • tests/test_fyle/test_models.py (3 hunks)
  • tests/test_workspaces/test_apis/test_export_settings/fixtures.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/workspaces/apis/export_settings/serializers.py
🔇 Additional comments (12)
tests/sql_fixtures/reset_db_fixtures/reset_db.sql (5)

1153-1154: LGTM: Appropriate column definition for bank_transaction_id

The bank_transaction_id column is appropriately defined as an optional VARCHAR(255), which is suitable for transaction identifiers.


7997-7997: LGTM: Migration sequence properly updated

The migration sequence is correctly incremented and the migration name follows the convention.


962-963: Verify data migration strategy for NOT NULL constraint

The new split_expense_grouping column is added with a NOT NULL constraint. Ensure there's a proper data migration strategy to populate this field for existing records.

✅ Verification successful

Migration strategy for NOT NULL constraint is properly handled

The migration file shows that the split_expense_grouping column is added with a default value provided by apps.fyle.models.get_default_split_expense_grouping function, which ensures existing records will have a valid value. The column also has predefined choices ('SINGLE_LINE_ITEM', 'MULTIPLE_LINE_ITEM'), making it a safe schema change.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for related migration files that might handle data population
fd -e py | xargs grep -l "split_expense_grouping"

Length of output: 333


Script:

#!/bin/bash
# Check the migration file content to verify the data migration strategy
cat apps/fyle/migrations/0035_support_split_expense_grouping.py

Length of output: 950


5-5: Verify the PostgreSQL version downgrade

The PostgreSQL version has been downgraded from 15.9 to 15.7. Please confirm if this downgrade was intentional and ensure compatibility with your deployment environment.


11584-11587: Verify if 'MULTIPLE_LINE_ITEM' is the only valid value

All inserted records use 'MULTIPLE_LINE_ITEM' for split_expense_grouping. Please confirm if this is the only valid value or if other values are supported.

tests/test_fyle/fixtures.py (1)

1011-1011: Verify the allowed values for split_expense_grouping

The fixtures use 'MULTIPLE_LINE_ITEM' as the value for split_expense_grouping. To ensure robust testing:

  1. Consider adding test cases for other valid values
  2. Add test cases to verify handling of invalid values

Let's check the model definition and any existing validation:

Also applies to: 1116-1116

✅ Verification successful

Let me search for the choices definition to understand the allowed values:


Test coverage for split_expense_grouping is sufficient

The field split_expense_grouping only accepts two valid values as defined in the model:

  • 'SINGLE_LINE_ITEM'
  • 'MULTIPLE_LINE_ITEM'

Looking at the test files, there are already comprehensive test cases covering both values:

  • test_split_expense_grouping_with_no_bank_transaction_id
  • test_split_expense_grouping_with_same_and_different_ids
  • test_split_expense_grouping_pairs_of_same_ids

Additionally, Django's model field with choices validates the input automatically, so invalid values are handled by the framework's validation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for split_expense_grouping field definition and validation
rg -A 5 "split_expense_grouping" --type py

Length of output: 9817


Script:

#!/bin/bash
# Search for SPLIT_EXPENSE_GROUPING choices definition
rg "SPLIT_EXPENSE_GROUPING.*=" --type py

Length of output: 295

apps/fyle/migrations/0035_support_split_expense_grouping.py (3)

14-18: LGTM: Bank transaction ID field looks good

The field definition is appropriate for storing bank transaction IDs with sufficient length and proper nullability settings.


21-22: Verify choice values match business requirements

The choices for split_expense_grouping are limited to:

  • SINGLE_LINE_ITEM
  • MULTIPLE_LINE_ITEM

Please confirm these values align with the business requirements from the Clickup task.

Consider documenting the meaning and use cases of each choice value in the help text for better maintainability.


19-23: Verify data migration strategy for non-nullable field

The split_expense_grouping field is being added as non-nullable with a default value. Please ensure:

  1. The default function get_default_split_expense_grouping returns a valid choice
  2. Existing records will be properly handled during migration
✅ Verification successful

Data migration strategy for non-nullable field is safe

The verification confirms:

  1. get_default_split_expense_grouping() returns 'MULTIPLE_LINE_ITEM' which is a valid choice defined in SPLIT_EXPENSE_GROUPING tuple
  2. The field is properly handled during migration because:
    • Default value function is correctly implemented
    • The choice is valid and matches the model's choices
    • Test fixtures show consistent usage of 'MULTIPLE_LINE_ITEM' across the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the default function and its return value

# Check the default function implementation
ast-grep --pattern 'def get_default_split_expense_grouping():
  $$$
'

# Check if there are any existing records in the table
rg -A 5 "INSERT INTO.*expense_group_settings" tests/sql_fixtures/

Length of output: 261


Script:

#!/bin/bash

# Check if MULTIPLE_LINE_ITEM is a valid choice in the model
ast-grep --pattern 'class ExpenseGroupSettings($$$):
  $$$
'

# Check for any references to split_expense_grouping in tests
rg "split_expense_grouping.*MULTIPLE_LINE_ITEM" tests/

Length of output: 9300


Script:

#!/bin/bash

# Check the SPLIT_EXPENSE_GROUPING choices definition
rg "SPLIT_EXPENSE_GROUPING.*=" apps/

# Check if there are any existing records in the database from test fixtures
rg "ExpenseGroupSettings.*create" tests/

Length of output: 403

tests/test_workspaces/test_apis/test_export_settings/fixtures.py (1)

29-30: Verify the hardcoded value for split_expense_grouping

The value 'MULTIPLE_LINE_ITEM' is hardcoded in multiple places. Let's verify if this is the only valid value or if we should test other possible values as well.

Also applies to: 78-79

✅ Verification successful

The hardcoded test value 'MULTIPLE_LINE_ITEM' is valid but test coverage could be improved

The model definition shows that split_expense_grouping accepts two valid choices:

  • 'SINGLE_LINE_ITEM'
  • 'MULTIPLE_LINE_ITEM'

While the test fixtures use 'MULTIPLE_LINE_ITEM', there are other test files that verify 'SINGLE_LINE_ITEM' behavior (in tests/test_fyle/conftest.py). The missing field in other test scenarios appears intentional as they likely test different configurations.

Suggestions:

  • Consider adding a test case in test_export_settings/fixtures.py that uses 'SINGLE_LINE_ITEM' to ensure both values work correctly with export settings
  • The current test coverage across different files is adequate, but could be more explicit in this specific test file
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the model definition to find allowed choices
ast-grep --pattern 'split_expense_grouping = models.CharField(
  $$$
  choices=$_,
  $$$
)'

# Search for any other occurrences of this field to understand usage
rg "split_expense_grouping.*=.*" --type python

Length of output: 521


Script:

#!/bin/bash
# Let's first check the SPLIT_EXPENSE_GROUPING choices definition
rg "SPLIT_EXPENSE_GROUPING.*=" -A 5

# Check the default function
rg "get_default_split_expense_grouping"

# Check all occurrences of this field in test files
rg "split_expense_grouping" --type-list
rg "split_expense_grouping" tests/

Length of output: 4180

apps/fyle/models.py (2)

179-179: LGTM! Method updates are consistent.

The new fields are properly integrated into the existing methods:

  • bank_transaction_id is correctly included in the expense creation defaults
  • split_expense_grouping is appropriately handled in the settings update

Also applies to: 326-327


108-108: Verify database migration impact and data handling.

The new fields look well-defined. However, since these are model changes:

  1. Ensure there's a corresponding migration file.
  2. Verify the handling of existing records when bank_transaction_id is null.
  3. Confirm that existing expense group settings will use the default MULTIPLE_LINE_ITEM value.

Also applies to: 242-246

✅ Verification successful

Migration and data handling are properly implemented

The verification shows:

  1. Migration file 0035_support_split_expense_grouping.py exists and correctly adds both fields
  2. bank_transaction_id is nullable with appropriate defaults
  3. split_expense_grouping has a default value function get_default_split_expense_grouping
  4. Test coverage exists for various scenarios including:
    • Expenses with no bank transaction ID
    • Expenses with same/different transaction IDs
    • Multiple pairs of split expenses
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for related migration file
fd --type f ".*split_expense.*\.py$" "apps/fyle/migrations"

# Check for any hardcoded references to the old model structure
rg -l "bank_transaction_id|split_expense_grouping" "tests/"

Length of output: 381


Script:

#!/bin/bash
# Check the migration file content
cat "apps/fyle/migrations/0035_support_split_expense_grouping.py"

# Check test files for handling of new fields
rg "bank_transaction_id|split_expense_grouping" "tests/test_fyle/test_models.py" -A 2

Length of output: 2944

* feat: implement split expense grouping functionality

* feat: add script for split expense grouping (#676)

* feat: add script for split expense grouping

Set the default split expense grouping config to SINGLE_LINE_ITEM for all old orgs

* test: add missing fixtures

* feat: support multiple line items for CC charge exports (#677)

* feat: support multiple line items for CC charge exports

* test: update tests to account for the new function signature

* test: update tests and fixtures

Account for tax balancing and credit card charge lineitems changes

* refactor: move url out of `for` loop
@github-actions github-actions bot added size/L Large PR and removed size/M Medium PR labels Nov 25, 2024
@JustARatherRidiculouslyLongUsername JustARatherRidiculouslyLongUsername merged commit 33a5a88 into split-expenses-db-changes Nov 25, 2024
3 checks passed
Copy link

Tests Skipped Failures Errors Time
232 0 💤 0 ❌ 0 🔥 26.259s ⏱️

JustARatherRidiculouslyLongUsername added a commit that referenced this pull request Nov 25, 2024
…680)

* feat: make db changes and fixture updates to support split expenses

* feat: support GET and PUT for `split_expense_grouping` in export settings (#672)

* feat: support GET and PUT for `split_expense_grouping` in export settings

* feat: implement split expense grouping functionality (#675)

* feat: implement split expense grouping functionality

* feat: add script for split expense grouping (#676)

* feat: add script for split expense grouping

Set the default split expense grouping config to SINGLE_LINE_ITEM for all old orgs

* test: add missing fixtures

* feat: support multiple line items for CC charge exports (#677)

* feat: support multiple line items for CC charge exports

* test: update tests to account for the new function signature

* test: update tests and fixtures

Account for tax balancing and credit card charge lineitems changes

* refactor: move url out of `for` loop
JustARatherRidiculouslyLongUsername added a commit that referenced this pull request Nov 25, 2024
)

* test: write unit tests and add fixtures for split expense grouping

* refactor: remove duplicate bank txn IDs

* test: fix failing tests

* feat: make db changes and fixture updates to support split expenses (#680)

* feat: make db changes and fixture updates to support split expenses

* feat: support GET and PUT for `split_expense_grouping` in export settings (#672)

* feat: support GET and PUT for `split_expense_grouping` in export settings

* feat: implement split expense grouping functionality (#675)

* feat: implement split expense grouping functionality

* feat: add script for split expense grouping (#676)

* feat: add script for split expense grouping

Set the default split expense grouping config to SINGLE_LINE_ITEM for all old orgs

* test: add missing fixtures

* feat: support multiple line items for CC charge exports (#677)

* feat: support multiple line items for CC charge exports

* test: update tests to account for the new function signature

* test: update tests and fixtures

Account for tax balancing and credit card charge lineitems changes

* refactor: move url out of `for` loop
JustARatherRidiculouslyLongUsername added a commit that referenced this pull request Nov 25, 2024
* test: write unit tests and add fixtures for split expense grouping (#670)

* test: write unit tests and add fixtures for split expense grouping

* refactor: remove duplicate bank txn IDs

* test: fix failing tests

* feat: make db changes and fixture updates to support split expenses (#680)

* feat: make db changes and fixture updates to support split expenses

* feat: support GET and PUT for `split_expense_grouping` in export settings (#672)

* feat: support GET and PUT for `split_expense_grouping` in export settings

* feat: implement split expense grouping functionality (#675)

* feat: implement split expense grouping functionality

* feat: add script for split expense grouping (#676)

* feat: add script for split expense grouping

Set the default split expense grouping config to SINGLE_LINE_ITEM for all old orgs

* test: add missing fixtures

* feat: support multiple line items for CC charge exports (#677)

* feat: support multiple line items for CC charge exports

* test: update tests to account for the new function signature

* test: update tests and fixtures

Account for tax balancing and credit card charge lineitems changes

* refactor: move url out of `for` loop
JustARatherRidiculouslyLongUsername added a commit that referenced this pull request Nov 26, 2024
* test: write unit tests and add fixtures for split expense grouping (#670)

* test: write unit tests and add fixtures for split expense grouping

* refactor: remove duplicate bank txn IDs

* test: fix failing tests

* feat: make db changes and fixture updates to support split expenses (#680)

* feat: make db changes and fixture updates to support split expenses

* feat: support GET and PUT for `split_expense_grouping` in export settings (#672)

* feat: support GET and PUT for `split_expense_grouping` in export settings

* feat: implement split expense grouping functionality (#675)

* feat: implement split expense grouping functionality

* feat: add script for split expense grouping (#676)

* feat: add script for split expense grouping

Set the default split expense grouping config to SINGLE_LINE_ITEM for all old orgs

* test: add missing fixtures

* feat: support multiple line items for CC charge exports (#677)

* feat: support multiple line items for CC charge exports

* test: update tests to account for the new function signature

* test: update tests and fixtures

Account for tax balancing and credit card charge lineitems changes

* refactor: move url out of `for` loop

(cherry picked from commit c0309e8)
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.

2 participants