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

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



Revision: 3006
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3006&view=rev
Author:   einhverfr
Date:     2010-05-25 21:16:55 +0000 (Tue, 25 May 2010)

Log Message:
-----------
More import fixes

Modified Paths:
--------------
    addons/1.3/assets/trunk/scripts/asset.pl
    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-05-25 20:55:20 UTC (rev 3005)
+++ addons/1.3/assets/trunk/scripts/asset.pl	2010-05-25 21:16:55 UTC (rev 3006)
@@ -833,6 +833,21 @@
     my $asset = LedgerSMB::DBObject::Asset->new({base => $request});
     $asset->get_metadata;
     for my $ai ($asset->import_file($request->{import_file})){
+        for my $l (@{$asset->{locations}}){
+            if ($ai->{location} eq $l->{description}){
+               $ai->{location} = $l->{id};
+            }
+        }
+        for my $l (@{$asset->{departments}}){
+            if ($ai->{location} eq $l->{description}){
+               $ai->{location} = $l->{id};
+            }
+        }
+        for my $l (@{$asset->{asset_classes}}){
+            if ($ai->{location} eq $l->{label}){
+               $ai->{location} = $l->{id};
+            }
+        }
         for my $attr_name (qw(location department asset_class)){
             my $attr = $ai->{$attr_name};
             $ai->{$attr} = $asset->{"${attr}_name"};

Modified: addons/1.3/assets/trunk/sql/modules/Assets.sql
===================================================================
--- addons/1.3/assets/trunk/sql/modules/Assets.sql	2010-05-25 20:55:20 UTC (rev 3005)
+++ addons/1.3/assets/trunk/sql/modules/Assets.sql	2010-05-25 21:16:55 UTC (rev 3006)
@@ -1036,7 +1036,7 @@
       FROM  asset_report__begin_import 
             (t_report.asset_class::int, t_report.report_date);
 
-    SELECT asset_item__import(
+    PERFORM asset_report__import(
 	ai.description,
 	ai.tag,
 	ai.purchase_value * rld.percent_disposed / 100,
@@ -1055,10 +1055,11 @@
         r.accum_depreciation * rld.percent_disposed / 100,
         TRUE)
     FROM asset_item ai
-    JOIN asset_report__get_disposal(t_report.id) r  ON (ai.id = r.asset_id)
+    JOIN asset_report__get_disposal(t_report.id) r  ON (ai.id = r.id)
     JOIN asset_report_line rl ON (rl.asset_id = ai.id AND rl.report_id = in_id)
     join asset_rl_to_disposal_method rld 
          ON (rl.report_id = rld.report_id and ai.id = rld.asset_id)
-   where rl.disposed_percent is null or disposed_percent < 100;
+   where rld.percent_disposed is null or percent_disposed < 100;
+   RETURN TRUE;
 END;
 $$ language plpgsql;


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