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

SF.net SVN: ledger-smb:[3056] addons/1.3



Revision: 3056
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3056&view=rev
Author:   einhverfr
Date:     2010-08-23 05:40:52 +0000 (Mon, 23 Aug 2010)

Log Message:
-----------
Aurynn's enhancements for AR/AP UI for large numbers of accounts

Added Paths:
-----------
    addons/1.3/extended_arap/
    addons/1.3/extended_arap/trunk/
    addons/1.3/extended_arap/trunk/UI/
    addons/1.3/extended_arap/trunk/UI/._aa.html
    addons/1.3/extended_arap/trunk/UI/aa.html
    addons/1.3/extended_arap/trunk/bin/
    addons/1.3/extended_arap/trunk/bin/custom/
    addons/1.3/extended_arap/trunk/bin/custom/._aa.pl
    addons/1.3/extended_arap/trunk/bin/custom/aa.pl

Added: addons/1.3/extended_arap/trunk/UI/._aa.html
===================================================================
(Binary files differ)


Property changes on: addons/1.3/extended_arap/trunk/UI/._aa.html
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: addons/1.3/extended_arap/trunk/UI/aa.html
===================================================================
--- addons/1.3/extended_arap/trunk/UI/aa.html	                        (rev 0)
+++ addons/1.3/extended_arap/trunk/UI/aa.html	2010-08-23 05:40:52 UTC (rev 3056)
@@ -0,0 +1,639 @@
+<?lsmb INCLUDE 'ui-header.html' 
+	include_script = [
+		"UI/ajax/scriptaculous/lib/prototype.js",
+		"UI/ajax/scriptaculous/src/scriptaculous.js?load=builder,effects,dragdrop,controls",
+		"UI/ajax/helpers.js"]
+	stylesheet=stylesheet ?>
+<?lsmb PROCESS 'elements.html' ?>
+    <body onload="document.forms[0].amount_<?lsmb rowcount?>.focus()">
+        
+        <form method="POST" action="<?lsmb script?>"> <?lsmb # This is definitely sub-ideal.?>
+            <?lsmb FOR id IN hidden_args?>
+                <?lsmb IF hidden_vars.id != ''?>
+                <?lsmb INCLUDE input element_data = {
+                    type="hidden",
+                    name=id,
+                    value=hidden_vars.id
+                }?>
+                <?lsmb END?>
+            <?lsmb END?>
+            <table width="100%">
+                <tr class="listtop">
+                    <th class="listtop">
+                        <?lsmb title?> <?lsmb# The title is always included first. ?>
+                            <?lsmb IF reverse?>
+                            <?lsmb IF subtype && subtype == 'credit_note'?>
+                                Credit Note
+                            <?lsmb ELSIF subtype && subtype == 'debit_note'?>
+                                Debit Note
+                            <?lsmb END?>
+
+                        <?lsmb ELSE?>
+                            <?lsmb ARAP?> Transaction
+                        <?lsmb END?>
+                    </th>
+                </tr>
+                <tr height="5"></tr>
+                <tr valign="top">
+                    <td>
+                        <table width="100%">
+                            <tr valign="top">
+                                <td>
+                                    <table>
+                                        <tr>
+                                            <th align="right">
+                                            <?lsmb IF vc == 'customer'?>
+                                                Customer
+                                            <?lsmb ELSE?>
+                                                Vendor
+                                            <?lsmb END?>
+                                            </th>
+                                            <td colspan="3">
+                                                <?lsmb IF all_vc_names?>
+                                                    <?lsmb INCLUDE select element_data = {
+                                                        name = vc,
+                                                        options = all_vc_names,
+                                                        default_values = all_vc_value
+                                                    }?>
+                                                <?lsmb ELSE?>
+                                                    <?lsmb INCLUDE input element_data = {
+                                                        type = "textarea",
+                                                        name = vc,
+                                                        size = 35, 
+                                                        value = all_vc_value
+                                                    }?>
+                                                <?lsmb END?>
+                                            </td>
+                                        </tr>
+                                        <tr>
+                                            <td></td>
+                                            <td colspan="3">
+                                                <table width="100%">
+                                                    <tr>
+                                                        <th align="left" nowrap="nowrap">
+                                                            <?lsmb text("Credit Limit")?>
+                                                        </th>
+                                                        <td>
+                                                            <?lsmb credit_limit || 0?>
+                                                            
+                                                        </td>
+                                                        <th align="left" nowrap="nowrap">
+                                                            <?lsmb text("Remaining")?>
+                                                        </th>
+                                                        <?lsmb IF credit_remaining != ''?>
+                                                            <td class="plus<?lsmb credit_remaining < 0 ? 0 : 1 ?>">
+                                                                <?lsmb format_amount(credit_remaining)?>
+                                                            </td>
+                                                        <?lsmb ELSE?>
+                                                            <td class="plus0">
+                                                            0
+                                                            </td>
+                                                        <?lsmb END?>
+                                                    </tr>
+                                                </table>
+                                            </td>
+                                        </tr>
+                                        <?lsmb IF batch_id ?>
+                                            <tr>
+                                                <th align="right" nowrap="nowrap">
+                                                    <?lsmb text("Batch Control Code")?>
+                                                </th>
+                                                <td><?lsmb batch_control_code?></td>
+                                            </tr>
+                                            <tr>
+                                                <th align="right" nowrap><?lsmb text("Batch Name")?></th>
+                                                <td><?lsmb batch_description?></td>
+                                            </tr>
+                                        <?lsmb END?>
+                                        
+                                        <?lsmb IF entity_control_code?>
+                                        
+                                            <tr>
+                                                <th align="right" nowrap><?lsmb text("Entity Control Code")?></th>
+                                                <td colspan="3"><?lsmb entity_control_code?></td>
+                                            </tr>
+                                            <tr>
+                                                <th align="right" nowrap="nowrap">
+                                                    <?lsmb text("Account")?>
+                                                </th>
+                                                <td colspan="3">
+                                                    <?lsmb meta_number?>
+                                                </td>
+                                            </tr>
+                                            
+                                        <?lsmb END?>
+                                        
+                                        <?lsmb IF defaultcurrency?>
+                                        <tr>
+                                            <th aligh="right" nowrap="nowrap">
+                                                <?lsmb text("Currency")?>
+                                            </th>
+                                            <td>
+                                                <?lsmb INCLUDE select element_data = {
+                                                    name="currency",
+                                                    default_values=defaultcurrency,
+                                                    options=all_currrencies
+                                                } ?>
+                                            </td>
+
+                                            <?lsmb IF currency != defaultcurrency?>
+
+                                                <?lsmb INCLUDE textarea element_data = {
+                                                    name="exchangerate",
+                                                    value=exchangerate,
+                                                    size=10
+                                                }?>
+                                            <?lsmb END?>
+                                        </tr>
+                                        <?lsmb END?>
+                                        
+                                        <?lsmb IF all_deparment?>
+                                        <tr>
+                                            <th align="right" nowrap="nowrap"><?lsmb text("Department")?></th>
+                                            <td colspan="3">
+                                                <?lsmb INCLUDE select element_data = {
+                                                    
+                                                    name="department",
+                                                    default_values=[department],
+                                                    options=all_department
+                                                }?>
+                                            </td>
+                                        </tr>
+                                        <?lsmb END?>
+                                        <?lsmb IF taxaccounts?>
+                                        <tr>
+                                            <th align="left" nowrap="nowrap"><?lsmb text("Tax Included?")?></th>
+                                            <td align="right">
+                                                <?lsmb INCLUDE input element_data = {
+                                                    
+                                                    name="taxincluded",
+                                                    type="checkbox",
+                                                    value="1",
+                                                    checked=taxincluded,
+                                                }?>
+                                            </td>
+                                        </tr>
+                                        <?lsmb END?>
+                                    </table>
+                                </td>
+                                
+                                
+                                <td align="right">
+                                    <table>
+                                        <?lsmb IF all_employees?> 
+                                            <?lsmb #Replaces selectemployee as the appropriate boolean item 
+                                                   #Allemployee is an array of option-compatible dicts.
+                                            ?>
+                                            
+                                            <tr>
+                                                <th align="right" nowrap="nowrap"> 
+                                                    <?lsmb IF ARAP == 'AR'?>
+                                                        Salesperson
+                                                    <?lsmb ELSE?>
+                                                        Employee
+                                                    <?lsmb END?>
+                                                </th>
+                                                
+                                                <td>
+                                                    <?lsmb INCLUDE select element_data = {
+                                                        name="employee",
+                                                        options=all_employee,
+                                                        default_values=employee
+                                                    }?>
+                                                </td>
+                                            </tr>
+                                        
+                                        <?lsmb END?>
+                                        <tr>
+                                            <th align="right" nowrap="nowrap">
+                                                <?lsmb text("Invoice Number")?>
+                                            </th>
+                                            <td>
+                                                <?lsmb INCLUDE input element_data = {
+                                                    type="textarea",
+                                                    size="20",
+                                                    value=invnumber,
+                                                    name="invnumber"
+                                                }?>
+                                            </td>
+                                        </tr>
+                                        <tr>
+                                            <th align="right" nowrap="nowrap">
+                                                <?lsmb text("Order Number")?>
+                                            </th>
+                                            <td>
+                                                <?lsmb INCLUDE input element_data = {
+                                                    type="textarea",
+                                                    name="ordernumber",
+                                                    size="20",
+                                                    value=ordernumber
+                                                }?>
+                                            </td>
+                                        </tr>
+                                        <tr>
+                                            <th align="right" nowrap="nowrap">
+                                                <?lsmb text("Invoice Date")?>
+                                            </th>
+                                            <td>
+                                                <?lsmb INCLUDE input element_data = {
+                                                    
+                                                    type="textarea",
+                                                    name="transdate",
+                                                    size=11,
+                                                    title=dateformat,
+                                                    value=transdate
+                                                }?>
+                                            </td>
+                                        </tr>
+                                        <tr>
+                                            <th align="right" nowrap="nowrap">
+                                                <?lsmb text("Due Date")?>
+                                            </th>
+                                            <td>
+                                                <?lsmb INCLUDE input element_data = {
+                                                    name="duedate",
+                                                    type="textarea",
+                                                    size="11",
+                                                    title=dateformat,
+                                                    value=duedate
+                                                }?>
+                                            </td>
+                                        </tr>
+                                        <tr>
+                                            <th align="right" nowrap="nowrap">
+                                                <?lsmb text("PO Number")?>
+                                            </th>
+                                            <td>
+                                                <?lsmb INCLUDE input element_data = {
+                                                    name="ponumber",
+                                                    type="textarea",
+                                                    size=20,
+                                                    value=ponumber
+                                                }?>
+                                            </td>
+                                        </tr>
+                                    </table>
+                                </td>
+                            </tr>
+                            </table>
+                            </td>
+                            </tr>
+                            <tr>
+                                <td>
+                                    <table>
+                                        <tr>
+                                            <th>
+                                                <?lsmb text("Amount")?>
+                                            </th>
+                                            <th></th>
+                                            <th><?lsmb text("Account")?></th>
+                                            <th><?lsmb text("Description")?></th>
+                                            <th><?lsmb text("Tax Form Applied")?></th>
+                                            <?lsmb IF has_project?>
+                                            <th><?lsmb text("Project")?></th>
+                                            <?lsmb END?>
+                                        </tr>
+                                        
+                                        <?lsmb FOREACH row IN rowcount_arr?>
+                                        <tr valign="top">
+                                            <td>
+                                                <?lsmb INCLUDE input element_data = {
+                                                    type="textarea",
+                                                    name="amount_" _ row.id,
+                                                    size=10,
+                                                    value=row.amount,
+                                                    accesskey=iter
+                                                }?>
+                                            </td>
+                                            <td></td>
+                                            <td>
+                                                <?lsmb PROCESS ajaxselect element_data = {
+                                                       name = ARAP _ "_amount" _ row.id,
+                                                       initial_value = ${"accno_$INDEX"},
+                                                       ajax_target = 'journal.pl',
+                                                       params = { link_desc = '"' _ arap_amount_name _ '"' }
+                                                       } ?>
+                                            </td>
+                                            <?lsmb #Not sure if numtextrows will show up as expected.?>
+                                            <td>
+                                                <?lsmb rowcount_arr.iter.desc_rows?>
+                                            <?lsmb IF rowcount_arr.iter.desc_rows != "" && rowcount_arr.iter.desc_rows > 1 ?>
+                                                <?lsmb INCLUDE textarea element_data = {
+                                                    rows=rowcount_arr.iter.desc_rows,
+                                                    name="description_" _ row.id,
+                                                    cols="40",
+                                                    text=row.description
+                                                }?>
+                                            <?lsmb ELSE?>
+                                                <?lsmb INCLUDE input element_data = {
+                                                    name="description_" _ row.id,
+                                                    type="textarea",
+                                                    value=row.description,
+                                                    size="40"
+                                                }?>
+                                            <?lsmb END?>
+                                            </td>
+                                            <td>
+                                                <?lsmb INCLUDE input element_data = {
+                                                    name="taxformcheck_" _ row.id,
+                                                    type="checkbox",
+                                                    checked=row.taxchecked
+                                                }?>
+                                            </td>
+                                            <?lsmb IF needs_project?>
+                                            <td>
+                                                <?lsmb INCLUDE select element_data = {
+
+                                                    name="projectnumber_" _ row.id,
+                                                    options=project_numbers,
+                                                    default_values=[row.project_default]
+                                                }?>
+                                            </td>
+                                            <?lsmb END?>
+                                            <?lsmb INCLUDE input element_data = {
+                                                name="entry_id_" _ row.id,
+                                                type="hidden",
+                                                value=row.entry_id
+                                            }?>
+                                        </tr>
+                                        <?lsmb END?> <?lsmb # End of for iter in [0..rowcount]?>
+                            
+                            <tr>
+                                <th align="left"><?lsmb #invtotal?></th>
+                                <td></td>
+                                <td>
+                                    <?lsmb INCLUDE select element_data = {
+                                        name=arap,
+                                        options=all_accounts_arap,
+                                        default_values=[all_accounts_arap_value]
+                                    }?>
+                                </td>
+                            </tr>
+                            <tr>
+                                <th align="right"><?lsmb text("Notes")?></th>
+                                <td></td>
+                                <td colspan="3">
+                                    <?lsmb INCLUDE textarea element_data = {
+                                        name="notes",
+                                        value=notes,
+                                        rows=note_rows,
+                                        cols=50,
+                                        wrap="soft"
+                                    }?>
+                                </td>
+                            </tr>
+                        </table>
+                    </td>
+                </tr>
+                
+                <tr class="listheading">
+                    <th class="listheading"><?lsmb text("Payments")?></th>
+                </tr>
+
+                <tr>
+                    <td>
+                        <table width="100%">
+                            <tr>
+                                <th><?lsmb text("Date")?></th>
+                                <th><?lsmb text("Source")?></th>
+                                <th><?lsmb text("Memo")?></th>
+                                <th><?lsmb text("Amount")?></th>
+                                <?lsmb IF currency != defaultcurrency ?> <?lsmb #If the currency values are not equal..?>
+                                <th><?lsmb text("Exch")?></th>
+                                <?lsmb END?>
+                                <th><?lsmb text("Account")?></th>
+                            </tr>
+                            <?lsmb FOREACH pd IN paid_arr?>
+                                <?lsmb INCLUDE input element_data = {
+                                    name="cleared_" _ pd.id,
+                                    type="hidden",
+                                    value=pd.cleared
+                                }?>
+                                <tr>
+                                    <td align="center">
+                                        <?lsmb INCLUDE input element_data = {
+                                            class="date",
+                                            name="datepaid_" _ pd.id,
+                                            size=11,
+                                            value= pd.datepaid,
+                                            type="textarea"
+                                        }?>
+                                    </td>
+                    
+                                    <td align="center">
+                                        <?lsmb INCLUDE input element_data = {
+                                            name="source_" _ pd.id,
+                                            size=11,
+                                            value=pd.source,
+                                            type="textarea"
+                                        }?>
+                                    </td>
+                    
+                                    <td align="center">
+                                        <?lsmb INCLUDE input element_data = {
+                                            name="memo_" _ pd.id,
+                                            size=11,
+                                            type="textarea",
+                                            value=pd.memo
+                                        }?>
+                                    </td>
+                    
+                                    <td align="center">
+                                        <?lsmb INCLUDE input element_data = {
+                                            name = 'paid_' _ pd.id,
+                                            size=11,
+                                            value= pd.amount,
+                                            type=textarea
+                                        }?>
+                                    </td>
+                    
+                                    <td align="center" <?lsmb #Exchange rate?> >
+                        
+                                        <?lsmb IF pd.forex?>
+                            
+                                            <?lsmb INCLUDE select element_data = {
+                                                name="forex_" _ pd.id,
+                                                type="hidden",
+                                                value=pd.forex
+                                            }?>
+                            
+                                        <?lsmb ELSE?>
+                                            <?lsmb INCLUDE input element_data = {
+                                                type="textarea"
+                                                name="exchangerate_" _ pd.id,
+                                                size=10,
+                                                value=pd.exchangerate
+                                            }?>
+                                        <?lsmb END?>
+                        
+                                    </td>
+                                    <td align="center">
+                                        <?lsmb INCLUDE select element_data = {
+                                            name=pd.type _ '_paid_' _ pd.id,
+                                            default_values=[ pd.ARAP_paid ],
+                                            options=all_accounts_arap
+                                        }?>
+                                    </td>
+                    
+                                </tr>
+                            <?lsmb END?>
+                        </table>
+                    </td>
+                </tr>
+                <tr>
+                    <td><hr size="3" noshade="noshade"></td>
+                </tr>
+                </table>
+                
+                <?lsmb #End of form header.?>
+                
+                <?lsmb #Beginning of form footer.?>
+                
+                <?lsmb #Print options stuff?>
+                 <table width="100%">
+                     <tr>
+                         <td>
+                            <?lsmb INCLUDE select element_data = {
+                                name="formname",
+                                options=all_formnames,
+                                default_value=formname
+                            }?>
+                        </td>
+            
+                        <?lsmb IF all_languages?>
+                            <td>
+                            <?lsmb INCLUDE select element_data = {
+                                name = "language_code",
+                                options=all_languages,
+                                default_values=language_code
+                            }?>
+                            </td>
+                        <?lsmb END?>
+                        <td>
+                            <?lsmb INCLUDE select element_data = {
+                                name="format",
+                                options=all_formats,
+                                default_value=format
+                            }?>
+                        </td>
+                        <td>
+                            <?lsmb INCLUDE select element_data = {
+                                name="media",
+                                options=all_media,
+                                default_value=media
+                            }?>
+                        </td>
+                        <td align="right" width="90%">
+                            <?lsmb IF recurring?>
+                                <?lsmb text("Scheduled")?>
+                            <?lsmb END?>
+                
+                            <?lsmb IF printed_bool == 1?>
+                                <?lsmb text("Printed")?>
+                                <br/>
+                            <?lsmb END?>
+                        </td>
+                    </tr>
+                </table>
+    
+                <br/>
+    
+                <?lsmb # Buttons and things
+                       # Update and Print never get removed.
+                ?>
+                <?lsmb INCLUDE button element_data = {
+                    name="action",
+                    value="update",
+                    key='U',
+                    text=text("Update")
+                }?>
+    
+                <?lsmb INCLUDE button element_data = {
+                    name="action",
+                    value="print",
+                    key='P',
+                    text=text("Print")
+                }?>
+    
+                <?lsmb IF approved && batch_id ?>
+    
+                    <?lsmb INCLUDE button element_data = {
+                        name="action",
+                        value="approve",
+                        key='O',
+                        text=text("Post as Saved")
+                    }?>
+        
+                    <?lsmb IF user.has_role("draft_modify")?>
+            
+                        <?lsmb INCLUDE button element_data = {
+                            name="action",
+                            value="edit_and_approve",
+                            key='O',
+                            text=text("Post as Shown")
+                        }?>
+                    <?lsmb END?>
+        
+                <?lsmb ELSE?>
+    
+                    <?lsmb IF !(locked) || !(transdate && le(transdate, closedto))?>
+            
+                        <?lsmb IF user.separate_duties || batch_id?>
+            
+                            <?lsmb INCLUDE button element_data = {
+                                name="action",
+                                value="post",
+                                key='O',
+                                text=text("Save")
+                            }?>
+                        <?lsmb ELSE?>
+                            <?lsmb INCLUDE button element_data = {
+                                name="action",
+                                value="post",
+                                key='O',
+                                text=text("Post")
+                            }?>
+                        <?lsmb END?>
+            
+                        <?lsmb IF !settings.latex ?>
+                            <?lsmb INCLUDE button element_data = {
+                                name="action",
+                                value="print_and_post",
+                                key='R',
+                                text=text("Print and Post")
+                            }?>
+                        <?lsmb END?>
+        
+                    <?lsmb END?> <?lsmb # End of if !(transdate) etc?>
+                <?lsmb END?>
+    
+                <?lsmb INCLUDE button element_data = {
+                    name="action",
+                    value="schedule",
+                    key='H',
+                    text=text("Schedule")
+                }?>
+                <?lsmb IF (!id || !locked) && !(transdate && le(transdate, closedto)) ?>
+                    <?lsmb INCLUDE button element_data = {
+                        name="action",
+                        key='D',
+                        text=text("Delete"),
+                        value=>"delete"
+                    }?>
+                    <?lsmb INCLUDE button element_data = {
+                        name="action",
+                        value="save_info",
+                        key='I',
+                        text=text("Save Info"),
+                    }?>
+                <?lsmb END?>
+                <?lsmb INCLUDE button element_data = {
+                    name="action",
+                    value="save_template",
+                    key="T",
+                    text=text("Save Template")
+                }?>
+                
+        </form>
+    </body>
+</html>
\ No newline at end of file

Added: addons/1.3/extended_arap/trunk/bin/custom/._aa.pl
===================================================================
(Binary files differ)


Property changes on: addons/1.3/extended_arap/trunk/bin/custom/._aa.pl
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: addons/1.3/extended_arap/trunk/bin/custom/aa.pl
===================================================================
--- addons/1.3/extended_arap/trunk/bin/custom/aa.pl	                        (rev 0)
+++ addons/1.3/extended_arap/trunk/bin/custom/aa.pl	2010-08-23 05:40:52 UTC (rev 3056)
@@ -0,0 +1,393 @@
+#!/usr/local/bin/perl
+#
+
+use LedgerSMB::Template;
+use Data::Dumper;
+
+sub display_form {
+    $form->close_form;
+    $form->open_form;
+    $form->{dbh}->commit;
+    
+    if (!$form->{__create_ran}) {
+        &create_links
+    }
+    
+    # The form header and footer stuff are removed due to lack of necessity.
+    
+    $form->{stylesheet} = $myconfig{stylesheet};
+    my $template = new LedgerSMB::Template(
+        user => \%myconfig,
+        locale => $locale,
+        path => 'UI',
+        template => 'aa',
+	    format => 'HTML',
+    );
+    print $template->render($form);
+    return;
+}
+
+sub create_links {
+    $form->{__create_ran} = 1;
+
+    if ( $form->{script} eq 'ap.pl' ) {
+        $form->{ARAP} = 'AP';
+        $form->{vc}   = 'vendor';	
+    }
+    elsif ( $form->{script} eq 'ar.pl' ) {
+        $form->{ARAP} = 'AR';
+        $form->{vc}   = 'customer';
+    }
+
+    $form->create_links( $form->{ARAP}, \%myconfig, $form->{vc} );
+
+    $duedate     = $form->{duedate};
+    $taxincluded = $form->{taxincluded};
+
+    $form->{formname} = "transaction";
+    $form->{format}   = "postscript" if $myconfig{printer};
+    $form->{media}    = $myconfig{printer};
+    $form->{all_formnames} = [{value => 'transaction', 
+                                text => $locale->text('Transaction')}];
+
+    if ( ${LedgerSMB::Sysconfig::latex} ) {
+        if ( $form->{ARAP} eq 'AR' ) {
+            push @{$form->{all_formnames}}, {value => "receipt",
+                                            text => $locale->text('Receipt')}; 
+        }
+        else {
+            push @{$form->{all_formnames}}, {value => "check",
+                                            text => $locale->text('Check')}; 
+        }
+    }
+
+    # currencies
+    $form->{all_currencies} = [];
+    for my $curr ( split /:/, $form->{currencies} ) {
+        push @{$form->{all_currencies}}, {text=>$curr, value=>$curr};
+    }
+    
+    $form->{defaultcurrency} = ${$form->{all_currrencies}}[0]->{text};
+    chomp $form->{defaultcurrency};
+    
+    # Departments
+    
+    @{$form->{all_department}} = map +{ 
+        text=> $_->{description}, 
+        value=>"$_->{description}--$_->{id}" 
+    }, @{$form->{all_department}};
+    
+    AA->get_name( \%myconfig, \%$form );
+    
+    $form->{currency} =~ s/ //g;
+    $form->{duedate}     = $duedate     if $duedate;
+    $form->{taxincluded} = $taxincluded if $form->{id};
+
+    #$form->{notes} = $form->{intnotes} if !$form->{id};
+
+    # needs to be changed to be multi-run safe.  Probably add a split? --CT
+    $form->{"old$form->{vc}"} =
+      qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
+    $form->{oldtransdate} = $form->{transdate};
+    
+    
+    # Needs to be changed to be multi-run safe. --CT
+    $form->{employee} = "$form->{employee}--$form->{employee_id}";
+
+    foreach $key ( keys %{ $form->{"$form->{ARAP}_links"} } ) {
+        # $key is the account_links description.  AR, AP, AR_paid, etc.
+        $form->{"all_accounts_$key"} = $form->{"$form->{ARAP}_links"}{$key};
+    }
+    
+    $form->{all_accounts_arap} = [];
+    for my $i (@{ $form->{"all_accounts_$form->{ARAP}"} }) {
+        # print STDERR Dumper ( $i );
+        push @{ $form->{all_accounts_arap} }, {
+            text=>$i->{accno}."--".$i->{description},
+            value=>$i->{accno}
+        };
+    }
+    
+    $form->{all_accounts_arap_value} = $form->{$form->{ARAP}};
+    
+    $form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
+    
+        # There's at least the one;
+        # So, we loop through this and turn it into a useful array instead of 
+        # paid_foo, allowing for easier manipulation in the template.
+        
+        $form->{paid_arr} = []; # arrayref
+        
+    for $i (1 .. $form->{paidaccounts}) {
+        
+        my $hr = {};
+        $hr->{id} = $i;
+        # This was paid_$i
+        $hr->{datepaid} = $form->{"datepaid_$i"};
+        $hr->{source} = $form->{"source_$i"};
+        $hr->{memo} = $form->{"memo_$i"};
+        $hr->{amount} = $form->format_amount( \%myconfig, $form->{"paid_$i"}, 2 );
+        $hr->{exchangerate} = $form->format_amount( \%myconfig, $form->{"exchangerate_$i"} );
+        $hr->{ARAP_paid} = $form->{"$form->{ARAP}_paid_$i"};
+        $hr->{type} = $form->{ARAP};
+        $hr->{forex} = $form->{"forex_$i"};
+        $hr->{cleared} = $form->{"cleared_$i"};
+        push (@{$form->{paid_arr}}, $hr);
+    }
+    
+    
+    # The rowcount amount accounts.
+    
+    $form->{all_amount_accounts} = [];
+    for my $i ( @{ $form->{"all_accounts_$form->{ARAP}_amount"} } ) {
+        
+        my $hr = {
+            text=>$i->{accno}."--".$i->{description}
+        };
+        
+        push @{$form->{all_amount_accounts}}, $hr;
+    }
+    
+    # The rowcount stuff.
+    
+    # Handle the for rowcount loop; Verify all the items are in a useful array
+    # shape for the template.
+    
+    $form->{amounts} = [];
+    $form->{descriptions} = [];
+    $form->{taxchecked} = [];
+    $form->{project_default} = [];
+    $form->{entry_id} = [];
+    $form->{summary} = [];
+    
+    if (!$form->{rowcount}) {
+        $form->{rowcount} = 1;
+    }
+    else {
+        $form->{rowcount}++;
+    }
+    
+    # if ($form->{rowcount}) {
+    #     for my $i (1 .. $form->{rowcount}) {
+    #         push @{$form->{amounts}}, $form->format_amount( \%myconfig, $form->{"amount_$i"}, 2 );
+    #         push @{$form->{descriptions}}, $form->{"description_$i"};
+    #         push @{$form->{taxchecked}}, $form->{"taxchecked_$i"};
+    #         push @{$form->{project_default}}, $form->{"project_default_$i"};
+    #         push @{$form->{entry_id}}, $form->{"entry_id_$i"};
+    #         push @{$form->{summary}}, $form->{"$form->{ARAP}_amount_$i"};
+    #     }
+    # }
+    
+    $form->{rowcount_arr} = [];
+    for my $i ( 1 .. $form->{rowcount}) {
+        my $hr = {};
+        print STDERR "Amount $i: ".$form->{"amount_$i"};
+        if ($form->{taxincluded}) {
+            $diff = 0;
+            if ($netamount) {
+                my $amount = $form->{"amount_$i"} * ( 1 + $tax / $netamount );
+                $hr->{amount} = $form->round_amount( $amount, 2 )->bstr();
+            }
+        }
+        else {
+            $hr->{amount} = $form->round_amount($form->{"amount_$i"}, 2)->bstr();
+        }
+        
+        if ($hr->{amount} eq "0") {
+            $hr->{amount} = "";
+        }
+        
+        $hr->{id} = $i;
+        $hr->{account} = $form->{"account_$i"};
+        $hr->{description} = $form->{"description_$i"};
+        $hr->{taxformcheck} = $form->{"taxformcheck_$i"};
+        $hr->{projectnumber} = $form->{"projectnumber_$i"};
+        $hr->{summary} = $form->{"$form->{ARAP}_amount_$i"};
+        $hr->{entry_id} = $form->{"entry_id_$i"};
+        $hr->{desc_rows} = $form->numtextrows($form->{"description_$i"}, 40);
+        push @{$form->{rowcount_arr}}, $hr;
+    }
+    my $n_rows = $form->numtextrows( $form->{notes}, 50 );
+    if ( ( $n_rows  - 1 ) < 2 ) {
+        $n_rows = 2;
+    }
+    $form->{note_rows} = $n_rows;
+    
+    # if ( $form->{taxincluded} ) {
+    #     $diff = 0;
+    # 
+    #     # add tax to individual amounts
+    #     # XXX needs alteration for conditional taxes
+    #     for $i ( 1 .. $form->{rowcount} ) {
+    #         if ($netamount) {
+    #             $amount = 
+    #             $form->{"amount_$i"} = 
+    #         }
+    #     }
+    # }
+
+    $form->{invtotal} = $netamount + $tax;
+
+    # check if calculated is equal to stored
+    # taxincluded is terrible to calculate
+    # this works only if all taxes are checked
+    @taxaccounts = Tax::init_taxes( $form, $form->{taxaccounts} );
+
+
+    if ( $form->{id} ) {
+        if ( $form->{taxincluded} ) {
+
+            $amount =
+              Tax::calculate_taxes( ..hidden.., $form, $form->{invtotal},
+                1 );
+            $tax = $form->round_amount( $amount, 2 );
+
+        }
+        else {
+            $tax =
+              $form->round_amount(
+                Tax::calculate_taxes( ..hidden.., $form, $netamount, 0 ) );
+        }
+        foreach $item (@taxaccounts) {
+            $tax{ $item->account } = $form->round_amount( $item->value, 2 );
+            $form->{ "calctax_" . $item->account } = 1
+              if $item->value
+              and
+              ( $tax{ $item->account } == $form->{ "tax_" . $item->account } );
+        }
+    }
+    else {
+        for (@taxaccounts) { $form->{ "calctax_" . $_->account } = 1 }
+    }
+    
+    
+    $form->{summary_accounts} = $form->{"all_accounts_$form->{ARAP}"};
+    
+
+    $form->{ $form->{ARAP} } = $form->{"$form->{ARAP}_1"};
+
+    $form->{locked} =
+      ( $form->{revtrans} )
+      ? '1'
+      : ( $form->datetonum( \%myconfig, $form->{transdate} ) <=
+          $form->datetonum( \%myconfig, $form->{closedto} ) );
+
+    # readonly
+    if ( !$form->{readonly} ) {
+        $form->{readonly} = 1
+          if $myconfig{acs} =~ /$form->{ARAP}--Add Transaction/;
+    }
+    # permits us to use numtextrows in the template.
+    $form->{numtextrows} = sub {$form->numtextrows(@_)};
+    
+    
+    if ($form->{all_employee}) {
+        $form->{all_employees} = [];
+        for my $employee (@{$form->{all_employee}}) {
+            push @{$form->{all_employees}}, 
+                { 
+                    text=>$employee->{name},
+                    value=>"$employee->{name}--$employee->{id}"  
+                };
+        }
+    }
+    
+    $form->{all_vc_names} = [];
+    for my $i (@{$form->{"all_$form->{vc}"}}) {
+        # Turn this into a list of usable options for the template controller,
+        # per aa.pl:204. --AS
+        push @{$form->{all_vc_names}}, {
+            text=>"$i->{name}--$i->{id}",
+            value=>$i->{name}
+        };
+    }
+    
+    $form->{all_vc_value} = $form->{ $form->{vc} }; # Use to avoid messy hash lookups in the template.
+    
+    if ( $form->{printed} =~ /$form->{formname}/ ) {
+        $form->{printed_bool} = 1;
+    }
+    else {
+        $form->{printed_bool} = 0;
+    }
+    
+    #print "Headerbreaker.";
+    
+    
+    $form->{le} = sub {
+        my ($l, $r) = @_;
+        if ($l <= $r) {
+            return 1;
+        }
+        return 0;
+    };
+    
+    # The footer drop-boxes.
+    
+    $form->{all_form_names} = [];
+    
+    push @{ $form->{all_form_names} }, { value=>"transaction", text=> $locale->text('Transaction') };
+
+    if ( ${LedgerSMB::Sysconfig::latex} ) {
+        if ( $form->{ARAP} eq 'AR' ) {
+            push @{ $form->{all_form_names} }, { value=>"receipt", text=> $locale->text('Receipt') };
+        }
+        else {
+            push @{ $form->{all_form_names} }, { value=>"check", text=> $locale->text('Check') };
+        }
+    }
+    # the Media keys
+    $form->{all_media} = [];
+    push @{ $form->{all_media} }, {text=>$locale->text("Screen"), value=>"screen"};
+    
+    if ( %{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex} ) {
+        for my $printer ( sort keys %{LedgerSMB::Sysconfig::printer} ) {
+            push @{ $form->{all_media} }, { text=>$printer, value=>$printer };
+        }
+    }
+    
+    # the format
+    
+    $form->{all_formats} = [];
+    
+    push @{ $form->{all_formats} }, {text=>"HTML", value=>"html"};
+    
+    if ( ${LedgerSMB::Sysconfig::latex} ) {
+        push @{ $form->{all_formats} }, {text=>$locale->text("Postscript"), value=>"postscript"};
+        push @{ $form->{all_formats} }, {text=>$locale->text("PDF"), value=>"pdf"};
+        push @{ $form->{all_media} }, {text=>$locale->text("Queue"), value=>"queue"};
+    }
+    
+    if (@{ $form->{all_language} }) {
+        $form->{all_languages}= [];
+        for my $lang ( @{ $form->{all_language} } ) {
+            push @{$form->{all_languages}}, {text=>$lang->{description}, value=>$lang->{code}}
+        };
+    }
+    
+    
+    # This allows for the hidden variables to be declared and emitted as expected.
+    
+    $form->{hidden_args} = [];
+    $form->{hidden_vars} = {};
+    for my $var ( qw(batch_id approved id printed emailed sort closedto locked 
+       oldtransdate audittrail recurring checktax reverse batch_id subtype
+       entity_control_code meta_number terms creditlimit creditremaining 
+       defaultcurrency rowcount callback path login sessionid form_id) ) {
+        push @{ $form->{hidden_args} }, $var;
+        $form->{hidden_vars}->{$var} = $form->{$var};
+    }
+    
+    # Add the vc items, too. aa.pl:586.
+    
+    push @{$form->{hidden_args}}, "old$form->{vc}";
+    $form->{hidden_vars}->{"old$form->{vc}"} = $form->{"old$form->{vc}"};
+    push @{$form->{hidden_args}}, "$form->{vc}_id";
+    $form->{hidden_vars}->{"$form->{vc}_id"} = $form->{"$form->{vc}_id"};
+    
+    #print STDERR Dumper($form);
+    
+    $form->{arap_amount_name} = $form->{ARAP}."_amount";
+    print STDERR $form->{arap_amount_name};
+
+}
\ No newline at end of file


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.