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

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



Revision: 1960
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1960&view=rev
Author:   einhverfr
Date:     2007-12-07 11:30:27 -0800 (Fri, 07 Dec 2007)

Log Message:
-----------
Adding vendor number to payments report.

Modified Paths:
--------------
    trunk/LedgerSMB/RP.pm
    trunk/LedgerSMB.pm
    trunk/bin/rp.pl

Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm	2007-12-07 17:19:41 UTC (rev 1959)
+++ trunk/LedgerSMB/RP.pm	2007-12-07 19:30:27 UTC (rev 1960)
@@ -2189,10 +2189,12 @@
     my $ml = 1;
     if ( $form->{db} eq 'ar' ) {
         $table = 'customer';
+        $account_class = 2;
         $ml    = -1;
     }
     if ( $form->{db} eq 'ap' ) {
         $table = 'vendor';
+        $account_class = 1;
     }
 
     my $query;
@@ -2215,6 +2217,9 @@
     if ( $form->{fromdate} ) {
         $where .= " AND ac.transdate >= " . $dbh->quote( $form->{fromdate} );
     }
+    if ($form->{meta_number} ) {
+        $where .= " AND c.meta_number = " . $dbh->quote($form->{meta_number});
+    }
     if ( $form->{todate} ) {
         $where .= " AND ac.transdate <= " . $dbh->quote( $form->{todate} );
     }
@@ -2224,7 +2229,7 @@
 
     if ( $form->{description} ne "" ) {
         $var = $dbh->quote( $form->like( lc $form->{description} ) );
-        $where .= " AND lower(c.name) LIKE $var";
+        $where .= " AND lower(ce.name) LIKE $var";
     }
     if ( $form->{source} ne "" ) {
         $var = $dbh->quote( $form->like( lc $form->{source} ) );
@@ -2263,14 +2268,19 @@
         push @{ $form->{PR} }, $ref;
         $sth->finish;
 
-        $query = qq|
-			   SELECT c.name, ac.transdate, 
+         $query = qq|
+			   SELECT ce.name, ac.transdate, 
 			          sum(ac.amount) * $ml AS paid, ac.source, 
-			          ac.memo, e.name AS employee, a.till, a.curr
+			          ac.memo, ee.name AS employee, a.till, a.curr,
+			          c.meta_number
 			     FROM acc_trans ac
 			     JOIN $form->{db} a ON (ac.trans_id = a.id)
-			     JOIN $table c ON (c.id = a.${table}_id)
-			LEFT JOIN employee e ON (a.employee_id = e.id)
+			     JOIN entity_credit_account c ON 
+				(c.id = a.entity_credit_account)
+			     JOIN entity ce ON (ce.id = c.entity_id)
+			LEFT JOIN entity_employee e ON 
+					(a.person_id = e.entity_id)
+			LEFT JOIN entity ee ON (e.entity_id = ee.id)
 			          $dpt_join
 			    WHERE ac.chart_id = $ref->{id} $where|;
 
@@ -2283,26 +2293,28 @@
         }
 
         $query .= qq|
-			GROUP BY c.name, ac.transdate, ac.source, ac.memo,
-			         e.name, a.till, a.curr|;
+			GROUP BY ce.name, ac.transdate, ac.source, ac.memo,
+			         ee.name, a.till, a.curr, c.meta_number|;
 
-        if ( $form->{till} eq "" ) {
+        if ( $form->{till} eq "" && !$form->{meta_number}) {
 
-            $query .= qq|
+             $query .= qq|
  				UNION
 				SELECT g.description, ac.transdate, 
 				       sum(ac.amount) * $ml AS paid, ac.source,
-				       ac.memo, e.name AS employee, '' AS till,
-				       '' AS curr
+				       ac.memo, ee.name AS employee, '' AS till,
+				       '' AS curr, '' AS meta_number
 				  FROM acc_trans ac
 				  JOIN gl g ON (g.id = ac.trans_id)
 				  LEFT 
-				  JOIN employee e ON (g.employee_id = e.id)
+				  JOIN entity_employee e ON 
+					(g.person_id = e.entity_id)
+				  JOIN entity ee ON (e.entity_id = ee.id)
 				       $dpt_join
 				 WHERE ac.chart_id = $ref->{id} $glwhere
 				       AND (ac.amount * $ml) > 0
 				 GROUP BY g.description, ac.transdate, 
-			               ac.source, ac.memo, e.name|;
+			               ac.source, ac.memo, ee.name|;
 
         }
 

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2007-12-07 17:19:41 UTC (rev 1959)
+++ trunk/LedgerSMB.pm	2007-12-07 19:30:27 UTC (rev 1960)
@@ -151,6 +151,7 @@
     $self->{VERSION} = $VERSION;
 
     $self->merge($params);
+    $self->{have_latex} = $LedgerSMB::Sysconfig::latex;
 
     # Adding this so that empty values are stored in the db as NULL's.  If
     # stored procedures want to handle them differently, they must opt to do so.

Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl	2007-12-07 17:19:41 UTC (rev 1959)
+++ trunk/bin/rp.pl	2007-12-07 19:30:27 UTC (rev 1960)
@@ -1877,6 +1877,7 @@
     my %column_data;
     for (@{$column_index}) { $column_data{$_} = ' ' }
 
+
     #SC: Yes, right now these are global, inherited from generate_tax_report
     $subtotal =
       $form->format_amount( \%myconfig, $subtotalnetamount + $subtotaltax,
@@ -1910,6 +1911,7 @@
 
     my %hiddens;
     my @options;
+    my $vc = ($form->{db} eq 'ar') ? 'Customer' : 'Vendor';
     if ( $form->{account} ) {
         ( $form->{paymentaccounts} ) = split /--/, $form->{account};
     }
@@ -1921,11 +1923,12 @@
 
     RP->payments( \%myconfig, \%$form );
 
-    my @columns = $form->sort_columns(qw(transdate name paid source memo));
+    my @columns = $form->sort_columns(qw(transdate name paid source meta_number 
+memo));
 
     if ( $form->{till} ) {
         @columns =
-          $form->sort_columns(qw(transdate name paid curr source till));
+          $form->sort_columns(qw(transdate name paid curr source meta_number till));
         if ( $myconfig{role} ne 'user' ) {
             @columns =
               $form->sort_columns(
@@ -2001,9 +2004,9 @@
         href => "$href&sort=source",
         text => $locale->text('Source'),
         };
-    $column_header{memo} = {
-        href => "$href&sort=memo",
-        text => $locale->text('Memo'),
+    $column_header{meta_number} = {
+        href => "$href&sort=meta_number",
+        text => $locale->text("$vc Number"),
         };
     $column_header{employee} = {
         href => "$href&sort=employee",
@@ -2042,6 +2045,7 @@
             next if ( $form->{till} && !$payment->{till} );
 
             my %column_data;
+            $column_data{meta_number} = $payment->{meta_number};
             $column_data{name}      = $payment->{name};
             $column_data{transdate} = $payment->{transdate};
             $column_data{paid} =


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