Skip to main content

A Python library for lease management calculations and business logic

Project description

Lease Management System Library

A Python library for lease management calculations and business logic.

Features

  • Lease expiry calculations
  • Rent due date calculations
  • Prorated rent calculations
  • Late fee calculations
  • Lease validation
  • Notification message formatting
  • ID generation

Installation

pip install lease-management-system

Quick Start

from lease_management import LeaseCalculator

# Generate IDs
lease_id = LeaseCalculator.generate_lease_id()
property_id = LeaseCalculator.generate_property_id()

# Calculate days until expiry
days = LeaseCalculator.calculate_days_until_expiry('2026-12-31')
print(f"Days until expiry: {days}")

# Check if lease expiring soon (within 30 days)
is_expiring = LeaseCalculator.is_lease_expiring_soon('2026-05-10', days_threshold=30)

# Calculate total rent
total = LeaseCalculator.calculate_total_rent(monthly_rent=1500, months=12)
print(f"Total rent: ${total}")

# Validate lease dates
validation = LeaseCalculator.validate_lease_dates('2026-01-01', '2026-12-31')
if validation['valid']:
    print("Dates are valid")
else:
    print(f"Error: {validation['error']}")

# Filter expiring leases
leases = [
    {'lease_id': '1', 'lease_end_date': '2026-05-10'},
    {'lease_id': '2', 'lease_end_date': '2026-12-31'}
]
expiring = LeaseCalculator.filter_expiring_leases(leases, days_threshold=30)

# Format notification message
message = LeaseCalculator.format_notification_message(
    tenant_name='John Doe',
    notification_type='lease_expiry',
    lease_data={
        'property_id': 'prop-123',
        'lease_end_date': '2026-05-10',
        'rent_amount': '1500'
    }
)
print(message['subject'])
print(message['message'])

API Reference

ID Generation

  • generate_lease_id() - Generate unique lease ID
  • generate_property_id() - Generate unique property ID
  • generate_tenant_id() - Generate unique tenant ID

Date Calculations

  • calculate_days_until_expiry(lease_end_date) - Days until lease expires
  • calculate_days_until_rent_due(rent_due_date) - Days until rent is due
  • calculate_lease_duration_months(start_date, end_date) - Lease duration in months

Validation

  • validate_lease_dates(start_date, end_date) - Validate lease dates
  • is_lease_expiring_soon(lease_end_date, days_threshold) - Check if expiring soon
  • is_rent_due_soon(rent_due_date, days_threshold) - Check if rent due soon

Financial Calculations

  • calculate_total_rent(monthly_rent, months) - Total rent for period
  • calculate_prorated_rent(monthly_rent, days_in_month, days_occupied) - Prorated rent
  • calculate_late_fee(rent_amount, days_late, daily_rate) - Late fee calculation

Filtering

  • filter_expiring_leases(leases, days_threshold) - Filter leases expiring soon
  • filter_rent_due_soon(leases, days_threshold) - Filter leases with rent due soon

Notifications

  • format_notification_message(tenant_name, notification_type, lease_data) - Format notification

Use Cases

Check Expiring Leases

from lease_management import LeaseCalculator

leases = get_all_leases()  # Your data source
expiring = LeaseCalculator.filter_expiring_leases(leases, days_threshold=30)

for lease in expiring:
    days = LeaseCalculator.calculate_days_until_expiry(lease['lease_end_date'])
    print(f"Lease {lease['lease_id']} expires in {days} days")

Calculate Rent

# Full month rent
monthly_rent = 1500
months = 12
total = LeaseCalculator.calculate_total_rent(monthly_rent, months)

# Prorated rent for partial month
prorated = LeaseCalculator.calculate_prorated_rent(
    monthly_rent=1500,
    days_in_month=30,
    days_occupied=15
)

Generate Notifications

lease_data = {
    'property_id': 'prop-123',
    'lease_end_date': '2026-05-10',
    'rent_amount': '1500'
}

message = LeaseCalculator.format_notification_message(
    tenant_name='John Doe',
    notification_type='lease_expiry',
    lease_data=lease_data
)

# Send via your notification system
send_email(to=tenant_email, subject=message['subject'], body=message['message'])

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lease_management_system-0.0.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lease_management_system-0.0.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file lease_management_system-0.0.2.tar.gz.

File metadata

  • Download URL: lease_management_system-0.0.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for lease_management_system-0.0.2.tar.gz
Algorithm Hash digest
SHA256 24797a9f986a9cf0da5bd667de1ea8bee3b90023601ec426d08396af33480bb5
MD5 943bf075774fd26c3eadcb7ce89305cc
BLAKE2b-256 241243d41895a1d946efa43c09a3a308dd90f379bf7a32ce1eab048715ca9252

See more details on using hashes here.

File details

Details for the file lease_management_system-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for lease_management_system-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d159a8bd411057177028c349c326c8d178392cd2f71bfca870b49c20f81b76dc
MD5 548272b6c5ef35dae6b25e8bf4e00ce4
BLAKE2b-256 8b29209e28fc8303c9e26d2aa6bf5dfb6eedda4b3a500172174b09d7b25df309

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page