"""
Quick test for processing fees property tests
"""
import os
import django

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'branch_system.settings')
django.setup()

from datetime import date, timedelta
from decimal import Decimal

# Test Property 16: Processing fees aggregation
def test_processing_fees_aggregation():
    """Test that sum of processing fees equals total"""
    fees = [Decimal('100.00'), Decimal('200.00'), Decimal('150.50'), Decimal('75.25')]
    expected_total = sum(fees)
    calculated_total = sum(fees)
    
    assert calculated_total == expected_total, f"Aggregation failed: {calculated_total} != {expected_total}"
    print(f"✓ Property 16 (Processing fees aggregation): PASS")
    print(f"  Total fees: {calculated_total}")

# Test Property 17: Period comparison duration equality
def test_period_comparison_duration():
    """Test that previous period has same duration as current period"""
    # Test case 1: 30-day period
    current_start = date(2024, 1, 1)
    current_end = date(2024, 1, 30)
    current_duration = (current_end - current_start).days
    
    # Calculate previous period
    previous_end = current_start - timedelta(days=1)
    previous_start = previous_end - timedelta(days=current_duration)
    previous_duration = (previous_end - previous_start).days
    
    assert current_duration == previous_duration, f"Duration mismatch: {current_duration} != {previous_duration}"
    print(f"✓ Property 17 (Period comparison duration): PASS")
    print(f"  Current period: {current_duration} days")
    print(f"  Previous period: {previous_duration} days")
    
    # Test case 2: 7-day period
    current_start = date(2024, 6, 1)
    current_end = date(2024, 6, 7)
    current_duration = (current_end - current_start).days
    
    previous_end = current_start - timedelta(days=1)
    previous_start = previous_end - timedelta(days=current_duration)
    previous_duration = (previous_end - previous_start).days
    
    assert current_duration == previous_duration, f"Duration mismatch: {current_duration} != {previous_duration}"
    print(f"✓ Property 17 (7-day period): PASS")
    
    # Test case 3: 90-day period
    current_start = date(2024, 1, 1)
    current_end = date(2024, 3, 31)
    current_duration = (current_end - current_start).days
    
    previous_end = current_start - timedelta(days=1)
    previous_start = previous_end - timedelta(days=current_duration)
    previous_duration = (previous_end - previous_start).days
    
    assert current_duration == previous_duration, f"Duration mismatch: {current_duration} != {previous_duration}"
    print(f"✓ Property 17 (90-day period): PASS")

if __name__ == '__main__':
    print("Testing Processing Fees Properties...")
    print("=" * 60)
    test_processing_fees_aggregation()
    print()
    test_period_comparison_duration()
    print("=" * 60)
    print("All property tests passed!")

