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

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



Revision: 2878
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2878&view=rev
Author:   einhverfr
Date:     2010-02-09 22:49:49 +0000 (Tue, 09 Feb 2010)

Log Message:
-----------
asset report approval fixes

Modified Paths:
--------------
    addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset_Report.pm
    addons/1.3/assets/trunk/scripts/asset.pl
    addons/1.3/assets/trunk/sql/modules/Assets.sql

Modified: addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset_Report.pm
===================================================================
--- addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset_Report.pm	2010-02-09 19:41:45 UTC (rev 2877)
+++ addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset_Report.pm	2010-02-09 22:49:49 UTC (rev 2878)
@@ -42,6 +42,7 @@
     my ($ref) = $self->exec_method(funcname => 'asset_report__get');
     $self->merge($ref);
     @{$self->{report_lines}} = $self->exec_method(funcname => 'asset_report__get_lines');
+    $self->debug({file => '/tmp/areport'});
     return;
 }
 

Modified: addons/1.3/assets/trunk/scripts/asset.pl
===================================================================
--- addons/1.3/assets/trunk/scripts/asset.pl	2010-02-09 19:41:45 UTC (rev 2877)
+++ addons/1.3/assets/trunk/scripts/asset.pl	2010-02-09 22:49:49 UTC (rev 2878)
@@ -323,11 +323,6 @@
     $template->render($request);
 }
 
-sub report_results {
-    my ($request) = @_;
-    # Use Form-dynatable
-}
-
 sub report_get {
     my ($request) = @_;
     my $report = LedgerSMB::DBObject::Asset_Report->new(base => $request);
@@ -420,7 +415,7 @@
         user =>$request->{_user}, 
         locale => $request->{_locale},
         path => 'UI/asset',
-        template => 'search_reports',
+        template => 'begin_approval',
         format => 'HTML'
     );
     $template->render($ar);
@@ -454,7 +449,7 @@
               select         => {input => { name    => "report_$count",
                                             checked => $asset->{checked},
                                             type    => "checkbox",
-                                            value   => '1',
+                                            value   => $r->{id},
                                           },
                                 },
                id             => {href => $base_href . "&id=".$r->{id},
@@ -496,7 +491,7 @@
          heading => $header,
          rows    => $rows,
          columns => $cols,
-         hidden  => $hidden,
+         hiddens  => $request,
         buttons  => $buttons,
    });
 }
@@ -508,16 +503,17 @@
     $report->get;
     my @cols = qw(tag description purchase_date basis amount);
     $report->{title} = $locale->text("Report [_1] on date [_2]", 
-                     $report->{id}, $report->{transdate});
+                     $report->{id}, $report->{report_date});
     my $header = {
                             tag => $locale->text('Tag'),
                     description => $locale->text('Description'),
                   purchase_date => $locale->text('Purchase Date'),
-                          basis => $locale->text('Basis'),
                          amount => $locale->text('Amount'),
     };
     my $rows = [];
     for my $r (@{$report->{report_lines}}){
+        $r->{basis} = $report->format_amount({amount => $r->{basis}});
+        $r->{amount} = $report->format_amount({amount => $r->{amount}});
         push @$rows, $r;
     }
     my $template = LedgerSMB::Template->new(
@@ -527,11 +523,18 @@
         template => 'form-dynatable',
         format => 'HTML'
     );
+    my $buttons = [{
+                   text  => $locale->text('Approve'),
+                   type  => 'submit',
+                   class => 'submit',
+                   action => 'approve'
+                   },
+    ];
     $template->render({form => $report, 
-                       cols => ..hidden.., 
+                    columns => ..hidden.., 
                     heading => $header,
                        rows => $rows,
-                     hidden => $hidden,
+                    hiddens => $report,
                     buttons => $buttons
     });
 }

Modified: addons/1.3/assets/trunk/sql/modules/Assets.sql
===================================================================
--- addons/1.3/assets/trunk/sql/modules/Assets.sql	2010-02-09 19:41:45 UTC (rev 2877)
+++ addons/1.3/assets/trunk/sql/modules/Assets.sql	2010-02-09 22:49:49 UTC (rev 2878)
@@ -441,10 +441,23 @@
 select * from asset_report where id = $1;
 $$ language sql;
 
+CREATE TYPE asset_report_line_result AS(
+     tag text,
+     description text,
+     purchase_date date,
+     purchase_value numeric,
+     basis numeric,
+     amount numeric
+);
+DROP FUNCTION asset_report__get_lines(int) if exists;
 CREATE OR REPLACE FUNCTION asset_report__get_lines(in_id int)
-RETURNS SETOF asset_report_line
+RETURNS SETOF asset_report_line_result
 as $$
-select * from asset_report_line where report_id = $1;
+select ai.tag, ai.description, ai.purchase_date, ai.purchase_value,
+       ai.purchase_value - ai.salvage_value, rl.amount
+  FROM asset_item ai
+  JOIN asset_report_line rl ON (rl.asset_id = ai.id)
+ WHERE rl.report_id = $1;
 $$ language sql;
 
 CREATE OR REPLACE FUNCTION asset_report__search


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