from decimal import Decimal

# Simulate the fixed calculate_penalty function
def calculate_penalty_before_fix(outstanding_amount, days_overdue, penalty_rate):
    # This simulates the bug - multiplying Decimal by float
    daily_penalty_rate = penalty_rate / 100
    return outstanding_amount * daily_penalty_rate * days_overdue

def calculate_penalty_after_fix(outstanding_amount, days_overdue, penalty_rate):
    # This simulates our fix - converting to Decimal before operations
    daily_penalty_rate = Decimal(str(penalty_rate)) / Decimal('100')
    return outstanding_amount * daily_penalty_rate * days_overdue

# Test with sample values
outstanding_amount = Decimal('10000.00')
days_overdue = 5
penalty_rate = 2.5  # 2.5% penalty rate

print("Testing Decimal fix for calculate_penalty function")
print("-" * 50)

try:
    # This would fail with TypeError
    result_before = calculate_penalty_before_fix(outstanding_amount, days_overdue, penalty_rate)
    print(f"Before fix (should fail): {result_before}")
except TypeError as e:
    print(f"Before fix correctly raises: {e}")

try:
    # This should work with our fix
    result_after = calculate_penalty_after_fix(outstanding_amount, days_overdue, penalty_rate)
    print(f"After fix: {result_after}")
    print(f"Result type: {type(result_after)}")
    print("Fix successful!")
except Exception as e:
    print(f"After fix still has an error: {e}")