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

SF.net SVN: ledger-smb:[4560] addons/1.3/b_units/trunk/patches/b_units. patch



Revision: 4560
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4560&view=rev
Author:   einhverfr
Date:     2012-03-25 07:04:59 +0000 (Sun, 25 Mar 2012)
Log Message:
-----------
Updating patch

Modified Paths:
--------------
    addons/1.3/b_units/trunk/patches/b_units.patch

Modified: addons/1.3/b_units/trunk/patches/b_units.patch
===================================================================
--- addons/1.3/b_units/trunk/patches/b_units.patch	2012-03-25 06:47:23 UTC (rev 4559)
+++ addons/1.3/b_units/trunk/patches/b_units.patch	2012-03-25 07:04:59 UTC (rev 4560)
@@ -1,134 +1,123 @@
-Index: bin/aa.pl
+Index: LedgerSMB/GL.pm
 ===================================================================
---- bin/aa.pl	(revision 4545)
-+++ bin/aa.pl	(working copy)
-@@ -435,6 +435,10 @@
+--- LedgerSMB/GL.pm	(revision 4473)
++++ LedgerSMB/GL.pm	(working copy)
+@@ -89,6 +89,7 @@
+ sub post_transaction {
  
-     $title = $form->{title};
+     my ( $self, $myconfig, $form, $locale) = @_;
++    $form->all_business_units;
+     $form->{reference} = $form->update_defaults( $myconfig, 'glnumber', $dbh )
+       unless $form->{reference};
+     my $null;
+@@ -187,6 +188,10 @@
+     my $debit;
+     my $credit;
  
-+    $form->all_business_units($form->{transdate}, 
-+                              $form->{"$form->{vc}_id"}, 
-+                              $form->{ARAP});
-+
-     if($form->{batch_id})
-     {
- 		$form->{batch_control_code}=$form->get_batch_control_code($form->{dbh},$form->{batch_id});
-@@ -738,7 +742,13 @@
- 	  <th>| . $locale->text('Account') . qq|</th>
- 	  <th>| . $locale->text('Description') . qq|</th>
- 	  <th>| . $locale->text('Tax Form Applied') . qq|</th>
--	  $project
-+	  $project|;
-+    for my $cls (@{$form->{bu_class}}){
-+        if (scalar @{$form->{b_units}->{"$cls->{id}"}}){
-+            print qq|<th>| . $locale->text($cls->{label}) . qq|</th>|;
-+        }
-+    }
-+       print qq|
- 	</tr>
- |;
++    $b_sth = $dbh->prepare(
++            qq|INSERT INTO business_unit_ac (entry_id, class_id, bu_id) | . 
++            qq|VALUES (currval('acc_trans_entry_id_seq'), ?, ?)|
++    );
+     # insert acc_trans transactions
+     for $i ( 0 .. $form->{rowcount} ) {
  
-@@ -786,7 +796,27 @@
- 	  <td><select name="$form->{ARAP}_amount_$i">$selectamount</select></td>
- 	  $description
-           $taxformcheck
--	  $project
-+	  $project|;
-+
-+        for my $cls (@{$form->{bu_class}}){
-+            if (scalar @{$form->{b_units}->{"$cls->{id}"}}){
-+                print qq|<td><select name="b_unit_$cls->{id}_$i">
-+                                    <option></option>|;
-+                      for my $bu (@{$form->{b_units}->{"$cls->{id}"}}){
-+                         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|
-+                             </select>
-+                        </th>|;
+@@ -236,6 +241,12 @@
+                 ($form->{"cleared_$i"} || 0)
+             ) || $form->dberror($query);
+ 
++            for my $cls(@{$form->{bu_class}}){
++                if ($form->{"b_unit_$cls->{id}_$i"}){
++                    $b_sth->execute($cls->{id}, 
++                                     $form->{"b_unit_$cls->{id}_$i"});
++                }
 +            }
-+        }
-+        print qq|
- 	</tr>
- |;
- 
-@@ -1486,6 +1516,9 @@
-         $selectname = qq|<input name=$form->{vc} size=35>|;
+             $posted = 1;
+         }
      }
+@@ -646,8 +657,18 @@
+         $sth = $dbh->prepare($query);
+         $sth->execute( $form->{id} ) || $form->dberror($query);
  
-+    # Business Reporting Units
-+    $form->all_business_units;
++        my $bu_sth = $dbh->prepare(
++            qq|SELECT * FROM business_unit_ac 
++                WHERE entry_id = ?  |
++        );
 +
-     # departments
-     if ( @{ $form->{all_department} } ) {
-         $form->{selectdepartment} = "<option>\n";
-Index: bin/io.pl
+         while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
++            $bu_sth->execute($ref->{entry_id});
++            while ($buref = $bu_sth->fetchrow_hashref(NAME_lc) ) {
++                 $ref->{"b_unit_$buref->{class_id}"} = $buref->{bu_id};
++            }
+ 
++
+             if ( $ref->{fx_transaction} ) {
+                 $form->{transfer} = 1;
+             }
+Index: LedgerSMB/Form.pm
 ===================================================================
---- bin/io.pl	(revision 4473)
-+++ bin/io.pl	(working copy)
-@@ -124,6 +124,15 @@
+--- LedgerSMB/Form.pm	(revision 4473)
++++ LedgerSMB/Form.pm	(working copy)
+@@ -1903,6 +1903,45 @@
+     return $i;
+ }
  
- sub display_row {
-     my $numrows = shift;
-+    my $lsmb_module;
-+    if ($form->{vc} eq 'customer'){
-+       $lsmb_module = 'AR';
-+    } elsif ($form->{vc} eq 'vendor'){
-+       $lsmb_module = 'AP';
-+    }
-+    $form->all_business_units($form->{transdate}, 
-+                              $form->{"$form->{vc}_id"}, 
-+                              $lsmb_module);
- 
-     @column_index = qw(runningnumber partnumber description qty);
- 
-@@ -172,6 +181,14 @@
- 
-     push @column_index, @{LedgerSMB::Sysconfig::io_lineitem_columns};
- 
-+    for my $cls(@{$form->{bu_class}}){
-+        if (scalar @{$form->{b_units}->{"$cls->{id}"}}){
-+             push @column_index, "b_unit_$cls->{id}";
-+             $column_data{"b_unit_$cls->{id}"} = 
-+               qq|<th class=listheading nowrap>| . $cls->{label} . qq|</th>|;
++=item $form->all_business_units([$transdate, $credit_id]);
++
++Returns a list at bu_class with class information, ordered by order information
++and a list of units in lists at bu_units->$class_id.  $transdate is used to
++filter projects active at specified date.  $credit_id is to filter out 
++units assigned to other customers.
++
++=cut
++
++sub all_business_units {
++
++    my ( $self, $transdate, $credit_id, $module_name) = @_;
++    $self->{bu_class} = [];
++    $self->{b_units} = {};
++
++    my $dbh       = $self->{dbh};
++    my $class_sth = $dbh->prepare(
++                q|SELECT * FROM business_unit__list_classes('1', ?)|
++    );
++    $class_sth->execute($module_name);
++
++    my $bu_sth    = $dbh->prepare(
++                q|SELECT * 
++                    FROM business_unit__list_by_class(?, ?, ?, 'false')|
++    );
++
++    while (my $classref = $class_sth->fetchrow_hashref('NAME_lc')){
++        push @{$self->{bu_class}}, $classref;
++        $bu_sth->execute($classref->{id}, $transdate, $credit_id);
++        $self->{b_units}->{$classref->{id}} = [];
++        while (my $buref = $bu_sth->fetchrow_hashref('NAME_lc')){
++           push @{$self->{b_units}->{$classref->{id}}}, $buref;
 +        }
 +    }
++    $class_sth->finish;
++    $bu_sth->finish;
 +
-     push @column_index, "taxformcheck";#increase the number of elements by pushing into column_index.(Ex: NEw added element 
- 				       # taxformcheck & check the screen AR->Sales Invoice) do everything before colspan ;
++}
++
+ =item $form->all_vc($myconfig, $vc, $module, $dbh, $transdate, $job);
  
-@@ -334,6 +351,26 @@
- 
- 	}
- 
-+        for my $cls(@{$form->{bu_class}}){
-+            if (scalar @{$form->{b_units}->{"$cls->{id}"}}){
-+                $column_data{"b_unit_$cls->{id}"} = 
-+                   qq|<td><select name="b_unit_$cls->{id}_$i">
-+                           <option></option>|;
-+                for my $bu (@{$form->{b_units}->{"$cls->{id}"}}){
-+                   my $selected = "";
-+                   if ($bu->{id} eq $form->{"b_unit_$cls->{id}_$i"}){
-+                       $selected = "SELECTED='SELECTED'";
-+                   }
-+                   $column_data{"b_unit_$cls->{id}"} .= qq|
-+                       <option value="$bu->{id}" $selected >
-+                               $bu->{control_code}
-+                       </option>|;
-+                }
-+                $column_data{"b_unit_$cls->{id}"} .= qq|
-+                     </select></td>|;
-+                   
-+            }
-+        }
- 
- $column_data{runningnumber} =
-           qq|<td><input name="runningnumber_$i" size=3 value=$i></td>|;
+ Populates the list referred to by $form->{all_${vc}} with hashes of either
+@@ -2583,10 +2622,13 @@
+         $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
++				p.projectnumber,
++                                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'
+ 			ORDER BY transdate|;
 Index: LedgerSMB/IR.pm
 ===================================================================
 --- LedgerSMB/IR.pm	(revision 4473)
@@ -448,68 +437,219 @@
              $tth->execute( $ref->{id} );
  
              $ref->{taxaccounts} = "";
-Index: LedgerSMB/Form.pm
+Index: UI/journal/journal_entry.html
 ===================================================================
---- LedgerSMB/Form.pm	(revision 4473)
-+++ LedgerSMB/Form.pm	(working copy)
-@@ -1903,6 +1903,45 @@
-     return $i;
- }
+--- UI/journal/journal_entry.html	(revision 4473)
++++ UI/journal/journal_entry.html	(working copy)
+@@ -133,6 +133,11 @@
+ 	  <?lsmb IF form.projectset == 1 ?>
+ 	  <th class="listheading"><?lsmb text('Project') ?></th>
+ 	  <?lsmb END ?>
++          <?lsmb FOREACH cls IN form.bu_class ?>
++              <?lsmb IF form.b_units.${cls.id} ?>
++          <th><?lsmb text(cls.label) ?></th>
++               <?lsmb END ?>
++          <?lsmb END ?>
+ 	</tr>
+ 	<?lsmb FOREACH displayrow IN displayrows ?> 
+ 	<tr>
+@@ -255,6 +260,23 @@
+ 			<?lsmb END ?>
  
-+=item $form->all_business_units([$transdate, $credit_id]);
+ 		   </td>
++                   <?lsmb FOREACH cls IN form.bu_class ?>
++                      <?lsmb IF form.b_units.${cls.id} ?>
++                   <td>
++                       
++                       <?lsmb clsid = cls.id;
++                              bucid = "b_unit_$clsid";
++                              burow = "${bucid}_$INDEX";
++                       form.b_units.${clsid}.unshift({});
++                       INCLUDE select element_data = {
++                              text_attr = "control_code"
++                             value_attr = "id"
++                         default_values = [displayrow.${bucid}]
++                                   name = "$burow"
++                                options = form.b_units.${clsid}
++                       } ?>
++                   </td>
++                   <?lsmb END ?>
+ 		  <?lsmb END ?>
+ 
+         </tr>
+Index: bin/io.pl
+===================================================================
+--- bin/io.pl	(revision 4473)
++++ bin/io.pl	(working copy)
+@@ -124,6 +124,15 @@
+ 
+ sub display_row {
+     my $numrows = shift;
++    my $lsmb_module;
++    if ($form->{vc} eq 'customer'){
++       $lsmb_module = 'AR';
++    } elsif ($form->{vc} eq 'vendor'){
++       $lsmb_module = 'AP';
++    }
++    $form->all_business_units($form->{transdate}, 
++                              $form->{"$form->{vc}_id"}, 
++                              $lsmb_module);
+ 
+     @column_index = qw(runningnumber partnumber description qty);
+ 
+@@ -172,6 +181,14 @@
+ 
+     push @column_index, @{LedgerSMB::Sysconfig::io_lineitem_columns};
+ 
++    for my $cls(@{$form->{bu_class}}){
++        if (scalar @{$form->{b_units}->{"$cls->{id}"}}){
++             push @column_index, "b_unit_$cls->{id}";
++             $column_data{"b_unit_$cls->{id}"} = 
++               qq|<th class=listheading nowrap>| . $cls->{label} . qq|</th>|;
++        }
++    }
 +
-+Returns a list at bu_class with class information, ordered by order information
-+and a list of units in lists at bu_units->$class_id.  $transdate is used to
-+filter projects active at specified date.  $credit_id is to filter out 
-+units assigned to other customers.
+     push @column_index, "taxformcheck";#increase the number of elements by pushing into column_index.(Ex: NEw added element 
+ 				       # taxformcheck & check the screen AR->Sales Invoice) do everything before colspan ;
+ 
+@@ -334,6 +351,26 @@
+ 
+ 	}
+ 
++        for my $cls(@{$form->{bu_class}}){
++            if (scalar @{$form->{b_units}->{"$cls->{id}"}}){
++                $column_data{"b_unit_$cls->{id}"} = 
++                   qq|<td><select name="b_unit_$cls->{id}_$i">
++                           <option></option>|;
++                for my $bu (@{$form->{b_units}->{"$cls->{id}"}}){
++                   my $selected = "";
++                   if ($bu->{id} eq $form->{"b_unit_$cls->{id}_$i"}){
++                       $selected = "SELECTED='SELECTED'";
++                   }
++                   $column_data{"b_unit_$cls->{id}"} .= qq|
++                       <option value="$bu->{id}" $selected >
++                               $bu->{control_code}
++                       </option>|;
++                }
++                $column_data{"b_unit_$cls->{id}"} .= qq|
++                     </select></td>|;
++                   
++            }
++        }
+ 
+ $column_data{runningnumber} =
+           qq|<td><input name="runningnumber_$i" size=3 value=$i></td>|;
+Index: bin/aa.pl
+===================================================================
+--- bin/aa.pl	(revision 4545)
++++ bin/aa.pl	(working copy)
+@@ -435,6 +435,10 @@
+ 
+     $title = $form->{title};
+ 
++    $form->all_business_units($form->{transdate}, 
++                              $form->{"$form->{vc}_id"}, 
++                              $form->{ARAP});
 +
-+=cut
+     if($form->{batch_id})
+     {
+ 		$form->{batch_control_code}=$form->get_batch_control_code($form->{dbh},$form->{batch_id});
+@@ -738,7 +742,13 @@
+ 	  <th>| . $locale->text('Account') . qq|</th>
+ 	  <th>| . $locale->text('Description') . qq|</th>
+ 	  <th>| . $locale->text('Tax Form Applied') . qq|</th>
+-	  $project
++	  $project|;
++    for my $cls (@{$form->{bu_class}}){
++        if (scalar @{$form->{b_units}->{"$cls->{id}"}}){
++            print qq|<th>| . $locale->text($cls->{label}) . qq|</th>|;
++        }
++    }
++       print qq|
+ 	</tr>
+ |;
+ 
+@@ -786,7 +796,27 @@
+ 	  <td><select name="$form->{ARAP}_amount_$i">$selectamount</select></td>
+ 	  $description
+           $taxformcheck
+-	  $project
++	  $project|;
 +
-+sub all_business_units {
++        for my $cls (@{$form->{bu_class}}){
++            if (scalar @{$form->{b_units}->{"$cls->{id}"}}){
++                print qq|<td><select name="b_unit_$cls->{id}_$i">
++                                    <option></option>|;
++                      for my $bu (@{$form->{b_units}->{"$cls->{id}"}}){
++                         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|
++                             </select>
++                        </th>|;
++            }
++        }
++        print qq|
+ 	</tr>
+ |;
+ 
+@@ -1486,6 +1516,9 @@
+         $selectname = qq|<input name=$form->{vc} size=35>|;
+     }
+ 
++    # Business Reporting Units
++    $form->all_business_units;
 +
-+    my ( $self, $transdate, $credit_id, $module_name) = @_;
-+    $self->{bu_class} = [];
-+    $self->{b_units} = {};
+     # departments
+     if ( @{ $form->{all_department} } ) {
+         $form->{selectdepartment} = "<option>\n";
+Index: bin/gl.pl
+===================================================================
+--- bin/gl.pl	(revision 4473)
++++ bin/gl.pl	(working copy)
+@@ -177,6 +177,7 @@
+ sub display_form
+ {
+     #Add General Ledger Transaction
++    $form->all_business_units($form->{transdate}, undef, 'GL');
+     $form->close_form;
+     $form->open_form; 
+     $form->{dbh}->commit;
+@@ -404,7 +405,12 @@
+ 			      $temphash1->{debit}=$form->{"debit_$i"};
+ 			      $temphash1->{credit}=$form->{"credit_$i"};
+ 
++                              for my $cls(@{$form->{bu_class}}){
++                                  $temphash1->{"b_unit_$cls->{id}"} =
++                                         $form->{"b_unit_$cls->{id}_$i"};
++                              } 
+ 
 +
-+    my $dbh       = $self->{dbh};
-+    my $class_sth = $dbh->prepare(
-+                q|SELECT * FROM business_unit__list_classes('1', ?)|
-+    );
-+    $class_sth->execute($module_name);
+ 			      if ( $i < $form->{rowcount} )
+ 			      {					      
+ 						    $temphash1->{accno}=$form->{"accno_$i"};
+@@ -925,6 +931,8 @@
+ 
+     &create_links;
+ 
++    $form->all_business_units($form->{transdate}, undef, 'GL');
 +
-+    my $bu_sth    = $dbh->prepare(
-+                q|SELECT * 
-+                    FROM business_unit__list_by_class(?, ?, ?, 'false')|
-+    );
-+
-+    while (my $classref = $class_sth->fetchrow_hashref('NAME_lc')){
-+        push @{$self->{bu_class}}, $classref;
-+        $bu_sth->execute($classref->{id}, $transdate, $credit_id);
-+        $self->{b_units}->{$classref->{id}} = [];
-+        while (my $buref = $bu_sth->fetchrow_hashref('NAME_lc')){
-+           push @{$self->{b_units}->{$classref->{id}}}, $buref;
+     $form->{locked} =
+       ( $form->{revtrans} )
+       ? '1'
+@@ -954,6 +962,10 @@
+             $form->{"credit_$i"} = $ref->{amount};
+         }
+ 
++        for my $cls (@{$form->{bu_class}}){
++            $form->{"b_unit_$cls->{id}_$i"} = $ref->{"b_unit_$cls->{id}"};
 +        }
-+    }
-+    $class_sth->finish;
-+    $bu_sth->finish;
 +
-+}
-+
- =item $form->all_vc($myconfig, $vc, $module, $dbh, $transdate, $job);
- 
- Populates the list referred to by $form->{all_${vc}} with hashes of either
-@@ -2583,10 +2622,13 @@
-         $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
-+				p.projectnumber,
-+                                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'
- 			ORDER BY transdate|;
+         $i++;
+     }
+    if ($form->{id}){

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