[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug? in 1.2.x: departments/accounts/projects change unpredictably on update or post

hi folks,

i'd love help with a nagging problem:

on AR/AP entries, the selected values for department, project, expense/income
account, and employee are all vulnerable to "disappearing" or changing to other
values on update or on post.  the update behavior seems to be the most
reproducible, with some specific accounts always changing on update, but not on
post.   more sporadically, "post" will not actually touch the db but will
effectively "update", with changed information.

i have a db that has been upgraded for about 6 years, from old versions of SL
back in the day.  it's entirely possible, i imagine, that some peculiar db
corruption is causing this behavior, which i've not seen described on this list
or in docs/buglists, etc.  (*has* anyone seen something like this?)

this behavior existed in SL, in 1.1.x, and i just upgraded finally to 1.2.22
and the behavior remains.

some initial exploration of the code in bin/aa.pl indicates that the html
"<option selected>" is set like this:

    for ( "$form->{vc}", "department", "employee", "formname" ) {
        $form->{"select$_"} = $form->unescape( $form->{"select$_"} );
        $form->{"select$_"} =~ s/ selected//;
        $form->{"select$_"} =~ s/(<option value="\Q$form->{$_}\E")/$1 selected/;

similar process for $selectprojectnumber and $selectamount.

a few watch variables seem to indicate that the error is often caused by
imperfect matches between the two sides of the regexp search/replace -- extra
spaces, or sometimes the department_id is missing in the scraped value.

the $form->{$_} values seem to get set in something like:

    if ( @{ $form->{all_department} } ) {
        $form->{selectdepartment} = "<option>\n";
        $form->{department} = "$form->{department}--$form->{department_id}"
          if $form->{department_id};

        for ( @{ $form->{all_department} } ) {
            $form->{selectdepartment} .=
qq|<option value="$_->{description}--$_->{id}">$_->{description}\n|;

this lacks a lot of error-checking, and it seems that perhaps, for example,
sometimes $form->{department_id} isn't set for some reason when
$form->{department} is.

but i don't really understand the details of how the selected options are
remembered between one update and the next.  

it *seems* to me that the hidden variables containing the whole list of the
$select list text for each variabel may be the way -- but i'm not sure.  anyone
have more experience to minimize more wasted hours on this?

thanks a ton!
be well,