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

SF.net SVN: ledger-smb:[4122] branches/1.3



Revision: 4122
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4122&view=rev
Author:   tshvr
Date:     2011-12-01 13:20:51 +0000 (Thu, 01 Dec 2011)
Log Message:
-----------
PLEASE TEST,trying to create empty lines for all taxes in one go

Modified Paths:
--------------
    branches/1.3/LedgerSMB/AM.pm
    branches/1.3/bin/am.pl

Modified: branches/1.3/LedgerSMB/AM.pm
===================================================================
--- branches/1.3/LedgerSMB/AM.pm	2011-12-01 11:50:37 UTC (rev 4121)
+++ branches/1.3/LedgerSMB/AM.pm	2011-12-01 13:20:51 UTC (rev 4122)
@@ -1931,6 +1931,7 @@
 
         my $rate=$form->{"taxrate_$i"};
         $rate=~s/^\s+|\s+$//g;
+        $rate=$form->parse_amount( $myconfig, $form->{"taxrate_$i"} ) / 100;
         my $validto=$form->{"validto_$i"};
         $validto=~s/^\s+|\s+$//g;
         my $pass=$form->{"pass_$i"};
@@ -1940,7 +1941,7 @@
         my $old_validto=$form->{"old_validto_$i"};
         $old_validto=~s/^\s+|\s+$//g;
         #print STDERR localtime()." AM save_taxes chart_id=$chart_id i=$i rate=$rate validto=$validto pass=$pass taxnumber=$taxnumber old_validto=$old_validto\n";
-        if($rate eq '' && $validto eq '' && $pass eq '' && $taxnumber eq '')
+        if($rate==0  && $validto eq '' && $pass eq '' && $taxnumber eq '')
         {
          $logger->debug("skipping chart_id=$chart_id i=$i rate=$rate validto=$validto pass=$pass taxnumber=$taxnumber old_validto=$old_validto skipping");
          next;
@@ -1950,8 +1951,7 @@
          $logger->info("will insert new chart_id=$chart_id i=$i rate=$rate validto=$validto pass=$pass taxnumber=$taxnumber old_validto=$old_validto");
         }        
 
-        $rate =
-          $form->parse_amount( $myconfig, $form->{"taxrate_$i"} ) / 100;
+        #$rate=$form->parse_amount( $myconfig, $form->{"taxrate_$i"} ) / 100;
         $validto = $form->{"validto_$i"};
         $validto = 'infinity' if not $validto;
         $form->{"pass_$i"} = 0 if not $form->{"pass_$i"};

Modified: branches/1.3/bin/am.pl
===================================================================
--- branches/1.3/bin/am.pl	2011-12-01 11:50:37 UTC (rev 4121)
+++ branches/1.3/bin/am.pl	2011-12-01 13:20:51 UTC (rev 4122)
@@ -1531,7 +1531,7 @@
         ( $null, $i ) = split /_/, $_;
 
         $form->{"taxrate_$i"} =
-          $form->format_amount( \%myconfig, $form->{"taxrate_$i"} );
+          $form->format_amount( \%myconfig, $form->{"taxrate_$i"},3,'0');
 
         $hiddens{"taxdescription_$i"} = $form->{"taxdescription_$i"};
         $hiddens{"old_validto_$i"} = $form->{"old_validto_$i"};
@@ -1586,11 +1586,16 @@
 
     @a = split / /, $form->{taxaccounts};
     $ndx = $#a + 1;
+    my $inserted=0;
+
     AM->taxes( \%myconfig, \%$form );
 
     foreach $item (@a) {
         ( $accno, $i ) = split /_/, $item;
         push @t, $accno;
+
+	$i=$i+$inserted;
+
         $form->{"taxmodulename_$i"} =
           $form->{ "taxmodule_" . $form->{"taxmodule_id_$i"} };
 
@@ -1600,34 +1605,37 @@
             {
 
                 #insert line
+                #print STDERR localtime()." am.pl update insert line\n";
                 for ( $j = $ndx + 1 ; $j > $i ; $j-- ) {
                     $k = $j - 1;
-                    for (qw(taxrate taxdescription taxnumber validto)) {
+                    for (qw(taxrate taxdescription taxnumber validto pass old_validto)) {
                         $form->{"${_}_$j"} = $form->{"${_}_$k"};
                     }
                 }
                 $ndx++;
+                $inserted++;
                 $k = $i + 1;
                 for (qw(taxdescription taxnumber)) {
                     $form->{"${_}_$k"} = $form->{"${_}_$i"};
                 }
-                for (qw(taxrate validto)) { $form->{"${_}_$k"} = "" }
+                for (qw(taxrate validto pass old_validto)) { $form->{"${_}_$k"} = "" }
                 push @t, $accno;
             }
         }
         else {
-
             # remove line
             $j = $i + 1;
             if ( $form->{"taxdescription_$i"} eq $form->{"taxdescription_$j"} )
             {
+             #print STDERR localtime()." am.pl update remove line\n";
                 for ( $j = $i + 1 ; $j <= $ndx ; $j++ ) {
                     $k = $j + 1;
-                    for (qw(taxrate taxdescription taxnumber validto)) {
+                    for (qw(taxrate taxdescription taxnumber validto pass old_validto)) {
                         $form->{"${_}_$j"} = $form->{"${_}_$k"};
                     }
                 }
                 $ndx--;
+                $inserted--;
                 splice @t, $i - 1, 1;
             }
         }

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