[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[3009] addons/1.3/assets/trunk
- Subject: SF.net SVN: ledger-smb:[3009] addons/1.3/assets/trunk
- From: ..hidden..
- Date: Thu, 27 May 2010 19:50:26 +0000
Revision: 3009
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3009&view=rev
Author: einhverfr
Date: 2010-05-27 19:50:26 +0000 (Thu, 27 May 2010)
Log Message:
-----------
More asset 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 23:01:26 UTC (rev 3008)
+++ addons/1.3/assets/trunk/scripts/asset.pl 2010-05-27 19:50:26 UTC (rev 3009)
@@ -1,3 +1,9 @@
+=pod
+
+=head1 LedgerSMB Asset Management workflow script
+
+=cut
+
package LedgerSMB::Scripts::asset;
use LedgerSMB::Template;
use LedgerSMB::DBObject::Asset_Class;
Modified: addons/1.3/assets/trunk/sql/modules/Assets.sql
===================================================================
--- addons/1.3/assets/trunk/sql/modules/Assets.sql 2010-05-25 23:01:26 UTC (rev 3008)
+++ addons/1.3/assets/trunk/sql/modules/Assets.sql 2010-05-27 19:50:26 UTC (rev 3009)
@@ -929,9 +929,9 @@
t_disposed_percent := 100;
end if;
-INSERT INTO gl (reference, description, approved)
+INSERT INTO gl (reference, description, approved, transdate)
select 'Asset Report ' || in_id, 'Asset Disposal Report for ' || report_date,
- false
+ false, report_date
FROM asset_report where id = in_id;
-- REMOVING ASSETS FROM ACCOUNT (Credit)
@@ -967,7 +967,7 @@
-- INSERT asset/proceeds (Debit, credit for negative values)
INSERT INTO acc_trans (trans_id, chart_id, amount, approved, transdate)
-SELECT currval('id'), in_asset_acct, l.amount * -1, true, r.report_date
+SELECT currval('id'), in_asset_acct, coalesce(l.amount, 0) * -1, true, r.report_date
FROM asset_item a
JOIN asset_report_line l ON (l.asset_id = a.id)
JOIN asset_report r ON (r.id = l.report_id)
@@ -978,38 +978,13 @@
-- INSERT GAIN/LOSS (Credit for gain, debit for loss)
INSERT INTO acc_trans(trans_id, chart_id, amount, approved, transdate)
select currval('id'),
- case when
- sum(dl.amount)
- *
- (coalesce(t_disposed_percent, m.percent_disposed)/100)
- >
- sum(purchase_value)
- * (coalesce(t_disposed_percent, m.percent_disposed)/100)
- THEN in_loss_acct
+ CASE WHEN sum(amount) > 0 THEN in_loss_acct
else in_gain_acct
END,
- sum(dl.amount)
- *
- (coalesce(t_disposed_percent, m.percent_disposed)/100)
- -
- sum(a.purchase_value)
- *
- (coalesce(t_disposed_percent, m.percent_disposed)/100)
- -
- sum(l.amount),
- true,
+ sum(amount) * -1 , true,
retval.report_date
- FROM asset_item a
- JOIN asset_report_line l ON (l.asset_id = a.id)
- JOIN asset_report r ON (r.id = l.report_id)
- JOIN asset_report_line dl ON (l.asset_id = dl.asset_id)
- JOIN asset_rl_to_disposal_method m
- ON (l.report_id = m.report_id and l.asset_id = m.asset_id)
- JOIN asset_report dr ON (dl.report_id = dr.id
- and dr.report_class = 1
- and dr.approved_at is not null)
- WHERE r.id = in_id
-GROUP BY m.percent_disposed;
+ FROM acc_trans
+ WHERE trans_id = currval('id');
IF retval.report_class = 4 then
PERFORM asset__import_from_disposal(retval.id);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.