Swiss QR-Bill: Datenbankupgrade BankAccount
authorCem Aydin <cem.aydin@gmx.ch>
Wed, 15 Dec 2021 15:38:28 +0000 (16:38 +0100)
committerAndreas Rudin <andreas.rudin@revamp-it.ch>
Thu, 23 Dec 2021 21:23:00 +0000 (22:23 +0100)
- Felder bank_account_id und use_for_qrbill hinzugefügt

SL/DB/MetaSetup/BankAccount.pm
sql/Pg-upgrade2/bank_account_informations_for_swiss_qrbill.sql [new file with mode: 0644]

index 5589ee4..d836778 100644 (file)
@@ -11,6 +11,7 @@ __PACKAGE__->meta->table('bank_accounts');
 __PACKAGE__->meta->columns(
   account_number                  => { type => 'varchar', length => 100 },
   bank                            => { type => 'text' },
+  bank_account_id                 => { type => 'varchar' },
   bank_code                       => { type => 'varchar', length => 100 },
   bic                             => { type => 'varchar', length => 100 },
   chart_id                        => { type => 'integer', not_null => 1 },
@@ -21,6 +22,7 @@ __PACKAGE__->meta->columns(
   reconciliation_starting_balance => { type => 'numeric', precision => 15, scale => 5 },
   reconciliation_starting_date    => { type => 'date' },
   sortkey                         => { type => 'integer', not_null => 1 },
+  use_for_qrbill                  => { type => 'boolean', default => 'false', not_null => 1 },
   use_for_zugferd                 => { type => 'boolean', default => 'false', not_null => 1 },
 );
 
diff --git a/sql/Pg-upgrade2/bank_account_informations_for_swiss_qrbill.sql b/sql/Pg-upgrade2/bank_account_informations_for_swiss_qrbill.sql
new file mode 100644 (file)
index 0000000..0c8c64c
--- /dev/null
@@ -0,0 +1,14 @@
+-- @tag: bank_account_information_for_swiss_qrbill
+-- @description: Bankkonto Informationen für Swiss QR-Bill hinzufügen
+-- @depends: release_3_5_6_1
+ALTER TABLE bank_accounts ADD COLUMN use_for_qrbill BOOLEAN;
+ALTER TABLE bank_accounts ADD COLUMN bank_account_id VARCHAR;
+
+UPDATE bank_accounts SET use_for_qrbill = (
+    SELECT COUNT(*)
+    FROM bank_accounts
+  ) = 1;
+
+ALTER TABLE bank_accounts
+  ALTER COLUMN use_for_qrbill SET DEFAULT FALSE,
+  ALTER COLUMN use_for_qrbill SET NOT NULL;