I encountered once for what you mentioned here and ended up with my bonus back by talking to my director who help me negotiate with HR.
My friend ever faced similar issue like you and even left company one month before bonus period. I suggested him to go and talk with his supervisor for help and ended with prorated bonus.
What 亢牛有悔 said is true. I feel it is all about communication between you, your boss and hr. If all the time you play nice in the company, i believe your boss & company will consider reward you accordingly.