added single quotes to where clause in sql strings
fixed methods in purchase model