All the controversy surrounding CEO Elon Musk aside, Tesla (TSLA 0.43%) just reported another fantastic quarter. Second-quarter 2022 revenue and profitability were down from the previous couple of quarters but up big versus the same period a year ago. As vehicle production gradually ramps up at factories around the world, profit is on the rise. That doesn't necessarily make the stock a buy, but Tesla continues to prove its automaking capabilities are the real deal.

A year-over-year jump in margins when excluding regulatory credits

Tesla's gross profit margin on vehicles was reported at 27.9% in Q2 2022. If you're keeping score, that compares to the stellar 32.9% gross margin in the first quarter of 2022 and -- more importantly -- 28.4% a year ago in Q2 2021. Queue up the music signaling Tesla's imminent doom. 

Except there are some caveats to consider with this vehicle gross margin figure. Several factors added up to drag down Tesla's margins on vehicles.

First were the constrained operations at Tesla's Shanghai factory, where regulators are trying to keep tight control over resurgent COVID-19 infections. Inflation and a strong U.S. dollar (which lowers revenue when a multinational company converts foreign currency for financial reporting here in the states) also contributed to lower vehicle gross margin. Additionally, Tesla produced more vehicles than it delivered in Q2 versus the last three quarters when it delivered more vehicles than it produced. Tesla doesn't realize revenue until a customer takes possession of the car, so the cadence of quarterly production versus deliveries also impacts margins.

But here's another factor to consider. Tesla's regulatory credit revenue (electric vehicle incentives from governments given to Tesla and purchased from Tesla by other automakers) remains in decline. As automakers ramp up their own EV lineups, it's always been inevitable the sale of these credits would decline. In Q2 2022, revenue from regulatory credit sales was $344 million, down from $679 million in Q1 and $354 million a year ago. As a result, regulatory credits were just 2.4% of automotive revenue this last quarter, compared to 4% in Q1 and 3.5% of revenue in Q2 2021.

Thus, when excluding these credits, automotive gross margins in Q2 2022 actually edge up to 26.2% compared to 25.8% last year (and 30% gross margin in Q1). Not quite the dire situation some financial outlets are presenting.

Profit will vary from quarter to quarter, but...

Moving past vehicle-specific margins, Tesla reported a total operating profit of $2.46 billion last quarter. That's an operating margin of 14.6%. It's a steep fall from the abnormally high 19.2% in Q1, but nonetheless a big jump from the meager 11% margin a year ago.

Various profit margin metrics are going to be highly variable from one period to the next for any manufacturing company, but especially Tesla, as it tries to rapidly expand its global output of EVs. But over time, focus on metrics like free cash flow (operating profit minus capital expenditures on property, plant, and equipment) per share. Thus far, this has been an absolute success story.

TSLA Free Cash Flow Per Share Chart.

Data by YCharts.

Again, I'm not saying Tesla is a buy. This simply isn't a stock for everyone, especially considering Musk and company can be unpredictable on a good day. And shares currently trade for 133 times trailing 12-month free cash flow, a premium that prices in the company's ability to keep growing its cash-generating potential for years to come. But by many counts, Tesla the auto manufacturer is meeting or beating expectations as it scales up its operations. If you don't like the company, that's fine, but I wouldn't bet against it.