[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[3053] addons/1.3/assets/trunk/scripts/asset.pl
- Subject: SF.net SVN: ledger-smb:[3053] addons/1.3/assets/trunk/scripts/asset.pl
- From: ..hidden..
- Date: Thu, 19 Aug 2010 19:28:45 +0000
Revision: 3053
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3053&view=rev
Author: einhverfr
Date: 2010-08-19 19:28:45 +0000 (Thu, 19 Aug 2010)
Log Message:
-----------
Correction in account mapping logic.
Modified Paths:
--------------
addons/1.3/assets/trunk/scripts/asset.pl
Modified: addons/1.3/assets/trunk/scripts/asset.pl
===================================================================
--- addons/1.3/assets/trunk/scripts/asset.pl 2010-08-18 14:47:25 UTC (rev 3052)
+++ addons/1.3/assets/trunk/scripts/asset.pl 2010-08-19 19:28:45 UTC (rev 3053)
@@ -11,12 +11,15 @@
use LedgerSMB::DBObject::Asset_Report;
use strict;
-my @file_columns = qw(tag purchase_date description asset_class location vendor
+our @file_columns = qw(tag purchase_date description asset_class location vendor
invoice department asset_account purchase_value
accum_dep nbv start_depreciation usable_life
- usable_life_remaining);
+ usable_life_remaining); # override in custom/asset.pl
+our $default_dep_account = '5010'; # Override in custom/asset.pl
+our $default_asset_account = '1300'; # Override in custom/asset.pl
+
sub begin_depreciation_all {
my ($request) = @_;
my $template = LedgerSMB::Template->new(
@@ -856,6 +859,7 @@
my $location = {};
my $class = {};
my $asset_account = {};
+ my $dep_account = {};
for my $c (@{$asset->{asset_classes}}){
$class->{"$c->{label}"} = $c;
}
@@ -868,6 +872,9 @@
for my $a (@{$asset->{asset_accounts}}){
$asset_account->{"$a->{accno}"} = $a;
}
+ for my $a (@{$asset->{dep_accounts}}){
+ $dep_account->{"$a->{accno}"} = $a;
+ }
for my $ail ($asset->import_file($request->{import_file})){
my $ai = LedgerSMB::DBObject::Asset->new({copy => 'base', base => $request});
for (0 .. $#file_columns){
@@ -876,6 +883,8 @@
next if $ai->{purchase_value} !~ /\d/;
$ai->{purchase_value} = $ai->parse_amount(amount => $ai->{purchase_value});
$ai->{accum_dep} = $ai->parse_amount(amount => $ai->{accum_dep});
+ $ai->{dep_account} = $default_dep_account if !$ai->{dep_account};
+ $ai->{asset_account} = $default_asset_account if !$ai->{dep_account};
if (!$ai->{start_depreciation}){
$ai->{start_depreciation} = $ai->{purchase_date};
}
@@ -887,7 +896,8 @@
$ai->{department_id} = $department->{"$ai->{department}"};
$ai->{asset_class_id} = $class->{"$ai->{asset_class}"}->{id};
$ai->{dep_account_id} = $class->{"$ai->{asset_class}"}->{dep_account_id};
- $ai->{asset_account} = $asset_account->{"$ai->{asset_account}"}->{id};
+ $ai->{asset_account_id} = $asset_account->{"$ai->{asset_account}"}->{id};
+ $ai->{dep_account_id} = $asset_account->{"$ai->{dep_account}"}->{id};
for my $l (@{$asset->{locations}}){
if ($ai->{location} eq $l->{description}){
@@ -915,5 +925,6 @@
begin_import($request);
}
+eval { do "scripts/custom/asset.pl"};
1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.