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

SF.net SVN: ledger-smb:[4771] trunk/LedgerSMB



Revision: 4771
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4771&view=rev
Author:   einhverfr
Date:     2012-05-24 08:16:25 +0000 (Thu, 24 May 2012)
Log Message:
-----------
Budget Variance Report now on 1.4 framework

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Report/Budget/Search.pm
    trunk/LedgerSMB/DBObject_Moose.pm

Added Paths:
-----------
    trunk/LedgerSMB/DBObject/Report/Budget/Variance.pm

Modified: trunk/LedgerSMB/DBObject/Report/Budget/Search.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Report/Budget/Search.pm	2012-05-24 06:57:33 UTC (rev 4770)
+++ trunk/LedgerSMB/DBObject/Report/Budget/Search.pm	2012-05-24 08:16:25 UTC (rev 4771)
@@ -65,18 +65,19 @@
 
 sub columns {
    return [ {col_id => 'start_date',
-               type => 'text',
+               type => 'href',
+          href_base => 'budget_reports.pl?action=variance_report&id=',
                name => $locale->text('Start Date') },
 
             {col_id => 'end_date', 
-               type => 'text',
+               type => 'href',
+          href_base => 'budget_reports.pl?action=variance_report&id=',
                name => $locale->text('End Date') },
 
             {col_id => 'reference', 
                type => 'href',
           href_base => 'budgets.pl?action=view_budget&id=',
                name => $locale->text('Reference') },
-             
 
             {col_id => 'description', 
                type => 'href',
@@ -217,8 +218,15 @@
 
 =back
 
-=head1 COPYRIGHT
+=head1 COPYRIGHT AND LICENSE
 
+Copyright (C) 2011 LedgerSMB Core Team.  This file is licensed under the GNU 
+General Public License version 2, or at your option any later version.  Please
+see the included License.txt for details.
+
 =cut
 
+__PACKAGE__->meta->make_immutable;
+
+
 return 1;

Added: trunk/LedgerSMB/DBObject/Report/Budget/Variance.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Report/Budget/Variance.pm	                        (rev 0)
+++ trunk/LedgerSMB/DBObject/Report/Budget/Variance.pm	2012-05-24 08:16:25 UTC (rev 4771)
@@ -0,0 +1,211 @@
+=head1 NAME
+
+LedgerSMB::DBObject::Report::Budget::Variance - Variance Report per Budget
+
+=head1 SYNPOSIS
+
+  my $report = LedgerSMB::DBObject::Report::Budget::Variance->new(%$request);
+  $report->run;
+  $report->render($request, $format);
+
+=head1 DESCRIPTION
+
+This is a basic variance report for budgets.  A variance report shows budgetted
+debits and credits along with those actually accrued during the stated period.
+It thus provides a way of measuring both current and historical expenditures
+against what was budgetted.
+
+=cut
+
+package LedgerSMB::DBObject::Report::Budget::Variance;
+use Moose;
+extends 'LedgerSMB::DBObject::Report';
+use LedgerSMB::App_State;
+my $locale = $LedgerSMB::App_State::Locale;
+
+=head1 PROPERTIES
+
+=over
+
+=item columns
+
+Read only accessor.  This provides the columns for the report
+
+=over 
+
+=item budget_description
+
+Description of he budget line item
+
+=item accno
+
+Account number budgetted
+
+=item account_label
+
+Account name
+
+=item budget_amount
+
+Amount (normalized left or right) budgetted
+
+=item used_amount
+
+Amount (normalized left or right) used
+
+=item variance
+
+Difference between budgetted and used.
+
+=back
+
+=cut
+
+sub columns {
+   return [
+      {col_id => 'budget_description', 
+         type => 'text', 
+         name => $locale->text('Description')},
+
+      {col_id => 'accno', 
+         type => 'text', 
+         name => $locale->text('Account Number')},
+
+      {col_id => 'account_label', 
+         type => 'text', 
+         name => $locale->text('Account Label')},
+
+      {col_id => 'budget_amount', 
+         type => 'text', 
+         name => $locale->text('Amount Budgetted')},
+
+      {col_id => 'used_amount', 
+         type => 'text', 
+         name => '- ' . $locale->text('Used')},
+
+      {col_id => 'variance', 
+         type => 'text', 
+         name => '= ' . $locale->text('Variance')},
+   ];
+}
+
+=item name
+
+Returns name of report
+
+=cut
+
+sub name {
+    return $locale->text('Budget Variance Report');
+}
+
+=item header_lines
+
+Returns the inputs to display on header.
+
+=cut
+
+sub header_lines {
+    return [{name => 'control_code',
+             text => $locale->text('Budget Number')},
+            {name => 'description',
+             text => $locale->text('Description')},
+            {name => 'start_date',
+             text => $locale->text('Start Date')},
+            {name => 'end_date',
+             text => $locale->text('End Date')},];
+}
+
+=back
+
+=head1 CRITERIA PROPERTIES
+
+=over
+
+=item id
+
+Budget id for variance report.  This is the only search criteria currently 
+supported.
+
+=cut
+
+has id => (is => 'ro', isa => 'Int');
+
+=back
+
+=head1 HEADER PROPERTIES
+
+These are used to generate the header as displayed and are typically pulled in 
+from a budget object.
+
+=over
+
+=item control_code
+
+=cut
+
+has control_code => (is => 'ro', isa => 'Str');
+
+=item description
+
+=cut
+
+has description => (is => 'ro', isa => 'Str');
+
+=item start_date
+
+=cut
+
+has start_date => (is => 'ro', isa => 'LedgerSMB::PGDate');
+
+=item end_date
+
+=cut
+
+has end_date => (is => 'ro', isa => 'LedgerSMB::PGDate');
+
+=back 
+
+=head1 METHODS
+
+=over
+
+=item for_budget_id
+
+Retrieves budget info and creates variance report object for it.
+
+=cut
+
+sub for_budget_id {
+    my ($self, $id) = @_;
+    use LedgerSMB::DBObject::Budget;
+
+    my $budget = LedgerSMB::DBObject::Budget->get($id);
+    return $self->new(%$budget);  
+}
+
+=item run_report
+
+Runs the report, setting rows for rendering.
+
+=cut
+
+sub run_report {
+    my ($self) = @_;
+    my @rows = $self->exec_method({funcname => 'budget__variance_report'});
+    $self->rows(..hidden..);
+}
+
+=back
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2012 LedgerSMB Core Team.  This file is licensed under the GNU 
+General Public License version 2, or at your option any later version.  Please
+see the included License.txt for details.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;
+
+1;

Modified: trunk/LedgerSMB/DBObject_Moose.pm
===================================================================
--- trunk/LedgerSMB/DBObject_Moose.pm	2012-05-24 06:57:33 UTC (rev 4770)
+++ trunk/LedgerSMB/DBObject_Moose.pm	2012-05-24 08:16:25 UTC (rev 4771)
@@ -54,22 +54,15 @@
 sub __validate__ {}
 
 has 'dbh' => (is => 'ro', isa => 'DBI::db', required => '1');
-has '_roles' => (is => 'ro', isa => 'ArrayRef[Str]', required => '1');
 has '_user' => (is => 'ro', isa => 'LedgerSMB::User', required => '1');
 has '_locale' => (is => 'ro', isa => 'LedgerSMB::Locale', required => '1');
 
 sub prepare_dbhash {
     my $self = shift;
     my $target = shift;
-    for my $att (qw(_roles _user _locale)){
-        my $t_att = $att;
-        $att =~ s/^\_//;
-        $att = ucfirst($att);
-        if (!$target->{$att}){
-           $target->{$t_att} = ${"LedgerSMB::App_State::$att"};
-        }
-    }
     $target->{dbh} = $LedgerSMB::App_State::DBH;
+    $target->{_user} = $LedgerSMB::App_State::User;
+    $target->{_locale} = $LedgerSMB::App_State::Locale;
 }
 
 # _to_dbobject 

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