Skip to content
This repository was archived by the owner on Feb 25, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ accounts:
password: # n26 password
skip_pending_transactions: false # default: false, only imports transactions when they're processed
set_category: false # default: false, sets the N26 category name as category
replacements:
- payee: "NETFLIX INTERNATIONAL B.V."
replacement: "Netflix"
2 changes: 2 additions & 0 deletions lib/dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def self.get_dumper(name)
Dumper::N26
when :fints
Dumper::Fints
when :deutschebank
Dumper::DeutscheBank
else
raise "Dumper \"#{name}\" not supported."
end
Expand Down
29 changes: 29 additions & 0 deletions lib/dumper/deutschebank.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Dumper
# Implements logic to fetch transactions via the Fints protocol
# and implements methods that convert the response to meaningful data.
class DeutscheBank < Fints
def payee_name(transaction)
if transaction.sepa["SVWZ"].nil?
puts transaction.inspect
puts transaction.to_json
end
if super == "DEUTSCHE BANK" || super == "" # This is either a interest statement or more likely a Payment with Apple Pay
if transaction.sepa.empty?
puts transaction.transaction_code
transaction.transaction_code
else
transaction.sepa["SVWZ"].split('//')[0]
end
else
super
end
end
def memo(transaction)
if transaction.sepa.empty?
transaction.information
else
transaction.sepa["SVWZ"]
end
end
end
end
2 changes: 1 addition & 1 deletion lib/dumper/fints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def fetch_transactions
client = FinTS::PinTanClient.new(@blz, @username, @password, @endpoint)

account = client.get_sepa_accounts.find { |a| a[:iban] == @iban }
statement = client.get_statement(account, Date.today - 35, Date.today)
statement = client.get_statement(account, Date.today - 10, Date.today)

statement.map { |t| to_ynab_transaction(t) }
end
Expand Down
11 changes: 11 additions & 0 deletions lib/transaction_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def call(options = {})
# rubocop:enable Metrics/MethodLength

def payee_id(options)
return nil # ignore for now and let ynab calc that
payee_id = options.fetch(:payee_id, nil)
return payee_id if payee_id

Expand All @@ -43,11 +44,21 @@ def payee_id(options)
def payee_name(options)
return nil if payee_id(options)
payee = options.fetch(:payee_name, nil)
# try to replace
payee = replaceFromConfig(payee)
# The api has a limit of 50 characters for the payee field
payee = truncate(payee, 50)
payee
end

def replaceFromConfig(payee)
result = Settings.all['replacements'].find do |replacement|
replacement['payee'] == payee
end
return payee if result.nil? || result == ""
result['replacement']
end

def memo(options)
memo = options.fetch(:memo, nil)
# The api has a limit of 100 characters for the momo field
Expand Down