Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix - Plantillas PDF - Formatear número con las preferencias del usuario #429

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions SticInclude/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ public static function createMandate()
}

/**
* Set the proper decimal separator according to the user/system configuration
* Set value with appropriate separators according to user/system configuration
*
* @param Decimal $decimalValue
* @param Boolean $userSetting. Indicates whether to choose user or system configuration
Expand All @@ -494,13 +494,24 @@ public static function formatDecimalInConfigSettings($decimalValue, $userSetting
{
global $current_user, $sugar_config;

// Get the user preferences for the thousands and decimal separator and the number of decimal places
if ($userSetting) {
// User decimal separator
$user_dec_sep = (!empty($current_user->id) ? $current_user->getPreference('dec_sep') : null);
// User thousands separator
$user_grp_sep = (!empty($current_user->id) ? $current_user->getPreference('num_grp_sep') : null);
// User number of decimal places
$user_sig_digits = (!empty($current_user->id) ? $current_user->getPreference('default_currency_significant_digits') : null);
}

// Set the user preferences or the default preferences
$dec_sep = empty($user_dec_sep) ? $sugar_config['default_decimal_seperator'] : $user_dec_sep;
$grp_sep = empty($user_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $user_grp_sep;
$sig_digits = empty($user_sig_digits) ? $sugar_config['sigDigits'] : $user_sig_digits;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El nombre correcto de la configuración debería ser default_currency_significant_digits: en config.php, se define en $sugar_config:

'default_currency_significant_digits' => 2,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corregido!


return str_replace('.', $dec_sep, $decimalValue);
// Format the number
$value = number_format($decimalValue, $sig_digits, $dec_sep, $grp_sep);
return $value;
}

/**
Expand Down
Loading