Background accounting entry on sales/purchase transaction

Can anyone guide me on how the background accounting entries take place when we make a purchase or a sale.

Eg., if I have a product with Sales Price of 6000 and Purchase price of 5000, then what would be the background journal entry at the time of a purchase and a sale.

My sales invoices somehow end up in the Cost of Sales a/c resulting in wrong profit figure.

For Purchase -
Purchase Account Debit
Supplier/Creditor Account Credit

For Sale -
Customer/Debtors Account Debit
Sales Account Credit