From 79b83b02cf67cf4b701eb1654fa274095d84745a Mon Sep 17 00:00:00 2001 From: Bernd Blessmann Date: Thu, 25 Aug 2011 10:17:44 +0200 Subject: [PATCH] =?utf8?q?Zahlungen=20bei=20Kreditorenbuchungen=20nur=20am?= =?utf8?q?=20selben=20Tag=20l=C3=B6schbar=20machen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Siehe auch Bug 1640. Ändert zwar nichts am Bug, steht da aber als Anregung drin. --- SL/AP.pm | 10 +++--- SL/Form.pm | 2 +- bin/mozilla/ap.pl | 88 ++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 79 insertions(+), 21 deletions(-) diff --git a/SL/AP.pm b/SL/AP.pm index d90a53f5c..79a93fe3a 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -288,12 +288,13 @@ sub post_transaction { $form->{payables} = $amount; # add payment + my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->{"gldate"}); $query = - 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|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, 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_account_$i"}, $form->{"paid_$i"}, - conv_date($form->{"datepaid_$i"}), $form->{"source_$i"}, + conv_date($form->{"datepaid_$i"}), $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $form->{"AP_paid_account_$i"}); do_query($form, $dbh, $query, @values); @@ -568,7 +569,7 @@ sub post_payment { $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+$|^AP_paid_\d+$|^paidaccounts$'; + my $payments_re = '^datepaid_\d+$|^gldate_\d+$|^memo_\d+$|^source_\d+$|^exchangerate_\d+$|^paid_\d+$|^paid_project_id_\d+$|^AP_paid_\d+$|^paidaccounts$'; map { $payments{$_} = $form->{$_} } grep m/$payments_re/, keys %{ $form }; # Clean up $form so that old content won't tamper the results. @@ -649,6 +650,7 @@ sub setup_form { $form->{"AP_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount}; $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}; diff --git a/SL/Form.pm b/SL/Form.pm index 418d3cf62..14e3ed20f 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -2986,7 +2986,7 @@ sub create_links { $query = qq|SELECT c.accno, c.description, - a.source, a.amount, a.memo, a.transdate, a.cleared, a.project_id, a.taxkey, + a.source, a.amount, a.memo, a.transdate, a.gldate, a.cleared, a.project_id, a.taxkey, p.projectnumber, t.rate, t.id FROM acc_trans a diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index f19363d4c..d90b06209 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -692,14 +692,24 @@ $jsscript $form->{"exchangerate_$i"} = ""; } + print qq|{"gldate_$i"}>\n|; + my $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"}); + $form->{"payment_readonly_$i"} = ($changeable)? 0 : 1; + print qq|{"payment_readonly_$i"}>\n|; + $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|$form->{"exchangerate_$i"}|. + qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|; + } } } @@ -707,32 +717,78 @@ $jsscript {"forex_$i"}> |; - $column_data{"paid_$i"} = - qq||; - $column_data{"AP_paid_$i"} = - qq|${selectAP_paid}|; - $column_data{"exchangerate_$i"} = qq|$exchangerate|; - $column_data{"datepaid_$i"} = - qq| + my $datepaid; + if ($changeable) { + $datepaid = qq| |; - $column_data{"source_$i"} = - qq||; - $column_data{"memo_$i"} = - qq||; - $column_data{"paid_project_id_$i"} = + } 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 $AP_paid; + if ($changeable) { + $AP_paid = qq|${selectAP_paid}|; + } else { + $AP_paid = qq|$form->{"AP_paid_$i"}|. + qq|{"AP_paid_$i"}>|; + } + + 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_$i"} = $paid; + $column_data{"AP_paid_$i"} = $AP_paid; + $column_data{"exchangerate_$i"} = qq|$exchangerate|; + $column_data{"datepaid_$i"} = $datepaid; + $column_data{"source_$i"} = $source; + $column_data{"memo_$i"} = $memo; + $column_data{"paid_project_id_$i"} = $paid_project_id; map { print qq|$column_data{"${_}_$i"}\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}; @@ -1126,7 +1182,7 @@ sub use_as_template { $main::auth->assert('general_ledger'); - 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 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno); $form->{paidaccounts} = 1; $form->{rowcount}--; $form->{invdate} = $form->current_date(\%myconfig); -- 2.20.1