From 75129b52c6ee7e0d08ae2eacdfd188e4ad69ea8d Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Wed, 29 Jul 2020 19:18:12 +0200 Subject: [PATCH] Add set_balance_as_sum and wait_with_text to BankAccountConnector --- config/locales/de.yml | 3 ++- config/locales/en.yml | 3 ++- lib/bank_account_connector.rb | 15 +++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index d605bfe5..33970f08 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -526,11 +526,12 @@ de: text_2: Die hier gezeigten Spalten sind Beispiele. Ist ein "x" in der ersten Spalte, wird der Artikel aussortiert und entfernt. Das erlaubt Dir die Tabelle zu ändern und schnell viele Artikel auf ein Mal zu entfernen, zum Beispiel wenn Artkiel des Lieferanten nicht mehr verfügbar sind. Die Kategorie wird der Foodsoft Kategorie zugeordnet (durch die Kategorienamen und die Importnamen). title: Artikel des Lieferanten %{supplier} hochladen bank_account_connector: - confirm_app: Bitte bestätige den Code %{code} in deiner App. + confirm: Bitte bestätige den Code %{code}. fields: email: E-Mail pin: PIN password: Passwort + tan: TAN username: Benutzername config: hints: diff --git a/config/locales/en.yml b/config/locales/en.yml index 5f7384d8..37ac1ea4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -544,11 +544,12 @@ en: text_2: The rows shown here are examples. When there is an "x" in the first column, the article is outlisted and will be removed. This allows you to edit the spreadsheet and quickly remove many articles at once, for example when articles become unavailable with the supplier. The category will be matched to your Foodsoft category list (both by category name and import names). title: Upload articles of %{supplier} bank_account_connector: - confirm_app: Please confirm the code %{code} in your app. + confirm: Please confirum the code %{code}. fields: email: E-Mail pin: PIN password: Password + tan: TAN username: Username config: hints: diff --git a/lib/bank_account_connector.rb b/lib/bank_account_connector.rb index bc479e84..4f4ecf79 100644 --- a/lib/bank_account_connector.rb +++ b/lib/bank_account_connector.rb @@ -96,14 +96,18 @@ class BankAccountConnector @controls += [TextItem.new(data)] end - def wait_with_text(auto_submit, data) + def confirm_text(code) + text t('.confirm', code: code) + end + + def wait_with_text(auto_submit, code) @auto_submit = auto_submit - @controls += [TextItem.new(data)] + confirm_text code end def wait_for_app(code) hidden_field :twofactor, code - wait_with_text 3000, t('.confirm_app', code: code) + wait_with_text 3000, code nil end @@ -119,11 +123,14 @@ class BankAccountConnector @controls += [PasswordField.new(name, value, t(name))] end - def set_balance(amount) @bank_account.balance = amount end + def set_balance_as_sum + @bank_account.balance = @bank_account.bank_transactions.sum(:amount) + end + def continuation_point @bank_account.import_continuation_point end