Nobody would ever PLAN to file bankruptcy, so a common question that is asked is how would one avoid bankruptcy, either business or personal? The logical answer is with planning, where you need a sound business plan, either for your business or for yourself personally. This sounds easier than it really is, but at the same time, it is purely logical and does not require a rocket science degree to figure out.
Whether personal or business, you simply need to determine how much money you have coming in each month and how much money you have going out each month. Really, it is as simple as that. If the figure in the latter column is greater than the figure in the former column, you are going to have financial difficulties, and that can almost be guaranteed.
One of the things that comes into play when such a plan is being developed is counting on "future money". To a certain extent, this is unavoidable, because in order to continue to have money coming in each month, you need to assume that you will continue to get a paycheck, will not be laid off, or from a business perspective, you will continue to make the same amount of sales that you have in past months.
The problem comes in when those plans do not come together for unforeseen reasons. You could not predict you were going to be laid off or come down with jungle beri-beri. You could not predict that a competitor was going to come out with a product or service just like yours that is faster, better, and cheaper. So when you are making those business plans, you should also plan for contingencies. In other words, plan for the unexpected. Yes, people like to plan based on a best case scenario, but what would your plan look like if you based it on WORST case scenario? While you want to remain positive and optimistic, the most successful businesses out there today are the ones who EXPECTED the best but also had contingency plans for the WORST.
There are so many things that are out of your control that it is probably not even worth the effort to try to list them all. But to avoid bankruptcy, you should make sure your plan works for BOTH the best and worst case scenarios, and already have your plan of action defined for what happens in either situation.