Skip to content

Commit

Permalink
codinguser#876 - Code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanGarf committed Mar 7, 2020
1 parent bf49482 commit 8e04ba5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
21 changes: 9 additions & 12 deletions app/src/main/java/org/gnucash/android/model/AccountType.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,16 @@ public enum AccountType {
}

// TODO TW C 2020-03-06 : Enlever le static

/**
* Compute red/green color according to accountType and isCredit
* Compute red/green color according to accountType and isCreditAmount
*
* @param isCredit
* @param isCreditAmount
* @param accountType
*
* @return
*/
@ColorInt
public static int getAmountColor(final boolean isCredit,
public static int getAmountColor(final boolean isCreditAmount,
final AccountType accountType) {

AccountType tmpAccountType = ((accountType != null)
Expand All @@ -79,18 +78,17 @@ public static int getAmountColor(final boolean isCredit,

@ColorRes final int colorRes;

// TODO TW C 2020-03-06 : Trouver un meilleur nom
final boolean specialAccountType = tmpAccountType.isEquityAccount() || tmpAccountType.isResultAccount();
// Accounts for which
final boolean debitCreditInvertedColorAccountType = tmpAccountType.isExpenseOrIncomeAccount() || tmpAccountType.isEquityAccount();

if ((!specialAccountType && isCredit) || (specialAccountType && !isCredit)) {
// TODO TW C 2020-03-02 : commenter
// CREDIT
if ((isCreditAmount && !debitCreditInvertedColorAccountType) || (!isCreditAmount && debitCreditInvertedColorAccountType)) {
// Credit amount and account like Assets, Bank, Cash..., or Debit amount and account like Expense/Income

// RED
colorRes = R.color.debit_red;

} else {
// DEBIT
// Credit amount and account like Expense/Income, or Debit amount and account like Assets, Bank, Cash...)

// GREEN
colorRes = R.color.credit_green;
Expand Down Expand Up @@ -125,8 +123,7 @@ public boolean isEquityAccount() {
return EQUITY.equals(this);
}

// TODO TW C 2020-03-03 : A renommer en anglais
public boolean isResultAccount() {
public boolean isExpenseOrIncomeAccount() {

return EXPENSE.equals(this) || INCOME.equals(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ private void initViews(final Split split) {
splitTypeSwitch.setViewsToColorize(splitAmountEditText,
splitCurrencyTextView);

// TODO TW C 2020-03-03 : A enlever ou mettre dans un else ?
// Switch on/off according to amount signum
splitTypeSwitch.setChecked(mBaseAmount.signum() > 0);

Expand Down

0 comments on commit 8e04ba5

Please sign in to comment.