I guess a line of credit to buy materials is ok, but we now understand the risks. There is a simpler solution.
On large projects, I usually ask for a 33% deposit when work commences to cover my material costs. Most customers expect to pay it. Those who won't pay set off an alarm in my head. Sometimes another 33% is due halfway through. The final 33% is due on completion.