From 890e057f52343ca24bbc74becb2bd715ac2ba3da Mon Sep 17 00:00:00 2001 From: Bernd Blessmann Date: Wed, 31 Aug 2011 15:28:51 +0200 Subject: [PATCH] =?utf8?q?=C3=84nderbarkeit=20bei=20Zahlungen=20f.=20Kredi?= =?utf8?q?torenbuchungen=20konfigurierbar=20machen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Nie, immer oder am selben Tag, einstellbar in der lx_office.conf --- SL/AP.pm | 12 ++++++++++-- SL/Form.pm | 3 ++- bin/mozilla/ap.pl | 15 +++++++++++---- config/lx_office.conf.default | 3 +++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/SL/AP.pm b/SL/AP.pm index 7b0bc12b7..2f52c6253 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -249,6 +249,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"}); @@ -566,10 +571,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+$|^gldate_\d+$|^memo_\d+$|^source_\d+$|^exchangerate_\d+$|^paid_\d+$|^paid_project_id_\d+$|^AP_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+$|^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. @@ -648,6 +655,7 @@ sub setup_form { if ($key eq "AP_paid") { $j++; $form->{"AP_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; + $form->{"acc_trans_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{acc_trans_id}; $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}; diff --git a/SL/Form.pm b/SL/Form.pm index e841771b6..409bcd63b 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -842,6 +842,7 @@ sub _prepare_html_template { $additional_params->{"conf_parts_image_css"} = $::lx_office_conf{features}->{parts_image_css}; $additional_params->{"conf_parts_listing_images"} = $::lx_office_conf{features}->{parts_listing_images}; $additional_params->{"conf_parts_show_image"} = $::lx_office_conf{features}->{parts_show_image}; + $additional_params->{"conf_payments_changeable"} = $::lx_office_conf{features}->{payments_changeable}; $additional_params->{"INSTANCE_CONF"} = $::instance_conf; if (%main::debug_options) { @@ -2991,7 +2992,7 @@ sub create_links { $query = qq|SELECT c.accno, c.description, - a.source, a.amount, a.memo, a.transdate, a.gldate, a.cleared, a.project_id, a.taxkey, + a.acc_trans_id, 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 bc2986c27..c97460877 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -693,10 +693,17 @@ $jsscript $form->format_amount(\%myconfig, $form->{"exchangerate_$i"}); } + print qq|{"acc_trans_id_$i"}>\n|; 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|; + 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})) { @@ -1183,7 +1190,7 @@ sub use_as_template { $main::auth->assert('general_ledger'); - 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); + 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); diff --git a/config/lx_office.conf.default b/config/lx_office.conf.default index 9df72a427..b0c3e66e5 100644 --- a/config/lx_office.conf.default +++ b/config/lx_office.conf.default @@ -86,6 +86,9 @@ parts_image_css = border:0;float:left;max-width:250px;margin-top:20px:margin-rig # Show the picture in the results when you search for parts parts_listing_images = 0 +# Should payments be changeable after posting (0 = never; 1 = every time; 2 = on the same day) +payments_changeable = 1 + [paths] # path to temporary files (must be writeable by the web server) userspath = users -- 2.20.1