* the saldo on that date
*/
protected void createSaldoEntry(final FixedPointNumber aValue, final Date timestamp) {
try {
FixedPointNumber saldo = aValue;
String saldoOKStr = "OK";
if (!getMyAccount().getBalance(timestamp).equals(saldo)) {
saldoOKStr = "NAK ("
+ getMyAccount().getBalance(timestamp).subtract(
saldo) + ")";
}
GnucashWritableTransaction transaction = getMyAccount()
.getWritableGnucashFile().createWritableTransaction();
transaction.setDescription("Saldo: " + aValue + " "
+ saldoOKStr + " (imported via script on " + DateFormat.getDateInstance().format(new Date()) + ")");
transaction.setDatePosted(timestamp);
transaction.setCurrencyNameSpace(getMyAccount()
.getCurrencyNameSpace());
transaction.setCurrencyID(getMyAccount().getCurrencyID());
// we always need the split on out account's side
GnucashWritableTransactionSplit myAccountSplit = transaction
.createWritingSplit(getMyAccount());
myAccountSplit.setValue(new FixedPointNumber()); // 0
myAccountSplit.setQuantity(new FixedPointNumber()); // 0
// dummy-split on the other side
GnucashWritableAccount otherAccount = getDefaultAccount();
GnucashWritableTransactionSplit otherAccountSplit = transaction
.createWritingSplit(otherAccount);
otherAccountSplit.setValue(new FixedPointNumber()); // 0
otherAccountSplit.setQuantity(new FixedPointNumber()); // 0
} catch (Exception e) {
LOG.log(Level.SEVERE, "Exception while creating Saldo-transaction.", e);
}
}