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

SF.net SVN: ledger-smb: [1422] trunk/LedgerSMB/IS.pm



Revision: 1422
          http://svn.sourceforge.net/ledger-smb/?rev=1422&view=rev
Author:   einhverfr
Date:     2007-07-17 20:57:57 -0700 (Tue, 17 Jul 2007)

Log Message:
-----------
Applying Victors invoice reversal patches

Modified Paths:
--------------
    trunk/LedgerSMB/IS.pm

Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm	2007-07-18 03:57:28 UTC (rev 1421)
+++ trunk/LedgerSMB/IS.pm	2007-07-18 03:57:57 UTC (rev 1422)
@@ -1081,27 +1081,34 @@
                                      $dbh, "invoice", "allocated", 
                                      qq|id = $ref->{id}|, $qty * -1 
                              );
+                            my $linetotal = $qty*$ref->{sellprice};
  			    $allocated += $qty;
+                            $query = qq|
+                                 INSERT INTO acc_trans 
+                                             (trans_id, chart_id, amount, 
+                                             transdate, project_id, invoice_id) 
+                                      VALUES (?, ?, ?, ?, ?, ?)|;
+                            my $sth1 = $dbh->prepare($query);
+                            $sth1->execute(
+                                 $form->{id}, $form->{"expense_accno_id_$i"}, 
+                                 $linetotal, $form->{transdate}, 
+                                 $form->{"project_id_$i"}, $ref->{id}
+                            ) || $form->dberror($query);
+
+                            $linetotal = (-1)*$linetotal;
+                            $query = qq|
+                                INSERT INTO acc_trans 
+                                            (trans_id, chart_id, amount, 
+                                            transdate, project_id, invoice_id) 
+                                     VALUES (?, ?, ?, ?, ?, ?)|;
+                            $sth1 = $dbh->prepare($query);
+        	            $sth1->execute(
+                                 $form->{id}, $form->{"inventory_accno_id_$i"}, 
+                                 $linetotal, $form->{transdate}, 
+                                 $form->{"project_id_$i"}, $ref->{id}
+                            ) || $form->dberror($query);
  		            last if ( ( $totalqty += $qty ) >= 0 );
  		        }
- 			
-                         $query = qq|
- 				INSERT INTO acc_trans 
- 					(trans_id, chart_id, amount, 
- 					transdate, project_id) 
- 				VALUES (?, ?, ?, ?, ?)|;
-  			my $sth = $dbh->prepare($query);
-     			$sth->execute(
-                                 $form->{id}, 
-                                 $form->{"expense_accno_id_$i"}, 
-                                 $total_inventory, $form->{transdate}, 
-                                 $form->{"project_id_$i"}
-                         ) || $form->dberror($query);
-
-			$total_inventory = (-1)*$total_inventory;
-                        $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id) VALUES (?, ?, ?, ?, ?)|;
-			$sth = $dbh->prepare($query);
-    			$sth->execute($form->{id}, $form->{"inventory_accno_id_$i"}, $total_inventory, $form->{transdate}, $form->{"project_id_$i"} ) || $form->dberror($query);
 		    }
                 }
             }


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