Added tot calculation

Added calcDateTot to calc tot. I have also added some code clean up