[ENG-602] feat:added created date filter for invoice#3694
Conversation
📝 WalkthroughWalkthroughA single line is added to ChangesInvoice Date Range Filter
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR adds a
Confidence Score: 5/5Safe to merge — this is a single-line filter addition with no side effects on write paths. The change is a one-line filter addition that exactly matches the same pattern used across at least seven other viewsets in the codebase. The target field exists on the model, is indexed, and is already exposed via ordering_fields in the same viewset. No logic, permissions, or data paths are modified. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "feat:added created date filter" | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
care/emr/api/viewsets/invoice.py (1)
61-61: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueThe
field_nameparameter is redundant.When the filter attribute name matches the model field name exactly, the
field_nameparameter can be omitted. Looking at lines 52, 53, 56, 57, and 58, you'll notice they follow this pattern.♻️ Simplify by removing redundant parameter
- created_date = filters.DateTimeFromToRangeFilter(field_name="created_date") + created_date = filters.DateTimeFromToRangeFilter()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@care/emr/api/viewsets/invoice.py` at line 61, The DateTimeFromToRangeFilter for the created_date attribute includes a redundant field_name parameter that specifies the same name as the filter attribute itself. Remove the field_name="created_date" parameter from the DateTimeFromToRangeFilter definition since when the filter attribute name matches the model field name exactly, the field_name parameter is unnecessary and can be omitted, consistent with the pattern used in other filter definitions in the same file.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@care/emr/api/viewsets/invoice.py`:
- Line 61: Add test cases for the `created_date` filter in the invoice viewset
to verify all filtering scenarios. Create tests that cover filtering by start
date only, filtering by end date only, filtering by both start and end dates
together, and edge cases such as invalid datetime formats or malformed range
parameters. Ensure the tests validate that the DateTimeFromToRangeFilter
correctly applies the range constraints to the invoice queryset and returns the
expected results for each scenario.
---
Nitpick comments:
In `@care/emr/api/viewsets/invoice.py`:
- Line 61: The DateTimeFromToRangeFilter for the created_date attribute includes
a redundant field_name parameter that specifies the same name as the filter
attribute itself. Remove the field_name="created_date" parameter from the
DateTimeFromToRangeFilter definition since when the filter attribute name
matches the model field name exactly, the field_name parameter is unnecessary
and can be omitted, consistent with the pattern used in other filter definitions
in the same file.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 13ed29dd-006c-4a1d-9bd5-79cddca2c049
📒 Files selected for processing (1)
care/emr/api/viewsets/invoice.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3694 +/- ##
========================================
Coverage 79.55% 79.55%
========================================
Files 479 479
Lines 22996 22997 +1
Branches 2378 2378
========================================
+ Hits 18295 18296 +1
Misses 4096 4096
Partials 605 605 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| is_refund = filters.BooleanFilter() | ||
| payment_reconciliation_present = DummyBooleanFilter() | ||
| created_by = filters.UUIDFilter(field_name="created_by__external_id") | ||
| created_date = filters.DateTimeFromToRangeFilter(field_name="created_date") |
There was a problem hiding this comment.
No need to explicitly state the field name if its the same as the filter name
Proposed Changes
Associated Issue
ENG-602
Merge Checklist
/docsOnly PR's with test cases included and passing lint and test pipelines will be reviewed
@ohcnetwork/care-backend-maintainers @ohcnetwork/care-backend-admins
Summary by CodeRabbit
New Features