static const AB_TRANSACTION * translist_cb (const AB_TRANSACTION *element, void *user_data) { AB_JOB *job; AB_TRANSACTION *trans = (AB_TRANSACTION*)element; GtkWidget *parent = NULL; struct import_data *data = user_data; struct trans_list_data hbci_userdata; /* This callback in the hbci module will add the imported transaction to gnucash's importer. */ hbci_userdata.gnc_acc = data->gnc_acc; hbci_userdata.importer_generic = data->importer_generic; /* The call will use "trans" only as const* */ gnc_hbci_trans_list_cb((AB_TRANSACTION*) trans, &hbci_userdata); if (data->hbci_account) { /* NEW: The imported transaction has been imported into gnucash. Now also add it as a job to aqbanking. */ AB_Transaction_SetLocalBankCode (trans, AB_Account_GetBankCode (data->hbci_account)); AB_Transaction_SetLocalAccountNumber (trans, AB_Account_GetAccountNumber (data->hbci_account)); AB_Transaction_SetLocalCountry (trans, "DE"); job = gnc_hbci_trans_dialog_enqueue(trans, data->ab, data->hbci_account, SINGLE_DEBITNOTE); /* Check whether we really got a job */ if (!job) { /* Oops, no job, probably not supported by bank. */ if (gnc_verify_dialog (parent, FALSE, "%s", _("The backend found an error during the preparation " "of the job. It is not possible to execute this job. \n" "\n" "Most probable 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 (parent, "Sorry, not implemented yet."); } /* else break; */ } data->job_list = g_list_append(data->job_list, job); } return NULL; }
/** * Create a new AB_TRANSACTION, fill the values from the entry fields into it * and return it. The caller must AB_TRANSACTION_free() it when finished. */ static AB_TRANSACTION * ab_trans_fill_values(GncABTransDialog *td) { /* Fill in the user-entered values */ AB_TRANSACTION *trans = AB_Transaction_new(); AB_VALUE *value; AB_Transaction_SetLocalBankCode(trans, AB_Account_GetBankCode(td->ab_acc)); AB_Transaction_SetLocalAccountNumber( trans, AB_Account_GetAccountNumber(td->ab_acc)); AB_Transaction_SetLocalCountry(trans, "DE"); AB_Transaction_SetRemoteBankCode( trans, gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry))); AB_Transaction_SetRemoteAccountNumber( trans, gtk_entry_get_text(GTK_ENTRY(td->recp_account_entry))); AB_Transaction_SetRemoteCountry(trans, "DE"); AB_Transaction_AddRemoteName( trans, gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry)), FALSE); AB_Transaction_AddPurpose( trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_entry)), FALSE); AB_Transaction_AddPurpose( trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont_entry)), FALSE); AB_Transaction_AddPurpose( trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont2_entry)), FALSE); AB_Transaction_AddPurpose( trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont3_entry)), FALSE); value = AB_Value_fromDouble(gnc_amount_edit_get_damount( GNC_AMOUNT_EDIT(td->amount_edit))); /* FIXME: Replace "EUR" by account-dependent string here. */ AB_Value_SetCurrency(value, "EUR"); AB_Transaction_SetValue(trans, value); AB_Value_free(value); /* If this is a direct debit, a textkey/ "Textschluessel"/transactionCode * different from the default has to be set. */ switch (td->trans_type) { case SINGLE_DEBITNOTE: /* AB_Transaction_SetTransactionCode (trans, 05); */ AB_Transaction_SetTextKey(trans, 05); break; default: /* AB_Transaction_SetTransactionCode (trans, 51); */ AB_Transaction_SetTextKey (trans, 51); break; } return trans; }
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; }