GWENHYWFAR_CB void AIO_OfxGroup_BUYMF_FreeData(void *bp, void *p) { AIO_OFX_GROUP_BUYMF *xg; xg=(AIO_OFX_GROUP_BUYMF*)p; assert(xg); AB_Transaction_free(xg->transaction); free(xg->currentElement); GWEN_FREE_OBJECT(xg); }
void gnc_ab_trans_dialog_free(GncABTransDialog *td) { if (!td) return; if (td->ab_trans) AB_Transaction_free(td->ab_trans); if (td->dialog) gtk_widget_destroy(td->dialog); if (td->template_list_store) { gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store), clear_templ_helper, NULL); g_object_unref(td->template_list_store); } #if HAVE_KTOBLZCHECK_H AccountNumberCheck_delete(td->blzcheck); #endif g_free(td); }
static const AB_TRANSACTION * txn_transaction_cb(const AB_TRANSACTION *element, gpointer user_data) { GncABImExContextImport *data = user_data; Transaction *gnc_trans; GncABTransType trans_type; g_return_val_if_fail(element && data, NULL); /* Create a GnuCash transaction from ab_trans */ gnc_trans = gnc_ab_trans_to_gnc(element, data->gnc_acc); if (data->execute_txns && data->ab_acc) { AB_TRANSACTION *ab_trans = AB_Transaction_dup(element); AB_JOB *job; /* NEW: The imported transaction has been imported into gnucash. * Now also add it as a job to aqbanking */ AB_Transaction_SetLocalBankCode( ab_trans, AB_Account_GetBankCode(data->ab_acc)); AB_Transaction_SetLocalAccountNumber( ab_trans, AB_Account_GetAccountNumber(data->ab_acc)); AB_Transaction_SetLocalCountry(ab_trans, "DE"); switch (AB_Transaction_GetType(ab_trans)) { case AB_Transaction_TypeDebitNote: trans_type = SINGLE_DEBITNOTE; break; case AB_Transaction_TypeEuTransfer: trans_type = SEPA_TRANSFER; break; case AB_Transaction_TypeTransaction: /* trans_type = SINGLE_INTERNAL_TRANSFER; * break; */ case AB_Transaction_TypeTransfer: default: trans_type = SINGLE_TRANSFER; } /* switch */ job = gnc_ab_get_trans_job(data->ab_acc, ab_trans, trans_type); /* Check whether we really got a job */ if (!job || AB_Job_CheckAvailability(job #ifndef AQBANKING_VERSION_5_PLUS , 0 #endif )) { /* Oops, no job, probably not supported by bank */ if (gnc_verify_dialog( NULL, FALSE, "%s", _("The backend found an error during the preparation " "of the job. It is not possible to execute this job. \n" "\n" "Most probably the bank does not support your chosen " "job or your Online Banking account does not have the permission " "to execute this job. More error messages might be " "visible on your console log.\n" "\n" "Do you want to enter the job again?"))) { gnc_error_dialog(NULL, "Sorry, not implemented yet. Please check the console or trace file logs to see which job was rejected."); } } else { gnc_gen_trans_list_add_trans_with_ref_id(data->generic_importer, gnc_trans, AB_Job_GetJobId(job)); /* AB_Job_List2_PushBack(data->job_list, job); -> delayed until trans is successfully imported */ g_datalist_set_data(&data->tmp_job_list, gnc_AB_JOB_to_readable_string(job), job); } AB_Transaction_free(ab_trans); } else { /* Instead of xaccTransCommitEdit(gnc_trans) */ gnc_gen_trans_list_add_trans(data->generic_importer, gnc_trans); } return NULL; }
AB_TRANSACTION *mkSepaDebitNote(AB_ACCOUNT *a, GWEN_DB_NODE *db) { AB_TRANSACTION *t; const char *s; t=mkSepaTransfer(a, db, AB_Job_TypeSepaDebitNote); if (t==NULL) { DBG_INFO(0, "here"); return NULL; } /* read some additional fields */ s=GWEN_DB_GetCharValue(db, "creditorSchemeId", 0, 0); if (!(s && *s)) { DBG_ERROR(0, "Missing creditor scheme id"); AB_Transaction_free(t); return NULL; } AB_Transaction_SetCreditorSchemeId(t, s); s=GWEN_DB_GetCharValue(db, "mandateId", 0, 0); if (!(s && *s)) { DBG_ERROR(0, "Missing mandate id"); AB_Transaction_free(t); return NULL; } AB_Transaction_SetMandateId(t, s); s=GWEN_DB_GetCharValue(db, "mandateDate", 0, 0); if (!(s && *s)) { DBG_ERROR(0, "Missing mandate date"); AB_Transaction_free(t); return NULL; } else { GWEN_DATE *dt; dt=GWEN_Date_fromString(s); if (dt==NULL) { DBG_ERROR(0, "Bad date format for mandate date"); AB_Transaction_free(t); return NULL; } AB_Transaction_SetMandateDate(t, dt); GWEN_Date_free(dt); } s=GWEN_DB_GetCharValue(db, "sequenceType", 0, "once"); if (s && *s) { AB_TRANSACTION_SEQUENCETYPE st; st=AB_Transaction_SequenceType_fromString(s); if (st!=AB_Transaction_SequenceTypeUnknown) AB_Transaction_SetSequenceType(t, st); else { DBG_ERROR(0, "Unknown sequence type [%s]", s); AB_Transaction_free(t); return NULL; } } else AB_Transaction_SetSequenceType(t, AB_Transaction_SequenceTypeOnce); return t; }
AB_TRANSACTION *mkSepaTransfer(AB_ACCOUNT *a, GWEN_DB_NODE *db, int expTransferType) { AB_BANKING *ab; AB_TRANSACTION *t; const char *s; int i; GWEN_TIME *d; assert(a); assert(db); ab=AB_Account_GetBanking(a); assert(ab); t=AB_Transaction_new(); AB_Banking_FillGapsInTransaction(ab, a, t); s=GWEN_DB_GetCharValue(db, "name", 0, 0); if (s && *s) AB_Transaction_SetLocalName(t, s); /* remote account */ s=GWEN_DB_GetCharValue(db, "remoteBankId", 0, 0); if (s && *s) AB_Transaction_SetRemoteBankCode(t, s); s=GWEN_DB_GetCharValue(db, "remoteAccountId", 0, 0); if (s && *s) AB_Transaction_SetRemoteAccountNumber(t, s); s=GWEN_DB_GetCharValue(db, "remoteIban", 0, 0); if (s && *s) AB_Transaction_SetRemoteIban(t, s); else { DBG_ERROR(0, "No remote IBAN given"); AB_Transaction_free(t); return NULL; } s=GWEN_DB_GetCharValue(db, "remoteBic", 0, 0); if (s && *s) AB_Transaction_SetRemoteBic(t, s); else if (strncmp(AB_Transaction_GetLocalIban(t), AB_Transaction_GetRemoteIban(t), 2)) { DBG_ERROR(0, "Remote BIC id required for international transaction"); AB_Transaction_free(t); return NULL; } for (i=0; i<10; i++) { s=GWEN_DB_GetCharValue(db, "remoteName", i, 0); if (!s) break; if (*s) AB_Transaction_AddRemoteName(t, s, 0); } if (i<1) { DBG_ERROR(0, "No remote name given"); AB_Transaction_free(t); return NULL; } /* transfer data */ for (i=0; i<20; i++) { s=GWEN_DB_GetCharValue(db, "purpose", i, 0); if (!s) break; if (*s) AB_Transaction_AddPurpose(t, s, 0); } if (i<1) { DBG_ERROR(0, "No purpose given"); AB_Transaction_free(t); return NULL; } i=GWEN_DB_GetIntValue(db, "textkey", 0, -1); if (i>0) AB_Transaction_SetTextKey(t, i); s=GWEN_DB_GetCharValue(db, "value", 0, 0); if (s && *s) { AB_VALUE *v; v=AB_Value_fromString(s); assert(v); if (AB_Value_IsNegative(v) || AB_Value_IsZero(v)) { DBG_ERROR(0, "Only positive non-zero amount allowed"); AB_Transaction_free(t); return NULL; } AB_Transaction_SetValue(t, v); AB_Value_free(v); } else { DBG_ERROR(0, "No value given"); AB_Transaction_free(t); return NULL; } /* dated transfer, SEPA debit notes */ s=GWEN_DB_GetCharValue(db, "executionDate", 0, 0); if (s && *s) { GWEN_BUFFER *dbuf; dbuf=GWEN_Buffer_new(0, 32, 0, 1); GWEN_Buffer_AppendString(dbuf, s); GWEN_Buffer_AppendString(dbuf, "-00:00"); d=GWEN_Time_fromUtcString(GWEN_Buffer_GetStart(dbuf), "YYYYMMDD-hh:mm"); GWEN_Buffer_free(dbuf); if (d==0) { DBG_ERROR(0, "Invalid execution date value \"%s\"", s); AB_Transaction_free(t); return NULL; } AB_Transaction_SetDate(t, d); GWEN_Time_free(d); } /* standing orders */ s=GWEN_DB_GetCharValue(db, "firstExecutionDate", 0, 0); if (s && *s) { GWEN_BUFFER *dbuf; dbuf=GWEN_Buffer_new(0, 32, 0, 1); GWEN_Buffer_AppendString(dbuf, s); GWEN_Buffer_AppendString(dbuf, "-00:00"); d=GWEN_Time_fromUtcString(GWEN_Buffer_GetStart(dbuf), "YYYYMMDD-hh:mm"); GWEN_Buffer_free(dbuf); if (d==0) { DBG_ERROR(0, "Invalid first execution date value \"%s\"", s); AB_Transaction_free(t); return NULL; } AB_Transaction_SetFirstExecutionDate(t, d); GWEN_Time_free(d); } s=GWEN_DB_GetCharValue(db, "lastExecutionDate", 0, 0); if (s && *s) { GWEN_BUFFER *dbuf; dbuf=GWEN_Buffer_new(0, 32, 0, 1); GWEN_Buffer_AppendString(dbuf, s); GWEN_Buffer_AppendString(dbuf, "-00:00"); d=GWEN_Time_fromUtcString(GWEN_Buffer_GetStart(dbuf), "YYYYMMDD-hh:mm"); GWEN_Buffer_free(dbuf); if (d==0) { DBG_ERROR(0, "Invalid last execution date value \"%s\"", s); AB_Transaction_free(t); return NULL; } AB_Transaction_SetLastExecutionDate(t, d); GWEN_Time_free(d); } if (expTransferType==AB_Job_TypeSepaCreateStandingOrder || expTransferType==AB_Job_TypeSepaModifyStandingOrder) { const char *s; AB_TRANSACTION_PERIOD period=AB_Transaction_PeriodUnknown; /* only needed for standing orders */ s=GWEN_DB_GetCharValue(db, "executionPeriod", 0, 0); if (s && *s) { period=AB_Transaction_Period_fromString(s); if (period==AB_Transaction_PeriodUnknown) { DBG_ERROR(0, "Invalid execution period value \"%s\"", s); AB_Transaction_free(t); return NULL; } } else { DBG_ERROR(0, "Missing execution period value"); return NULL; } AB_Transaction_SetPeriod(t, period); i=GWEN_DB_GetIntValue(db, "executionCycle", 0, -1); if (i <= 0) { DBG_ERROR(0, "Invalid execution cycle value \"%d\"", i); AB_Transaction_free(t); return NULL; } AB_Transaction_SetCycle(t, i); i=GWEN_DB_GetIntValue(db, "executionDay", 0, -1); if (i <= 0 || (period == AB_Transaction_PeriodWeekly && i > 7) || (period == AB_Transaction_PeriodMonthly && i > 30 && (i < 97 || i > 99))) { DBG_ERROR(0, "Invalid execution day value \"%d\"", i); AB_Transaction_free(t); return NULL; } AB_Transaction_SetExecutionDay(t, i); } return t; }
gint gnc_ab_trans_dialog_run_until_ok(GncABTransDialog *td) { gint result; AB_JOB *job; const AB_TRANSACTION_LIMITS *joblimits; guint8 max_purpose_lines; gboolean values_ok; gchar *purpose; gchar *othername; /* Check whether the account supports this job */ job = get_available_empty_job(td->ab_acc, td->trans_type); if (!job) { g_warning("gnc_ab_trans_dialog_run_until_ok: Oops, job not available"); return GTK_RESPONSE_CANCEL; } /* Activate as many purpose entries as available for the job */ joblimits = AB_JobSingleTransfer_GetFieldLimits(job); max_purpose_lines = joblimits ? AB_TransactionLimits_GetMaxLinesPurpose(joblimits) : 2; gtk_widget_set_sensitive(td->purpose_cont_entry, max_purpose_lines > 1); gtk_widget_set_sensitive(td->purpose_cont2_entry, max_purpose_lines > 2); gtk_widget_set_sensitive(td->purpose_cont3_entry, max_purpose_lines > 3); /* Show the dialog */ gtk_widget_show(td->dialog); /* Repeat until entered values make sense */ do { /* Now run the dialog until it gets closed by a button press */ result = gtk_dialog_run (GTK_DIALOG (td->dialog)); /* Was cancel pressed or dialog closed? * GNC_RESPONSE_NOW == execute now * GNC_RESPONSE_LATER == scheduled for later execution (unimplemented) * GTK_RESPONSE_CANCEL == cancel * GTK_RESPONSE_DELETE_EVENT == window destroyed */ if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER) { gtk_widget_destroy(td->dialog); td->dialog = NULL; break; } /* Now fill in the values from the entry fields into a new * AB_TRANSACTION */ td->ab_trans = ab_trans_fill_values(td); values_ok = TRUE; /* Check transaction value */ values_ok = AB_Value_GetValueAsDouble(AB_Transaction_GetValue(td->ab_trans)) != 0.0; if (!values_ok) { gtk_widget_show(td->dialog); if (gnc_verify_dialog( td->dialog, TRUE, "%s", _("The amount is zero or the amount field could not be " "interpreted correctly. You might have mixed up decimal " "point and comma, compared to your locale settings. " "This does not result in a valid online transfer job. \n" "\n" "Do you want to enter the job again?"))) { continue; } else { AB_Transaction_free(td->ab_trans); td->ab_trans = NULL; result = GTK_RESPONSE_CANCEL; break; } } /* Check transaction purpose */ purpose = gnc_ab_get_purpose(td->ab_trans); values_ok = *purpose; g_free(purpose); if (!values_ok) { gtk_widget_show(td->dialog); if (gnc_verify_dialog( td->dialog, TRUE, "%s", _("You did not enter any transaction purpose. A purpose is " "required for an online transfer.\n" "\n" "Do you want to enter the job again?"))) { continue; } else { AB_Transaction_free(td->ab_trans); td->ab_trans = NULL; result = GTK_RESPONSE_CANCEL; break; } } /* Check recipient / remote name */ othername = gnc_ab_get_remote_name(td->ab_trans); values_ok = othername && *othername; g_free(othername); if (!values_ok) { gtk_widget_show(td->dialog); if (gnc_verify_dialog( td->dialog, TRUE, "%s", _("You did not enter a recipient name. A recipient name is " "required for an online transfer.\n" "\n" "Do you want to enter the job again?"))) { continue; } else { AB_Transaction_free(td->ab_trans); td->ab_trans = NULL; result = GTK_RESPONSE_CANCEL; break; } } /* FIXME: If this is a direct debit, set the textkey/ "Textschluessel"/ * transactionCode according to some GUI selection here!! */ /*if (td->trans_type == SINGLE_DEBITNOTE) AB_TRANSACTION_setTextKey (td->hbci_trans, 05); */ /* And finally check the account code, if ktoblzcheck is available */ values_ok = check_ktoblzcheck(td->dialog, td, td->ab_trans); } while (!values_ok); /* Hide the dialog */ if (td->dialog) gtk_widget_hide(td->dialog); return result; }
int sepaTransfer(AB_BANKING *ab, GWEN_DB_NODE *dbArgs, int argc, char **argv) { GWEN_DB_NODE *db; AB_ACCOUNT_SPEC *as; int rv; int rvExec=0; const char *ctxFile; AB_TRANSACTION *t; int noCheck; /* parse command line arguments */ db=_readCommandLine(dbArgs, argc, argv); if (db==NULL) { /* error in command line */ return 1; } /* read arguments */ noCheck=GWEN_DB_GetIntValue(db, "noCheck", 0, 0); ctxFile=GWEN_DB_GetCharValue(db, "ctxfile", 0, 0); /* init AqBanking */ rv=AB_Banking_Init(ab); if (rv) { DBG_ERROR(0, "Error on init (%d)", rv); return 2; } /* get account to work with */ as=getSingleSelectedAccount(ab, db); if (as==NULL) { AB_Banking_Fini(ab); return 2; } /* create transaction from arguments */ t=mkSepaTransfer(db, AB_Transaction_CommandSepaTransfer); if (t==NULL) { DBG_ERROR(0, "Could not create SEPA transaction from arguments"); AB_Transaction_free(t); AB_AccountSpec_free(as); AB_Banking_Fini(ab); return 2; } AB_Transaction_SetUniqueAccountId(t, AB_AccountSpec_GetUniqueId(as)); /* set local account info from selected AB_ACCOUNT_SPEC */ AB_Banking_FillTransactionFromAccountSpec(t, as); /* some checks */ rv=checkTransactionIbans(t); if (rv!=0) { AB_Transaction_free(t); AB_AccountSpec_free(as); AB_Banking_Fini(ab); return rv; } /* probably check against transaction limits */ if (!noCheck) { rv=checkTransactionLimits(t, AB_AccountSpec_GetTransactionLimitsForCommand(as, AB_Transaction_GetCommand(t)), AQBANKING_TOOL_LIMITFLAGS_PURPOSE | AQBANKING_TOOL_LIMITFLAGS_NAMES | AQBANKING_TOOL_LIMITFLAGS_DATE | AQBANKING_TOOL_LIMITFLAGS_SEPA); if (rv!=0) { AB_Transaction_free(t); AB_AccountSpec_free(as); AB_Banking_Fini(ab); return rv; } } AB_AccountSpec_free(as); /* execute job */ rv=execSingleBankingJob(ab, t, ctxFile); if (rv) { fprintf(stderr, "Error on executeQueue (%d)\n", rv); rvExec=rv; } /* cleanup */ AB_Transaction_free(t); /* that's it */ rv=AB_Banking_Fini(ab); if (rv<0) { fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv); if (rvExec==0) rvExec=5; } return rvExec; }
static int addTransaction(AB_BANKING *ab, GWEN_DB_NODE *dbArgs, int argc, char **argv) { GWEN_DB_NODE *db; int rv; AB_JOB_TYPE transferType; const char *ctxFile; const char *bankId; const char *accountId; const char *subAccountId; AB_IMEXPORTER_CONTEXT *ctx=0; AB_ACCOUNT_LIST2 *al; AB_ACCOUNT *a; AB_TRANSACTION *t; const GWEN_ARGS args[]={ { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "ctxFile", /* name */ 0, /* minnum */ 1, /* maxnum */ "c", /* short option */ "ctxfile", /* long option */ "Specify the file to store the context in", /* short description */ "Specify the file to store the context in" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "bankId", /* name */ 0, /* minnum */ 1, /* maxnum */ "b", /* short option */ "bank", /* long option */ "overwrite the bank code", /* short description */ "overwrite the bank code" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "accountId", /* name */ 0, /* minnum */ 1, /* maxnum */ "a", /* short option */ "account", /* long option */ "overwrite the account number", /* short description */ "overwrite the account number" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "subAccountId", /* name */ 0, /* minnum */ 1, /* maxnum */ "aa", /* short option */ "subaccount", /* long option */ "Specify the sub account id (Unterkontomerkmal)", /* short description */ "Specify the sub account id (Unterkontomerkmal)" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "remoteBankId", /* name */ 1, /* minnum */ 1, /* maxnum */ 0, /* short option */ "rbank", /* long option */ "Specify the remote bank code",/* short description */ "Specify the remote bank code" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "remoteAccountId", /* name */ 1, /* minnum */ 1, /* maxnum */ 0, /* short option */ "raccount", /* long option */ "Specify the remote account number", /* short description */ "Specify the remote account number" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "remoteIban", /* name */ 0, /* minnum */ 1, /* maxnum */ 0, /* short option */ "riban", /* long option */ "Specify the remote IBAN", /* short description */ "Specify the remote IBAN" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "remoteBic", /* name */ 0, /* minnum */ 1, /* maxnum */ 0, /* short option */ "rbic", /* long option */ "Specify the remote BIC", /* short description */ "Specify the remote BIC" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "value", /* name */ 1, /* minnum */ 1, /* maxnum */ "v", /* short option */ "value", /* long option */ "Specify the transfer amount", /* short description */ "Specify the transfer amount" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Int, /* type */ "textkey", /* name */ 0, /* minnum */ 1, /* maxnum */ "t", /* short option */ "textkey", /* long option */ "Specify the text key (51 for normal transfer)", /* short description */ "Specify the text key (51 for normal transfer)" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "remoteName", /* name */ 1, /* minnum */ 2, /* maxnum */ 0, /* short option */ "rname", /* long option */ "Specify the remote name", /* short description */ "Specify the remote name" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "purpose", /* name */ 1, /* minnum */ 6, /* maxnum */ "p", /* short option */ "purpose", /* long option */ "Specify the purpose", /* short description */ "Specify the purpose" /* long description */ }, { GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST, /* flags */ GWEN_ArgsType_Int, /* type */ "help", /* name */ 0, /* minnum */ 0, /* maxnum */ "h", /* short option */ "help", /* long option */ "Show this help screen", /* short description */ "Show this help screen" /* long description */ } }; db=GWEN_DB_GetGroup(dbArgs, GWEN_DB_FLAGS_DEFAULT, "local"); rv=GWEN_Args_Check(argc, argv, 1, 0 /*GWEN_ARGS_MODE_ALLOW_FREEPARAM*/, args, db); if (rv==GWEN_ARGS_RESULT_ERROR) { fprintf(stderr, "ERROR: Could not parse arguments\n"); return 1; } else if (rv==GWEN_ARGS_RESULT_HELP) { GWEN_BUFFER *ubuf; ubuf=GWEN_Buffer_new(0, 1024, 0, 1); if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) { fprintf(stderr, "ERROR: Could not create help string\n"); return 1; } fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf)); GWEN_Buffer_free(ubuf); return 0; } bankId=GWEN_DB_GetCharValue(db, "bankId", 0, 0); accountId=GWEN_DB_GetCharValue(db, "accountId", 0, 0); subAccountId=GWEN_DB_GetCharValue(db, "subAccountId", 0, 0); rv=AB_Banking_Init(ab); if (rv) { DBG_ERROR(0, "Error on init (%d)", rv); return 2; } rv=AB_Banking_OnlineInit(ab); if (rv) { DBG_ERROR(0, "Error on init (%d)", rv); return 2; } /* get account */ al=AB_Banking_FindAccounts(ab, "*", "*", bankId, accountId, subAccountId); if (al==NULL || AB_Account_List2_GetSize(al)==0) { DBG_ERROR(0, "Account not found"); AB_Account_List2_free(al); return 2; } else if (AB_Account_List2_GetSize(al)>1) { DBG_ERROR(0, "Ambiguous account specification"); AB_Account_List2_free(al); return 2; } a=AB_Account_List2_GetFront(al); AB_Account_List2_free(al); /* create transaction from arguments */ t=mkTransfer(a, db, &transferType); if (t==NULL) { DBG_ERROR(0, "Could not create transaction from arguments"); return 2; } ctxFile=GWEN_DB_GetCharValue(db, "ctxfile", 0, 0); rv=readContext(ctxFile, &ctx, 0); if (rv<0) { DBG_ERROR(0, "Error reading context (%d)", rv); AB_Transaction_free(t); return 4; } AB_ImExporterContext_AddTransaction(ctx, t); rv=writeContext(ctxFile, ctx); AB_ImExporterContext_free(ctx); if (rv<0) { DBG_ERROR(0, "Error writing context (%d)", rv); return 4; } /* that's it */ rv=AB_Banking_OnlineFini(ab); if (rv) { fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv); AB_Banking_Fini(ab); return 5; } rv=AB_Banking_Fini(ab); if (rv) { fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv); return 5; } return 0; }