Skip to content

Commit

Permalink
codinguser#876 - Replace mAssetAccountTypes with ASSET_ACCOUNT_TYPES …
Browse files Browse the repository at this point in the history
…from AccountType
  • Loading branch information
JeanGarf committed Mar 7, 2020
1 parent b31daad commit bf49482
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
22 changes: 19 additions & 3 deletions app/src/main/java/org/gnucash/android/model/AccountType.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
import org.gnucash.android.R;
import org.gnucash.android.app.GnuCashApplication;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* The type of account
* This are the different types specified by the OFX format and
* they are currently not used except for exporting
*/
public enum AccountType {

CASH(TransactionType.DEBIT),
BANK(TransactionType.DEBIT),
CREDIT,
Expand All @@ -28,19 +33,30 @@ public enum AccountType {
TRADING,
ROOT;

public final static List<AccountType> ASSET_ACCOUNT_TYPES = new ArrayList<AccountType>(Arrays.asList(AccountType.ASSET,
AccountType.CASH,
AccountType.BANK));

public final static List<AccountType> LIABLITY_ACCOUNT_TYPES = new ArrayList<AccountType>(Arrays.asList(AccountType.LIABILITY,
AccountType.CREDIT));

public final static List<AccountType> EQUITY_ACCOUNT_TYPES = new ArrayList<AccountType>(Arrays.asList(AccountType.EQUITY));


/**
* Indicates that this type of normal balance the account type has
* <p>To increase the value of an account with normal balance of credit, one would credit the account.
* To increase the value of an account with normal balance of debit, one would likewise debit the account.</p>
*/
private TransactionType mNormalBalance = TransactionType.CREDIT;
private TransactionType mNormalBalance;

AccountType(TransactionType normalBalance) {

AccountType(TransactionType normalBalance){
this.mNormalBalance = normalBalance;
}

AccountType() {
//nothing to see here, move along
this(TransactionType.CREDIT);
}

// TODO TW C 2020-03-06 : Enlever le static
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@

import butterknife.BindView;

import static org.gnucash.android.model.AccountType.ASSET_ACCOUNT_TYPES;
import static org.gnucash.android.model.AccountType.EQUITY_ACCOUNT_TYPES;
import static org.gnucash.android.model.AccountType.LIABLITY_ACCOUNT_TYPES;

/**
* Balance sheet report fragment
* @author Ngewi Fet <[email protected]>
Expand All @@ -56,9 +60,6 @@ public class BalanceSheetFragment extends BaseReportFragment {

private Money mAssetsBalance;
private Money mLiabilitiesBalance;
private List<AccountType> mAssetAccountTypes;
private List<AccountType> mLiabilityAccountTypes;
private List<AccountType> mEquityAccountTypes;

@Override
public int getLayoutResource() {
Expand All @@ -78,19 +79,6 @@ public ReportType getReportType() {
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

// TODO TW C 2020-03-06 : A mettre dans AccountType sous formes de constantes
mAssetAccountTypes = new ArrayList<>();
mAssetAccountTypes.add(AccountType.ASSET);
mAssetAccountTypes.add(AccountType.CASH);
mAssetAccountTypes.add(AccountType.BANK);

mLiabilityAccountTypes = new ArrayList<>();
mLiabilityAccountTypes.add(AccountType.LIABILITY);
mLiabilityAccountTypes.add(AccountType.CREDIT);

mEquityAccountTypes = new ArrayList<>();
mEquityAccountTypes.add(AccountType.EQUITY);
}

@Override
Expand All @@ -105,16 +93,16 @@ public boolean requiresTimeRangeOptions() {

@Override
protected void generateReport() {
mAssetsBalance = mAccountsDbAdapter.getAccountBalance(mAssetAccountTypes, -1, System.currentTimeMillis());
mLiabilitiesBalance = mAccountsDbAdapter.getAccountBalance(mLiabilityAccountTypes, -1, System.currentTimeMillis());
mAssetsBalance = mAccountsDbAdapter.getAccountBalance(ASSET_ACCOUNT_TYPES, -1, System.currentTimeMillis());
mLiabilitiesBalance = mAccountsDbAdapter.getAccountBalance(LIABLITY_ACCOUNT_TYPES, -1, System.currentTimeMillis());
}

@Override
protected void displayReport() {

loadAccountViews(mAssetAccountTypes, mAssetsTableLayout);
loadAccountViews(mLiabilityAccountTypes, mLiabilitiesTableLayout);
loadAccountViews(mEquityAccountTypes, mEquityTableLayout);
loadAccountViews(ASSET_ACCOUNT_TYPES, mAssetsTableLayout);
loadAccountViews(LIABLITY_ACCOUNT_TYPES, mLiabilitiesTableLayout);
loadAccountViews(EQUITY_ACCOUNT_TYPES, mEquityTableLayout);

TransactionsActivity.displayBalance(mNetWorth,
// #8xx
Expand Down

0 comments on commit bf49482

Please sign in to comment.