34 #include <glib/gi18n.h> 35 #include <aqbanking/banking.h> 36 # include <aqbanking/types/transaction.h> 38 #include "dialog-ab-daterange.h" 39 #include "gnc-ab-gettrans.h" 45 G_GNUC_UNUSED
static QofLogModule log_module =
G_LOG_DOMAIN;
47 static gboolean gettrans_dates(GtkWidget *parent,
Account *gnc_acc, GWEN_TIME **from_date, GWEN_TIME **to_date);
50 gettrans_dates(GtkWidget *parent,
Account *gnc_acc,
51 GWEN_TIME **from_date, GWEN_TIME **to_date)
54 gboolean use_last_date = TRUE;
55 gboolean use_earliest_date = TRUE;
56 gboolean use_until_now = TRUE;
58 g_return_val_if_fail(from_date && to_date, FALSE);
64 use_last_date = FALSE;
72 &use_last_date, &use_earliest_date,
73 &until, &use_until_now))
77 if (use_earliest_date)
85 *from_date = GWEN_Time_fromSeconds(last);
91 *to_date = GWEN_Time_fromSeconds(until);
100 GNC_AB_ACCOUNT_SPEC *ab_acc;
101 GWEN_TIME *from_date = NULL, *to_date = NULL;
103 GNC_AB_JOB *job = NULL;
104 GNC_AB_JOB_LIST2 *job_list = NULL;
105 GncGWENGui *gui = NULL;
106 AB_IMEXPORTER_CONTEXT *context = NULL;
107 GncABImExContextImport *ieci = NULL;
108 GNC_AB_JOB_STATUS job_status;
110 g_return_if_fail(parent && gnc_acc);
116 g_warning(
"gnc_ab_gettrans: Couldn't get AqBanking API");
123 g_warning(
"gnc_ab_gettrans: No AqBanking account found");
124 gnc_error_dialog (GTK_WINDOW (parent), _(
"No valid online banking account assigned."));
129 if (!gettrans_dates(parent, gnc_acc, &from_date, &to_date))
131 DEBUG(
"gnc_ab_gettrans: gettrans_dates aborted");
135 until = GWEN_Time_toTime_t(to_date);
138 if (!AB_AccountSpec_GetTransactionLimitsForCommand(ab_acc, AB_Transaction_CommandGetTransactions))
140 g_warning(
"gnc_ab_gettrans: JobGetTransactions not available for this " 142 gnc_error_dialog (GTK_WINDOW (parent), _(
"Online action \"Get Transactions\" not available for this account."));
145 job = AB_Transaction_new();
146 AB_Transaction_SetCommand(job, AB_Transaction_CommandGetTransactions);
147 AB_Transaction_SetUniqueAccountId(job, AB_AccountSpec_GetUniqueId(ab_acc));
153 dt=GWEN_Date_fromLocalTime(GWEN_Time_toTime_t(from_date));
154 AB_Transaction_SetFirstDate(job, dt);
162 dt=GWEN_Date_fromLocalTime(GWEN_Time_toTime_t(to_date));
163 AB_Transaction_SetLastDate(job, dt);
167 job_list = AB_Transaction_List2_new();
168 AB_Transaction_List2_PushBack(job_list, job);
173 g_warning(
"gnc_ab_gettrans: Couldn't initialize Gwenhywfar GUI");
178 context = AB_ImExporterContext_new();
181 AB_Banking_SendCommands(api, job_list, context);
188 job_status = AB_Transaction_GetStatus(job);
189 if (job_status != AB_Transaction_StatusAccepted
190 && job_status != AB_Transaction_StatusPending)
192 g_warning(
"gnc_ab_gettrans: Error on executing job");
193 gnc_error_dialog (GTK_WINDOW (parent),
194 _(
"Error on executing job.\n\nStatus: %s (%d)"),
195 AB_Transaction_Status_toString(job_status),
206 GtkWidget *dialog = gtk_message_dialog_new(
208 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
212 _(
"The Online Banking import returned no transactions " 213 "for the selected time period."));
214 gtk_dialog_run(GTK_DIALOG(dialog));
215 gtk_widget_destroy(dialog);
225 AB_ImExporterContext_free(context);
229 AB_Transaction_List2_free(job_list);
231 AB_Transaction_free(job);
233 GWEN_Time_free(to_date);
235 GWEN_Time_free(from_date);
time64 gnc_ab_get_account_trans_retrieval(const Account *a)
Return the time of last online transaction retrieval for Account a.
void gnc_ab_set_account_trans_retrieval(Account *a, time64 time)
Set the time of last online transaction retrieval for Account a.
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
#define DEBUG(format, args...)
Print a debugging message.
GncGWENGui * gnc_GWEN_Gui_get(GtkWidget *parent)
When called for the first time, create a unique GncGWENGui object featuring a GWEN_GUI with all neces...
Account handling public routines.
void gnc_GWEN_Gui_release(GncGWENGui *gui)
Currently a no-op.
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
gboolean gnc_ab_enter_daterange(GtkWidget *parent, const char *heading, time64 *from_date, gboolean *last_retv_date, gboolean *first_possible_date, time64 *to_date, gboolean *to_now)
Show a dialog to pick a time frame using a sensible set of default options.
GncABImExContextImport * gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context, guint awaiting, gboolean execute_txns, AB_BANKING *api, GtkWidget *parent)
Import balances and transactions found in a AB_IMEXPORTER_CONTEXT into GnuCash.
GNC_AB_ACCOUNT_SPEC * gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
Get the corresponding AqBanking account to the GnuCash account gnc_acc.
time64 gnc_time(time64 *tbuf)
get the current time
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
GUI callbacks for AqBanking.
guint gnc_ab_ieci_get_found(GncABImExContextImport *ieci)
Extract awaiting from data.
void gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc)
Execute a GetTransactions job.
AqBanking utility functions.