Пример #1
0
 public Transaction toTransaction(Account a) {
   Transaction t;
   Money m = new Money(a.currency, amount);
   if (isSplit()) {
     t = new SplitTransaction(a.getId(), m);
   } else if (isTransfer()) {
     t = new Transfer(a.getId(), m);
   } else {
     t = new Transaction(a.getId(), m);
   }
   if (date != null) {
     t.setDate(date);
   }
   t.comment = memo;
   t.crStatus = Transaction.CrStatus.fromQifName(status);
   t.referenceNumber = number;
   return t;
 }
Пример #2
0
 public void testAccount() throws RemoteException, OperationApplicationException {
   Account account, restored = null;
   Long openingBalance = (long) 100;
   account = new Account("TestAccount", openingBalance, "Testing with Junit");
   account.setCurrency("EUR");
   assertEquals("EUR", account.currency.getCurrencyCode());
   account.save();
   assertTrue(account.getId() > 0);
   restored = Account.getInstanceFromDb(account.getId());
   assertEquals(account, restored);
   Long trAmount = (long) 100;
   Transaction op1 = Transaction.getNewInstance(account.getId());
   op1.setAmount(new Money(account.currency, trAmount));
   op1.comment = "test transaction";
   op1.save();
   assertEquals(account.getTotalBalance().getAmountMinor().longValue(), openingBalance + trAmount);
   Account.delete(account.getId());
   assertNull(
       "Account deleted, but can still be retrieved", Account.getInstanceFromDb(account.getId()));
   assertNull(
       "Account delete should delete transaction, but operation can still be retrieved",
       Transaction.getInstanceFromDb(op1.getId()));
 }