diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-06-22 05:01:13 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-06-22 05:01:13 +0000 |
commit | 170174b76910a2916db1a9208597a428ebb9b40d (patch) | |
tree | ea09ceee935ec631d97786bd827cff9dcad2d2eb /scripts | |
parent | 426e5a7263770cee8138d44a8c66a257ed7665de (diff) |
Added version of Aurynn's reconciliation logic
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1302 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Reconciliation.pl | 110 |
1 files changed, 102 insertions, 8 deletions
diff --git a/scripts/Reconciliation.pl b/scripts/Reconciliation.pl index 189eecb4..8826f037 100644 --- a/scripts/Reconciliation.pl +++ b/scripts/Reconciliation.pl @@ -2,8 +2,21 @@ =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; @@ -24,7 +37,7 @@ report_id. =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}, @@ -36,6 +49,7 @@ sub display_report { } sub search { + my ($class, $request) = @_; my $search = LedgerSMB::Employee->new(base => $request, copy => 'all'); $employee->{search_results} = $employee->search(); my $template = LedgerSMB::Template->new( user => $user, @@ -61,14 +75,38 @@ This is to prevent arbitrary editing of the database by unscrupulous users. =cut sub correct { + my ($class, $request) = @_; my $recon = LedgerSMB::DBObject::Reconciliation->new(base => $request, copy => 'all'); - - my $template = LedgerSMB::Template->new( user => $user, - template => 'reconciliation_correct.html', language => $user->{language}, - format => 'html'); + $recon->correct_entry(); - $template->render($recon->get_report()); + + 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() + } ); + } } =pod @@ -88,6 +126,7 @@ it has been created. =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. @@ -116,7 +155,7 @@ sub new_report { =over -=item ($self, $request, $user) +=item approve ($self, $request, $user) Requires report_id @@ -131,6 +170,12 @@ the uncorrected entries. =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. my $recon = LedgerSMB::DBObject::Reconciliation->new(base => request, copy=> 'all'); @@ -148,11 +193,60 @@ sub approve { template => 'reconciliation_report.html', language => $user->{language}, format => 'html'); $report = $recon->get_report(); + ## relies on foreknowledge in the template ## we basically tell the template, we can't approve, this uncorrected ## error is preventing us. + $report->{ error } = { approval => 1 }; } $template->render($report); } -1;
\ No newline at end of file + +=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}) + } + ); +} + +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 |