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

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



Revision: 5054
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5054&view=rev
Author:   einhverfr
Date:     2012-07-28 01:12:17 +0000 (Sat, 28 Jul 2012)
Log Message:
-----------
Removing old income statement code

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

Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm	2012-07-28 01:08:44 UTC (rev 5053)
+++ trunk/LedgerSMB/RP.pm	2012-07-28 01:12:17 UTC (rev 5054)
@@ -171,275 +171,6 @@
 
 }
 
-sub income_statement {
-    my ( $self, $myconfig, $form ) = @_;
-
-    my $dbh = $form->{dbh};
-
-    my $last_period = 0;
-    my @categories  = qw(I E);
-    my $category;
-
-    $form->{decimalplaces} *= 1;
-
-    if ( !( $form->{fromdate} || $form->{todate} ) ) {
-        if ( $form->{fromyear} && $form->{frommonth} ) {
-            ( $form->{fromdate}, $form->{todate} ) =
-              $form->from_to( $form->{fromyear}, $form->{frommonth},
-                $form->{interval} );
-        }
-    }
-    
-    &get_accounts( $dbh, $last_period, $form->{fromdate}, $form->{todate},
-        $form, ..hidden.., 1 );
-
-    if ( !( $form->{comparefromdate} || $form->{comparetodate} ) ) {
-        if ( $form->{compareyear} && $form->{comparemonth} ) {
-            ( $form->{comparefromdate}, $form->{comparetodate} ) =
-              $form->from_to( $form->{compareyear}, $form->{comparemonth},
-                $form->{interval} );
-        }
-    }
-
-    # if there are any compare dates
-    if ( $form->{comparefromdate} || $form->{comparetodate} ) {
-        $last_period = 1;
-
-        &get_accounts(
-            $dbh, $last_period,
-            $form->{comparefromdate},
-            $form->{comparetodate},
-            $form, ..hidden.., 1
-        );
-    }
-
-    $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
-        }
-    );
-
-    my $str;
-
-    foreach $category (@categories) {
-
-        foreach $key ( sort keys %{ $form->{$category} } ) {
-
-            # push description onto array
-
-##            $str = ( $form->{l_heading} ) ? $form->{padding} : "";
-            $str = "";
-
-            if ( $form->{$category}{$key}{charttype} eq "A" ) {
-                $str .=
-                  ( $form->{l_accno} )
-                  ? "$form->{$category}{$key}{accno} - $form->{$category}{$key}{description}"
-                  : "$form->{$category}{$key}{description}";
-                $str = {account => $form->{$category}{$key}{accno}, text => $str };
-                $str->{gifi_account} = 1 if $form->{accounttype} eq 'gifi';
-            }
-            if ( $form->{$category}{$key}{charttype} eq "H" ) {
-                if (   $account{$category}{subtotal}
-                    && $form->{l_subtotal} )
-                {
-
-                    $dash = "- ";
-                    push(
-                        @{ $form->{"$account{$category}{label}_account"} }, {
-                            text => "$account{$category}{subdescription}",
-                            subtotal => 1,
-                            },
-                    );
-
-                    push(
-                        @{
-                            $form->{"$account{$category}{labels}_this_period"}
-                          },
-                        $form->format_amount(
-                            $myconfig,
-                            $account{$category}{subthis} *
-                              $account{$category}{ml},
-                            $form->{decimalplaces},
-                            $dash
-                        )
-                    );
-
-                    if ($last_period) {
-
-                        # Chris T:  Giving up on
-                        # Formatting this one :-(
-                        push(
-                            @{
-                                $form->{
-                                    "$account{$category}{labels}_last_period"}
-                              },
-                            $form->format_amount(
-                                $myconfig,
-                                $account{$category}{sublast} *
-                                  $account{$category}{ml},
-                                $form->{decimalplaces},
-                                $dash
-                            )
-                        );
-                    }
-
-                }
-
-                $str = {
-                    text => "$form->{$category}{$key}{description}",
-                    heading => 1,
-                    };
-
-                $account{$category}{subthis} = $form->{$category}{$key}{this};
-                $account{$category}{sublast} = $form->{$category}{$key}{last};
-                $account{$category}{subdescription} =
-                  $form->{$category}{$key}{description};
-                $account{$category}{subtotal} = 1;
-
-                $form->{$category}{$key}{this} = 0;
-                $form->{$category}{$key}{last} = 0;
-
-                next unless $form->{l_heading};
-
-                $dash = " ";
-            }
-
-            push( @{ $form->{"$account{$category}{label}_account"} }, $str );
-
-            if ( $form->{$category}{$key}{charttype} eq 'A' ) {
-                $form->{"total_$account{$category}{labels}_this_period"} +=
-                  $form->{$category}{$key}{this} * $account{$category}{ml};
-
-                $dash = "- ";
-            }
-
-            push(
-                @{ $form->{"$account{$category}{labels}_this_period"} },
-                $form->format_amount(
-                    $myconfig,
-                    $form->{$category}{$key}{this} * $account{$category}{ml},
-                    $form->{decimalplaces}, $dash
-                )
-            );
-
-            # add amount or - for last period
-            if ($last_period) {
-                $form->{"total_$account{$category}{labels}_last_period"} +=
-                  $form->{$category}{$key}{last} * $account{$category}{ml};
-
-                push(
-                    @{ $form->{"$account{$category}{labels}_last_period"} },
-                    $form->format_amount(
-                        $myconfig,
-                        $form->{$category}{$key}{last} *
-                          $account{$category}{ml},
-                        $form->{decimalplaces},
-                        $dash
-                    )
-                );
-            }
-        }
-
-##        $str = ( $form->{l_heading} ) ? $form->{padding} : "";
-        $str = "";
-        if ( $account{$category}{subtotal} && $form->{l_subtotal} ) {
-            push(
-                @{ $form->{"$account{$category}{label}_account"} }, {
-                    text => "$account{$category}{subdescription}",
-                    subtotal => 1,
-                    },
-            );
-            push(
-                @{ $form->{"$account{$category}{labels}_this_period"} },
-                $form->format_amount(
-                    $myconfig,
-                    $account{$category}{subthis} * $account{$category}{ml},
-                    $form->{decimalplaces}, $dash
-                )
-            );
-
-            if ($last_period) {
-                push(
-                    @{ $form->{"$account{$category}{labels}_last_period"} },
-                    $form->format_amount(
-                        $myconfig,
-                        $account{$category}{sublast} * $account{$category}{ml},
-                        $form->{decimalplaces},
-                        $dash
-                    )
-                );
-            }
-        }
-
-    }
-
-    # 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};
-
-    if ($last_period) {
-
-        # total for income/loss
-        $form->{total_last_period} = $form->format_amount(
-            $myconfig,
-            $form->{total_income_last_period} -
-              $form->{total_expenses_last_period},
-            $form->{decimalplaces},
-            "- "
-        );
-
-        # totals for income and expenses for last_period
-        $form->{total_income_last_period} = $form->format_amount(
-            $myconfig,
-            $form->{total_income_last_period},
-            $form->{decimalplaces}, "- "
-        );
-        $form->{total_expenses_last_period} = $form->format_amount(
-            $myconfig,
-            $form->{total_expenses_last_period},
-            $form->{decimalplaces}, "- "
-        );
-
-    }
-
-    $form->{total_income_this_period} = $form->format_amount(
-        $myconfig,
-        $form->{total_income_this_period},
-        $form->{decimalplaces}, "- "
-    );
-    $form->{total_expenses_this_period} = $form->format_amount(
-        $myconfig,
-        $form->{total_expenses_this_period},
-        $form->{decimalplaces}, "- "
-    );
-    $form->{total_this_period} = $form->format_amount(
-        $myconfig,
-        $form->{total_this_period},
-        $form->{decimalplaces}, "- "
-    );
-
-}
-
 sub balance_sheet {
     my ( $self, $myconfig, $form ) = @_;
 

Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl	2012-07-28 01:08:44 UTC (rev 5053)
+++ trunk/bin/rp.pl	2012-07-28 01:12:17 UTC (rev 5054)
@@ -149,9 +149,6 @@
         $gifi = 0;
         $hiddens{nextsub} = 'generate_inv_activity';
         $subform = 'generate_inv_activity';
-    } elsif ( $form->{report} eq "income_statement" ) {
-        $hiddens{nextsub} = 'generate_income_statement';
-        $subform = 'generate_income_statement';
     } elsif ( $form->{report} eq "balance_sheet" ) {
         $hiddens{nextsub} = 'generate_balance_sheet';
         $subform = 'generate_balance_sheet';
@@ -431,73 +428,6 @@
     });
 }
 
-sub generate_income_statement {
-    init_company_config($form);
-
-    RP->income_statement( \%myconfig, \%$form );
-
-    ( $form->{department} )    = split /--/, $form->{department};
-    ( $form->{projectnumber} ) = split /--/, $form->{projectnumber};
-
-    $form->{period} =
-      $locale->date( \%myconfig, $form->current_date( \%myconfig ), 1 );
-    $form->{todate} = $form->current_date( \%myconfig ) unless $form->{todate};
-
-    # if there are any dates construct a where
-    unless ( $form->{todate} ) {
-        $form->{todate} = $form->current_date( \%myconfig );
-    }
-
-    $longtodate  = $locale->date( \%myconfig, $form->{todate}, 1 );
-    $shorttodate = $locale->date( \%myconfig, $form->{todate}, 0 );
-
-    $longfromdate  = $locale->date( \%myconfig, $form->{fromdate}, 1 );
-    $shortfromdate = $locale->date( \%myconfig, $form->{fromdate}, 0 );
-
-    $form->{this_period_from} = $shortfromdate;
-    $form->{this_period_to} = $shorttodate;
-    # example output: 2006-01-01 To 2007-01-01
-    $form->{period} = $locale->text('[_1] To [_2]', $longfromdate, $longtodate);
-
-    if ( $form->{comparefromdate} || $form->{comparetodate} ) {
-        $longcomparefromdate =
-          $locale->date( \%myconfig, $form->{comparefromdate}, 1 );
-        $shortcomparefromdate =
-          $locale->date( \%myconfig, $form->{comparefromdate}, 0 );
-
-        $longcomparetodate =
-          $locale->date( \%myconfig, $form->{comparetodate}, 1 );
-        $shortcomparetodate =
-          $locale->date( \%myconfig, $form->{comparetodate}, 0 );
-
-        $form->{last_period_from} = $shortcomparefromdate;
-        $form->{last_period_to} = $shortcomparetodate;
-        $form->{compare_period} = $locale->text('[_1] To [_2]',
-            $longcomparefromdate, $longcomparetodate);
-    }
-
-    ##SC: The escaped form will be converted in-template
-    $form->{address} =~ s/\\n/<br>/g;
-
-
-    my $template = LedgerSMB::Template->new(
-        user => \%myconfig, 
-        locale => $locale, 
-        template => 'income_statement',
-        format => 'HTML',
-	#no_escape => '1'
-        );
-    try {
-        $template->render($form);
-        $template->output(%{$form});
-    }
-    catch Error::Simple with {
-        my $E = shift;
-        $form->error( $E->stacktrace );
-    };
-
-}
-
 sub generate_balance_sheet {
     init_company_config($form);
     RP->balance_sheet( \%myconfig, \%$form );

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