Calculate the cost for maintenance and insert into db