X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/30b4a78c4100ebdcd6e6917fbcbf1d12f4f7b4d6..1d99e3e9537f75342a9f20f1e89a3e8cb4bb5444:/sql/Pg-upgrade2/tax_reverse_charge_key_19.sql

diff --git a/sql/Pg-upgrade2/tax_reverse_charge_key_19.sql b/sql/Pg-upgrade2/tax_reverse_charge_key_19.sql
index 33d65048c..c4b4a6872 100644
--- a/sql/Pg-upgrade2/tax_reverse_charge_key_19.sql
+++ b/sql/Pg-upgrade2/tax_reverse_charge_key_19.sql
@@ -1,6 +1,6 @@
 -- @tag: tax_reverse_charge_key_19
 -- @description: Reverse Charge fÃ¼r Kreditorenbelege SteuerschlÃ¼ssel 19
--- @depends: release_3_6_0
+-- @depends: release_3_6_0 clean_tax_18_19
 -- @ignore: 0
 
 UPDATE tax set rate=0.19 where taxkey=94 AND reverse_charge_chart_id is not NULL;
@@ -56,8 +56,10 @@ WHERE EXISTS ( -- update only for SKR04
 
 -- if not defined
 insert into taxkeys(chart_id,tax_id,taxkey_id,startdate) SELECT (SELECT reverse_charge_chart_id FROM tax WHERE taxkey = '19' and rate = 0.19 and reverse_charge_chart_id is not null),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 = '19' and rate = 0.19 and reverse_charge_chart_id is not null));
+  (SELECT chart_id from taxkeys where chart_id = ( SELECT reverse_charge_chart_id FROM tax WHERE taxkey = '19' and rate = 0.19 and reverse_charge_chart_id is not null))
+  AND (EXISTS (SELECT coa FROM defaults WHERE defaults.coa='Germany-DATEV-SKR04EU') OR EXISTS (SELECT coa FROM defaults WHERE defaults.coa='Germany-DATEV-SKR03EU'));
 -- if not defined
 insert into taxkeys(chart_id,tax_id,taxkey_id,startdate) SELECT (SELECT chart_id FROM tax WHERE taxkey = '19' and rate = 0.19 and reverse_charge_chart_id is not null),0,0,'1970-01-01' WHERE NOT EXISTS
-  (SELECT chart_id from taxkeys where chart_id = ( SELECT chart_id FROM tax WHERE taxkey = '19' and rate = 0.19 and reverse_charge_chart_id is not null));
+  (SELECT chart_id from taxkeys where chart_id = ( SELECT chart_id FROM tax WHERE taxkey = '19' and rate = 0.19 and reverse_charge_chart_id is not null))
+  AND (EXISTS (SELECT coa FROM defaults WHERE defaults.coa='Germany-DATEV-SKR04EU') OR EXISTS (SELECT coa FROM defaults WHERE defaults.coa='Germany-DATEV-SKR03EU'));
 
