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

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



Revision: 5059
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5059&view=rev
Author:   einhverfr
Date:     2012-07-29 14:01:30 +0000 (Sun, 29 Jul 2012)
Log Message:
-----------
Removing unused code

Modified Paths:
--------------
    trunk/LedgerSMB/AM.pm
    trunk/LedgerSMB/RP.pm
    trunk/bin/am.pl

Modified: trunk/LedgerSMB/AM.pm
===================================================================
--- trunk/LedgerSMB/AM.pm	2012-07-29 11:26:40 UTC (rev 5058)
+++ trunk/LedgerSMB/AM.pm	2012-07-29 14:01:30 UTC (rev 5059)
@@ -1484,269 +1484,7 @@
 
 }
 
-=item AM->closedto($myconfig, $form);
 
-Populates $form->{closedto}, $form->{revtrans}, and $form->{audittrail} with
-their values in the defaults table.
-
-$myconfig is unused.
-
-=cut
-
-sub closedto {
-    my ( $self, $myconfig, $form ) = @_;
-
-    my $dbh = $form->{dbh};
-
-    my $query = qq|
-		SELECT (SELECT value FROM defaults 
-		         WHERE setting_key = 'closedto'), 
-		       (SELECT value FROM defaults
-		         WHERE setting_key = 'revtrans'), 
-		       (SELECT value FROM defaults
-		         WHERE setting_key = 'audittrail')|;
-
-    ( $form->{closedto}, $form->{revtrans}, $form->{audittrail} ) =
-      $dbh->selectrow_array($query);
-
-    $dbh->commit;
-
-}
-
-=item AM->closebooks($myconfig, $form);
-
-Updates the revtrans, closedto, and audittrail entries in the defaults table
-using their corresponding $form values.  If $form->{removeaudittrail} is set,
-this used to remove all audittrail entries with a transdate prior to the date
-given by $form->{removeaudittrail}, but has been disabled.
-
-$myconfig is unused.
-
-=cut
-
-sub closebooks {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    my $dbh   = $form->{dbh};
-    my $query = qq|
-		UPDATE defaults SET value = ? 
-		 WHERE setting_key = ?|;
-    my $sth = $dbh->prepare($query);
-    my $sth_closedto = $dbh->prepare(qq|
-		UPDATE defaults SET value = to_char(?::date, 'YYYY-MM-DD') 
-		 WHERE setting_key = ?|);
-		
-    for (qw(revtrans closedto audittrail)) {
-
-        if ( $form->{$_} ) {
-            $val = $form->{$_};
-        }
-        else {
-            $val = 0;
-        }
-        if ($_ eq 'closedto'){
-            $sth_closedto->execute( $val || undef, $_);
-        } else { 
-            $sth->execute( $val, $_ );
-        }
-    }
-
-## SC: Disabling audit trail removal
-##    if ( $form->{removeaudittrail} ) {
-##        $query = qq|
-##			DELETE FROM audittrail
-##			 WHERE transdate < ?|;
-##
-##        $dbh->do($query, undef, $form->{removeaudittrail}) || $form->dberror($query);
-##    }
-
-    $dbh->commit;
-
-}
-
-=item AM->earningsaccounts($myconfig, $form);
-
-Populates the list referred to as $form->{chart} with hashes containing the
-account number (accno) and the description of all equity accounts, ordered by
-the account number.
-
-$myconfig is unused.
-
-=cut
-
-sub earningsaccounts {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    my ( $query, $sth, $ref );
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    # get chart of accounts
-    $query = qq|
-		    SELECT accno,description
-		      FROM chart
-		     WHERE charttype = 'A'
-		           AND category = 'Q'
-		  ORDER BY accno|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-    $form->{chart} = [];
-
-    while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-        push @{ $form->{chart} }, $ref;
-    }
-
-    $sth->finish;
-    $dbh->commit;
-}
-
-=item AM->post_yearend($myconfig, $form);
-
-Posts the termination of a financial year.  Makes use of the $form attributes
-login, reference, notes, description, and transdate to populate the gl table
-entry.  The id of the gl transaction is placed in $form->{id}.  
-
-For every accno_$i in $form, where $i is between 1 and $form->{rowcount}, an
-acc_trans entry will be added if credit_$i or debit_$i is non-zero.
-
-A new yearend entry is populated with the id and transdate of the gl
-transaction.
-
-Adds an entry to the audittrail.
-
-$myconfig is unused.
-
-=cut
-
-sub post_yearend {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    my $dbh = $form->{dbh};
-
-    my $query;
-    my @queryargs;
-    my $uid = localtime;
-    $uid .= "$$";
-
-    $query = qq|
-		INSERT INTO gl (reference, person_id)
-		     VALUES (?, (SELECT id FROM person WHERE entity_id = (select entity_id from users where username = current_user)))|;
-
-    $dbh->prepare($query)->execute( $uid)
-      || $form->dberror($query);
-
-    $query = qq|
-		SELECT id 
-		  FROM gl
-		 WHERE reference = ?|;
-
-    my $sth = $dbh->prepare($query);
-    $sth->execute($uid);
-    ( $form->{id} ) = $sth->fetchrow_array;
-
-    $query = qq|
-		UPDATE gl 
-		   SET reference = ?,
-		       description = ?,
-		       notes = ?,
-		       transdate = ?,
-		       department_id = 0
-		 WHERE id = ?|;
-
-    @queryargs = (
-        $form->{reference}, $form->{description}, $form->{notes},
-        $form->{transdate}, $form->{id}
-    );
-    $dbh->prepare($query)->execute(@queryargs) || $form->dberror($query);
-
-    my $amount;
-    my $accno;
-    $query = qq|
-		INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, 
-		            source)
-		     VALUES (?, (SELECT id
-		                   FROM chart
-		                  WHERE accno = ?),
-		            ?, ?, ?)|;
-
-    # insert acc_trans transactions
-    for my $i ( 1 .. $form->{rowcount} ) {
-
-        # extract accno
-        ($accno) = split( /--/, $form->{"accno_$i"} );
-        $amount = 0;
-
-        if ( $form->{"credit_$i"} ) {
-            $amount = $form->{"credit_$i"};
-        }
-
-        if ( $form->{"debit_$i"} ) {
-            $amount = $form->{"debit_$i"} * -1;
-        }
-
-        # if there is an amount, add the record
-        if ($amount) {
-            my @args = (
-                $form->{id}, $accno, $amount, $form->{transdate},
-                $form->{reference}
-            );
-
-            $dbh->prepare($query)->execute(@args)
-              || $form->dberror($query);
-        }
-    }
-
-    $query = qq|
-		INSERT INTO yearend (trans_id, transdate)
-		     VALUES (?, ?)|;
-
-    $dbh->prepare($query)->execute( $form->{id}, $form->{transdate} )
-      || $form->dberror($query);
-
-    my %audittrail = (
-        tablename => 'gl',
-        reference => $form->{reference},
-        formname  => 'yearend',
-        action    => 'posted',
-        id        => $form->{id}
-    );
-
-    $form->audittrail( $dbh, "", \%audittrail );
-
-    # commit and redirect
-    my $rc = $dbh->commit;
-
-    $rc;
-
-}
-
-=item AM->get_templates_directories;
-
-This functions gets all the directories from $LedgerSMB::Sysconfig::templates to list all the possible
-non-Ui templates.
-
-=cut
-sub get_templates_directories {
-my ( $self, $form ) = @_;
-my $subdircount = 0;
-my @dirarray;
-opendir ( DIR, $LedgerSMB::Sysconfig::templates) || $form->error("Error while opening file: ./".$LedgerSMB::Sysconfig::templates);
-while( (my $name = readdir(DIR))){
-                 next if ($name =~ /\./);
-                 if (-d $LedgerSMB::Sysconfig::templates.'/'.$name) {
-                         $dirarray[$subdircount++] = $name;
-                 }
-}
-closedir(DIR);
..hidden..>{templates_directories}} = @dirarray;
-}
-
-
 1;
 
 =back

Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm	2012-07-29 11:26:40 UTC (rev 5058)
+++ trunk/LedgerSMB/RP.pm	2012-07-29 14:01:30 UTC (rev 5059)
@@ -104,73 +104,6 @@
 
 }
 
-sub yearend_statement {
-    my ( $self, $myconfig, $form ) = @_;
-
-    my $dbh = $form->{dbh};
-
-    # if todate < existing yearends, delete GL and yearends
-    my $query = qq|SELECT trans_id FROM yearend WHERE transdate >= ?|;
-    my $sth   = $dbh->prepare($query);
-    $sth->execute( $form->{todate} ) || $form->dberror($query);
-
-    my @trans_id = ();
-    my $id;
-    while ( ($id) = $sth->fetchrow_array ) {
-        push @trans_id, $id;
-    }
-    $sth->finish;
-
-    my $last_period = 0;
-    my @categories  = qw(I E);
-    my $category;
-
-    $form->{decimalplaces} *= 1;
-
-    &get_accounts( $dbh, 0, $form->{fromdate}, $form->{todate}, $form,
-        ..hidden.. );
-
-    $dbh->commit;
-
-    # now we got $form->{I}{accno}{ }
-    # and $form->{E}{accno}{  }
-
-    my %account = (
-        'I' => {
-            'label'  => 'income',
-            'labels' => 'income',
-            'ml'     => 1
-        },
-        'E' => {
-            'label'  => 'expense',
-            'labels' => 'expenses',
-            'ml'     => -1
-        }
-    );
-
-    foreach $category (@categories) {
-        foreach $key ( sort keys %{ $form->{$category} } ) {
-            if ( $form->{$category}{$key}{charttype} eq 'A' ) {
-                $form->{"total_$account{$category}{labels}_this_period"} +=
-                  $form->{$category}{$key}{this} * $account{$category}{ml};
-            }
-        }
-    }
-
-    # totals for income and expenses
-    $form->{total_income_this_period} =
-      $form->round_amount( $form->{total_income_this_period},
-        $form->{decimalplaces} );
-    $form->{total_expenses_this_period} =
-      $form->round_amount( $form->{total_expenses_this_period},
-        $form->{decimalplaces} );
-
-    # total for income/loss
-    $form->{total_this_period} =
-      $form->{total_income_this_period} - $form->{total_expenses_this_period};
-
-}
-
 sub balance_sheet {
     my ( $self, $myconfig, $form ) = @_;
 

Modified: trunk/bin/am.pl
===================================================================
--- trunk/bin/am.pl	2012-07-29 11:26:40 UTC (rev 5058)
+++ trunk/bin/am.pl	2012-07-29 14:01:30 UTC (rev 5059)
@@ -1423,81 +1423,6 @@
 
 }
 
-sub audit_control {
-
-    $form->{title} = $locale->text('Audit Control');
-
-    AM->closedto( \%myconfig, \%$form );
-    my %checked;
-
-    if ( $form->{revtrans} ) {
-        $checked{revtransY} = 'checked';
-    } else {
-        $checked{revtransN} = 'checked';
-    }
-
-    if ( $form->{audittrail} ) {
-        $checked{audittrailY} = 'checked';
-    } else {
-        $checked{audittrailN} = 'checked';
-    }
-
-    my %hiddens = (
-        path => $form->{path},
-        login => $form->{login},
-        sessionid => $form->{sessionid},
-        );
-    my $template = LedgerSMB::Template->new_UI(
-        user => \%myconfig, 
-        locale => $locale,
-        template => 'am-audit-control');
-    $template->render({
-        user => \%myconfig,
-        form => $form,
-        checked => \%checked,
-	hiddens => \%hiddens,
-    });
-}
-
-sub doclose {
-
-    AM->closebooks( \%myconfig, \%$form );
-
-    if ( $form->{revtrans} ) {
-        $msg = $locale->text('Transaction reversal enforced for all dates');
-    }
-    else {
-
-        if ( $form->{closedto} ) {
-            $msg =
-                $locale->text('Transaction reversal enforced up to [_1]',
-                $locale->date( \%myconfig, $form->{closedto}, 1 ));
-        }
-        else {
-            $msg = $locale->text('Books are open');
-        }
-    }
-
-    $msg .= "<p>";
-    if ( $form->{audittrail} ) {
-        $msg .= $locale->text('Audit trail enabled');
-    }
-    else {
-        $msg .= $locale->text('Audit trail disabled');
-    }
-
-##SC: Disabling audit trail deletion
-##    $msg .= "<p>";
-##    if ( $form->{removeaudittrail} ) {
-##        $msg .=
-##            $locale->text('Audit trail removed up to') . " "
-##          . $locale->date( \%myconfig, $form->{removeaudittrail}, 1 );
-##    }
-
-    $form->redirect($msg);
-
-}
-
 sub add_warehouse {
 
     $form->{title} = "Add";
@@ -1653,99 +1578,6 @@
 
 }
 
-sub yearend {
-
-    AM->earningsaccounts( \%myconfig, \%$form );
-    my %hiddens;
-    my $chart = "";
-    my %accounts = (
-        name => 'accno',
-        options => [],
-        );
-    for ( @{ $form->{chart} } ) {
-        push @{$accounts{options}}, {
-            text => "$_->{accno}--$_->{description}",
-            value => "$_->{accno}--$_->{description}",
-            };
-    }
-    $form->{title} = $locale->text('Yearend');
-
-    $hiddens{decimalplaces} = 2;
-    $hiddens{l_accno} = 'Y';
-    $hiddens{$_} = $form->{$_} foreach qw(path login sessionid);
-
-    my @buttons = ({
-        name => 'action',
-        value => 'generate_yearend',
-        text => $locale->text('Continue'),
-        });
-
-    my $template = LedgerSMB::Template->new_UI(
-        user => \%myconfig, 
-        locale => $locale,
-        template => 'am-yearend');
-    $template->render({
-        user => \%myconfig, 
-        form => $form,
-        buttons => ..hidden..,
-	hiddens => \%hiddens,
-	accounts => \%accounts,
-    });
-}
-
-sub generate_yearend {
-
-    $form->isblank( "todate", $locale->text('Yearend date missing!') );
-
-    RP->yearend_statement( \%myconfig, \%$form );
-
-    $form->{transdate} = $form->{todate};
-
-    $earnings = 0;
-
-    $form->{rowcount} = 1;
-    foreach $key ( keys %{ $form->{I} } ) {
-        if ( $form->{I}{$key}{charttype} eq "A" ) {
-            $form->{"debit_$form->{rowcount}"} = $form->{I}{$key}{this};
-            $earnings += $form->{I}{$key}{this};
-            $form->{"accno_$form->{rowcount}"} = $key;
-            $form->{rowcount}++;
-            $ok = 1;
-        }
-    }
-
-    foreach $key ( keys %{ $form->{E} } ) {
-        if ( $form->{E}{$key}{charttype} eq "A" ) {
-            $form->{"credit_$form->{rowcount}"} = $form->{E}{$key}{this} * -1;
-            $earnings += $form->{E}{$key}{this};
-            $form->{"accno_$form->{rowcount}"} = $key;
-            $form->{rowcount}++;
-            $ok = 1;
-        }
-    }
-    if ( $earnings > 0 ) {
-        $form->{"credit_$form->{rowcount}"} = $earnings;
-        $form->{"accno_$form->{rowcount}"}  = $form->{accno};
-    }
-    else {
-        $form->{"debit_$form->{rowcount}"} = $earnings * -1;
-        $form->{"accno_$form->{rowcount}"} = $form->{accno};
-    }
-
-    if ($ok) {
-        if ( AM->post_yearend( \%myconfig, \%$form ) ) {
-            $form->redirect( $locale->text('Yearend posted!') );
-        }
-        else {
-            $form->error( $locale->text('Yearend posting failed!') );
-        }
-    }
-    else {
-        $form->error('Nothing to do!');
-    }
-
-}
-
 sub company_logo {
 
     $myconfig{address} =~ s/\\n/<br>/g; # Template cleans this up

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