Skip to content

Feature/charge schemas - #62

Merged
NouhJama merged 2 commits into
mainfrom
feature/charge-schemas
Aug 27, 2026
Merged

NouhJama merged 2 commits into
mainfrom
feature/charge-schemas

Conversation

@NouhJama

Copy link
Copy Markdown
Owner

No description provided.

NouhJama and others added 2 commits August 25, 2026 17:06
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>
@NouhJama
NouhJama merged commit 421ea10 into main Aug 27, 2026
1 check passed
@NouhJama
NouhJama deleted the feature/charge-schemas branch August 27, 2026 10:56
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