Bankbewegung: Zuweisungsüberbuchungen per Constraint verbieten
authorJan Büren <jan@kivitendo.de>
Thu, 14 Mar 2019 15:08:23 +0000 (16:08 +0100)
committerJan Büren <jan@kivitendo.de>
Thu, 14 Mar 2019 15:08:23 +0000 (16:08 +0100)
sql/Pg-upgrade2/bank_transactions_check_constraint_invoice_amount.sql [new file with mode: 0644]

diff --git a/sql/Pg-upgrade2/bank_transactions_check_constraint_invoice_amount.sql b/sql/Pg-upgrade2/bank_transactions_check_constraint_invoice_amount.sql
new file mode 100644 (file)
index 0000000..cb81293
--- /dev/null
@@ -0,0 +1,5 @@
+-- @tag: bank_transactions_check_constraint_invoice_amount
+-- @description: Bank-Transaktionen dürfen mehrfach verbucht werden - Sicherheitscheck auf DB-Ebene, Überbuchen der Bankbewegung verbieten
+-- @depends: bank_transactions_type2 release_3_5_3
+
+ALTER TABLE bank_transactions ADD CHECK (abs(invoice_amount) <= abs(amount));