From 5cdcf572cfe983e66b14aefde3533614edefbb7e Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Wed, 6 Aug 2014 12:32:23 +0200 Subject: [PATCH] =?utf8?q?convert=5Ftaxzone=20-=20Fall=20keine=20Buchungsg?= =?utf8?q?ruppen=20ber=C3=BCcksichtigen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Für den Fall, daß in dem Mandanten gar keine Buchungsgruppen konfiguriert sind (z.B. bei einem frischen Schweizer Kontenrahmen), wird die Umwandlung der Buchungsgruppen übersprungen. --- sql/Pg-upgrade2/convert_taxzone.pl | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/sql/Pg-upgrade2/convert_taxzone.pl b/sql/Pg-upgrade2/convert_taxzone.pl index 413d772de..b1e1a0bb6 100644 --- a/sql/Pg-upgrade2/convert_taxzone.pl +++ b/sql/Pg-upgrade2/convert_taxzone.pl @@ -39,17 +39,21 @@ SQL } $sth->finish; - my $taxzone_charts_update_query; - foreach my $taxzone ( @{$::form->{taxzones}} ) { - foreach my $buchungsgruppe ( @{$::form->{buchungsgruppen}} ) { - my $id = $taxzone->{id}; - my $income_accno_id = $buchungsgruppe->{"income_accno_id_$id"}; - my $expense_accno_id = $buchungsgruppe->{"expense_accno_id_$id"}; - # TODO: check if the variables have a value - $taxzone_charts_update_query .= "INSERT INTO taxzone_charts (taxzone_id, buchungsgruppen_id, income_accno_id, expense_accno_id) VALUES ('$taxzone->{id}', '$buchungsgruppe->{id}', $income_accno_id, $expense_accno_id);\n"; + # convert Buchungsgruppen to taxzone_charts if any exist + # the default swiss COA doesn't have any, for example + if ( scalar @{ $::form->{buchungsgruppen} } > 0 ) { + my $taxzone_charts_update_query; + foreach my $taxzone ( @{$::form->{taxzones}} ) { + foreach my $buchungsgruppe ( @{$::form->{buchungsgruppen}} ) { + my $id = $taxzone->{id}; + my $income_accno_id = $buchungsgruppe->{"income_accno_id_$id"}; + my $expense_accno_id = $buchungsgruppe->{"expense_accno_id_$id"}; + # TODO: check if the variables have a value + $taxzone_charts_update_query .= "INSERT INTO taxzone_charts (taxzone_id, buchungsgruppen_id, income_accno_id, expense_accno_id) VALUES ('$taxzone->{id}', '$buchungsgruppe->{id}', $income_accno_id, $expense_accno_id);\n"; + }; }; + $self->db_query($taxzone_charts_update_query) if $taxzone_charts_update_query; }; - $self->db_query($taxzone_charts_update_query); my $clean_buchungsgruppen_query = <