Beim Erzeugen einer Rechnung für Mahngebühren taxzone_id des Kunden eintragen.
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 17 Apr 2015 09:13:02 +0000 (11:13 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 17 Apr 2015 09:13:02 +0000 (11:13 +0200)
Ist notwendig geworden, da das Feld taxzone_id inzwischen not null ist.
Behebt #54 (redmine).

SL/DN.pm

index c9289e4..5520083 100644 (file)
--- a/SL/DN.pm
+++ b/SL/DN.pm
@@ -211,7 +211,7 @@ sub create_invoice_for_fees {
   $query =
     qq|INSERT INTO ar (id,          invnumber, transdate, gldate, customer_id,
                        taxincluded, amount,    netamount, paid,   duedate,
-                       invoice,     currency_id,      notes,
+                       invoice,     currency_id, taxzone_id,      notes,
                        employee_id)
        VALUES (
          ?,                     -- id
@@ -232,6 +232,14 @@ sub create_invoice_for_fees {
          (SELECT duedate FROM dunning WHERE dunning_id = ? LIMIT 1),
          'f',                   -- invoice
          (SELECT id FROM currencies WHERE name = ?), -- curr
+         --taxzone_id:
+         (SELECT taxzone_id FROM customer WHERE id =
+          (SELECT ar.customer_id
+           FROM dunning dn
+           LEFT JOIN ar ON (dn.trans_id = ar.id)
+           WHERE dn.dunning_id = ?
+           LIMIT 1)
+         ),
          ?,                     -- notes
          -- employee_id:
          (SELECT id FROM employee WHERE login = ?)
@@ -243,6 +251,7 @@ sub create_invoice_for_fees {
              $amount,
              $dunning_id,       # duedate
              $curr,             # default currency
+             $dunning_id,       # taxzone_id
              sprintf($main::locale->text('Automatically created invoice for fee and interest for dunning %s'), $dunning_id), # notes
              $::myconfig{login});   # employee_id
   do_query($form, $dbh, $query, @values);