Erfolgsrechnung: von pos_eur auf pos_er gelegt.
[kivitendo-erp.git] / bin / mozilla / oe.pl
index 97494cf..164eab3 100644 (file)
@@ -240,9 +240,7 @@ sub order_links {
   # get customer/vendor
   $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
 
-  # retrieve order/quotation and webdav config
-  $form->{webdav}   = $::instance_conf->get_webdav;
-
+  # retrieve order/quotation
   my $editing = $form->{id};
 
   OE->retrieve(\%myconfig, \%$form);
@@ -535,9 +533,6 @@ sub form_footer {
               </tr> |;
       }
     }
-
-#    $form->{invsubtotal} = $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0); # template does this
-
   } else {
     foreach my $item (split / /, $form->{taxaccounts}) {
       if ($form->{"${item}_base"}) {
@@ -559,6 +554,10 @@ sub form_footer {
     }
   }
 
+  $form->{rounding} = $form->round_amount(
+    $form->round_amount($form->{invtotal}, 2, 1) - $form->round_amount($form->{invtotal}, 2)
+  );
+  $form->{invtotal} = $form->round_amount( $form->{invtotal}, 2, 1);
   $form->{oldinvtotal} = $form->{invtotal};
 
   $TMPL_VAR{ALL_DELIVERY_TERMS} = SL::DB::Manager::DeliveryTerm->get_all_sorted();
@@ -567,7 +566,6 @@ sub form_footer {
   $tpca_reminder = check_transport_cost_reminder_article_number() if $::instance_conf->get_transport_cost_reminder_article_number_id;
   print $form->parse_html_template("oe/form_footer", {
      %TMPL_VAR,
-     webdav          => $::instance_conf->get_webdav,
      tpca_reminder   => $tpca_reminder,
      print_options   => print_options(inline => 1),
      label_edit      => $locale->text("Edit the $form->{type}"),
@@ -789,7 +787,6 @@ sub search {
   $form->header();
 
   print $form->parse_html_template('oe/search', {
-    %myconfig,
     is_order => scalar($form->{type} =~ /_order/),
   });
 
@@ -1147,6 +1144,7 @@ sub save_and_close {
   my $locale   = $main::locale;
 
   check_oe_access();
+  $form->mtime_ischanged('oe');
 
   $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
 
@@ -1253,6 +1251,7 @@ sub save {
 
   check_oe_access();
 
+  $form->mtime_ischanged('oe');
   $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
 
 
@@ -1404,6 +1403,8 @@ sub invoice {
 
   check_oe_access();
   check_oe_conversion_to_sales_invoice_allowed();
+  $form->mtime_ischanged('oe');
+
   $main::auth->assert($form->{type} eq 'purchase_order' || $form->{type} eq 'request_quotation' ? 'vendor_invoice_edit' : 'invoice_edit');
 
   $form->{old_salesman_id} = $form->{salesman_id};
@@ -1663,14 +1664,9 @@ sub save_as_new {
   if ( $form->{reqdate} && $form->{id} ) {
     my $saved_order = OE->retrieve_simple(id => $form->{id});
     if ( $saved_order && $saved_order->{reqdate} eq $form->{reqdate} && $saved_order->{transdate} eq $form->{transdate} ) {
-      my $extra_days   = $form->{type} eq 'sales_quotation' ? $::instance_conf->get_reqdate_interval : 1;
-      my $next_workday = DateTime->today_local->add(days => $extra_days);
-      my $day_of_week  = $next_workday->day_of_week;
-
-      $next_workday->add(days => (8 - $day_of_week)) if $day_of_week >= 6;
-
+      my $extra_days     = $form->{type} eq 'sales_quotation' ? $::instance_conf->get_reqdate_interval : 1;
+      $form->{reqdate}   = DateTime->today_local->next_workday(extra_days => $extra_days)->to_kivitendo;
       $form->{transdate} = DateTime->today_local->to_kivitendo;
-      $form->{reqdate}   = $next_workday->to_kivitendo;
     }
   }
 
@@ -1751,6 +1747,8 @@ sub purchase_order {
   my $locale   = $main::locale;
 
   check_oe_access();
+  $form->mtime_ischanged('oe');
+
   $main::auth->assert('purchase_order_edit');
 
   $form->{sales_order_to_purchase_order} = 0;
@@ -1789,6 +1787,7 @@ sub sales_order {
 
   check_oe_access();
   $main::auth->assert('sales_order_edit');
+  $form->mtime_ischanged('oe');
 
   if ($form->{type} eq "purchase_order") {
     delete($form->{ordnumber});
@@ -1878,6 +1877,8 @@ sub delivery_order {
   my $form     = $main::form;
   my %myconfig = %main::myconfig;
 
+  $form->mtime_ischanged('oe');
+
   if ($form->{type} =~ /^sales/) {
     $main::auth->assert('sales_delivery_order_edit');
 
@@ -1937,6 +1938,7 @@ sub e_mail {
 
   check_oe_access();
 
+  $form->mtime_ischanged('oe','mail');
   $form->{print_and_save} = 1;
 
   my $saved_form = save_form();