The profit made by selling an inventory item is the difference between your sales price and the average cost of the item (in the Inventory on hand account) at the time the sales transaction is entered. It does not matter whether the transaction is a sales invoice or receipt. The current average cost of the item is posted as a debit to the Inventory - cost expense account. At the same time, the selling price is posted as a credit to the Inventory - sales income account. The difference is profit or margin. That is what goes into the Inventory Profit Margin report.
In your example, if you purchase 1 item at 35.56 and the next 1 at 40.12 (and make no sales or other purchases), your average cost will be 37.84. If you then sell 1 for 45.00, your profit will be 7.16.