[ENG-698] Add basic end to end account->invoice->CI->P fixtures#3709
[ENG-698] Add basic end to end account->invoice->CI->P fixtures#3709yash-learner wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughAdds 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. ChangesBilling fixture seeding
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
care/fixtures/base.pycare/fixtures/billing.pycare/fixtures/context.pycare/fixtures/fixtures.mdcare/fixtures/scripts/default_fixtures.py
| - `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). |
There was a problem hiding this comment.
📐 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.
| - `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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Proposed Changes
Fixed https://openhealthcarenetwork.atlassian.net/browse/ENG-698
The fixtures can be further extended later with different variants of invoice -> locked, PayementReconciliation etc
Associated Issue
Architecture changes
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
Documentation