Ejemplo n.º 1
0
bool MyMoneyReport::includes( const MyMoneyAccount& acc ) const
{
  bool result = false;

  if ( includesAccountGroup ( acc.accountGroup() ) )
  {
    switch ( acc.accountGroup() )
    {
      case MyMoneyAccount::Income:
      case MyMoneyAccount::Expense:
        if ( isTax() )
          result = ( acc.value ( "Tax" ) == "Yes" ) && includesCategory ( acc.id() );
        else
          result = includesCategory ( acc.id() );
        break;
      case MyMoneyAccount::Asset:
      case MyMoneyAccount::Liability:
        if ( isLoansOnly() )
          result = acc.isLoan() && includesAccount ( acc.id() );
        else if ( isInvestmentsOnly() )
          result = acc.isInvest() && includesAccount ( acc.id() );
        else if ( isIncludingTransfers() && m_rowType == MyMoneyReport::eExpenseIncome )
          // If transfers are included, ONLY include this account if it is NOT
          // included in the report itself!!
          result = ! includesAccount ( acc.id() );
        else
          result = includesAccount ( acc.id() );
        break;
      default:
        result = includesAccount ( acc.id() );
    }
  }
  return result;
}
Ejemplo n.º 2
0
void MyMoneyAccountTest::testIsLoan()
{
  MyMoneyAccount a;

  a.setAccountType(MyMoneyAccount::UnknownAccountType);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::Checkings);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::Savings);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::Cash);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::CreditCard);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::Loan);
  QVERIFY(a.isLoan() == true);

  a.setAccountType(MyMoneyAccount::CertificateDep);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::Investment);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::MoneyMarket);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::Asset);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::Liability);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::Currency);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::Income);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::Expense);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::AssetLoan);
  QVERIFY(a.isLoan() == true);

  a.setAccountType(MyMoneyAccount::Stock);
  QVERIFY(a.isLoan() == false);

  a.setAccountType(MyMoneyAccount::Equity);
  QVERIFY(a.isLoan() == false);
}