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

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



Revision: 4884
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4884&view=rev
Author:   einhverfr
Date:     2012-06-10 10:56:05 +0000 (Sun, 10 Jun 2012)
Log Message:
-----------
Removing ability to repost transactions

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/AA.pm
    trunk/LedgerSMB/GL.pm
    trunk/LedgerSMB/IR.pm
    trunk/LedgerSMB/IS.pm
    trunk/bin/aa.pl
    trunk/bin/arap.pl
    trunk/bin/gl.pl
    trunk/bin/ir.pl
    trunk/bin/is.pl

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2012-06-10 10:39:16 UTC (rev 4883)
+++ trunk/Changelog	2012-06-10 10:56:05 UTC (rev 4884)
@@ -18,6 +18,7 @@
 * Invoices with inventory subject to draft/vouchers workflows (Chris T)
 * Added Equity (Temp) account type (Chris T)
 * Added description field to AR/AP transaction screen (Chris T)
+* Removed ability to repost/delete transactions (Chris T)
 
 New RESTful Web Services Framework
 * Supports XML and JSON as input formats

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2012-06-10 10:39:16 UTC (rev 4883)
+++ trunk/LedgerSMB/AA.pm	2012-06-10 10:56:05 UTC (rev 4884)
@@ -750,75 +750,6 @@
 
 }
 
-=item delete_transaction(\%myconfig, $form)
-
-Deletes a transaction identified by $form->{id}, whether it is an ar or ap
-transaction is identified by $form->{vc}.  $form->{invnumber} used for the 
-audittrail routine.
-
-=cut
-
-sub delete_transaction {
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database, turn AutoCommit off
-    my $dbh = $form->{dbh};
-
-    my $table = ( $form->{vc} eq 'customer' ) ? 'ar' : 'ap';
-
-    my %audittrail = (
-        tablename => $table,
-        reference => $form->{invnumber},
-        formname  => 'transaction',
-        action    => 'deleted',
-        id        => $form->{id}
-    );
-
-    $form->audittrail( $dbh, "", \%audittrail );
-    my $query = qq|DELETE FROM ac_tax_form WHERE entry_id IN
-                   (SELECT entry_id FROM acc_trans WHERE trans_id = ?)|;
-    $dbh->prepare($query)->execute($form->{id}) || $form->dberror($query);
-
-    $query = qq|DELETE FROM $table WHERE id = ?|;
-    $dbh->prepare($query)->execute($form->{id}) || $form->dberror($query);
-
-    $query = qq|DELETE FROM acc_trans WHERE trans_id = ?|;
-    $dbh->prepare($query)->execute( $form->{id} ) || $form->dberror($query);
-
-    # get spool files
-    $query = qq|SELECT spoolfile 
-				  FROM status
-				 WHERE trans_id = ?
-				   AND spoolfile IS NOT NULL|;
-
-    $logger->debug("query: $query");
-    my $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-
-    my $spoolfile;
-    my @spoolfiles = ();
-
-    while ( ($spoolfile) = $sth->fetchrow_array ) {
-        push @spoolfiles, $spoolfile;
-    }
-
-    $sth->finish;
-
-    $query = qq|DELETE FROM status WHERE trans_id = ?|;
-    $dbh->prepare($query)->execute( $form->{id} ) || $form->dberror($query);
-
-    # commit
-    my $rc = $dbh->commit;
-
-    if ($rc) {
-        foreach $spoolfile (@spoolfiles) {
-            unlink "${LedgerSMB::Sysconfig::spool}/$spoolfile" if $spoolfile;
-        }
-    }
-
-    $rc;
-}
-
 =item transactions(\%myconfig, $form)
 
 Generates the transaction and outstanding reports.  Form variables used in this

Modified: trunk/LedgerSMB/GL.pm
===================================================================
--- trunk/LedgerSMB/GL.pm	2012-06-10 10:39:16 UTC (rev 4883)
+++ trunk/LedgerSMB/GL.pm	2012-06-10 10:56:05 UTC (rev 4884)
@@ -65,35 +65,6 @@
 
 }
 
-sub delete_transaction {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    my %audittrail = (
-        tablename => 'gl',
-        reference => $form->{reference},
-        formname  => 'transaction',
-        action    => 'deleted',
-        id        => $form->{id}
-    );
-
-    $form->audittrail( $dbh, "", \%audittrail );
-    my $id    = $dbh->quote( $form->{id} );
-    my $query = qq|DELETE FROM gl WHERE id = $id|;
-    $dbh->do($query) || $form->dberror($query);
-
-    $query = qq|DELETE FROM acc_trans WHERE trans_id = $id|;
-    $dbh->do($query) || $form->dberror($query);
-
-    # commit and redirect
-    my $rc = $dbh->commit;
-
-    $rc;
-}
-
 sub post_transaction {
 
     my ( $self, $myconfig, $form, $locale) = @_;

Modified: trunk/LedgerSMB/IR.pm
===================================================================
--- trunk/LedgerSMB/IR.pm	2012-06-10 10:39:16 UTC (rev 4883)
+++ trunk/LedgerSMB/IR.pm	2012-06-10 10:56:05 UTC (rev 4884)
@@ -953,87 +953,6 @@
 
 }
 
-sub delete_invoice {
-    my ( $self, $myconfig, $form ) = @_;
-
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    my %audittrail = (
-        tablename => 'ap',
-        reference => $form->{invnumber},
-        formname  => $form->{type},
-        action    => 'deleted',
-        id        => $form->{id}
-    );
-
-    $form->audittrail( $dbh, "", \%audittrail );
-
-    my $query = qq|SELECT parts_id FROM invoice WHERE trans_id = ?|;
-    my $sth   = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-
-    my $item;
-    my %updparts = ();
-    while ( ($item) = $sth->fetchrow_array ) {
-        $updparts{$item} = 1;
-    }
-    $sth->finish;
-
-    &reverse_invoice( $dbh, $form );
-
-
-    # delete spool files
-    $query = qq|
-		SELECT spoolfile FROM status 
-		 WHERE trans_id = ?
-		       AND spoolfile IS NOT NULL|;
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-
-    my $spoolfile;
-    my @spoolfiles = ();
-
-    while ( ($spoolfile) = $sth->fetchrow_array ) {
-        push @spoolfiles, $spoolfile;
-    }
-    $sth->finish;
-
-    # delete status entries
-    $query = qq|DELETE FROM status WHERE trans_id = ?|;
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-
-    if ($rc) {
-        foreach $item ( keys %updparts ) {
-            $item  = $dbh->quote($item);
-            $query = qq|
-				UPDATE parts 
-				   SET avgcost = avgcost($item),
-				       lastcost = lastcost($item)
-				 WHERE id = $item|;
-            $dbh->do($query) || $form->dberror($query);
-        }
-
-        foreach $spoolfile (@spoolfiles) {
-            unlink "${LedgerSMB::Sysconfig::spool}/$spoolfile"
-              if $spoolfile;
-        }
-    }
-    #$query = "DELETE FROM invoice WHERE trans_id = ?";#tshvr already done in reverse_invoice
-    #$sth = $dbh->prepare($query);
-    #$sth->execute($form->{id});
-    # delete AP record
-    $query = qq|DELETE FROM ap WHERE id = ?|;
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-    my $rc = $dbh->commit;
-
-    $rc;
-
-}
-
 sub retrieve_invoice {
     my ( $self, $myconfig, $form ) = @_;
 

Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm	2012-06-10 10:39:16 UTC (rev 4883)
+++ trunk/LedgerSMB/IS.pm	2012-06-10 10:56:05 UTC (rev 4884)
@@ -1886,73 +1886,6 @@
 
 }
 
-sub delete_invoice {
-    my ( $self, $myconfig, $form ) = @_;
-
-    my $dbh = $form->{dbh};
-    my $sth;
-
-    &reverse_invoice( $dbh, $form );
-
-    my %audittrail = (
-        tablename => 'ar',
-        reference => $form->{invnumber},
-        formname  => $form->{type},
-        action    => 'deleted',
-        id        => $form->{id}
-    );
-
-    $form->audittrail( $dbh, "", \%audittrail );
-
-    # delete AR record
-    
-    my $query = qq|DELETE FROM invoice WHERE trans_id = ?|;
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-    $sth->finish;
-    $query = qq|DELETE FROM acc_trans WHERE trans_id = ?|;
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-    $sth->finish;
-
-    $query = qq|DELETE FROM ar WHERE id = ?|;
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-    $sth->finish;
-
-    # delete spool files
-    $query = qq|
-		SELECT spoolfile FROM status
-		 WHERE trans_id = ? AND spoolfile IS NOT NULL|;
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-
-    my $spoolfile;
-    my @spoolfiles = ();
-
-    while ( ($spoolfile) = $sth->fetchrow_array ) {
-        push @spoolfiles, $spoolfile;
-    }
-    $sth->finish;
-
-    # delete status entries
-    $query = qq|DELETE FROM status WHERE trans_id = ?|;
-    $sth   = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-
-    my $rc = $dbh->commit;
-
-    if ($rc) {
-        foreach $spoolfile (@spoolfiles) {
-            unlink "${LedgerSMB::Sysconfig::spool}/$spoolfile"
-              if $spoolfile;
-        }
-    }
-
-    $rc;
-
-}
-
 sub retrieve_invoice {
     my ( $self, $myconfig, $form ) = @_;
 

Modified: trunk/bin/aa.pl
===================================================================
--- trunk/bin/aa.pl	2012-06-10 10:39:16 UTC (rev 4883)
+++ trunk/bin/aa.pl	2012-06-10 10:56:05 UTC (rev 4884)
@@ -1034,12 +1034,9 @@
             $button{post_as_new}->{value} = $locale->text('Save as New');
             $form->hide_form('separate_duties');
         }
-        if ( $form->{id} && ($form->{approved} || !$form->{batch_id})) {
-            if ( $form->{locked} || ( $transdate && $transdate <= $closedto ) )
-            {
-                for ( "post","delete" ) {
-                    delete $button{$_};
-                }
+        if ( $form->{id}) { 
+            for ( "post","delete" ) {
+                delete $button{$_};
             }
         }
         elsif (!$form->{id}) {
@@ -1434,55 +1431,6 @@
 #New function starts Here
 
 
-sub delete {
-
-    $form->{title} = $locale->text('Confirm!');
-
-    $form->header;
-
-    print qq|
-<body>
-
-<form method=post action=$form->{script}>
-|;
-
-    $form->{action} = "yes";
-    $form->hide_form;
-
-    print qq|
-<h2 class=confirm>$form->{title}</h2>
-
-<h4>|
-      . $locale->text('Are you sure you want to delete Transaction')
-      . qq| $form->{invnumber}</h4>
-
-<button name="action" class="submit" type="submit" value="yes">|
-      . $locale->text('Yes')
-      . qq|</button>
-</form>
-
-</body>
-</html>
-|;
-
-}
-
-sub yes {
-
-    if (
-        AA->delete_transaction(
-            \%myconfig, \%$form, ${LedgerSMB::Sysconfig::spool}
-        )
-      )
-    {
-        $form->redirect( $locale->text('Transaction deleted!') );
-    }
-    else {
-        $form->error( $locale->text('Cannot delete transaction!') );
-    }
-
-}
-
 sub search {
 
     $form->create_links( module => $form->{ARAP},

Modified: trunk/bin/arap.pl
===================================================================
--- trunk/bin/arap.pl	2012-06-10 10:39:16 UTC (rev 4883)
+++ trunk/bin/arap.pl	2012-06-10 10:56:05 UTC (rev 4884)
@@ -523,70 +523,7 @@
 }
 
 sub repost {
-
-    if ( $form->{type} =~ /_order/ ) {
-        if ( $form->{print_and_save} ) {
-            $form->{nextsub} = "print_and_save";
-            $msg =
-              $locale->text('You are printing and saving an existing order');
-        }
-        else {
-            $form->{nextsub} = "save";
-            $msg = $locale->text('You are saving an existing order');
-        }
-    }
-    elsif ( $form->{type} =~ /_quotation/ ) {
-        if ( $form->{print_and_save} ) {
-            $form->{nextsub} = "print_and_save";
-            $msg =
-              $locale->text(
-                'You are printing and saving an existing quotation');
-        }
-        else {
-            $form->{nextsub} = "save";
-            $msg = $locale->text('You are saving an existing quotation');
-        }
-    }
-    else {
-        if ( $form->{print_and_post} ) {
-            $form->{nextsub} = "print_and_post";
-            $msg =
-              $locale->text(
-                'You are printing and posting an existing transaction!');
-        }
-        else {
-            $form->{nextsub} = "post";
-            $msg = $locale->text('You are posting an existing transaction!');
-        }
-    }
-
-    delete $form->{action};
-    $form->{repost} = 1;
-
-    $form->header;
-
-    print qq|
-<body>
-
-<form method=post action=$form->{script}>
-|;
-
-    $form->hide_form;
-
-    print qq|
-<h2 class=confirm>| . $locale->text('Warning!') . qq|</h2>
-
-<h4>$msg</h4>
-
-<button name="action" class="submit" type="submit" value="continue">|
-      . $locale->text('Continue')
-      . qq|</button>
-</form>
-
-</body>
-</html>
-|;
-
+    $form->error($locale->text('Reposting Not Allowed');
 }
 
 sub schedule {

Modified: trunk/bin/gl.pl
===================================================================
--- trunk/bin/gl.pl	2012-06-10 10:39:16 UTC (rev 4883)
+++ trunk/bin/gl.pl	2012-06-10 10:56:05 UTC (rev 4884)
@@ -269,8 +269,6 @@
 		    { ndx => 6, key => 'N', value => $locale->text('Post as new') },
 		  'schedule' =>
 		    { ndx => 7, key => 'H', value => $locale->text('Schedule') },
-		  'delete' =>
-		    { ndx => 8, key => 'D', value => $locale->text('Delete') },
                   'new' => 
                     { ndx => 9, key => 'N', value => $locale->text('New') },
 	      );
@@ -286,16 +284,11 @@
               } else {
                  $a{'update'} = 1;
               }
-	      if ( $form->{id} && ($form->{approved} || !$form->{batch_id})) {
+	      if ( $form->{id}) {
 
 		  for ( 'post_as_new', 'schedule' ) { $a{$_} = 1 }
 
-		  if ( !$form->{locked} ) {
-		      if ( $transdate ge $closedto) {
-			  for ( 'post', 'delete' ) { $a{$_} = 1 }
-		      }
-		  }
-
+		  for ( 'post', 'delete' ) { $a{$_} = 1 }
 	      }
 	      elsif (!$form->{id}){
 		  if ( $transdate > $closedto ) {
@@ -639,49 +632,10 @@
 
 
 
-sub delete {
-
-    my %hiddens;
-    delete $form->{action};
-    foreach (keys %$form) {
-        $hiddens{$_} = $form->{$_} unless ref $form->{$_};
-    }
-
-    $form->{title} = $locale->text('Confirm!');
-    my $query = $locale->text(
-        'Are you sure you want to delete Transaction [_1]',
-        $form->{reference} );
-
-    my @buttons = ({
-        name => 'action',
-        value => 'delete_transaction',
-        text => $locale->text('Yes'),
-        });
-    my $template = LedgerSMB::Template->new_UI(
-        user => \%myconfig, 
-        locale => $locale, 
-        template => 'form-confirmation',
-        );
-    $template->render({
-        form => $form,
-        query => $query,
-        hiddens => \%hiddens,
-        buttons => ..hidden..,
-    });
-}
-
-sub delete_transaction {
-
-    if ( GL->delete_transaction( \%myconfig, \%$form ) ) {
-        $form->redirect( $locale->text('Transaction deleted!') );
-    }
-    else {
-        $form->error( $locale->text('Cannot delete transaction!') );
-    }
-
-}
-
 sub post {
+    if ($form->{id}){
+       $form->error($locale->text('Cannot Repost Transaction'));
+    }
     if (!$form->close_form){
         &update;
         $form->finalize_request();

Modified: trunk/bin/ir.pl
===================================================================
--- trunk/bin/ir.pl	2012-06-10 10:39:16 UTC (rev 4883)
+++ trunk/bin/ir.pl	2012-06-10 10:56:05 UTC (rev 4884)
@@ -899,8 +899,6 @@
             },
             'schedule' =>
               { ndx => 7, key => 'H', value => $locale->text('Schedule') },
-            'delete' =>
-              { ndx => 8, key => 'D', value => $locale->text('Delete') },
             'on_hold' =>
               { ndx => 9, key=> 'O', value => $locale->text('On Hold') },
 	    'save_info'  => 
@@ -915,9 +913,7 @@
 
         if ( $form->{id} ) {
          
-            if ( $form->{locked} and !$form->{approved} ) {
-                for ( "post", "delete", 'on_hold' ) { delete $button{$_} }
-            }
+            for ( "post", "delete", 'on_hold' ) { delete $button{$_} }
             for ( 'post_as_new', 'print_and_post_as_new', "update") {
                 delete $button{$_};
             }
@@ -1395,46 +1391,6 @@
 
 }
 
-sub delete {
-
-    $form->header;
-
-    print qq|
-<body>
-
-<form method=post action=$form->{script}>
-|;
-
-    $form->{action} = "yes";
-    $form->hide_form;
-
-    print qq|
-<h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
-
-<h4>|
-      . $locale->text( 'Are you sure you want to delete Invoice Number [_1]?',
-        $form->{invnumber} )
-      . qq|</h4>
-<p>
-<button name="action" class="submit" type="submit" value="yes">|
-      . $locale->text('Yes')
-      . qq|</button>
-</form>
-|;
-
-}
-
-sub yes {
-
-    if ( IR->delete_invoice( \%myconfig, \%$form ) ) {
-        $form->redirect( $locale->text('Invoice deleted!') );
-    }
-    else {
-        $form->error( $locale->text('Cannot delete invoice!') );
-    }
-
-}
-
 sub on_hold {
     
     if ($form->{id}) {

Modified: trunk/bin/is.pl
===================================================================
--- trunk/bin/is.pl	2012-06-10 10:39:16 UTC (rev 4883)
+++ trunk/bin/is.pl	2012-06-10 10:56:05 UTC (rev 4884)
@@ -953,8 +953,6 @@
               { ndx => 9, key => 'L', value => $locale->text('Sales Order') },
             'schedule' =>
               { ndx => 10, key => 'H', value => $locale->text('Schedule') },
-            'delete' =>
-              { ndx => 11, key => 'D', value => $locale->text('Delete') },
             'on_hold' =>
               { ndx => 12, key => 'O', value => $locale->text('On Hold') },
              'void'  => 
@@ -974,12 +972,8 @@
 
         if ( $form->{id} ) {
 
-            if ( ($form->{locked} || $transdate <= $closedto) 
-                    and $form->{approved}
-             ) {
-                for ( "post", "print_and_post", "delete" ) {
-                    delete $button{$_};
-                }
+            for ( "post", "print_and_post", "delete" ) {
+                delete $button{$_};
             }
             my $is_draft = 0;
             if (!$form->{approved} && !$form->{batch_id}){
@@ -1433,53 +1427,6 @@
 
 }
 
-sub delete {
-
-    $form->header;
-
-    print qq|
-<body>
-
-<form method=post action=$form->{script}>
-|;
-
-    $form->{action} = "yes";
-    $form->hide_form;
-
-    print qq|
-<h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
-
-<h4>|
-      . $locale->text( 'Are you sure you want to delete Invoice Number [_1]?',
-        $form->{invnumber} )
-      . qq|
-</h4>
-
-<p>
-<button name="action" class="submit" type="submit" value="yes">|
-      . $locale->text('Yes')
-      . qq|</button>
-</form>
-|;
-
-}
-
-sub yes {
-
-    if (
-        IS->delete_invoice(
-            \%myconfig, \%$form, ${LedgerSMB::Sysconfig::spool}
-        )
-      )
-    {
-        $form->redirect( $locale->text('Invoice deleted!') );
-    }
-    else {
-        $form->error( $locale->text('Cannot delete invoice!') );
-    }
-
-}
-
 sub on_hold {
     
     if ($form->{id}) {

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