Merge lp:~tlnd/financisto/bug-fixes into lp:~financisto-dev/financisto/trunk

Proposed by tlnd
Status: Merged
Merged at revision: 198
Proposed branch: lp:~tlnd/financisto/bug-fixes
Merge into: lp:~financisto-dev/financisto/trunk
Diff against target: 63 lines (+10/-7)
2 files modified
src/ru/orangesoftware/financisto/activity/AccountActivity.java (+7/-4)
src/ru/orangesoftware/financisto/adapter/AccountListAdapter2.java (+3/-3)
To merge this branch: bzr merge lp:~tlnd/financisto/bug-fixes
Reviewer Review Type Date Requested Status
Denis Solonenko Pending
Review via email: mp+63743@code.launchpad.net

Description of the change

Induced by the redesign of the income/expense amount input fields, the handling of the credit card limit is kind of corrupted. While previously the limit had been stored as a positive value, it is stored as a negative one (expense) when creating new accounts -- which is reasonable. However, negative amounts have not been considered, e.g. to visualize the balance in the account list with a colorful bar.

For legacy support, the absolute value is considered now.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ru/orangesoftware/financisto/activity/AccountActivity.java'
2--- src/ru/orangesoftware/financisto/activity/AccountActivity.java 2011-02-20 19:39:08 +0000
3+++ src/ru/orangesoftware/financisto/activity/AccountActivity.java 2011-06-07 17:47:24 +0000
4@@ -130,6 +130,8 @@
5 x.addEditNode(layout, R.string.title, accountTitle);
6 currencyText = x.addListNodePlus(layout, R.id.currency, R.id.currency_add, R.string.currency, R.string.select_currency);
7
8+ limitInput.setExpense();
9+ limitInput.disableIncomeExpenseButton();
10 limitAmountView = x.addEditNode(layout, R.string.limit_amount, limitInput);
11 setVisibility(limitAmountView, View.GONE);
12
13@@ -207,7 +209,7 @@
14 String sortOrder = Utils.text(sortOrderText);
15 account.sortOrder = sortOrder == null ? 0 : Integer.parseInt(sortOrder);
16 account.isIncludeIntoTotals = isIncludedIntoTotals.isChecked();
17- account.limitAmount = limitInput.getAmount();
18+ account.limitAmount = -Math.abs(limitInput.getAmount());
19
20 long accountId = em.saveAccount(account);
21 long amount = amountInput.getAmount();
22@@ -329,8 +331,9 @@
23 }
24
25 private void selectCurrency(Currency c) {
26- currencyText.setText(c.name);
27+ currencyText.setText(c.name);
28 amountInput.setCurrency(c);
29+ limitInput.setCurrency(c);
30 account.currency = c;
31 }
32
33@@ -355,8 +358,8 @@
34 /********************************/
35
36 isIncludedIntoTotals.setChecked(account.isIncludeIntoTotals);
37- if (account.limitAmount > 0) {
38- limitInput.setAmount(account.limitAmount);
39+ if (account.limitAmount != 0) {
40+ limitInput.setAmount(-Math.abs(account.limitAmount));
41 }
42 }
43
44
45=== modified file 'src/ru/orangesoftware/financisto/adapter/AccountListAdapter2.java'
46--- src/ru/orangesoftware/financisto/adapter/AccountListAdapter2.java 2011-02-20 19:39:08 +0000
47+++ src/ru/orangesoftware/financisto/adapter/AccountListAdapter2.java 2011-06-07 17:47:24 +0000
48@@ -81,12 +81,12 @@
49 v.bottomView.setText(df.format(new Date(date)));
50
51 long amount = a.totalAmount;
52- if (type == AccountType.CREDIT_CARD && a.limitAmount > 0) {
53- long balance = a.limitAmount + amount;
54+ if (type == AccountType.CREDIT_CARD && a.limitAmount != 0) {
55+ long balance = Math.abs(a.limitAmount) + amount;
56 u.setAmountText(v.rightCenterView, a.currency, amount, false);
57 u.setAmountText(v.rightView, a.currency, balance, false);
58 v.rightCenterView.setVisibility(View.VISIBLE);
59- v.progressBar.setMax((int)a.limitAmount);
60+ v.progressBar.setMax((int) Math.abs(a.limitAmount));
61 v.progressBar.setProgress((int)(balance > 0 ? balance : 0));
62 v.progressBar.setVisibility(View.VISIBLE);
63 } else {