Fix undefined index if no purchases made
Merge pull request #2164 from elliott-stocks/patch-16

Fix undefined index if no purchases made