X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/18a9328cd24bc8e809454bb08d6c575deee1e213..de009a3fee7e0471c3e095ce92d8708ff2b42597:/sql/Pg-upgrade2/payment_terms_for_invoices.sql

diff --git a/sql/Pg-upgrade2/payment_terms_for_invoices.sql b/sql/Pg-upgrade2/payment_terms_for_invoices.sql
new file mode 100644
index 000000000..6b6653d41
--- /dev/null
+++ b/sql/Pg-upgrade2/payment_terms_for_invoices.sql
@@ -0,0 +1,20 @@
+-- @tag: payment_terms_for_invoices
+-- @description: Unterscheidung in Zahlungsbedingungen fÃ¼r Angebote/AuftrÃ¤ge und Rechnungen
+-- @depends: release_3_4_0
+ALTER TABLE payment_terms ADD COLUMN description_long_invoice TEXT;
+UPDATE payment_terms SET description_long_invoice = description_long;
+
+INSERT INTO generic_translations (translation_type, language_id, translation_id, translation)
+SELECT translation_type || '_invoice', language_id, translation_id, translation
+FROM generic_translations
+WHERE translation_type = 'SL::DB::PaymentTerm/description_long';
+
+CREATE OR REPLACE FUNCTION generic_translations_delete_on_payment_terms_delete_trigger()
+RETURNS TRIGGER AS $$
+  BEGIN
+    DELETE FROM generic_translations
+    WHERE (translation_id = OLD.id)
+      AND (translation_type IN ('SL::DB::PaymentTerm/description_long', 'SL::DB::PaymentTerm/description_long_invoice'));
+    RETURN OLD;
+  END;
+$$ LANGUAGE plpgsql;
