+27 33 396 9461 phil@philprecious.co.za
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Phil Precious Auto Sales Finance Calculator</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Inter', sans-serif;
            background-color: #333;
            color: white;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .calculator {
            max-width: 400px;
            width: 100%;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 10px;
            background-color: #444;
            text-align: center;
        }
        .calculator h2 {
            color: white;
            margin-bottom: 20px;
        }
        .calculator label {
            display: block;
            text-align: left;
            margin-bottom: 5px;
        }
        .calculator input, .calculator select {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            background-color: #555;
            color: white;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        .calculator button {
            width: 100%;
            padding: 10px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        .calculator button:hover {
            background-color: #0056b3;
        }
        .result {
            margin-top: 20px;
        }
    </style>
</head>
<body>

<div class="calculator">
    <h2>Phil Precious Auto Sales Finance Calculator</h2>
    <label for="vehiclePrice">Vehicle Price (ZAR):</label>
    <input type="number" id="vehiclePrice" required>

    <label for="downPayment">Down Payment (ZAR):</label>
    <input type="number" id="downPayment" required>

    <label for="tradeInValue">Trade-in Value (ZAR):</label>
    <input type="number" id="tradeInValue" required>

    <label for="interestRate">Annual Interest Rate (%):</label>
    <input type="number" id="interestRate" step="0.01" required>

    <label for="loanTerm">Loan Term (years):</label>
    <input type="number" id="loanTerm" required>

    <button onclick="calculateFinance()">Calculate</button>

    <div class="result">
        <p id="loanAmount"></p>
        <p id="monthlyPayment"></p>
        <p id="totalCost"></p>
    </div>
</div>

<script>
    function calculateMonthlyPayment(loanAmount, annualInterestRate, loanTermYears) {
        const monthlyInterestRate = annualInterestRate / 100 / 12;
        const numberOfPayments = loanTermYears * 12;
        if (annualInterestRate === 0) {
            return loanAmount / numberOfPayments;
        }
        return loanAmount * monthlyInterestRate / (1 - Math.pow(1 + monthlyInterestRate, -numberOfPayments));
    }

    function calculateTotalCost(monthlyPayment, loanTermYears) {
        return monthlyPayment * loanTermYears * 12;
    }

    function formatCurrency(amount) {
        return new Intl.NumberFormat('en-ZA', {
            style: 'currency',
            currency: 'ZAR'
        }).format(amount);
    }

    function calculateFinance() {
        const vehiclePrice = parseFloat(document.getElementById('vehiclePrice').value);
        const downPayment = parseFloat(document.getElementById('downPayment').value);
        const tradeInValue = parseFloat(document.getElementById('tradeInValue').value);
        const annualInterestRate = parseFloat(document.getElementById('interestRate').value);
        const loanTermYears = parseInt(document.getElementById('loanTerm').value);

        const loanAmount = vehiclePrice - downPayment - tradeInValue;
        const monthlyPayment = calculateMonthlyPayment(loanAmount, annualInterestRate, loanTermYears);
        const totalCost = calculateTotalCost(monthlyPayment, loanTermYears);

        document.getElementById('loanAmount').innerText = `Loan Amount: ${formatCurrency(loanAmount)}`;
        document.getElementById('monthlyPayment').innerText = `Monthly Payment: ${formatCurrency(monthlyPayment)}`;
        document.getElementById('totalCost').innerText = `Total Cost: ${formatCurrency(totalCost)}`;
    }
</script>

</body>
</html>