diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-06-12 17:13:50 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-06-12 17:13:50 +0000 |
commit | 12c908bf37942a9ac65da380ea24fe3003bafc2a (patch) | |
tree | d3aee22b7810001f5c41e335986bc0d6ac4e37a9 /scripts | |
parent | d0b988e4428f7ce8e5cd8cf79f6f4d2ddbf75ccf (diff) |
Committing Aurynn's changes to Reconciliation logic
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1268 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Reconciliation.pl | 158 | ||||
-rw-r--r-- | scripts/employees.pl | 43 |
2 files changed, 201 insertions, 0 deletions
diff --git a/scripts/Reconciliation.pl b/scripts/Reconciliation.pl new file mode 100644 index 00000000..189eecb4 --- /dev/null +++ b/scripts/Reconciliation.pl @@ -0,0 +1,158 @@ +=pod + +=head1 NAME + +=cut + +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 $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}); +} + +sub search { + my $search = LedgerSMB::Employee->new(base => $request, copy => 'all'); + $employee->{search_results} = $employee->search(); + my $template = LedgerSMB::Template->new( user => $user, + template => 'employee_search.html', language => $user->{language}, + format => 'html'); + $template->render($employee); +} + +=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 $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()); +} + +=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 { + # 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. + + my $template; + my $recon = LedgerSMB::DBObject::Reconciliation->new(base => $request, copy => 'all'); + my $return; + if ($request->{selection}) { + + $template = LedgerSMB::Template->new( user => $user, + template => 'reconciliation_report.html', language => $user->{language}, + format => 'html'); + + $template->render($recon->new_report()); + } + else { + + # Generate the list of available bank statements/bank statements that + # we have access to. + } + return $return; + +} + +=pod + +=over + +=item ($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 $recon = LedgerSMB::DBObject::Reconciliation->new(base => request, copy=> 'all'); + + my $template; + my $report; + if ($recon->approve()) { + + $template = LedgerSMB::Template->new( user => $user, + template => 'reconciliation_approve.html', language => $user->{language}, + format => 'html'); + } + else { + + $template = LedgerSMB::Template->new( user => $user, + 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 diff --git a/scripts/employees.pl b/scripts/employees.pl new file mode 100644 index 00000000..fa9ec05f --- /dev/null +++ b/scripts/employees.pl @@ -0,0 +1,43 @@ +# The handler, prior to handing the execution off to this script will create a +# $request object from the LedgerSMB namespace. This object contains the http +# request parameters, db connections, and the like. A $user object is also +# created +# +# Entrence points are functions which do not begin with an underscore (_) +use LedgerSMB::Template; + +sub save { + my $employee = LedgerSMB::Employee->new(base => $request, copy => 'all'); + $employee->save(); + &_display; +} + +sub search { + my $search = LedgerSMB::Employee->new(base => $request, copy => 'all'); + $employee->{search_results} = $employee->search(); + my $template = LedgerSMB::Template->new( user => $user, + template => 'employee_search.html', language => $user->{language}, + format => 'html'); + $template->render($employee); +} + +sub add { + my $employee = LedgerSMB::Employee->new(base => $request, copy => 'all'); + &_display; +} + +sub edit { + my $employee = LedgerSMB::Employee->new(base => $request, copy => 'all'); + $employee->get(); + &_display; +} + +sub _display { + my $template = LedgerSMB::Template->new( user => $user, + template => 'employee.html', language => $user->{language}, + format => 'html'); + $template->render($employee); + +} + +1; |