myAccountSplit.setQuantity(value);
myAccountSplit.setUserDefinedAttribute(getPluginName() + ".orig_description",
text);
myAccountSplit.setDescription(text.replace('\n', ' '));
GnucashWritableAccount otherAccount = getDefaultAccount();
String otherAccountText = "automatically added";
boolean scriptMatched = false;
try {
// look if there is a script matching,
int scriptnum = 0;
LOG.log(Level.FINEST, "Testing scripts for a match");
while (getMyProperties().containsKey(
getPluginName() + SETTINGS_PREFIX_IMPORTSCRIPT_REGEXP + scriptnum)) {
String scriptFilenameKey = getPluginName() + SETTINGS_PREFIX_IMPORTSCRIPT + scriptnum;
String scriptAccountKey = getPluginName() + SETTINGS_PREFIX_IMPORTSCRIPT_ACCOUNT + scriptnum;
LOG.log(Level.FINEST, "Testing script number " + scriptnum + " for a match");
String regexp = getMyProperties().getProperty(
getPluginName() + SETTINGS_PREFIX_IMPORTSCRIPT_REGEXP + scriptnum);
if (text.matches(regexp)) {
scriptMatched = true;
// does a full script exist or only an alternate
// accountid?
if (getMyProperties().containsKey(scriptFilenameKey)) {
importViaScript(value, text, myAccountSplit, scriptnum);
} else {
String alternateAccountID = getMyProperties()
.getProperty(scriptAccountKey);
otherAccount = getMyAccount().getWritableGnucashFile()
.getAccountByID(alternateAccountID);
if (otherAccount == null) {
LOG.log(Level.SEVERE, "Error Account " + otherAccount
+ " given in user-" + getPluginName() + "-rule #"
+ scriptnum + " not found");
JOptionPane
.showMessageDialog(
null,
"Error Account "
+ otherAccount
+ " given in user-" + getPluginName() + "-rule #"
+ scriptnum
+ " not found",
"User-supplied target-account not found.",
JOptionPane.ERROR_MESSAGE);
} else {
LOG.log(Level.INFO, "importing transaction using alternate target-account: "
+ alternateAccountID
+ "="
+ otherAccount
.getQualifiedName());
otherAccountText = "";
}
}