X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fap.pl;h=04604831e5a6e6d59cd76dec441dc400bb22dc67;hb=cc6d0e60e203d7b7fab1e95908cbe4afca5e18a0;hp=7b16657e578c9f11824bc7592df27be8345b46d3;hpb=5be8f31261931722ee1e33d553282140c323e6a9;p=kivitendo-erp.git diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 7b16657e5..04604831e 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -483,23 +483,15 @@ sub update { my $count = 0; my (@a, $j, $totaltax); for my $i (1 .. $form->{rowcount}) { - $form->{"amount_$i"} = - $form->parse_amount(\%myconfig, $form->{"amount_$i"}); - $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"}); + $form->{"amount_$i"} = $form->parse_amount(\%myconfig, $form->{"amount_$i"}); if ($form->{"amount_$i"}) { push @a, {}; $j = $#a; 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; - } - } else { - $form->{"tax_$i"} = 0; - } - $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2); + + # calculate tax exactly the same way as AP in post_transaction via form->calculate_tax + my $tmpnetamount; + ($tmpnetamount,$form->{"tax_$i"}) = $form->calculate_tax($form->{"amount_$i"},$rate,$form->{taxincluded},2); $totaltax += $form->{"tax_$i"}; map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds; @@ -590,9 +582,15 @@ sub post_payment { ($form->{AP}) = split /--/, $form->{AP}; ($form->{AP_paid}) = split /--/, $form->{AP_paid}; - $form->redirect($locale->text('Payment posted!')) - if (AP->post_payment(\%myconfig, \%$form)); + if (AP->post_payment(\%myconfig, \%$form)) { + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{what_done} = 'invoice'; + $form->{addition} = "PAYMENT POSTED"; + $form->save_history; + $form->redirect($locale->text('Payment posted!')) + } else { $form->error($locale->text('Cannot post payment!')); + }; $main::lxdebug->leave_sub(); @@ -681,8 +679,9 @@ sub post { if (AP->post_transaction(\%myconfig, \%$form)) { # saving the history if(!exists $form->{addition} && $form->{id} ne "") { - $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; - $form->{addition} = "POSTED"; + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{addition} = "POSTED"; + $form->{what_done} = "invoice"; $form->save_history; } # /saving the history @@ -707,8 +706,12 @@ sub post_as_new { $form->{postasnew} = 1; # saving the history if(!exists $form->{addition} && $form->{id} ne "") { - $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; - $form->{addition} = "POSTED AS NEW"; + # does this work? post_as_new for ap doesn't immediately save the + # invoice, because the invnumber has to be entered by hand. + # And the value of $form->{postasnew} isn't checked when calling post + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{addition} = "POSTED AS NEW"; + $form->{what_done} = "invoice"; $form->save_history; } # /saving the history @@ -785,8 +788,9 @@ sub yes { if (AP->delete_transaction(\%myconfig, \%$form)) { # saving the history if(!exists $form->{addition}) { - $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; - $form->{addition} = "DELETED"; + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{addition} = "DELETED"; + $form->{what_done} = "invoice"; $form->save_history; } # /saving the history @@ -919,6 +923,7 @@ sub ap_transactions { my @options; push @options, $locale->text('Vendor') . " : $form->{vendor}" if ($form->{vendor}); + push @options, $locale->text('Contact Person') . " : $form->{cp_name}" if ($form->{cp_name}); 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}); @@ -1029,8 +1034,9 @@ sub storno { # saving the history if(!exists $form->{addition} && $form->{id} ne "") { - $form->{snumbers} = "ordnumber_$form->{ordnumber}"; - $form->{addition} = "STORNO"; + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{addition} = "STORNO"; + $form->{what_done} = "invoice"; $form->save_history; } # /saving the history