Skip to content

Commit

Permalink
Merge pull request #480 from liato/feature/475-villabanken-crash-on-m…
Browse files Browse the repository at this point in the history
…issing-balance

Check that regex matches before adding account for Villabanken.
  • Loading branch information
fredrike committed Mar 2, 2015
2 parents 09b0edf + 67a9d34 commit 27b85c5
Showing 1 changed file with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,35 +165,34 @@ public void update() throws BankException, LoginException, BankChoiceException {
Matcher matcher;

matcher = reDisposableAmount.matcher(accountResponse);
matcher.find();
Account account = new Account("Disponibelt belopp", Helpers.parseBalance(matcher.group(2)), "0");
account.setType(Account.CCARD);
account.setCurrency(currency);
accounts.add(account);
balance = balance.add(account.getBalance());

if(matcher.find()) {
Account account = new Account("Disponibelt belopp", Helpers.parseBalance(matcher.group(2)), "0");
account.setType(Account.CCARD);
account.setCurrency(currency);
accounts.add(account);
balance = balance.add(account.getBalance());
}
matcher = reBalance.matcher(accountResponse);
matcher.find();
account = new Account("Saldo", Helpers.parseBalance(matcher.group(2)), "1");
account.setType(Account.OTHER);
account.setAliasfor("Saldo alias");
account.setCurrency(currency);
accounts.add(account);

if(matcher.find()) {
Account account = new Account("Saldo", Helpers.parseBalance(matcher.group(2)), "1");
account.setType(Account.OTHER);
account.setAliasfor("Saldo alias");
account.setCurrency(currency);
accounts.add(account);
}
matcher = reCreditLimit.matcher(accountResponse);
matcher.find();
account = new Account("Köpgräns", Helpers.parseBalance(matcher.group(2)), "2");
account.setType(Account.OTHER);
account.setAliasfor("Köpgräns alias");
account.setCurrency(currency);
accounts.add(account);

if(matcher.find()) {
Account account = new Account("Köpgräns", Helpers.parseBalance(matcher.group(2)), "2");
account.setType(Account.OTHER);
account.setAliasfor("Köpgräns alias");
account.setCurrency(currency);
accounts.add(account);
}
if (accounts.isEmpty()) {
throw new BankException(res.getText(R.string.no_accounts_found).toString());
}

super.updateComplete();

}

@Override
Expand Down

0 comments on commit 27b85c5

Please sign in to comment.