Issue with % adjustements with decimals
pcambra - September 30, 2008 - 08:11
| Project: | Ubercart Payment Method Adjustments |
| Version: | 5.x-1.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Hi
I have posted this on ubercart forums, and Ryan told me that it was better to open an issue here:
I don't know if this is posted already, but for % adjustements with decimals, it truncates the decimal part.
ie. for 6.95% COD adjustment the adjustment applied is 0.06 instead of 0.0695
I've modified the _payment_method_adjustment of uc_pma.module for solving this (lines 178-183 or so):
Before:
if (strstr($adjustment, '%')){
$percent = TRUE;
$adjustment = str_replace('%', '', $adjustment);
$adjustment /= 100;
}After:
if (strstr($adjustment, '%')){
$percent = TRUE;
$adjustment = str_replace('%', '', $adjustment);
$adjustment = number_format(str_replace(variable_get('uc_currency_dec', '.'),".",$adjustment), 2);
$adjustment /= 100;
}Lyle has commented that it would be better to use floatval instead number_format, but I haven't tested it..

#1
This might be related to #307151: Adjustments over $1000 do not work correctly, but I haven't had a chance to look closely at both these issues yet.
I'll test out your suggestion and see if it happens to remedy both problems. Thanks for the bug report and fix.
#2
I believe this is fixed here: http://drupal.org/cvs?commit=145406
Can you give it a try?
#3
#4
Automatically closed -- issue fixed for two weeks with no activity.