COHIV-203: Refactor Report configuration and NK report#383
Draft
MarcoSteinacher wants to merge 42 commits into
Draft
COHIV-203: Refactor Report configuration and NK report#383MarcoSteinacher wants to merge 42 commits into
MarcoSteinacher wants to merge 42 commits into
Conversation
NkCost.get_section_weights() was returning equal weights (1.0) for all sections, ignoring the section_weights profile configured per cost item. It now looks up the profile from the report's section_weights dict and applies the correct weight per section (matched via section.id.capitalize()). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests two NkTotalCost instances side-by-side: - "Wasser_Abwasser" with default section weights (all sections at 1.0), verifying costs are split purely by area - "Reinigung" with "reinigung" section weights (Wohnen=0.7, Gewerbe=1.0, Lager=1.0, Allgemein=0.0), verifying the section weight scales the rental unit's effective area when distributing costs Both individual rental unit costs and section totals are asserted. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Calculates costs individually per rental unit rather than distributing a total amount. Mirrors the logic from the old report_nk.internetrechnung(): - Fixed fee per rental unit name (from config key fixed_fees_key) - Or: fee_per_unit + min_occupancy × fee_per_person (from config keys fee_per_unit_key / fee_per_person_key) - Monthly amounts are scaled by get_monthly_weights() - split_costs() aggregates the per-unit amounts up to sections and total instead of distributing a total downward via weights Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Path 1 (fixed fee): G001 configured with a fixed 100 CHF/month via Internet:Tarif:Fix, verified against 100 × num_months - Path 2 (per-unit + per-person × min_occupancy): 001a (min_occupancy=3) and 001b (min_occupancy=1) verified using Internet:Tarif:ProWohnung and Internet:Tarif:ProPerson config values - Path 3 (zero): G002 with no min_occupancy and no fixed fee → 0 - Section and grand totals verified to aggregate correctly from rental units Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add NkCostZEVStromallmend (cost/zev.py): new NkCost subclass implementing
ZEV electricity cost calculation per rental unit, mirroring the logic of
the old report_nk.stromrechnung(). Reads measurement data from
report.object_messung[ru.name] and building totals from report.data_amount,
computes eigenverbrauch solar, netzstrom, HKN, and corrections.
- Add NkCost.get_extra_context() hook (cost/base.py): base class returns {}
by default; subclasses can override to inject extra variables into the ODT
bill template context beyond the standard billing-group fields.
- Modify NkBill._get_rental_unit_context() (bill.py): after building the
costs list, call get_extra_context() on every cost and merge the result
into the context dict, enabling NkCostZEVStromallmend to inject the
ssd_*, sss_*, snh_*, snt_*, shk_*, sk_*, st_*, stot_* variables required
by the Stromkosten section of the ODT template.
- Add tests (tests/test_nk_zev.py): three test cases covering correct
per-unit cost calculation, extra-context variable generation, and the
no-measurement-data zero case.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…efactor_nk_config
- Add ReportInput choice fields for enums - Add enums for weights - Fix report config default value issue - Add monthly weights - Add base settings report item - Separate config structure `get_report_item_config()` from the actual costs config `get_costs_from_config()`
- Flattened measurement data config - Replaced INPUT_KEY fields with actual value fields
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I confirm that I have read the Contributor Agreement v1.1, agree to be bound on them and confirm that my contribution is compliant.