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

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



Revision: 2212
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2212&view=rev
Author:   aurynn_cmd
Date:     2008-07-11 13:10:36 -0700 (Fri, 11 Jul 2008)

Log Message:
-----------
Additions and fixes to the Reconciliation code.

Modified Paths:
--------------
    trunk/LedgerSMB/Reconciliation/CSV.pm

Added Paths:
-----------
    trunk/scripts/recon.pl

Removed Paths:
-------------
    trunk/LedgerSMB/Admin.pm
    trunk/LedgerSMB/DBObject/User.pm
    trunk/LedgerSMB/Employee.pm
    trunk/scripts/reconciliation.pl

Deleted: trunk/LedgerSMB/Admin.pm
===================================================================
--- trunk/LedgerSMB/Admin.pm	2008-07-11 00:42:05 UTC (rev 2211)
+++ trunk/LedgerSMB/Admin.pm	2008-07-11 20:10:36 UTC (rev 2212)
@@ -1,179 +0,0 @@
-package LedgerSMB::DBObject::Admin;
-
-use base LedgerSMB::DBObject;
-
-use LedgerSMB::DBObject::Location;
-use LedgerSMB::DBObject::Employee;
-use LedgerSMB::DBObject::Contact;
-
-sub save_user {
-    
-    my $self = shift @_;
-    
-    my $entity_id = shift @{ $self->exec_method( procname => "save_user" ) };
-    $self->merge($entity_id);
-    
-    my $employee = LedgerSMB::DBObject::Employee->new(base=>$self, copy=>'list',
-        merge=>[
-            'salutation',
-            'first_name',
-            'last_name',
-            'employeenumber',
-        ]    
-    );
-    
-    $employee->{entity_id} = $entity_id->{id};    
-    $employee->save_employee();
-        
-    my $loc = LedgerSMB::DBObject::Location->new(base=>$self, copy=>'list', 
-        merge=>[
-            'address1',
-            'address2',
-            'city',
-            'state',
-            'zipcode',
-            'country',
-            'companyname',            
-        ]
-    );
-    $loc->save_location();
-    $loc->join_to_person(person=>$employee);
-    
-    
-    my $contact = LedgerSMB::DBObject::Contact->new(base=>$self, copy=>'list', 
-        merge=>[
-            'workphone',
-            'homephone',
-            'email',
-        ]
-    );
-    
-    $contact->save_homephone(person=>$employee);
-    $contact->save_workphone(person=>$employee);
-    $contact->save_email(person=>$employee);
-    
-    my $roles = $self->exec_method( procname => "all_roles" );
-    my $user_roles = $self->exec_method(procname => "get_user_roles", args=>[ $self->{ modifying_user } ] );
-    
-    my %active_roles;
-    for my $role (@{$user_roles}) {
-       
-       # These are our user's roles.
-        
-       $active_roles{$role} = 1;
-    }
-    
-    my $status;
-    
-    for my $role ( @{ $roles } ) {
-        
-        # These roles are were ALL checked on the page, so they're the active ones.
-        
-        if ($active_roles{$role} && $self->{incoming_roles}->{$role}) {
-            
-            # do nothing.
-        }
-        elsif ($active_roles{$role} && !($self->{incoming_roles}->{$role} )) {
-            
-            # do remove function
-            $status = $self->exec_method(procname => "remove_user_from_role",
-                args=>[ $self->{ modifying_user }, $role ] 
-        }
-        elsif ($self->{incoming_roles}->{$role} and !($active_roles{$role} )) {
-            
-            # do add function
-            $status = $self->exec_method(procname => "add_user_to_role",
-               args=>[ $self->{ modifying_user }, $role ] 
-            );
-        }         
-    }
-}
-
-sub save_group {
-    
-     my $self = shift @_;
-     
-     my $existant = shift @{ $self->exec_method (procname=> "is_group", args=>[$self->{modifying_group}]) };
-     
-     my $group = shift @{ $self->exec_method (procname=> "save_group") };
-     
-     # first we grab all roles
-     
-     my $roles = $self->exec_method( procname => "all_roles" );
-     my $user_roles = $self->exec_method(procname => "get_user_roles", 
-        args=>[ $self->{ group_name } ] 
-    );
-
-     my %active_roles;
-     for my $role (@{$user_roles}) {
-
-        # These are our user's roles.
-
-        $active_roles{$role} = 1;
-     }
-
-     my $status;
-
-     for my $role ( @{ $roles } ) {
-
-         # These roles are were ALL checked on the page, so they're the active ones.
-
-         if ($active_roles{$role} && $self->{incoming_roles}->{$role}) {
-
-             # we don't need to do anything.
-         }
-         elsif ($active_roles{$role} && !($self->{incoming_roles}->{$role} )) {
-
-             # do remove function
-             $status = $self->exec_method(
-                 procname => "remove_group_from_role",
-                 args=>[ $self->{ modifying_user }, $role ] 
-             );
-         }
-         elsif ($self->{incoming_roles}->{$role} and !($active_roles{$role} )) {
-
-             # do add function
-             $status = $self->exec_method(
-                 procname => "add_group_to_role",
-                 args=>[ $self->{ modifying_user }, $role ] 
-             );
-         }         
-     }     
-}
-
-
-sub delete_user {
-    
-    my $self = shift @_;
-    
-    my $status = shift @{ $self->exec_method(procname=>'delete_user', args=>[$self->{modifying_user}]) };
-    
-    if ($status) {
-        
-        return 1;
-    } else {
-        
-        my $error = LedgerSMB::Error->new("Delete user failed.");
-        $error->set_status($status);
-        return $error;
-    }
-}
-
-sub delete_group {
-    
-    my $self = shift @_;
-    
-    my $status = shift @{ $self->exec_method(procname=>'delete_group', args=>[$self->{groupname}])};
-    
-    if ($status) {
-        
-        return 1;
-    } else {
-        
-        my $error = LedgerSMB::Error->new("Delete group failed.");
-        $error->set_status($status);
-        return $error;
-    }
-}
-
-1;
\ No newline at end of file

Deleted: trunk/LedgerSMB/DBObject/User.pm
===================================================================
--- trunk/LedgerSMB/DBObject/User.pm	2008-07-11 00:42:05 UTC (rev 2211)
+++ trunk/LedgerSMB/DBObject/User.pm	2008-07-11 20:10:36 UTC (rev 2212)
@@ -1,80 +0,0 @@
-package LedgerSMB::DBObject::User;
-
-use base qw/LedgerSMB::DBObject/;
-
-sub save {
-    
-    my $self = shift @_;
-    
-    my $user = $self->get();
-    
-    if ( $user->{id} && $self->{is_a_user} ) {
-    
-        # doesn't check for the password - that's done in the sproc.
-        $self->{id} = shift @{ $self->exec_method(procname=>'admin__save_user', 
-            args=>[$user->{id}, $self->{username}, $self->{password}] ) }; 
-        if (!$self->{id}) {
-            
-            return 0;
-        }
-    }
-    elsif ($user && !$self->{is_a_user}) {
-        
-        # there WAS a user, and we've decided we want that user to go away now.
-        
-        $self->{id} = $user->{id};
-        return $self->remove();
-        
-    }
-    elsif ($self->{is_a_user}) {
-        
-        # No user ID, meaning, creating a new one.        
-        $self->{id} = shift @{ $self->exec_method(procname=>'admin__save_user', 
-            args=>[undef, $self->{username}, $self->{password}] ) };
-    }
-    return 1;
-}
-
-sub get {
-    
-    my $self = shift @_;
-    
-    my ($user_id, $username) = @{ $self->exec_method(procname=>'admin__get_user',
-        args=>[$self->{id}])};
-        
-    return {id=>$user_id, username=>$username};
-}
-
-sub remove {
-    
-    my $self = shift;
-    
-    my $code = $self->exec_method(procname=>"admin__delete_user", args=>[$self->{id}, $self->{username}]);
-    $self->{id} = undef; # never existed..
-    
-    return $code->[0];
-}
-
-sub save_prefs {
-    
-    my $self = shift @_; 
-    
-    my $pref_id = $self->exec_method(procname=>"admin__save_preferences", 
-        args=>[
-            'language',
-            'stylesheet',
-            'printer',
-            'dateformat',
-            'numberformat'
-        ]
-    );
-}
-
-sub get_all_users {
-    
-    my $self = shift @_;
-    
-    $self->{users} = $self->exec_method( procname=>"user__get_all_users" );
-}
-
-1;

Deleted: trunk/LedgerSMB/Employee.pm
===================================================================
--- trunk/LedgerSMB/Employee.pm	2008-07-11 00:42:05 UTC (rev 2211)
+++ trunk/LedgerSMB/Employee.pm	2008-07-11 20:10:36 UTC (rev 2212)
@@ -1,91 +0,0 @@
-
-=head1 NAME
-
-LedgerSMB::Employee - LedgerSMB class for managing Employees 
-
-=head1 SYOPSIS
-
-This module creates object instances based on LedgerSMB's in-database ORM.  
-
-=head1 METHODS
-
-The following method is static:
-
-=over
-
-=item new ($LedgerSMB object);
-
-=back
-
-The following methods are passed through to stored procedures via Autoload.
-
-=over
-
-=item save
-
-=item get
-
-=item search
-
-=item list_managers
-
-The above list may grow over time, and may depend on other installed modules.
-
-=back
-
-=head1 Copyright (C) 2007, The LedgerSMB core team.
-
-This file is licensed under the Gnu General Public License version 2, or at your
-option any later version.  A copy of the license should have been included with
-your software.
-
-=cut
-
-package LedgerSMB::Employee;
-use base qw(LedgerSMB::DBObject);
-use strict;
-our $VERSION = '1.0.0';
-
-sub save {
-    my $self = shift;
-        
-    my $hashref = shift @{ $self->exec_method( procname => "employee_save" ) };
-    $self->merge( $hashref, 'id' );
-}
-
-sub get {
-    my $self = shift;
-    my $hashref = shift @{ $self->exec_method( procname => "employee_get" ) };
-    $self->merge( $hashref, keys %{$hashref} );
-}
-
-sub list_managers {
-    my $self = shift;
-    $self->{manager_list} =
-      $self->exec_method( procname => "employee_list_managers" );
-}
-
-sub search {
-    my $self = shift;
-    $self->{search_results} =
-      $self->exec_method( procname => "employee_search" );
-}
-
-sub set_location {
-    
-    my $self = shift @_;
-    my $location = shift @_;
-    
-    my $code = $self->exec_method ( procname => 'employee_set_location', 
-        args=>[ $self->{id}, $location->{id} ] );
-    
-    if ($code) {
-        
-        # good, it worked.
-        
-        return 1;        
-    }
-    return 0;
-}
-
-1;

Modified: trunk/LedgerSMB/Reconciliation/CSV.pm
===================================================================
--- trunk/LedgerSMB/Reconciliation/CSV.pm	2008-07-11 00:42:05 UTC (rev 2211)
+++ trunk/LedgerSMB/Reconciliation/CSV.pm	2008-07-11 20:10:36 UTC (rev 2212)
@@ -4,7 +4,7 @@
 package LedgerSMB::Reconciliation::CSV;
 
 use base qw/LedgerSMB/;
-use Datetime;
+use DateTime;
 
 sub load_file {
     
@@ -16,7 +16,7 @@
         local $/; # I think this is the right way to outrageously cheat
         open(FH,$filename);
         $contents = <FH>;
-    }
+    };
     return $contents;
 }
 
@@ -30,8 +30,8 @@
         # Unpack for the format it is inexplicably in
         ($accno,
          $checkno,
-         $issuedate
-         $amount
+         $issuedate,
+         $amount,
          $cleared,
          $last_three) = unpack("A10A10A6A10A6A3",$line);
          
@@ -50,9 +50,9 @@
         # First check the account number.
         # According to the docs I have, it's all numbers.
         
-        
+       ; 
     }
-    
+   
     return;
 }
 
@@ -66,4 +66,4 @@
     
 }
 
-1;
\ No newline at end of file
+1;

Copied: trunk/scripts/recon.pl (from rev 2198, trunk/scripts/reconciliation.pl)
===================================================================
--- trunk/scripts/recon.pl	                        (rev 0)
+++ trunk/scripts/recon.pl	2008-07-11 20:10:36 UTC (rev 2212)
@@ -0,0 +1,415 @@
+#!/usr/bin/perl
+=pod
+
+=head1 NAME
+
+LedgerSMB::Scripts::Reconciliation - LedgerSMB class defining the Controller
+functions, template instantiation and rendering.
+
+=head1 SYOPSIS
+
+This module acts as the UI controller class for Reconciliation. It controls
+interfacing with the Core Logic and database layers.
+
+=head1 METHODS
+
+=cut
+
+# NOTE:  This is a first draft modification to use the current parameter type.
+# It will certainly need some fine tuning on my part.  Chris
+
+package LedgerSMB::Scripts::recon;
+
+use LedgerSMB::Template;
+use LedgerSMB::Reconciliation;
+
+=pod
+
+=over
+
+=item display_report($self, $request, $user)
+
+Renders out the selected report given by the incoming variable report_id.
+Returns HTML, or raises an error from being unable to find the selected
+report_id.
+
+=back
+
+=cut
+
+sub display_report {
+    my ($class, $request) = @_;
+    my $recon = LedgerSMB::Employee->new(base => $request, copy => 'all'); 
+    my $template = LedgerSMB::Template->new( user=>$user, 
+        template => "reconciliation/report.html", language => $user->{language},
+            format=>'html'
+        );
+    my $report = $recon->get_report();
+    my $total = $recon->get_total();
+    $template->render({report=>$report, total=>$total, recon=>$recon});
+}
+
+=pod
+
+=over
+
+=item search($self, $request, $user)
+
+Renders out a list of meta-reports based on the search criteria passed to the
+search function.
+Meta-reports are report_id, date_range, and likely errors.
+Search criteria accepted are 
+date_begin
+date_end
+account
+status
+
+=back
+
+=cut
+
+sub search {
+    my ($class, $request) = @_;
+    
+    if ($request->type() eq "POST") {
+        # WE HAS DATUMS
+        # INTENTIONAL BAD PLURALIZATION OF LATIN
+        
+        my $template = LedgerSMB::Template->new(
+            user => $user,
+            template=>'reconciliation/search.html',
+            language=>$user->{language},
+            format=>'html'
+        );
+        return $template->render();
+        
+    } else {
+        my $search = LedgerSMB::Reconciliation->new(base => $request, copy => 'all');
+        my $results = $search->search();
+        my $total = $search->total();
+    
+    
+        my $template = LedgerSMB::Template->new( user => $user, 
+    	    template => 'reconciliation/report.html', language => $user->{language}, 
+            format => 'html');
+        return $template->render({report => $results, total => $total});
+    }
+}
+
+=pod
+
+=over
+
+=item correct ($self, $request, $user)
+
+Requires report_id, entry_id.
+
+Correct is a strange one. Based on the type of transaction listed in the
+report, it will run one of several correction functions in the database.
+This is to prevent arbitrary editing of the database by unscrupulous users.
+
+=back
+
+=cut
+
+sub correct {
+    my ($class, $request) = @_;
+    
+    if ($request->type() eq "POST") {
+        
+        my $recon = LedgerSMB::DBObject::Reconciliation->new(base => $request, copy => 'all');
+
+        $recon->correct_entry();
+        
+        #  Are we getting data?
+        if ($recon->{corrected_id}) {
+
+            my $template = LedgerSMB::Template->new( user => $user, 
+        	template => 'reconciliation/report.html', language => $user->{language}, 
+                format => 'html');
+
+            $template->render( { 
+                corrected=> $recon->{corrected_id}, 
+                report=> $recon->get_report(),
+                total=> $recon->get_total()
+            } );
+        } 
+        else {
+
+            # indicate we were unable to correct this entry, with the error code 
+            # spat back to us by the DB.
+            my $template = LedgerSMB::Template->new( user => $user, 
+        	template => 'reconciliation/report.html', language => $user->{language}, 
+                format => 'html');
+
+            $template->render( { 
+                recon   => $recon,
+                report  => $recon->get_report(),
+                total   => $recon->get_total()
+            } );
+        }
+    }
+    else {
+        
+        # We are not getting data sent
+        # ergo, we render out stuff.
+        
+        if ($request->{report_id} && $request->{entry_id}) {
+            
+            # draw the editor interface.
+            
+            my $template = LedgerSMB::Template->new(
+                user=>$user,
+                template=>"reconciliation/correct.html",
+                language=> $user->{language},
+                format=>'html'
+            );
+            my $recon = LedgerSMB::DBObject::Reconciliation->new(base=>$request, copy=>'all');
+            
+            $template->render($recon->details($request->{report_id}));
+        }
+        elsif ($request->{report_id}) {
+            
+            my $template = LedgerSMB::Template->new(
+                user=>$user,
+                template=>"reconciliation/correct.html",
+                language=> $user->{language},
+                format=>'html'
+            );
+            $class->display_report();
+        }
+    }
+    
+}
+
+=pod
+
+=over
+
+=item new_report ($self, $request, $user)
+
+Creates a new report, from a selectable set of bank statements that have been
+received (or can be received from, depending on implementation)
+
+Allows for an optional selection key, which will return the new report after
+it has been created.
+
+=back
+
+=cut
+
+sub new_report {
+    my ($class, $request) = @_;
+    # how are we going to allow this to be created? Grr.
+    # probably select a list of statements that are available to build 
+    # reconciliation reports with.
+    
+    # This should do some fun stuff.
+    
+    my $template;
+    my $return;
+    
+    if ($request->type() eq "POST") {
+        
+        # We can assume that we're doing something useful with new data.
+        # We can also assume that we've got a file.
+        my $recon = LedgerSMB::DBObject::Reconciliation->new(base => $request, copy => 'all');
+        
+        # $self is expected to have both the file handling logic, as well as 
+        # the logic to load the processing module.
+        
+        # Why isn't this testing for errors?
+        my ($report_id, $entries) = $recon->new_report($recon->import_file());
+        if ($recon->is_error()) {
+            
+            $template = LedgerSMB::Template->new(
+                user=>$user,
+                template=> 'reconciliation/upload.html',
+                language=>$user->{language},
+                format=>'html'
+            );
+            return $template->render({error=>$recon->error()});
+        }
+        
+        $template = LedgerSMB::Template->new( 
+            user=> $user,
+            template => 'reconciliation/new_report.html', 
+            language => $user->{language},
+            format=>'html'        
+        );
+        return $template->render(
+            {
+                entries=>$entries,
+                report_id=>$report_id
+            }
+        );
+    }
+    else {
+        
+        # we can assume we're to generate the "Make a happy new report!" page.
+        $template = LedgerSMB::Template->new( 
+            user => $user, 
+            template => 'reconciliation/upload.html', 
+            language => $user->{language}, 
+            format => 'html'
+        );
+        return $template->render();
+    }
+    return undef;
+    
+}
+
+=pod
+
+=over
+
+=item approve ($self, $request, $user)
+
+Requires report_id
+
+Approves the given report based on id. Generally, the roles should be 
+configured so as to disallow the same user from approving, as created the report.
+
+Returns a success page on success, returns a new report on failure, showing 
+the uncorrected entries.
+
+=back
+
+=cut
+
+sub approve {
+    my ($class, $request) = @_;
+    
+    # Approve will also display the report in a blurred/opaqued out version,
+    # with the controls removed/disabled, so that we know that it has in fact
+    # been cleared. This will also provide for return-home links, auditing, 
+    # etc.
+    
+    if ($request->type() eq "POST") {
+        
+        # we need a report_id for this.
+        
+        my $recon = LedgerSMB::DBObject::Reconciliation->new(base => request, copy=> 'all');
+
+        my $template;
+        my $code = $recon->approve($request->{report_id});
+        if ($code == 0) {
+
+            $template = LedgerSMB::Template->new( user => $user, 
+        	template => 'reconciliation/approve.html', language => $user->{language}, 
+                format => 'html');
+                
+            return $template->render();
+        }
+        else {
+            
+            # failure case
+            
+            $template = LedgerSMB::Template->new( 
+                user => $user, 
+        	    template => 'reconciliation/report.html', 
+        	    language => $user->{language}, 
+                format => 'html');
+            return $template->render(
+                {
+                    entries=>$recon->get_report($request->{report_id}),
+                    total=>$recon->get_total($request->{report_id}),
+                    error_code => $code
+                }
+            );
+        }
+    }
+    else {
+        return $class->display_report($request);
+    }
+}
+
+=pod
+
+=over
+
+=item corrections ($self, $request, $user)
+
+Requires report_id and entry_id.
+
+Loads the selected entry id and all corrections associated with it. If there
+aren't any corrections, it will display "no corrections found".
+=back
+
+=cut
+
+sub corrections {
+    my ($class, $request) = @_;
+    
+    # Load the corrections for a given report & entry id.
+    # possibly should use a "micro" popup window?
+    
+    my $recon = LedgerSMB::DBObject::Reconciliation->new(base => request, copy=> 'all');
+    
+    my $template;
+        
+    $template = LedgerSMB::Template->new( user => $user, 
+	template => 'reconciliation/corrected.html', language => $user->{language}, 
+        format => 'html');
+    
+    return $template->render(
+        {
+            corrections=>$recon->get_corrections(), 
+            entry=>$recon->entry($self->{report_id}, $self->{entry_id})
+        }
+    );
+}
+
+=pod
+
+=over
+
+=item pending ($self, $request, $user)
+
+Requires {date} and {month}, to handle the month-to-month pending transactions
+in the database. No mechanism is provided to grab ALL pending transactions 
+from the acc_trans table.
+
+=back
+
+=cut
+
+
+sub pending {
+    
+    my ($class, $request) = @_;
+    
+    my $recon = LedgerSMB::DBObject::Reconciliation->new(base=>request, copy=>'all');
+    my $template;
+    
+    $template= LedgerSMB::Template->new(
+        user => $user,
+        template=>'reconciliation/pending.html',
+        language=>$user->{language},
+        format=>'html'
+    );
+    if ($request->type() eq "POST") {
+        return $template->render(
+            {
+                pending=>$recon->get_pending($request->{year}."-".$request->{month})
+            }
+        );
+    } 
+    else {
+        
+        return $template->render();
+    }
+}
+
+# eval { do "scripts/custom/Reconciliation.pl" };
+1;
+
+=pod
+
+=head1 Copyright (C) 2007, The LedgerSMB core team.
+
+This file is licensed under the Gnu General Public License version 2, or at your
+option any later version.  A copy of the license should have been included with
+your software.
+
+=cut

Deleted: trunk/scripts/reconciliation.pl
===================================================================
--- trunk/scripts/reconciliation.pl	2008-07-11 00:42:05 UTC (rev 2211)
+++ trunk/scripts/reconciliation.pl	2008-07-11 20:10:36 UTC (rev 2212)
@@ -1,414 +0,0 @@
-=pod
-
-=head1 NAME
-
-LedgerSMB::Scripts::Reconciliation - LedgerSMB class defining the Controller
-functions, template instantiation and rendering.
-
-=head1 SYOPSIS
-
-This module acts as the UI controller class for Reconciliation. It controls
-interfacing with the Core Logic and database layers.
-
-=head1 METHODS
-
-=cut
-
-# NOTE:  This is a first draft modification to use the current parameter type.
-# It will certainly need some fine tuning on my part.  Chris
-
-package LedgerSMB::Scripts::Reconciliation;
-
-use LedgerSMB::Template;
-use LedgerSMB::DBObject::Reconciliation;
-
-=pod
-
-=over
-
-=item display_report($self, $request, $user)
-
-Renders out the selected report given by the incoming variable report_id.
-Returns HTML, or raises an error from being unable to find the selected
-report_id.
-
-=back
-
-=cut
-
-sub display_report {
-    my ($class, $request) = @_;
-    my $recon = LedgerSMB::Employee->new(base => $request, copy => 'all'); 
-    my $template = LedgerSMB::Template->new( user=>$user, 
-        template => "reconciliation/report.html", language => $user->{language},
-            format=>'html'
-        );
-    my $report = $recon->get_report();
-    my $total = $recon->get_total();
-    $template->render({report=>$report, total=>$total, recon=>$recon});
-}
-
-=pod
-
-=over
-
-=item search($self, $request, $user)
-
-Renders out a list of meta-reports based on the search criteria passed to the
-search function.
-Meta-reports are report_id, date_range, and likely errors.
-Search criteria accepted are 
-date_begin
-date_end
-account
-status
-
-=back
-
-=cut
-
-sub search {
-    my ($class, $request) = @_;
-    
-    if ($request->type() eq "POST") {
-        # WE HAS DATUMS
-        # INTENTIONAL BAD PLURALIZATION OF LATIN
-        
-        my $template = LedgerSMB::Template->new(
-            user => $user,
-            template=>'reconciliation/search.html',
-            language=>$user->{language},
-            format=>'html'
-        );
-        return $template->render();
-        
-    } else {
-        my $search = LedgerSMB::Reconciliation->new(base => $request, copy => 'all');
-        my $results = $search->search();
-        my $total = $search->total();
-    
-    
-        my $template = LedgerSMB::Template->new( user => $user, 
-    	    template => 'reconciliation/report.html', language => $user->{language}, 
-            format => 'html');
-        return $template->render({report => $results, total => $total});
-    }
-}
-
-=pod
-
-=over
-
-=item correct ($self, $request, $user)
-
-Requires report_id, entry_id.
-
-Correct is a strange one. Based on the type of transaction listed in the
-report, it will run one of several correction functions in the database.
-This is to prevent arbitrary editing of the database by unscrupulous users.
-
-=back
-
-=cut
-
-sub correct {
-    my ($class, $request) = @_;
-    
-    if ($request->type() eq "POST") {
-        
-        my $recon = LedgerSMB::DBObject::Reconciliation->new(base => $request, copy => 'all');
-
-        $recon->correct_entry();
-        
-        #  Are we getting data?
-        if ($recon->{corrected_id}) {
-
-            my $template = LedgerSMB::Template->new( user => $user, 
-        	template => 'reconciliation/report.html', language => $user->{language}, 
-                format => 'html');
-
-            $template->render( { 
-                corrected=> $recon->{corrected_id}, 
-                report=> $recon->get_report(),
-                total=> $recon->get_total()
-            } );
-        } 
-        else {
-
-            # indicate we were unable to correct this entry, with the error code 
-            # spat back to us by the DB.
-            my $template = LedgerSMB::Template->new( user => $user, 
-        	template => 'reconciliation/report.html', language => $user->{language}, 
-                format => 'html');
-
-            $template->render( { 
-                recon   => $recon,
-                report  => $recon->get_report(),
-                total   => $recon->get_total()
-            } );
-        }
-    }
-    else {
-        
-        # We are not getting data sent
-        # ergo, we render out stuff.
-        
-        if ($request->{report_id} && $request->{entry_id}) {
-            
-            # draw the editor interface.
-            
-            my $template = LedgerSMB::Template->new(
-                user=>$user,
-                template=>"reconciliation/correct.html",
-                language=> $user->{language},
-                format=>'html'
-            );
-            my $recon = LedgerSMB::DBObject::Reconciliation->new(base=>$request, copy=>'all');
-            
-            $template->render($recon->details($request->{report_id}));
-        }
-        elsif ($request->{report_id}) {
-            
-            my $template = LedgerSMB::Template->new(
-                user=>$user,
-                template=>"reconciliation/correct.html",
-                language=> $user->{language},
-                format=>'html'
-            );
-            $class->display_report();
-        }
-    }
-    
-}
-
-=pod
-
-=over
-
-=item new_report ($self, $request, $user)
-
-Creates a new report, from a selectable set of bank statements that have been
-received (or can be received from, depending on implementation)
-
-Allows for an optional selection key, which will return the new report after
-it has been created.
-
-=back
-
-=cut
-
-sub new_report {
-    my ($class, $request) = @_;
-    # how are we going to allow this to be created? Grr.
-    # probably select a list of statements that are available to build 
-    # reconciliation reports with.
-    
-    # This should do some fun stuff.
-    
-    my $template;
-    my $return;
-    
-    if ($request->type() eq "POST") {
-        
-        # We can assume that we're doing something useful with new data.
-        # We can also assume that we've got a file.
-        my $recon = LedgerSMB::DBObject::Reconciliation->new(base => $request, copy => 'all');
-        
-        # $self is expected to have both the file handling logic, as well as 
-        # the logic to load the processing module.
-        
-        # Why isn't this testing for errors?
-        my ($report_id, $entries) = $recon->new_report($recon->import_file());
-        if ($recon->is_error()) {
-            
-            $template = LedgerSMB::Template->new(
-                user=>$user,
-                template=> 'reconciliation/upload.html',
-                language=>$user->{language},
-                format=>'html'
-            );
-            return $template->render({error=>$recon->error()});
-        }
-        
-        $template = LedgerSMB::Template->new( 
-            user=> $user,
-            template => 'reconciliation/new_report.html', 
-            language => $user->{language},
-            format=>'html'        
-        );
-        return $template->render(
-            {
-                entries=>$entries,
-                report_id=>$report_id
-            }
-        );
-    }
-    else {
-        
-        # we can assume we're to generate the "Make a happy new report!" page.
-        $template = LedgerSMB::Template->new( 
-            user => $user, 
-            template => 'reconciliation/upload.html', 
-            language => $user->{language}, 
-            format => 'html'
-        );
-        return $template->render();
-    }
-    return undef;
-    
-}
-
-=pod
-
-=over
-
-=item approve ($self, $request, $user)
-
-Requires report_id
-
-Approves the given report based on id. Generally, the roles should be 
-configured so as to disallow the same user from approving, as created the report.
-
-Returns a success page on success, returns a new report on failure, showing 
-the uncorrected entries.
-
-=back
-
-=cut
-
-sub approve {
-    my ($class, $request) = @_;
-    
-    # Approve will also display the report in a blurred/opaqued out version,
-    # with the controls removed/disabled, so that we know that it has in fact
-    # been cleared. This will also provide for return-home links, auditing, 
-    # etc.
-    
-    if ($request->type() eq "POST") {
-        
-        # we need a report_id for this.
-        
-        my $recon = LedgerSMB::DBObject::Reconciliation->new(base => request, copy=> 'all');
-
-        my $template;
-        my $code = $recon->approve($request->{report_id});
-        if ($code == 0) {
-
-            $template = LedgerSMB::Template->new( user => $user, 
-        	template => 'reconciliation/approve.html', language => $user->{language}, 
-                format => 'html');
-                
-            return $template->render();
-        }
-        else {
-            
-            # failure case
-            
-            $template = LedgerSMB::Template->new( 
-                user => $user, 
-        	    template => 'reconciliation/report.html', 
-        	    language => $user->{language}, 
-                format => 'html');
-            return $template->render(
-                {
-                    entries=>$recon->get_report($request->{report_id}),
-                    total=>$recon->get_total($request->{report_id}),
-                    error_code => $code
-                }
-            );
-        }
-    }
-    else {
-        return $class->display_report($request);
-    }
-}
-
-=pod
-
-=over
-
-=item corrections ($self, $request, $user)
-
-Requires report_id and entry_id.
-
-Loads the selected entry id and all corrections associated with it. If there
-aren't any corrections, it will display "no corrections found".
-=back
-
-=cut
-
-sub corrections {
-    my ($class, $request) = @_;
-    
-    # Load the corrections for a given report & entry id.
-    # possibly should use a "micro" popup window?
-    
-    my $recon = LedgerSMB::DBObject::Reconciliation->new(base => request, copy=> 'all');
-    
-    my $template;
-        
-    $template = LedgerSMB::Template->new( user => $user, 
-	template => 'reconciliation/corrected.html', language => $user->{language}, 
-        format => 'html');
-    
-    return $template->render(
-        {
-            corrections=>$recon->get_corrections(), 
-            entry=>$recon->entry($self->{report_id}, $self->{entry_id})
-        }
-    );
-}
-
-=pod
-
-=over
-
-=item pending ($self, $request, $user)
-
-Requires {date} and {month}, to handle the month-to-month pending transactions
-in the database. No mechanism is provided to grab ALL pending transactions 
-from the acc_trans table.
-
-=back
-
-=cut
-
-
-sub pending {
-    
-    my ($class, $request) = @_;
-    
-    my $recon = LedgerSMB::DBObject::Reconciliation->new(base=>request, copy=>'all');
-    my $template;
-    
-    $template= LedgerSMB::Template->new(
-        user => $user,
-        template=>'reconciliation/pending.html',
-        language=>$user->{language},
-        format=>'html'
-    );
-    if ($request->type() eq "POST") {
-        return $template->render(
-            {
-                pending=>$recon->get_pending($request->{year}."-".$request->{month});
-            }
-        );
-    } 
-    else {
-        
-        return $template->render();
-    }
-}
-
-# eval { do "scripts/custom/Reconciliation.pl" };
-1;
-
-=pod
-
-=head1 Copyright (C) 2007, The LedgerSMB core team.
-
-This file is licensed under the Gnu General Public License version 2, or at your
-option any later version.  A copy of the license should have been included with
-your software.
-
-=cut


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