[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[3725] branches/1.3
- Subject: SF.net SVN: ledger-smb:[3725] branches/1.3
- From: ..hidden..
- Date: Tue, 20 Sep 2011 23:50:01 +0000
Revision: 3725
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3725&view=rev
Author: einhverfr
Date: 2011-09-20 23:50:01 +0000 (Tue, 20 Sep 2011)
Log Message:
-----------
Adding routines to delete reconciliation reports
Fix for emailing statements per John Locke
Modified Paths:
--------------
branches/1.3/LedgerSMB/DBObject/Reconciliation.pm
branches/1.3/UI/reconciliation/report.html
branches/1.3/bin/rp.pl
branches/1.3/scripts/recon.pl
Added Paths:
-----------
branches/1.3/sql/upgrade/3714-drop-recon-delete.sql
Modified: branches/1.3/LedgerSMB/DBObject/Reconciliation.pm
===================================================================
--- branches/1.3/LedgerSMB/DBObject/Reconciliation.pm 2011-09-20 22:11:44 UTC (rev 3724)
+++ branches/1.3/LedgerSMB/DBObject/Reconciliation.pm 2011-09-20 23:50:01 UTC (rev 3725)
@@ -93,6 +93,8 @@
$self->{dbh}->commit;
}
+
+
=item save
Saves the reconciliation set for later work
@@ -184,42 +186,42 @@
}
-=item delete_report ($self, $report_id)
+=item delete ($self, $report_id)
Requires report_id
-Deletes a report based on the report id.
-Stored procedure returns true if deleted, false if not deleted/could not be
-found, and raises EXCEPTION on report already approved.
+This will allow the deletion of a report if the report is not approved and
+the user either owns the unsubmitted report, or the user has the right to
+approve reports.
+Returns 0 if successful, or a true result if not.
+
=cut
-sub delete_report {
+sub delete {
my $self = shift @_;
- my $report_id = shift @_;
-
- my $bool = $self->exec_method(funcname=>'reconciliation__delete_report',
- args=>[$report_id]);
-
- if ($bool) {
- $self->{dbh}->commit();
+ my ($report_id) = @_;
+ my $retval;
+ my $found;
+ if ($self->is_allowed_role({allowed_roles => ['reconciliation_approve']})){
+ ($found) = $self->exec_method(
+ funcname => 'reconciliation__delete_unapproved',
+ args => [$report_id]);
+ } else {
+ ($found) = $self->exec_method(
+ funcname => 'reconciliation__delete_my_report',
+ args => [$report_id]);
+
}
- else{
- $err = $self->{dbh}->errstr();
- $self->{dbh}->rollback();
- if ($err) {
- # It's an exception.
- $self->error("Report delete failed due to previous report submission or approval.");
- }
- else {
-
- # It's due to a non-existant report
- $self->error("Cannot delete non-existant report.");
- }
+ $self->{dbh}->commit;
+ if ($found){
+ $retval = '0';
+ } else {
+ $retval = '1';
}
- return $bool;
+ return $retval;
}
=item add_entries
@@ -275,7 +277,7 @@
sub search {
my $self = shift @_;
- my $type = shift;
+ my $type = shift @_;
return $self->exec_method(
funcname=>'reconciliation__search',
);
@@ -405,8 +407,8 @@
=cut
sub get_accounts {
-
my $self = shift @_;
+
return $self->exec_method(
funcname=>'reconciliation__account_list',
);
Modified: branches/1.3/UI/reconciliation/report.html
===================================================================
--- branches/1.3/UI/reconciliation/report.html 2011-09-20 22:11:44 UTC (rev 3724)
+++ branches/1.3/UI/reconciliation/report.html 2011-09-20 23:50:01 UTC (rev 3725)
@@ -260,5 +260,12 @@
class = "submit"
} ?>
<?lsmb END ?>
+<?lsmb INCLUDE button element_data = {
+ name = "action"
+ text = text('Delete')
+ value = 'delete_report'
+ type = 'submit'
+ class = 'submit'
+} ?>
</form>
</body></html>
Modified: branches/1.3/bin/rp.pl
===================================================================
--- branches/1.3/bin/rp.pl 2011-09-20 22:11:44 UTC (rev 3724)
+++ branches/1.3/bin/rp.pl 2011-09-20 23:50:01 UTC (rev 3725)
@@ -1426,8 +1426,6 @@
unless $form->{subject};
$form->isblank( "email", $locale->text('E-mail address missing!') );
- RP->aging( \%myconfig, $form );
-
my $selected = 0;
RP->aging( \%myconfig, $form );
my $ag = {};
Modified: branches/1.3/scripts/recon.pl
===================================================================
--- branches/1.3/scripts/recon.pl 2011-09-20 22:11:44 UTC (rev 3724)
+++ branches/1.3/scripts/recon.pl 2011-09-20 23:50:01 UTC (rev 3725)
@@ -25,8 +25,6 @@
use Data::Dumper;
use strict;
-=pod
-
=over
=item display_report($self, $request, $user)
@@ -35,8 +33,6 @@
Returns HTML, or raises an error from being unable to find the selected
report_id.
-=back
-
=cut
sub display_report {
@@ -45,21 +41,23 @@
_display_report($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
+=over
+
+=item date_begin
+
+=item date_end
+
+=item account
+
+=item status
+
=back
=cut
@@ -240,14 +238,14 @@
}
-=item
+=item search
Displays search criteria screen
=cut
sub search {
- my ($request,$type) = @_;
+ my ($request) = @_;
my $recon = LedgerSMB::DBObject::Reconciliation->new(base=>$request, copy=>'all');
if (!$recon->{hide_status}){
@@ -266,9 +264,7 @@
return $template->render($recon);
}
-=pod
-=over
=item new_report ($self, $request, $user)
@@ -278,8 +274,6 @@
Allows for an optional selection key, which will return the new report after
it has been created.
-=back
-
=cut
sub _display_report {
@@ -455,53 +449,29 @@
}
-=pod
+=item ($request)
-=over
-
-=item delete_report ($request)
-
Requires report_id
-Deletes the given report_id, and marks whom it was deleted by.
-Will fail if the report does not exist, or if the report has already been
-approved.
+This deletes a report. Reports may not be deleted if approved (this will throw
+a database-level exception). Users may delete their own reports if they have
+not yet been submitted for approval. Those who have approval permissions may
+delete any non-approved reports.
-TO BE DETERMINED:
-Whether or not a delete is permissable by the same user that created the
-report.
-=back
-
=cut
-
+
sub delete_report {
-
-
my ($request) = @_;
- my $recon = LedgerSMB::DBObject::Reconciliation->new(base=>$request, copy=>'all');
-
- # report_id should be set in the request object. It should be an int, and
- # it should correspond to one of the reports.
-
- if ($request->type() eq "POST") {
+ my $recon = LedgerSMB::DBObject::Reconciliation->new(
+ base=>$request,
+ copy=>'all'
+ );
- my $resp = $recon->delete_report($request->{report_id});
+ my $resp = $recon->delete($request->{report_id});
- if ($resp) {
-
- # This is good; we have a true-like response.
- # Drop the report_id and send the request to search()
- delete($request->{report_id});
- return search($request);
- }
- return undef;
- }
- else {
- # this is wrong - We should never get a GET request here. This should
- # throw an error? Or redirect back to the display page?
- return undef;
- }
+ delete($request->{report_id});
+ return search($request);
}
=pod
Added: branches/1.3/sql/upgrade/3714-drop-recon-delete.sql
===================================================================
--- branches/1.3/sql/upgrade/3714-drop-recon-delete.sql (rev 0)
+++ branches/1.3/sql/upgrade/3714-drop-recon-delete.sql 2011-09-20 23:50:01 UTC (rev 3725)
@@ -0,0 +1 @@
+DROP FUNCTION reconciliation__delete_report(in_report_id int);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.