bggann
Active Member
I have a calc field (charged cost) in a repeated group which is the total of 4 other calc fields and 3 direct entry fields in the repeated group.
I'm having very inconsistent results on getting the "charged_cost" field to calculate when one of the 4 input calc fields changes. It works fine when one of the 3 direct input fields changes.
It seems to not trigger calculation sometimes, and sometimes it does. Sometimes it triggers but returns the wrong result.
It seems like the ajax calls may be out of sequence, perhaps my "total" field is calculated 'before' one of it's inputs.
Another possibility is formating. I've added %$01.2f formats to some of my calculated fields so they show up nicely in the list. But - it seems that maybe this is causing them to be treated differently in the calculation - though that does not seem to mess up the calculations based upon direct entry fields. I added (float) to cast these elements but it did not help.
Code from the calc field. Note - I started with this all in one line - broken it up and assigned variables to try to debug.
---
$hobbs_cost = (float) '{daily_log_7_repeat___hobbs_flight_cost}';
dump($hobbs_cost,'hobbs');
$availability_charged = (float) '{daily_log_7_repeat___availability_cost}';
dump($availability_charged,'aval');
$pilot_per_diem_total = (float) '{daily_log_7_repeat___pilot_per_diem_total}';
dump($pilot_per_diem_total,'pilot');
$mechanic_per_diem_total = (float) '{daily_log_7_repeat___mechanic_per_diem_total}';
dump($mechanic_per_diem_total,'mechanic');
$other_charges = (float) '{daily_log_7_repeat___other_charges}';
dump($other_charges,'other');
$aircraft_fuel = (float) '{daily_log_7_repeat___aircraft_fuel_cost}';
dump($aircraft_fuel,'aircraft fuel');
$relief_crew_travel = (float) '{daily_log_7_repeat___relief_crew_travel_charge}';
dump($relief_crew_travel,'releif');
$charged_cost = $hobbs_cost + $availability_charged + $pilot_per_diem_total + $mechanic_per_diem_total + $other_charges + $aircraft_fuel + $relief_crew_travel;
dump($charged_cost,'charged_cost');
return $charged_cost;
----
Of these fields - the 1st 4 are calculated and changing them does not update "charged_cost"
The last 3 are direct entry fields, and the calculation works fine.
It -seems- as if charged_cost is written to the db correctly - I think.
I'm having very inconsistent results on getting the "charged_cost" field to calculate when one of the 4 input calc fields changes. It works fine when one of the 3 direct input fields changes.
It seems to not trigger calculation sometimes, and sometimes it does. Sometimes it triggers but returns the wrong result.
It seems like the ajax calls may be out of sequence, perhaps my "total" field is calculated 'before' one of it's inputs.
Another possibility is formating. I've added %$01.2f formats to some of my calculated fields so they show up nicely in the list. But - it seems that maybe this is causing them to be treated differently in the calculation - though that does not seem to mess up the calculations based upon direct entry fields. I added (float) to cast these elements but it did not help.
Code from the calc field. Note - I started with this all in one line - broken it up and assigned variables to try to debug.
---
$hobbs_cost = (float) '{daily_log_7_repeat___hobbs_flight_cost}';
dump($hobbs_cost,'hobbs');
$availability_charged = (float) '{daily_log_7_repeat___availability_cost}';
dump($availability_charged,'aval');
$pilot_per_diem_total = (float) '{daily_log_7_repeat___pilot_per_diem_total}';
dump($pilot_per_diem_total,'pilot');
$mechanic_per_diem_total = (float) '{daily_log_7_repeat___mechanic_per_diem_total}';
dump($mechanic_per_diem_total,'mechanic');
$other_charges = (float) '{daily_log_7_repeat___other_charges}';
dump($other_charges,'other');
$aircraft_fuel = (float) '{daily_log_7_repeat___aircraft_fuel_cost}';
dump($aircraft_fuel,'aircraft fuel');
$relief_crew_travel = (float) '{daily_log_7_repeat___relief_crew_travel_charge}';
dump($relief_crew_travel,'releif');
$charged_cost = $hobbs_cost + $availability_charged + $pilot_per_diem_total + $mechanic_per_diem_total + $other_charges + $aircraft_fuel + $relief_crew_travel;
dump($charged_cost,'charged_cost');
return $charged_cost;
----
Of these fields - the 1st 4 are calculated and changing them does not update "charged_cost"
The last 3 are direct entry fields, and the calculation works fine.
It -seems- as if charged_cost is written to the db correctly - I think.