From: Bernd Blessmann Date: Tue, 6 Sep 2011 11:25:34 +0000 (+0200) Subject: Änderbarkeit der Zahlungen bei Debitorenbuchungen konfigurierbar X-Git-Tag: release-2.7.0beta1~311 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=4aa816112a8b9f2d2959c92cfaa2f2954bdeceb2;p=kivitendo-erp.git Änderbarkeit der Zahlungen bei Debitorenbuchungen konfigurierbar --- diff --git a/SL/AR.pm b/SL/AR.pm index ef42e69c6..7aa709df4 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -201,6 +201,11 @@ sub post_transaction { # add paid transactions for my $i (1 .. $form->{paidaccounts}) { + + if ($form->{"acc_trans_id_$i"} && $payments_only && ($::lx_office_conf{features}->{payments_changeable} == 0)) { + next; + } + if ($form->{"paid_$i"} != 0) { my $project_id = conv_i($form->{"paid_project_id_$i"}); @@ -229,12 +234,13 @@ sub post_transaction { } if ($form->{"paid_$i"} != 0) { - my $project_id = conv_i($form->{"paid_project_id_$i"}); # add payment + my $project_id = conv_i($form->{"paid_project_id_$i"}); + my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig)); $amount = $form->{"paid_$i"} * -1; - $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) - VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?))|; - @values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $form->{AR}{"paid_$i"}); + $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey) + VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?))|; + @values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $form->{AR}{"paid_$i"}); do_query($form, $dbh, $query, @values); # exchangerate difference for payment @@ -328,10 +334,12 @@ sub post_payment { $old_form = save_form(); # Delete all entries in acc_trans from prior payments. - $self->_delete_payments($form, $dbh); + if ($::lx_office_conf{features}->{payments_changeable} != 0) { + $self->_delete_payments($form, $dbh); + } # Save the new payments the user made before cleaning up $form. - my $payments_re = '^datepaid_\d+$|^memo_\d+$|^source_\d+$|^exchangerate_\d+$|^paid_\d+$|^paid_project_id_\d+$|^AR_paid_\d+$|^paidaccounts$'; + my $payments_re = '^datepaid_\d+$|^gldate_\d+$|^acc_trans_id_\d+$|^memo_\d+$|^source_\d+$|^exchangerate_\d+$|^paid_\d+$|^paid_project_id_\d+$|^AR_paid_\d+$|^paidaccounts$'; map { $payments{$_} = $form->{$_} } grep m/$payments_re/, keys %{ $form }; # Clean up $form so that old content won't tamper the results. @@ -573,9 +581,11 @@ sub setup_form { $j++; $form->{"AR_paid_$j"} = $form->{acc_trans}{$key}->[$i-1]->{accno}; + $form->{"acc_trans_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{acc_trans_id}; # reverse paid $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1; $form->{"datepaid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{transdate}; + $form->{"gldate_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{gldate}; $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source}; $form->{"memo_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{memo}; $form->{"forex_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{exchangerate}; diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 8ec365ada..2f2f55e56 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -734,14 +734,31 @@ $jsscript $form->format_amount(\%myconfig, $form->{"exchangerate_$i"}); } + print qq|{"acc_trans_id_$i"}>\n|; + print qq|{"gldate_$i"}>\n|; + my $changeable = 1; + if ($::lx_office_conf{features}->{payments_changeable} == 0) { + # never + $changeable = ($form->{"acc_trans_id_$i"})? 0 : 1; + } + if ($::lx_office_conf{features}->{payments_changeable} == 2) { + # on the same day + $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"}); + } + $exchangerate = qq| |; if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) { if ($form->{"forex_$i"}) { $exchangerate = qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|; } else { - $exchangerate = - qq|{"exchangerate_$i"}>|; + if ($changeable) { + $exchangerate = + qq|{"exchangerate_$i"}>|; + } else { + $exchangerate = + qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|; + } } } @@ -749,33 +766,78 @@ $jsscript {"forex_$i"}> |; - $column_data{paid} = - qq||; - $column_data{AR_paid} = - qq|${selectAR_paid}|; - $column_data{exchangerate} = qq|$exchangerate|; - $column_data{datepaid} = - qq| + my $datepaid; + if ($changeable) { + $datepaid = qq| |; - $column_data{source} = - qq||; - $column_data{memo} = - qq||; + } else { + $datepaid = qq|$form->{"datepaid_$i"}|. + qq|{"datepaid_$i"}>|; + } + + my $paid; + if ($changeable) { + $paid = qq||; + } else { + $paid = qq|$form->{"paid_$i"}|. + qq|{"paid_$i"}>|; + } + + my $source; + if ($changeable) { + $source = qq||; + } else { + $source = qq|$form->{"source_$i"}|. + qq|{"source_$i"}>|; + } + + my $memo; + if ($changeable) { + $memo = qq||; + } else { + $memo = qq|$form->{"memo_$i"}|. + qq|{"memo_$i"}>|; + } + + my $AR_paid; + if ($changeable) { + $AR_paid = qq|${selectAR_paid}|; + } else { + $AR_paid = qq|$form->{"AR_paid_$i"}|. + qq|{"AR_paid_$i"}>|; + } - $column_data{paid_project_id} = + my $paid_project_id; + if ($changeable) { + $paid_project_id = qq|| . NTI($cgi->popup_menu('-name' => "paid_project_id_$i", '-values' => \@project_values, '-labels' => \%project_labels, '-default' => $form->{"paid_project_id_$i"} )) . qq||; + } else { + my $projectnumber = $project_labels{$form->{"paid_project_id_$i"}}; + $paid_project_id = qq|$projectnumber|. + qq|{"paid_project_id_$i"}>|; + } + + $column_data{paid} = $paid; + $column_data{AR_paid} = $AR_paid; + $column_data{exchangerate} = qq|$exchangerate|; + $column_data{datepaid} = $datepaid; + $column_data{source} = $source; + $column_data{memo} = $memo; + $column_data{paid_project_id} = $paid_project_id; map { print qq|$column_data{$_}\n| } @column_index; print " "; - push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); + if ($changeable) { + push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); + } } my $paid_missing = $form->{invtotal_unformatted} - $form->{totalpaid}; @@ -1185,7 +1247,7 @@ sub use_as_template { my $form = $main::form; my %myconfig = %main::myconfig; - map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno); + map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno); $form->{paidaccounts} = 1; $form->{rowcount}--; $form->{invdate} = $form->current_date(\%myconfig);