bank_scrap 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/bank_scrap/cli.rb +22 -2
- data/lib/bank_scrap/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd004b30d6dd4eb2d705fcbe0affc0579d104a37
|
4
|
+
data.tar.gz: f47e2c334a704fe27b256548fab622723dc429dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d6370a6ae37fb00162023fe6e500fa550f98ef49e1d6f58c4bf96a8b569b124a906dbed8837c669af3ba5224e216c97b2d60b67d5f7d6bb83fafd14acfc6356
|
7
|
+
data.tar.gz: 171fef5e6ca580034f30f8c5e15007b817ef72c3d76ce318c829f6dd1c38ac1593d256ef77406115fb98ba296c3e694e1817616ccf773e3e89295cbd7c8bf015
|
data/README.md
CHANGED
@@ -74,6 +74,10 @@ Replace 01/01/1980 with your actual birthday.
|
|
74
74
|
|
75
75
|
$ bank_scrap transactions ing --user YOUR_DNI --password YOUR_PASSWORD --extra=birthday:01/01/1980
|
76
76
|
|
77
|
+
#### Transactions with date range
|
78
|
+
|
79
|
+
$ bank_scrap transactions your_bank --user YOUR_BANK_USER --password YOUR_BANK_PASSWORD --extra=from:01-01-2015 to:01-02-2015
|
80
|
+
|
77
81
|
---
|
78
82
|
|
79
83
|
By default it will use your first bank account, if you want to fetch transactions for a different account you can use this syntax:
|
data/lib/bank_scrap/cli.rb
CHANGED
@@ -12,7 +12,7 @@ module BankScrap
|
|
12
12
|
# Some bank needs more input, like birthday, this would go here
|
13
13
|
# Usage:
|
14
14
|
# bank_scrap balance BANK_NAME --extra=birthday:01/12/1980
|
15
|
-
option :extra, type: :hash
|
15
|
+
option :extra, type: :hash, default: {}
|
16
16
|
end
|
17
17
|
|
18
18
|
desc "balance BANK", "get accounts' balance"
|
@@ -31,9 +31,29 @@ module BankScrap
|
|
31
31
|
shared_options
|
32
32
|
def transactions(bank, iban = nil)
|
33
33
|
assign_shared_options
|
34
|
+
|
35
|
+
begin
|
36
|
+
start_date = @extra_args.has_key?('from') ? Date.strptime(@extra_args['from'],'%d-%m-%Y') : nil
|
37
|
+
end_date = @extra_args.has_key?('to') ? Date.strptime(@extra_args['to'],'%d-%m-%Y') : nil
|
38
|
+
rescue ArgumentError
|
39
|
+
say "Invalid date format. Correct format d-m-Y", :red
|
40
|
+
end
|
41
|
+
|
34
42
|
initialize_client_for(bank)
|
43
|
+
|
35
44
|
account = iban ? @client.account_with_iban(iban) : @client.accounts.first
|
36
|
-
|
45
|
+
|
46
|
+
if (!start_date.nil? && !end_date.nil?)
|
47
|
+
if (start_date > end_date)
|
48
|
+
say "From date must be lower than to date", :red
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
|
52
|
+
transactions = account.fetch_transactions(start_date:start_date, end_date:end_date)
|
53
|
+
else
|
54
|
+
transactions = account.transactions
|
55
|
+
end
|
56
|
+
|
37
57
|
say "Transactions for: #{account.description} (#{account.iban})", :cyan
|
38
58
|
|
39
59
|
transactions.each do |transaction|
|
data/lib/bank_scrap/version.rb
CHANGED