Add js to calculate credit and total