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

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



Revision: 2607
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2607&view=rev
Author:   einhverfr
Date:     2009-05-21 16:00:22 +0000 (Thu, 21 May 2009)

Log Message:
-----------
More tax form stuff

Modified Paths:
--------------
    trunk/LedgerSMB/Admin.pm
    trunk/LedgerSMB/Database.pm
    trunk/LedgerSMB/IR.pm
    trunk/LedgerSMB/IS.pm
    trunk/LedgerSMB/TaxForm.pm
    trunk/bin/ir.pl

Modified: trunk/LedgerSMB/Admin.pm
===================================================================
--- trunk/LedgerSMB/Admin.pm	2009-05-21 05:55:42 UTC (rev 2606)
+++ trunk/LedgerSMB/Admin.pm	2009-05-21 16:00:22 UTC (rev 2607)
@@ -192,4 +192,4 @@
     return $user;
 }
 
-1;
\ No newline at end of file
+1;

Modified: trunk/LedgerSMB/Database.pm
===================================================================
--- trunk/LedgerSMB/Database.pm	2009-05-21 05:55:42 UTC (rev 2606)
+++ trunk/LedgerSMB/Database.pm	2009-05-21 16:00:22 UTC (rev 2607)
@@ -114,7 +114,9 @@
 }
 
 sub _create_roles {
-    #TODO
+    
+#TODO
+
 }
 
 sub update {

Modified: trunk/LedgerSMB/IR.pm
===================================================================
--- trunk/LedgerSMB/IR.pm	2009-05-21 05:55:42 UTC (rev 2606)
+++ trunk/LedgerSMB/IR.pm	2009-05-21 16:00:22 UTC (rev 2607)
@@ -1496,7 +1496,7 @@
 
    my ( $self,$form,$vendor_id) = @_;
 
-   my $query = "select country_taxform_id from entity_credit_account where id=?";
+   my $query = "select taxform_id from entity_credit_account where id=?";
 
    my $sth = $form->{dbh}->prepare($query);
 

Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm	2009-05-21 05:55:42 UTC (rev 2606)
+++ trunk/LedgerSMB/IS.pm	2009-05-21 16:00:22 UTC (rev 2607)
@@ -2562,89 +2562,7 @@
 
 }
 
-sub get_taxcheck
-{
 
-   my ( $self,$form,$invoice_id,$dbh) = @_;
-
-   my $query=qq|select reportable from invoice_tax_form where invoice_id=?|;
-   my $sth=$dbh->prepare($query);
-   $sth->execute($invoice_id) ||  $form->dberror($query);
-   
-   my $found=0;
-
-   while(my $ret1=$sth->fetchrow())
-   {
-
-      if($ret1 eq "t" || $ret1)   # this if is not required because when reportable is false, control would not come inside while itself.
-      { $found=1;  }
-
-   }
-
-   return($found);
-
-}
-
-
-
-sub taxform_exist
-{
-
-   my ( $self,$form,$customer_id) = @_;
-
-   my $query = "select country_taxform_id from entity_credit_account where id=?";
-
-   my $sth = $form->{dbh}->prepare($query);
-
-   $sth->execute($customer_id) || $form->dberror($query);
-
-   my $retval=0;
-
-   while(my $val=$sth->fetchrow())
-   {
-        $retval=1;
-   }
-   
-   return $retval;
-
-
-}
-
-
-sub update_invoice_tax_form
-{
-
-   my ( $self,$form,$dbh,$invoice_id,$report) = @_;
-
-   my $query=qq|select count(*) from invoice_tax_form where invoice_id=?|;
-   my $sth=$dbh->prepare($query);
-   $sth->execute($invoice_id) ||  $form->dberror($query);
-   
-   my $found=0;
-
-   while(my $ret1=$sth->fetchrow())
-   {
-      $found=1;  
-
-   }
-
-   if($found)
-   {
-	  my $query = qq|update invoice_tax_form set reportable=? where invoice_id=?|;
-          my $sth = $dbh->prepare($query);
-          $sth->execute($report,$invoice_id) || $form->dberror($query);
-   }
-  else
-   {
-          my $query = qq|insert into invoice_tax_form(invoice_id,reportable) values(?,?)|;
-          my $sth = $dbh->prepare($query);
-          $sth->execute($invoice_id,$report) || $form->dberror("$query");
-   }
-
-   $dbh->commit();
-
-}
-
 sub get_taxcheck
 {
 
@@ -2670,5 +2588,6 @@
 
 
 
+
 1;
 

Modified: trunk/LedgerSMB/TaxForm.pm
===================================================================
--- trunk/LedgerSMB/TaxForm.pm	2009-05-21 05:55:42 UTC (rev 2606)
+++ trunk/LedgerSMB/TaxForm.pm	2009-05-21 16:00:22 UTC (rev 2607)
@@ -24,7 +24,18 @@
     
 }
 
+sub get_metadata
+{
+    my ($self) = @_;
 
+    @{$self->{countries}} = $self->exec_method(
+                funcname => 'location_list_country'
+    );
 
+}
+
+1;
+   
+
     
 1;

Modified: trunk/bin/ir.pl
===================================================================
--- trunk/bin/ir.pl	2009-05-21 05:55:42 UTC (rev 2606)
+++ trunk/bin/ir.pl	2009-05-21 16:00:22 UTC (rev 2607)
@@ -262,6 +262,9 @@
               $form->format_amount( \%myconfig, $form->{"qty_$i"} );
             $form->{"oldqty_$i"} = $form->{"qty_$i"};
 
+	    $form->{"taxformcheck_$i"}=1 if(IR->get_taxcheck($form,$form->{"invoice_id_$i"},$form->{dbh}));
+
+
             for (qw(partnumber sku description unit)) {
                 $form->{"${_}_$i"} = $form->quote( $form->{"${_}_$i"} );
             }
@@ -696,6 +699,8 @@
               { ndx => 8, key => 'D', value => $locale->text('Delete') },
             'on_hold' =>
               { ndx => 9, key=> 'O', value => $locale->text('On Hold') },
+	    'save_info'  => 
+                { ndx => 10, key => 'I', value => $locale->text('Save Info') },
         );
 
         if ( $form->{id} ) {
@@ -1145,3 +1150,50 @@
 }
 
 
+
+sub save_info {
+
+    
+	    my $taxformfound=0;
+
+	    $taxformfound=IR->taxform_exist($form,$form->{"vendor_id"});
+	    
+	    print STDERR qq|___Rowcount=$form->{rowcount} _______|;
+
+	    foreach my $i(1..($form->{rowcount}))
+	    {
+		print STDERR qq| taxformcheck_$i = $form->{"taxformcheck_$i"} and taxformfound= $taxformfound ___________|;
+		
+		if($form->{"taxformcheck_$i"} and $taxformfound)
+		{
+			
+		  IR->update_invoice_tax_form($form,$form->{dbh},$form->{"invoice_id_$i"},"true") if($form->{"invoice_id_$i"});
+
+		}
+		else
+		{
+
+		    IR->update_invoice_tax_form($form,$form->{dbh},$form->{"invoice_id_$i"},"false") if($form->{"invoice_id_$i"});
+
+		}
+		
+	    }    
+
+	    if ($form->{callback}){
+		print "Location: $form->{callback}\n";
+		print "Status: 302 Found\n\n";
+		print "<html><body>";
+		my $url = $form->{callback};
+		print qq|If you are not redirected automatically, click <a href="$url">|
+			. qq|here</a>.</body></html>|;
+
+	    } else {
+		$form->info($locale->text('Draft Posted'));
+	    }
+
+}
+
+
+
+
+


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