# Decimal and Float Type Error Fix

## Problem

A TypeError was occurring in production when viewing loan details:

```
TypeError at /loans/30f53996-bf7c-4c17-8a10-717695c2cf1c/ 
unsupported operand type(s) for *: 'decimal.Decimal' and 'float'
```

The error was occurring in the `calculate_penalty` method in `loans/models.py` at line 688. The issue was that a Decimal value was being multiplied by a float value, which is not supported in Python.

## Solution

The following changes were made to fix the issue:

1. In the `calculate_penalty` method, converted the float value to a Decimal before performing the multiplication:
   ```python
   # Before
   daily_penalty_rate = self.application.loan_product.get_late_payment_penalty() / 100
   
   # After
   daily_penalty_rate = Decimal(str(self.application.loan_product.get_late_payment_penalty())) / Decimal('100')
   ```

2. Similar issues were also fixed in the `calculate_risk_score` and `get_risk_assessment` methods to ensure consistent use of Decimal types for financial calculations.

## Files Modified

- `loans/models.py`

## Verification

The fix ensures that all mathematical operations involving Decimal values use Decimal operands, preventing the TypeError from occurring. This is particularly important for financial calculations to maintain precision and avoid type errors.

## Recommendations

1. Use Decimal types consistently for all financial calculations.
2. When converting from float to Decimal, always use `Decimal(str(float_value))` to avoid precision issues.
3. Consider adding unit tests that verify the behavior of financial calculation methods with different input types.
4. Add type hints to methods that deal with financial calculations to make the expected types clearer.
5. Consider implementing a code linter rule to detect mixed Decimal and float operations.