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

Fix #9261 - Use decimal symbol configured in system and user #10495

Open
wants to merge 1 commit into
base: hotfix
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 17 additions & 0 deletions include/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -6339,3 +6339,20 @@ function isWebToLeadAllowedRedirectHost(string $url): bool {

return false;
}

/**
* Set the proper decimal separator according to the user/system configuration
*
* @param Decimal $decimalValue
* @param Boolean $userSetting. Indicates whether to choose user or system configuration
* @return Decimal
*/
function formatDecimalInConfigSettings($decimalValue, $userSetting = false) {
global $current_user, $sugar_config;
if ($userSetting) {
$user_dec_sep = (!empty($current_user->id) ? $current_user->getPreference('dec_sep') : null);
}
$dec_sep = empty($user_dec_sep) ? $sugar_config['default_decimal_seperator'] : $user_dec_sep;
return str_replace('.', $dec_sep, $decimalValue);
}

7 changes: 7 additions & 0 deletions modules/AOS_PDF_Templates/templateParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ public static function parse_template_bean($string, $key, &$focus)
ENT_COMPAT, 'UTF-8');
$repl_arr[$key . "_" . $fieldName] = html_entity_decode((string) $focus->{$fieldName},
ENT_COMPAT, 'UTF-8');
} elseif ($field_def['type'] == 'decimal' || $field_def['type'] == 'float') {
if ($_REQUEST['entryPoint'] == 'formLetter') {
$value = formatDecimalInConfigSettings($focus->$fieldName, true);
} else {
$value = formatDecimalInConfigSettings($focus->$fieldName, false);
}
$repl_arr[$key . "_" . $fieldName] = $value;
} else {
$repl_arr[$key . "_" . $fieldName] = $focus->{$fieldName};
}
Expand Down
3 changes: 3 additions & 0 deletions modules/EmailTemplates/EmailTemplateParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ private function getValueFromBean($variable)
if (isset($app_list_strings[$enum][$this->module->$attribute])) {
$this->module->$attribute = $app_list_strings[$enum][$this->module->$attribute];
}
} else if (($this->module->field_name_map[$attribute]['type']) && (($this->module->field_name_map[$attribute]['type']) === 'decimal' || ($this->module->field_name_map[$attribute]['type']) === 'float')) {
$value = formatDecimalInConfigSettings($this->module->$attribute, false);
return $value;
}
return $this->module->$attribute;
}
Expand Down