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: bill number edge case: #673

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/quickbooks_online/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def get_bill_number(expense_group: ExpenseGroup):

bill_number = expense_group.expenses.first().__getattribute__(bill_number_field)

count = Bill.objects.filter(bill_number=bill_number, expense_group__workspace_id=expense_group.workspace.id).count()
count = Bill.objects.filter(bill_number__icontains=bill_number, expense_group__workspace_id=expense_group.workspace.id).count()
if count > 0:
bill_number = '{} - {}'.format(bill_number, count)
Comment on lines +195 to 197
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Suggestion: Add tests for the new bill number matching behavior

While the change in the get_bill_number function is localized, it's important to ensure that this new behavior is properly tested. This will help catch any potential issues with the new matching logic and prevent regressions in the future.

Consider adding the following types of tests:

  1. Test with exact match bill numbers
  2. Test with case-insensitive matches
  3. Test with partial matches
  4. Test with multiple potential matches
  5. Test with no matches

These tests will help validate the new behavior and ensure it works as expected across different scenarios.

return bill_number
Expand Down
Loading