fix #7699 - order in history
typo fix
refactor cost counter and add total cost @BOOtak