From f45b296fb0bb9491d86d80e9f7a7d79c3e0295ba Mon Sep 17 00:00:00 2001 From: Bernd Blessmann Date: Tue, 13 Sep 2011 09:26:06 +0200 Subject: [PATCH] =?utf8?q?=C3=84nderbarkeit=20bei=20Zahlungen=20f.=20Verka?= =?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/IS.pm | 19 ++++++--- bin/mozilla/is.pl | 18 ++++++++- templates/webpages/is/_payments.html | 59 ++++++++++++++++++++++++---- 3 files changed, 82 insertions(+), 14 deletions(-) diff --git a/SL/IS.pm b/SL/IS.pm index 6c23f2d64..da801fd52 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -877,6 +877,12 @@ sub post_invoice { # record payments and offsetting AR if (!$form->{storno}) { 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); @@ -908,13 +914,14 @@ sub post_invoice { # record payment $form->{"paid_$i"} *= -1; + 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, source, memo, taxkey, project_id) - VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, + 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 difference @@ -1128,10 +1135,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+$|^AR_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+$|^AR_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/is.pl b/bin/mozilla/is.pl index c5d5f8986..737d46143 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -195,9 +195,11 @@ sub invoice_links { for my $i (1 .. scalar @{ $form->{acc_trans}{$key} }) { $form->{"AR_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} * -1; $form->{"datepaid_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{transdate}; + $form->{"gldate_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{gldate}; $form->{"exchangerate_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{exchangerate}; $form->{"forex_$i"} = $form->{"exchangerate_$i"}; $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{source}; @@ -427,6 +429,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->{"selectAR_paid_$i"} = $form->{selectAR_paid}; if (!$form->{"AR_paid_$i"}) { $form->{"selectAR_paid_$i"} =~ s/option>$accno_arap--(.*?)$accno_arap--$1assert('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); @@ -811,7 +823,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 }; $form->{storno_id} = $form->{id}; $form->{storno} = 1; @@ -934,6 +946,8 @@ sub credit_note { delete $form->{"source_$i"}; delete $form->{"memo_$i"}; delete $form->{"datepaid_$i"}; + delete $form->{"gldate_$i"}; + delete $form->{"acc_trans_id_$i"}; delete $form->{"AR_paid_$i"}; }; $form->{paidaccounts} = 1; diff --git a/templates/webpages/is/_payments.html b/templates/webpages/is/_payments.html index 04eb93af4..4ba3ebf62 100644 --- a/templates/webpages/is/_payments.html +++ b/templates/webpages/is/_payments.html @@ -24,21 +24,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 AR_paid = 'AR_paid_' _ i %] [% SET selectAR_paid_ref = 'selectAR_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 %] @@ -47,19 +78,33 @@ [% LxERP.format_amount($forex, 2) %] [% ELSE %] + [% IF $changeable %] + [% ELSE %] + + [% LxERP.format_amount($exchangerate, 2, 1) %] + [% END %] [% END %] [% END %] - + + + [% IF $changeable %] + + [% ELSE %] + [% $AR_paid %] + [% END %] + + [% IF $changeable %] + [% END %] [% END # foreach %] -- 2.20.1