X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/deb4d2dbb676d7d6f69dfe7815d6e0cb09bd4a44..53593baa211863fbf66540cf1bcc36c8fb37257f:/sql/Pg-upgrade2/defaults_advance_payment_transfer_charts.sql

diff --git a/sql/Pg-upgrade2/defaults_advance_payment_transfer_charts.sql b/sql/Pg-upgrade2/defaults_advance_payment_transfer_charts.sql
new file mode 100644
index 000000000..f77b2578e
--- /dev/null
+++ b/sql/Pg-upgrade2/defaults_advance_payment_transfer_charts.sql
@@ -0,0 +1,59 @@
+-- @tag: defaults_advance_payment_transfer_charts
+-- @description: Standardkonten fÃ¼r erhaltene versteuerte Anzahlungen 7% und 19% setzen
+-- @depends:new_chart_3260_1711 new_chart_3272_1718 defaults_advance_payment_clearing_chart_id
+
+
+ALTER TABLE defaults ADD COLUMN advance_payment_taxable_19_id INTEGER;
+ALTER TABLE defaults ADD COLUMN advance_payment_taxable_7_id  INTEGER;
+UPDATE chart set link ='AR' where id = (select advance_payment_clearing_chart_id from defaults);
+
+
+DO $$
+BEGIN
+
+  IF ( SELECT coa FROM defaults ) = 'Germany-DATEV-SKR03EU' THEN
+    DECLARE
+      clearing_accno text := '1718';
+
+    BEGIN
+      IF ( SELECT COUNT(accno) FROM chart WHERE accno LIKE clearing_accno ) = 1 THEN
+        UPDATE defaults SET advance_payment_taxable_19_id = (SELECT id FROM chart WHERE accno LIKE clearing_accno);
+      END IF;
+    END;
+  END IF;
+
+  IF ( SELECT coa FROM defaults ) = 'Germany-DATEV-SKR04EU' THEN
+    DECLARE
+      clearing_accno text := '3272';
+
+    BEGIN
+      IF ( SELECT COUNT(accno) FROM chart WHERE accno LIKE clearing_accno ) = 1 THEN
+        UPDATE defaults SET advance_payment_taxable_19_id = (SELECT id FROM chart WHERE accno LIKE clearing_accno);
+      END IF;
+    END;
+  END IF;
+
+  IF ( SELECT coa FROM defaults ) = 'Germany-DATEV-SKR03EU' THEN
+    DECLARE
+      clearing_accno text := '1711';
+
+    BEGIN
+      IF ( SELECT COUNT(accno) FROM chart WHERE accno LIKE clearing_accno ) = 1 THEN
+        UPDATE defaults SET advance_payment_taxable_7_id = (SELECT id FROM chart WHERE accno LIKE clearing_accno);
+      END IF;
+    END;
+  END IF;
+
+  IF ( SELECT coa FROM defaults ) = 'Germany-DATEV-SKR04EU' THEN
+    DECLARE
+      clearing_accno text := '3260';
+
+    BEGIN
+      IF ( SELECT COUNT(accno) FROM chart WHERE accno LIKE clearing_accno ) = 1 THEN
+        UPDATE defaults SET advance_payment_taxable_7_id = (SELECT id FROM chart WHERE accno LIKE clearing_accno);
+      END IF;
+    END;
+  END IF;
+
+
+END $$;
