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

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



Revision: 2426
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2426&view=rev
Author:   einhverfr
Date:     2008-12-11 00:02:59 +0000 (Thu, 11 Dec 2008)

Log Message:
-----------
 * Payment searches now show batch control codes and comments
 * Minor issues corrected with old payment report
 * Tests added for all these issues

Modified Paths:
--------------
    trunk/LedgerSMB/RP.pm
    trunk/UI/form-dynatable.html
    trunk/UI/rp-payments.html
    trunk/bin/rp.pl
    trunk/scripts/payment.pl
    trunk/sql/modules/Payment.sql
    trunk/sql/modules/test/Payment.sql
    trunk/t/04-template-handling.t
    trunk/t/43-dbtest.t
    trunk/t/data/62-request-data

Added Paths:
-----------
    trunk/sql/modules/drop-Payment.sql

Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm	2008-12-09 23:03:14 UTC (rev 2425)
+++ trunk/LedgerSMB/RP.pm	2008-12-11 00:02:59 UTC (rev 2426)
@@ -2399,7 +2399,9 @@
 			   SELECT ce.name, ac.transdate, 
 			          sum(ac.amount) * $ml AS paid, ac.source, 
 			          ac.memo, ee.name AS employee, a.till, a.curr,
-			          c.meta_number
+			          c.meta_number, 
+			          b.control_code as batch_control,
+			          b.description AS batch_description
 			     FROM acc_trans ac
 			     JOIN $form->{db} a ON (ac.trans_id = a.id)
 			     JOIN entity_credit_account c ON 
@@ -2408,6 +2410,8 @@
 			LEFT JOIN entity_employee e ON 
 					(a.person_id = e.entity_id)
 			LEFT JOIN entity ee ON (e.entity_id = ee.id)
+			LEFT JOIN voucher v ON (ac.voucher_id = v.id)
+			LEFT JOIN batch b ON (b.id = v.batch_id)
 			          $dpt_join
 			    WHERE ac.chart_id = $ref->{id} 
 			          AND ac.approved AND a.approved
@@ -2423,7 +2427,8 @@
 
         $query .= qq|
 			GROUP BY ce.name, ac.transdate, ac.source, ac.memo,
-			         ee.name, a.till, a.curr, c.meta_number|;
+			         ee.name, a.till, a.curr, c.meta_number, 
+			         b.control_code, b.description|;
 
         if ( $form->{till} eq "" && !$form->{meta_number}) {
 
@@ -2432,19 +2437,24 @@
 				SELECT g.description, ac.transdate, 
 				       sum(ac.amount) * $ml AS paid, ac.source,
 				       ac.memo, ee.name AS employee, '' AS till,
-				       '' AS curr, '' AS meta_number
+				       '' AS curr, '' AS meta_number, 
+			               b.control_code as batch_control,
+			               b.description AS batch_description
 				  FROM acc_trans ac
 				  JOIN gl g ON (g.id = ac.trans_id)
 				  LEFT 
 				  JOIN entity_employee e ON 
 					(g.person_id = e.entity_id)
 				  JOIN entity ee ON (e.entity_id = ee.id)
+				LEFT JOIN voucher v ON (ac.voucher_id = v.id)
+				LEFT JOIN batch b ON (b.id = v.batch_id)
 				       $dpt_join
 				 WHERE ac.chart_id = $ref->{id} $glwhere
 			               AND ac.approved AND g.approved
 				       AND (ac.amount * $ml) > 0
 				 GROUP BY g.description, ac.transdate, 
-			               ac.source, ac.memo, ee.name|;
+			               ac.source, ac.memo, ee.name, 
+				       b.control_code, b.description|;
 
         }
 

Modified: trunk/UI/form-dynatable.html
===================================================================
--- trunk/UI/form-dynatable.html	2008-12-09 23:03:14 UTC (rev 2425)
+++ trunk/UI/form-dynatable.html	2008-12-11 00:02:59 UTC (rev 2426)
@@ -31,7 +31,7 @@
   <tr class="listheading">
 <?lsmb FOREACH column IN columns ?>
     <th class="listtop">
-	<?lsmb IF heading.$column.href ?><a class="listtop" href="<?lsmb heading.$column.href ?>"><?lsmb heading.$column.text ?></a>
+	<?lsmb IF heading.$column.href.defined ?><a class="listtop" href="<?lsmb heading.$column.href ?>"><?lsmb heading.$column.text ?></a>
 	<?lsmb ELSE; heading.$column; END ?>
     </th>
 <?lsmb END ?>

Modified: trunk/UI/rp-payments.html
===================================================================
--- trunk/UI/rp-payments.html	2008-12-09 23:03:14 UTC (rev 2425)
+++ trunk/UI/rp-payments.html	2008-12-11 00:02:59 UTC (rev 2426)
@@ -15,7 +15,7 @@
   </tr>
   <tr class="listheading">
 <?lsmb FOREACH column IN columns ?>
-<th class="listtop" 
+<th class="listtop">
 	<?lsmb IF heading.$column.href ?><a class="listtop" href="<?lsmb heading.$column.href ?>"><?lsmb heading.$column.text ?></a>
 	<?lsmb ELSE; heading.$column; END ?>
     </th>

Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl	2008-12-09 23:03:14 UTC (rev 2425)
+++ trunk/bin/rp.pl	2008-12-11 00:02:59 UTC (rev 2426)
@@ -1925,7 +1925,7 @@
     RP->payments( \%myconfig, \%$form );
 
     my @columns = $form->sort_columns(qw(meta_number transdate name paid source 
-memo));
+					memo batch_control batch_description));
 
     if ( $form->{till} ) {
         @columns =
@@ -2000,7 +2000,10 @@
         text => $locale->text('Date'),
         };
     $column_header{paid} = $locale->text('Amount');
+    $column_header{batch_control} = $locale->text('Batch');
+    $column_header{batch_description} = $locale->text('Batch Description');
     $column_header{curr} = $locale->text('Curr');
+    $column_header{memo} = $locale->text('Memo');
     $column_header{source} = {
         href => "$href&sort=source",
         text => $locale->text('Source'),
@@ -2049,6 +2052,8 @@
             $column_data{meta_number} = $payment->{meta_number};
             $column_data{name}      = $payment->{name};
             $column_data{transdate} = $payment->{transdate};
+            $column_data{batch_control} = $payment->{batch_control};
+            $column_data{batch_description} = $payment->{batch_description};
             $column_data{paid} =
                 $form->format_amount(\%myconfig, $payment->{paid}, 2, ' ');
             $column_data{curr}     = $payment->{curr};

Modified: trunk/scripts/payment.pl
===================================================================
--- trunk/scripts/payment.pl	2008-12-09 23:03:14 UTC (rev 2425)
+++ trunk/scripts/payment.pl	2008-12-11 00:02:59 UTC (rev 2426)
@@ -127,7 +127,8 @@
         }
     }
 
-    my @columns = qw(selected meta_number date_paid amount source company_paid);
+    my @columns = qw(selected meta_number date_paid amount source 
+		company_paid batch_description batch_control);
     my $contact_type = ($payment->{account_class} == 1) ? 'Vendor' : 'Customer';
 
     # CT:  Locale strings for gettext:
@@ -158,6 +159,14 @@
                           text => $request->{_locale}->text('Source'),
                           href => "$search_url&orderby=source",
                          },
+	 batch_control => {
+                          text => $request->{_locale}->text('Batch'),
+                          href => "$search_url&orderby=batch_control",
+			},
+	 batch_description => {
+                          text => $request->{_locale}->text('Batch Description'),
+                          href => "$search_url&orderby=batch_description",
+			},
     };
 
 
@@ -175,6 +184,8 @@
           date_paid    => $line->{date_paid},
           source       => $line->{source},
           meta_number  => $line->{meta_number},
+          batch_control => $line->{batch_control},
+          batch_description => $line->{batch_description},
           selected     => {
                           input => {
                                     type  => "checkbox",

Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql	2008-12-09 23:03:14 UTC (rev 2425)
+++ trunk/sql/modules/Payment.sql	2008-12-11 00:02:59 UTC (rev 2426)
@@ -939,6 +939,8 @@
 	company_paid text,
 	accounts text[],
         source text,
+	batch_control text,
+	batch_description text,
         date_paid date
 );
 
@@ -955,7 +957,8 @@
 				ELSE a.amount * -1 END), c.meta_number, 
 			c.id, co.legal_name,
 			compound_array(ARRAY[ARRAY[ch.id::text, ch.accno, 
-				ch.description]]), a.source, a.transdate
+				ch.description]]), a.source, 
+			b.control_code, b.description, a.transdate
 		FROM entity_credit_account c
 		JOIN ( select entity_credit_account, id
 			FROM ar WHERE in_account_class = 2
@@ -966,6 +969,8 @@
 		JOIN acc_trans a ON (arap.id = a.trans_id)
 		JOIN chart ch ON (ch.id = a.chart_id)
 		JOIN company co ON (c.entity_id = co.entity_id)
+		LEFT JOIN voucher v ON (v.id = a.voucher_id)
+		LEFT JOIN batch b ON (b.id = v.batch_id)
 		WHERE (ch.accno = in_cash_accno)
 			AND (c.id = in_credit_id OR in_credit_id IS NULL)
 			AND (a.transdate >= in_date_from 
@@ -973,7 +978,7 @@
 			AND (a.transdate <= in_date_to OR in_date_to IS NULL)
 			AND (source = in_source OR in_source IS NULL)
 		GROUP BY c.meta_number, c.id, co.legal_name, a.transdate, 
-			a.source
+			a.source, a.memo, b.id, b.control_code, b.description
 		ORDER BY a.transdate, c.meta_number, a.source
 	LOOP
 		RETURN NEXT out_row;

Added: trunk/sql/modules/drop-Payment.sql
===================================================================
--- trunk/sql/modules/drop-Payment.sql	                        (rev 0)
+++ trunk/sql/modules/drop-Payment.sql	2008-12-11 00:02:59 UTC (rev 2426)
@@ -0,0 +1,8 @@
+DROP TYPE payment_vc_info CASCADE;
+DROP TYPE payment_invoice CASCADE;
+DROP TYPE payment_contact_invoice CASCADE;
+DROP TYPE job__status CASCADE;
+DROP TYPE payment_location_result CASCADE;
+DROP TYPE payment_record  CASCADE;
+DROP TYPE payment_header_item CASCADE;
+DROP TYPE payment_line_item CASCADE;

Modified: trunk/sql/modules/test/Payment.sql
===================================================================
--- trunk/sql/modules/test/Payment.sql	2008-12-09 23:03:14 UTC (rev 2425)
+++ trunk/sql/modules/test/Payment.sql	2008-12-11 00:02:59 UTC (rev 2426)
@@ -28,6 +28,8 @@
 VALUES ('00001', 'testing', 'A', 'L', 'AP');
 INSERT INTO chart (accno, description, charttype, category, link)
 VALUES ('00002', 'testing2', 'A', 'E', 'AP_expense');
+INSERT INTO chart (accno, description, charttype, category, link)
+VALUES ('00003', 'testing2', 'A', 'A', 'AP_paid');
 
 INSERT INTO session (users_id, last_used, token, transaction_id)
 values (currval('users_id_seq'),  now(), md5('test2'), 2);
@@ -128,6 +130,23 @@
 		(SELECT total_due < 1000000
 			FROM payment_get_all_contact_invoices(1, NULL, 'USD', NULL, NULL, currval('batch_id_seq')::int, '00001', 'TEST1')) );
 
+INSERT INTO voucher(batch_id, batch_class, id, trans_id)
+values (currval('batch_id_seq')::int, 4, -100, currval('id')::int);
+INSERT INTO acc_trans(trans_id, chart_id, voucher_id, approved, amount,
+	transdate, source)
+values (currval('id')::int, 
+	(select id from chart where accno = '00003'), -100, true, '1', now(),
+	'_test_src1');
+INSERT INTO acc_trans(trans_id, chart_id, voucher_id, approved, amount, 
+	transdate, source)
+values (currval('id')::int, 
+	(select id from chart where accno = '00001'), -100, true, '-1', now(),
+	'_test_src1');
+
+INSERT INTO test_result(test_name, success)
+SELECT 'batch_description exists', count(batch_description) = 1 
+FROM payment__search('_test_src1', NULL, NULL, -101, '00003', 1);
+
 SELECT * FROM TEST_RESULT;
 
 SELECT (select count(*) from test_result where success is true) 

Modified: trunk/t/04-template-handling.t
===================================================================
--- trunk/t/04-template-handling.t	2008-12-09 23:03:14 UTC (rev 2425)
+++ trunk/t/04-template-handling.t	2008-12-11 00:02:59 UTC (rev 2426)
@@ -467,6 +467,20 @@
 
 like($line1, qr/^%PDF/, 'output file is pdf');
 
+$template =  LedgerSMB::Template->new(
+        path            => 'UI',
+        template        => 'rp-payments',
+        format          => 'HTML',
+        no_auto_output  => 1,
+        output_file     => 'rp_payment_test1'
+);
+
+$lsmb = {columns => ['test']};
+$template->render($lsmb);
..hidden.. =  get_output_line_array($template);
+cmp_ok(grep(/^\s*<\s*th\s+class="listtop"\s*>\s*$/, @output), '>', 0, 
+	'th tags properly finish');
+
 # Functions
 sub get_output_line_array {
         my $FH;

Modified: trunk/t/43-dbtest.t
===================================================================
--- trunk/t/43-dbtest.t	2008-12-09 23:03:14 UTC (rev 2425)
+++ trunk/t/43-dbtest.t	2008-12-11 00:02:59 UTC (rev 2426)
@@ -5,7 +5,7 @@
 	plan skip_all => 'Skipping all.  Told not to test db.';
 }
 else {
-	plan tests => 54;
+	plan tests => 55;
 	if (defined $ENV{LSMB_NEW_DB}){
 		$ENV{PGDATABASE} = $ENV{LSMB_NEW_DB};
 	}

Modified: trunk/t/data/62-request-data
===================================================================
--- trunk/t/data/62-request-data	2008-12-09 23:03:14 UTC (rev 2425)
+++ trunk/t/data/62-request-data	2008-12-11 00:02:59 UTC (rev 2426)
@@ -113,6 +113,23 @@
 		}
 	},
 	{
+		'_test_id'     => 'Payment search (OLD)',
+		'_codebase'    => 'old',
+		'account'      => '1060--Checking Account',
+		'module'       => 'rp.pl',
+		'action'       => 'list_payments',
+	},
+	{
+		'_test_id'	=> 'Payment Search (NEW)',
+		'_codebase'	=> 'new',
+		module		=> 'payment.pl',
+		account_class	=> 1,				
+		meta_number     => 'TEST_VENDOR',	
+		cash_accno	=> '-111',
+		date_reversed	=> '2009-12-01',
+		action 		=> 'get_search_results',
+	},
+	{
 		'_test_id'      => 'Payment print total',
 		'_codebase'     => 'new',
 		'action'        => 'print',


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