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

SF.net SVN: ledger-smb:[3101] addons/1.3/extended_arap/trunk



Revision: 3101
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3101&view=rev
Author:   aurynn_cmd
Date:     2010-10-18 23:40:49 +0000 (Mon, 18 Oct 2010)

Log Message:
-----------
Updating the ARAP AJAX page. This should now work correctly when loading lines from the database.

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

Modified: addons/1.3/extended_arap/trunk/UI/aa.html
===================================================================
--- addons/1.3/extended_arap/trunk/UI/aa.html	2010-10-18 21:51:49 UTC (rev 3100)
+++ addons/1.3/extended_arap/trunk/UI/aa.html	2010-10-18 23:40:49 UTC (rev 3101)
@@ -309,7 +309,7 @@
                                             <td>
                                                 <?lsmb PROCESS ajaxselect element_data = {
                                                        name = ARAP _ "_amount" _ row.id,
-                                                       initial_value = ${"accno_$INDEX"},
+                                                       initial_value = row.account,
                                                        ajax_target = 'journal.pl',
                                                        params = { 'link_desc' = arap_amount_name }
                                                        } ?>
@@ -346,7 +346,7 @@
 
                                                     name="projectnumber_" _ row.id,
                                                     options=project_numbers,
-                                                    default_values=[row.project_default]
+                                                    default_values=[row.projectnumber]
                                                 }?>
                                             </td>
                                             <?lsmb END?>
@@ -415,7 +415,7 @@
                                             class="date",
                                             name="datepaid_" _ pd.id,
                                             size=11,
-                                            value= pd.datepaid,
+                                            value= pd.transdate,
                                             type="textarea"
                                         }?>
                                     </td>
@@ -462,7 +462,7 @@
                                                 type="textarea"
                                                 name="exchangerate_" _ pd.id,
                                                 size=10,
-                                                value=pd.exchangerate
+                                                value=pd.exchangerate.bstr
                                             }?>
                                         <?lsmb END?>
                         

Modified: addons/1.3/extended_arap/trunk/bin/custom/aa.pl
===================================================================
--- addons/1.3/extended_arap/trunk/bin/custom/aa.pl	2010-10-18 21:51:49 UTC (rev 3100)
+++ addons/1.3/extended_arap/trunk/bin/custom/aa.pl	2010-10-18 23:40:49 UTC (rev 3101)
@@ -3,6 +3,7 @@
 
 use LedgerSMB::Template;
 use Data::Dumper;
+use LedgerSMB::AA;
 
 sub display_form {
     $form->close_form;
@@ -27,6 +28,8 @@
     return;
 }
 
+
+
 sub create_links {
     $form->{__create_ran} = 1;
 
@@ -163,7 +166,7 @@
     if (!$form->{rowcount}) {
         $form->{rowcount} = 1;
     }
-    else {
+    elsif ($form->{rowcount} > 1) {
         $form->{rowcount}++;
     }
     
@@ -179,6 +182,58 @@
     # }
     
     $form->{rowcount_arr} = [];
+    # This only really works for new transaction stuff.
+    # It does NOT work for an existing view.
+    # print STDERR Dumper($form->{acc_trans});
+    my $max_acc_trans;
+    
+    if ($form->{id} ) {
+        
+        if (scalar @{ $form->{acc_trans}->{ $form->{ARAP} . "_amount" } } > 1) {
+            $form->{rowcount} += scalar @{ $form->{acc_trans} -> {  $form->{ARAP} . "_amount"  }};
+        }
+        # We have an id value.
+        # This means we *are probably* be an edit.
+        
+        for $max_acc_trans (0 .. scalar @{ $form->{acc_trans}->{ $form->{ARAP} . "_amount" } }) {
+            my $line = $form->{acc_trans}->{ $form->{ARAP} . "_amount" }->[$max_acc_trans];
+            
+            if ($form->{taxincluded}) {
+                $diff = 0;
+                if ($netamount) {
+                    my $amount = $line->{amount} * ( 1 + $tax / $netamount );
+                    $line->{amount} = $form->round_amount( $amount, 2 )->bstr();
+                }
+            }
+            else {
+                $line->{amount} = $form->round_amount( $line->{amount}, 2 )->bstr();
+            }
+            # c.accno, 
+            # c.description, 
+            # a.source, 
+            # a.amount,
+            # a.memo,
+            # a.entry_id, 
+            # a.transdate, 
+            # a.cleared, 
+            # a.project_id,
+            # p.projectnumber
+            if ($line->{amount} && $line->{accno}) {
+                push @{$form->{rowcount_arr}}, {
+                    description=> $line->{memo},
+                    desc_rows => $form->numtextrows($line->{memo}, 40),
+                    amount => $line->{amount},
+                    account => $line->{accno} . '--'. $line->{description},
+                    entry_id => $line->{entry_id},
+                    taxcheck => AA->get_taxcheck($form, $line->{entry_id}, $form->{dbh}),
+                    projectnumber => $line->{projectnumber}
+                }
+            }
+        }
+        
+        $form->{paid_arr} = $form->{acc_trans} -> { $form->{ARAP} . "_paid" }; 
+    }
+    
     for my $i ( 1 .. $form->{rowcount}) {
         my $hr = {};
         print STDERR "Amount $i: ".$form->{"amount_$i"};
@@ -257,7 +312,7 @@
         }
     }
     else {
-        for (@taxaccounts) { $form->{ "calctax_" . $_->account } = 1 }
+        for (@taxaccounts) { $form->{ "calctax_" . $_->account } = 1 };
     }
     
     
@@ -287,7 +342,7 @@
             push @{$form->{all_employees}}, 
                 { 
                     text=>$employee->{name},
-                    value=>"$employee->{name}--$employee->{id}"  
+                    value=>"$employee->{name}--$employee->{id}",
                 };
         }
     }
@@ -388,6 +443,5 @@
     #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.