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

SF.net SVN: ledger-smb:[2796] trunk



Revision: 2796
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2796&view=rev
Author:   einhverfr
Date:     2009-11-12 23:27:56 +0000 (Thu, 12 Nov 2009)

Log Message:
-----------
Fixes to project transaction/tb reports

Modified Paths:
--------------
    trunk/LedgerSMB/GL.pm
    trunk/bin/aa.pl
    trunk/bin/gl.pl
    trunk/bin/rp.pl

Modified: trunk/LedgerSMB/GL.pm
===================================================================
--- trunk/LedgerSMB/GL.pm	2009-11-12 19:53:49 UTC (rev 2795)
+++ trunk/LedgerSMB/GL.pm	2009-11-12 23:27:56 UTC (rev 2796)
@@ -262,6 +262,12 @@
         $apwhere .= " AND a.department_id = $var";
     }
 
+    if ( $form->{project_id} ne "") {
+        $var = $dbh->quote($form->{project_id});
+        $glwhere .= " AND ac.project_id = $var";
+        $arwhere .= " AND ac.project_id = $var";
+        $apwhere .= " AND ac.project_id = $var";
+    }
     if ( $form->{source} ne "" ) {
         $var = $dbh->quote( $form->like( lc $form->{source} ) );
         $glwhere .= " AND lower(ac.source) LIKE $var";

Modified: trunk/bin/aa.pl
===================================================================
--- trunk/bin/aa.pl	2009-11-12 19:53:49 UTC (rev 2795)
+++ trunk/bin/aa.pl	2009-11-12 23:27:56 UTC (rev 2796)
@@ -959,6 +959,8 @@
 
             'save_info' => 
               { ndx => 9, key => 'I', value => $locale->text('Save Info') },
+            'save_temp' =>
+              { ndx => 10, key => 'T', value => $locale->text('Save Template')},
         );
         if (!$form->{approved} && !$form->{batch_id}){
            $button{approve} = { 
@@ -1028,6 +1030,41 @@
 |;
 }
 
+sub save_temp {
+    use LedgerSMB;
+    use LedgerSMB::DBObject::TransTemplate;
+    my $lsmb = LedgerSMB->new();
+    $lsmb->merge($form);
+    $lsmb->{is_invoice} = 1;
+    my ($department_name, $department_id) = split/--/, $form->{department};
+     if (!$lsmb->{language_code}){
+        delete $lsmb->{language_code};
+    }
+    $lsmb->{credit_id} = $form->{"$form->{vc}_id"};
+    $lsmb->{department_id} = $department_id;
+    if ($form->{arap} eq 'ar'){
+        $lsmb->{entity_class} = 2;
+    } else {
+        $lsmb->{entity_class} = 1;
+    }
+    $lsmb->{transaction_date} = $form->{transdate}; 
+    for my $iter (0 .. $form->{rowcount}){
+        if ($form->{"AP_amount_$iter"} and 
+                  ($form->{"amount_$iter"} != 0)){
+             my ($acc_id, $acc_name) = split /--/, $form->{"AP_amount_$iter"};
+             my $amount = $form->{"amount_$iter"};
+             push @{$lsmb->{journal_lines}}, 
+                  {accno => $acc_id,
+                   amount => $amount, 
+                   cleared => false,
+                  };
+        }
+    }
+    $template = LedgerSMB::DBObject::TransTemplate->new(base => $lsmb);
+    $template->save;
+    $form->redirect( $locale->text('Template Saved!') );
+}
+
 sub edit_and_approve {
     use LedgerSMB::DBObject::Draft;
     use LedgerSMB;

Modified: trunk/bin/gl.pl
===================================================================
--- trunk/bin/gl.pl	2009-11-12 19:53:49 UTC (rev 2795)
+++ trunk/bin/gl.pl	2009-11-12 23:27:56 UTC (rev 2796)
@@ -246,6 +246,10 @@
 		  'update' =>
 		    { ndx => 1, key => 'U', value => $locale->text('Update') },
 		  'post' => { ndx => 3, key => 'O', value => $locale->text('Post') },
+                  'save_temp' =>
+                    { ndx   => 9, 
+                      key   => 'T', 
+                      value => $locale->text('Save Template') },
 		  'post_as_new' =>
 		    { ndx => 6, key => 'N', value => $locale->text('Post as new') },
 		  'schedule' =>
@@ -259,6 +263,7 @@
 		  $button{post}->{value} = $locale->text('Save'); 
 	      }
 	      %a = ();
+              $a{save_temp} = 1;
 	      if ( $form->{id} ) {
 
 		  for ( 'update', 'post_as_new', 'schedule' ) { $a{$_} = 1 }
@@ -340,7 +345,37 @@
 }
  
 
+sub save_temp {
+    use LedgerSMB;
+    use LedgerSMB::DBObject::TransTemplate;
+    my $lsmb = LedgerSMB->new();
+    my ($department_name, $department_id) = split/--/, $form->{department};
+    $lsmb->{department_id} = $department_id;
+    $lsmb->{source} = $form->{reference};
+    $lsmb->{description} = $form->{description};
+    $lsmb->{department_id} = $department_id;
+    $lsmb->{transaction_date} = $form->{transdate};
+    $lsmb->{type} = 'gl';
+    $lsmb->{journal_lines} = [];
+    for my $iter (0 .. $form->{rowcount}){
+        if ($form->{"accno_$iter"} and 
+                  (($form->{"credit_$iter"} != 0) or ($form->{"debit_$iter"} != 0))){
+             my ($acc_id, $acc_name) = split /--/, $form->{"accno_$iter"};
+             my $amount = $form->{"credit_$iter"} || ( $form->{"debit_$iter"} 
+                                                     * -1 );
+             push @{$lsmb->{journal_lines}}, 
+                  {accno => $acc_id,
+                   amount => $amount, 
+                   cleared => false,
+                  };
+        }
+    }
+    $template = LedgerSMB::DBObject::TransTemplate->new(base => $lsmb);
+    $template->save;
+    $form->redirect( $locale->text('Template Saved!') );
+}
 
+
 sub display_row
 {
  

Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl	2009-11-12 19:53:49 UTC (rev 2795)
+++ trunk/bin/rp.pl	2009-11-12 23:27:56 UTC (rev 2796)
@@ -677,7 +677,7 @@
         $department = $form->escape( $form->{department} );
     }
     if ( $form->{projectnumber} ) {
-        ($projectnumber) = split /--/, $form->{projectnumber};
+        ($projectnumber, $project_id) = split /--/, $form->{projectnumber};
         push @options, $locale->text('Project Number: [_1]', $projectnumber);
         $projectnumber = $form->escape( $form->{projectnumber} );
     }
@@ -724,7 +724,7 @@
 	# gl.pl requires datefrom instead of fromdate, etc.  We will get this
 	# consistent.... eventually....  --CT
         my $href =
-qq|gl.pl?path=$form->{path}&action=generate_report&accounttype=$form->{accounttype}&datefrom=$form->{fromdate}&dateto=$form->{todate}&sort=transdate&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&l_balance=Y&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title&nextsub=$form->{nextsub}&prevreport=$form->{callback}&category=X&l_reference=Y&l_transdate=Y&l_description=Y&l_debit=Y&l_credit=Y|;
+qq|gl.pl?path=$form->{path}&action=generate_report&accounttype=$form->{accounttype}&datefrom=$form->{fromdate}&dateto=$form->{todate}&sort=transdate&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&l_balance=Y&department=$department&projectnumber=$projectnumber&project_id=$project_id&title=$title&nextsub=$form->{nextsub}&prevreport=$form->{callback}&category=X&l_reference=Y&l_transdate=Y&l_description=Y&l_debit=Y&l_credit=Y|;
 
         if ( $form->{accounttype} eq 'gifi' ) {
             $href .= "&gifi_accno=$ref->{accno}&gifi_description=$description";


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