]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/is.pl
Zusätzliche Auftragsfelder beim Laden von Rechnungen holen.
[mfinanz.git] / bin / mozilla / is.pl
index 530c4776e8127454f69aa29afc770661d84b371a..ad0c99080d941e0355f9327d9a02b43c9894b771 100644 (file)
@@ -45,7 +45,6 @@ require "bin/mozilla/drafts.pl";
 use strict;
 
 my $edit;
-#my $payment;
 my $print_post;
 
 1;
@@ -156,6 +155,14 @@ sub invoice_links {
     $ref->{name} = $form->quote($ref->{name});
   }
 
+  # Load data for a specific order and update form fields
+  my $order_data = IS->get_order_data();
+
+  # Copy the fields we need to %form
+  for my $key (qw(payment_id salesman_id orddate taxzone_id quonumber)) {
+    $form->{$key} = $order_data->{$key};
+  }
+
   $form->restore_vars(qw(id));
 
   IS->retrieve_invoice(\%myconfig, \%$form);
@@ -163,24 +170,22 @@ sub invoice_links {
   $form->restore_vars(qw(taxincluded)) if $form->{id};
   $form->restore_vars(qw(salesman_id)) if $main::editing;
 
+
   # build vendor/customer drop down comatibility... don't ask
   if (@{ $form->{"all_customer"} }) {
     $form->{"selectcustomer"} = 1;
     $form->{customer}         = qq|$form->{customer}--$form->{"customer_id"}|;
   }
 
-  $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
-  $form->{selectcustomer} = 1;
+  $form->{"oldcustomer"}  = $form->{customer};
 
-  # departments
-#  if ($form->{all_departments}) {
-#    $form->{selectdepartment} = "<option>\n";
-#    $form->{department}       = "$form->{department}--$form->{department_id}";
-#
-#    map {
-#      $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}</option>\n"
-#    } @{ $form->{all_departments} };
-#  }
+  if ($form->{"oldcustomer"} !~ m/--\d+$/ && $form->{"customer_id"}) {
+    $form->{"oldcustomer"} .= qq|--$form->{"customer_id"}|
+  }
+
+
+#  $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
+#  $form->{selectcustomer} = 1;
 
   $form->{employee} = "$form->{employee}--$form->{employee_id}";
 
@@ -408,7 +413,7 @@ sub form_footer {
   # follow ups
   if ($form->{id}) {
     $form->{follow_ups}            = FU->follow_ups('trans_id' => $form->{id}) || [];
-    $form->{follow_ups_unfinished} = sum map { $_->{due} * 1 } @{ $form->{follow_ups} };
+    $form->{follow_ups_unfinished} = ( sum map { $_->{due} * 1 } @{ $form->{follow_ups} } ) || 0;
   }
 
   # payments
@@ -459,7 +464,7 @@ sub update {
 
   my ($recursive_call) = shift;
 
-  map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining) unless $recursive_call;
+#  map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining) unless $recursive_call;
 
   $form->{print_and_post} = 0         if $form->{second_run};
   my $taxincluded            = "checked" if $form->{taxincluded};
@@ -880,8 +885,8 @@ sub credit_note {
 
   map { $form->{"select$_"} = "" } ($form->{vc}, 'currency');
 
-  map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
-    qw(creditlimit creditremaining);
+#  map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
+#    qw(creditlimit creditremaining);
 
   my $currency = $form->{currency};
   &invoice_links;