Einkaufs- und Verkaufsrechnungen: Bei den Buchungen (sowohl für die Positionen als...
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 20 Feb 2007 09:13:20 +0000 (09:13 +0000)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 20 Feb 2007 09:13:20 +0000 (09:13 +0000)
SL/IR.pm
SL/IS.pm

index e75fd30..5970672 100644 (file)
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -389,6 +389,8 @@ sub post_invoice {
     }
   }
 
+  $project_id = conv_i($form->{"globalproject_id"});
+
   $form->{datepaid} = $form->{invdate};
 
   # all amounts are in natural state, netamount includes the taxes
@@ -476,12 +478,12 @@ sub post_invoice {
           ) != 0
         ) {
         $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
-                   transdate, taxkey)
+                   transdate, taxkey, project_id)
                    VALUES ($trans_id, (SELECT c.id FROM chart c
                                         WHERE c.accno = '$accno'),
                    $form->{amount}{$trans_id}{$accno}, '$form->{invdate}',
-                   (SELECT taxkey_id  FROM chart WHERE accno = '$accno'))|;
-        $dbh->do($query) || $form->dberror($query);
+                   (SELECT taxkey_id  FROM chart WHERE accno = '$accno'), ?)|;
+        do_query($form, $dbh, $query, $project_id);
       }
     }
   }
@@ -518,22 +520,22 @@ sub post_invoice {
 
       if ($form->{amount}{ $form->{id} }{ $form->{AP} } != 0) {
         $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
-                   transdate)
+                   transdate, project_id)
                    VALUES ($form->{id}, (SELECT c.id FROM chart c
                                        WHERE c.accno = '$form->{AP}'),
-                   $amount, '$form->{"datepaid_$i"}')|;
-        $dbh->do($query) || $form->dberror($query);
+                   $amount, '$form->{"datepaid_$i"}', ?)|;
+        do_query($form, $dbh, $query, $project_id);
       }
 
       # record payment
 
       $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
-                  source, memo)
+                  source, memo, project_id)
                   VALUES ($form->{id}, (SELECT c.id FROM chart c
                                      WHERE c.accno = '$accno'),
                   $form->{"paid_$i"}, '$form->{"datepaid_$i"}',
-                 '$form->{"source_$i"}', '$form->{"memo_$i"}')|;
-      $dbh->do($query) || $form->dberror($query);
+                 '$form->{"source_$i"}', '$form->{"memo_$i"}', ?)|;
+      do_query($form, $dbh, $query, $project_id);
 
       $exchangerate = 0;
 
@@ -587,11 +589,11 @@ sub post_invoice {
         ) {
 
         $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
-                   transdate, cleared, fx_transaction)
+                   transdate, cleared, fx_transaction, project_id)
                    VALUES ($form->{id}, (SELECT c.id FROM chart c
                                        WHERE c.accno = '$accno'),
-                    $form->{fx}{$accno}{$transdate}, '$transdate', '0', '1')|;
-        $dbh->do($query) || $form->dberror($query);
+                    $form->{fx}{$accno}{$transdate}, '$transdate', '0', '1', ?)|;
+        do_query($form, $dbh, $query, $project_id);
       }
     }
   }
@@ -1302,6 +1304,8 @@ sub post_payment {
       $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate},
                               "buy");
 
+  my $project_id = conv_i($form->{"globalproject_id"});
+
   # record payments and offsetting AP
   for my $i (1 .. $form->{paidaccounts}) {
 
@@ -1336,11 +1340,11 @@ sub post_payment {
       $dbh->do($query) || $form->dberror($query);
 
       $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
-                  transdate)
+                  transdate, project_id)
                   VALUES ($form->{id}, (SELECT c.id FROM chart c
                                       WHERE c.accno = '$form->{AP}'),
-                  $amount, '$form->{"datepaid_$i"}')|;
-      $dbh->do($query) || $form->dberror($query);
+                  $amount, '$form->{"datepaid_$i"}', ?)|;
+      do_query($form, $dbh, $query, $project_id);
 
 
 
@@ -1349,12 +1353,12 @@ sub post_payment {
       $dbh->do($query) || $form->dberror($query);
 
       $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
-                  source, memo)
+                  source, memo, project_id)
                   VALUES ($form->{id}, (SELECT c.id FROM chart c
                                      WHERE c.accno = '$accno'),
                  $form->{"paid_$i"}, '$form->{"datepaid_$i"}',
-                 '$form->{"source_$i"}', '$form->{"memo_$i"}')|;
-      $dbh->do($query) || $form->dberror($query);
+                 '$form->{"source_$i"}', '$form->{"memo_$i"}', ?)|;
+      do_query($form, $dbh, $query, $project_id);
 
 
       # gain/loss
@@ -1392,12 +1396,12 @@ sub post_payment {
                                         WHERE c.accno = '$accno') AND amount=$form->{fx}{$accno}{$transdate} AND transdate='$transdate' AND cleared='0' AND fx_transaction='1'|;
         $dbh->do($query) || $form->dberror($query);
         $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
-                   transdate, cleared, fx_transaction)
+                   transdate, cleared, fx_transaction, project_id)
                    VALUES ($form->{id},
                           (SELECT c.id FROM chart c
                            WHERE c.accno = '$accno'),
-                   $form->{fx}{$accno}{$transdate}, '$transdate', '0', '1')|;
-        $dbh->do($query) || $form->dberror($query);
+                   $form->{fx}{$accno}{$transdate}, '$transdate', '0', '1', ?)|;
+        do_query($form, $dbh, $query, $project_id);
       }
     }
   }
index da23eb4..3e72da7 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -797,6 +797,8 @@ sub post_invoice {
                                $form->{exchangerate}, 0);
   }
 
+  $project_id = conv_i($form->{"globalproject_id"});
+
   foreach my $trans_id (keys %{ $form->{amount} }) {
     foreach my $accno (keys %{ $form->{amount}{$trans_id} }) {
       next unless ($form->{expense_inventory} =~ /$accno/);
@@ -806,12 +808,12 @@ sub post_invoice {
           ) != 0
         ) {
         $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
-                   transdate, taxkey)
+                   transdate, taxkey, project_id)
                    VALUES ($trans_id, (SELECT c.id FROM chart c
                                        WHERE c.accno = '$accno'),
                    $form->{amount}{$trans_id}{$accno}, '$form->{invdate}',
-                    (SELECT taxkey_id  FROM chart WHERE accno = '$accno'))|;
-        $dbh->do($query) || $form->dberror($query);
+                    (SELECT taxkey_id  FROM chart WHERE accno = '$accno'), ?)|;
+        do_query($form, $dbh, $query, $project_id);
         $form->{amount}{$trans_id}{$accno} = 0;
       }
     }
@@ -823,12 +825,12 @@ sub post_invoice {
           ) != 0
         ) {
         $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
-                   transdate, taxkey)
+                   transdate, taxkey, project_id)
                    VALUES ($trans_id, (SELECT id FROM chart
                                        WHERE accno = '$accno'),
                    $form->{amount}{$trans_id}{$accno}, '$form->{invdate}',
-                    (SELECT taxkey_id  FROM chart WHERE accno = '$accno'))|;
-        $dbh->do($query) || $form->dberror($query);
+                    (SELECT taxkey_id  FROM chart WHERE accno = '$accno'), ?)|;
+        do_query($form, $dbh, $query, $project_id);
       }
     }
   }
@@ -877,23 +879,23 @@ sub post_invoice {
   
         if ($form->{amount}{ $form->{id} }{ $form->{AR} } != 0) {
           $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
-                      transdate)
+                      transdate, project_id)
                       VALUES ($form->{id}, (SELECT c.id FROM chart c
                                           WHERE c.accno = '$form->{AR}'),
-                      $amount, '$form->{"datepaid_$i"}')|;
-          $dbh->do($query) || $form->dberror($query);
+                      $amount, '$form->{"datepaid_$i"}', ?)|;
+          do_query($form, $dbh, $query, $project_id);
         }
   
         # record payment
         $form->{"paid_$i"} *= -1;
   
         $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
-                    source, memo)
+                    source, memo, ?)
                     VALUES ($form->{id}, (SELECT c.id FROM chart c
-                                        WHERE c.accno = '$accno'),
+                                        WHERE c.accno = '$accno', project_id),
                     $form->{"paid_$i"}, '$form->{"datepaid_$i"}',
                     '$form->{"source_$i"}', '$form->{"memo_$i"}')|;
-        $dbh->do($query) || $form->dberror($query);
+        do_query($form, $dbh, $query, $project_id);
   
         # exchangerate difference
         $form->{fx}{$accno}{ $form->{"datepaid_$i"} } +=
@@ -933,12 +935,12 @@ sub post_invoice {
         ) {
 
         $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
-                   transdate, cleared, fx_transaction)
+                   transdate, cleared, fx_transaction, project_id)
                    VALUES ($form->{id},
                           (SELECT c.id FROM chart c
                            WHERE c.accno = '$accno'),
-                   $form->{fx}{$accno}{$transdate}, '$transdate', '0', '1')|;
-        $dbh->do($query) || $form->dberror($query);
+                   $form->{fx}{$accno}{$transdate}, '$transdate', '0', '1', ?)|;
+        do_query($form, $dbh, $query, $project_id);
       }
     }
   }
@@ -1071,6 +1073,8 @@ sub post_payment {
       $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate},
                               "buy");
 
+  my $project_id = conv_i($form->{"globalproject_id"});
+
   # record payments and offsetting AR
   for my $i (1 .. $form->{paidaccounts}) {
 
@@ -1105,11 +1109,11 @@ sub post_payment {
       $dbh->do($query) || $form->dberror($query);
 
       $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
-                  transdate)
+                  transdate, project_id)
                   VALUES ($form->{id}, (SELECT c.id FROM chart c
                                       WHERE c.accno = '$form->{AR}'),
-                  $amount, '$form->{"datepaid_$i"}')|;
-      $dbh->do($query) || $form->dberror($query);
+                  $amount, '$form->{"datepaid_$i"}', ?)|;
+      do_query($form, $dbh, $query, $project_id);
 
 
       # record payment
@@ -1120,12 +1124,12 @@ sub post_payment {
       $dbh->do($query) || $form->dberror($query);
 
       $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
-                  source, memo)
+                  source, memo, project_id)
                   VALUES ($form->{id}, (SELECT c.id FROM chart c
                                      WHERE c.accno = '$accno'),
                  $form->{"paid_$i"}, '$form->{"datepaid_$i"}',
-                 '$form->{"source_$i"}', '$form->{"memo_$i"}')|;
-      $dbh->do($query) || $form->dberror($query);
+                 '$form->{"source_$i"}', '$form->{"memo_$i"}', ?)|;
+      do_query($form, $dbh, $query, $project_id);
 
 
       # gain/loss
@@ -1163,12 +1167,12 @@ sub post_payment {
                                         WHERE c.accno = '$accno') AND amount=$form->{fx}{$accno}{$transdate} AND transdate='$transdate' AND cleared='0' AND fx_transaction='1'|;
         $dbh->do($query) || $form->dberror($query);
         $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount,
-                   transdate, cleared, fx_transaction)
+                   transdate, cleared, fx_transaction, project_id)
                    VALUES ($form->{id},
                           (SELECT c.id FROM chart c
                            WHERE c.accno = '$accno'),
-                   $form->{fx}{$accno}{$transdate}, '$transdate', '0', '1')|;
-        $dbh->do($query) || $form->dberror($query);
+                   $form->{fx}{$accno}{$transdate}, '$transdate', '0', '1', ?)|;
+        do_query($form, $dbh, $query, $project_id);
       }
     }
   }