Energy meter - import/export

Hello, I have the same question. Could someone give us a suggestions about how to calculate the balance of energy between production and consumption? Thanks.