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

SF.net SVN: ledger-smb:[3213] branches/1.2/bin/oe.pl



Revision: 3213
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3213&view=rev
Author:   einhverfr
Date:     2011-06-11 01:03:57 +0000 (Sat, 11 Jun 2011)

Log Message:
-----------
Correcting bug 2796818

Modified Paths:
--------------
    branches/1.2/bin/oe.pl

Modified: branches/1.2/bin/oe.pl
===================================================================
--- branches/1.2/bin/oe.pl	2011-06-10 05:20:45 UTC (rev 3212)
+++ branches/1.2/bin/oe.pl	2011-06-11 01:03:57 UTC (rev 3213)
@@ -651,6 +651,7 @@
 }
 
 sub form_footer {
+    _calc_taxes();
 
     $form->{invtotal} = $form->{invsubtotal};
 
@@ -686,34 +687,18 @@
 	}
 
     if ( !$form->{taxincluded} ) {
-
-        my @taxes = sort bypass Tax::init_taxes( $form, $form->{taxaccounts} );
-		my $passlvl = 0;
-		my $taxable_base = undef;
-        foreach my $item (@taxes) {
-            my $taccno = $item->account;
-
-			if ( $taxable_base eq undef ) {
-				$taxable_base = $form->{"${taccno}_base"};
-			}
-
-			if ( $item->pass gt $passlvl ) {
-				$taxable_base = $form->{invtotal};
-			}
-			$passlvl = $item->pass;
-
-	    $form->{invtotal} += $form->round_amount( 
-                $form->{"${taccno}_rate"} * $taxable_base, 2);
+        foreach $item (keys %{$form->{taxes}}) {
+            my $taccno = $item;
+	    $form->{invtotal} += $form->round_amount($form->{taxes}{$item}, 2);
             $form->{"${taccno}_total"} =
-        	  $form->format_amount( \%myconfig,
-                $form->{"${taccno}_rate"} * $taxable_base, 2 );
-
+                  $form->format_amount( \%myconfig,
+                    $form->round_amount( $form->{taxes}{$item}, 2 ), 2 );
+            next if !$form->{"${taccno}_total"};
             $tax .= qq|
-	      <tr>
-		<th align="right">$form->{"${taccno}_description"}</th>
-		<td align="right">$form->{"${taccno}_total"}</td>
-	      </tr>
-	      | if $form->{"${taccno}_base"};
+        <tr>
+      	<th align="right">$form->{"${taccno}_description"}</th>
+      	<td align="right">$form->{"${taccno}_total"}</td>
+        </tr>|;
         }
 
         $form->{invsubtotal} =
@@ -1091,20 +1076,20 @@
                     $form->{"${_}_$i"} /= $exchangerate;
                 }
 
-                $amount =
-                  $form->{"sellprice_$i"} * $form->{"qty_$i"} *
-                  ( 1 - $form->{"discount_$i"} / 100 );
-                for ( split / /, $form->{taxaccounts} ) {
-                    $form->{"${_}_base"} = 0;
-                }
-                for ( split / /, $form->{"taxaccounts_$i"} ) {
-                    $form->{"${_}_base"} += $amount;
-                }
-                if ( !$form->{taxincluded} ) {
-                    my @taxes = Tax::init_taxes( $form, $form->{taxaccounts} );
-                    $amount +=
-                      Tax::calculate_taxes( ..hidden.., $form, $amount, 0 );
-                }
+#                $amount =
+#                  $form->{"sellprice_$i"} * $form->{"qty_$i"} *
+#                  ( 1 - $form->{"discount_$i"} / 100 );
+#                for ( split / /, $form->{taxaccounts} ) {
+#                    $form->{"${_}_base"} = 0;
+#                }
+#                for ( split / /, $form->{"taxaccounts_$i"} ) {
+#                    $form->{"${_}_base"} += $amount;
+#                }
+#                if ( !$form->{taxincluded} ) {
+#                    my @taxes = Tax::init_taxes( $form, $form->{taxaccounts} );
+#                    $amount +=
+#                      Tax::calculate_taxes( ..hidden.., $form, $amount, 0 );
+#                }
 
                 $form->{creditremaining} -= $amount;
 


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