Why the result of a logic hook operation is to rounded (is it 'to rounded' ?, soz for my english).
it's to say, if the result is 4.76 it take 5.00 Why??
Thanks in advance !
Why the result of a logic hook operation is to rounded (is it 'to rounded' ?, soz for my english).
it's to say, if the result is 4.76 it take 5.00 Why??
Thanks in advance !
Hi manolotri
Let us know the content of the logic_hook function and the cached vardefs: cache/modules/<ModuleName>/<ClassName>vardefs.php
Cheers
André Lopes
DevToolKit / Project of the Month - June 2009
Lampada Global Services- Open Source Solutions
Avenida Ipiranga, 318
Bloco B - CJ 1602
São Paulo, SP 01046-010
Brazil
Office: +55 11 3237-3110
Mobile: +55 11 7636-5859
e-mail: andre@lampadaglobal.com
Lampada Global delivers offshore software development and support services to customers around the world.
Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.
I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.
I don't know if this is that you want:
Logic_hook:
operationLogicHook:PHP Code:<?php
$hook_version = 1;
$hook_array = Array();
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'Operacion', 'custom/modules/ba01_parte_de_gastos/operacionLogicHook.php','operacion_code', 'operacion_code');
?>
Only the last code line is given me the rounded result coste_km_c=0.23PHP Code:<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class operacion_code {
function operacion_code(&$focus, $event, $arguments) {
$focus->total_km_c = $focus->total_km_1_c + $focus->total_km_2_c + $focus->total_km_3_c + $focus->total_km_4_c + $focus->total_km_5_c;
$focus->importe_kms_c = $focus->total_km_c * $focus->coste_km_c;
$focus->total_dietas_c = $focus->dieta_1_c + $focus->dieta_2_c + $focus->dieta_3_c + $focus->dieta_4_c + $focus->dieta_5_c;
$focus->km_dietas_c = $focus->total_dietas_c + $focus->importe_kms_c + $focus->otros_gastos_c;
}
}
?>
PHP Code:<?php
// created: 2009-04-29 08:56:37
$GLOBALS["dictionary"]["ba01_Parte_de_Gastos"] = array (
'table' => 'ba01_parte_de_gastos',
'audited' => true,
'fields' =>
[SIZE="6"] [...][/SIZE]
'coste_km_c' =>
array (
'required' => '0',
'source' => 'custom_fields',
'name' => 'coste_km_c',
'vname' => 'LBL_COSTE_KM',
'type' => 'float',
'massupdate' => '0',
'default' => '0.23',
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'audited' => 0,
'reportable' => 0,
'len' => '18',
'precision' => NULL,
'id' => 'ba01_Parte_de_Gastoscoste_km_c',
'custom_module' => 'ba01_Parte_de_Gastos',
),
[SIZE="6"][...][/SIZE]
'total_km_c' =>
array (
'required' => '0',
'source' => 'custom_fields',
'name' => 'total_km_c',
'vname' => 'LBL_TOTAL_KM',
'type' => 'int',
'massupdate' => '0',
'default' => NULL,
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'audited' => 0,
'reportable' => 0,
'len' => '6',
'disable_num_format' => NULL,
'id' => 'ba01_Parte_de_Gastostotal_km_c',
'custom_module' => 'ba01_Parte_de_Gastos',
),
'importe_kms_c' =>
array (
'required' => '0',
'source' => 'custom_fields',
'name' => 'importe_kms_c',
'vname' => 'LBL_IMPORTE_KMS',
'type' => 'currency',
'massupdate' => '0',
'default' => NULL,
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'audited' => 0,
'reportable' => 0,
'len' => '26',
'id' => 'ba01_Parte_de_Gastosimporte_kms_c',
'custom_module' => 'ba01_Parte_de_Gastos',
),
'currency_id' =>
array (
'required' => '0',
'source' => 'custom_fields',
'name' => 'currency_id',
'vname' => 'LBL_CURRENCY',
'type' => 'id',
'massupdate' => '0',
'default' => NULL,
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'audited' => 0,
'reportable' => 0,
'len' => '36',
'studio' => 'visible',
'function' =>
array (
'name' => 'getCurrencyDropDown',
'returns' => 'html',
),
'id' => 'ba01_Parte_de_Gastoscurrency_id',
'custom_module' => 'ba01_Parte_de_Gastos',
),
'total_dietas_c' =>
array (
'required' => '0',
'source' => 'custom_fields',
'name' => 'total_dietas_c',
'vname' => 'LBL_TOTAL_DIETAS',
'type' => 'int',
'massupdate' => '0',
'default' => NULL,
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'audited' => 0,
'reportable' => 0,
'len' => '11',
'disable_num_format' => NULL,
'id' => 'ba01_Parte_de_Gastostotal_dietas_c',
'custom_module' => 'ba01_Parte_de_Gastos',
),
'km_dietas_c' =>
array (
'required' => '0',
'source' => 'custom_fields',
'name' => 'km_dietas_c',
'vname' => 'LBL_KM_DIETAS',
'type' => 'int',
'massupdate' => '0',
'default' => NULL,
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'audited' => 0,
'reportable' => 0,
'len' => '11',
'disable_num_format' => NULL,
'id' => 'ba01_Parte_de_Gastoskm_dietas_c',
'custom_module' => 'ba01_Parte_de_Gastos',
),
'otros_gastos_c' =>
array (
'required' => '1',
'source' => 'custom_fields',
'name' => 'otros_gastos_c',
'vname' => 'LBL_OTROS_GASTOS',
'type' => 'int',
'massupdate' => '0',
'default' => NULL,
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'audited' => 0,
'reportable' => 0,
'disable_num_format' => NULL,
'validation' =>
array (
'type' => 'range',
'min' => 0,
'max' => '100',
),
'id' => 'ba01_Parte_de_Gastosotros_gastos_c',
'custom_module' => 'ba01_Parte_de_Gastos',
),
),
'relationships' =>
[SIZE="6"][...][/SIZE]
),
'templates' =>
array (
'issue' => 'issue',
'assignable' => 'assignable',
'basic' => 'basic',
),
'custom_fields' => true,
);
?>
Hi manolotri
You have got the point!
It is exactly that I would like to see!
According to vardefs you provided:
total_km_c, total_dietas_c, km_dietas_c are integer fields (not decimal), so always rounded;
importe_kms_c is currency field, so it should display 2 decimal places.
Cheers
André Lopes
DevToolKit / Project of the Month - June 2009
Lampada Global Services- Open Source Solutions
Avenida Ipiranga, 318
Bloco B - CJ 1602
São Paulo, SP 01046-010
Brazil
Office: +55 11 3237-3110
Mobile: +55 11 7636-5859
e-mail: andre@lampadaglobal.com
Lampada Global delivers offshore software development and support services to customers around the world.
Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.
I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.
Thanks for reply !
"total_km_c, total_dietas_c, km_dietas_c are integer fields (not decimal), so always rounded;
importe_kms_c is currency field, so it should display 2 decimal places."
I have changed total_km_c, total_dietas_c, km_dietas_c and importe_kms_c to decimal. And the result is always rounded. ¿?¿?
I don't know what can i do :S
Thanks in advance !!
Did you click on Quick Repair and Rebuild on Admin -> Repair?
Make sure the fields type had been modified on cached vardefs.
Cheers
André Lopes
DevToolKit / Project of the Month - June 2009
Lampada Global Services- Open Source Solutions
Avenida Ipiranga, 318
Bloco B - CJ 1602
São Paulo, SP 01046-010
Brazil
Office: +55 11 3237-3110
Mobile: +55 11 7636-5859
e-mail: andre@lampadaglobal.com
Lampada Global delivers offshore software development and support services to customers around the world.
Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.
I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.
Hi !! I find the problem!!
In database the fields definition not change when i delete it and create other one with same name and diferent type, so i went to database and change manually the field type and the number of decimals.
Thanks for replys, ur time it's much apreciated thanks !
Last edited by manolotri; 2009-05-05 at 03:26 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks