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

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



Revision: 5877
          http://sourceforge.net/p/ledger-smb/code/5877
Author:   einhverfr
Date:     2013-05-29 10:54:48 +0000 (Wed, 29 May 2013)
Log Message:
-----------
Moving fixed asset net book value report to new framework

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Asset_Report.pm
    trunk/LedgerSMB/Report.pm
    trunk/LedgerSMB/Scripts/asset.pm

Added Paths:
-----------
    trunk/LedgerSMB/Report/Assets/
    trunk/LedgerSMB/Report/Assets/Net_Book_Value.pm

Modified: trunk/LedgerSMB/DBObject/Asset_Report.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Asset_Report.pm	2013-05-28 20:42:37 UTC (rev 5876)
+++ trunk/LedgerSMB/DBObject/Asset_Report.pm	2013-05-29 10:54:48 UTC (rev 5877)
@@ -143,17 +143,6 @@
     return;
 }
 
-=item get_nbv
-
-Returns line items for the Net Book Value report.
-
-=cut
-
-sub get_nbv {
-    my ($self) = @_;
-    return $self->exec_method(funcname => 'asset_nbv_report');
-}
-
 =item generate
 
 Properties used:

Added: trunk/LedgerSMB/Report/Assets/Net_Book_Value.pm
===================================================================
--- trunk/LedgerSMB/Report/Assets/Net_Book_Value.pm	                        (rev 0)
+++ trunk/LedgerSMB/Report/Assets/Net_Book_Value.pm	2013-05-29 10:54:48 UTC (rev 5877)
@@ -0,0 +1,159 @@
+=head1 NAME
+
+LedgerSMB::Report::Assets::Net_Book_Value - Fixed Asset Current Book Value 
+Report
+
+=head1 SYNPOSIS
+
+ my $report = LedgerSMB::Report::Assets::Net_Book_Value->new(%$request);
+ $report->render($request);
+
+=head1 DESCRIPTION
+
+The Net Book Value report provides current information on the book value of 
+assets at the current date.  The net book value is the depreciable basis plus 
+the estimated salvage value, less accumulated depreciation.  This thus gives 
+a view of the current value left per asset, as they contribute to the specific
+asset accounts.
+
+=cut
+
+package LedgerSMB::Report::Assets::Net_Book_Value;
+use Moose;
+extends 'LedgerSMB::Report';
+
+=head1 CRITERIA PROPERTIES
+
+none
+
+=head1 STATIC METHODS
+
+=head2 columns
+
+=over
+
+=item id, id of asset
+
+=item tag, text id of asset
+
+=item description, text description of asset
+
+=item begin_depreciation, date when asset begins to depreciate
+
+=item method, short description of method. 
+
+=item remaining life, how much is left to depreciate
+
+=item basis, amount that can be depreciated
+
+=item salvage_value, amount expected to be recovered on salvage
+
+=item accum_depreciation, amount depreciated so far
+
+=item net_book_value, value still remaining as asset for accounting purposes
+
+=item precent_depreciated, percent the asset has been depreciated.
+
+=back
+
+=cut
+
+sub columns {
+    return 
+    [
+          {type => 'text', 
+         col_id => 'id', 
+           name =>  LedgerSMB::Report::text('ID'), },
+
+          {type => 'href', 
+         col_id => 'tag', 
+      href_base => 'asset.pl?action=ed&id=',
+           name =>  LedgerSMB::Report::text('Tag'),},
+
+          {type => 'text',
+         col_id => 'description', 
+           name =>  LedgerSMB::Report::text('Description'), },
+
+          {type => 'text', 
+         col_id => 'begin_depreciation', 
+           name =>  LedgerSMB::Report::text('In Svc'), },
+
+          {type => 'text', 
+         col_id => 'method', 
+           name =>  LedgerSMB::Report::text('Method'),},
+
+          {type => 'text', 
+         col_id => 'remaining_life', 
+           name =>  LedgerSMB::Report::text('Rem. Life'),},
+
+          {type => 'text', 
+         col_id => 'basis', 
+           name =>  LedgerSMB::Report::text('Basis'),},
+
+          {type => 'text', 
+         col_id => 'salvage_value', 
+           name =>  LedgerSMB::Report::text('(+) Salvage Value'),},
+
+          {type => 'text', 
+         col_id => 'through_date', 
+           name =>  LedgerSMB::Report::text('Dep. Through'),},
+
+          {type => 'text', 
+         col_id => 'accum_depreciation', 
+           name =>  LedgerSMB::Report::text('(-) Accum. Dep.'),},
+
+          {type => 'text', 
+         col_id => 'net_book_value', 
+           name =>  LedgerSMB::Report::text('(=) NBV'),},
+
+          {type => 'text', 
+         col_id => 'percent_depreciated', 
+           name =>  LedgerSMB::Report::text('% Dep.'),},
+  ];
+};
+
+
+=head2 header_lines
+
+None added
+
+=cut
+
+sub header_lines {
+    return [];
+}
+
+=head2 name
+
+Net Book Value
+
+=cut
+
+sub name {
+    return LedgerSMB::Report->text('Net Book Value');
+}
+
+=head1 METHODS
+
+=head2 run_report
+
+=cut
+
+sub run_report{
+    my ($self) = @_;
+    my @rows = $self->exec_method(funcname => 'asset_nbv_report');
+    for my $row(@rows){
+        $row->{row_id} = $row->{id};
+    }
+    $self->rows(..hidden..);
+}
+
+=head1 COPYRIGHT
+
+COPYRIGHT (C) 2013 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/Report.pm
===================================================================
--- trunk/LedgerSMB/Report.pm	2013-05-28 20:42:37 UTC (rev 5876)
+++ trunk/LedgerSMB/Report.pm	2013-05-29 10:54:48 UTC (rev 5877)
@@ -356,6 +356,22 @@
 
 =back
 
+=head1 WRITING REPORTS 
+
+LedgerSMB::Report subclasses are written typically in a few parts:
+
+=over
+
+=item SQL or PL/PGSQL function
+
+=item Criteria Properties
+
+=item Method overrides
+
+=item Main processing function(s)
+
+=back
+
 =head1 COPYRIGHT
 
 COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the

Modified: trunk/LedgerSMB/Scripts/asset.pm
===================================================================
--- trunk/LedgerSMB/Scripts/asset.pm	2013-05-28 20:42:37 UTC (rev 5876)
+++ trunk/LedgerSMB/Scripts/asset.pm	2013-05-29 10:54:48 UTC (rev 5877)
@@ -19,6 +19,7 @@
 use LedgerSMB::DBObject::Asset_Class;
 use LedgerSMB::DBObject::Asset;
 use LedgerSMB::DBObject::Asset_Report;
+use LedgerSMB::Report::Assets::Net_Book_Value;
 use strict;
 
 our @file_columns = qw(tag purchase_date description asset_class location vendor 
@@ -986,47 +987,8 @@
 
 sub display_nbv {
     my ($request) = @_;
-    my $locale = $request->{_locale};
-    my $report = LedgerSMB::DBObject::Asset_Report->new({base => $request });
-    my @cols = qw(id tag description begin_depreciation method remaining_life basis salvage_value
-                  through_date accum_depreciation net_book_value);
-    my $header = {
-                   id                  => $locale->text('ID'),
-                   tag                 => $locale->text('Tag'),
-                   description         => $locale->text('Description'),
-                   begin_depreciation  => $locale->text('In Svc.'),
-                   method              => $locale->text('Method'),
-                   remaining_life      => $locale->text('Rem. Life'), 
-                   basis               => $locale->text('Basis'),
-                   salvage_value       => $locale->text('(+) Salvage Value'),
-                   through_date        => $locale->text('Dep. through'),
-                   accum_depreciation  => $locale->text('(-) Accum. Dep.'),
-                   net_book_value      => $locale->text('(=) NBV'),
-                   percent_depreciated => $locale->text('Pct. Dep.'),
-    };
-    my @results = $report->get_nbv;
-    my $rows = [];
-    for my $r(@results){
-        for my $amt (qw(basis salvage_value accum_depreciation net_book_value)){
-            $r->{$amt} = $request->format_amount({amount => $r->{$amt}, money => 1});
-        }
-        for my $amt (qw(percent_depreciated remaining_life)){
-            $r->{$amt} = $request->format_amount({amount => $r->{$amt}});
-        }
-        push @$rows, $r;
-    }
-    my $template = LedgerSMB::Template->new(
-        user =>$request->{_user}, 
-        locale => $request->{_locale},
-        path => 'UI',
-        template => 'form-dynatable',
-        format => 'HTML'
-    );
-    $template->render({form => $report, 
-                    columns => ..hidden.., 
-                    heading => $header,
-                       rows => $rows,
-    });
+    my $report = LedgerSMB::Report::Assets::Net_Book_Value->new(%$request);
+    $report->render($request);
 }
 
 =item begin_import 

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