X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAR.pm;h=e01ddcb06ee27c82e8b015b227a6e535541127c9;hb=44fb4fe8d98ced50689764dab64b4633016c9fe0;hp=2841743965fc432c39f08ec9a3b558ca9fa775ca;hpb=cff1389b37e5adfde7734718a02290421aa1bf9a;p=kivitendo-erp.git diff --git a/SL/AR.pm b/SL/AR.pm index 284174396..e01ddcb06 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -41,6 +41,7 @@ use SL::IO; use SL::MoreCommon; use SL::DB::Default; use SL::TransNumber; +use SL::Util qw(trim); use strict; @@ -183,6 +184,8 @@ sub post_transaction { do_query($form, $dbh, $query, $form->{paid}, $form->{paid} ? conv_date($form->{datepaid}) : undef, conv_i($form->{id})); } + $form->new_lastmtime('ar'); + # add paid transactions for my $i (1 .. $form->{paidaccounts}) { @@ -470,6 +473,7 @@ sub ar_transactions { qq| dc.dunning_description, | . qq| tz.description AS taxzone, | . qq| pt.description AS payment_terms, | . + qq| d.description AS department, | . qq{ ( SELECT ch.accno || ' -- ' || ch.description FROM acc_trans at LEFT JOIN chart ch ON ch.id = at.chart_id @@ -497,18 +501,18 @@ sub ar_transactions { if ($form->{customernumber}) { $where .= " AND c.customernumber = ?"; - push(@values, $form->{customernumber}); + push(@values, trim($form->{customernumber})); } if ($form->{customer_id}) { $where .= " AND a.customer_id = ?"; push(@values, $form->{customer_id}); } elsif ($form->{customer}) { $where .= " AND c.name ILIKE ?"; - push(@values, $form->like($form->{customer})); + push(@values, like($form->{customer})); } if ($form->{"cp_name"}) { $where .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)"; - push(@values, ('%' . $form->{"cp_name"} . '%')x2); + push(@values, (like($form->{"cp_name"}))x2); } if ($form->{business_id}) { my $business_id = $form->{business_id}; @@ -521,14 +525,14 @@ sub ar_transactions { push(@values, $department_id); } if ($form->{department}) { - my $department = "%" . $form->{department} . "%"; + my $department = like($form->{department}); $where .= " AND d.description ILIKE ?"; push(@values, $department); } foreach my $column (qw(invnumber ordnumber cusordnumber notes transaction_description)) { if ($form->{$column}) { $where .= " AND a.$column ILIKE ?"; - push(@values, $form->like($form->{$column})); + push(@values, like($form->{$column})); } } if ($form->{"project_id"}) { @@ -545,19 +549,19 @@ sub ar_transactions { if ($form->{transdatefrom}) { $where .= " AND a.transdate >= ?"; - push(@values, $form->{transdatefrom}); + push(@values, trim($form->{transdatefrom})); } if ($form->{transdateto}) { $where .= " AND a.transdate <= ?"; - push(@values, $form->{transdateto}); + push(@values, trim($form->{transdateto})); } if ($form->{duedatefrom}) { $where .= " AND a.duedate >= ?"; - push(@values, $form->{duedatefrom}); + push(@values, trim($form->{duedatefrom})); } if ($form->{duedateto}) { $where .= " AND a.duedate <= ?"; - push(@values, $form->{duedateto}); + push(@values, trim($form->{duedateto})); } if ($form->{open} || $form->{closed}) { unless ($form->{open} && $form->{closed}) { @@ -581,6 +585,33 @@ sub ar_transactions { } }; + if ($form->{parts_partnumber}) { + $where .= <{parts_partnumber}); + } + + if ($form->{parts_description}) { + $where .= <{parts_description}); + } + my ($cvar_where, @cvar_values) = CVar->build_filter_query('module' => 'CT', 'trans_id_field' => 'c.id', 'filter' => $form, @@ -770,6 +801,8 @@ sub storno { $query = qq|UPDATE ar SET paid = amount + paid, storno = 't' WHERE id = ?|; do_query($form, $dbh, $query, $id); + $form->new_lastmtime('ar') if $id == $form->{id}; + # now copy acc_trans entries $query = qq|SELECT a.*, c.link FROM acc_trans a LEFT JOIN chart c ON a.chart_id = c.id WHERE a.trans_id = ? ORDER BY a.acc_trans_id|; my $rowref = selectall_hashref_query($form, $dbh, $query, $id);