X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/bb84bc55a14e2124d1dfd899d8e7afaad152a35d..f4da9593b8f91ae5d57437ed124f9c9d859bc698:/sql/Pg-upgrade2/tax_reverse_charge.sql

diff --git a/sql/Pg-upgrade2/tax_reverse_charge.sql b/sql/Pg-upgrade2/tax_reverse_charge.sql
index cf075a954..91ba9c111 100644
--- a/sql/Pg-upgrade2/tax_reverse_charge.sql
+++ b/sql/Pg-upgrade2/tax_reverse_charge.sql
@@ -1,6 +1,6 @@
 -- @tag: tax_reverse_charge
 -- @description: Reverse Charge fÃ¼r Kreditorenbelege
--- @depends: release_3_5_0
+-- @depends: release_3_6_0
 -- @ignore: 0
 
 ALTER TABLE tax add column reverse_charge_chart_id integer;
@@ -99,11 +99,11 @@ WHERE EXISTS ( -- update only for SKR03
     WHERE defaults.coa='Germany-DATEV-SKR04EU'
 );
 
-;
 -- if not defined
 insert into taxkeys(chart_id,tax_id,taxkey_id,startdate) SELECT (SELECT chart_id FROM tax WHERE taxkey = '94'),0,0,'1970-01-01' WHERE NOT EXISTS
-  (SELECT chart_id from taxkeys where chart_id = ( SELECT chart_id FROM tax WHERE taxkey = '94'));
+  (SELECT chart_id from taxkeys where chart_id = ( SELECT chart_id FROM tax WHERE taxkey = '94'))
+  AND (EXISTS (SELECT coa FROM defaults WHERE defaults.coa='Germany-DATEV-SKR04EU') OR EXISTS (SELECT coa FROM defaults WHERE defaults.coa='Germany-DATEV-SKR03EU'));
 
 insert into taxkeys(chart_id,tax_id,taxkey_id,startdate) SELECT (SELECT reverse_charge_chart_id FROM tax WHERE taxkey = '94'),0,0,'1970-01-01' WHERE NOT EXISTS
-  (SELECT chart_id from taxkeys where chart_id = ( SELECT reverse_charge_chart_id FROM tax WHERE taxkey = '94'));
-
+  (SELECT chart_id from taxkeys where chart_id = ( SELECT reverse_charge_chart_id FROM tax WHERE taxkey = '94'))
+    AND (EXISTS (SELECT coa FROM defaults WHERE defaults.coa='Germany-DATEV-SKR04EU') OR EXISTS (SELECT coa FROM defaults WHERE defaults.coa='Germany-DATEV-SKR03EU'));
