Automatic energy accounting and sales system