X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=c41068046edafedcf49eaa7422e4dc60fa9a46f3;hb=8f8ad003294a3a8277500ca7ec436f9f92999de2;hp=e0571633dc5c39b34e009331a796623d8df35ca2;hpb=679db39f627675838659464293d384b0f8a79a96;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index e0571633d..c41068046 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -32,7 +32,7 @@ #====================================================================== use POSIX qw(strftime); -use List::Util qw(sum); +use List::Util qw(sum first); use SL::AR; use SL::FU; @@ -214,7 +214,7 @@ sub form_header { my ($title, $readonly, $exchangerate, $rows); my ($taxincluded, $notes, $department, $customer, $employee, $amount, $project); my ($jsscript, $button1, $button2, $onload); - my ($selectAR_amount, $selectAR_paid, $korrektur_checked, $ARselected, $tax); + my ($selectAR_amount, $selectAR_paid, $ARselected, $tax); my (@column_index, %column_data); @@ -340,12 +340,13 @@ sub form_header { map({ push(@old_project_ids, $form->{"project_id_$_"}) if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); - $form->get_lists("projects" => { "key" => "ALL_PROJECTS", - "all" => 0, - "old_id" => \@old_project_ids }, - "charts" => { "key" => "ALL_CHARTS", - "transdate" => $form->{transdate} }, - "taxcharts" => "ALL_TAXCHARTS"); + $form->get_lists("projects" => { "key" => "ALL_PROJECTS", + "all" => 0, + "old_id" => \@old_project_ids }, + "charts" => { "key" => "ALL_CHARTS", + "transdate" => $form->{transdate} }, + "taxcharts" => { "key" => "ALL_TAXCHARTS", + "module" => "AR" },); map({ $_->{link_split} = [ split(/:/, $_->{link}) ]; } @{ $form->{ALL_CHARTS} }); @@ -544,8 +545,6 @@ $jsscript | . $locale->text('Tax') . qq| | - . $locale->text('Korrektur') . qq| - | . $locale->text('Taxkey') . qq| | . $locale->text('Project') . qq| @@ -578,7 +577,13 @@ $jsscript $selected_taxchart = "$item->{id}--$item->{rate}"; } - $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"}); + if (!$form->{"taxchart_$i"}) { + if ($form->{"AR_amount_$i"} =~ m/.--./) { + $selected_taxchart = join '--', map { ($_->{id}, $_->{rate}) } first { $_->{id} == $item->{tax_id} } @{ $form->{ALL_TAXCHARTS} }; + } else { + $selected_taxchart = $taxchart_init; + } + } $selectAR_amount = NTI($cgi->popup_menu('-name' => "AR_amount_$i", @@ -600,8 +605,6 @@ $jsscript '-default' => $selected_taxchart)) . qq||; - $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : ''); - my $projectnumber = NTI($cgi->popup_menu('-name' => "project_id_$i", '-values' => \@project_values, @@ -612,8 +615,7 @@ $jsscript $selectAR_amount {"amount_$i"}> - {"tax_$i"}> - + $form->{"tax_$i"} $tax $projectnumber @@ -847,7 +849,7 @@ $follow_ups_block # ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it print qq| | - if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ar') && !IS->is_storno(\%myconfig, $form, 'ar')); + if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ar') && !IS->is_storno(\%myconfig, $form, 'ar') && (($total_paid == 0) || ($total_paid eq ""))); if ($form->{id}) { if ($form->{radier}) { @@ -919,6 +921,8 @@ sub update { $form->{invtotal} = 0; + delete @{ $form }{ grep { m/^tax_\d+$/ } keys %{ $form } }; + map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); @@ -932,17 +936,15 @@ sub update { if ($form->{"amount_$i"}) { push @a, {}; my $j = $#a; - if (!$form->{"korrektur_$i"}) { - my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"}); - if ($taxkey > 1) { - if ($form->{taxincluded}) { - $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate; - } else { - $form->{"tax_$i"} = $form->{"amount_$i"} * $rate; - } + my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"}); + if ($taxkey > 1) { + if ($form->{taxincluded}) { + $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate; } else { - $form->{"tax_$i"} = 0; + $form->{"tax_$i"} = $form->{"amount_$i"} * $rate; } + } else { + $form->{"tax_$i"} = 0; } $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2); @@ -960,9 +962,19 @@ sub update { $form->{exchangerate} = $form->{forex} if $form->{forex}; $form->{invdate} = $form->{transdate}; - my $save_AR = $form->{AR}; - check_name("customer"); - $form->{AR} = $save_AR; + + $form->{invdate} = $form->{transdate}; + + my %saved_variables = map +( $_ => $form->{$_} ), qw(AR AR_amount_1 taxchart_1); + + &check_name("customer"); + + $form->{AR} = $saved_variables{AR}; + if ($saved_variables{AR_amount_1} =~ m/.--./) { + map { $form->{$_} = $saved_variables{$_} } qw(AR_amount_1 taxchart_1); + } else { + delete $form->{taxchart_1}; + } $form->{invtotal} = ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax; @@ -1500,7 +1512,7 @@ sub ar_transactions { 'marge_percent' => { 'text' => $locale->text('Ertrag prozentual'), }, ); - foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid employee shippingpoint shipvia)) { + foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid employee shippingpoint shipvia transaction_description)) { my $sortdir = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir}; $column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir"; } @@ -1513,7 +1525,7 @@ sub ar_transactions { $report->set_columns(%column_defs); $report->set_column_order(@columns); - $report->set_export_options('ar_transactions', @hidden_variables); + $report->set_export_options('ar_transactions', @hidden_variables, qw(sort sortdir)); $report->set_sort_indicator($form->{sort}, $form->{sortdir}); @@ -1538,10 +1550,10 @@ sub ar_transactions { push @options, $locale->text('Transaction description') . " : $form->{transaction_description}"; } if ($form->{transdatefrom}) { - push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1); + push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1); } if ($form->{transdateto}) { - push @options, $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{transdateto}, 1); + push @options, $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{transdateto}, 1); } if ($form->{open}) { push @options, $locale->text('Open'); @@ -1583,8 +1595,8 @@ sub ar_transactions { map { $ar->{$_} = $form->format_amount(\%myconfig, $ar->{$_}, 2) } qw(netamount tax amount paid due marge_total marge_percent); - my $is_storno = $ar->{storno} && !$ar->{storno_id}; - my $has_storno = $ar->{storno} && $ar->{storno_id}; + my $is_storno = $ar->{storno} && $ar->{storno_id}; + my $has_storno = $ar->{storno} && !$ar->{storno_id}; $ar->{type} = $has_storno ? $locale->text("Invoice with Storno (abbreviation)") :