I had problems, too and finally tracked down the culprit. There's a typo (and some strange definitions) in one file that I was able to fix, some missing definitions, and some potential glitches with the paypal module that I've found so far.
In includes/modules/order_total.php:
replace
'value' => $account_balance, $tax);
with
'value' => tep_add_tax($account_balance, $tax));
and replace
if ($ot > $ab) {
$ot -= $ab; // + tep_calculate_tax($begin_account_balance, $tax);
$account_balance = 0;
}
if ($ot < $ab) {
// $account_balance = $begin_account_balance - $ot; // + tep_calculate_tax($begin_account_balance, $tax) - $order->info['total'];
$account_balance = $ot; // + tep_calculate_tax($begin_account_balance, $tax) - $order->info['total'];
$ot = 0;
}
if ($ot == $ab) {
$ot = 0;
$account_balance = 0;
}
with
if ($ot > $ab) {
$ot -= $ab; // + tep_calculate_tax($begin_account_balance, $tax);
$account_balance = $ab;
}
elseif ($ot < $ab) {
// $account_balance = $begin_account_balance - $ot; // + tep_calculate_tax($begin_account_balance, $tax) - $order->info['total'];
$account_balance = $ot; // + tep_calculate_tax($begin_account_balance, $tax) - $order->info['total'];
$ot = 0;
}
elseif ($ot == $ab) {
$ot = 0;
$account_balance = $ab;
}
The latter fix makes the account balance on the order preview page display the amount that was actually subtracted from the total, rather than what's left in the account, which doesn't make sense to me as a line item on an invoice and causes the total to be wrong anyway. Also the lack of elseifs was less than well thought out.
ALSO
There were several missing definitions in admin/includes/languages/english/customers.php:
here are some suggestions:
define('CATEGORY_ACCOUNT_BALANCE','Account Balance');
define('TABLE_HEADING_ACCOUNT_BALANCE', 'Account Balance');
define('ENTRY_ACCOUNT_BALANCE_OLD','Current Balance');
define('ENTRY_ACCOUNT_BALANCE','Add (or subtract) Balance');
define('ENTRY_ACCOUNT_BALANCE_DESC','Description');
AND
this module totally screws with paypal if the total ends up being less than the usual shipping cost, so this fix has to be made:
You'll see where this goes, in includes/modules/shipping/PayPal.php:
I commented out the existing code below and wrote my mods underneath
// fixed for my use with gift certificates - Ben
// tep_draw_hidden_field('amount', number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency))) .
tep_draw_hidden_field('amount', number_format($order->info['total'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency))) .
// and this, to fix shipping - Ben
// tep_draw_hidden_field('shipping', number_format($order->info['shipping_cost'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency))) .
tep_draw_hidden_field('shipping', number_format(0 * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency))) .
I'm still working on this stuff myself, so let me know if this helps.
You owe me $200! ;-)
Ben