Results 1 to 7 of 7

Thread: logic hook without to round result

  1. #1
    manolotri is offline Senior Member
    Join Date
    Apr 2009
    Posts
    44

    Exclamation logic hook without to round result

    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 !

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: logic hook without to round result

    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.

  3. #3
    manolotri is offline Senior Member
    Join Date
    Apr 2009
    Posts
    44

    Smile Re: logic hook without to round result

    I don't know if this is that you want:

    Logic_hook:
    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');

    ?>
    operationLogicHook:
    PHP 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;
        }
    }
    ?>
    Only the last code line is given me the rounded result coste_km_c=0.23

    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,
    );
    ?>

  4. #4
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: logic hook without to round result

    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.

  5. #5
    manolotri is offline Senior Member
    Join Date
    Apr 2009
    Posts
    44

    Default Re: logic hook without to round result

    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 !!

  6. #6
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: logic hook without to round result

    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.

  7. #7
    manolotri is offline Senior Member
    Join Date
    Apr 2009
    Posts
    44

    Default Re: logic hook without to round result

    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help on my first logic hook.
    By amrutha in forum Developer Help
    Replies: 9
    Last Post: 2009-11-24, 01:29 PM
  2. logic hook
    By atik in forum Developer Help
    Replies: 2
    Last Post: 2009-03-28, 10:47 AM
  3. help with a logic hook
    By souheil in forum Français
    Replies: 12
    Last Post: 2009-03-13, 09:00 AM
  4. Help with a Logic Hook
    By Iggby in forum Developer Help
    Replies: 6
    Last Post: 2009-01-29, 12:01 PM
  5. logic Hook up
    By sugar7478 in forum Developer Help
    Replies: 8
    Last Post: 2008-07-11, 02:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •