California Capital Gains Calculator

California Capital Gains Calculator – Calculate Your Tax Liability :root { –primary-color: #004a99; –secondary-color: #f8f9fa; –success-color: #28a745; –text-color: #333; –border-color: #ddd; –shadow-color: rgba(0, 0, 0, 0.1); –accent-color: #e9ecef; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; background-color: var(–secondary-color); color: var(–text-color); margin: 0; padding: 20px; } .container { max-width: 960px; margin: 0 auto; background-color: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 4px 15px var(–shadow-color); } h1, h2, h3 { color: var(–primary-color); margin-bottom: 20px; } h1 { text-align: center; font-size: 2.2em; margin-bottom: 30px; } h2 { font-size: 1.8em; border-bottom: 2px solid var(–primary-color); padding-bottom: 10px; margin-top: 40px; } h3 { font-size: 1.4em; margin-top: 30px; } .calculator-section { background-color: var(–accent-color); padding: 30px; border-radius: 6px; margin-bottom: 40px; } .input-group { margin-bottom: 20px; text-align: left; } .input-group label { display: block; font-weight: bold; margin-bottom: 8px; color: var(–primary-color); } .input-group input[type="number"], .input-group select { width: 100%; padding: 12px; border: 1px solid var(–border-color); border-radius: 4px; box-sizing: border-box; font-size: 1em; } .input-group .helper-text { font-size: 0.85em; color: #6c757d; margin-top: 5px; } .input-group .error-message { color: #dc3545; font-size: 0.9em; margin-top: 5px; display: none; /* Hidden by default */ } .input-group .error input, .input-group .error select { border-color: #dc3545; } .button-group { display: flex; gap: 10px; justify-content: center; margin-top: 30px; } .button-group button, .button-group input[type="button"] { padding: 12px 25px; border: none; border-radius: 5px; font-size: 1em; cursor: pointer; transition: background-color 0.3s ease; font-weight: bold; } .btn-calculate { background-color: var(–primary-color); color: white; } .btn-calculate:hover { background-color: #003366; } .btn-reset { background-color: #6c757d; color: white; } .btn-reset:hover { background-color: #5a6268; } .btn-copy { background-color: var(–success-color); color: white; } .btn-copy:hover { background-color: #1e7e34; } #results { margin-top: 30px; padding: 25px; border: 1px dashed var(–primary-color); border-radius: 6px; background-color: var(–secondary-color); } #results h3 { margin-top: 0; color: var(–primary-color); text-align: center; } .result-item { margin-bottom: 15px; font-size: 1.1em; } .result-item strong { color: var(–primary-color); display: inline-block; min-width: 220px; } .primary-result { background-color: var(–primary-color); color: white; padding: 15px; text-align: center; font-size: 1.8em; font-weight: bold; border-radius: 5px; margin-bottom: 20px; } .chart-container { text-align: center; margin-top: 30px; background-color: var(–accent-color); padding: 20px; border-radius: 6px; } canvas { max-width: 100%; height: auto !important; margin: 0 auto; } caption { font-size: 1.1em; font-weight: bold; color: var(–primary-color); margin-bottom: 15px; caption-side: top; text-align: center; } table { width: 100%; border-collapse: collapse; margin-top: 20px; } th, td { padding: 10px; text-align: left; border: 1px solid var(–border-color); } th { background-color: var(–primary-color); color: white; } tbody tr:nth-child(odd) { background-color: var(–accent-color); } .formula-explanation { font-size: 0.95em; color: #555; margin-top: 20px; text-align: center; padding: 15px; background-color: var(–accent-color); border-left: 3px solid var(–primary-color); border-radius: 4px; } .article-content { margin-top: 50px; padding-top: 30px; border-top: 1px solid var(–border-color); } .article-content p, .article-content ul, .article-content ol { margin-bottom: 20px; font-size: 1.05em; } .article-content ul, .article-content ol { padding-left: 25px; } .article-content li { margin-bottom: 10px; } .article-content a { color: var(–primary-color); text-decoration: none; font-weight: bold; } .article-content a:hover { text-decoration: underline; } .article-content .faq-question { font-weight: bold; color: var(–primary-color); margin-top: 25px; margin-bottom: 10px; font-size: 1.2em; } .article-content .faq-answer { margin-bottom: 15px; } .variable-table th, .variable-table td { border: 1px solid var(–border-color); padding: 8px; text-align: left; } .variable-table th { background-color: var(–primary-color); color: white; } .variable-table tr:nth-child(odd) { background-color: var(–accent-color); } #copyMessage { display: none; color: var(–success-color); text-align: center; margin-top: 10px; font-weight: bold; }

California Capital Gains Calculator

Calculate Your California Capital Gains Tax

Enter the details of your asset sale to estimate your California capital gains tax liability. This calculator differentiates between short-term and long-term gains and applies current California tax rates.

The price you initially paid for the asset.
The price you sold the asset for.
Additions or subtractions to the cost basis (e.g., improvements, depreciation).
How long you owned the asset before selling.
Used to determine the applicable CA capital gains tax bracket. Enter your total taxable income from your federal return.

Your Estimated Capital Gains Tax

Total Capital Gain:
Gain Type:
Applicable CA Rate:
Estimated CA Tax:
Federal Taxable Income:
Formula Used:

Capital Gain = Sale Price – (Purchase Price + Cost Basis Adjustments). The gain is classified as Short-Term if held for 12 months or less, and Long-Term if held for more than 12 months. California taxes short-term capital gains at your ordinary income tax rate. Long-term capital gains are generally taxed at lower rates, but in California, they are also taxed at your ordinary income tax rate. The specific rate applied depends on your total federal taxable income, which determines your California income tax bracket.

Capital Gains Distribution
Capital Gains Tax Rates (Illustrative)
Federal Taxable Income (CA Brackets) Short-Term / Long-Term Rate
Results copied to clipboard!

What is California Capital Gains Tax?

The California capital gains tax is a tax levied by the state of California on the profits realized from the sale of capital assets. Capital assets include things like stocks, bonds, real estate, collectibles, and other investments. When you sell a capital asset for more than you paid for it (your cost basis), you have a capital gain. This profit is subject to taxation. Understanding how this tax works in California is crucial for investors and property owners to accurately plan their finances and tax liabilities.

Who Should Use a California Capital Gains Calculator?

Anyone selling a capital asset within California should consider using a California capital gains calculator. This includes:

  • Investors selling stocks, bonds, or cryptocurrency.
  • Homeowners selling a primary residence (though specific exclusions may apply).
  • Real estate investors selling investment properties.
  • Anyone who has inherited assets and later sells them.
  • Individuals who have made significant improvements to property and are now selling.

A California capital gains calculator simplifies the complex calculations required to determine your tax obligation, accounting for different holding periods and tax brackets.

Common Misconceptions About California Capital Gains

  • "Long-term gains are always taxed at a lower rate." While this is true at the federal level, California taxes both short-term and long-term capital gains at your ordinary income tax rate. The distinction is important for federal taxes, but not for state taxes in California, as the rate is determined by your income bracket.
  • "Selling my primary home is always tax-free." While California offers significant exclusions for primary residences (up to $250,000 for single filers and $500,000 for married couples filing jointly), these rules have specific requirements regarding ownership and usage duration. Selling a primary home that doesn't meet these criteria can still trigger capital gains tax.
  • "Capital gains are only on stocks." Capital assets are broad and include real estate, art, collectibles, business assets, and more.

California Capital Gains Tax Formula and Mathematical Explanation

Calculating capital gains tax in California involves several steps. The core calculation determines the amount of the gain, and then the applicable tax rate is applied based on the holding period and your overall income level.

Step-by-Step Calculation

  1. Determine the Cost Basis: This is typically the original purchase price of the asset, plus any non-deductible expenses incurred during ownership (like major improvements for real estate) and minus any depreciation claimed.
  2. Calculate the Capital Gain (or Loss): Subtract the adjusted cost basis from the net sale price (sale price minus selling expenses).
    Formula: Capital Gain = Sale Price – Adjusted Cost Basis
  3. Determine Holding Period:
    • Short-Term Capital Gain: Asset held for 12 months or less.
    • Long-Term Capital Gain: Asset held for more than 12 months.
  4. Apply California Tax Rate: California does not have separate tax rates for long-term capital gains. Both short-term and long-term capital gains are taxed as ordinary income at your applicable California state income tax rate. This rate is determined by your total taxable income for the year.

Variable Explanations

Here's a breakdown of the variables used in our California capital gains calculator:

Variable Meaning Unit Typical Range
Purchase Price The original amount paid for the capital asset. Currency ($) $100 – $10,000,000+
Sale Price The amount received when selling the capital asset. Currency ($) $500 – $20,000,000+
Cost Basis Adjustments Costs added to the basis (improvements) or deducted (depreciation). Currency ($) $0 – $1,000,000+
Holding Period (Months) The duration the asset was owned by the taxpayer. Months 1 – 12 (Short-Term) or 13+ (Long-Term)
Federal Taxable Income Total taxable income reported on the federal tax return. Used to determine CA tax bracket. Currency ($) $0 – $1,000,000+
Total Capital Gain Profit realized from the sale of the asset. Currency ($) $-500,000 – $10,000,000+
Applicable CA Rate Your California state income tax rate based on your taxable income. Percentage (%) 1% – 13.3%
Estimated CA Tax The calculated tax liability on the capital gain. Currency ($) $0 – $1,000,000+

Practical Examples (Real-World Use Cases)

Example 1: Sale of Stocks (Long-Term Gain)

Sarah bought 100 shares of XYZ Corp. stock for $50 per share ($5,000 total) 5 years ago. She recently sold all 100 shares for $150 per share ($15,000 total). Her brokerage fees for the sale were $50. Her total federal taxable income for the year is $90,000.

  • Purchase Price: $5,000
  • Sale Price: $15,000
  • Cost Basis Adjustments: $0 (assuming no additional costs or adjustments)
  • Selling Expenses: $50 (reduces proceeds, effectively adding to cost basis for gain calculation)
  • Adjusted Sale Proceeds: $15,000 – $50 = $14,950
  • Holding Period: 5 years (60 months) – Long-Term
  • Federal Taxable Income: $90,000

Calculation:

Total Capital Gain: $14,950 (Adjusted Sale Proceeds) – $5,000 (Purchase Price) = $9,950

Gain Type: Long-Term (held > 12 months)

Applicable CA Rate: Based on $90,000 federal taxable income, Sarah falls into a California tax bracket. For 2023, $90,000 would likely place her in the 9.3% bracket. (Note: This rate can fluctuate based on tax year and specific income breakdown.)

Estimated CA Tax: $9,950 (Total Capital Gain) * 9.3% = $925.35

Interpretation: Sarah will owe approximately $925.35 in California capital gains tax on this stock sale.

Example 2: Sale of Investment Property (Short-Term Gain)

Mark purchased an investment property for $300,000 three years ago. He spent $20,000 on significant renovations (capital improvements). He sold the property for $400,000 after holding it for only 10 months. Selling costs (realtor commissions, closing costs) amounted to $25,000. His federal taxable income is $150,000.

  • Purchase Price: $300,000
  • Cost Basis Adjustments (Improvements): $20,000
  • Total Adjusted Cost Basis: $300,000 + $20,000 = $320,000
  • Sale Price: $400,000
  • Selling Costs: $25,000 (reduces proceeds)
  • Adjusted Sale Proceeds: $400,000 – $25,000 = $375,000
  • Holding Period: 10 months – Short-Term
  • Federal Taxable Income: $150,000

Calculation:

Total Capital Gain: $375,000 (Adjusted Sale Proceeds) – $320,000 (Total Adjusted Cost Basis) = $55,000

Gain Type: Short-Term (held <= 12 months)

Applicable CA Rate: With $150,000 federal taxable income, Mark is in a higher tax bracket. For 2023, this might place him in the 10.3% or 11.3% bracket depending on the exact income and filing status. Let's assume 10.3%. (Note: Consult tax professional for exact bracket.)

Estimated CA Tax: $55,000 (Total Capital Gain) * 10.3% = $5,665

Interpretation: Mark faces a significant California capital gains tax liability of $5,665 due to the short holding period and his income level.

How to Use This California Capital Gains Calculator

Using our California capital gains calculator is straightforward. Follow these steps to get an accurate estimate of your tax liability:

  1. Gather Asset Information: Before you start, collect details about the asset you sold:
    • Original purchase price.
    • Date of purchase and date of sale (to determine holding period).
    • Total sale price.
    • Any costs associated with the sale (e.g., realtor commissions, closing costs).
    • Records of capital improvements made to the property or asset (e.g., home renovations, significant upgrades).
    • Your total federal taxable income for the year you sold the asset. This is crucial for determining your California tax bracket.
  2. Enter Purchase Price: Input the original amount you paid for the asset.
  3. Enter Sale Price: Input the total amount you received from the sale.
  4. Enter Cost Basis Adjustments: Add the total value of capital improvements or subtract depreciation. If none, enter 0.
  5. Enter Holding Period: Specify how many months you owned the asset. The calculator will automatically determine if it's a short-term or long-term gain.
  6. Enter Federal Taxable Income: Provide your total taxable income from your federal return. This helps the calculator apply the correct California tax rate.
  7. Click 'Calculate Gains': The calculator will instantly display your total capital gain, whether it's short-term or long-term, the applicable California tax rate, and the estimated California tax amount.
  8. Review Results: Check the primary result (Estimated CA Tax) and the intermediate values for clarity. The formula explanation provides context.
  9. Use 'Copy Results': If you need to share these figures or save them, click the 'Copy Results' button.
  10. Use 'Reset': If you need to perform a new calculation, click 'Reset' to clear all fields.

Decision-Making Guidance: The results from this calculator can help you understand potential tax obligations, plan for future investments, and make informed decisions about when to sell assets.

Key Factors That Affect California Capital Gains Results

Several factors significantly influence the outcome of your California capital gains tax calculation:

  1. Asset Appreciation: The most direct factor. The larger the difference between your sale price and your adjusted cost basis, the higher your capital gain and, consequently, your tax liability.
  2. Holding Period: While California taxes short-term and long-term gains at the same rate (ordinary income rates), understanding this distinction is vital for federal tax purposes and overall financial planning. For instance, holding an asset longer might allow you to benefit from federal long-term capital gains rates, even if state rates are the same.
  3. California Income Tax Bracket: Your total taxable income determines your tax rate. Higher income levels mean higher marginal tax rates, thus increasing the capital gains tax you'll owe. This is a primary driver for California's tax calculation.
  4. Original Purchase Price (Cost Basis): A lower purchase price (and a well-documented, higher adjusted cost basis) leads to a larger capital gain. Accurately establishing your cost basis is critical.
  5. Selling Expenses: Costs like real estate agent commissions, escrow fees, and transfer taxes reduce your net proceeds from a sale, thereby lowering your taxable capital gain.
  6. Capital Improvements: For real estate, significant improvements (like adding a room, upgrading a roof) increase your cost basis, reducing the taxable gain. Keep meticulous records for these.
  7. Depreciation Recapture: If you've claimed depreciation on an asset (like an investment property), that portion of the gain may be taxed at a different rate (depreciation recapture rate, which can be higher than standard long-term rates federally, though California taxes it as ordinary income).
  8. State Tax Laws and Changes: Tax laws, including income tax brackets and any specific provisions related to capital gains, can change annually. Always ensure you are using current rates and rules. Understanding California's tax policy is essential.

Frequently Asked Questions (FAQ)

Does California have a separate tax rate for long-term capital gains?
No. Unlike the federal tax system, California taxes both short-term and long-term capital gains at your ordinary income tax rate, which is determined by your total taxable income.
What is considered a capital asset in California?
Capital assets generally include stocks, bonds, cryptocurrency, collectibles, real estate (investment and sometimes primary residence), vehicles, and other property held for investment or personal use, excluding inventory and business property used in a trade or business.
How do I calculate the cost basis for inherited property in California?
Inherited property generally receives a "stepped-up" basis, meaning its cost basis is the fair market value of the property on the date of the decedent's death. This can significantly reduce or eliminate capital gains tax if sold soon after inheritance.
Are there exemptions for selling a primary residence in California?
Yes. California offers a significant exclusion for gains on the sale of a primary residence, up to $250,000 for single filers and $500,000 for married couples filing jointly, provided ownership and residency requirements are met (generally owned and lived in for at least 2 of the last 5 years).
How are selling expenses factored into the calculation?
Selling expenses, such as real estate commissions, escrow fees, and advertising costs, are subtracted from the gross sale price to determine the net proceeds. This effectively reduces your taxable capital gain.
What happens if I have a capital loss?
If you sell a capital asset for less than its adjusted cost basis, you have a capital loss. Capital losses can be used to offset capital gains. If losses exceed gains, you can deduct up to $3,000 ($1,500 if married filing separately) of net capital loss against your ordinary income each year. Remaining losses can be carried forward to future tax years. You can learn more about managing investment losses.
Does California tax cryptocurrency capital gains differently?
No. California treats cryptocurrency like property. Capital gains or losses from selling or trading cryptocurrency are taxed at your ordinary income tax rate, similar to stocks or other capital assets.
How does federal taxable income affect my California capital gains tax?
Your federal taxable income is used to determine which California income tax bracket you fall into. Since California taxes capital gains as ordinary income, a higher federal taxable income generally means a higher marginal tax rate applied to your capital gains.
Where can I find the current California capital gains tax rates?
California capital gains tax rates are aligned with its ordinary income tax rates, which range from 1% to 13.3%. The Franchise Tax Board (FTB) publishes the official tax brackets annually. You can also refer to our calculator, which uses estimated rates based on provided income. For precise, up-to-the-minute rates, consult the California Franchise Tax Board or a tax professional.

Related Tools and Internal Resources

Disclaimer: This calculator provides an estimate for informational purposes only. It is not a substitute for professional tax advice. Consult with a qualified tax professional for personalized guidance regarding your specific situation.

function formatCurrency(amount) { if (isNaN(amount) || amount === null || amount === undefined) return '–'; return '$' + amount.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); } function formatRate(rate) { if (isNaN(rate) || rate === null || rate === undefined) return '–%'; return (rate * 100).toFixed(2) + '%'; } function formatInteger(value) { if (isNaN(value) || value === null || value === undefined) return '–'; return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } function clearError(id) { var errorElement = document.getElementById(id + 'Error'); if (errorElement) { errorElement.style.display = 'none'; errorElement.textContent = "; } var inputElement = document.getElementById(id); if (inputElement) { inputElement.classList.remove('error'); } } function displayError(id, message) { var errorElement = document.getElementById(id + 'Error'); if (errorElement) { errorElement.style.display = 'block'; errorElement.textContent = message; } var inputElement = document.getElementById(id); if (inputElement) { inputElement.classList.add('error'); } } var currentChart = null; function calculateCapitalGains() { var purchasePrice = parseFloat(document.getElementById('purchasePrice').value); var salePrice = parseFloat(document.getElementById('salePrice').value); var costBasisAdjustments = parseFloat(document.getElementById('costBasisAdjustments').value); var holdingPeriodMonths = parseInt(document.getElementById('holdingPeriodMonths').value); var federalTaxableIncome = parseFloat(document.getElementById('federalTaxableIncome').value); var errors = false; if (isNaN(purchasePrice) || purchasePrice <= 0) { displayError('purchasePrice', 'Please enter a valid purchase price.'); errors = true; } else { clearError('purchasePrice'); } if (isNaN(salePrice) || salePrice <= 0) { displayError('salePrice', 'Please enter a valid sale price.'); errors = true; } else { clearError('salePrice'); } if (isNaN(costBasisAdjustments) || costBasisAdjustments < 0) { displayError('costBasisAdjustments', 'Cost basis adjustments cannot be negative.'); errors = true; } else { clearError('costBasisAdjustments'); } if (isNaN(holdingPeriodMonths) || holdingPeriodMonths <= 0) { displayError('holdingPeriodMonths', 'Please enter a valid holding period in months.'); errors = true; } else { clearError('holdingPeriodMonths'); } if (isNaN(federalTaxableIncome) || federalTaxableIncome 12 ? 'Long-Term' : 'Short-Term'; // Determine CA tax rate based on federal taxable income brackets (simplified for illustration) // These brackets are illustrative and should be updated for specific tax years. var caRate = 0.01; // Default minimum if (federalTaxableIncome > 1000000) caRate = 0.133; else if (federalTaxableIncome > 900000) caRate = 0.123; else if (federalTaxableIncome > 700000) caRate = 0.113; else if (federalTaxableIncome > 500000) caRate = 0.103; else if (federalTaxableIncome > 300000) caRate = 0.093; else if (federalTaxableIncome > 250000) caRate = 0.080; else if (federalTaxableIncome > 180000) caRate = 0.068; else if (federalTaxableIncome > 140000) caRate = 0.055; else if (federalTaxableIncome > 100000) caRate = 0.043; else if (federalTaxableIncome > 80000) caRate = 0.025; else if (federalTaxableIncome > 60000) caRate = 0.020; else if (federalTaxableIncome > 50000) caRate = 0.018; else if (federalTaxableIncome > 40000) caRate = 0.015; else if (federalTaxableIncome > 30000) caRate = 0.013; else if (federalTaxableIncome > 20000) caRate = 0.011; else if (federalTaxableIncome > 10000) caRate = 0.010; else caRate = 0.01; // Minimum rate var estimatedTax = totalGain * caRate; document.getElementById('primaryResult').textContent = formatCurrency(estimatedTax); document.getElementById('totalGain').textContent = formatCurrency(totalGain); document.getElementById('gainType').textContent = gainType; document.getElementById('applicableRate').textContent = formatRate(caRate); document.getElementById('estimatedTax').textContent = formatCurrency(estimatedTax); document.getElementById('displayFederalTaxableIncome').textContent = formatCurrency(federalTaxableIncome); populateRateTable(federalTaxableIncome); updateChart(totalGain, estimatedTax, caRate); } function populateRateTable(federalTaxableIncome) { var tableBody = document.getElementById('rateTableBody'); tableBody.innerHTML = "; // Clear existing rows var rates = [ { income: 0, rate: 0.01 }, { income: 10000, rate: 0.010 }, { income: 20000, rate: 0.011 }, { income: 30000, rate: 0.013 }, { income: 40000, rate: 0.015 }, { income: 50000, rate: 0.018 }, { income: 60000, rate: 0.020 }, { income: 80000, rate: 0.025 }, { income: 100000, rate: 0.043 }, { income: 140000, rate: 0.055 }, { income: 180000, rate: 0.068 }, { income: 250000, rate: 0.080 }, { income: 300000, rate: 0.093 }, { income: 500000, rate: 0.103 }, { income: 700000, rate: 0.113 }, { income: 900000, rate: 0.123 }, { income: 1000000, rate: 0.133 } ]; var currentBracketRate = 0.01; var incomeRanges = []; for (var i = 0; i < rates.length; i++) { var lowerBound = rates[i].income; var upperBound = (i + 1 < rates.length) ? rates[i+1].income – 1 : Infinity; var rate = rates[i].rate; if (lowerBound <= federalTaxableIncome && federalTaxableIncome <= upperBound) { currentBracketRate = rate; } var rangeText; if (upperBound === Infinity) { rangeText = formatCurrency(lowerBound) + " +"; } else { rangeText = formatCurrency(lowerBound) + " – " + formatCurrency(upperBound); } var row = tableBody.insertRow(); var cellRange = row.insertCell(0); var cellRate = row.insertCell(1); cellRange.textContent = rangeText; cellRate.textContent = formatRate(rate); } } function updateChart(totalGain, estimatedTax, caRate) { var ctx = document.getElementById('gainsChart').getContext('2d'); if (currentChart) { currentChart.destroy(); } var dataSeries1 = []; // Hypothetical gains at different rates var dataSeries2 = []; // Corresponding tax at those hypothetical rates var labels = []; var startRate = 0.01; // 1% var endRate = 0.14; // 14% var step = 0.01; // 1% increments var currentIncome = parseFloat(document.getElementById('federalTaxableIncome').value) || 100000; // Use input value or default var baseGain = totalGain; if (baseGain < 0) baseGain = 0; // Don't plot negative gains for chart illustration for (var rate = startRate; rate = 0) { dataSeries1.push(estimatedTax); dataSeries2.push(caRate * 100); labels.push("Your Tax"); } currentChart = new Chart(ctx, { type: 'bar', // Changed to bar for better comparison of tax amounts data: { labels: labels, datasets: [{ label: 'Estimated CA Tax Amount ($)', data: dataSeries1, backgroundColor: 'rgba(0, 74, 153, 0.6)', // Primary color borderColor: 'rgba(0, 74, 153, 1)', borderWidth: 1, yAxisID: 'y-axis-tax' }, { label: 'CA Tax Rate (%)', data: dataSeries2, type: 'line', // Line for rates borderColor: 'rgba(40, 167, 69, 0.8)', // Success color backgroundColor: 'rgba(40, 167, 69, 0.2)', borderWidth: 2, fill: false, yAxisID: 'y-axis-rate' }] }, options: { responsive: true, maintainAspectRatio: false, scales: { x: { title: { display: true, text: 'Applicable California Tax Rate' } }, 'y-axis-tax': { type: 'linear', position: 'left', title: { display: true, text: 'Estimated Tax ($)' }, ticks: { beginAtZero: true, callback: function(value) { return formatCurrency(value); } } }, 'y-axis-rate': { type: 'linear', position: 'right', title: { display: true, text: 'Tax Rate (%)' }, ticks: { beginAtZero: true, callback: function(value) { return value + '%'; } }, grid: { drawOnChartArea: false, // Only display ticks, not grid lines for the secondary axis } } }, plugins: { tooltip: { callbacks: { label: function(context) { var label = context.dataset.label || "; if (label) { label += ': '; } if (context.dataset.yAxisID === 'y-axis-tax') { label += formatCurrency(context.raw); } else { label += context.raw + '%'; } return label; } } } } } }); } function resetCalculator() { document.getElementById('purchasePrice').value = "; document.getElementById('salePrice').value = "; document.getElementById('costBasisAdjustments').value = '0'; document.getElementById('holdingPeriodMonths').value = "; document.getElementById('federalTaxableIncome').value = "; document.getElementById('primaryResult').textContent = '–'; document.getElementById('totalGain').textContent = '–'; document.getElementById('gainType').textContent = '–'; document.getElementById('applicableRate').textContent = '–'; document.getElementById('estimatedTax').textContent = '–'; document.getElementById('displayFederalTaxableIncome').textContent = '–'; clearError('purchasePrice'); clearError('salePrice'); clearError('costBasisAdjustments'); clearError('holdingPeriodMonths'); clearError('federalTaxableIncome'); if (currentChart) { currentChart.destroy(); currentChart = null; } var tableBody = document.getElementById('rateTableBody'); tableBody.innerHTML = "; // Clear table rows document.getElementById('copyMessage').style.display = 'none'; } function copyResults() { var primaryResult = document.getElementById('primaryResult').textContent; var totalGain = document.getElementById('totalGain').textContent; var gainType = document.getElementById('gainType').textContent; var applicableRate = document.getElementById('applicableRate').textContent; var estimatedTax = document.getElementById('estimatedTax').textContent; var federalTaxableIncome = document.getElementById('displayFederalTaxableIncome').textContent; var assumptions = "Key Assumptions:\n" + "- Federal Taxable Income Used: " + federalTaxableIncome + "\n" + "- Holding Period Classification: " + gainType + "\n" + "- Applicable CA Rate: " + applicableRate; var resultsText = "— California Capital Gains Tax Estimate —\n\n" + "Estimated CA Tax: " + primaryResult + "\n" + "Total Capital Gain: " + totalGain + "\n" + "Gain Type: " + gainType + "\n" + "Applicable CA Rate: " + applicableRate + "\n" + "—————————————-\n\n" + assumptions; navigator.clipboard.writeText(resultsText).then(function() { var copyMessage = document.getElementById('copyMessage'); copyMessage.style.display = 'block'; setTimeout(function() { copyMessage.style.display = 'none'; }, 3000); }).catch(function(err) { console.error('Failed to copy results: ', err); }); } // Initial calculation and table population on load if defaults exist, or empty document.addEventListener('DOMContentLoaded', function() { // Optional: Call calculateCapitalGains() if you want to display default results on load // calculateCapitalGains(); populateRateTable(100000); // Populate table with a sample income });

Leave a Comment