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

SF.net SVN: ledger-smb:[3005] addons/1.3



Revision: 3005
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3005&view=rev
Author:   einhverfr
Date:     2010-05-25 20:55:20 +0000 (Tue, 25 May 2010)

Log Message:
-----------
fixes for some partial depreciation and import errors

Modified Paths:
--------------
    addons/1.3/assets/trunk/scripts/asset.pl
    addons/1.3/assets/trunk/sql/modules/Assets.sql

Added Paths:
-----------
    addons/1.3/taxcategory/
    addons/1.3/taxcategory/tags/
    addons/1.3/taxcategory/trunk/
    addons/1.3/taxcategory/trunk/sql/
    addons/1.3/taxcategory/trunk/sql/modules/

Modified: addons/1.3/assets/trunk/scripts/asset.pl
===================================================================
--- addons/1.3/assets/trunk/scripts/asset.pl	2010-05-19 20:12:32 UTC (rev 3004)
+++ addons/1.3/assets/trunk/scripts/asset.pl	2010-05-25 20:55:20 UTC (rev 3005)
@@ -357,7 +357,7 @@
        description    =>  $locale->text('Description') ,
        purchase_date  =>  $locale->text('Purchase Date') ,
        purchase_value =>  $locale->text('Purchase Value') ,
-       amount         =>  $locale->text('Amount'),
+       amount         =>  $locale->text('Proceeds'),
        dm             =>  $locale->text('Disposal Method'),
        percent        =>  $locale->text('Percent'),
    };

Modified: addons/1.3/assets/trunk/sql/modules/Assets.sql
===================================================================
--- addons/1.3/assets/trunk/sql/modules/Assets.sql	2010-05-19 20:12:32 UTC (rev 3004)
+++ addons/1.3/assets/trunk/sql/modules/Assets.sql	2010-05-25 20:55:20 UTC (rev 3005)
@@ -528,7 +528,9 @@
 LEFT JOIN asset_report r on (rl.report_id = r.id)
  GROUP BY ai.id, ai.tag, ai.description, ai.start_depreciation, ai.purchase_date,
           adm.short_name, ai.usable_life, ai.purchase_value, salvage_value
-   HAVING NOT 2 = ANY(as_array(r.report_class)) AND NOT 4 = ANY(as_array(r.report_class))
+   HAVING (NOT 2 = ANY(as_array(r.report_class))) 
+          AND (NOT 4 = ANY(as_array(r.report_class)))
+          OR max(r.report_class) IS NULL
  ORDER BY ai.id, ai.tag, ai.description;
 $$ language sql;
       
@@ -769,7 +771,7 @@
           ai.salvage_value, ai.department_id, ai.exp_account_id, ai.obsolete_by
    HAVING coalesce(max(ar.report_class), 1) = 1
           AND ((ai.purchase_value - coalesce(sum(arl.amount), 0) 
-               > ai.salvage_value) and ai.obsolete_by is not null)
+               > ai.salvage_value) and ai.obsolete_by is null)
                OR $1 is not true
 $$ language sql;
 
@@ -922,7 +924,7 @@
 -- with typical debit/credit designations.  Note debits are always negative.
 
 
-retval := asset_report__record_approve(in_report_id);
+retval := asset_report__record_approve(in_id);
 if retval.report_class = 2 then
      t_disposed_percent := 100;
 end if;
@@ -947,10 +949,10 @@
 
 -- REMOVING ACCUM DEP. (Debit)
 INSERT into acc_trans (trans_id, chart_id, amount, approved, transdate)
-SELECT currval('id', a.dep_account_id, 
+SELECT currval('id'), a.dep_account_id, 
        sum(dl.amount) * -1 
        * (coalesce(t_disposed_percent, m.percent_disposed)/100), 
-       true, r.report_date)
+       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)
@@ -958,13 +960,14 @@
  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.depreciation is true 
+                           and dr.report_class = 1
                            and dr.approved_at is not null)
- WHERE r.id = in_id;
+ WHERE r.id = in_id
+group by a.dep_account_id, m.percent_disposed, r.report_date;
 
 -- INSERT asset/proceeds (Debit, credit for negative values)
 INSERT INTO acc_trans (trans_id, chart_id, amount, approved, transdate)
-SELECT currval('id'), in_asset_act, l.amount * -1, true, r.report_date
+SELECT currval('id'), in_asset_acct, l.amount * -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)
@@ -973,23 +976,23 @@
  WHERE r.id = in_id;
 
 -- INSERT GAIN/LOSS (Credit for gain, debit for loss)
-INSERT INTO acc_trans(trans_id, chart_id, amount, approed, transdate)
+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_price) 
+                  sum(purchase_value) 
                   * (coalesce(t_disposed_percent, m.percent_disposed)/100)
             THEN in_loss_acct
-            else in_gain_account
+            else in_gain_acct
         END,
         sum(dl.amount) 
         * 
         (coalesce(t_disposed_percent, m.percent_disposed)/100) 
         - 
-        sum(a.purchase_price) 
+        sum(a.purchase_value) 
         *
         (coalesce(t_disposed_percent, m.percent_disposed)/100)
         - 
@@ -1003,9 +1006,10 @@
  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.depreciation is true 
+                            and dr.report_class = 1
                             and dr.approved_at is not null)
-  WHERE r.id = in_id;
+  WHERE r.id = in_id
+GROUP BY m.percent_disposed;
 
 IF retval.report_class = 4 then
    PERFORM asset__import_from_disposal(retval.id);
@@ -1029,8 +1033,8 @@
 
     SELECT * 
       INTO t_import 
-      FROM  asset_item__begin_import 
-            (t_report.asset_class, t_report.report_date);
+      FROM  asset_report__begin_import 
+            (t_report.asset_class::int, t_report.report_date);
 
     SELECT asset_item__import(
 	ai.description,


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