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

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



Revision: 3031
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3031&view=rev
Author:   einhverfr
Date:     2010-07-27 18:00:31 +0000 (Tue, 27 Jul 2010)

Log Message:
-----------
Fixed minor logic error in import

Modified Paths:
--------------
    addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset.pm
    addons/1.3/assets/trunk/scripts/asset.pl

Modified: addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset.pm
===================================================================
--- addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset.pm	2010-07-27 17:43:27 UTC (rev 3030)
+++ addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset.pm	2010-07-27 18:00:31 UTC (rev 3031)
@@ -93,6 +93,12 @@
     $self->{dbh}->commit;
 }
 
+sub import {
+    my ($self) =  @_;
+    my ($ref) = $self->exec_method(funcname => 'asset_report__import');
+    return $ref;
+}
+
 sub get_invoice_id {
     my ($self) = @_;
     my ($ref) = $self->exec_method(funcname => 'get_vendor_invoice_id');

Modified: addons/1.3/assets/trunk/scripts/asset.pl
===================================================================
--- addons/1.3/assets/trunk/scripts/asset.pl	2010-07-27 17:43:27 UTC (rev 3030)
+++ addons/1.3/assets/trunk/scripts/asset.pl	2010-07-27 18:00:31 UTC (rev 3031)
@@ -841,6 +841,12 @@
     my ($request) = @_;
     my $asset = LedgerSMB::DBObject::Asset->new({base => $request});
     $asset->get_metadata;
+    my ($report_results) = $asset->call_procedure(
+                               procname => 'asset_report__begin_import', 
+                                   args => [$self->{asset_classes}->[0]->{id},
+                                            'today']
+    );
+    
     my $department = {};
     my $location = {};
     my $class = {}
@@ -858,6 +864,7 @@
        $asset_account->{"$a->{accno}"} = $a;
     }
     for my $ai ($asset->import_file($request->{import_file})){
+        $ai->{dep_report_id} = $report_results->{id};
         $ai->{location} = $location->{"$ai->{location}"};
         $ai->{department} = $department->{"$ai->{department}"};
         $ai->{asset_class} = $class->{"$ai->{asset_class}"}->{id};
@@ -883,7 +890,7 @@
             my $attr = $ai->{$attr_name};
             $ai->{$attr} = $asset->{"${attr}_name"};
         }
-        $ai->save;
+        $ai->import;
     }
     $request->{info} = $request->{_locale}->text('File Imported');
     begin_import($request);


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