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

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



Revision: 3034
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3034&view=rev
Author:   einhverfr
Date:     2010-07-29 16:29:56 +0000 (Thu, 29 Jul 2010)

Log Message:
-----------
Numerous fixes, but including to AJAX chart searching routines.

Modified Paths:
--------------
    trunk/LedgerSMB/AA.pm
    trunk/UI/lib/elements.html
    trunk/scripts/journal.pl
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Company.sql
    trunk/sql/modules/Roles.sql
    trunk/sql/modules/Voucher.sql
    trunk/sql/modules/chart.sql

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2010-07-29 02:43:35 UTC (rev 3033)
+++ trunk/LedgerSMB/AA.pm	2010-07-29 16:29:56 UTC (rev 3034)
@@ -1251,7 +1251,7 @@
         ## needs fixing (SELECT *)
         $query = qq|
 			SELECT * 
-			  FROM shipto
+			  FROM new_shipto
 			 WHERE trans_id = $form->{"$form->{vc}_id"}|;
 
         $sth = $dbh->prepare($query);

Modified: trunk/UI/lib/elements.html
===================================================================
--- trunk/UI/lib/elements.html	2010-07-29 02:43:35 UTC (rev 3033)
+++ trunk/UI/lib/elements.html	2010-07-29 16:29:56 UTC (rev 3034)
@@ -133,7 +133,19 @@
 	      $(hidden_field_to_update).value = li.id;
 	      text.blur();
 	    }
-	    new Ajax.Autocompleter('<?lsmb attribute_data.id ?>-ac-search', '<?lsmb attribute_data.id ?>-ac-choices', '<?lsmb element_data.ajax_target ?>', {afterUpdateElement:post_ajax_setter})
+	    new Ajax.Autocompleter('<?lsmb attribute_data.id ?>-ac-search', 
+                                   '<?lsmb attribute_data.id ?>-ac-choices', 
+                                   '<?lsmb element_data.ajax_target ?>', 
+                                   {"afterUpdateElement":"post_ajax_setter"
+                                   <?lsmb IF attribute_data.params ?>
+                                   'params' : {<?lsmb FOR k
+                                               IN attribute_data.params.keys();
+                                               ?>,
+                                               <?lsmb k ?> : <?lsmb
+                                                  attribute_data.params.keys()
+                                               -?>
+                                         <?lsmb END -?> } <?lsmb END -?>
+                                   })
 	  //--></script>
   <?lsmb END ?>
 <?lsmb END ?>

Modified: trunk/scripts/journal.pl
===================================================================
--- trunk/scripts/journal.pl	2010-07-29 02:43:35 UTC (rev 3033)
+++ trunk/scripts/journal.pl	2010-07-29 16:29:56 UTC (rev 3034)
@@ -54,7 +54,7 @@
        
       if ($r =~ m/-ac-search$/)
       {
-        my @call_args = ($request->{$r});
+        my @call_args = ($request->{$r}, $request->{link_desc});
         my @results = $request->call_procedure( procname => $funcname, args => ..hidden.., order_by => 'accno' );
         foreach (@results) { $results_hash{$_->{'accno'}.'--'.$_->{'description'}} = $_->{'accno'}.'--'.$_->{'description'}; }
       }

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2010-07-29 02:43:35 UTC (rev 3033)
+++ trunk/sql/Pg-database.sql	2010-07-29 16:29:56 UTC (rev 3034)
@@ -1480,12 +1480,14 @@
 create index ap_invnumber_key on ap (invnumber);
 create index ap_ordnumber_key on ap (ordnumber);
 create index ap_quonumber_key on ap (quonumber);
+create index ap_curr_idz on ap(curr);
 --
 create index ar_id_key on ar (id);
 create index ar_transdate_key on ar (transdate);
 create index ar_invnumber_key on ar (invnumber);
 create index ar_ordnumber_key on ar (ordnumber);
 create index ar_quonumber_key on ar (quonumber);
+create index ar_curr_idz on ar(curr);
 --
 create index assembly_id_key on assembly (id);
 --
@@ -2802,6 +2804,9 @@
     
 CREATE INDEX location_city_prov_gist_idx ON location USING gist(city gist_trgm_ops);
 CREATE INDEX entity_name_gist_idx ON entity USING gist(name gist_trgm_ops);
+CREATE INDEX ap_approved_idx ON ap(approved);
+CREATE INDEX ar_approved_idx ON ar(approved);
+CREATE INDEX gl_approved_idx ON gl(approved);
 
 CREATE TABLE pending_job (
 	id serial not null unique,

Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql	2010-07-29 02:43:35 UTC (rev 3033)
+++ trunk/sql/modules/Company.sql	2010-07-29 16:29:56 UTC (rev 3034)
@@ -30,19 +30,25 @@
 		SELECT e.id, e.control_code, c.id, ec.id, ec.meta_number, 
 			ec.description, ec.entity_class, 
 			c.legal_name, c.sic_code, b.description , ec.curr::text
-		FROM entity e
-		JOIN company c ON (e.id = c.entity_id)
-		JOIN entity_credit_account ec ON (ec.entity_id = e.id)
+		FROM (select * from entity where in_control_code = control_code
+                      union
+                      select * from entity where in_control_code is null) e
+		JOIN (SELECT * FROM company 
+                       WHERE legal_name like  '%' || in_legal_name || '%'
+                      UNION ALL
+                      SELECT * FROM company
+                       WHERE in_legal_name IS NULL) c ON (e.id = c.entity_id)
+		JOIN (SELECT * FROM entity_credit_account 
+                       WHERE meta_number = in_meta_number
+                      UNION ALL
+                      SELECT * from entity_credit_account
+                       WHERE meta_number ec IS NULL) ec ON (ec.entity_id = e.id)
 		LEFT JOIN business b ON (ec.business_id = b.id)
 		WHERE ec.entity_class = in_account_class
-			AND (e.control_code = in_control_code 
-				or in_control_code IS NULL)
 			AND (c.id IN (select company_id FROM company_to_contact
 				WHERE contact LIKE ALL(t_contact_info))
 				OR '' LIKE ALL(t_contact_info))
 			
-			AND (ec.meta_number = in_meta_number 
-				OR in_meta_number IS NULL)
 			AND (c.legal_name like '%' || in_legal_name || '%'
 				OR in_legal_name IS NULL)
 			AND ((in_address IS NULL AND in_city IS NULL 

Modified: trunk/sql/modules/Roles.sql
===================================================================
--- trunk/sql/modules/Roles.sql	2010-07-29 02:43:35 UTC (rev 3033)
+++ trunk/sql/modules/Roles.sql	2010-07-29 16:29:56 UTC (rev 3034)
@@ -1492,6 +1492,7 @@
 GRANT SELECT ON payment_type TO public;
 GRANT SELECT ON lsmb_roles TO public;
 GRANT SELECT ON employee_search TO PUBLIC;
+GRANT SELECT ON warehouse TO public;
 
 GRANT EXECUTE ON FUNCTION user__get_all_users() TO public;
 

Modified: trunk/sql/modules/Voucher.sql
===================================================================
--- trunk/sql/modules/Voucher.sql	2010-07-29 02:43:35 UTC (rev 3033)
+++ trunk/sql/modules/Voucher.sql	2010-07-29 16:29:56 UTC (rev 3034)
@@ -273,44 +273,16 @@
 DECLARE out_value batch_list_item;
 BEGIN
 	FOR out_value IN
-		SELECT b.id, c.class, b.control_code, b.description, u.username,
-			b.created_on, b.default_date, 0, 0
-		FROM batch b
-		JOIN batch_class c ON (b.batch_class_id = c.id)
-		LEFT JOIN users u ON (u.entity_id = b.created_by)
-		LEFT JOIN voucher v ON (v.batch_id = b.id)
-		LEFT JOIN batch_class vc ON (v.batch_class = vc.id)
-		LEFT JOIN ar ON (vc.id = 2 AND v.trans_id = ar.id)
-		LEFT JOIN ap ON (vc.id = 1 AND v.trans_id = ap.id)
-		LEFT JOIN acc_trans al ON 
-			((vc.id = 5 AND v.trans_id = al.trans_id) OR
-				(vc.id IN (3, 4, 6, 7) 
-					AND al.voucher_id = v.id))
-		LEFT JOIN chart alc ON (al.chart_id = alc.id)
-		WHERE (c.id = in_class_id OR in_class_id IS NULL) AND 
-			(b.description LIKE 
-				'%' || in_description || '%' OR
-				in_description IS NULL) AND
-			(in_created_by_eid = b.created_by OR
-				in_created_by_eid IS NULL) AND
-			((in_approved = false OR in_approved IS NULL AND
-				approved_on IS NULL) OR
-				(in_approved = true AND approved_on IS NOT NULL)
-			)
-		GROUP BY b.id, c.class, b.description, u.username, b.created_on,
-			b.control_code, b.default_date
-		HAVING  
-			(in_amount_gt IS NULL OR
-			sum(coalesce(ar.amount - ar.paid, ap.amount - ap.paid, 
-				al.amount)) 
-			>= in_amount_gt) 
-			AND 
-			(in_amount_lt IS NULL OR
-			sum(coalesce(ar.amount - ar.paid, ap.amount - ap.paid, 
-				al.amount))
-			<= in_amount_lt)
-			AND count(v.*) = 0
-		ORDER BY b.control_code, b.description
+               SELECT b.id, c.class, b.control_code, b.description, u.username,
+                        b.created_on, b.default_date, 0, 0
+                FROM batch b
+                JOIN batch_class c ON (b.batch_class_id = c.id)
+                JOIN users u ON (u.entity_id = b.created_by)
+                LEFT JOIN voucher v ON (v.batch_id = b.id) where v.id is null
+                GROUP BY b.id, c.class, b.description, u.username, b.created_on, 
+                        b.control_code, b.default_date
+                ORDER BY b.control_code, b.description
+
 		
 	LOOP
 		RETURN NEXT out_value;

Modified: trunk/sql/modules/chart.sql
===================================================================
--- trunk/sql/modules/chart.sql	2010-07-29 02:43:35 UTC (rev 3033)
+++ trunk/sql/modules/chart.sql	2010-07-29 16:29:56 UTC (rev 3034)
@@ -104,13 +104,20 @@
 COMMENT ON FUNCTION chart_get_ar_ap(in_account_class int) IS
 $$ This function returns the cash account acording with in_account_class which must be 1 or 2 $$;
 
-CREATE OR REPLACE FUNCTION chart_list_search(search text)
-RETURNS SETOF chart AS
+CREATE OR REPLACE FUNCTION chart_list_search(search text, link_desc text)
+RETURNS SETOF account AS
 $$
-DECLARE out_row chart%ROWTYPE;
+DECLARE out_row account%ROWTYPE;
 BEGIN
 	FOR out_row IN 
-		SELECT * FROM chart WHERE accno ~* ('^'||search) OR description ~* ('^'||search) ORDER BY accno
+		SELECT * FROM account 
+                 WHERE (accno ~* ('^'||search) 
+                       OR description ~* ('^'||search))
+                       AND (link_desc IS NULL 
+                           or id in 
+                          (select account_id from account_link 
+                            where description = link_desc))
+              ORDER BY accno
 	LOOP
 		RETURN next out_row;
 	END LOOP;


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