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

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



Revision: 5040
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5040&view=rev
Author:   einhverfr
Date:     2012-07-25 10:11:30 +0000 (Wed, 25 Jul 2012)
Log Message:
-----------
Removing unused SL trial balance and aging report code

Modified Paths:
--------------
    trunk/LedgerSMB/RP.pm
    trunk/LedgerSMB/Report.pm
    trunk/bin/rp.pl

Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm	2012-07-25 08:31:25 UTC (rev 5039)
+++ trunk/LedgerSMB/RP.pm	2012-07-25 10:11:30 UTC (rev 5040)
@@ -1302,429 +1302,6 @@
 
 }
 
-sub trial_balance {
-    my ( $self, $myconfig, $form ) = @_;
-    my $p;
-    my $year_end = $form->{ignore_yearend};
-    ( $form->{fromdate}, $form->{todate} ) =
-      $form->from_to( $form->{fromyear}, $form->{frommonth}, $form->{interval} )
-      if $form->{fromyear} && $form->{frommonth};
-
-    my $dbh = $form->{dbh};
-    my $approved = 'FALSE';
-
-    my ( $query, $sth, $ref );
-    my %balance = ();
-    my %trb     = ();
-    my $null;
-    my $department_id;
-    my $project_id;
-    my @headingaccounts = ();
-    my $dpt_where;
-    my $dpt_join;
-    my $project;
-
-    my $where    = "1 = 1";
-    my $invwhere = $where;
-
-    ( $null, $department_id ) = split /--/, $form->{department};
-    ( $null, $project_id )    = split /--/, $form->{projectnumber};
-
-    if ($department_id) {
-        $dpt_join = qq|
-			JOIN dpt_trans t ON (ac.trans_id = t.trans_id)|;
-        $dpt_where = qq|
-			AND t.department_id = | . $dbh->quote($department_id);
-    }
-    if ($project_id) {
-        $project = qq|
-			AND ac.project_id = | . $dbh->quote($project_id);
-    }
-
-    ( $form->{fromdate}, $form->{todate} ) =
-      $form->from_to( $form->{year}, $form->{month}, $form->{interval} )
-      if $form->{year} && $form->{month};
-    my $amount_cast; # Whitelisted, safe for interpolation
-    if ($form->{discrete_money}){
-        $form->{calc_precision} = $LedgerSMB::Sysconfig::precision;
-    }
-    if ($form->{calc_precision} =~ /\D/){
-        $form->error('Illegal calculation precision');
-    }
-    if ($form->{calc_precision} =~ /\d+/){
-        $amount_cast = "NUMERIC(30,$form->{calc_precision})";
-    } else {
-        $amount_cast = "NUMERIC";
-    }
-
-    # get beginning balances
-    if ( ($department_id or $form->{accounttype} eq 'gifi') and $form->{fromdate}) {
-        if ( $form->{accounttype} eq 'gifi' ) {
-
-            $query = qq|
-				  SELECT g.accno, c.category, 
-				         SUM(ac.amount::$amount_cast) AS amount,
-				         g.description, c.contra
-				    FROM acc_trans ac
-				    JOIN chart c ON (ac.chart_id = c.id AND c.charttype = 'A')
-				    JOIN gifi g ON (c.gifi_accno = g.accno)
-				         $dpt_join
-				    JOIN (SELECT id, approved FROM gl UNION
-				          SELECT id, approved FROM ar UNION
-				          SELECT id, approved FROM ap) gl
-				         ON (ac.trans_id = gl.id)
-				   WHERE ac.transdate < '$form->{fromdate}'
-				         $dpt_where $project
-				         AND ($approved OR ac.approved)
-				         AND ($approved OR gl.approved)
-				GROUP BY g.accno, c.category, g.description, 
-				         c.contra|;
-
-        }
-        else {
-
-            $query = qq|
-				  SELECT c.accno, c.category, 
-				         SUM(ac.amount::$amount_cast) AS amount,
-				         c.description, c.contra
-				    FROM acc_trans ac
-				    JOIN chart c ON (ac.chart_id = c.id AND c.charttype = 'A')
-				         $dpt_join
-				    JOIN (SELECT id, approved FROM gl UNION
-				          SELECT id, approved FROM ar UNION
-				          SELECT id, approved FROM ap) gl
-				         ON (ac.trans_id = gl.id)
-				   WHERE ac.transdate < '$form->{fromdate}'
-				         $dpt_where $project
-				         AND ($approved OR ac.approved)
-				         AND ($approved OR gl.approved)
-				GROUP BY c.accno, c.category, c.description, 
-				         c.contra|;
-
-        }
-
-        $sth = $dbh->prepare($query);
-        $sth->execute || $form->dberror($query);
-
-        while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-            $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
-            $balance{ $ref->{accno} } = $ref->{amount};
-
-            if ( $form->{all_accounts} ) {
-                $trb{ $ref->{accno} }{description} = $ref->{description};
-                $trb{ $ref->{accno} }{charttype}   = 'A';
-                $trb{ $ref->{accno} }{category}    = $ref->{category};
-                $trb{ $ref->{accno} }{contra}      = $ref->{contra};
-            }
-
-        }
-        $sth->finish;
-
-    }
-
-    # get headings
-    $query = qq|
-		  SELECT c.accno, c.description, c.category FROM chart c
-		   WHERE c.charttype = 'H'
-		ORDER by c.accno|;
-
-    if ( $form->{accounttype} eq 'gifi' ) {
-        $query = qq|
-			  SELECT g.accno, g.description, c.category, c.contra
-			    FROM gifi g
-			    JOIN chart c ON (c.gifi_accno = g.accno)
-			   WHERE c.charttype = 'H'
-			ORDER BY g.accno|;
-    }
-
-    $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-
-    while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
-        $trb{ $ref->{accno} }{description} = $ref->{description};
-        $trb{ $ref->{accno} }{charttype}   = 'H';
-        $trb{ $ref->{accno} }{category}    = $ref->{category};
-        $trb{ $ref->{accno} }{accno}       = $ref->{accno};
-        $trb{ $ref->{accno} }{contra}      = $ref->{contra};
-
-        push @headingaccounts, $ref->{accno};
-    }
-
-    $sth->finish;
-    my $yearend_filter;
-    if (!$department_id and !$form->{gifi}){
-        my $datefrom = $dbh->quote($form->{fromdate});
-        my $dateto = $dbh->quote($form->{todate});
-	my $safe_project_id = $dbh->quote($project_id);
-        if ($datefrom eq "''") {
-            $datefrom = "NULL";
-        }
-        if ($dateto eq "''") {
-            $dateto = "NULL";
-        }
-        if ($year_end ne 'none'){
-             if ($year_end eq 'last'){
-                   # CT:  The coalesce below uses magic values but this should
-                   # be safe because all automatically assigned transactions 
-                   # should be positive integers.  In the long run though this
-                   # is being moved into stored procedures.
-                  $yearend_filter = "AND (ac.transdate < coalesce($datefrom, ac.transdate)  OR 
-			ac.trans_id <> (select coalesce(max(trans_id), -1000) FROM yearend WHERE transdate <= coalesce($dateto, 'infinity'::timestamp)))";
-             } elsif ($year_end eq 'all'){
-                  $yearend_filter = "AND (y.trans_id is null or ac.transdate < coalesce($datefrom, ac.transdate))";
-             } else {
-                 $form->error($main::locale->text('Invalid Year-end filter request!'));
-             }
-        }
-        $query = "SELECT c.id AS chart_id, c.accno, c.description, c.contra, 
-                                c.category,
-                                SUM(CASE WHEN ac.transdate < $datefrom
-                                    THEN ac.amount::$amount_cast
-                                    ELSE 0 END) AS balance,
-                                SUM(CASE WHEN ac.transdate >= 
-                                              coalesce($datefrom, ac.transdate)
-                                              AND ac.amount > 0
-                                    THEN ac.amount::$amount_cast
-                                    ELSE 0 END) AS credit,
-                                SUM(CASE WHEN ac.transdate >= 
-                                              coalesce($datefrom, ac.transdate)
-                                              AND ac.amount < 0
-                                    THEN ac.amount::$amount_cast
-                                    ELSE 0 END) * -1 AS debit,
-                                SUM(CASE WHEN ac.transdate >=
-                                              coalesce($datefrom, ac.transdate)
-                                         THEN ac.amount::$amount_cast
-                                         ELSE 0
-                                    END) as amount
-                                FROM acc_trans ac
-                                JOIN (select id, approved FROM ap
-                                        UNION ALL
-                                        select id, approved FROM gl
-                                        UNION ALL
-                                        select id, approved FROM ar) g
-                                        ON (g.id = ac.trans_id)
-                                JOIN chart c ON (c.id = ac.chart_id AND c.charttype = 'A')
-				LEFT JOIN yearend y ON (ac.trans_id = y.trans_id)
-                                WHERE (ac.transdate <= $dateto OR $dateto IS NULL)
-                                        AND ac.approved AND g.approved
-                                        AND ($safe_project_id IS NULL
-                                                OR $safe_project_id = ac.project_id)
-				      $yearend_filter
-                                GROUP BY c.id, c.accno, c.description, c.contra,
-                                         c.category
-				ORDER BY c.accno";
-        my $sth = $dbh->prepare($query);
-        $sth->execute();
-        while ($ref = $sth->fetchrow_hashref('NAME_lc')){
-            $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
-            $trb{ $ref->{accno} }{accno}       = $ref->{accno};
-            $trb{ $ref->{accno} }{description} = $ref->{description};
-            $trb{ $ref->{accno} }{charttype}   = 'A';
-            $trb{ $ref->{accno} }{amount}      = $ref->{amount};
-            $trb{ $ref->{accno} }{debit}       = $ref->{debit};
-            $trb{ $ref->{accno} }{credit}      = $ref->{credit};
-            $trb{ $ref->{accno} }{category}    = $ref->{category};
-            $trb{ $ref->{accno} }{contra}      = $ref->{contra};
-            $trb{ $ref->{accno} }{balance}     = $ref->{balance};
-        }
-        $form->{TB} = [];
-        foreach my $accno ( sort keys %trb ) {
-           push @{$form->{TB}}, $trb{$accno};
-        }
-        return;
-    } else {
-        if ( $form->{fromdate} || $form->{todate} ) {
-            if ( $form->{fromdate} ) {
-                $where .=
-                  " AND ac.transdate >= " . $dbh->quote( $form->{fromdate} );
-                $invwhere .=
-                  " AND a.transdate >= " . $dbh->quote( $form->{fromdate} );
-            }
-            if ( $form->{todate} ) {
-                $where .= " AND ac.transdate <= " . $dbh->quote( $form->{todate} );
-                $invwhere .=
-                  " AND a.transdate <= " . $dbh->quote( $form->{todate} );
-            }
-        }
-
-        if ( $form->{accounttype} eq 'gifi' ) {
-
-            $query = qq|
-			  SELECT g.accno, g.description, c.category,
-			         SUM(ac.amount::$amount_cast) AS amount, c.contra
-			    FROM acc_trans ac
-			    JOIN chart c ON (c.id = ac.chart_id AND c.charttype = 'A')
-			    JOIN gifi g ON (c.gifi_accno = g.accno)
-			         $dpt_join
-			    JOIN (SELECT id, approved FROM gl UNION
-			          SELECT id, approved FROM ar UNION
-			          SELECT id, approved FROM ap) gl
-			         ON (ac.trans_id = gl.id)
-			   WHERE $where $dpt_where $project
-			         AND ($approved OR ac.approved)
-			         AND ($approved OR gl.approved)
-			GROUP BY g.accno, g.description, c.category, c.contra
-			ORDER BY accno|;
-
-        }
-        else {
-
-            $query = qq|
-			  SELECT c.accno, c.description, c.category,
-			         SUM(ac.amount::$amount_cast) AS amount, c.contra
-			    FROM acc_trans ac
-			    JOIN chart c ON (c.id = ac.chart_id AND c.charttype = 'A')
-			         $dpt_join
-			    JOIN (SELECT id, approved FROM gl UNION
-			          SELECT id, approved FROM ar UNION
-			          SELECT id, approved FROM ap) gl
-			         ON (ac.trans_id = gl.id)
-			   WHERE $where $dpt_where $project
-			         AND ($approved OR ac.approved)
-			         AND ($approved OR gl.approved)
-			GROUP BY c.accno, c.description, c.category, c.contra
-			ORDER BY accno|;
-
-        }
-
-        $sth = $dbh->prepare($query);
-        $sth->execute || $form->dberror($query);
-
-        # prepare query for each account
-        $query = qq|
-		SELECT (SELECT SUM(ac.amount::$amount_cast) * -1 FROM acc_trans ac
-		          JOIN chart c ON (c.id = ac.chart_id)
-		               $dpt_join
-			  JOIN (SELECT id, approved FROM gl UNION
-			        SELECT id, approved FROM ar UNION
-			        SELECT id, approved FROM ap) gl
-			       ON (ac.trans_id = gl.id)
-		          WHERE $where $dpt_where $project AND ac.amount < 0
-				 AND ($approved OR ac.approved)
-			         AND ($approved OR gl.approved)
-		                 AND c.accno = ?) AS debit,
-		       (SELECT SUM(ac.amount::$amount_cast) FROM acc_trans ac
-		          JOIN chart c ON (c.id = ac.chart_id AND c.charttype = 'A')
-		               $dpt_join
-			  JOIN (SELECT id, approved FROM gl UNION
-			        SELECT id, approved FROM ar UNION
-			        SELECT id, approved FROM ap) gl
-			       ON (ac.trans_id = gl.id)
-		         WHERE $where $dpt_where $project AND ac.amount > 0
-			       AND ($approved OR ac.approved)
-			       AND ($approved OR gl.approved)
-		               AND c.accno = ?) AS credit |;
-
-        if ( $form->{accounttype} eq 'gifi' ) {
-
-            $query = qq|
-		SELECT (SELECT SUM(ac.amount::$amount_cast) * -1
-		          FROM acc_trans ac
-		          JOIN chart c ON (c.id = ac.chart_id AND c.charttype = 'A')
-		               $dpt_join
-		         WHERE $where $dpt_where $project AND ac.amount < 0
-				         AND ($approved OR ac.approved)
-		               AND c.gifi_accno = ?) AS debit,
-		
-		       (SELECT SUM(ac.amount::$amount_cast)
-		          FROM acc_trans ac
-		          JOIN chart c ON (c.id = ac.chart_id AND c.charttype = 'A')
-		               $dpt_join
-		         WHERE $where $dpt_where $project AND ac.amount > 0
-				         AND ($approved OR ac.approved)
-		               AND c.gifi_accno = ?) AS credit|;
-
-        }
-
-        $drcr = $dbh->prepare($query);
-
-        # calculate debit and credit for the period
-        while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-            $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
-            $trb{ $ref->{accno} }{description} = $ref->{description};
-            $trb{ $ref->{accno} }{charttype}   = 'A';
-            $trb{ $ref->{accno} }{category}    = $ref->{category};
-            $trb{ $ref->{accno} }{contra}      = $ref->{contra};
-            $trb{ $ref->{accno} }{amount} += $ref->{amount};
-        }
-        $sth->finish;
-    }
-    my ( $debit, $credit );
-
-    foreach my $accno ( sort keys %trb ) {
-        $ref = ();
-
-        $ref->{accno} = $accno;
-        for (qw(description category contra charttype amount)) {
-            $ref->{$_} = $trb{$accno}{$_};
-        }
-
-        $ref->{balance} = $balance{ $ref->{accno} };
-
-        if ( $trb{$accno}{charttype} eq 'A' ) {
-            if ($project_id) {
-
-                if ( $ref->{amount} < 0 ) {
-                    $ref->{debit} = $ref->{amount} * -1;
-                }
-                else {
-                    $ref->{credit} = $ref->{amount};
-                }
-                next if $form->round_amount( $ref->{amount}, 2 ) == 0;
-
-            }
-            else {
-
-                # get DR/CR
-                $drcr->execute( $ref->{accno}, $ref->{accno} )
-                  || $form->dberror($query);
-
-                ( $debit, $credit ) = ( 0, 0 );
-                while ( my @drcrlist = $drcr->fetchrow_array ) {
-                    $form->db_parse_numeric(sth=>$drcr, arrayref=>..hidden..);
-                    ($debit, $credit) = @drcrlist;
-                    $ref->{debit}  += $debit;
-                    $ref->{credit} += $credit;
-                }
-                $drcr->finish;
-
-            }
-
-
-            if ( !$form->{all_accounts} ) {
-                next
-                  if $form->round_amount( $ref->{debit} + $ref->{credit}, 2 ) ==
-                  0;
-            }
-        }
-
-        # add subtotal
-        @accno = grep { $_ le "$ref->{accno}" } @headingaccounts;
-        $accno = pop @accno;
-        if ($accno) {
-            $trb{$accno}{debit}  += $ref->{debit};
-            $trb{$accno}{credit} += $ref->{credit};
-        }
-
-        push @{ $form->{TB} }, $ref;
-
-    }
-
-    $dbh->commit;
-
-    # debits and credits for headings
-    foreach $accno (@headingaccounts) {
-        foreach $ref ( @{ $form->{TB} } ) {
-            if ( $accno eq $ref->{accno} ) {
-                $ref->{debit}  = $trb{$accno}{debit};
-                $ref->{credit} = $trb{$accno}{credit};
-            }
-        }
-    }
-
-}
-
 sub get_taxaccounts {
     my ( $self, $myconfig, $form ) = @_;
 

Modified: trunk/LedgerSMB/Report.pm
===================================================================
--- trunk/LedgerSMB/Report.pm	2012-07-25 08:31:25 UTC (rev 5039)
+++ trunk/LedgerSMB/Report.pm	2012-07-25 10:11:30 UTC (rev 5040)
@@ -259,14 +259,6 @@
     return ..hidden..;
 }
 
-=item prepare_input
-
-Handles from_date and to_date fields, as well as from_month, from_year, and 
-interval, setting from_date and to_date to LedgerSMB::PGDate types, and setting
-from_amount and to_amount to LedgerSMB::PGNumber types.
-
-Valid values for interval are:
-
 =over
 
 =item none 

Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl	2012-07-25 08:31:25 UTC (rev 5039)
+++ trunk/bin/rp.pl	2012-07-25 10:11:30 UTC (rev 5040)
@@ -77,7 +77,6 @@
     my %report = (
         balance_sheet    => { title => 'Balance Sheet' },
         income_statement => { title => 'Income Statement' },
-        trial_balance    => { title => 'Trial Balance' },
         tax_collected    => { title => 'Tax collected', vc => 'customer' },
         tax_paid         => { title => 'Tax paid' },
         nontaxable_sales => { title => 'Non-taxable Sales', vc => 'customer' },
@@ -156,9 +155,6 @@
     } elsif ( $form->{report} eq "balance_sheet" ) {
         $hiddens{nextsub} = 'generate_balance_sheet';
         $subform = 'generate_balance_sheet';
-    } elsif ( $form->{report} eq "trial_balance" ) {
-        $hiddens{nextsub} = 'generate_trial_balance';
-        $subform = 'generate_trial_balance';
     } elsif ( $form->{report} =~ /^tax_/ ) {
         $gifi = 0;
 
@@ -551,50 +547,10 @@
     };
 }
 
-sub generate_projects {
-
-    $form->{nextsub} = "generate_projects";
-    $form->{title}   = $locale->text('Project Transactions');
-
-    RP->trial_balance( \%myconfig, $form );
-
-    &list_accounts;
-
-}
 sub csv_generate_projects { &generate_projects }
 sub xls_generate_projects { &generate_projects }
 sub ods_generate_projects { &generate_projects }
 
-# Antonio Gallardo
-#
-# D.S. Feb 16, 2001
-# included links to display transactions for period entered
-# added headers and subtotals
-#
-sub generate_trial_balance {
-    $form->{money_precision} = $form->{display_precision};
-    # get for each account initial balance, debits and credits
-    RP->trial_balance( \%myconfig, \%$form );
-
-    $form->{nextsub} = "generate_trial_balance";
-    $form->{title}   = $locale->text('Trial Balance');
-
-    $form->{callback} = "$form->{script}?action=generate_trial_balance";
-    for (
-        qw(login path sessionid nextsub fromdate todate month year interval l_heading l_subtotal all_accounts accounttype title ignore_yearend)
-      )
-    {
-        $form->{callback} .= "&$_=$form->{$_}";
-    }
-    $form->{callback} = $form->escape( $form->{callback} );
-
-    &list_accounts;
-
-}
-sub csv_generate_trial_balance { &generate_trial_balance }
-sub xls_generate_trial_balance { &generate_trial_balance }
-sub ods_generate_trial_balance { &generate_trial_balance }
-
 sub list_accounts {
 
     $title = $form->escape( $form->{title} );
@@ -876,417 +832,6 @@
     });
 }
 
-sub generate_ar_aging {
-
-    # split customer
-    ( $form->{customer} ) = split( /--/, $form->{customer} );
-    $customer = $form->escape( $form->{customer}, 1 );
-    $title    = $form->escape( $form->{title},    1 );
-    $media    = $form->escape( $form->{media},    1 );
-
-    $form->{ct}   = "customer";
-    $form->{arap} = "ar";
-
-    RP->aging( \%myconfig, \%$form );
-
-    $form->{callback} =
-qq|$form->{script}?path=$form->{path}&action=generate_ar_aging&login=$form->{login}&sessionid=$form->{sessionid}&todate=$form->{todate}&customer=$customer&title=$title&type=$form->{type}&format=$form->{format}&media=$media&summary=$form->{summary}|;
-
-    &aging;
-
-}
-
-sub csv_generate_ar_aging { &generate_ar_aging }
-
-sub generate_ap_aging {
-
-    # split vendor
-    ( $form->{vendor} ) = split( /--/, $form->{vendor} );
-    $vendor = $form->escape( $form->{vendor}, 1 );
-    $title  = $form->escape( $form->{title},  1 );
-    $media  = $form->escape( $form->{media},  1 );
-
-    $form->{ct}   = "vendor";
-    $form->{arap} = "ap";
-
-    RP->aging( \%myconfig, \%$form );
-
-    $form->{callback} =
-qq|$form->{script}?path=$form->{path}&action=generate_ap_aging&login=$form->{login}&sessionid=$form->{sessionid}&todate=$form->{todate}&vendor=$vendor&title=$title&type=$form->{type}&format=$form->{format}&media=$media&summary=$form->{summary}|;
-
-    &aging;
-
-}
-
-sub select_all {
-
-    RP->aging( \%myconfig, \%$form );
-
-    for ( @{ $form->{AG} } ) { $_->{checked} = "checked" }
-
-    &aging;
-
-}
-
-sub print_options {
-
-    $form->{sendmode} = "attachment";
-    $form->{copies} = 1 unless $form->{copies};
-
-    $form->{print}{format} = {name => 'format', default_values => $form->{format}};
-    $form->{print}{template} = {name => 'type', default_values => $form->{type}};
-
-    my @formats = ();
-    my @media = ();
-    my @templates = ();
-
-    push @formats, {text => 'HTML', value => 'html'};
-    push @templates, {text => $locale->text('Statement'), value => 'statement'};
-
-    if ( $form->{media} eq 'email' ) {
-        $form->{print}{medium} = {name => 'sendmode', default_values => $form->{sendmode}};
-        push @media, {text => $locale->text('Attachment'), value => 'attachment'};
-        push @media, {text => $locale->text('In-line'), value => 'inline'};
-	if ($form->{SM}{attachment}) {
-	    $form->{print}{medium}{default_values} = $form->{SM}{attachment};
-	} elsif ($form->{SM}{inline}) {
-	    $form->{print}{medium}{default_values} = $form->{SM}{inline};
-	}
-    } else {
-        $form->{print}{medium} = {name => 'media'};
-        push @media, {text => $locale->text('Screen'), value => 'screen'};
-        if (   %{LedgerSMB::Sysconfig::printer}
-            && ${LedgerSMB::Sysconfig::latex} )
-        {
-            for ( sort keys %{LedgerSMB::Sysconfig::printer} ) {
-                push @media, {text => $_, value => $_};
-            }
-        }
-    }
-
-    if ( ${LedgerSMB::Sysconfig::latex} ) {
-        push @formats, {text => $locale->text('PDF'), value => 'pdf'};
-        push @formats, {text => $locale->text('Postscript'), value => 'ps'};
-    }
-
-    if (   %{LedgerSMB::Sysconfig::printer}
-        && ${LedgerSMB::Sysconfig::latex}
-        && $form->{media} ne 'email' )
-    {
-        $form->{print}{copies} = {
-            label => $locale->text('Copies'),
-            name => 'copies',
-            value => $form->{copies},
-            size => 2,
-            };
-    }
-
-    $form->{print}{template}{options} = ..hidden..;
-    $form->{print}{format}{options} = ..hidden..;
-    $form->{print}{medium}{options} = ..hidden..;
-}
-
-sub e_mail {
-
-    my %hiddens;
-    # get name and email addresses
-    for $i ( 1 .. $form->{rowcount} ) {
-        if ( $form->{"statement_$i"} ) {
-            $form->{"$form->{ct}_id"}  = $form->{"$form->{ct}_id_$i"};
-            $form->{"statement_1"}     = $form->{"statement_$i"};
-            $form->{"language_code_1"} = $form->{"language_code_$i"};
-            $form->{"curr_1"}          = $form->{"curr_$i"};
-            RP->get_customer( \%myconfig, \%$form );
-            $selected = 1;
-            last;
-        }
-    }
-
-    $form->error( $locale->text('Nothing selected!') ) unless $selected;
-    $form->{media} = "email";
-
-    &print_options;
-
-    for (qw(subject message type sendmode format action nextsub)) {
-        delete $form->{$_};
-    }
-
-    for (keys %$form) {
-        $hiddens{$_} = $form->{$_} unless ref $form->{$_};
-    }
-
-    my @buttons = ({
-        name => 'action',
-        value => 'send_email',
-        text => $locale->text('Continue'),
-    });
-    my $template = LedgerSMB::Template->new_UI(
-        user => \%myconfig, 
-        locale => $locale, 
-        template => 'rp-email',
-        );
-    $template->render({
-        form => $form,
-        user => \%myconfig, 
-        hiddens => \%hiddens,
-        buttons => ..hidden..,
-    });
-}
-
-sub send_email {
-
-    $form->{subject} = $locale->text( 'Statement - [_1]', $form->{todate} )
-      unless $form->{subject};
-    $form->isblank( "email", $locale->text('E-mail address missing!') );
-
-    my $selected = 0;
-    RP->aging( \%myconfig, $form );
-    my $ag = {};
-    for my $ref(@{$form->{AG}}){
-        push @{$ag->{$ref->{ctid}}}, $ref;
-    }
-    $form->{statementdate} = $locale->date( \%myconfig, $form->{todate}, 1 );
-    $form->{templates} = "$myconfig{templates}";
-    # CT-- These aren't working right now, seeing if they are in fact necessary
-    # due to changes in structure.
-    #
-    #my @vars = qw(company address businessnumber tel fax);
-    #for (@vars) { $form->{$_} = $myconfig{$_} }
-    $form->{address} =~ s/\\n/\n/g;
-
-    @vars = qw(name address1 address2 city state zipcode country contact);
-    push @vars, "$form->{ct}phone", "$form->{ct}fax", "$form->{ct}taxnumber";
-    push @vars, 'email' if !$form->{media} eq 'email';
-    my $invoices = 0; 
-    my $data= {};
-    for $i ( 1 .. $form->{rowcount} ) {
-        last if $selected;
-        if ( $form->{"statement_$i"}) {
-            $selected = 1;
-            for (qw(invnumber ordnumber ponumber notes invdate duedate)) {
-                $form->{$_} = ();
-            }
-            foreach $item (qw(c0 c30 c60 c90)) {
-                $form->{$item} = ();
-                $form->{"${item}total"} = 0;
-            }
-            $form->{total} = 0;
-            $form->{"$form->{ct}_id"} = $form->{"$form->{ct}_id_$i"};
-            $language_code            = $form->{"language_code_$i"};
-            $curr                     = $form->{"curr_$i"};
-            $selected                 = 1;
-            
-            if ( $form->{media} !~ /(screen|email)/ ) {
-                $SIG{INT} = 'IGNORE';
-            }
-    
-            @refs = @{$ag->{$form->{"statement_$i"}}};    
-
-
-            
-            for $ref( @refs ) {
-                for (@vars) { $form->{$_} = $ref->{$_} }
-
-                $form->{ $form->{ct} }    = $ref->{name};
-                $form->{"$form->{ct}_id"} = $ref->{ctid};
-                $form->{language_code}    = $form->{"language_code_$i"};
-                $form->{currency}         = $form->{"curr_$i"};
-
-                if ($ref->{curr} eq $form->{currency}){
-                    ++$invoices;
-                    $ref->{invdate} = $ref->{transdate};
-                   my @a = qw(invnumber ordnumber ponumber notes invdate duedate);
-                  for (@a) { $form->{"${_}_1"} = $ref->{$_} }
-                  $form->format_string(qw(invnumber_1 ordnumber_1 ponumber_1 notes_1));
-                  for (@a) { push @{ $form->{$_} }, $form->{"${_}_1"} }
-
-                  foreach $item (qw(c0 c30 c60 c90)) {
-                      eval {
-                           $ref->{$item} =
-                                  $form->round_amount( 
-                                      $ref->{$item} / $ref->{exchangerate}, 2 );
-                       };
-                      $form->{"${item}total"} += $ref->{$item};
-                      $form->{total}          += $ref->{$item};
-                      push @{ $form->{$item} },
-                      $form->format_amount( \%myconfig, $ref->{$item}, 2 );
-                   }
-                }
-                
-            }
-            for ( "c0", "c30", "c60", "c90", "" ) {
-                $form->{"${_}total"} =
-                  $form->format_amount( \%myconfig, $form->{"${_}total"},
-                    2 );
-            }
-            
-
-            for (keys %$form) { $data->{$_} = $form->{$_}}
-        }
-    }
-    delete $form->{header};
-    my $template = LedgerSMB::Template->new( 
-        user => \%myconfig,
-        template => $form->{'formname'} || $form->{'type'},
-        format => uc $form->{format},
-        method => 'email',
-        locale => $locale,
-        output_options => {
-            to => $form->{email},
-            cc => $form->{cc},
-            bcc => $form->{bcc},
-            from => $form->{form},
-            subject => $form->{subject},
-            message => $form->{message},
-            notify => $form->{read_receipt},
-            attach => ($form->{sendmode} eq 'attachment')? 1: 0,
-            },
-        );
-    try {
-        my $csettings = $LedgerSMB::Company_Config::settings;
-        $data->{company} = $csettings->{company_name};
-        $data->{businessnumber} = $csettings->{businessnumber};
-        $data->{email} = $csettings->{company_email};
-        $data->{address} = $csettings->{company_address};
-        $data->{tel} = $csettings->{company_phone};
-        $data->{fax} = $csettings->{company_fax};
-        $template->render({data => [$data]});
-    }
-    catch Error::Simple with {
-        my $E = shift;
-        $form->error( $E->stacktrace );
-    };
-    $form->redirect(
-        $locale->text( 'Statement sent to [_1]', $form->{ $form->{ct} } ) );
-
-    $form->finalize_request();
-}
-
-sub print {
-
-    if ( $form->{media} !~ /(screen|email)/ ) {
-        $form->error( $locale->text('Select postscript or PDF!') )
-          if ( $form->{format} !~ /(postscript|pdf)/ );
-    }
-
-    my @batch_data = ();
-    my $selected;
-    RP->aging( \%myconfig, $form );
-    my $ag = {};
-    for my $ref(@{$form->{AG}}){
-        push @{$ag->{$ref->{ctid}}}, $ref;
-    }
-    $form->{statementdate} = $locale->date( \%myconfig, $form->{todate}, 1 );
-    $form->{templates} = "$myconfig{templates}";
-    # CT-- These aren't working right now, seeing if they are in fact necessary
-    # due to changes in structure.
-    #
-    #my @vars = qw(company address businessnumber tel fax);
-    #for (@vars) { $form->{$_} = $myconfig{$_} }
-    $form->{address} =~ s/\\n/\n/g;
-
-    @vars = qw(name address1 address2 city state zipcode country contact);
-    push @vars, "$form->{ct}phone", "$form->{ct}fax", "$form->{ct}taxnumber";
-    push @vars, 'email' if !$form->{media} eq 'email';
-    my $invoices = 0; 
-    for $i ( 1 .. $form->{rowcount} ) {
-
-        if ( $form->{"statement_$i"}) {
-            for (qw(invnumber ordnumber ponumber notes invdate duedate)) {
-                $form->{$_} = ();
-            }
-            foreach $item (qw(c0 c30 c60 c90)) {
-                $form->{$item} = ();
-                $form->{"${item}total"} = 0;
-            }
-            $form->{total} = 0;
-            $form->{"$form->{ct}_id"} = $form->{"$form->{ct}_id_$i"};
-            $language_code            = $form->{"language_code_$i"};
-            $curr                     = $form->{"curr_$i"};
-            $selected                 = 1;
-            
-            if ( $form->{media} !~ /(screen|email)/ ) {
-                $SIG{INT} = 'IGNORE';
-            }
-    
-            @refs = @{$ag->{$form->{"statement_$i"}}};    
-
-
-            
-            for $ref( @refs ) {
-                for (@vars) { $form->{$_} = $ref->{$_} }
-
-                $form->{ $form->{ct} }    = $ref->{name};
-                $form->{"$form->{ct}_id"} = $ref->{ctid};
-                $form->{language_code}    = $form->{"language_code_$i"};
-                $form->{currency}         = $form->{"curr_$i"};
-
-                if ($ref->{curr} eq $form->{currency}){
-                    ++$invoices;
-                    $ref->{invdate} = $ref->{transdate};
-                   my @a = qw(invnumber ordnumber ponumber notes invdate duedate);
-                  for (@a) { $form->{"${_}_1"} = $ref->{$_} }
-                      $form->format_string(qw(invnumber_1 ordnumber_1 ponumber_1 notes_1));
-                  for (@a) { push @{ $form->{$_} }, $form->{"${_}_1"} }
-
-                  foreach $item (qw(c0 c30 c60 c90)) {
-                      eval {
-                           $ref->{$item} =
-                                  $form->round_amount( 
-                                      $ref->{$item} / $ref->{exchangerate}, 2 );
-                       };
-                      $form->{"${item}total"} += $ref->{$item};
-                      $form->{total}          += $ref->{$item};
-                      push @{ $form->{$item} },
-                      $form->format_amount( \%myconfig, $ref->{$item}, 2 );
-                   }
-                }
-                
-            }
-            for ( "c0", "c30", "c60", "c90", "" ) {
-                $form->{"${_}total"} =
-                  $form->format_amount( \%myconfig, $form->{"${_}total"},
-                    2 );
-            }
-            
-            my $printhash = {};
-            my $csettings = $LedgerSMB::Company_Config::settings;
-            $form->{company} = $csettings->{company_name};
-            $form->{businessnumber} = $csettings->{businessnumber};
-            $form->{email} = $csettings->{company_email};
-            $form->{address} = $csettings->{company_address};
-            $form->{tel} = $csettings->{company_phone};
-            $form->{fax} = $csettings->{company_fax};
-
-            for (keys %$form) { $printhash->{$_} = $form->{$_}}
-            push @batch_data, $printhash;
-        }
-    }
-
-    $form->error( $locale->text('Nothing selected!') ) unless $selected;
-   
-    my $template = LedgerSMB::Template->new( 
-      user => \%myconfig,
-      template => $form->{'formname'} || $form->{'type'},
-      format => uc $form->{format},
-      locale => $locale
-    );
-    try {
-        $template->render({currency => $form->{currency}, 
-                            data => ..hidden..);
-        $template->output($form);
-    }
-    catch Error::Simple with {
-        my $E = shift;
-        $form->error( $E->stacktrace );
-    };
-
-    $form->redirect( $locale->text('Statements sent to printer!') )
-      if ( $form->{media} !~ /(screen|email)/ );
-
-}
-
-
 sub generate_tax_report {
     RP->tax_report( \%myconfig, $form );
 

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