Measure capacity of Lithium by Coulomb counter method while charging
The process is a tad more complicated than that. 


The %battery is not an absolute value, it is a dynamic value. You need to keep a current running tally of the charge in the battery and its current capacity. If you start counting the outgoing current at 72% capacity then your first formula does not work. 
The battery may have more or less capacity than 13Ah. You also need to keep track of what that capacity is. This will degrade over time. The algorithm needs to cross check the voltage of the battery vs its current capacity. If the voltage shows discharged but the battery is at 30% then the total capacity needs to be adjusted. This is further compounded by the fact that draining the battery to its low voltage cut off is not practical and so voltage readings need to be taken all across the full range of the battery.