gchar * gnc_ab_description_to_gnc(const AB_TRANSACTION *ab_trans) { /* Description */ gchar *description = gnc_ab_get_purpose(ab_trans); gchar *other_name = gnc_ab_get_remote_name(ab_trans); gchar *retval; if (other_name) { if (description && *description) { retval = g_strdup_printf("%s; %s", description, other_name); } else { retval = g_strdup(other_name); } } else { if (description && *description) { retval = g_strdup(description); } else { retval = g_strdup(_("Unspecified")); } } g_free(description); g_free(other_name); return retval; }
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; }