[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[3030] addons/1.3/assets/trunk
- Subject: SF.net SVN: ledger-smb:[3030] addons/1.3/assets/trunk
- From: ..hidden..
- Date: Tue, 27 Jul 2010 17:43:27 +0000
Revision: 3030
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3030&view=rev
Author: einhverfr
Date: 2010-07-27 17:43:27 +0000 (Tue, 27 Jul 2010)
Log Message:
-----------
Asset import fixes to be rolled out this pm
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-22 16:46:04 UTC (rev 3029)
+++ addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset.pm 2010-07-27 17:43:27 UTC (rev 3030)
@@ -31,7 +31,7 @@
my $csv = LedgerSMB::Assets::CSV->new(base=>$self);
$self->{import_entries} = $csv->process($self, 'import_file');
-
+ unshift @{$self->{import_entries}}; # get rid of header line
return @{$self->{import_entries}};
}
Modified: addons/1.3/assets/trunk/scripts/asset.pl
===================================================================
--- addons/1.3/assets/trunk/scripts/asset.pl 2010-07-22 16:46:04 UTC (rev 3029)
+++ addons/1.3/assets/trunk/scripts/asset.pl 2010-07-27 17:43:27 UTC (rev 3030)
@@ -11,6 +11,9 @@
use LedgerSMB::DBObject::Asset_Report;
use strict;
+my @file_columns = qw(tag purchase_date description asset_class location vendor invoice department GL asset_account purchase_value accum_depreciation nbv);
+
+
sub begin_depreciation_all {
my ($request) = @_;
my $template = LedgerSMB::Template->new(
@@ -838,7 +841,29 @@
my ($request) = @_;
my $asset = LedgerSMB::DBObject::Asset->new({base => $request});
$asset->get_metadata;
+ my $department = {};
+ my $location = {};
+ my $class = {}
+ my $asset_account = {};
+ for my $c (@{$self->{asset_classes}}){
+ $class->{"$c->{label}"} = $c;
+ }
+ for my $l (@{$self->{locations}}){
+ $location->{"$l->{description}"} = $l->{id};
+ }
+ for my $d (@{$self->{departments}}){
+ $department->{"$d->{description}"} = $d->{id};
+ }
+ for my $a (@{$self->{asset_accounts}}){
+ $asset_account->{"$a->{accno}"} = $a;
+ }
for my $ai ($asset->import_file($request->{import_file})){
+ $ai->{location} = $location->{"$ai->{location}"};
+ $ai->{department} = $department->{"$ai->{department}"};
+ $ai->{asset_class} = $class->{"$ai->{asset_class}"}->{id};
+ $ai->{dep_account_id} = $class->{"$ai->{asset_class}"}->{dep_account_id};
+ $ai->{asset_account_id = $asset_account->{"$ai->{asset_account}"}->{id};
+
for my $l (@{$asset->{locations}}){
if ($ai->{location} eq $l->{description}){
$ai->{location} = $l->{id};
@@ -850,7 +875,7 @@
}
}
for my $l (@{$asset->{asset_classes}}){
- if ($ai->{location} eq $l->{label}){
+ if ($ai->{location} eq $l->{label}){
$ai->{location} = $l->{id};
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.