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

SF.net SVN: ledger-smb:[2917] addons/1.3/assets/trunk



Revision: 2917
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2917&view=rev
Author:   einhverfr
Date:     2010-02-27 20:39:21 +0000 (Sat, 27 Feb 2010)

Log Message:
-----------
New depreciation details report verified and ready to roll out:

Modified Paths:
--------------
    addons/1.3/assets/trunk/scripts/asset.pl
    addons/1.3/assets/trunk/sql/modules/Assets-tables.sql
    addons/1.3/assets/trunk/sql/modules/Assets.sql

Modified: addons/1.3/assets/trunk/scripts/asset.pl
===================================================================
--- addons/1.3/assets/trunk/scripts/asset.pl	2010-02-27 20:12:11 UTC (rev 2916)
+++ addons/1.3/assets/trunk/scripts/asset.pl	2010-02-27 20:39:21 UTC (rev 2917)
@@ -3,6 +3,7 @@
 use LedgerSMB::DBObject::Asset_Class;
 use LedgerSMB::DBObject::Asset;
 use LedgerSMB::DBObject::Asset_Report;
+use strict;
 
 sub begin_depreciation_all {
     my ($request) = @_;
@@ -106,6 +107,7 @@
         template => 'form-dynatable',
         format => 'HTML'
     );
+    my $columns;
     @$columns = qw(id label dep_method asset_account dep_account);
     my $heading = {
          id            => $locale->text('ID'),
@@ -210,7 +212,7 @@
         $departments->{$dept->{id}} = $dept;
     }
     my $locations = {};
-    for $loc(@{$asset->{asset_classes}}){
+    for my $loc(@{$asset->{asset_classes}}){
         $locations->{$loc->{id}} = $loc;
     }
     my $rows = [];
@@ -254,7 +256,7 @@
                    . 'Invoice:'.$asset->{invnumber};
     $asset->{subject} = 'Vendor/Invoice Note';
     $asset->save_note;
-    $newasset = LedgerSMB::DBObject::Asset->new(
+    my $newasset = LedgerSMB::DBObject::Asset->new(
                   base  => $request, 
                   copy  => 'list',
                   merge => ['stylesheet'],
@@ -395,7 +397,7 @@
        $request->{title} = $locale->text('Asset Disposal Report');
        push @$cols, 'amount';
    }
-   for $hide (qw(exp_account_id gain_account_id loss_account_id report_date 
+   for my $hide (qw(exp_account_id gain_account_id loss_account_id report_date 
                  asset_class rowcount depreciation))
    {
        $hiddens->{$hide} = $request->{$hide};
@@ -456,10 +458,10 @@
                      "expense_acct=$ar->{expense_acct}&".
                      "depreciation=$ar->{depreciation}";
     for my $r (@results){
-        $hidden->{"id_$count"} = $r->{id};
+        $hiddens->{"id_$count"} = $r->{id};
         my $ref = {
               select         => {input => { name    => "report_$count",
-                                            checked => $asset->{checked},
+                                            checked => $r->{checked},
                                             type    => "checkbox",
                                             value   => $r->{id},
                                           },
@@ -513,22 +515,32 @@
     my $locale = $request->{_locale};
     my $report = LedgerSMB::DBObject::Asset_Report->new(base => $request);
     $report->get;
-    my @cols = qw(tag description purchase_date basis amount);
+    my @cols = qw(tag start_depreciation purchase_value method_short_name
+                 usable_life basis prior_through prior_dep dep_this_time
+                 dep_ytd dep_total);
     $report->{title} = $locale->text("Report [_1] on date [_2]", 
                      $report->{id}, $report->{report_date});
     my $header = {
                             tag => $locale->text('Tag'),
-                    description => $locale->text('Description'),
-                  purchase_date => $locale->text('Purchase Date'),
-                         basis  => $locale->text('Depreciation Basis'),
-                         amount => $locale->text('Amount'),
+             start_depreciation => $locale->text('Dep. Starts'),
+                 purchase_value =>$locale->text('Aquired Value'),
+              method_short_name =>$locale->text('Dep. Method'),
+                    usable_life =>$locale->text('Est. Life'),
+                          basis =>$locale->text('Dep. Basis'),
+                  prior_through =>$locale->text('Prior Through'),
+                      prior_dep =>$locale->text('Prior Dep.'),
+                  dep_this_time =>$locale->text('Dep. this run'),
+                        dep_ytd =>$locale->text('Dep. YTD'),
+                      dep_total =>$locale->text('Total Accum. Dep.'),
     };
     my $rows = [];
     for my $r (@{$report->{report_lines}}){
-        $r->{basis} = $report->format_amount({amount => $r->{basis},
+        $r->{usable_life} = $report->format_amount({amount => $r->{usable_life}});
+        for my $amt (qw(purchase_value basis prior_dep dep_this_time dep_ytd
+                        dep_total)){
+             $r->{$amt} = $report->format_amount({amount => $r->{$amt},
                                               money  => 1,});
-        $r->{amount} = $report->format_amount({amount => $r->{amount},
-                                                money => 1});
+        }
         push @$rows, $r;
     }
     my $template = LedgerSMB::Template->new(

Modified: addons/1.3/assets/trunk/sql/modules/Assets-tables.sql
===================================================================
--- addons/1.3/assets/trunk/sql/modules/Assets-tables.sql	2010-02-27 20:12:11 UTC (rev 2916)
+++ addons/1.3/assets/trunk/sql/modules/Assets-tables.sql	2010-02-27 20:39:21 UTC (rev 2917)
@@ -13,19 +13,24 @@
         short_name text not null,
         sproc text not null unique,
         unit_label text not null,
+        short_name text not null unique,
 	unit_class int not null references asset_unit_class(id) 
 );
 
 comment on column asset_dep_method.method IS 
 $$ These are keyed to specific stored procedures.  Currently only "straight_line" is supported$$;
 
-INSERT INTO asset_dep_method(method, unit_class, sproc, unit_label) 
-values ('Annual Straight Line', 1, 'asset_dep_straight_line_yr', 'in years');
+INSERT INTO asset_dep_method(method, unit_class, sproc, unit_label, short_name) 
+values ('Annual Straight Line Daily', 1, 'asset_dep_straight_line_yr_d', 'in years', 'SLYD');
 
-INSERT INTO asset_dep_method(method, unit_class, sproc, unit_label) 
+
+INSERT INTO asset_dep_method(method, unit_class, sproc, unit_label, short_name) 
 values ('Whole Month Straight Line', 1, 'asset_dep_straight_line_whl_m', 
-'in months');
+'in months', 'SLMM');
 
+INSERT INTO asset_dep_method(method, unit_class, sproc, unit_label, short_name) 
+values ('Annual Straight Line Daily', 1, 'asset_dep_straight_line_yr_m', 'in years', 'SLYM');
+
 CREATE TABLE asset_class (
 	id serial not null unique,
 	label text primary key,

Modified: addons/1.3/assets/trunk/sql/modules/Assets.sql
===================================================================
--- addons/1.3/assets/trunk/sql/modules/Assets.sql	2010-02-27 20:12:11 UTC (rev 2916)
+++ addons/1.3/assets/trunk/sql/modules/Assets.sql	2010-02-27 20:39:21 UTC (rev 2917)
@@ -550,13 +550,13 @@
      dep_ytd numeric,
      dep_total numeric,
      description text,
-     purchase_date date,
+     purchase_date date
 );
 
 CREATE OR REPLACE FUNCTION asset_report__get_lines(in_id int)
 RETURNS SETOF asset_report_line_result
 as $$
-   select ai.tag, ai.start_depreciation, ai.purchase_value, m.short_name, 
+   select ai.tag, coalesce(ai.start_depreciation, ai.purchase_date), ai.purchase_value, m.short_name, 
           ai.usable_life, 
           ai.purchase_value - ai.salvage_value, max(pr.report_date),
           sum(case when pr.report_date < r.report_date then prl.amount
@@ -566,9 +566,10 @@
           sum (case when extract(year from pr.report_date)
                          = extract(year from r.report_date)
                          AND pr.report_date < r.report_date
-                    then rl.amount
+                    then prl.amount
                     else 0
-                end), sum(prl.amount) + rl.amount,
+                end), 
+          sum(prl.amount), 
           ai.description, ai.purchase_date
      FROM asset_item ai
      JOIN asset_class c ON (ai.asset_class_id = c.id)


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