Costs are calculated as (electricity price * kWh consumed) + (feed-in tariff * kWh consumed). These two values are then added together.
Example:
1 kWh from grid import * 0.28 EUR/kWh = 0.28 EUR.
100 kWh from PV surplus * 0.009 EUR/kWh = 0.90 EUR.
Therefore, the 101 kWh cost you a total of 1.18 EUR.