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; }
private void insertData() { Transaction op; account1 = new Account("Account 1", openingBalance, "Account 1"); account1.save(); account2 = new Account("Account 2", openingBalance, "Account 2"); account2.save(); catId = Category.write(0, TEST_CAT, null); op = Transaction.getNewInstance(account1.getId()); op.setAmount(new Money(account1.currency, -expense1)); op.crStatus = CrStatus.CLEARED; op.save(); op.setAmount(new Money(account1.currency, -expense2)); op.saveAsNew(); op.setAmount(new Money(account1.currency, income1)); op.saveAsNew(); op.setAmount(new Money(account1.currency, income2)); op.setCatId(catId); op.saveAsNew(); Transfer op1 = Transfer.getNewInstance(account1.getId(), account2.getId()); op1.setAmount(new Money(account1.currency, transferP)); op1.save(); op1.setAmount(new Money(account1.currency, -transferN)); op1.saveAsNew(); }