I think you're conflating two different usages of the term "money". Wikipedia calls them "money of account" and "money of exchange". Money of account appears to be older, and was, as you say, invented to keep track of debts. But when economics textbooks talk about money being invented to solve the double coincidence of wants problem, which is the main limitation of barter, they are talking about money of exchange.