X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=sql%2FPg-upgrade2%2Fsteuerfilterung.pl;h=b7be34167028578d4447cc4d650f2910a44f3cb7;hb=a27846ef2756ed0f59c29d256a5d43d6caaf0b58;hp=36bc5f2dcb7066796fcb23bed68c565ab1de2acd;hpb=835ff8df3b01d99e3f5f2f821efad682d8dbf16a;p=kivitendo-erp.git diff --git a/sql/Pg-upgrade2/steuerfilterung.pl b/sql/Pg-upgrade2/steuerfilterung.pl index 36bc5f2dc..b7be34167 100644 --- a/sql/Pg-upgrade2/steuerfilterung.pl +++ b/sql/Pg-upgrade2/steuerfilterung.pl @@ -19,7 +19,6 @@ sub run { $self->db_query($query); if ( $::form->{continued_tax} ) { - my $update_query; foreach my $i (1 .. $::form->{rowcount}) { $tax_id = $::form->{"tax_id_$i"}; $categories = ''; @@ -29,15 +28,15 @@ sub run { $categories .= 'C' if $::form->{"costs_$i"}; $categories .= 'I' if $::form->{"revenue_$i"}; $categories .= 'E' if $::form->{"expense_$i"}; - $update_query = qq|UPDATE tax SET chart_categories = '$categories' WHERE id=$tax_id;|; - $self->db_query($update_query); + $self->db_query(qq|UPDATE tax SET chart_categories = ? WHERE id = ?|, bind => [ $categories, $tax_id ]); } - $update_query = qq|ALTER TABLE tax ALTER COLUMN chart_categories SET NOT NULL|; - $self->db_query($update_query); + $self->db_query(qq|UPDATE tax SET chart_categories = 'ALQCIE' WHERE chart_categories IS NULL|); + $self->db_query(qq|ALTER TABLE tax ALTER COLUMN chart_categories SET NOT NULL|); return 1; } my @well_known_taxes = ( + # German SKR03 { taxkey => 0, rate => 0, taxdescription => qr{keine.*steuer}i, categories => 'ALQCIE' }, { taxkey => 1, rate => 0, taxdescription => qr{frei}i, categories => 'ALQCIE' }, { taxkey => 2, rate => 0.07, taxdescription => qr{umsatzsteuer}i, categories => 'I' }, @@ -58,7 +57,15 @@ sub run { { taxkey => 18, rate => 0.07, taxdescription => qr{innergem.*erwerb.*erm}i, categories => 'E' }, { taxkey => 19, rate => 0.16, taxdescription => qr{innergem.*erwerb.*voll}i, categories => 'E' }, { taxkey => 19, rate => 0.19, taxdescription => qr{innergem.*erwerb.*voll}i, categories => 'E' }, - ); + + # Swiss + { taxkey => 2, rate => 0.08, taxdescription => qr{mwst}i, categories => 'I' }, + { taxkey => 3, rate => 0.025, taxdescription => qr{mwst}i, categories => 'I' }, + { taxkey => 4, rate => 0.08, taxdescription => qr{mwst}i, categories => 'E' }, + { taxkey => 5, rate => 0.025, taxdescription => qr{mwst}i, categories => 'E' }, + { taxkey => 6, rate => 0.08, taxdescription => qr{mwst}i, categories => 'E' }, + { taxkey => 7, rate => 0.025, taxdescription => qr{mwst}i, categories => 'E' }, + ); $query = qq|SELECT taxkey, taxdescription, rate, id AS tax_id FROM tax order by taxkey, rate;|; @@ -75,10 +82,7 @@ sub run { && ($ref->{taxdescription} =~ $_->{taxdescription}) } @well_known_taxes; if ($well_known_tax) { - $categories = $well_known_tax->{categories}; - $tax_id = $ref->{tax_id}; - $query = qq|UPDATE tax SET chart_categories = '$categories' WHERE id=$tax_id;|; - $self->db_query($query); + $self->db_query(qq|UPDATE tax SET chart_categories = ? WHERE id = ?|, bind => [ $well_known_tax->{categories}, $ref->{tax_id} ]); } else { $ref->{rate} = $::form->format_amount(\%::myconfig, $ref->{rate} * 100); push @{ $::form->{PARTS} }, $ref;