If you have an existing analysis code and are receiving this error, then it would suggest that the type of analysis code is incorrect for the transaction you are posting. To check, you can view the analysis code and if it is not a Purchase type, you will not be able to post purchase transactions. You can check this by doing the following:
Navigate to Creditors, Settings, Analysis
Find the analysis code and press the Eye icon
Look at the Type. If it's not Purchase, then change this by pressing Edit and then pressing Save
