Tesla (NASDAQ:TSLA) will report its second-quarter earnings results after the bell on Aug. 1, and most observers are expecting another substantial loss -- but guidance from management that points to a more upbeat outlook for the second half of the year.

We'll dig into the details of what Tesla is likely to report as we get closer to Aug. 1. But there's one thing that I think Tesla fans and skeptics alike should start thinking about now: Tesla may be very close to running out of cash.

A red Tesla Model 3, a sleek compact luxury sedan, on a coastal road at sunset.

Tesla managed to make 5,000 Model 3s in the last week of the second quarter, but the effort may have burned most of its remaining cash. Image source: Tesla, Inc.

Last quarter, Tesla said it would cut spending

Let's start by looking at where Tesla was at the end of the first quarter, the most recent official data we have available. At that time, the company had $2.67 billion in cash and another $653 million in accounts receivable.

On the other side of the ledger, it had $2.60 billion in accounts payable, another $1.9 billion in current accrued liabilities (think of these as accounts payable that haven't yet been billed) -- and a note that $985 million of its cash was made up of customer deposits. (They're recorded as liabilities because Tesla is obliged to deliver something for them -- either a vehicle or a refund.)

It was clear then that Tesla's senior management was already worried about its cash position. For starters, the company told us in its first-quarter shareholder letter that it was focused on reducing capital expenditures for 2018.

We have significantly cut back our capex projections by focusing on the critical near-term needs that benefit us primarily in the next couple of years. At this stage, we are expecting total 2018 capex to be slightly below $3 billion, which is below the total 2017 level of $3.4 billion. Ultimately, our capex guidance will develop in line with Model 3 production and profitability. We will be able to adjust our capital expenditures significantly depending on our operating cash generation. [Emphasis added.]

Now let's think about what has happened since then.

The final Model 3 ramp-up was probably expensive

Tesla spent the second quarter engaged in an all-out, all-hands-on-deck effort to ramp up production of the Model 3 sedan in order to hit its long-promised goal of making 5,000 Model 3s in a week.

That effort was almost certainly a costly one. Among other things, the company moved away from its (very expensive) automated production line after significant quality problems showed up in early Model 3. It apparently revamped the final-assembly section of its production line -- hastily -- to include more humans.

But despite that all-out effort, Tesla did move to reduce its spending as it had promised after the first quarter. One very big move: Tesla laid off 9% of its workforce in June, a clear sign that the company was becoming very worried about its spending.

Another sign: Under pressure to hit that Model 3 production goal, Tesla chose, curiously, to erect a temporary tent-like structure next to its factory. The "tent" houses a makeshift assembly line for some versions of the Model 3. It may have been key to Tesla's successful effort to produce (almost) 5,000 Model 3s in the last week of the quarter -- but it's clearly an improvised, temporary, low-cost solution.

To be fair, the decision to house the line in the "tent" may have been at least partly about getting it into operation as quickly as possible. But it's a safe bet that cost was also a very big factor.

That said, we don't know how much Tesla spent on the Model 3 ramp-up in the second quarter. But it's likely that it was considerably more than the company earned on the cars it managed to make before quarter-end.

Tesla has also pushed its credit line to the hilt

Back in 2015, Tesla opened up an asset-backed revolving credit line with a syndicate of banks. It's asset-backed, which means Tesla has been borrowing against its accounts receivable, inventory, and equipment. It was originally a $500 million line of credit, but Tesla has expanded it several times by adding more collateral to the loan.

As of the end of the first quarter, the total line of credit had been expanded to a little over $1.8 billion, of which Tesla had used $1.29 billion. (In other words, its balance due was $1.29 billion, and it had about $543 million left to draw on.) But in another sign that Tesla is worried about its cash, it expanded the line of credit again in May by adding a very big piece of collateral: its factory in Fremont, California.

Put simply, Tesla laid the groundwork for mortgaging its factory. The company may or may not have actually borrowed against the factory yet, but it now can.

Let's just say that's not something you do when you have plenty of cash available.

Long story short: Tesla probably needs to raise more money

CEO Elon Musk has said repeatedly that Tesla won't need to raise additional cash in 2018. Most analysts have been quite skeptical, with even longtime Tesla bull Adam Jonas, of Morgan Stanley, saying that Tesla will almost certainly need to raise $3 billion in the third quarter to cover upcoming debt payments and ongoing expenses.

So far, there haven't been any signs that Tesla is preparing to raise more cash. Expect that to be a major focus -- maybe the focus -- during Tesla's second-quarter earnings call on Aug. 1.