Implemented true total price calculation
Extracted sql from entities