Everybody's talking about Tesla (NASDAQ:TSLA) right now, and not necessarily in a good way. With the news that CEO Elon Musk was the target of an SEC lawsuit, which he then settled, Tesla shares plummeted as the market seemed to be weighing whether Tesla is worth its premium price. 

While all this is important to the company's future, of course, there's a more fundamental issue that currently seems to be overlooked: Tesla just can't seem to make money. In fact, in its most recently reported quarter, Q2 2018, the company recorded its largest-ever quarterly loss, beating the record it had set in...Q1 2018. 

If Tesla could start consistently turning a profit in the near future, the recent price tumble might be a buying opportunity. So let's take a peek under the hood -- or rather, in the "frunk," in Tesla-speak -- to see what we can find out.

A red Tesla Model 3 with a cityscape in the background

Tesla has been ramping up production of its top seller, the Model 3. Image source: Tesla.

The company line

In June, Musk said he expects the company to be both GAAP profitable and cash flow positive in the third quarter of this year. Considering how poorly the company has fared in those departments so far in 2018, this is an ambitious goal. 

Of course, Tesla is no stranger to overpromising and underdelivering. For years, Musk and his team have missed deadlines and targets. One noteworthy example was Tesla's guidance, issued on Feb. 10, 2016, that the company would deliver 16,000 vehicles in Q1 2016, which ran from January through March. But despite that forecast being issued almost halfway through the quarter, Tesla still fell 7.3% short. 

That may seem like a small thing, but Musk's insistence in Q3 2017 that Tesla would produce 5,000 Model 3s per week by the end of 2017 was a bigger promise that, once again, was not kept. Musk pushed that target back to Q1 2018 -- and missed it again. Finally, in the final week of Q2 2018 -- and, apparently, only after a grueling "all-hands-on-deck" production push -- the company was able to meet that particular goal. 

The lesson here: Just because Musk has promised something is no guarantee Tesla can deliver.

By the numbers

But maybe he's right about this one -- after all, Tesla did eventually produce 5,000 Model 3s in one week, as promised. Fellow Motley Fool contributor Daniel Sparks has crunched the numbers and determined that it's at least theoretically possible for Tesla to turn a profit in the second half of the year, assuming it can sustain its output of Model 3s and keep costs under control.

On the costs front, it seems as though Tesla may be succeeding. In June, the company announced it would trim 9% of its workforce, leaving production personnel intact. It has reduced the number of standard paint colors available on the Model 3 in order to streamline production. But, of course, ramping up production is likely to increase costs as opposed to reducing them. 

Tesla's recently reported production of 53,239 Model 3s was in line with the company's guidance of 50,000 to 55,000 vehicles. Overall production -- including the Model S and Model X -- came in at 80,142, with total deliveries of 83,500 vehicles.

Musk had recently sent an email to Tesla employees -- posted on the company's blog -- in which he stated, "We are about to have the most amazing quarter in our history, building and delivering more than twice as many cars as we did last quarter." That would have translated to producing more than 106,000 vehicles and delivering more than 81,000. It's unclear whether Musk was referring to Q3 2018 or Q4 2018 -- or, for that matter, Q1 2019 -- as the quarter when this feat would occur. Tesla's there on the deliveries but not on the production...at least, not yet.

Reply hazy

There are a lot of moving parts to consider when looking at whether Tesla can turn a profit, and a lot of unresolved questions as well. Much of it boils down to a series of ifsIf Tesla can iron out its production problems at the Gigafactory, and if it can then ramp up production while keeping costs down, and if any surprises that come up are positive as opposed to negative, then it may indeed turn a quarterly profit, perhaps even consistently.

Of course, I could have said the same thing back in 2016.

But here's the deal: It seems unlikely, having produced 5,000 Model 3s in one week once, that Tesla will never be able to do so again. And if it can do it again, it ought to be able to figure out how to do so consistently. Tesla's Model 3 production has been getting faster -- it produced 28,578 Model 3s in Q2, which was more than triple the number produced in Q1, and in Q3 nearly doubled Model 3 production from Q2, so it's possible that the bulk of the production ramp-up costs have in fact been achieved.

Five thousand Model 3s per week in a 13-week quarter would translate to quarterly production of 65,000 Model 3s, so Tesla isn't quite there yet. But even if all of those were the cheapest version currently available ($49,000), that's still almost $3.2 billion worth of vehicles. If Tesla had produced -- and, of course, delivered -- that many Model 3s in Q2, its $717.5 million loss would have almost certainly been a profit instead.

Factor in production of other models -- 24,761 in Q2 2018 and 26,903 in Q3 -- and I could see Tesla reasonably cranking out 90,000 to 95,000 vehicles per quarter in the not-too-distant future. North of 106,000? Well, maybe Musk knows something I don't.

Investor takeaway

If everything goes as planned -- and that's a big if -- Tesla could turn a profit, as Musk predicts, by the end of this year. However, it's worth noting that Tesla's stock price has soared more than 600% since 2013 even while the company wasn't profitable. Likewise, just because Tesla turns a profit doesn't necessarily mean the stock price will go higher -- although it probably will, at least temporarily -- or stay higher. 

Just turning a profit, though, isn't going to be enough for Tesla. The company will also need to stave off hungry competitors eager to enter the electric-vehicle space and expand its product line to include more affordable offerings, all while keeping costs down and hopefully reducing turnover. But showing it can turn a profit will be a big step in the right direction.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.