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 - General - Usar el delimitador de decimales configurado en campos FLOAT #338

Merged
merged 2 commits into from
Sep 20, 2024
Merged
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
22 changes: 14 additions & 8 deletions include/SugarFields/Fields/Float/SugarFieldFloat.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,21 @@ public function importSanitize(
$focus,
ImportFieldSanitize $settings
) {
$value = str_replace($settings->num_grp_sep, "", $value);
$dec_sep = $settings->dec_sep;
if ($dec_sep != '.') {
$value = str_replace($dec_sep, ".", $value);
// STIC-Custom 20240814 MHP - https://github.com/SinergiaTIC/SinergiaCRM/pull/338
// Apply the solution that is applied with the Decimal type fields, which is the one implemented in SugarFieldBase
// $value = str_replace($settings->num_grp_sep, "", $value);
// $dec_sep = $settings->dec_sep;
// if ($dec_sep != '.') {
// $value = str_replace($dec_sep, ".", $value);
// }
// if (!is_numeric($value)) {
// return false;
// }
if (isset($vardef['len'])) {
// check for field length
$value = sugar_substr($value, $vardef['len']);
}
if (!is_numeric($value)) {
return false;
}

// STIC-Custom
return $value;
}
}
3 changes: 2 additions & 1 deletion modules/AOS_PDF_Templates/templateParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public static function parse_template_bean($string, $key, &$focus)
ENT_COMPAT, 'UTF-8');
// STIC-custom 20210922 - Parse decimal symbol in templates according to configuration
// STIC#390
} elseif ($field_def['type'] == 'decimal') {
// https://github.com/SinergiaTIC/SinergiaCRM/pull/338
} elseif ($field_def['type'] == 'decimal' || $field_def['type'] == 'float') {
require_once('SticInclude/Utils.php');
if ($_REQUEST['entryPoint'] == 'formLetter') { // If generating a PDF...
$value = SticUtils::formatDecimalInConfigSettings($focus->$fieldName, true); // ...get user config
Expand Down
3 changes: 2 additions & 1 deletion modules/EmailTemplates/EmailTemplateParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ private function getValueFromBean($variable)
}
// STIC-custom 20210922 - Parse decimal symbol in templates according to configuration
// STIC#390
else if (($this->module->field_name_map[$attribute]['type']) && ($this->module->field_name_map[$attribute]['type']) === 'decimal'){
// https://github.com/SinergiaTIC/SinergiaCRM/pull/338
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')){
require_once('SticInclude/Utils.php');
$value = SticUtils::formatDecimalInConfigSettings($this->module->$attribute, false);
return $value;
Expand Down
3 changes: 2 additions & 1 deletion modules/KReports/KReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,8 @@ function formatFields($fieldArray, $excludeFields = array(), $toPdf = false, $fo
// Following the above statement, a specific condition is added for decimal and datetimecombo types.
// STIC#222
// STIC#296
if ($this->fieldNameMap[$fieldID]['type'] == 'decimal' || $this->fieldNameMap[$fieldID]['type'] == 'datetimecombo') {
// https://github.com/SinergiaTIC/SinergiaCRM/pull/338
if ($this->fieldNameMap[$fieldID]['type'] == 'decimal' || $this->fieldNameMap[$fieldID]['type'] == 'float' || $this->fieldNameMap[$fieldID]['type'] == 'datetimecombo') {
$thisFieldRenderer = $this->getXtypeRenderer((!empty($fieldDetails['overridetype']) ? $fieldDetails['overridetype'] : $this->fieldNameMap [$fieldID] ['type']) , $fieldID);
}
else {
Expand Down
Loading