From b56c0cd76508a8d39e080f316285db1c52c17255 Mon Sep 17 00:00:00 2001 From: Bernd Blessmann Date: Wed, 14 Sep 2011 12:34:22 +0200 Subject: [PATCH] =?utf8?q?=C3=84nderbarkeit=20bei=20Zahlungen=20f.=20Einka?= =?utf8?q?ufsrechnungen=20konfigurierbar.?= 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/IR.pm | 21 ++++++++--- bin/mozilla/ir.pl | 16 +++++++-- templates/webpages/ir/_payments.html | 53 +++++++++++++++++++++++++--- 3 files changed, 79 insertions(+), 11 deletions(-) diff --git a/SL/IR.pm b/SL/IR.pm index 909a3b07d..8536aad4f 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -499,6 +499,12 @@ sub post_invoice { # record payments and offsetting AP for my $i (1 .. $form->{paidaccounts}) { + if ($form->{"acc_trans_id_$i"} + && $payments_only + && ($::lx_office_conf{features}->{payments_changeable} == 0)) { + next; + } + next if $form->{"paid_$i"} == 0; my ($accno) = split /--/, $form->{"AP_paid_$i"}; @@ -518,11 +524,14 @@ sub post_invoice { } # record payment - $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, taxkey, project_id) - VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, + my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig)); + + $query = + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, project_id) + VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; @values = (conv_i($form->{id}), $accno, $form->{"paid_$i"}, $form->{"datepaid_$i"}, - $form->{"source_$i"}, $form->{"memo_$i"}, $accno, $project_id); + $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, $project_id); do_query($form, $dbh, $query, @values); $exchangerate = 0; @@ -1394,10 +1403,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. - map { $payments{$_} = $form->{$_} } grep m/^datepaid_\d+$|^memo_\d+$|^source_\d+$|^exchangerate_\d+$|^paid_\d+$|^AP_paid_\d+$|^paidaccounts$/, keys %{ $form }; + map { $payments{$_} = $form->{$_} } grep m/^datepaid_\d+$|^gldate_\d+$|^acc_trans_id_\d+$|^memo_\d+$|^source_\d+$|^exchangerate_\d+$|^paid_\d+$|^AP_paid_\d+$|^paidaccounts$/, keys %{ $form }; # Clean up $form so that old content won't tamper the results. %keep_vars = map { $_, 1 } qw(login password id); diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index fab18f722..6b09b5b3c 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -181,10 +181,12 @@ sub invoice_links { $form->{"AP_paid_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; + $form->{"acc_trans_id_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{acc_trans_id}; # reverse paid $form->{"paid_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{amount}; $form->{"datepaid_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{transdate}; + $form->{"gldate_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{gldate}; $form->{"forex_$i"} = $form->{"exchangerate_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{exchangerate}; $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{source}; @@ -403,6 +405,16 @@ sub form_footer { my $accno_arap = IS->get_standard_accno_current_assets(\%myconfig, \%$form); for my $i (1 .. $form->{paidaccounts}) { + $form->{"changeable_$i"} = 1; + if ($::lx_office_conf{features}->{payments_changeable} == 0) { + # never + $form->{"changeable_$i"} = ($form->{"acc_trans_id_$i"})? 0 : 1; + } elsif ($::lx_office_conf{features}->{payments_changeable} == 2) { + # on the same day + $form->{"changeable_$i"} = (($form->{"gldate_$i"} eq '') || + ($form->current_date(\%myconfig) eq $form->{"gldate_$i"})); + } + $form->{"selectAP_paid_$i"} = $form->{selectAP_paid}; if (!$form->{"AP_paid_$i"}) { $form->{"selectAP_paid_$i"} =~ s/option>$accno_arap--(.*?)>/option selected>$accno_arap--$1>/; @@ -560,7 +572,7 @@ sub storno { # Payments must not be recorded for the new storno invoice. $form->{paidaccounts} = 0; - map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form }; + map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ gldate_ acc_trans_id_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form }; # saving the history if(!exists $form->{addition} && $form->{id} ne "") { @@ -589,7 +601,7 @@ sub use_as_template { $main::auth->assert('vendor_invoice_edit'); - 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); diff --git a/templates/webpages/ir/_payments.html b/templates/webpages/ir/_payments.html index c3c7ca2d3..277d4db49 100644 --- a/templates/webpages/ir/_payments.html +++ b/templates/webpages/ir/_payments.html @@ -25,21 +25,52 @@ [% FOREACH i = paid_indices %] + [% SET changeable = 'changeable_' _ i %] + [% SET acc_trans_id = 'acc_trans_id_' _ i %] + [% SET gldate = 'gldate_' _ i %] [% SET datepaid = 'datepaid_' _ i %] [% SET source = 'source_' _ i %] [% SET memo = 'memo_' _ i %] [% SET paid = 'paid_' _ i %] + [% SET AP_paid = 'AP_paid_' _ i %] [% SET selectAP_paid_ref = 'selectAP_paid_' _ i %] + + + + [% IF $changeable %] + [% ELSE %] + [% $datepaid %] + [% END %] + + + [% IF $changeable %] + + [% ELSE %] + [% $source %] + [% END %] + + + [% IF $changeable %] + + [% ELSE %] + [% $memo %] + [% END %] + + + [% IF $changeable %] + + [% ELSE %] + + [% LxERP.format_amount($paid, 2, 1) %] + [% END %] - - - + [% IF show_exchangerate %] [% SET forex = 'forex_' _ i %] @@ -48,19 +79,33 @@ [% LxERP.format_amount(exchangerate, 2) %] [% ELSE %] + [% IF $changeable %] + [% ELSE %] + + [% LxERP.format_amount($exchangerate, 2, 1) %] + [% END %] [% END %] ; [% END %] - + + + [% IF $changeable %] + + [% ELSE %] + [% $AP_paid %] + [% END %] + + [% IF $changeable %] + [% END %] [% END # foreach %] -- 2.20.1