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

SF.net SVN: ledger-smb:[2457] trunk/LedgerSMB



Revision: 2457
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2457&view=rev
Author:   einhverfr
Date:     2009-02-22 20:48:32 +0000 (Sun, 22 Feb 2009)

Log Message:
-----------
Invoice handling corrections

Modified Paths:
--------------
    trunk/LedgerSMB/IR.pm
    trunk/LedgerSMB/IS.pm
    trunk/LedgerSMB/OE.pm
    trunk/LedgerSMB/PriceMatrix.pm

Modified: trunk/LedgerSMB/IR.pm
===================================================================
--- trunk/LedgerSMB/IR.pm	2009-02-20 22:56:55 UTC (rev 2456)
+++ trunk/LedgerSMB/IR.pm	2009-02-22 20:48:32 UTC (rev 2457)
@@ -139,11 +139,11 @@
     if ( !$form->{id} ) {
 
         $query = qq|
-			INSERT INTO ap (invnumber, employee_id)
-			VALUES ('$uid', (SELECT id FROM employee
-			                  WHERE login = ?))|;
+			INSERT INTO ap (invnumber, person_id, entity_credit_account)
+			VALUES ('$uid', (SELECT entity_id FROM users
+			                  WHERE username = ?), ?)|;
         $sth = $dbh->prepare($query);
-        $sth->execute( $form->{login} ) || $form->dberror($query);
+        $sth->execute( $form->{login}, $form->{vendor_id} ) || $form->dberror($query);
 
         $query = qq|SELECT id FROM ap WHERE invnumber = '$uid'|;
         $sth   = $dbh->prepare($query);
@@ -760,7 +760,6 @@
 		       ordnumber = ?,
 		       quonumber = ?,
 		       transdate = ?,
-		       entity_credit_account = ?,
 		       amount = ?,
 		       netamount = ?,
 		       paid = ?,
@@ -774,7 +773,6 @@
 		       intnotes = ?,
 		       curr = ?,
 		       department_id = ?,
-		       employee_id = ?,
 		       language_code = ?,
 		       ponumber = ?
 		 WHERE id = ?|;
@@ -782,11 +780,11 @@
     $sth = $dbh->prepare($query);
     $sth->execute(
         $form->{invnumber},     $form->{ordnumber},     $form->{quonumber},
-        $form->{transdate},     $form->{vendor_id},     $invamount,
+        $form->{transdate},     $invamount,
         $invnetamount,          $form->{paid},          $form->{datepaid},
         $form->{duedate},       $form->{shippingpoint}, $form->{shipvia},
         $form->{taxincluded},   $form->{notes},         $form->{intnotes},
-        $form->{currency},      $form->{department_id}, $form->{employee_id},
+        $form->{currency},      $form->{department_id}, 
         $form->{language_code}, $form->{ponumber},      $form->{id}
     ) || $form->dberror($query);
 

Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm	2009-02-20 22:56:55 UTC (rev 2456)
+++ trunk/LedgerSMB/IS.pm	2009-02-22 20:48:32 UTC (rev 2457)
@@ -864,9 +864,9 @@
             &reverse_invoice( $dbh, $form );
         }
         else {
-            $query = qq|INSERT INTO ar (id) VALUES (?)|;
+            $query = qq|INSERT INTO ar (id, entity_credit_account) VALUES (?, ?)|;
             $sth   = $dbh->prepare($query);
-            $sth->execute( $form->{id} ) || $form->dberror($query);
+            $sth->execute( $form->{id}, $form->{customer_id}) || $form->dberror($query);
         }
 
     }
@@ -877,10 +877,10 @@
     if ( !$form->{id} ) {
 
         $query = qq|
-			INSERT INTO ar (invnumber, person_id) 
-			     VALUES ('$uid', ?)|;
+			INSERT INTO ar (invnumber, person_id, entity_credit_account) 
+			     VALUES ('$uid', ?, ?)|;
         $sth = $dbh->prepare($query);
-        $sth->execute( $form->{employee_id} ) || $form->dberror($query);
+        $sth->execute( $form->{employee_id}, $form->{customer_id}) || $form->dberror($query);
 
         $query = qq|SELECT id FROM ar WHERE invnumber = '$uid'|;
         $sth   = $dbh->prepare($query);

Modified: trunk/LedgerSMB/OE.pm
===================================================================
--- trunk/LedgerSMB/OE.pm	2009-02-20 22:56:55 UTC (rev 2456)
+++ trunk/LedgerSMB/OE.pm	2009-02-22 20:48:32 UTC (rev 2457)
@@ -263,14 +263,17 @@
     my $quotation;
     my $ordnumber;
     my $numberfld;
+    my $class_id;
     $form->{vc} = ( $form->{vc} eq 'customer' ) ? 'customer' : 'vendor';
     if ( $form->{type} =~ /_order$/ ) {
         $quotation = "0";
         $ordnumber = "ordnumber";
-        $numberfld =
-          ( $form->{vc} eq 'customer' )
-          ? "sonumber"
-          : "ponumber";
+	if ($form->{vc} eq 'customer'){
+             $numberfld = "sonumber";
+             $class_id = 1;
+        } else {
+             $numberfld = "ponumber";
+        }
     }
     else {
         $quotation = "1";
@@ -354,12 +357,12 @@
 				entity_id, reqdate, shippingpoint, shipvia,
 				notes, intnotes, curr, closed, department_id,
 				person_id, language_code, ponumber, terms,
-				quotation)
+				quotation, oe_class_id)
 			VALUES 
 				($form->{id}, ?, ?, ?, ?,
 				?, ?, ?, ?,
 				?, ?, ?, ?, ?,
-				?, ?, ?, ?)|;
+				?, ?, ?, ?, ?)|;
         @queryargs = (
             $form->{ordnumber},     $form->{quonumber},
             $form->{transdate},     $form->{entity_id}, $form->{reqdate},
@@ -368,7 +371,7 @@
             $form->{currency},      $form->{closed},
             $form->{department_id}, $form->{person_id},
             $form->{language_code}, $form->{ponumber},
-            $form->{terms},         $quotation
+            $form->{terms},         $quotation, $class_id
         );
         $sth = $dbh->prepare($query);
         $sth->execute(@queryargs) || $form->dberror($query);
@@ -569,7 +572,7 @@
 				closed = ?, 
 				quotation = ?, 
 				department_id = ?, 
-				employee_id = ?, 
+				person_id = ?, 
 				language_code = ?, 
 				ponumber = ?, 
 				terms = ?

Modified: trunk/LedgerSMB/PriceMatrix.pm
===================================================================
--- trunk/LedgerSMB/PriceMatrix.pm	2009-02-20 22:56:55 UTC (rev 2456)
+++ trunk/LedgerSMB/PriceMatrix.pm	2009-02-22 20:48:32 UTC (rev 2457)
@@ -41,6 +41,7 @@
     my $sth;
 
     my @queryargs;
+    my $transdate = $form->{dbh}->quote( $form->{transdate} );
     my $entity_id     = $form->{dbh}->quote( $form->{entity_id} );
 
     if ( $form->{customer_id} ) {


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