6b6653d41200e25199ab60d9946bc87ef4eca733
[kivitendo-erp.git] / sql / Pg-upgrade2 / payment_terms_for_invoices.sql
1 -- @tag: payment_terms_for_invoices
2 -- @description: Unterscheidung in Zahlungsbedingungen für Angebote/Aufträge und Rechnungen
3 -- @depends: release_3_4_0
4 ALTER TABLE payment_terms ADD COLUMN description_long_invoice TEXT;
5 UPDATE payment_terms SET description_long_invoice = description_long;
6
7 INSERT INTO generic_translations (translation_type, language_id, translation_id, translation)
8 SELECT translation_type || '_invoice', language_id, translation_id, translation
9 FROM generic_translations
10 WHERE translation_type = 'SL::DB::PaymentTerm/description_long';
11
12 CREATE OR REPLACE FUNCTION generic_translations_delete_on_payment_terms_delete_trigger()
13 RETURNS TRIGGER AS $$
14   BEGIN
15     DELETE FROM generic_translations
16     WHERE (translation_id = OLD.id)
17       AND (translation_type IN ('SL::DB::PaymentTerm/description_long', 'SL::DB::PaymentTerm/description_long_invoice'));
18     RETURN OLD;
19   END;
20 $$ LANGUAGE plpgsql;