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

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



Revision: 4413
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4413&view=rev
Author:   einhverfr
Date:     2012-03-08 10:56:18 +0000 (Thu, 08 Mar 2012)
Log Message:
-----------

Correcting UI not showing buisness reporting units on edit screen.  Thus AR/AP largely working outside of reports, to be moved to new framework asap

Modified Paths:
--------------
    trunk/LedgerSMB/Form.pm
    trunk/bin/aa.pl

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2012-03-08 09:44:16 UTC (rev 4412)
+++ trunk/LedgerSMB/Form.pm	2012-03-08 10:56:18 UTC (rev 4413)
@@ -2284,8 +2284,7 @@
 				a.entity_credit_account AS entity_id, 
 				a.datepaid, a.duedate, a.ordnumber,
 				a.taxincluded, a.curr AS currency, a.notes, 
-				a.intnotes, ce.name AS $vc, a.department_id, 
-				d.description AS department,
+				a.intnotes, ce.name AS $vc, 
 				a.amount AS oldinvtotal, a.paid AS oldtotalpaid,
 				a.person_id, e.name AS employee, 
 				c.language_code, a.ponumber, a.reverse,
@@ -2297,7 +2296,6 @@
 			LEFT JOIN entity_employee er 
                                    ON (er.entity_id = a.person_id)
 			LEFT JOIN entity e ON (er.entity_id = e.id)
-			LEFT JOIN department d ON (d.id = a.department_id)
                         LEFT JOIN country_tax_form ctf 
                                   ON (ctf.id = c.taxform_id)
 			WHERE a.id = ? AND c.entity_class = 
@@ -2373,13 +2371,16 @@
         # get amounts from individual entries
         $query = qq|
 			SELECT c.accno, c.description, a.source, a.amount,
-				a.memo,a.entry_id, a.transdate, a.cleared, a.project_id,
-				p.projectnumber
+				a.memo,a.entry_id, a.transdate, a.cleared, 
+                                compound_array(ARRAY[ARRAY[bul.class_id, bul.bu_id]])
+                                AS bu_lines
 			FROM acc_trans a
 			JOIN chart c ON (c.id = a.chart_id)
-			LEFT JOIN project p ON (p.id = a.project_id)
+                   LEFT JOIN business_unit_ac bul ON a.entry_id = bul.entry_id
 			WHERE a.trans_id = ?
 				AND a.fx_transaction = '0'
+                        GROUP BY c.accno, c.description, a.source, a.amount,
+                                a.memo,a.entry_id, a.transdate, a.cleared
 			ORDER BY transdate|;
 
         $sth = $dbh->prepare($query);
@@ -2394,6 +2395,9 @@
         # store amounts in {acc_trans}{$key} for multiple accounts
         while ( my $ref = $sth->fetchrow_hashref('NAME_lc') ) {
             $self->db_parse_numeric(sth=>$sth, hashref=>$ref);#tshvr
+            for my $aref (@{$ref->{bu_lines}}){
+                $ref->{"b_unit_$aref->[0]"} = $aref->[1];
+            }
             $ref->{exchangerate} =
               $self->get_exchangerate( $dbh, $self->{currency},
                 $ref->{transdate}, $fld );

Modified: trunk/bin/aa.pl
===================================================================
--- trunk/bin/aa.pl	2012-03-08 09:44:16 UTC (rev 4412)
+++ trunk/bin/aa.pl	2012-03-08 10:56:18 UTC (rev 4413)
@@ -221,6 +221,8 @@
               qq|<option value="$_->{name}--$_->{id}">$_->{name}\n|;
         }
     }
+    # Business Reporting Units
+    $form->all_business_units;
 
     # sales staff
     if ( @{ $form->{all_employee} } ) {
@@ -326,9 +328,13 @@
                        $form->{rowcount}++;
                         $netamount += $form->{"${akey}_$i"};
 
-                        $form->{"projectnumber_$i"} =
-"$form->{acc_trans}{$key}->[$i-1]->{projectnumber}--$form->{acc_trans}{$key}->[$i-1]->{project_id}"
-                          if $form->{acc_trans}{$key}->[ $i - 1 ]->{project_id};
+                        my $ref = $form->{acc_trans}{$key}->[ $i - 1 ];
+                        for my $cls (@{$form->{bu_class}}){
+                           if ($ref->{"b_unit_$cls->{id}"}){
+                              $form->{"b_unit_$cls->{id}_$i"} 
+                                                         = $ref->{"b_unit_$cls->{id}"};
+                           }
+                        }
                     }
                     else {
                         $form->{invtotal} =
@@ -780,7 +786,12 @@
                 print qq|<td><select name="b_unit_$cls->{id}_$i">
                                     <option></option>|;
                       for my $bu (@{$form->{b_units}->{"$cls->{id}"}}){
-                         print qq|  <option value="$bu->{id}">$bu->{control_code}
+                         my $selected = '';
+                         if ($form->{"b_unit_$cls->{id}_$i"} eq $bu->{id}){
+                            $selected = "SELECTED='SELECTED'";
+                         }
+                         print qq|  <option value="$bu->{id}" $selected>
+                                        $bu->{control_code}
                                     </option>|;
                       }
                 print qq|

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