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

SF.net SVN: ledger-smb:[2910] addons/1.3/assets/trunk



Revision: 2910
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2910&view=rev
Author:   einhverfr
Date:     2010-02-24 19:55:43 +0000 (Wed, 24 Feb 2010)

Log Message:
-----------
Fixes to a couple more approval bugs discovered this morning

Modified Paths:
--------------
    addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset_Report.pm
    addons/1.3/assets/trunk/UI/asset/begin_approval.html
    addons/1.3/assets/trunk/scripts/asset.pl
    addons/1.3/assets/trunk/sql/modules/Assets-tables.sql
    addons/1.3/assets/trunk/sql/modules/Assets.sql

Modified: addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset_Report.pm
===================================================================
--- addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset_Report.pm	2010-02-24 18:07:39 UTC (rev 2909)
+++ addons/1.3/assets/trunk/LedgerSMB/DBObject/Asset_Report.pm	2010-02-24 19:55:43 UTC (rev 2910)
@@ -42,6 +42,7 @@
     my ($self) = @_;
     my ($ref) = $self->exec_method(funcname => 'asset_report__get');
     $self->merge($ref);
+    $self->{report_lines} = [];
     @{$self->{report_lines}} = $self->exec_method(funcname => 'asset_report__get_lines');
     $self->debug({file => '/tmp/areport'});
     return;
@@ -59,6 +60,12 @@
     }
 }
 
+sub approve {
+    my ($self) = @_;
+    $self->exec_method(funcname => 'asset_report__approve');
+    $self->{dbh}->commit;
+}
+
 sub search {
     my ($self) = @_;
     return $self->exec_method(funcname => 'asset_report__search');

Modified: addons/1.3/assets/trunk/UI/asset/begin_approval.html
===================================================================
--- addons/1.3/assets/trunk/UI/asset/begin_approval.html	2010-02-24 18:07:39 UTC (rev 2909)
+++ addons/1.3/assets/trunk/UI/asset/begin_approval.html	2010-02-24 19:55:43 UTC (rev 2910)
@@ -3,7 +3,7 @@
 <?lsmb PROCESS "elements.html" -?>
 <body>
 <form action="asset.pl" method="post">
-<div class="listtop"><?lsmb text('New Asset Report') ?></div>
+<div class="listtop"><?lsmb text('New Asset Report Search') ?></div>
 <div class="inputrow" id="classrow"><div class="inputgroup" id="classgrp">
 <?lsmb asset_classes.unshift({}) ?>
 <?lsmb PROCESS select element_data = {
@@ -76,6 +76,16 @@
      class = "submit"
 } ?>
 </div></div>
+<?lsmb PROCESS input element_data = {
+     name = "approved"
+     type = "hidden"
+     value = "0"
+} ?>
+<?lsmb PROCESS input element_data = {
+     name = "depreciation"
+     type = "hidden"
+     value = depreciation
+} ?>
 </form>
 </body>
 </html>

Modified: addons/1.3/assets/trunk/scripts/asset.pl
===================================================================
--- addons/1.3/assets/trunk/scripts/asset.pl	2010-02-24 18:07:39 UTC (rev 2909)
+++ addons/1.3/assets/trunk/scripts/asset.pl	2010-02-24 19:55:43 UTC (rev 2910)
@@ -452,7 +452,9 @@
     my $rows = [];
     my $hiddens = {};
     my $count = 0;
-    my $base_href = "asset.pl?action=report_details";
+    my $base_href = "asset.pl?action=report_details&".
+                     "expense_acct=$ar->{expense_acct}&".
+                     "depreciation=$ar->{depreciation}";
     for my $r (@results){
         $hidden->{"id_$count"} = $r->{id};
         my $ref = {
@@ -540,7 +542,8 @@
                    text  => $locale->text('Approve'),
                    type  => 'submit',
                    class => 'submit',
-                   action => 'approve'
+                   name =>  'action',
+                   value => 'approve'
                    },
     ];
     $template->render({form => $report, 
@@ -566,6 +569,7 @@
         if ($report->{"report_id_$l"}){
             my $approved = LedgerSMB::DBObject::Asset_Report->new(base => $request);
             $approved->{id} = $report->{"report_id_$l"};
+            $approved->{expense_acct} = $report->{"expense_acct"};
             $approved->approve;
         }
     }

Modified: addons/1.3/assets/trunk/sql/modules/Assets-tables.sql
===================================================================
--- addons/1.3/assets/trunk/sql/modules/Assets-tables.sql	2010-02-24 18:07:39 UTC (rev 2909)
+++ addons/1.3/assets/trunk/sql/modules/Assets-tables.sql	2010-02-24 19:55:43 UTC (rev 2910)
@@ -84,6 +84,7 @@
 	entered_at timestamp default now(),
 	approved_at timestamp,
 	depreciated_qty numeric,
+        dont_approve bool default false,
 	submitted bool not null default false
 );
 

Modified: addons/1.3/assets/trunk/sql/modules/Assets.sql
===================================================================
--- addons/1.3/assets/trunk/sql/modules/Assets.sql	2010-02-24 18:07:39 UTC (rev 2909)
+++ addons/1.3/assets/trunk/sql/modules/Assets.sql	2010-02-24 19:55:43 UTC (rev 2910)
@@ -120,39 +120,36 @@
 	t_dep_amount numeric;
 
 Begin
-	INSERT INTO gl (reference, description, transdate, approved, 
-		department_id)
-	SELECT setting_increment('glnumber'), 'Asset Report' || report_id, 
-		report_date, false, department_id
+	INSERT INTO gl (reference, description, transdate, approved)
+	SELECT setting_increment('glnumber'), 'Asset Report ' || asset_report.id,
+		report_date, false
 	FROM asset_report 
 	JOIN asset_report_line 
 		ON (asset_report.id = asset_report_line.report_id)
 	JOIN asset_item 
-		ON (asset_report_line.asset_item_id = asset_item.id)
+		ON (asset_report_line.asset_id = asset_item.id)
 	WHERE asset_report.id = in_report_id
-	GROUP BY asset_report.report_id, asset_item.department_id;
+	GROUP BY asset_report.id, asset_report.report_date;
 
 	INSERT INTO acc_trans (trans_id, chart_id, transdate, approved, amount)
 	SELECT gl.id, in_accum_account_id, r.report_date, true, sum(amount) * -1
 	FROM asset_report r
 	JOIN asset_report_line l ON (r.id = l.report_id)
-	JOIN asset_item a ON (l.asset_item_id = a.id)
-	JOIN gl ON (gl.description = 'Asset Report' || l.report_id AND
-		a.department_id = gl.department_id)
-	JOIN asset_class c ON (a.class_id = c.id)
+	JOIN asset_item a ON (l.asset_id = a.id)
+	JOIN gl ON (gl.description = 'Asset Report ' || l.report_id)
 	WHERE r.id = in_report_id
 	GROUP BY gl.id, r.report_date;
 
-	INSERT INTO acc_trans (trans_id, chart_id, transdate, approved, amount)
-	SELECT gl.id, a.dep_account_id, r.report_date, true, sum(amount)
+	INSERT INTO acc_trans (trans_id, chart_id, transdate, approved, amount,
+                               source, memo)
+	SELECT gl.id, a.dep_account_id, r.report_date, true, sum(amount),
+               a.tag, a.description
 	FROM asset_report r
 	JOIN asset_report_line l ON (r.id = l.report_id)
-	JOIN asset_item a ON (l.asset_item_id = a.id)
-	JOIN gl ON (gl.description = 'Asset Report' || l.report_id AND
-		a.department_id = gl.department_id)
-	JOIN asset_class c ON (a.class_id = c.id)
+	JOIN asset_item a ON (l.asset_id = a.id)
+	JOIN gl ON (gl.description = 'Asset Report ' || l.report_id) 
 	WHERE r.id = in_report_id
-	GROUP BY gl.id, a.dep_account_id, r.report_date;
+	GROUP BY gl.id, a.dep_account_id, r.report_date, a.tag, a.description;
 
 	RETURN in_report_id;
 END;
@@ -444,17 +441,20 @@
 $$ language sql;
 
 CREATE OR REPLACE FUNCTION asset_report__approve
-(in_id int)
+(in_id int, in_expense_acct int)
 RETURNS asset_report AS
 $$
 DECLARE ret_val asset_report;
 BEGIN
-	UPDATE asset_report SET approved = TRUE
-	where id = in_id;
-
-        PERFORM asset_report__generate_gl(in_id);
-
+        UPDATE asset_report 
+           SET approved_at = now(),
+               approved_by = person__get_my_entity_id()
+         where id = in_id;
 	SELECT * INTO ret_val FROM asset_report WHERE id = in_id;
+        if ret_val.dont_approve is not true then 
+                PERFORM asset_report__generate_gl(in_id, in_expense_acct);
+        end if;
+	SELECT * INTO ret_val FROM asset_report WHERE id = in_id;
 	RETURN ret_val;
 end;
 $$ language plpgsql;
@@ -501,7 +501,7 @@
      basis numeric,
      amount numeric
 );
-DROP FUNCTION asset_report__get_lines(int) if exists;
+
 CREATE OR REPLACE FUNCTION asset_report__get_lines(in_id int)
 RETURNS SETOF asset_report_line_result
 as $$


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