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

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



Revision: 5374
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5374&view=rev
Author:   einhverfr
Date:     2012-12-17 15:44:19 +0000 (Mon, 17 Dec 2012)
Log Message:
-----------
Moving reconciliation report search to 1.4 reporting framework (no menu change required

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Reconciliation.pm
    trunk/LedgerSMB/Report/Invoices/Payments.pm
    trunk/LedgerSMB/Scripts/recon.pm
    trunk/sql/modules/Reconciliation.sql

Added Paths:
-----------
    trunk/LedgerSMB/Report/Reconciliation/
    trunk/LedgerSMB/Report/Reconciliation/Summary.pm
    trunk/UI/Reports/filters/reconciliation_search.html

Removed Paths:
-------------
    trunk/UI/reconciliation/search.html

Modified: trunk/LedgerSMB/DBObject/Reconciliation.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Reconciliation.pm	2012-12-17 11:06:17 UTC (rev 5373)
+++ trunk/LedgerSMB/DBObject/Reconciliation.pm	2012-12-17 15:44:19 UTC (rev 5374)
@@ -263,26 +263,6 @@
     $self->{dbh}->commit;
 }
 
-=item search
-
-Searches for reconciliation reports.  No inputs mandatory.
-
-date_from and date_to specify ranges.
-balance_from and balance_to specify ranges
-chart_id specifies an account
-submitted and approved are exact matches to status.
-
-=cut
-
-sub search {
-    
-    my $self = shift @_;
-    my $type = shift @_;
-    return $self->exec_method(
-        funcname=>'reconciliation__search',
-    );
-}
-
 =item get
 
 Gets all information relating to a reconciliation report.

Modified: trunk/LedgerSMB/Report/Invoices/Payments.pm
===================================================================
--- trunk/LedgerSMB/Report/Invoices/Payments.pm	2012-12-17 11:06:17 UTC (rev 5373)
+++ trunk/LedgerSMB/Report/Invoices/Payments.pm	2012-12-17 15:44:19 UTC (rev 5374)
@@ -234,7 +234,7 @@
         type => 'submit',
        class => 'submit',
        value => 'reverse_payments',
-    }]);
+    }]) if $self->batch_id;
 }
 
 =back

Added: trunk/LedgerSMB/Report/Reconciliation/Summary.pm
===================================================================
--- trunk/LedgerSMB/Report/Reconciliation/Summary.pm	                        (rev 0)
+++ trunk/LedgerSMB/Report/Reconciliation/Summary.pm	2012-12-17 15:44:19 UTC (rev 5374)
@@ -0,0 +1,225 @@
+=head1 NAME
+
+LedgerSMB::Report::Reconciliation::Summary - List of Reconciliation Reports for
+LedgerSMB
+
+=head1 SYNPOSIS
+
+ my $report = LedgerSMB::Report::Reconciliation::Summary->new(%$request);
+ $report->render($request);
+
+=cut
+
+package LedgerSMB::Report::Reconciliation::Summary;
+use Moose;
+use LedgerSMB::MooseTypes;
+extends "LedgerSMB::Report";
+with "LedgerSMB::Report::Dates";
+
+=head1 DESCRIPTION
+
+This report allows for searching reconciliation reports.  The reports are then 
+accessed by clicking on the hyperlinks and can be then approved or denied.
+
+LedgerSMB follows a two-stage bank reconciliation process.  In the first stage,
+the reconciliation data is entered, reviewed by the one who entered it, and
+submitted for approval.  Prior to submission the data entry individual can
+continue to work on the reconciliation report, entering missing items, etc.
+After this is submitted, the only possible options are approval or removal.
+
+This report is typically used in two contexts.  The first is in the approval
+process, where this provides the basic search routines.  The second is in
+checking past reconciliation report information to see what exactly was
+reconciled in a specific report.
+
+=head1 CRITERIA PROPERTIES
+
+=over
+
+=item amount_from
+
+Only show reports where the amount is greater or equal to this
+
+=cut
+
+has amount_from => (is => 'ro', isa => 'LedgerSMB::Moose::Number', 
+              required => 0, coerce => 1);
+
+=item amount_to
+
+Only show reports where the amount is less than or equal to this
+
+=cut
+
+has amount_to => (is => 'ro', isa => 'LedgerSMB::Moose::Number', required => 0, 
+              coerce => 1);
+
+=item account_id 
+
+Show repoirts only for this specific account
+
+=cut
+
+has account_id => (is => 'ro', isa => 'Int', required => 0);
+
+=item approved
+
+If undef, show all reports, if true, show approved ones and if false show 
+unapproved ones.
+
+=cut
+
+has approved => (is => 'ro', isa => 'Bool', required => 0);
+
+=item submitted
+
+If undef, show all reports, if true, show ones submitted for approval, and if
+false only show reports in progress.
+
+Note that approved being set to true and submitted bein set to false will never
+match any reports.
+
+=cut
+
+has submitted => (is => 'ro', isa => 'Bool', required => 0);
+
+=back
+
+=head1 INTERNALS
+
+=head2 columns
+
+=over
+
+=item account
+
+This is the account label for recon purposes
+
+=item end_date
+
+This is the statement date.
+
+=item their_total
+
+The bank statement total.
+
+=item approved
+
+0 for not, 1 for approved
+
+=item submitted 
+
+0 for not, 1 for approved
+
+=item updated_timestamp
+
+This is used to indicated when a reconciliation report was last updated for data
+entry purposes.
+
+=item entered_by
+
+Username of the one who entered the report
+
+=item approved_by
+
+Username of the one who approved the report
+
+=cut
+
+sub columns {
+    return [ {col_id => 'account',
+                name => LedgerSMB::Report::text('Account'),
+                type => 'text', },
+             {col_id => 'end_date',
+                name => LedgerSMB::Report::text('Statement Date'),
+                type => 'href',
+           href_base => "recon.pl?action=display_report&report_id=", },
+             {col_id => 'their_total',
+                name => LedgerSMB::Report::text('Statement Balance'),
+                type => 'text', },
+             {col_id => 'approved',
+                name => LedgerSMB::Report::text('Approved'),
+                type => 'text', },
+             {col_id => 'submitted',
+                name => LedgerSMB::Report::text('Submitted'),
+                type => 'text', },
+             {col_id => 'updated',
+                name => LedgerSMB::Report::text('Last Updated'),
+                type => 'text', },
+             {col_id => 'entered_by',
+                name => LedgerSMB::Report::text('Entered By'),
+                type => 'text', },
+             {col_id => 'approved_by',
+                name => LedgerSMB::Report::text('Approved By'),
+                type => 'text', },
+          ];
+}
+
+             
+
+=back
+
+=cut
+
+=head2 header_lines
+
+=over
+
+=back
+
+=cut
+
+sub header_lines {
+    return [{name => 'date_from',  
+             text => LedgerSMB::Report::text('From Date')},
+            {name => 'date_to',
+             text => LedgerSMB::Report::text('To Date') },
+            {name => 'amount_from',
+             text => LedgerSMB::Report::text('From Amount')},
+            {name => 'amount_to',
+             text => LedgerSMB::Report::text('To Amount')}
+     ];
+}
+
+=head2 name
+
+"Reconciliation Reports"
+
+=cut
+
+sub name {
+    return LedgerSMB::Report::text('Reconciliation Reports');
+}
+
+=head1 METHODS
+
+=head2 run_report
+
+=cut
+
+sub run_report {
+    my ($self) = @_;
+    my @rows = $self->exec_method({funcname => 'reconciliation__search'});
+    my @accounts = $self->exec_method(
+            {funcname => 'reconciliation__account_list'}
+    );
+    my $account = {};
+    for my $a (@accounts){
+       $account->{$a->{id}} = $a;
+    }
+    for my $r (@rows){
+        $r->{account} = $account->{$r->{chart_id}}->{name};
+        $r->{row_id} = $r->{id};
+    }
+    $self->rows(..hidden..);
+}
+
+=head1 COPYRIGHT
+
+COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the
+terms of the LedgerSMB General Public License version 2 or at your option any
+later version.  Please see enclosed LICENSE file for details.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;

Modified: trunk/LedgerSMB/Scripts/recon.pm
===================================================================
--- trunk/LedgerSMB/Scripts/recon.pm	2012-12-17 11:06:17 UTC (rev 5373)
+++ trunk/LedgerSMB/Scripts/recon.pm	2012-12-17 15:44:19 UTC (rev 5374)
@@ -21,6 +21,8 @@
 use LedgerSMB::Template;
 use LedgerSMB::DBObject::Reconciliation;
 use LedgerSMB::Setting;
+use LedgerSMB::Scripts::reports;
+use LedgerSMB::Report::Reconciliation::Summary;
 use Data::Dumper;
 use strict;
 
@@ -146,95 +148,8 @@
 
 sub get_results {
     my ($request) = @_;
-    $request->close_form;
-    $request->open_form({commit =>1});
-        if ($request->{approved} ne '1' and $request->{approved} ne '0'){
-		$request->{approved} = undef;
-        }
-        if ($request->{submitted} ne '1' and $request->{submitted} ne '0'){
-		$request->{submitted} = undef;
-        }
-        my $search = LedgerSMB::DBObject::Reconciliation->new(base => $request, copy => 'all');
-        if ($search->{order_by}){
-            $search->set_ordering({
-			method => 'reconciliation__search', 
-			column => $search->{order_by},
-            });
-        }
-        my @results = $search->search();
-        my @accounts = $search->get_accounts();
-        my $act_hash = {};
-        for my $act (@accounts){
-            $act_hash->{"$act->{id}"} = $act->{name};
-        }
-        for my $row (@results){
-            $row->{account} = $act_hash->{"$row->{chart_id}"};
-        }
-        my $base_url = "recon.pl?action=display_report";
-        my $search_url = "recon.pl?action=get_results".
-            "&date_from=$search->{date_from}&date_to=$search->{date_to}".
-             "&amount_from=$search->{amount_from}&".
-             "amount_to=$search->{amount_to}&chart_id=$search->{chart_id}".
-             "&approved=$search->{approved}&submitted=$search->{submitted}";
-        
-        my $column_names = {
-            "select" => 'Select',
-            account => 'Account',
-            their_total => 'Balance',
-            end_date => 'Statement Date',
-            submitted => 'Submitted',
-            approved => 'Approved',
-            updated => 'Last Updated',
-            entered_username => 'Entered By',
-            approved_username => 'Approved By'
-        };
-        my $sort_href = "$search_url&order_by";
-        my @sort_columns = qw(account their_total end_date submitted 
-            approved updated entered_username approved_username);
-        
-	my $cols = [];
-	my @acts = $search->get_accounts;
-	@$cols = qw(select account end_date their_total approved submitted 
-                    updated entered_username approved_username);
-	my $recon =$search;
-	for my $row(@results){
-            my $act = undef;
-            for (@acts){
-                if ($_->{id} == $row->{chart_id}){
-                    $act = $_->{name};
-                }
-                last if $act;
-            }
-            $row->{account} = $act;
-            $row->{their_total} = $recon->format_amount(
-		{amount => $row->{their_total}, money => 1}); 
-            $row->{end_date} = {
-                text => $row->{end_date}, 
-                href => "$base_url&report_id=$row->{id}"
-            };
-        }
-	$recon->{_results} = ..hidden..;
-        $recon->{title} = $request->{_locale}->text('Reconciliation Sets');
-        my $template = LedgerSMB::Template->new( 
-            locale => $request->{_locale},
-            user => $request->{_user}, 
-    	    template => 'form-dynatable', 
-            locale => $request->{_locale},
-            format => 'HTML',
-            path=>"UI");
-        
-        my $column_heading = $template->column_heading($column_names,
-            {href => $sort_href, columns => ..hidden..
-        );
-        
-        return $template->render({
-		form     => $recon,
-		heading  => $column_heading,
-        	hiddens  => $recon,
-		columns  => $cols,
-		rows     => ..hidden..
-	});
-        
+    my $report = LedgerSMB::Report::Reconciliation::Summary->new(%$request);
+    $report->render($request);
 }
 
 =item search
@@ -251,16 +166,10 @@
             $recon->{show_approved} = 1;        
             $recon->{show_submitted} = 1;        
         }
-        @{$recon->{account_list}} = $recon->get_accounts();
-	unshift @{$recon->{account_list}}, {id => '', name => '' };
-        my $template = LedgerSMB::Template->new(
-            user => $request->{_user},
-            template=>'search',
-            locale => $request->{_locale},
-            format=>'HTML',
-            path=>"UI/reconciliation",
-        );
-        return $template->render($recon);
+        @{$recon->{recon_accounts}} = $recon->get_accounts();
+	unshift @{$recon->{recon_accounts}}, {id => '', name => '' };
+    $recon->{report_name} = 'reconciliation_search';
+    LedgerSMB::Scripts::reports::start_report($recon);
 }
 
 

Copied: trunk/UI/Reports/filters/reconciliation_search.html (from rev 5367, trunk/UI/reconciliation/search.html)
===================================================================
--- trunk/UI/Reports/filters/reconciliation_search.html	                        (rev 0)
+++ trunk/UI/Reports/filters/reconciliation_search.html	2012-12-17 15:44:19 UTC (rev 5374)
@@ -0,0 +1,107 @@
+<?lsmb PROCESS 'ui-header.html' ?>
+<?lsmb PROCESS 'elements.html' ?>
+
+<div class="title"><?lsmb text('Search Reconciliation Reports') ?></div>
+        
+<div class="body">
+        <form name="reconciliation__search" method="post" action="recon.pl" id="reconciliation__search">
+            <div>
+		<?lsmb INCLUDE input element_data = {
+			label = text('Date From'), #'
+			type = 'text',
+			class = 'date',
+			size = 12,
+			value = date_from,
+			name = 'date_from'
+		} ?>
+		<?lsmb INCLUDE input element_data = {
+			label = text('To:'), 
+			type = 'text',
+			class = 'date',
+			size = 12,
+			value = date_to,
+			name = 'date_to'
+		} ?>
+            </div>
+            <div>
+		<?lsmb INCLUDE input element_data = {
+			label = text('Amount From'), #'
+			type = 'text',
+			class = 'money',
+			size = 12,
+			value = amount_from,
+			name = 'amount_from'
+		} ?>
+		<?lsmb INCLUDE input element_data = {
+			label = text('To:'), 
+			type = 'text',
+			class = 'money',
+			size = 12,
+			value = amount_to,
+			name = 'amount_to'
+		} ?>
+            </div>
+            <div>
+            <div>
+		<?lsmb INCLUDE select element_data = {
+			label = text('Account:'),
+			class = "chart_id",
+                        name = "account_id",
+			options = recon_accounts,
+			text_attr = 'name',
+			value_attr = 'id'
+		} ?>
+            </div>
+            <div>
+		<?lsmb IF show_approved ?>
+			<?lsmb- approved_options = [
+				{id = undef, label = undef },
+				{id = '1', label = text('Approved') },
+				{id = '0', label = text('Not Approved') } #'
+			];
+			PROCESS select element_data = {
+				name = 'approved',
+				label = text('Approval Status'), #'
+				options = approved_options
+				text_attr = 'label',
+				value_attr = 'id',
+				class = 'status'
+			} -?>
+		<?lsmb ELSE ?>
+		<?lsmb INCLUDE input element_data = {
+			type = "hidden",
+			name = "approved",
+			value = approved
+		} ?>
+		<?lsmb END ?>
+		<?lsmb IF show_submitted ?>
+			<?lsmb- submitted_options = [
+				{id = undef, label = undef },
+				{id = '1', label = text('Submitted') },
+				{id = '0', label = text('Not Submitted') } #'
+			];
+			PROCESS select element_data = {
+				name = 'submitted',
+				label = text('Submission Status'), #'
+				options = submitted_options
+				text_attr = 'label',
+				value_attr = 'id',
+				class = 'status'
+			} -?>
+		<?lsmb ELSE ?>
+		<?lsmb INCLUDE input element_data = {
+			type = "hidden",
+			name = "submitted",
+			value = submitted
+		} ?>
+		<?lsmb END ?>
+            </div>
+		<?lsmb INCLUDE button element_data = {
+			type = "submit",
+			name = "action",
+			text = text('Search'),
+			value = 'get_results'
+		} ?>
+        </form>
+
+</div>

Deleted: trunk/UI/reconciliation/search.html
===================================================================
--- trunk/UI/reconciliation/search.html	2012-12-17 11:06:17 UTC (rev 5373)
+++ trunk/UI/reconciliation/search.html	2012-12-17 15:44:19 UTC (rev 5374)
@@ -1,107 +0,0 @@
-<?lsmb PROCESS 'ui-header.html' ?>
-<?lsmb PROCESS 'elements.html' ?>
-
-<div class="title"><?lsmb text('Search Reconciliation Reports') ?></div>
-        
-<div class="body">
-        <form name="reconciliation__search" method="post" action="recon.pl" id="reconciliation__search">
-            <div>
-		<?lsmb INCLUDE input element_data = {
-			label = text('Date From'), #'
-			type = 'text',
-			class = 'date',
-			size = 12,
-			value = date_from,
-			name = 'date_from'
-		} ?>
-		<?lsmb INCLUDE input element_data = {
-			label = text('To:'), 
-			type = 'text',
-			class = 'date',
-			size = 12,
-			value = date_to,
-			name = 'date_to'
-		} ?>
-            </div>
-            <div>
-		<?lsmb INCLUDE input element_data = {
-			label = text('Amount From'), #'
-			type = 'text',
-			class = 'money',
-			size = 12,
-			value = amount_from,
-			name = 'amount_from'
-		} ?>
-		<?lsmb INCLUDE input element_data = {
-			label = text('To:'), 
-			type = 'text',
-			class = 'money',
-			size = 12,
-			value = amount_to,
-			name = 'amount_to'
-		} ?>
-            </div>
-            <div>
-            <div>
-		<?lsmb INCLUDE select element_data = {
-			label = text('Account:'),
-			class = "chart_id",
-                        name = "chart_id",
-			options = account_list,
-			text_attr = 'name',
-			value_attr = 'id'
-		} ?>
-            </div>
-            <div>
-		<?lsmb IF show_approved ?>
-			<?lsmb- approved_options = [
-				{id = undef, label = undef },
-				{id = '1', label = text('Approved') },
-				{id = '0', label = text('Not Approved') } #'
-			];
-			PROCESS select element_data = {
-				name = 'approved',
-				label = text('Approval Status'), #'
-				options = approved_options
-				text_attr = 'label',
-				value_attr = 'id',
-				class = 'status'
-			} -?>
-		<?lsmb ELSE ?>
-		<?lsmb INCLUDE input element_data = {
-			type = "hidden",
-			name = "approved",
-			value = approved
-		} ?>
-		<?lsmb END ?>
-		<?lsmb IF show_submitted ?>
-			<?lsmb- submitted_options = [
-				{id = undef, label = undef },
-				{id = '1', label = text('Submitted') },
-				{id = '0', label = text('Not Submitted') } #'
-			];
-			PROCESS select element_data = {
-				name = 'submitted',
-				label = text('Submission Status'), #'
-				options = submitted_options
-				text_attr = 'label',
-				value_attr = 'id',
-				class = 'status'
-			} -?>
-		<?lsmb ELSE ?>
-		<?lsmb INCLUDE input element_data = {
-			type = "hidden",
-			name = "submitted",
-			value = submitted
-		} ?>
-		<?lsmb END ?>
-            </div>
-		<?lsmb INCLUDE button element_data = {
-			type = "submit",
-			name = "action",
-			text = text('Search'),
-			value = 'get_results'
-		} ?>
-        </form>
-
-</div>

Modified: trunk/sql/modules/Reconciliation.sql
===================================================================
--- trunk/sql/modules/Reconciliation.sql	2012-12-17 11:06:17 UTC (rev 5373)
+++ trunk/sql/modules/Reconciliation.sql	2012-12-17 15:44:19 UTC (rev 5374)
@@ -497,7 +497,7 @@
 CREATE OR REPLACE FUNCTION reconciliation__search
 (in_date_from date, in_date_to date, 
 	in_balance_from numeric, in_balance_to numeric, 
-	in_chart_id int, in_submitted bool, in_approved bool) 
+	in_account_id int, in_submitted bool, in_approved bool) 
 returns setof cr_report AS
 $$
 DECLARE report cr_report;
@@ -512,7 +512,7 @@
 				or in_balance_from <= their_total ) AND
 			(in_balance_to IS NULL 
 				OR in_balance_to >= their_total) AND
-			(in_chart_id IS NULL OR in_chart_id = chart_id) AND
+			(in_account_id IS NULL OR in_account_id = chart_id) AND
 			(in_submitted IS NULL or in_submitted = submitted) AND
 			(in_approved IS NULL OR in_approved = approved) AND
 			(r.deleted IS FALSE)

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