Eligibility Tab Income Javascript
From PikaDocs
| Table of contents |
Part 1: Examining the Javascript code for Income on the Eligibility Tab
(Description as of Pika 3.05)
Pressing the Calculate button does the following:
1) calls calc_income()
2) counts # of people and figures % of poverty
function calc_income() does the following:
1) converts the frequency of the income to annual
2) multiplies the income amount to make it annual
3) calls income_change()
function income_change() does the following:
1) sets the frequency of the income to annual
Note: does not convert the income amount to annual
2) adds up the income totals into the field income (this is the readonly field you see for income total)
3) adds up the income totals again into the hidden field, income_only (why? I'm not sure)
Every time one of the income fields (annual0, annual1, etc.) is changed, the onChange method calls the function annual_change(). This is a historical relic, right now it does nothing except return true;
The template file itself, case_elig.html, calls the function income_change() each time it is loaded. (Is this true? - need to doublecheck and clarify exactly when the function runs).
/modules/case-elig.php has the following code:
for ($i = 0; $i < 5; $i++)
{
if ($case_row["annual{$i}"] != '')
{
$case_row["income_freq{$i}"] = 'A';
}
}
which will change the frequency to annual if it is anything else. This runs upon page load.
Part 2: Potential Bugs or Problems with Existing Code
- Ticket 1354 (http://pikasoftware.net/support/s.php/tickets/1354/)
- Ticket 732 (http://pikasoftware.net/support/s.php/tickets/732/)
Part 3: Potential Solution to be tested in Vermont
modify /subtemplates/case-info.html to comment out the call to income_change();
<script type="text/javascript" language="JavaScript"> <!-- // The second (non-adjusted) Income field needs to be calculated on each page view (it's not in the DB.) <!-- Andrew 2006/2/27 the following line is unnecessary for us, commenting out --> //income_change(); //--> </script>
Also, add a new onSubmit event to the form:
<form action="%%[base_url]%%/ops/update_case.php" method="post" name="ws" onSubmit="return calc_income();">
Part 4: Fix on the Way from Pika Software
Aaron is working on a fix probably for version 3.06 that will work on the PHP backend to convert the frequency and amount correctly.
Andrew Cameron
