Hi everyone,
For what it's worth - I had the same issue with the affiliate_sales table not being populated when it should be.
I solved the problem by changing the following line in affiliate_checkout_process.php :
if ($HTTP_SESSION_VARS['affiliate_ref']) {
to
if ($affiliate_ref) {
Hope that can be of use to somebody.