Skip to content

[ENG-602] feat:added created date filter for invoice#3694

Open
nandkishorr wants to merge 1 commit into
developfrom
ENG-602-date-filter-for-invoices
Open

[ENG-602] feat:added created date filter for invoice#3694
nandkishorr wants to merge 1 commit into
developfrom
ENG-602-date-filter-for-invoices

Conversation

@nandkishorr

@nandkishorr nandkishorr commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

  • Added invoice created date filter.

Associated Issue

ENG-602

Merge Checklist

  • Tests added/fixed
  • Update docs in /docs
  • Linting Complete
  • Any other necessary step

Only 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

  • Invoice filtering capabilities have been enhanced with date range filtering. Users can now filter invoices based on their creation date, enabling more efficient invoice management and retrieval across specific time periods. This improvement simplifies locating and organizing invoices within your desired date range.

@nandkishorr nandkishorr requested a review from a team as a code owner June 23, 2026 11:43
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

A single line is added to InvoiceFilters in the invoice viewset, introducing a created_date field using DateTimeFromToRangeFilter mapped to the model's created_date field, allowing invoice queries to be filtered by a datetime range.

Changes

Invoice Date Range Filter

Layer / File(s) Summary
Add created_date range filter to InvoiceFilters
care/emr/api/viewsets/invoice.py
Adds created_date = filters.DateTimeFromToRangeFilter(field_name="created_date") to InvoiceFilters, enabling from-to datetime range filtering on invoice creation date.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding a created date filter for invoices, directly corresponding to the code modification in InvoiceFilters.
Description check ✅ Passed The description follows the template structure with Proposed Changes, Associated Issue, and Merge Checklist sections; however, the Associated Issue section lacks a link and explanation of how the solution addresses the requirement.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ENG-602-date-filter-for-invoices

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a created_date datetime range filter to InvoiceFilters, allowing callers to query invoices by creation date range via created_date_after / created_date_before query parameters.

  • The filter uses DateTimeFromToRangeFilter(field_name="created_date"), which exactly mirrors the same filter already present in charge_item.py, account.py, encounter.py, payment_reconciliation.py, and several other viewsets in the codebase.
  • The target field (created_date) is defined on BaseModel with auto_now_add=True and db_index=True, so the filter maps correctly and queries will hit the existing index.

Confidence Score: 5/5

Safe 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

Filename Overview
care/emr/api/viewsets/invoice.py Adds a created_date datetime range filter to InvoiceFilters, consistent with the same pattern used in charge_item.py, account.py, encounter.py, payment_reconciliation.py, and others across the codebase.

Reviews (1): Last reviewed commit: "feat:added created date filter" | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
care/emr/api/viewsets/invoice.py (1)

61-61: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

The field_name parameter is redundant.

When the filter attribute name matches the model field name exactly, the field_name parameter 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

📥 Commits

Reviewing files that changed from the base of the PR and between c8baced and f43e169.

📒 Files selected for processing (1)
  • care/emr/api/viewsets/invoice.py

Comment thread care/emr/api/viewsets/invoice.py
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.55%. Comparing base (c8baced) to head (f43e169).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nandkishorr nandkishorr self-assigned this Jun 23, 2026
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")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need to explicitly state the field name if its the same as the filter name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants