From 0e0ff15052f7cb7ed1a2b04235a8a217da97a183 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Sat, 18 Dec 2010 14:13:07 +0100 Subject: [PATCH] =?utf8?q?Standard-Auswahl=20f=C3=BCr=20Umlaufverm=C3=B6ge?= =?utf8?q?nskonto=20(Bank)=20mandantenweit=20setzen.=20Ferner=20yearend=20?= =?utf8?q?aus=20AM.pm=20entfernt=20und=20schliessende=20=20f?= =?utf8?q?=C3=BCr=20selectAP=5Fpaid=20Array=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/AM.pm | 27 ++++++++++++++++++++---- SL/IS.pm | 17 +++++++++++++++ bin/mozilla/cp.pl | 18 ++++++++++------ bin/mozilla/ir.pl | 12 +++++++++-- sql/Pg-upgrade2/add_ar_paid_defaults.sql | 5 +++++ templates/webpages/am/edit_defaults.html | 10 +++++++++ 6 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 sql/Pg-upgrade2/add_ar_paid_defaults.sql diff --git a/SL/AM.pm b/SL/AM.pm index 12a4ad7d3..df7d9d2c0 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -1358,7 +1358,7 @@ sub save_defaults { my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); my %accnos; - map { ($accnos{$_}) = split(m/--/, $form->{$_}) } qw(inventory_accno income_accno expense_accno fxgain_accno fxloss_accno); + map { ($accnos{$_}) = split(m/--/, $form->{$_}) } qw(inventory_accno income_accno expense_accno fxgain_accno fxloss_accno ar_paid_accno); $form->{curr} =~ s/ //g; my @currencies = grep { $_ ne '' } split m/:/, $form->{curr}; @@ -1373,6 +1373,7 @@ sub save_defaults { expense_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), fxgain_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), fxloss_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), + ar_paid_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), invnumber = ?, cnnumber = ?, sonumber = ?, @@ -1385,19 +1386,18 @@ sub save_defaults { servicenumber = ?, sdonumber = ?, pdonumber = ?, - yearend = ?, curr = ?, businessnumber = ?, weightunit = ?|; my @values = ($accnos{inventory_accno}, $accnos{income_accno}, $accnos{expense_accno}, - $accnos{fxgain_accno}, $accnos{fxloss_accno}, + $accnos{fxgain_accno}, $accnos{fxloss_accno}, $accnos{ar_paid_accno}, $form->{invnumber}, $form->{cnnumber}, $form->{sonumber}, $form->{ponumber}, $form->{sqnumber}, $form->{rfqnumber}, $form->{customernumber}, $form->{vendornumber}, $form->{articlenumber}, $form->{servicenumber}, $form->{sdonumber}, $form->{pdonumber}, - $form->{yearend}, $currency, + $currency, $form->{businessnumber}, $form->{weightunit}); do_query($form, $dbh, $query, @values); @@ -1492,6 +1492,7 @@ sub defaultaccounts { $form->{defaults}{IC_expense} = $form->{defaults}{expense_accno_id}; $form->{defaults}{FX_gain} = $form->{defaults}{fxgain_accno_id}; $form->{defaults}{FX_loss} = $form->{defaults}{fxloss_accno_id}; + $form->{defaults}{AR_paid} = $form->{defaults}{ar_paid_accno_id}; $form->{defaults}{weightunit} ||= 'kg'; @@ -1571,6 +1572,24 @@ sub defaultaccounts { if $ref->{taxnumber}; $form->{taxrates}{ $ref->{accno} }{rate} = $ref->{rate} if $ref->{rate}; } + # Abfrage für Standard Umlaufvermögenskonto + $query = + qq|SELECT id, accno, description, link | . + qq|FROM chart | . + qq|WHERE link LIKE ? |. + qq|ORDER BY accno|; + $sth = prepare_execute_query($form, $dbh, $query, '%AR%'); + $sth->execute || $form->dberror($query);# + while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { + foreach my $item (split(/:/, $ref->{link})) { + if ($item eq "AR_paid") { + %{ $form->{IC}{AR_paid}{ $ref->{accno} } } = ( + id => $ref->{id}, + description => $ref->{description} + ); + } + } + } $sth->finish; $dbh->disconnect; diff --git a/SL/IS.pm b/SL/IS.pm index 8e7dcc9f1..590923361 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -2159,4 +2159,21 @@ sub is_storno { return $result; } +sub get_standard_accno_current_assets { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $form) = @_; + + my $dbh = $form->dbconnect($myconfig); + + my $query = qq| SELECT accno FROM chart WHERE id = (SELECT ar_paid_accno_id FROM defaults)|; + my ($result) = selectrow_query($form, $dbh, $query); + + $dbh->disconnect(); + + $main::lxdebug->leave_sub(); + + return $result; +} + 1; diff --git a/bin/mozilla/cp.pl b/bin/mozilla/cp.pl index b3efdec57..721a4a8cf 100644 --- a/bin/mozilla/cp.pl +++ b/bin/mozilla/cp.pl @@ -78,15 +78,21 @@ sub payment { CP->paymentaccounts(\%myconfig, \%$form); + # Standard Konto für Umlaufvermögen + my $accno_arap = IS->get_standard_accno_current_assets(\%myconfig, \%$form); + $form->{selectaccount} = ""; $form->{"select$form->{ARAP}"} = ""; - map { $form->{selectaccount} .= ""; } next unless $form->{acc_trans}{$key}; @@ -393,9 +393,17 @@ sub form_footer { $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); $form->{paid_indices} = [ 1 .. $form->{paidaccounts} ]; + # Standard Konto für Umlaufvermögen + my $accno_arap = IS->get_standard_accno_current_assets(\%myconfig, \%$form); + for my $i (1 .. $form->{paidaccounts}) { $form->{"selectAP_paid_$i"} = $form->{selectAP_paid}; - $form->{"selectAP_paid_$i"} =~ s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/; + if (!$form->{"AP_paid_$i"}) { + $form->{"selectAP_paid_$i"} =~ s/option>$accno_arap--(.*?)>/option selected>$accno_arap--$1>/; + } else { + $form->{"selectAP_paid_$i"} =~ s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/; + } + $totalpaid += $form->{"paid_$i"}; } diff --git a/sql/Pg-upgrade2/add_ar_paid_defaults.sql b/sql/Pg-upgrade2/add_ar_paid_defaults.sql new file mode 100644 index 000000000..43b257e6a --- /dev/null +++ b/sql/Pg-upgrade2/add_ar_paid_defaults.sql @@ -0,0 +1,5 @@ +-- @tag: add_ar_paid_defaults +-- @description: Standardkonto für ar_paid (Umlaufvermögenskonto == Bank) in der Tabelle defaults hinzugefügt +-- @depends: release_2_6_1 +-- @charset: utf-8 +ALTER TABLE defaults ADD COLUMN ar_paid_accno_id integer; diff --git a/templates/webpages/am/edit_defaults.html b/templates/webpages/am/edit_defaults.html index 315673b03..d346b893f 100644 --- a/templates/webpages/am/edit_defaults.html +++ b/templates/webpages/am/edit_defaults.html @@ -116,6 +116,16 @@ + + [% 'Current assets account' | $T8 %] + + + + [% 'Miscellaneous' | $T8 %] -- 2.20.1