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

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



Revision: 1796
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1796&view=rev
Author:   einhverfr
Date:     2007-10-19 11:47:03 -0700 (Fri, 19 Oct 2007)

Log Message:
-----------
GL Vouchers are posting and saving correctly.  Need to get listing and approving but that is conceptually a lot easier and involves a lot less legacy code

Modified Paths:
--------------
    trunk/LedgerSMB/Batch.pm
    trunk/LedgerSMB/DBObject.pm
    trunk/LedgerSMB/Form.pm
    trunk/LedgerSMB/GL.pm
    trunk/LedgerSMB.pm
    trunk/UI/create_batch.html
    trunk/bin/aa.pl
    trunk/bin/gl.pl
    trunk/scripts/vouchers.pl
    trunk/sql/modules/Voucher.sql

Modified: trunk/LedgerSMB/Batch.pm
===================================================================
--- trunk/LedgerSMB/Batch.pm	2007-10-19 06:05:41 UTC (rev 1795)
+++ trunk/LedgerSMB/Batch.pm	2007-10-19 18:47:03 UTC (rev 1796)
@@ -6,7 +6,8 @@
 sub create {
     $self = shift @_;
     my ($ref) = $self->exec_method(funcname => 'batch_create');
-    $self->{id} = $ref->{id}
+    print STDERR "$ref, $ref->{batch_create}, " . join (':', keys %$ref);
+    $self->{id} = $ref->{batch_create};
     return $ref->{id};
 }
 

Modified: trunk/LedgerSMB/DBObject.pm
===================================================================
--- trunk/LedgerSMB/DBObject.pm	2007-10-19 06:05:41 UTC (rev 1795)
+++ trunk/LedgerSMB/DBObject.pm	2007-10-19 18:47:03 UTC (rev 1796)
@@ -128,13 +128,13 @@
     
     my $m_name = $ref->{proname};
 
-#    if ($args) {
-#        for my $arg (@proc_args) {
-#            if ( $arg =~ s/^in_// ) {
-                # push @call_args, $arg;
-#            }
-#        }
-#    }
+    if ($args) {
+        for my $arg (@proc_args) {
+            if ( $arg =~ s/^in_// ) {
+                 push @call_args, $self->{$arg};
+            }
+        }
+    }
 
     for (@in_args) { push @call_args, $_ } ;
     $self->{call_args} = ..hidden..;

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2007-10-19 06:05:41 UTC (rev 1795)
+++ trunk/LedgerSMB/Form.pm	2007-10-19 18:47:03 UTC (rev 1796)
@@ -2299,7 +2299,7 @@
         }
         $sth->finish;
     }
-    if (!$self->{id}){
+    if (!$self->{id} && !$self->{transdate}){
         $self->{transdate} = $self->{current_date};
     }
 

Modified: trunk/LedgerSMB/GL.pm
===================================================================
--- trunk/LedgerSMB/GL.pm	2007-10-19 06:05:41 UTC (rev 1795)
+++ trunk/LedgerSMB/GL.pm	2007-10-19 18:47:03 UTC (rev 1796)
@@ -130,22 +130,24 @@
 		WHERE id = ?|;
 
     if (defined $form->{approved}) {
-
-        $query = qq| UPDATE gl SET approved = ? WHERE id = ?|;
+        my $query = qq| UPDATE gl SET approved = ? WHERE id = ?|;
         $dbh->prepare($query)->execute($form->{approved}, $form->{id}) 
              || $form->dberror($query);
         if (!$form->{approved}){
            if (not defined $form->{batch_id}){
                $form->error($locale->text('Batch ID Missing'));
            }
-           $query = qq| 
-			INSERT INTO voucher (batch_id, trans_id) VALUES (?, ?)|;
-           $sth = $dbh->prepare($query);
-           $sth->execute($form->{batch_id}, $form->{id}) ||
+           my $query = qq| 
+			INSERT INTO voucher (batch_id, trans_id, batch_class) 
+			VALUES (?, ?, (select id FROM batch_class 
+			                        WHERE class = ?))|;
+           my $sth2 = $dbh->prepare($query);
+           $sth2->execute($form->{batch_id}, $form->{id}, 'gl') ||
                 $form->dberror($query);
        }
     }
     $sth = $dbh->prepare($query);
+    print STDERR $query;
     $sth->execute( $form->{transdate}, $department_id, $form->{id} )
       || $form->dberror($query);
 
@@ -570,7 +572,9 @@
         my $results = $sth->fetchall_hashref('setting_key');
         $form->{closedto}  = $results->{'closedto'}->{'value'};
         $form->{revtrans}  = $results->{'revtrans'}->{'value'};
-        $form->{transdate} = $results->{'revtrans'}->{'transdate'};
+        if (!$form->{transdate}){
+            $form->{transdate} = $results->{'revtrans'}->{'transdate'};
+        }
     }
 
     $sth->finish;

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2007-10-19 06:05:41 UTC (rev 1795)
+++ trunk/LedgerSMB.pm	2007-10-19 18:47:03 UTC (rev 1796)
@@ -535,7 +535,7 @@
     my @results;
 
     $procname = $self->{dbh}->quote_identifier($procname);
-
+    print STDERR join(':', @call_args) . "\n";
     for ( 1 .. scalar @call_args ) {
         $argstr .= "?, ";
     }

Modified: trunk/UI/create_batch.html
===================================================================
--- trunk/UI/create_batch.html	2007-10-19 06:05:41 UTC (rev 1795)
+++ trunk/UI/create_batch.html	2007-10-19 18:47:03 UTC (rev 1796)
@@ -21,7 +21,7 @@
     <?lsmb text("Batch Number") ?>
   </div>
   <div class="value">
-    <input name="batchnumber" type="text" value="<?lsmb batchnumber ?>"/>
+    <input name="batch_number" type="text" value="<?lsmb batch_number ?>"/>
   </div>
 <div class="labelledinput">
   <div class="label">

Modified: trunk/bin/aa.pl
===================================================================
--- trunk/bin/aa.pl	2007-10-19 06:05:41 UTC (rev 1795)
+++ trunk/bin/aa.pl	2007-10-19 18:47:03 UTC (rev 1796)
@@ -541,10 +541,12 @@
 <input type=hidden name=title value="$title">
 
 |;
-
+    if (!defined $form->{approved}){
+        $form->{approved} = 1;
+    }
     $form->hide_form(
-        qw(id printed emailed sort closedto locked oldtransdate audittrail 
-           recurring checktax reverse batch_id subtype)
+        qw(batch_id approved id printed emailed sort closedto locked 
+           oldtransdate audittrail recurring checktax reverse batch_id subtype)
     );
 
     if ( $form->{vc} eq 'customer' ) {

Modified: trunk/bin/gl.pl
===================================================================
--- trunk/bin/gl.pl	2007-10-19 06:05:41 UTC (rev 1795)
+++ trunk/bin/gl.pl	2007-10-19 18:47:03 UTC (rev 1796)
@@ -1103,6 +1103,9 @@
     else {
         $notes = qq|<input name=notes size=50 value="$form->{notes}">|;
     }
+    if (!defined $form->{approved}){
+        $form->{approved} = '1';
+    }
 
     $department = qq|
         <tr>
@@ -1131,10 +1134,11 @@
 <body onload="document.forms[0].${focus}.focus()" />
 
 <form method=post action=$form->{script}>
+         <input type="hidden" name="approved" value="$form->{approved}" />
 |;
 
     $form->hide_form(
-        qw(id transfer selectaccno closedto locked oldtransdate recurring));
+        qw(batch_id id transfer selectaccno closedto locked oldtransdate recurring));
 
     print qq|
 <input type=hidden name=title value="$title">

Modified: trunk/scripts/vouchers.pl
===================================================================
--- trunk/scripts/vouchers.pl	2007-10-19 06:05:41 UTC (rev 1795)
+++ trunk/scripts/vouchers.pl	2007-10-19 18:47:03 UTC (rev 1796)
@@ -37,6 +37,7 @@
     use LedgerSMB::Form;
 
     my $batch = LedgerSMB::Batch->new({base => $request});
+    $batch->{batch_class} = $request->{batch_type};
     $batch->create;
 
     my $vouchers_dispatch = 
@@ -49,29 +50,36 @@
     };
 
     # Note that the line below is generally considered incredibly bad form. 
-    # However, the code we are including is going to require it for now.
-    no strict;
+    # However, the code we are including is going to require it for now. -- CT
     our $form = new Form;
     our $locale = $request->{_locale};
+
     for (keys %$request){
         $form->{$_} = $request->{$_};
     }
 
+    $form->{batch_id} = $batch->{id};
     $form->{approved} = 0;
     $form->{transdate} = $request->{batch_date};
-    print STDERR "$request->{batch_type}\n";
-    require $vouchers_dispatch->{$request->{batch_type}}{script};
 
+
     my $script = $vouchers_dispatch->{$request->{batch_type}}{script};
+    { no strict; no warnings 'redefine'; do $script; }
+
     $script =~ s|.*/||;
     $form->{script} = $script;
+    $vouchers_dispatch->{$request->{batch_type}}{function}();
+}
 
-\    $vouchers_dispatch->{$request->{batch_type}}{function}();
+sub get_batch {
 }
 
 sub list_vouchers {
 }
 
+sub add_vouchers {
+}
+
 sub approve_batch {
 }
 

Modified: trunk/sql/modules/Voucher.sql
===================================================================
--- trunk/sql/modules/Voucher.sql	2007-10-19 06:05:41 UTC (rev 1795)
+++ trunk/sql/modules/Voucher.sql	2007-10-19 18:47:03 UTC (rev 1796)
@@ -276,7 +276,7 @@
 		batch (batch_class_id, description, control_code, created_by)
 	VALUES ((SELECT id FROM batch_class WHERE class = in_batch_class),
 		in_description, in_batch_number, 
-			(select id FROM users WHERE username = session_user));
+			(select entity_id FROM users WHERE username = session_user));
 
 	return currval('batch_id_seq');
 END;	


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