X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAP.pm;h=e4ff230c2e8af13b449bb70581c3745d3a9d4ee8;hb=89c9ff022d3f13e27ba6bda085df15707fcfb0eb;hp=ad8749f56882cd4d2fafe78b8383acbc258ce5f6;hpb=5dfee15a6634923410679ad91d965b2df34172a4;p=kivitendo-erp.git diff --git a/SL/AP.pm b/SL/AP.pm index ad8749f56..e4ff230c2 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -38,13 +38,15 @@ use SL::DBUtils; use SL::IO; use SL::MoreCommon; +use Data::Dumper; + use strict; sub post_transaction { $main::lxdebug->enter_sub(); my ($self, $myconfig, $form, $provided_dbh, $payments_only) = @_; - + my $rc = 0; # return code auf false setzen # connect to database my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect_noauto($myconfig); @@ -52,6 +54,7 @@ sub post_transaction { my $exchangerate = 0; $form->{defaultcurrency} = $form->get_default_currency($myconfig); + delete $form->{currency} unless $form->{defaultcurrency}; ($null, $form->{department_id}) = split(/--/, $form->{department}); $form->{department_id} *= 1; @@ -68,7 +71,7 @@ sub post_transaction { (split(/--/, $form->{"AP_amount_$i"}))[0]; } ($form->{AP_amounts}{payables}) = split(/--/, $form->{APselected}); - ($form->{AP}{payables}) = split(/--/, $form->{APselected}); + ($form->{AP_payables}) = split(/--/, $form->{APselected}); # reverse and parse amounts for my $i (1 .. $form->{rowcount}) { @@ -105,26 +108,14 @@ sub post_transaction { my ($tax, $diff); if ($form->{taxincluded} *= 1) { - if (!$form->{"korrektur_$i"}) { - $tax = - $form->{"amount_$i"} - - ($form->{"amount_$i"} / ($form->{"taxrate_$i"} + 1)); - } else { - $tax = $form->{"tax_$i"}; - } + $tax = $form->{"amount_$i"} - ($form->{"amount_$i"} / ($form->{"taxrate_$i"} + 1)); $amount = $form->{"amount_$i"} - $tax; $form->{"amount_$i"} = $form->round_amount($amount, 2); $diff += $amount - $form->{"amount_$i"}; $form->{"tax_$i"} = $form->round_amount($tax, 2); $form->{netamount} += $form->{"amount_$i"}; } else { - if (!$form->{"korrektur_$i"}) { - $form->{"tax_$i"} = $form->{"amount_$i"} * $form->{"taxrate_$i"}; - } else { - $tax = $form->{"tax_$i"}; - } - $form->{"tax_$i"} = - $form->round_amount($form->{"tax_$i"} * $form->{exchangerate}, 2); + $form->{"tax_$i"} = $form->{"amount_$i"} * $form->{"taxrate_$i"}; $form->{netamount} += $form->{"amount_$i"}; } $form->{total_tax} += $form->{"tax_$i"} * -1; @@ -270,7 +261,7 @@ sub post_transaction { # get paid account - ($form->{AP}{"paid_$i"}) = split(/--/, $form->{"AP_paid_$i"}); + ($form->{"AP_paid_account_$i"}) = split(/--/, $form->{"AP_paid_$i"}); $form->{"datepaid_$i"} = $form->{transdate} unless ($form->{"datepaid_$i"}); @@ -287,9 +278,9 @@ sub post_transaction { qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) | . qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | . qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; - @values = ($form->{id}, $form->{AP}{payables}, $amount, + @values = ($form->{id}, $form->{AP_payables}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, - $form->{AP}{payables}); + $form->{AP_payables}); do_query($form, $dbh, $query, @values); } $form->{payables} = $amount; @@ -299,9 +290,9 @@ sub post_transaction { qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) | . qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, | . qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; - @values = ($form->{id}, $form->{AP}{"paid_$i"}, $form->{"paid_$i"}, + @values = ($form->{id}, $form->{"AP_paid_account_$i"}, $form->{"paid_$i"}, conv_date($form->{"datepaid_$i"}), $form->{"source_$i"}, - $form->{"memo_$i"}, $project_id, $form->{AP}{"paid_$i"}); + $form->{"memo_$i"}, $project_id, $form->{"AP_paid_account_$i"}); do_query($form, $dbh, $query, @values); # add exchange rate difference @@ -313,9 +304,9 @@ sub post_transaction { qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | . qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|; - @values = ($form->{id}, $form->{AP}{"paid_$i"}, $amount, + @values = ($form->{id}, $form->{"AP_paid_account_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, - $form->{AP}{"paid_$i"}); + $form->{"AP_paid_account_$i"}); do_query($form, $dbh, $query, @values); } @@ -354,12 +345,13 @@ sub post_transaction { IO->set_datepaid(table => 'ap', id => $form->{id}, dbh => $dbh); - my $rc = 1; if (!$provided_dbh) { $dbh->commit(); $dbh->disconnect(); } + $rc = 1; # Den return-code auf true setzen, aber nur falls beim commit alles i.O. ist + $main::lxdebug->leave_sub(); return $rc; @@ -368,7 +360,7 @@ sub post_transaction { sub delete_transaction { $main::lxdebug->enter_sub(); - my ($self, $myconfig, $form, $spool) = @_; + my ($self, $myconfig, $form) = @_; # connect to database my $dbh = $form->dbconnect_noauto($myconfig); @@ -584,11 +576,9 @@ sub post_payment { $self->setup_form($form); - ($form->{defaultcurrency}) = selectrow_query($form, $dbh, qq|SELECT curr FROM defaults|); - $form->{defaultcurrency} = (split m/:/, $form->{defaultcurrency})[0]; - $form->{currency} = $form->{defaultcurrency} if ($form->{defaultcurrency} && ($form->{currency} =~ m/^\s*$/)); - - $form->{exchangerate} = $form->format_amount($myconfig, $form->{exchangerate}); + $form->{exchangerate} = $form->format_amount($myconfig, $form->{exchangerate}); + $form->{defaultcurrency} = $form->get_default_currency($myconfig); + delete $form->{currency} unless $form->{defaultcurrency}; # Get the AP accno. $query = @@ -779,7 +769,7 @@ sub storno { } for my $row (@$rowref) { - delete @$row{qw(itime mtime link)}; + delete @$row{qw(itime mtime link acc_trans_id)}; $query = sprintf 'INSERT INTO acc_trans (%s) VALUES (%s)', join(', ', keys %$row), join(', ', map '?', values %$row); $row->{trans_id} = $new_id; $row->{amount} *= -1;