Because you use the cash method of accounting you don't have a choice on this. The income is reported as such in the tax year that money is received. Period. Then as you already know, what you paid for the inventory is not deductible until the tax year you actually sell the product.
We sat on $ 40K in inventory for five months.
Doesn't matter. The $20K received by you in 2017 is income and that's really not up for debate by either of us. What's also not up for debate by either of us is the fact that what you pay for inventory is not deductible until the tax year you actually sell that inventory. So even if you purchased the inventory 50 years ago, what you paid for that inventory is not deductible until the tax year you actually sell that inventory. So if the $20K received in 2017 puts you in a higher tax bracket, that's basically just to bad. It sucks I know. But it is what it is.