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

SF.net SVN: ledger-smb:[3424] trunk/bin



Revision: 3424
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3424&view=rev
Author:   einhverfr
Date:     2011-07-04 11:44:01 +0000 (Mon, 04 Jul 2011)

Log Message:
-----------
UI for manual tax entry complete.  Next up: saving and retrieving

Modified Paths:
--------------
    trunk/bin/io.pl
    trunk/bin/ir.pl
    trunk/bin/is.pl

Modified: trunk/bin/io.pl
===================================================================
--- trunk/bin/io.pl	2011-07-04 10:50:34 UTC (rev 3423)
+++ trunk/bin/io.pl	2011-07-04 11:44:01 UTC (rev 3424)
@@ -111,8 +111,12 @@
               if $fxlinetotal;
         }        
         for (@taxaccounts) {
+            $form->{tax_obj}{$_->account} = $_;
             $form->{taxes}{$_->account} = 0 if ! $form->{taxes}{$_->account};
             $form->{taxes}{$_->account} += $_->value;
+            if ($_->value){
+               $form->{taxbasis}{$_->account} += $linetotal;
+            }
         }
     }
 }

Modified: trunk/bin/ir.pl
===================================================================
--- trunk/bin/ir.pl	2011-07-04 10:50:34 UTC (rev 3423)
+++ trunk/bin/ir.pl	2011-07-04 11:44:01 UTC (rev 3424)
@@ -485,15 +485,24 @@
             qq|<input type="hidden" name="manual_tax" value="|
                . $form->{manual_tax} . qq|" />|;
     } else {
+        my $checked0;
+        my $checked1;
+        if ($form->{manual_tax}){
+           $checked1=qq|checked="CHECKED"|;
+           $checked0="";
+        } else {
+           $checked0=qq|checked="CHECKED"|;
+           $checked1="";
+        }
         $manual_tax = 
                     qq|<label for="manual-tax-0">|.
                        $locale->text("Automatic"). qq|</label>
                        <input type="radio" name="manual_tax" value="0"
-                              id="manual-tax-0">
+                              id="manual-tax-0" $checked0 />
                         <label for="manual-tax-1">|.
                         $locale->text("Manual"). qq|</label>
                       <input type="radio" name="manual_tax" value="1"
-                              id="manual-tax-1">|;
+                              id="manual-tax-1" $checked1 />|;
     }
     _calc_taxes();
     $form->{invtotal} = $form->{invsubtotal};
@@ -522,7 +531,8 @@
 
     if ( !$form->{taxincluded} ) {
         if ($form->{manual_tax}){
-             $tax .= qq|<tr class="listtop">
+             $tax .= qq|
+                 <table><tr class="listtop">
                       <td>&nbsp</td>
                       <th align="center">|.$locale->text('Amount').qq|</th>
                       <th align="center">|.$locale->text('Rate').qq|</th>
@@ -535,8 +545,28 @@
         foreach $item (keys %{$form->{taxes}}) {
             my $taccno = $item;
             if ($form->{manual_tax}){
+               # Setting defaults from tax calculations
+               # These are set in io.pl sub _calc_taxes --CT
+               if ($form->{"mt_rate_$item"} eq '' or 
+                   !defined $form->{"mt_rate_$item"}){
+                   $form->{"mt_rate_$item"} = $form->{tax_obj}{$item}->rate;
+               }
+               if ($form->{"mt_basis_$item"} eq '' or
+                   !defined $form->{"mt_basis_$item"}){
+                   $form->{"mt_basis_$item"} = $form->{taxbasis}{$item};
+               }
+               if ($form->{"mt_amount_$item"} eq '' or
+                   !defined $form->{"mt_amount_$item"}){
+                   $form->{"mt_amount_$item"} = 
+                           $form->{"mt_rate_$item"}
+                           * $form->{"mt_basis_$item"};
+               }
                $form->{invtotal} += $form->round_amount(
                                          $form->{"mt_amount_$item"}, 2);
+               # Setting this up as a table
+               # Note that the screens may be not wide enough to display
+               # this in the normal way so we have to change the layout of the
+               # notes fields. --CT 
                $tax .= qq|<tr>
                 <th align=right>$form->{"${taccno}_description"}</th>
                 <td><input type="text" name="mt_amount_$item"
@@ -569,6 +599,9 @@
 |;
             }
         }
+        if ($form->{manual_tax}){
+            $tax .= "</table>";
+        }
 
         $form->{invsubtotal} =
           $form->format_amount( \%myconfig, $form->{invsubtotal}, 2, 0 );
@@ -603,18 +636,36 @@
 	  <td>
 	    <table>
 	      <tr>
-		<th align=left>| . $locale->text('Notes') . qq|</th>
+		<th align=left>| . $locale->text('Notes') . qq|</th>|;
+    if (!$form->{manual_tax}){
+        print qq|
 		<th align=left>| . $locale->text('Internal Notes') . qq|</th>
                 <th align=left>| . $locale->text('Import Text') . qq|</th>
 	      </tr>
-	      <tr valign=top>
+	      <tr valign=top>|;
+     }
+     # Redesigning layout as per notes above.  When this is redesigned
+     # we really should use floats and CSS instead. --CT
+     if ($form->{manual_tax}){
+         print qq|</tr><tr><td>$notes</td></tr>
+                 <tr><th align=left>| . $locale->text('Internal Notes').qq|</th>
+                 </tr>
+                 <tr><td>$intnotes</td></tr>
+                 <tr><th align=left>| . $locale->text('Import Text') . qq|</th>
+                 </tr>
+                 <tr>
+                <td><textarea name=import_text rows=$rows cols=25></textarea>|;
+     } else {
+         print qq|
 		<td>$notes</td>
 		<td>$intnotes</td>
-                <td><textarea name=import_text rows=$rows cols=25></textarea>
+                <td><textarea name=import_text rows=$rows cols=25></textarea>|;
+    }
+    print qq|
 	      </tr>
 	    </table>
 	  </td>
-	  <td align=right>
+	  <td align=right valign="top">
 	    $taxincluded <br/>
 	    <table>
               <tr><th align="center" colspan="2">|.

Modified: trunk/bin/is.pl
===================================================================
--- trunk/bin/is.pl	2011-07-04 10:50:34 UTC (rev 3423)
+++ trunk/bin/is.pl	2011-07-04 11:44:01 UTC (rev 3424)
@@ -582,16 +582,16 @@
     $form->{invtotal} = $form->{invsubtotal};
 
     if ( ( $rows = $form->numtextrows( $form->{notes}, 35, 8 ) ) < 2 ) {
-        $rows = 2;
+        $rows = 5;
     }
     if ( ( $introws = $form->numtextrows( $form->{intnotes}, 35, 8 ) ) < 2 ) {
-        $introws = 2;
+        $introws = 5;
     }
     $rows = ( $rows > $introws ) ? $rows : $introws;
     $notes =
-qq|<textarea name=notes rows=$rows cols=35 wrap=soft>$form->{notes}</textarea>|;
+qq|<textarea name=notes rows=$rows cols=40 wrap=soft>$form->{notes}</textarea>|;
     $intnotes =
-qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
+qq|<textarea name=intnotes rows=$rows cols=40 wrap=soft>$form->{intnotes}</textarea>|;
 
     $form->{taxincluded} = ( $form->{taxincluded} ) ? "checked" : "";
 
@@ -617,14 +617,33 @@
                       <th align="center">|.$locale->text('Basis').qq|</th>
                       <th align="center">|.$locale->text('Tax Code').qq|</th>
                       <th align="center">|.$locale->text('Memo').qq|</th>
-                      <td>&nbsp</td>
                     </tr>|;
         }
         foreach $item (keys %{$form->{taxes}}) {
             my $taccno = $item;
             if ($form->{manual_tax}){
+               # Setting defaults from tax calculations
+               # These are set in io.pl sub _calc_taxes --CT
+               if ($form->{"mt_rate_$item"} eq '' or 
+                   !defined $form->{"mt_rate_$item"}){
+                   $form->{"mt_rate_$item"} = $form->{tax_obj}{$item}->rate;
+               }
+               if ($form->{"mt_basis_$item"} eq '' or
+                   !defined $form->{"mt_basis_$item"}){
+                   $form->{"mt_basis_$item"} = $form->{taxbasis}{$item};
+               }
+               if ($form->{"mt_amount_$item"} eq '' or
+                   !defined $form->{"mt_amount_$item"}){
+                   $form->{"mt_amount_$item"} = 
+                           $form->{"mt_rate_$item"}
+                           * $form->{"mt_basis_$item"};
+               }
                $form->{invtotal} += $form->round_amount(
                                          $form->{"mt_amount_$item"}, 2);
+               # Setting this up as a table
+               # Note that the screens may be not wide enough to display
+               # this in the normal way so we have to change the layout of the
+               # notes fields. --CT 
                $tax .= qq|<tr>
                 <th align=right>$form->{"${taccno}_description"}</th>
                 <td><input type="text" name="mt_amount_$item"
@@ -642,8 +661,6 @@
                 <td><input type="text" name="mt_memo_$item"
                          id="mt-memo-$item" value="|
                         .$form->{"mt_memo_$item"} .qq|" size="10"/></td>
-                <td><button id="mt-calc-$item name="mt_calc_$item"
-                    >|.$locale->text('Calc').qq|</button></td>
                </tr>|;
             }  else {
 	       $form->{invtotal} += $form->round_amount($form->{taxes}{$item}, 2);
@@ -690,12 +707,28 @@
 	  <td>
 	    <table>
 	      <tr>
-		<th align=left>| . $locale->text('Notes') . qq|</th>
-		<th align=left>| . $locale->text('Internal Notes') . qq|</th>
+		<th align=left>| . $locale->text('Notes') . qq|</th>|;
+     # Redesigning layout as per notes above.  When this is redesigned
+     # we really should use floats and CSS instead. --CT
+     if (!$form->{manual_tax}){
+           print qq|
+		<th align=left>| . $locale->text('Internal Notes') . qq|</th>|;
+     }
+     print qq|
 	      </tr>
-	      <tr valign=top>
+	      <tr valign=top>|;
+     if ($form->{manual_tax}){
+         print qq|<td>$notes</td>
+              </tr><tr>
+               <th align=left>| . $locale->text('Internal Notes') . qq|</th>
+              </tr><tr>
+              <td>$intnotes</td>|;
+     } else {
+         print qq|
 		<td>$notes</td>
-		<td>$intnotes</td>
+		<td>$intnotes</td>|;
+    }
+    print qq|
 	      </tr>
 	    </table>
 	  </td>


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