Skip to content

[ENG-698] Add basic end to end account->invoice->CI->P fixtures#3709

Draft
yash-learner wants to merge 2 commits into
ohcnetwork:developfrom
yash-learner:ENG-698-add-fixtures-billing/account
Draft

[ENG-698] Add basic end to end account->invoice->CI->P fixtures#3709
yash-learner wants to merge 2 commits into
ohcnetwork:developfrom
yash-learner:ENG-698-add-fixtures-billing/account

Conversation

@yash-learner

@yash-learner yash-learner commented Jul 10, 2026

Copy link
Copy Markdown
Member

Proposed Changes

Fixed https://openhealthcarenetwork.atlassian.net/browse/ENG-698

  • Add the helper methods in base.py
  • Add biiling.py which seeds
    • 2 Accounts for first 2 patient created.
    • 12 charge items with different CID's
    • 8 invoices across statuses/date ranges
    • 2 payments for balanced invoices
......
Loading lab definitions completed
Loading inventory completed
Loading billing (accounts, charge items, invoices) completed
Loading scheduling completed
Loading managing organization completed

The fixtures can be further extended later with different variants of invoice -> locked, PayementReconciliation etc

Associated Issue

  • Link to issue here, explain how the proposed solution will solve the reported issue/ feature request.

Architecture changes

  • Remove this section if not used

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

    • Added comprehensive billing fixture data, including accounts, charge items, invoices, payments, and multiple invoice statuses.
    • Default fixture loading now includes billing records linked to patients and encounters.
    • Added support for configuring invoice numbering and realistic invoice dates.
  • Documentation

    • Documented the billing fixture helpers, invoice lifecycle, charge-item states, and billing data loading process.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds reusable billing fixture helpers, a billing dataset orchestrator, authenticated fixture context support, and default fixture integration for accounts, charge items, invoices, payments, and invoice lifecycle states.

Changes

Billing fixture seeding

Layer / File(s) Summary
Billing fixture helper API
care/fixtures/base.py, care/fixtures/context.py
Adds account, charge-item, invoice, payment, expression, reconciliation, lifecycle, and listing helpers; fixture contexts now expose the created superuser.
Invoice dataset orchestration
care/fixtures/billing.py
Adds configurable billing plans and seeds accounts and invoices with draft, issued, canceled, and balanced states.
Default fixture integration and documentation
care/fixtures/scripts/default_fixtures.py, care/fixtures/fixtures.md
Captures encounters, invokes billing loading after inventory setup, logs completion, and documents the billing fixture layer.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main change: adding basic account-to-invoice billing fixtures.
Description check ✅ Passed It includes the required sections and enough detail, though the issue link is tucked into Proposed Changes instead of the Associated Issue section.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@yash-learner

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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

🤖 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/fixtures/fixtures.md`:
- Line 137: Update the issue_invoice documentation entry to include its optional
issue_date parameter, matching the signature in base.py and usage in billing.py;
describe that it can backdate the invoice issue date.
🪄 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: ffe51ab3-2dd0-42db-9f34-31997e56d487

📥 Commits

Reviewing files that changed from the base of the PR and between e26a3c6 and cccf854.

📒 Files selected for processing (5)
  • care/fixtures/base.py
  • care/fixtures/billing.py
  • care/fixtures/context.py
  • care/fixtures/fixtures.md
  • care/fixtures/scripts/default_fixtures.py

Comment thread care/fixtures/fixtures.md
- `create_invoice(facility_id, account_id, charge_items, created_date=None, **kwargs)` — an invoice linking `billable` charge items on the account.
- The invoice is created through the API as `draft` (the viewset forces `draft` and marks the linked charge items `billed`, then syncs totals).
- **`created_date` caveat:** the API stamps `created_date` to `now`. When `created_date` is passed, the helper backdates it via a direct ORM `update()` after creation — a deliberate exception to the API-only fixture rule, needed so the invoice list date-range filter has data spread across known dates.
- `issue_invoice(facility_id, invoice)` — transitions a draft invoice to `issued` (snapshots line items and totals).

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Doc for issue_invoice is missing the issue_date param it actually documents elsewhere as necessary.

base.py defines issue_invoice(self, facility_id, invoice, issue_date=None), and billing.py relies on it (issue_date=created.isoformat()) to backdate issue dates. The doc line only shows issue_invoice(facility_id, invoice). Small thing, but docs that quietly drop a parameter aren't exactly doing their job.

📝 Suggested doc fix
-- `issue_invoice(facility_id, invoice)` — transitions a draft invoice to `issued` (snapshots line items and totals).
+- `issue_invoice(facility_id, invoice, issue_date=None)` — transitions a draft invoice to `issued` (snapshots line items and totals); pass `issue_date` to backdate the transition.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- `issue_invoice(facility_id, invoice)` — transitions a draft invoice to `issued` (snapshots line items and totals).
`issue_invoice(facility_id, invoice, issue_date=None)` — transitions a draft invoice to `issued` (snapshots line items and totals); pass `issue_date` to backdate the transition.
🤖 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/fixtures/fixtures.md` at line 137, Update the issue_invoice
documentation entry to include its optional issue_date parameter, matching the
signature in base.py and usage in billing.py; describe that it can backdate the
invoice issue date.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 101 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.33%. Comparing base (e26a3c6) to head (cccf854).

Files with missing lines Patch % Lines
care/fixtures/base.py 0.00% 49 Missing ⚠️
care/fixtures/billing.py 0.00% 44 Missing ⚠️
care/fixtures/scripts/default_fixtures.py 0.00% 5 Missing ⚠️
care/fixtures/context.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3709      +/-   ##
===========================================
- Coverage    79.67%   79.33%   -0.35%     
===========================================
  Files          479      480       +1     
  Lines        23098    23197      +99     
  Branches      2406     2417      +11     
===========================================
  Hits         18404    18404              
- Misses        4086     4185      +99     
  Partials       608      608              

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

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.

1 participant