X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAP.pm;h=95b0d5208fa5d5d5bf2b70a3b5c3656c219672c2;hb=daaac66a83e3dbdcc910731a1695e7e59b9cbbc6;hp=e3dc7b31d9506d2f8d04a5e047b6851547d92487;hpb=88dea78ecdb77761f71c5016ca97e53b2d55d9d3;p=kivitendo-erp.git diff --git a/SL/AP.pm b/SL/AP.pm index e3dc7b31d..95b0d5208 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -319,6 +319,15 @@ sub post_transaction { $form->{"exchangerate_$i"}), 2); if ($amount != 0) { + # fetch fxgain and fxloss chart info from defaults if charts aren't already filled in form + if ( !$form->{fxgain_accno} && $::instance_conf->get_fxgain_accno_id ) { + $form->{fxgain_accno} = SL::DB::Manager::Chart->find_by(id => $::instance_conf->get_fxgain_accno_id)->accno; + }; + if ( !$form->{fxloss_accno} && $::instance_conf->get_fxloss_accno_id ) { + $form->{fxloss_accno} = SL::DB::Manager::Chart->find_by(id => $::instance_conf->get_fxloss_accno_id)->accno; + }; + die "fxloss_accno missing" if $amount < 0 and not $form->{fxloss_accno}; + die "fxgain_accno missing" if $amount > 0 and not $form->{fxgain_accno}; $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id, chart_link) | . qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . @@ -454,11 +463,11 @@ sub ap_transactions { push(@values, $form->{vendor_id}); } elsif ($form->{vendor}) { $where .= " AND v.name ILIKE ?"; - push(@values, $form->like($form->{vendor})); + push(@values, like($form->{vendor})); } if ($form->{"cp_name"}) { $where .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)"; - push(@values, ('%' . trim($form->{"cp_name"}) . '%')x2); + push(@values, (like($form->{"cp_name"}))x2); } if ($form->{department}) { # ähnlich wie commit 0bbfb33b6aa8e38bb6c81d1684ab7d08e5b5c5af abteilung @@ -470,19 +479,19 @@ sub ap_transactions { } if ($form->{invnumber}) { $where .= " AND a.invnumber ILIKE ?"; - push(@values, $form->like($form->{invnumber})); + push(@values, like($form->{invnumber})); } if ($form->{ordnumber}) { $where .= " AND a.ordnumber ILIKE ?"; - push(@values, $form->like($form->{ordnumber})); + push(@values, like($form->{ordnumber})); } if ($form->{notes}) { $where .= " AND lower(a.notes) LIKE ?"; - push(@values, $form->like($form->{notes})); + push(@values, like($form->{notes})); } if ($form->{project_id}) { $where .= - qq|AND ((a.globalproject_id = ?) OR EXISTS | . + qq| AND ((a.globalproject_id = ?) OR EXISTS | . qq| (SELECT * FROM invoice i | . qq| WHERE i.project_id = ? AND i.trans_id = a.id) | . qq| OR EXISTS | . @@ -507,6 +516,33 @@ sub ap_transactions { } } + if ($form->{parts_partnumber}) { + $where .= <{parts_partnumber}); + } + + if ($form->{parts_description}) { + $where .= <{parts_description}); + } + if ($where) { substr($where, 0, 4, " WHERE "); $query .= $where; @@ -719,7 +755,7 @@ sub setup_form { } $index = $form->{acc_trans}{$key}->[$i - 1]->{index}; - $form->{"tax_$index"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1; + $form->{"tax_$index"} = $form->round_amount($form->{acc_trans}{$key}->[$i - 1]->{amount} * -1 / $exchangerate, 2); $totaltax += $form->{"tax_$index"}; } else {