X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fap.pl;h=33d2eee3fb0d2c7725e5272dec7ea8cacf36b696;hb=e09347c89ca119213c4d8ba43083653cda793399;hp=895fa0305da57db7e6a35289c839deeb5d5308e0;hpb=2dc09cf507b099b014a405001a6d67aa58cd124d;p=kivitendo-erp.git diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 895fa0305..33d2eee3f 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -298,12 +298,13 @@ selectvendor } | 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" => "AP" },); map({ $_->{link_split} = [ split(/:/, $_->{link}) ]; } @{ $form->{ALL_CHARTS} }); @@ -361,12 +362,12 @@ selectvendor } | # with JavaScript Calendar $button1 = qq| - $readonly + text('button') . qq|> |; $button2 = qq| - $readonly + text('button') . qq|> |; @@ -379,9 +380,9 @@ selectvendor } | # without JavaScript Calendar $button1 = - qq| $readonly|; + qq||; $button2 = - qq| $readonly|; + qq||; } my $follow_up_vc = $form->{vendor}; @@ -426,7 +427,7 @@ selectvendor } | - + @@ -498,8 +499,6 @@ $jsscript . $locale->text('Amount') . qq| - - - + $tax @@ -642,7 +638,7 @@ $jsscript $column_data{AP_paid} = ""; $column_data{source} = ""; $column_data{memo} = ""; - $column_data{paid_project_id} = ""; + $column_data{paid_project_id} = ""; print " @@ -703,7 +699,7 @@ $jsscript $column_data{"exchangerate_$i"} = qq||; $column_data{"datepaid_$i"} = qq||; + |; $column_data{"source_$i"} = qq||; $column_data{"memo_$i"} = @@ -804,10 +800,9 @@ $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, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap', $form->{id})); + if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap', $form->{id}) && (($total_paid == 0) || ($total_paid eq ""))); print qq| @@ -823,8 +818,8 @@ $follow_ups_block print qq| |; } # /button for saving history - # mark_as_paid button - if($form->{id} ne "") { + # mark_as_paid button + if($form->{id} ne "") { print qq| |; } # /mark_as_paid button @@ -843,7 +838,7 @@ sub mark_as_paid { $auth->assert('general_ledger'); - &mark_as_paid_common(\%myconfig,"ap"); + &mark_as_paid_common(\%myconfig,"ap"); $lxdebug->leave_sub(); } @@ -857,10 +852,12 @@ sub update { $form->{invtotal} = 0; + delete @{ $form }{ grep { m/^tax_\d+$/ } keys %{ $form } }; + map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); - @flds = qw(amount AP_amount projectnumber oldprojectnumber project_id); + @flds = qw(amount AP_amount projectnumber oldprojectnumber project_id taxchart); $count = 0; for $i (1 .. $form->{rowcount}) { $form->{"amount_$i"} = @@ -869,17 +866,15 @@ sub update { if ($form->{"amount_$i"}) { push @a, {}; $j = $#a; - if (!$form->{"korrektur_$i"}) { - ($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; - } + ($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); @@ -896,9 +891,16 @@ sub update { $form->{exchangerate} = $form->{forex} if $form->{forex}; $form->{invdate} = $form->{transdate}; - $save_AP = $form->{AP}; - &check_name("vendor"); - $form->{AP} = $save_AP; + my %saved_variables = map +( $_ => $form->{$_} ), qw(AP AP_amount_1 taxchart_1); + + my $vendor_changed = &check_name("vendor"); + + $form->{AP} = $saved_variables{AP}; + if ($saved_variables{AP_amount_1} =~ m/.--./) { + map { $form->{$_} = $saved_variables{$_} } qw(AP_amount_1 taxchart_1); + } else { + delete $form->{taxchart_1}; + } $form->{rowcount} = $count + 1; @@ -926,7 +928,7 @@ sub update { $form->{oldtotalpaid} = $totalpaid; # notes - $form->{notes} = $form->{intnotes}; + $form->{notes} = $form->{intnotes} if $vendor_changed; &display_form; @@ -1040,7 +1042,7 @@ sub post { $form->{addition} = "POSTED"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history + # /saving the history remove_draft() if $form->{remove_draft}; $form->redirect($locale->text('Transaction posted!')); } @@ -1061,7 +1063,7 @@ sub post_as_new { $form->{addition} = "POSTED AS NEW"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history + # /saving the history &post; $lxdebug->leave_sub(); @@ -1134,7 +1136,7 @@ sub yes { $form->{addition} = "DELETED"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history + # /saving the history $form->redirect($locale->text('Transaction deleted!')); } $form->error($locale->text('Cannot delete transaction!')); @@ -1426,48 +1428,27 @@ sub ap_transactions { $report->set_columns(%column_defs); $report->set_column_order(@columns); - $report->set_export_options('ap_transactions', @hidden_variables); + $report->set_export_options('ap_transactions', @hidden_variables, qw(sort sortdir)); $report->set_sort_indicator($form->{sort}, $form->{sortdir}); my @options; - if ($form->{vendor}) { - push @options, $locale->text('Vendor') . " : $form->{vendor}"; - } - if ($form->{department}) { - ($department) = split /--/, $form->{department}; - push @options, $locale->text('Department') . " : $department"; - } - if ($form->{invnumber}) { - push @options, $locale->text('Invoice Number') . " : $form->{invnumber}"; - } - if ($form->{ordnumber}) { - push @options, $locale->text('Order Number') . " : $form->{ordnumber}"; - } - if ($form->{notes}) { - push @options, $locale->text('Notes') . " : $form->{notes}"; - } - if ($form->{transaction_description}) { - push @options, $locale->text('Transaction description') . " : $form->{transaction_description}"; - } - if ($form->{transdatefrom}) { - 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); - } - if ($form->{open}) { - push @options, $locale->text('Open'); - } - if ($form->{closed}) { - push @options, $locale->text('Closed'); - } + push @options, $locale->text('Vendor') . " : $form->{vendor}" if ($form->{vendor}); + push @options, $locale->text('Department') . " : " . (split /--/, $form->{department})[0] if ($form->{department}); + push @options, $locale->text('Invoice Number') . " : $form->{invnumber}" if ($form->{invnumber}); + push @options, $locale->text('Order Number') . " : $form->{ordnumber}" if ($form->{ordnumber}); + push @options, $locale->text('Notes') . " : $form->{notes}" if ($form->{notes}); + push @options, $locale->text('Transaction description') . " : $form->{transaction_description}" if ($form->{transaction_description}); + push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1) if ($form->{transdatefrom}); + push @options, $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{transdateto}, 1) if ($form->{transdateto}); + push @options, $locale->text('Open') if ($form->{open}); + push @options, $locale->text('Closed') if ($form->{closed}); $report->set_options('top_info_text' => join("\n", @options), 'raw_bottom_info_text' => $form->parse_html_template('ap/ap_transactions_bottom'), 'output_format' => 'HTML', 'title' => $form->{title}, - 'attachment_basename' => $locale->text('invoice_list') . strftime('_%Y%m%d', localtime time), + 'attachment_basename' => $locale->text('vendor_invoice_list') . strftime('_%Y%m%d', localtime time), ); $report->set_options_from_form(); @@ -1493,9 +1474,20 @@ sub ap_transactions { map { $ap->{$_} = $form->format_amount(\%myconfig, $ap->{$_}, 2) } qw(netamount tax amount paid due); - $ap->{type} = - $ap->{invoice} ? $locale->text("Invoice (one letter abbreviation)") : - $locale->text("AP Transaction (abbreviation)"); + my $is_storno = $ap->{storno} && $ap->{storno_id}; + my $has_storno = $ap->{storno} && !$ap->{storno_id}; + + if ($ap->{invoice}) { + $ap->{type} = + $has_storno ? $locale->text("Invoice with Storno (abbreviation)") + : $is_storno ? $locale->text("Storno (one letter abbreviation)") + : $locale->text("Invoice (one letter abbreviation)"); + } else { + $ap->{type} = + $has_storno ? $locale->text("AP Transaction with Storno (abbreviation)") + : $is_storno ? $locale->text("AP Transaction Storno (one letter abbreviation)") + : $locale->text("AP Transaction (abbreviation)"); + } my $row = { }; @@ -1548,9 +1540,9 @@ sub storno { $form->{addition} = "STORNO"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history + # /saving the history - $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id}); + $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id}); $lxdebug->leave_sub(); }
| . $locale->text('Vendor') . qq|$vendor $vendor | . $locale->text('Tax') . qq|| - . $locale->text('Korrektur') . qq| | . $locale->text('Taxkey') . qq| | @@ -555,8 +554,6 @@ $jsscript '-default' => $selected_taxchart)) . qq||; - my $korrektur = $form->{"korrektur_$i"} ? 'checked' : ''; - my $projectnumber = NTI($cgi->popup_menu('-name' => "project_id_$i", '-values' => \@project_values, @@ -567,8 +564,7 @@ $jsscript
$selectAP_amount {"amount_$i"}>{"tax_$i"}>$form->{"tax_$i"}$projectnumber
" . $locale->text('Account') . "" . $locale->text('Source') . "" . $locale->text('Memo') . "" . $locale->text('Project Number') . "" . $locale->text('Project Number') . "
$exchangerate -