CRM-14329 fix
Optimization changes
Minor fix
Merge pull request #64 from monishdeb/CRM-14329

CRM-14329 fix
apply discount automatically only in cases of automatic discount and apply discount after the code