[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[2981] addons/1.3/assets/trunk
- Subject: SF.net SVN: ledger-smb:[2981] addons/1.3/assets/trunk
- From: ..hidden..
- Date: Mon, 12 Apr 2010 21:12:14 +0000
Revision: 2981
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2981&view=rev
Author: einhverfr
Date: 2010-04-12 21:12:14 +0000 (Mon, 12 Apr 2010)
Log Message:
-----------
Partial disposal 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-03-26 19:36:04 UTC (rev 2980)
+++ addons/1.3/assets/trunk/scripts/asset.pl 2010-04-12 21:12:14 UTC (rev 2981)
@@ -550,13 +550,16 @@
sub report_details {
my ($request) = @_;
- if (!$request->{depreciation}){
- disposal_details($request);
- exit;
- }
my $locale = $request->{_locale};
my $report = LedgerSMB::DBObject::Asset_Report->new(base => $request);
$report->get;
+ if ($report->{report_class} == 2) {
+ disposal_details($report);
+ exit;
+ } elsif ($report->{report_class} == 4) {
+ partial_disposal_details($report);
+ exit;
+ }
my @cols = qw(tag start_depreciation purchase_value method_short_name
usable_life basis prior_through prior_dep dep_this_time
dep_ytd dep_total);
@@ -609,6 +612,67 @@
});
}
+sub partial_disposal_details {
+ my ($request) = @_;
+ my $locale = $request->{_locale};
+ my $report = LedgerSMB::DBObject::Asset_Report->new(base => $request);
+ $report->get;
+ my @cols = qw(tag begin_depreciation purchase_value description
+ percent_disposed disposed_acquired_value
+ percent_remaining remaining_aquired_value);
+ $report->{title} = $locale->text("Partial Disposal Report [_1] on date [_2]",
+ $report->{id}, $report->{report_date});
+ my $header = {
+ tag => $locale->text('Tag'),
+ description => $locale->text('Description'),
+ begin_depreciation => $locale->text('Dep. Starts'),
+ purchase_value => $locale->text('Aquired Value'),
+ percent_disposed => $locale->text('Percent Disposed'),
+ disposed_acquired_value =>
+ $locale->text('Disp. Aquired Value'),
+ percent_remaining => $locale->text('Percent Remaining'),
+ remaining_aquired_value =>
+ $locale->text('Aquired Value Remaining')
+ };
+ my $rows = [];
+ for my $r (@{$report->{report_lines}}){
+ $r->{usable_life} = $report->format_amount({amount => $r->{usable_life}});
+ for my $amt (qw(purchase_value adj_basis disposed_acquired_value
+ remaining_aquired_value percent_disposed
+ percent_remaining)
+ ){
+ $r->{$amt} = $report->format_amount({amount => $r->{$amt},
+ money => 1,});
+ }
+ $r->{gain_loss} = $report->format_amount({amount => $r->{gain_loss},
+ money => 1,
+ neg_format => '-' } );
+ push @$rows, $r;
+ }
+ my $template = LedgerSMB::Template->new(
+ user =>$request->{_user},
+ locale => $request->{_locale},
+ path => 'UI',
+ template => 'form-dynatable',
+ format => 'HTML'
+ );
+ my $buttons = [{
+ text => $locale->text('Approve'),
+ type => 'submit',
+ class => 'submit',
+ name => 'action',
+ value => 'approve'
+ },
+ ];
+ $template->render({form => $report,
+ columns => ..hidden..,
+ heading => $header,
+ rows => $rows,
+ hiddens => $report,
+ buttons => $buttons
+ });
+}
+
sub disposal_details {
my ($request) = @_;
my $locale = $request->{_locale};
@@ -616,7 +680,7 @@
$report->get;
my @cols = qw(tag description start_dep disposed_on dm purchase_value
accum_depreciation adj_basis disposal_amt gain_loss);
- $report->{title} = $locale->text("Report [_1] on date [_2]",
+ $report->{title} = $locale->text("Disposal Report [_1] on date [_2]",
$report->{id}, $report->{report_date});
my $header = {
tag => $locale->text('Tag'),
Modified: addons/1.3/assets/trunk/sql/modules/Assets.sql
===================================================================
--- addons/1.3/assets/trunk/sql/modules/Assets.sql 2010-03-26 19:36:04 UTC (rev 2980)
+++ addons/1.3/assets/trunk/sql/modules/Assets.sql 2010-04-12 21:12:14 UTC (rev 2981)
@@ -492,6 +492,35 @@
ORDER BY ai.id, ai.tag;
$$ language sql;
+CREATE TYPE partial_disposal_line AS (
+id int,
+tag text,
+begin_depreciation date,
+purchase_value numeric,
+description text,
+disposal_date date,
+percent_disposed numeric,
+disposed_acquired_value numeric,
+percent_remaining numeric,
+remaining_aquired_value numeric
+);
+
+CREATE OR REPLACE FUNCTION asset_report_partial_disposal_details(in_id int)
+RETURNS SETOF PARTIAL_DISPOSAL_LINE AS
+$$
+SELECT ai.id, ai.tag, ai.start_depreciation, ai.purchase_value, ai.description,
+ ar.report_date, arld.percent_disposed,
+ (arld.percent_disposed / 100) * ai.purchase_value,
+ 100 - arld.percent_disposed,
+ ((100 - arld.percent_disposed)/100) * ai.purchase_value
+ FROM asset_item ai
+ JOIN asset_report_line l ON (ai.id = l.asset_id)
+ JOIN asset_report ar ON (ar.id = l.report_id)
+ JOIN asset_rl_to_disposal_method arld
+ ON ((arld.report_id, arld.asset_id) = (l.report_id, l.asset_id))
+ WHERE ar.id = $1;
+$$ LANGUAGE SQL;
+
CREATE OR REPLACE FUNCTION asset_report__approve
(in_id int, in_expense_acct int, in_gain_acct int, in_loss_acct int)
RETURNS asset_report AS
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.