So,
I am back, apparently I was able to follow your suggestions (andopes) and the math for the custom module is working. Thank You, again.
Here is the problem I am running into now. I was able to create the logic_hooks.php, and the logic file, in my case I created the following:
logic_hooks.php and total_monthly_net.php (which is called by logic_hooks.php (or is it defined in?))
At this point everything is working wonderfully and as you can see the files seem to be working and doing exactly what they are asked to do.
logic_hooks.php
total_monthly_net.phpCode:<?php // Do not store anything in this file that is not part of the array or the hook version. This file will // be automatically rebuilt in the future. $hook_version = 1; $hook_array = Array(); // position, file, function :: FINANCIALS LOGIC $hook_array['before_save'] = Array(); $hook_array['before_save'][] = Array(1, 'total_monthly_net', 'custom/modules/sec2_financials/total_monthly_net.php', 'total_monthly_net_class', 'total_monthly_net_method'); ?>
Code:<?php if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class total_monthly_net_class { function total_monthly_net_method(&$focus, $event, $arguments) { // andopes comment: for float numbers it is necessary to unformat them to avoid wrong calculation require_once('modules/sec2_financials/sec2_financials.php'); $main_net_inc = unformat_number($focus->main_net_inc); $co_net_inc = unformat_number($focus->co_net_inc); $second_job_c = unformat_number($focus->second_job_c); $child_support = unformat_number($focus->child_support); $rental = unformat_number($focus->rental); $ss_inc = unformat_number($focus->ss_inc); $pension = unformat_number($focus->pension); $other_inc = unformat_number($focus->other_inc); $total_mon_inc = $main_net_inc + $co_net_inc + $second_job_c + $child_support + $rental + $ss_inc + $pension + $other_inc; $focus->total_mon_inc = format_number($total_mon_inc); } } ?>
This is where my problem begins:
I added a second definition to logic_hooks.php as you can see in the provided file(s). I have also added the math calculation in the second .php file named monthly_obs.php ; however at this point the field that should be auto calculating is doing nothing. No data is stored and I am not getting any errors to otherwise make me believe I am doing something wrong.
logic_hooks.php (adding a second definition)
monthly_obs.php (second definition logic)Code:<?php // Do not store anything in this file that is not part of the array or the hook version. This file will // be automatically rebuilt in the future. $hook_version = 1; $hook_array = Array(); // position, file, function :: FINANCIALS LOGIC $hook_array['before_save'] = Array(); $hook_array['before_save'][] = Array(1, 'total_monthly_net', 'custom/modules/sec2_financials/total_monthly_net.php', 'total_monthly_net_class', 'total_monthly_net_method'); $hook_array['before_save'][] = Array(1, 'monthly_obs', 'custom/modules/sec2_financials/monthly_obs.php', 'monthly_obs_class', 'monthly_obs_method'); ?>
What should I be doing at this point. Bare in mind, I will be running multiple math equations in this module so I need to be sure I can define more than 2 or 3 .php files with logic to:Code:<?php class monthly_obs_class { function monthly_obs_method(&$focus, $event, $arguments) { // andopes comment: for float numbers it is necessary to unformat them to avoid wrong calculation $rents_pay = unformat_number($focus->rents_pay); $home_repairs = unformat_number($focus->home_repairs); $other_mortg = unformat_number($focus->other_mortg); $total_monthly_ob = $rents_pay + $home_repairs + $other_mortg; $focus->total_monthly_ob = format_number($total_monthly_ob); } } ?>
a) calculate
b) print/save data in the appropriate field(s)
Thanks again for any help any of you may be able to provide.


LinkBack URL
About LinkBacks



Reply With Quote

Bookmarks