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

SF.net SVN: ledger-smb:[2790] addons/1.3/templatetrans/trunk



Revision: 2790
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2790&view=rev
Author:   einhverfr
Date:     2009-11-10 19:38:10 +0000 (Tue, 10 Nov 2009)

Log Message:
-----------
Fixes for memorized transactions in place

Modified Paths:
--------------
    addons/1.3/templatetrans/trunk/LedgerSMB/DBObject/TransTemplate.pm
    addons/1.3/templatetrans/trunk/patches/aa_gl.patch
    addons/1.3/templatetrans/trunk/scripts/transtemplate.pl

Modified: addons/1.3/templatetrans/trunk/LedgerSMB/DBObject/TransTemplate.pm
===================================================================
--- addons/1.3/templatetrans/trunk/LedgerSMB/DBObject/TransTemplate.pm	2009-11-10 19:36:16 UTC (rev 2789)
+++ addons/1.3/templatetrans/trunk/LedgerSMB/DBObject/TransTemplate.pm	2009-11-10 19:38:10 UTC (rev 2790)
@@ -46,4 +46,28 @@
    ($self->{inv_data}) = $self->exec_method(funcname => 'journal__retrieve_invoice');
 }
 
+sub get {
+    my ($self) = @_;
+    my ($ref) = $self->exec_method(funcname => 'journal__get_entry');
+    $self->merge($ref);
+    @{$self->{line_items}} =  $self->exec_method(funcname => 'journal__lines');
+    ($self->{invoice_data}) =
+                 $self->exec_method(funcname => 'journal__get_invoice');
+    if ($self->{invoice_data}->{credit_id}){
+        ($self->{credit_data}) = $self->call_procedure(
+               procname => 'entity_credit__get',
+               args     => [$self->{invoice_data}->{credit_id}]
+        );
+    }
+}
+
+sub get_account_info {
+    my ($self, $acct_id) = @_;
+    my ($ref) = $self->call_procedure(
+               procname => 'account_get', 
+               args     => [$acct_id]
+    );
+    return $ref;
+}
+
 1;

Modified: addons/1.3/templatetrans/trunk/patches/aa_gl.patch
===================================================================
--- addons/1.3/templatetrans/trunk/patches/aa_gl.patch	2009-11-10 19:36:16 UTC (rev 2789)
+++ addons/1.3/templatetrans/trunk/patches/aa_gl.patch	2009-11-10 19:38:10 UTC (rev 2790)
@@ -1,6 +1,6 @@
 Index: bin/aa.pl
 ===================================================================
---- bin/aa.pl	(revision 2777)
+--- bin/aa.pl	(revision 2784)
 +++ bin/aa.pl	(working copy)
 @@ -959,6 +959,8 @@
  
@@ -11,7 +11,7 @@
          );
          if (!$form->{approved} && !$form->{batch_id}){
             $button{approve} = { 
-@@ -1028,6 +1030,42 @@
+@@ -1028,6 +1030,41 @@
  |;
  }
  
@@ -34,11 +34,10 @@
 +    }
 +    $lsmb->{transaction_date} = $form->{transdate}; 
 +    for my $iter (0 .. $form->{rowcount}){
-+        if ($form->{"accno_$iter"} and 
++        if ($form->{"AP_amount_$iter"} and 
 +                  ($form->{"amount_$iter"} != 0)){
-+             my ($acc_id, $acc_name) = split /--/, $form->{"accno_$iter"};
-+             my $amount = $form->{"credit_$iter"} || ( $form->{"debit_$iter"} 
-+                                                     * -1 );
++             my ($acc_id, $acc_name) = split /--/, $form->{"AP_amount_$iter"};
++             my $amount = $form->{"amount_$iter"};
 +             push @{$lsmb->{journal_lines}}, 
 +                  {accno => $acc_id,
 +                   amount => $amount, 
@@ -56,9 +55,9 @@
      use LedgerSMB;
 Index: bin/gl.pl
 ===================================================================
---- bin/gl.pl	(revision 2777)
+--- bin/gl.pl	(revision 2788)
 +++ bin/gl.pl	(working copy)
-@@ -241,6 +241,10 @@
+@@ -246,6 +246,10 @@
  		  'update' =>
  		    { ndx => 1, key => 'U', value => $locale->text('Update') },
  		  'post' => { ndx => 3, key => 'O', value => $locale->text('Post') },
@@ -69,7 +68,7 @@
  		  'post_as_new' =>
  		    { ndx => 6, key => 'N', value => $locale->text('Post as new') },
  		  'schedule' =>
-@@ -254,6 +258,7 @@
+@@ -259,6 +263,7 @@
  		  $button{post}->{value} = $locale->text('Save'); 
  	      }
  	      %a = ();
@@ -77,7 +76,7 @@
  	      if ( $form->{id} ) {
  
  		  for ( 'update', 'post_as_new', 'schedule' ) { $a{$_} = 1 }
-@@ -334,7 +339,37 @@
+@@ -339,7 +344,37 @@
  }
   
  

Modified: addons/1.3/templatetrans/trunk/scripts/transtemplate.pl
===================================================================
--- addons/1.3/templatetrans/trunk/scripts/transtemplate.pl	2009-11-10 19:36:16 UTC (rev 2789)
+++ addons/1.3/templatetrans/trunk/scripts/transtemplate.pl	2009-11-10 19:38:10 UTC (rev 2790)
@@ -9,24 +9,29 @@
     use LedgerSMB::Form;
     our $template_dispatch = 
     {
-        ap         => {script => 'bin/ap.pl', function => sub {edit()}},
-        ar         => {script => 'bin/ar.pl', function => sub {edit()}},
-        gl         => {script => 'bin/gl.pl', function => sub {edit()}},
+        ap         => {script => 'bin/ap.pl', function => sub {update()}},
+        ar         => {script => 'bin/ar.pl', function => sub {update()}},
+        gl         => {script => 'bin/gl.pl', function => sub {update()}},
     };
 
     our $form = new Form;
     $form->{dbh} = $request->{dbh};
     our $locale = $request->{_locale};
-    our %myconfig = %{$request->{_user}};
     our %myconfig = ();
     %myconfig = %{$request->{_user}};
+    $form->{stylesheet} = $myconfig{stylesheet};
     our $locale = $request->{_locale};
+    my $transtemplate = LedgerSMB::DBObject::TransTemplate->new(base => $request);
+    $transtemplate->get;
     my $script = $template_dispatch->{$request->{entry_type}}->{script};
+    $form->{script} = $script;
+    $form->{script} =~ s/(bin|scripts)\///;
     if ($script =~ /^bin/){
 	# I hate this old code!
         {
              no strict; 
              no warnings 'redefine'; 
+             convert_to_form($transtemplate, $form, $request->{entry_type});
              do $script; 
         }
 
@@ -39,6 +44,37 @@
 
 }
 
+sub convert_to_form{
+    my ($trans, $form, $type) = @_;
+    if ($type eq 'gl'){
+        $form->{reference} = $trans->{reference};
+        $form->{description} = $trans->{description};
+        $form->{rowcount} = 0;
+        for $row (@{$trans->{line_items}}){
+            if ($row->{amount} < 0){
+                $form->{"debit_$form->{rowcount}"} = $row->{amount} * -1;
+            } else {
+                $form->{"credit_$form->{rowcount}"} = $row->{amount};
+            }
+            my $act = $trans->get_account_info($row->{account_id});
+            $form->{"accno_$form->{rowcount}"} = 
+                       "$act->{accno}--$act->{description}";
+            ++$form->{rowcount};
+        }
+    } else { #ar or ap
+        my $meta_number = $trans->{credit_data}->{meta_number};
+        if ($type eq 'ar'){
+            $form->{customer} = $meta_number;
+        } else {
+            $form->{vendor} = $meta_number; 
+        }
+        $form->{rowcount} = 1;
+        for $row (@{$trans->{line_items}}){
+            $form->{"amount_$form->{rowcount}"} = $row->{amount};
+        }
+    }
+}
+   
 sub search {
     my ($request) = @_;
     my $template = LedgerSMB::Template->new(


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