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

SF.net SVN: ledger-smb:[2763] trunk/bin/gl.pl



Revision: 2763
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2763&view=rev
Author:   einhverfr
Date:     2009-09-08 15:54:41 +0000 (Tue, 08 Sep 2009)

Log Message:
-----------
Correcting out of balance issue with posting gl drafts as shown

Modified Paths:
--------------
    trunk/bin/gl.pl

Modified: trunk/bin/gl.pl
===================================================================
--- trunk/bin/gl.pl	2009-09-01 15:59:49 UTC (rev 2762)
+++ trunk/bin/gl.pl	2009-09-08 15:54:41 UTC (rev 2763)
@@ -95,6 +95,7 @@
 sub edit_and_approve {
     use LedgerSMB::DBObject::Draft;
     use LedgerSMB;
+    check_balanced($form);
     my $lsmb = LedgerSMB->new();
     $lsmb->merge($form);
     my $draft = LedgerSMB::DBObject::Draft->new({base => $lsmb});
@@ -1100,6 +1101,25 @@
         $locale->text('Cannot post transaction for a closed period!') )
       if ( $transdate <= $closedto );
 
+    check_balanced($form);
+    if ( !$form->{repost} ) {
+        if ( $form->{id} ) {
+            &repost;
+            exit;
+        }
+    }
+
+    if ( GL->post_transaction( \%myconfig, \%$form ) ) {
+        $form->redirect( $locale->text('Transaction posted!') );
+    }
+    else {
+        $form->error( $locale->text('Cannot post transaction!') );
+    }
+
+}
+
+sub check_balanced {
+    my ($form) = @_;
     # add up debits and credits
     for $i ( 0 .. $form->{rowcount} ) {
         $dr = $form->parse_amount( \%myconfig, $form->{"debit_$i"} );
@@ -1120,20 +1140,5 @@
     {
         $form->error( $locale->text('Out of balance transaction!') );
     }
-
-    if ( !$form->{repost} ) {
-        if ( $form->{id} ) {
-            &repost;
-            exit;
-        }
-    }
-
-    if ( GL->post_transaction( \%myconfig, \%$form ) ) {
-        $form->redirect( $locale->text('Transaction posted!') );
-    }
-    else {
-        $form->error( $locale->text('Cannot post transaction!') );
-    }
-
 }
 


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