final String language,
final String scriptPath,
final Reader reader) {
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine jsEngine = mgr.getEngineByName(language);
jsEngine.put("text", text);
jsEngine.put("value", value);
jsEngine.put("transaction", myAccountSplit.getTransaction());
jsEngine.put("myAccountSplit", myAccountSplit);
jsEngine.put("file", myAccountSplit.getWritableGnucashFile());
FixedPointNumber ustValue = ((FixedPointNumber) value.clone())
.divideBy(new FixedPointNumber("-1,19")).multiply(
new FixedPointNumber("0,19")); // TODO: get tax-% from
// tax-config
FixedPointNumber nettoValue = ((FixedPointNumber) value.clone())
.negate().subtract(ustValue);
jsEngine.put("USt", ustValue);
jsEngine.put("Netto", nettoValue);
jsEngine.put("Helper", new ScriptHelper());
jsEngine.getContext().setAttribute(ScriptEngine.FILENAME, scriptPath,
ScriptContext.GLOBAL_SCOPE);
try {
LOG.info("importing transaction using script: " + scriptPath);
jsEngine.eval(reader);
} catch (Exception ex) {
LOG.log(Level.SEVERE, "Error executing script number " + scriptnum
+ " from " + scriptPath, ex);
JOptionPane.showMessageDialog(null,
"Error executing user Import-Script #" + scriptnum