+
+ $query = qq|SELECT c.id, c.accno, c.description, c.link
+ FROM chart c
+ WHERE c.link LIKE '%IC%'
+ ORDER BY c.accno|;
+ $sth = $dbh->prepare($query);
+ $sth->execute || $self->dberror($query);
+
+ while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+ foreach my $key (split(/:/, $ref->{link})) {
+ if ($key =~ /IC/) {
+ my $nkey = $key;
+ if ($key =~ /cogs/) {
+ $nkey = "IC_expense";
+ }
+ if ($key =~ /sale/) {
+ $nkey = "IC_income";
+ }
+ %{ $form->{IC}{$nkey}{ $ref->{accno} } } = (
+ id => $ref->{id},
+ description => $ref->{description}
+ );
+ }
+ }
+ }
+ $sth->finish;
+
+ $query = qq|SELECT c.id, c.accno, c.description
+ FROM chart c
+ WHERE c.category = 'I'
+ AND c.charttype = 'A'
+ ORDER BY c.accno|;
+ $sth = $dbh->prepare($query);
+ $sth->execute || $self->dberror($query);
+
+ while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+ %{ $form->{IC}{FX_gain}{ $ref->{accno} } } = (
+ id => $ref->{id},
+ description => $ref->{description}
+ );
+ }
+ $sth->finish;
+
+ $query = qq|SELECT c.id, c.accno, c.description
+ FROM chart c
+ WHERE c.category = 'E'
+ AND c.charttype = 'A'
+ ORDER BY c.accno|;
+ $sth = $dbh->prepare($query);
+ $sth->execute || $self->dberror($query);
+
+ while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+ %{ $form->{IC}{FX_loss}{ $ref->{accno} } } = (
+ id => $ref->{id},
+ description => $ref->{description}
+ );
+ }
+ $sth->finish;
+
+ # now get the tax rates and numbers
+ $query = qq|SELECT c.id, c.accno, c.description,
+ t.rate * 100 AS rate, t.taxnumber
+ FROM chart c, tax t
+ WHERE c.id = t.chart_id|;
+
+ $sth = $dbh->prepare($query);
+ $sth->execute || $form->dberror($query);
+
+ while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+ $form->{taxrates}{ $ref->{accno} }{id} = $ref->{id};
+ $form->{taxrates}{ $ref->{accno} }{description} = $ref->{description};
+ $form->{taxrates}{ $ref->{accno} }{taxnumber} = $ref->{taxnumber}
+ 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;