]> wagnertech.de Git - kivitendo-erp.git/blobdiff - bin/mozilla/oe.pl
booking roundings to new standard-accounts
[kivitendo-erp.git] / bin / mozilla / oe.pl
index a89f69b09179679e2a78481101ac8727185d2468..565a40310df835fa240976e3ccebfe8145d8c293 100644 (file)
@@ -352,7 +352,6 @@ sub form_header {
 
   $form->get_lists("taxzones"      => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
                    "payments"      => "ALL_PAYMENTS",
-                   "projects"      => "ALL_PROJECTS",
                    "currencies"    => "ALL_CURRENCIES",
                    "departments"   => "ALL_DEPARTMENTS",
                    $vc             => { key   => "ALL_" . uc($vc),
@@ -377,6 +376,7 @@ sub form_header {
     ]);
 
   $TMPL_VAR{ALL_PROJECTS}          = SL::DB::Manager::Project->get_all_sorted(query => \@conditions);
+  $form->{ALL_PROJECTS}            = $TMPL_VAR{ALL_PROJECTS}; # make projects available for second row drop-down in io.pl
 
   # label subs
   my $employee_list_query_gen      = sub { $::form->{$_[0]} ? [ or => [ id => $::form->{$_[0]}, deleted => 0 ] ] : [ deleted => 0 ] };
@@ -535,9 +535,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,7 +556,10 @@ sub form_footer {
     }
   }
 
-  $form->{oldinvtotal} = $form->{invtotal};
+  # beware numeric effects
+  $form->{oldinvtotal} = $form->round_amount( $form->{invtotal},2,1 );
+  $form->{rounding} = $form->round_amount( $form->{oldinvtotal}-$form->{invtotal}, 2 );
+  $form->{invtotal} = $form->{oldinvtotal};
 
   $TMPL_VAR{ALL_DELIVERY_TERMS} = SL::DB::Manager::DeliveryTerm->get_all_sorted();
 
@@ -625,7 +625,7 @@ sub update {
     if ($form->{type} =~ /^sales/) {
       IS->retrieve_item(\%myconfig, \%$form);
       $mode = 'IS';
-    } else {
+  } else {
       IR->retrieve_item(\%myconfig, \%$form);
       $mode = 'IR';
     }
@@ -1147,6 +1147,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 +1254,7 @@ sub save {
 
   check_oe_access();
 
+  $form->mtime_ischanged('oe');
   $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
 
 
@@ -1404,6 +1406,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};
@@ -1751,6 +1755,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 +1795,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 +1885,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 +1946,7 @@ sub e_mail {
 
   check_oe_access();
 
+  $form->mtime_ischanged('oe','mail');
   $form->{print_and_save} = 1;
 
   my $saved_form = save_form();
@@ -2063,6 +2073,7 @@ sub save_periodic_invoices_config {
 
   my $config = { active                  => $::form->{active}     ? 1 : 0,
                  terminated              => $::form->{terminated} ? 1 : 0,
+                 direct_debit            => $::form->{direct_debit} ? 1 : 0,
                  periodicity             => (any { $_ eq $::form->{periodicity}             }       @SL::DB::PeriodicInvoicesConfig::PERIODICITIES)              ? $::form->{periodicity}             : 'm',
                  order_value_periodicity => (any { $_ eq $::form->{order_value_periodicity} } ('p', @SL::DB::PeriodicInvoicesConfig::ORDER_VALUE_PERIODICITIES)) ? $::form->{order_value_periodicity} : 'p',
                  start_date_as_date      => $::form->{start_date_as_date},