From 87fe9ccdb144ff159ffbb6e0eb3c1b5e3a1fc80c Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Fri, 5 Mar 2021 12:43:40 +0100 Subject: [PATCH] Add model for BankGateway --- app/models/bank_account.rb | 1 + app/models/bank_gateway.rb | 8 ++++++++ config/locales/de.yml | 8 ++++++++ config/locales/en.yml | 8 ++++++++ db/migrate/20190100000009_create_bank_gateways.rb | 12 ++++++++++++ db/schema.rb | 8 ++++++++ 6 files changed, 45 insertions(+) create mode 100644 app/models/bank_gateway.rb create mode 100644 db/migrate/20190100000009_create_bank_gateways.rb diff --git a/app/models/bank_account.rb b/app/models/bank_account.rb index bb77b587..07a85c4d 100644 --- a/app/models/bank_account.rb +++ b/app/models/bank_account.rb @@ -1,5 +1,6 @@ class BankAccount < ApplicationRecord has_many :bank_transactions, dependent: :destroy + belongs_to :bank_gateway, optional: true normalize_attributes :name, :iban, :description diff --git a/app/models/bank_gateway.rb b/app/models/bank_gateway.rb new file mode 100644 index 00000000..3811f128 --- /dev/null +++ b/app/models/bank_gateway.rb @@ -0,0 +1,8 @@ +class BankGateway < ApplicationRecord + has_many :bank_accounts, dependent: :nullify + belongs_to :unattended_user, class_name: 'User', optional: true + + scope :with_unattended_support, -> { where.not(unattended_user: nil) } + + validates_presence_of :name, :url +end diff --git a/config/locales/de.yml b/config/locales/de.yml index f5951028..fa47d4ee 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -35,9 +35,15 @@ de: unit_quantity: Gebindegröße bank_account: balance: Kontostand + bank_gateway: Bankgateway description: Beschreibung iban: IBAN name: Name + bank_gateway: + authorization: Authorization-Header + name: Name + unattended_user: Bedienerlos-Benutzer_in + url: URL bank_transaction: amount: Betrag date: Datum @@ -244,6 +250,8 @@ de: models: article: Artikel article_category: Kategorie + bank_account: Bankkonto + bank_gateway: Bankgateway bank_transaction: Banktransaktion delivery: Lieferung financial_transaction: Kontotransaktion diff --git a/config/locales/en.yml b/config/locales/en.yml index 38c41d73..3d38d7b9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -35,9 +35,15 @@ en: unit_quantity: Unit quantity bank_account: balance: Balance + bank_gateway: Bank gateway description: Description iban: IBAN name: Name + bank_gateway: + authorization: Authorization-Header + name: Name + unattended_user: Unattended user + url: URL bank_transaction: amount: Amount date: Date @@ -244,6 +250,8 @@ en: models: article: Article article_category: Category + bank_account: Bank account + bank_gateway: Bank gateway bank_transaction: Bank transaction delivery: Delivery financial_transaction: Financial transaction diff --git a/db/migrate/20190100000009_create_bank_gateways.rb b/db/migrate/20190100000009_create_bank_gateways.rb new file mode 100644 index 00000000..9da8eb1c --- /dev/null +++ b/db/migrate/20190100000009_create_bank_gateways.rb @@ -0,0 +1,12 @@ +class CreateBankGateways < ActiveRecord::Migration[4.2] + def change + create_table :bank_gateways do |t| + t.string :name, null: false + t.string :url, null: false + t.string :authorization + t.integer :unattended_user_id + end + + add_reference :bank_accounts, :bank_gateway + end +end diff --git a/db/schema.rb b/db/schema.rb index b3f80bb2..869e614f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -89,6 +89,14 @@ ActiveRecord::Schema.define(version: 2021_02_05_090257) do t.decimal "balance", precision: 12, scale: 2, default: "0.0", null: false t.datetime "last_import" t.string "import_continuation_point" + t.integer "bank_gateway_id" + end + + create_table "bank_gateways", id: :integer, force: :cascade do |t| + t.string "name", null: false + t.string "url", null: false + t.string "authorization" + t.integer "unattended_user_id" end create_table "bank_transactions", id: :integer, force: :cascade do |t|