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

SF.net SVN: ledger-smb:[3753] trunk



Revision: 3753
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3753&view=rev
Author:   einhverfr
Date:     2011-09-27 00:18:44 +0000 (Tue, 27 Sep 2011)
Log Message:
-----------
Merging in branches/1.3

Modified Paths:
--------------
    trunk/LedgerSMB/AA.pm
    trunk/bin/aa.pl
    trunk/sql/Pg-database.sql

Property Changed:
----------------
    trunk/


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3:3711-3748
   + /branches/1.3:3711-3752

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2011-09-26 22:56:18 UTC (rev 3752)
+++ trunk/LedgerSMB/AA.pm	2011-09-27 00:18:44 UTC (rev 3753)
@@ -897,9 +897,7 @@
                           AS paid,
 		          vce.name, vc.meta_number,
 		          a.entity_id, 
-		          d.description AS department, 
-		          as_array(p.projectnumber) as ac_projects,
-                          as_array(ip.projectnumber) as inv_projects
+		          d.description AS department
 		     FROM $table a
 		     JOIN entity_credit_account vc ON (a.entity_credit_account = vc.id)
 		     JOIN acc_trans acs ON (acs.trans_id = a.id)
@@ -909,9 +907,6 @@
 		LEFT JOIN exchangerate ex ON (ex.curr = a.curr
 		          AND ex.transdate = a.transdate)
 		LEFT JOIN department d ON (a.department_id = d.id)
-                LEFT JOIN invoice i ON (i.trans_id = a.id)
-                LEFT JOIN project ip ON (i.project_id = ip.id)
-                LEFT JOIN project p ON acs.project_id = p.id 
 		$acc_trans_join
 		    WHERE c.link = '$form->{ARAP}' AND 
 		          (|.$dbh->quote($form->{transdateto}) . qq| IS NULL OR 
@@ -927,8 +922,10 @@
             $query = qq|
 		   SELECT a.id, a.invnumber, a.ordnumber, a.transdate,
 		          a.duedate, a.netamount, a.amount::numeric(20,$p), 
-                          a.amount::numeric(20,$p) 
-                          - sum(acs.amount::numeric(20,$p)) AS paid,
+		          sum(a.amount::numeric(20,$p)) 
+                             - (sum(acs.amount::numeric(20,$p)) 
+                                * CASE WHEN '$table' = 'ar' THEN -1 ELSE 1 END)
+                          AS paid,
 		          a.invoice, a.datepaid, a.terms, a.notes,
 		          a.shipvia, a.shippingpoint, 
 		          vce.name, vc.meta_number,
@@ -936,21 +933,19 @@
 		          ex.$buysell AS exchangerate, 
 		          d.description AS department, 
 		          as_array(p.projectnumber) as ac_projects,
-                          as_array(ip.projectnumber) as inv_projects,
 		          a.ponumber $acc_trans_fields
 		     FROM $table a
 		     JOIN entity_credit_account vc ON (a.entity_credit_account = vc.id)
 		     JOIN acc_trans acs ON (acs.trans_id = a.id)
 		     JOIN entity vce ON (vc.entity_id = vce.id)
-		     JOIN chart c ON (acs.chart_id = c.id)
+		     JOIN chart c ON (acs.chart_id = c.id
+                                      AND charttype='A')
 		LEFT JOIN exchangerate ex ON (ex.curr = a.curr
 		          AND ex.transdate = a.transdate)
 		LEFT JOIN department d ON (a.department_id = d.id)
-                LEFT JOIN invoice i ON (i.trans_id = a.id)
-                LEFT JOIN project ip ON (i.project_id = ip.id)
                 LEFT JOIN project p ON acs.project_id = p.id 
 		$acc_trans_join
-		    WHERE c.link = '$form->{ARAP}' AND 
+		    WHERE c.link = '$ARAP' AND 
 		          (|.$dbh->quote($form->{transdateto}) . qq| IS NULL OR 
 		           |.$dbh->quote($form->{transdateto}) . qq| >= acs.transdate)
 			AND a.approved IS TRUE AND acs.approved IS TRUE

Modified: trunk/bin/aa.pl
===================================================================
--- trunk/bin/aa.pl	2011-09-26 22:56:18 UTC (rev 3752)
+++ trunk/bin/aa.pl	2011-09-27 00:18:44 UTC (rev 3753)
@@ -1360,8 +1360,7 @@
 	{
         	$form->{callback}.= qq|&batch_id=$form->{batch_id}|;
 	}
-
-        $form->redirect( $locale->text('Transaction posted!') );
+        edit();
     }
     else {
         $form->error( $locale->text('Cannot post transaction!') );

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2011-09-26 22:56:18 UTC (rev 3752)
+++ trunk/sql/Pg-database.sql	2011-09-27 00:18:44 UTC (rev 3753)
@@ -3236,169 +3236,6 @@
 );
 
 
-CREATE OR REPLACE FUNCTION menu_generate() RETURNS SETOF menu_item AS 
-$$
-DECLARE 
-	item menu_item;
-	arg menu_attribute%ROWTYPE;
-BEGIN
-	FOR item IN 
-		SELECT n.position, n.id, c.level, n.label, c.path, 
-                       to_args(array[ma.attribute, ma.value])
-		FROM connectby('menu_node', 'id', 'parent', 'position', '0', 
-				0, ',') 
-			c(id integer, parent integer, "level" integer, 
-				path text, list_order integer)
-		JOIN menu_node n USING(id)
-                JOIN menu_attribute ma ON (n.id = ma.node_id)
-               WHERE n.id IN (select node_id FROM menu_acl
-                               WHERE pg_has_role(CASE WHEN role_name 
-                                                           ilike 'public'
-                                                      THEN current_user
-                                                      ELSE role_name
-                                                   END, 'USAGE')
-                            GROUP BY node_id
-                              HAVING bool_and(CASE WHEN acl_type ilike 'DENY'
-                                                   THEN FALSE
-                                                   WHEN acl_type ilike 'ALLOW'
-                                                   THEN TRUE
-                                                END))
-                    or exists (select cn.id, cc.path
-                                 FROM connectby('menu_node', 'id', 'parent', 
-                                                'position', '0', 0, ',')
-                                      cc(id integer, parent integer, 
-                                         "level" integer, path text,
-                                         list_order integer)
-                                 JOIN menu_node cn USING(id)
-                                WHERE cn.id IN 
-                                      (select node_id FROM menu_acl
-                                        WHERE pg_has_role(CASE WHEN role_name 
-                                                           ilike 'public'
-                                                      THEN current_user
-                                                      ELSE role_name
-                                                   END, 'USAGE')
-                                     GROUP BY node_id
-                                       HAVING bool_and(CASE WHEN acl_type 
-                                                                 ilike 'DENY'
-                                                            THEN false
-                                                            WHEN acl_type 
-                                                                 ilike 'ALLOW'
-                                                            THEN TRUE
-                                                         END))
-                                       and cc.path like c.path || ',%')
-            GROUP BY n.position, n.id, c.level, n.label, c.path, c.list_order
-            ORDER BY c.list_order
-                             
-	LOOP
-		RETURN NEXT item;
-	END LOOP;
-END;
-$$ language plpgsql;
-
-COMMENT ON FUNCTION menu_generate() IS
-$$
-This function returns the complete menu tree.  It is used to generate nested
-menus for the web interface.
-$$;
-
-CREATE OR REPLACE FUNCTION menu_children(in_parent_id int) RETURNS SETOF menu_item
-AS $$
-declare 
-	item menu_item;
-	arg menu_attribute%ROWTYPE;
-begin
-        FOR item IN
-		SELECT n.position, n.id, c.level, n.label, c.path, 
-                       to_args(array[ma.attribute, ma.value])
-		FROM connectby('menu_node', 'id', 'parent', 'position', 
-				in_parent_id, 1, ',') 
-			c(id integer, parent integer, "level" integer, 
-				path text, list_order integer)
-		JOIN menu_node n USING(id)
-                JOIN menu_attribute ma ON (n.id = ma.node_id)
-               WHERE n.id IN (select node_id FROM menu_acl
-                               WHERE pg_has_role(CASE WHEN role_name 
-                                                           ilike 'public'
-                                                      THEN current_user
-                                                      ELSE role_name
-                                                   END, 'USAGE')
-                            GROUP BY node_id
-                              HAVING bool_and(CASE WHEN acl_type ilike 'DENY'
-                                                   THEN FALSE
-                                                   WHEN acl_type ilike 'ALLOW'
-                                                   THEN TRUE
-                                                END))
-                    or exists (select cn.id, cc.path
-                                 FROM connectby('menu_node', 'id', 'parent', 
-                                                'position', '0', 0, ',')
-                                      cc(id integer, parent integer, 
-                                         "level" integer, path text,
-                                         list_order integer)
-                                 JOIN menu_node cn USING(id)
-                                WHERE cn.id IN 
-                                      (select node_id FROM menu_acl
-                                        WHERE pg_has_role(CASE WHEN role_name 
-                                                           ilike 'public'
-                                                      THEN current_user
-                                                      ELSE role_name
-                                                   END, 'USAGE')
-                                     GROUP BY node_id
-                                       HAVING bool_and(CASE WHEN acl_type 
-                                                                 ilike 'DENY'
-                                                            THEN false
-                                                            WHEN acl_type 
-                                                                 ilike 'ALLOW'
-                                                            THEN TRUE
-                                                         END))
-                                       and cc.path like c.path || ',%')
-            GROUP BY n.position, n.id, c.level, n.label, c.path, c.list_order
-            ORDER BY c.list_order
-        LOOP
-                return next item;
-        end loop;
-end;
-$$ language plpgsql;
-
-COMMENT ON FUNCTION menu_children(int) IS 
-$$ This function returns all menu  items which are children of in_parent_id 
-(the only input parameter). 
-
-It is thus similar to menu_generate() but it only returns the menu items 
-associated with nodes directly descendant from the parent.  It is used for
-menues for frameless browsers.$$;
-
-CREATE OR REPLACE FUNCTION 
-menu_insert(in_parent_id int, in_position int, in_label text)
-returns int
-AS $$
-DECLARE
-	new_id int;
-BEGIN
-	UPDATE menu_node 
-	SET position = position * -1
-	WHERE parent = in_parent_id
-		AND position >= in_position;
-
-	INSERT INTO menu_node (parent, position, label)
-	VALUES (in_parent_id, in_position, in_label);
-
-	SELECT INTO new_id currval('menu_node_id_seq');
-
-	UPDATE menu_node 
-	SET position = (position * -1) + 1
-	WHERE parent = in_parent_id
-		AND position < 0;
-
-	RETURN new_id;
-END;
-$$ language plpgsql;
-
-comment on function menu_insert(int, int, text) is $$
-This function inserts menu items at arbitrary positions.  The arguments are, in
-order:  parent, position, label.  The return value is the id number of the menu
-item created. $$;
-
-
 CREATE VIEW menu_friendly AS
 SELECT t."level", t.path, t.list_order, 
        (repeat(' '::text, (2 * t."level")) || (n.label)::text) AS label, 

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