Repository navigation
Feature/charge schemas - #62
Merged
Merged
Conversation
ChargeBase carries validate_party_for_category (model_validator, mode=after), which is where the 'exactly one of owner_id/tenant_id' rule is genuinely enforced: service_charge requires an owner_id and a percentage and forbids a tenant_id; rent/water/move_out require a tenant_id and forbid both owner_id and percentage. The database deliberately allows both FK columns to be nullable, since a single column can't conditionally point at two tables with real referential integrity -- so the pairing rule lives at the schema layer, same approach as Unit's bedrooms/unit_type rule. amount and percentage use Decimal, never float, matching the model's Numeric columns. ChargeUpdate deliberately excludes category, unit_id, owner_id and tenant_id -- changing any of them would silently rewrite financial history rather than correct it; cancel the wrong charge and create a correct one instead. is_cancelled is excluded too, since cancelling has its own narrow admin-only schema (ChargeCancel). Charge has no delete schema anywhere by design -- financial records are voided, never destroyed, so the audit trail always survives. Verified: 10 schema checks pass (valid rent, valid service_charge, and 5 distinct rejection cases), all 51 existing tests still pass.
Deliberately has no delete() — financial records are voided via cancel(), never destroyed, so the audit trail always survives. Adds two query shapes no previous repository needed: inclusive period-range filtering and a database-side SUM that excludes cancelled charges. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
No description provided.