Untitled

 avatar
unknown
plain_text
8 days ago
3.5 kB
3
Indexable
// Singapore Corporate Tax Rate (after Partial Tax Exemption)
function calculateCorporateTax(chargeableIncome) {
  let tax = 0;

  // Apply Partial Tax Exemption
  if (chargeableIncome <= 10000) {
    // 75% exemption on the first SGD 10,000
    tax = chargeableIncome * 0.17 * 0.25; // Only 25% of the first SGD 10,000 is taxable
  } else if (chargeableIncome <= 200000) {
    // 75% exemption on the first SGD 10,000
    tax = 10000 * 0.17 * 0.25;
    // 50% exemption on the next SGD 190,000
    tax += (chargeableIncome - 10000) * 0.17 * 0.5;
  } else {
    // 75% exemption on the first SGD 10,000
    tax = 10000 * 0.17 * 0.25;
    // 50% exemption on the next SGD 190,000
    tax += 190000 * 0.17 * 0.5;
    // Remaining income taxed at 17%
    tax += (chargeableIncome - 200000) * 0.17;
  }

  return tax;
}

// Singapore Personal Income Tax Rates (2023 rates)
const personalTaxRates = [
  { min: 0, max: 20000, rate: 0 },
  { min: 20001, max: 30000, rate: 0.02 },
  { min: 30001, max: 40000, rate: 0.035 },
  { min: 40001, max: 80000, rate: 0.07 },
  { min: 80001, max: 120000, rate: 0.115 },
  { min: 120001, max: 160000, rate: 0.15 },
  { min: 160001, max: 200000, rate: 0.18 },
  { min: 200001, max: Infinity, rate: 0.22 },
];

// Function to calculate personal income tax
function calculatePersonalTax(income) {
  let tax = 0;
  for (const bracket of personalTaxRates) {
    if (income > bracket.min) {
      const taxableAmount = Math.min(income, bracket.max) - bracket.min;
      tax += taxableAmount * bracket.rate;
    }
  }
  return tax;
}

// Function to find the optimal split
function findOptimalSplit(totalAmount) {
  let optimalDividends = 0;
  let optimalDirectorFees = 0;
  let minTotalTax = Infinity;

  // Iterate through all possible splits
  for (let dividends = 0; dividends <= totalAmount; dividends += 1000) {
    const directorFees = totalAmount - dividends;

    // Calculate corporate tax on dividends
    const corporateTax = calculateCorporateTax(dividends);

    // Calculate personal tax on director fees
    const personalTax = calculatePersonalTax(directorFees);

    // Calculate total tax
    const totalTax = corporateTax + personalTax;

    // Check if this is the optimal split
    if (totalTax < minTotalTax) {
      minTotalTax = totalTax;
      optimalDividends = dividends;
      optimalDirectorFees = directorFees;
    }
  }

  return {
    dividends: optimalDividends,
    directorFees: optimalDirectorFees,
    totalTax: minTotalTax,
  };
}

// Main calculation function
function calculate() {
  const amount = parseFloat(document.getElementById('amount').value);

  if (isNaN(amount) || amount <= 0) {
    alert("Please enter a valid amount.");
    return;
  }

  // Find the optimal split
  const optimalSplit = findOptimalSplit(amount);

  // Display results
  document.getElementById('dividendsResult').innerText =
    `Dividends: SGD ${optimalSplit.dividends.toFixed(2)} (Tax: SGD ${calculateCorporateTax(optimalSplit.dividends).toFixed(2)})`;

  document.getElementById('directorFeesResult').innerText =
    `Director Fees: SGD ${optimalSplit.directorFees.toFixed(2)} (Tax: SGD ${calculatePersonalTax(optimalSplit.directorFees).toFixed(2)})`;

  document.getElementById('optimalOption').innerText =
    `Optimal Split: Pay SGD ${optimalSplit.dividends.toFixed(2)} as Dividends and SGD ${optimalSplit.directorFees.toFixed(2)} as Director Fees. Total Tax: SGD ${optimalSplit.totalTax.toFixed(2)}`;
}
Leave a Comment