]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/ar.pl
Einkaufs- & Verkaufsbelege: Bearbeiter*in & Verkäufer*in mit aktueller Benutzer*in...
[mfinanz.git] / bin / mozilla / ar.pl
index a1a7635ab8bd0afc955774a274b5edf76b7ff72f..9d1784f78f2d3d6d70a073959a9ed854e0435afc 100644 (file)
@@ -407,8 +407,7 @@ sub form_header {
     };
 
     my (%taxchart_labels, @taxchart_values, $default_taxchart, $taxchart_to_use);
-    my $amount_chart_id   = $form->{"AR_amount_chart_id_$i"} // $default_ar_amount_chart_id;
-    my $chart_has_changed = $::form->{"previous_AR_amount_chart_id_$i"} && ($amount_chart_id != $::form->{"previous_AR_amount_chart_id_$i"});
+    my $amount_chart_id = $form->{"AR_amount_chart_id_$i"} // $default_ar_amount_chart_id;
 
     foreach my $item ( GL->get_active_taxes_for_chart($amount_chart_id, $transdate) ) {
       my $key             = $item->id . "--" . $item->rate;
@@ -420,7 +419,7 @@ sub form_header {
       $taxchart_labels{$key} = $item->taxdescription . " " . $item->rate * 100 . ' %';
     }
 
-    $taxchart_to_use      = $default_taxchart // $first_taxchart if $chart_has_changed || !$taxchart_to_use;
+    $taxchart_to_use    //= $default_taxchart // $first_taxchart;
     my $selected_taxchart = $taxchart_to_use->id . '--' . $taxchart_to_use->rate;
 
     $transaction->{selectAR_amount} =
@@ -611,6 +610,10 @@ sub update {
 
   if (($form->{previous_customer_id} || $form->{customer_id}) != $form->{customer_id}) {
     IS->get_customer(\%myconfig, $form);
+    if (($form->{rowcount} == 1) && ($form->{amount_1} == 0)) {
+      my $last_used_ar_chart = SL::DB::Customer->load_cached($form->{customer_id})->last_used_ar_chart;
+      $form->{"AR_amount_chart_id_1"} = $last_used_ar_chart->id if $last_used_ar_chart;
+    }
   }
 
   $form->{invtotal} =
@@ -913,7 +916,7 @@ sub search {
   my $locale   = $main::locale;
   my $cgi      = $::request->{cgi};
 
-  $form->{title}    = $locale->text('AR Transactions');
+  $form->{title} = $locale->text('Invoices, Credit Notes & AR Transactions');
 
   $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
   $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted;
@@ -974,7 +977,7 @@ sub ar_transactions {
 
   AR->ar_transactions(\%myconfig, \%$form);
 
-  $form->{title} = $locale->text('AR Transactions');
+  $form->{title} = $locale->text('Invoices, Credit Notes & AR Transactions');
 
   my $report = SL::ReportGenerator->new(\%myconfig, $form);
 
@@ -1028,7 +1031,7 @@ sub ar_transactions {
     'ustid'                   => { 'text' => $locale->text('USt-IdNr.'), },
     'taxzone'                 => { 'text' => $locale->text('Steuersatz'), },
     'payment_terms'           => { 'text' => $locale->text('Payment Terms'), },
-    'charts'                  => { 'text' => $locale->text('Buchungskonto'), },
+    'charts'                  => { 'text' => $locale->text('Chart'), },
     'customertype'            => { 'text' => $locale->text('Customer type'), },
     'direct_debit'            => { 'text' => $locale->text('direct debit'), },
     'department'              => { 'text' => $locale->text('Department'), },
@@ -1201,7 +1204,7 @@ sub ar_transactions {
   $::request->layout->add_javascripts('kivi.MassInvoiceCreatePrint.js');
   setup_ar_transactions_action_bar(num_rows => scalar(@{ $form->{AR} }));
 
-  $report->generate_with_headers(action_bar => 1);
+  $report->generate_with_headers();
 
   $main::lxdebug->leave_sub();
 }