How do I create 12 month rolling total?

I am self-employed and want to stay under the VAT threshold so I need to keep an eye on my 12 month rolling total of earnings. I have a spreadsheet set up with ‘month’ in column A, ‘earnings’ in column B and I’d like column C to be rolling total for the previous 12 moths but I cannot for the life of me find a formula that allows me to see a total for the 12 months in any given month. Can anyone help please?

It is not exactly easy for me to describe a solution (except in very general terms). Therefor I preferred to create this attached demo.
It handles two different assumptions concerning the 12-month-period. Firstly: The period must start with a first-day-of-month. Secondly: The period can start with any day.