/* Constructor */ GNCImportSettings * gnc_import_Settings_new (void) { GNCImportSettings * settings; settings = g_new0 ( GNCImportSettings, 1); settings->action_skip_enabled = gnc_gconf_get_bool(GCONF_IMPORT_SECTION, "enable_skip", NULL); settings->action_update_enabled = gnc_gconf_get_bool(GCONF_IMPORT_SECTION, "enable_update", NULL); settings->action_add_enabled = DEFAULT_ACTION_ADD_ENABLED; settings->action_clear_enabled = DEFAULT_ACTION_CLEAR_ENABLED; settings->clear_threshold = (int)gnc_gconf_get_float(GCONF_IMPORT_SECTION, "auto_clear_threshold", NULL); settings->add_threshold = (int)gnc_gconf_get_float(GCONF_IMPORT_SECTION, "auto_add_threshold", NULL); settings->display_threshold = (int)gnc_gconf_get_float(GCONF_IMPORT_SECTION, "match_threshold", NULL); settings->fuzzy_amount = gnc_gconf_get_float(GCONF_IMPORT_SECTION, "atm_fee_threshold", NULL); settings->match_date_hardlimit = 42; /* 6 weeks */ return settings; }
static void gnc_plugin_page_invoice_init (GncPluginPageInvoice *plugin_page) { GncPluginPage *parent; GtkActionGroup *action_group; gboolean use_new; /* Init parent declared variables */ parent = GNC_PLUGIN_PAGE(plugin_page); use_new = gnc_gconf_get_bool(GCONF_SECTION_INVOICE, KEY_USE_NEW, NULL); g_object_set(G_OBJECT(plugin_page), "page-name", _("Invoice"), "page-uri", "default:", "ui-description", "gnc-plugin-page-invoice-ui.xml", "use-new-window", use_new, (char *)NULL); /* change me when the system supports multiple books */ gnc_plugin_page_add_book(parent, gnc_get_current_book()); /* Create menu and toolbar information */ action_group = gnc_plugin_page_create_action_group(parent, "GncPluginPageInvoiceActions"); gtk_action_group_add_actions (action_group, gnc_plugin_page_invoice_actions, gnc_plugin_page_invoice_n_actions, plugin_page); gtk_action_group_add_radio_actions (action_group, radio_entries, n_radio_entries, REG_STYLE_LEDGER, G_CALLBACK(gnc_plugin_page_invoice_cmd_sort_changed), plugin_page); gnc_plugin_init_short_names (action_group, toolbar_labels); }
/********************************************************************\ * gnc_get_credit_string * * return a credit string for a given account type * * * * Args: account_type - type of account to get credit string for * * Return: g_malloc'd credit string or NULL * \********************************************************************/ char * gnc_get_credit_string(GNCAccountType account_type) { const gchar *string; SCM result; SCM arg; initialize_scm_functions(); if (gnc_gconf_get_bool(GCONF_GENERAL, KEY_ACCOUNTING_LABELS, NULL)) return g_strdup(_("Credit")); if ((account_type < ACCT_TYPE_NONE) || (account_type >= NUM_ACCOUNT_TYPES)) account_type = ACCT_TYPE_NONE; arg = scm_long2num(account_type); result = scm_call_1(getters.credit_string, arg); if (!scm_is_string(result)) return NULL; string = scm_to_locale_string(result); if (string) return g_strdup(string); return NULL; }
static void gnc_commodities_dialog_create (GtkWidget * parent, CommoditiesDialog *cd) { GtkWidget *button; GtkWidget *scrolled_window; GtkBuilder *builder; GtkTreeView *view; GtkTreeSelection *selection; builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-commodities.glade", "Securities Dialog"); cd->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Securities Dialog")); cd->session = gnc_get_current_session(); cd->book = qof_session_get_book(cd->session); cd->show_currencies = gnc_gconf_get_bool(GCONF_SECTION, "include_iso", NULL); gtk_builder_connect_signals(builder, cd); /* parent */ if (parent != NULL) gtk_window_set_transient_for (GTK_WINDOW (cd->dialog), GTK_WINDOW (parent)); /* buttons */ cd->remove_button = GTK_WIDGET(gtk_builder_get_object (builder, "remove_button")); cd->edit_button = GTK_WIDGET(gtk_builder_get_object (builder, "edit_button")); /* commodity tree */ scrolled_window = GTK_WIDGET(gtk_builder_get_object (builder, "commodity_list_window")); view = gnc_tree_view_commodity_new(cd->book, "gconf-section", GCONF_SECTION, "show-column-menu", TRUE, NULL); cd->commodity_tree = GNC_TREE_VIEW_COMMODITY(view); gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(view)); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(cd->commodity_tree), TRUE); gnc_tree_view_commodity_set_filter (cd->commodity_tree, gnc_commodities_dialog_filter_ns_func, gnc_commodities_dialog_filter_cm_func, cd, NULL); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (gnc_commodities_dialog_selection_changed), cd); g_signal_connect (G_OBJECT (cd->commodity_tree), "row-activated", G_CALLBACK (row_activated_cb), cd); /* Show currency button */ button = GTK_WIDGET(gtk_builder_get_object (builder, "show_currencies_button")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), cd->show_currencies); g_object_unref(G_OBJECT(builder)); gnc_restore_window_size (GCONF_SECTION, GTK_WINDOW(cd->dialog)); }
static void reset_dialog(GncGWENGui *gui) { gboolean cache_passwords; g_return_if_fail(gui); ENTER("gui=%p", gui); gtk_entry_set_text(GTK_ENTRY(gui->top_entry), ""); gtk_entry_set_text(GTK_ENTRY(gui->second_entry), ""); g_list_foreach(gui->progresses, (GFunc) free_progress, NULL); g_list_free(gui->progresses); gui->progresses = NULL; if (gui->other_entries_box) { gtk_table_resize(GTK_TABLE(gui->entries_table), OTHER_ENTRIES_ROW_OFFSET, 2); gtk_widget_destroy(gui->other_entries_box); gui->other_entries_box = NULL; } if (gui->showbox_hash) g_hash_table_destroy(gui->showbox_hash); gui->showbox_last = NULL; gui->showbox_hash = g_hash_table_new_full( NULL, NULL, NULL, (GDestroyNotify) gtk_widget_destroy); if (gui->parent) gtk_window_set_transient_for(GTK_WINDOW(gui->dialog), GTK_WINDOW(gui->parent)); gnc_restore_window_size(GCONF_SECTION_CONNECTION, GTK_WINDOW(gui->dialog)); gui->keep_alive = TRUE; gui->state = INIT; gui->min_loglevel = GWEN_LoggerLevel_Verbous; cache_passwords = gnc_gconf_get_bool(GCONF_SECTION_AQBANKING, KEY_REMEMBER_PIN, NULL); enable_password_cache(gui, cache_passwords); if (!gui->accepted_certs) gui->accepted_certs = g_hash_table_new_full( g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL); if (!gui->permanently_accepted_certs) gui->permanently_accepted_certs = gnc_ab_get_permanent_certs(); LEAVE(" "); }
static void setup_dialog(GncGWENGui *gui) { GladeXML *xml; gint component_id; g_return_if_fail(gui); ENTER("gui=%p", gui); xml = gnc_glade_xml_new("aqbanking.glade", "Connection Dialog"); gui->dialog = glade_xml_get_widget(xml, "Connection Dialog"); g_object_set_data_full(G_OBJECT(gui->dialog), "xml", xml, g_object_unref); glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, gui); gui->entries_table = glade_xml_get_widget(xml, "entries_table"); gui->top_entry = glade_xml_get_widget(xml, "top_entry"); gui->top_progress = glade_xml_get_widget(xml, "top_progress"); gui->second_entry = glade_xml_get_widget(xml, "second_entry"); gui->other_entries_box = NULL; gui->progresses = NULL; gui->log_text = glade_xml_get_widget(xml, "log_text"); gui->abort_button = glade_xml_get_widget(xml, "abort_button"); gui->close_button = glade_xml_get_widget(xml, "close_button"); gui->close_checkbutton = glade_xml_get_widget(xml, "close_checkbutton"); gui->accepted_certs = NULL; gui->permanently_accepted_certs = NULL; gui->showbox_hash = NULL; gui->showbox_id = 1; gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(gui->close_checkbutton), gnc_gconf_get_bool(GCONF_SECTION_AQBANKING, KEY_CLOSE_ON_FINISH, NULL)); component_id = gnc_register_gui_component(GWEN_GUI_CM_CLASS, NULL, cm_close_handler, gui); gnc_gui_component_set_session(component_id, gnc_get_current_session()); reset_dialog(gui); LEAVE(" "); }
void gnc_sx_sxsincelast_book_opened(void) { GList *auto_created_txns = NULL; GncSxInstanceModel *inst_model; GncSxSummary summary; if (!gnc_gconf_get_bool(GCONF_SECTION, "show_at_file_open", NULL)) return; inst_model = gnc_sx_get_current_instances(); gnc_sx_instance_model_summarize(inst_model, &summary); gnc_sx_summary_print(&summary); gnc_sx_instance_model_effect_change(inst_model, TRUE, &auto_created_txns, NULL); if (summary.need_dialog) { gnc_ui_sx_since_last_run_dialog(inst_model, auto_created_txns); auto_created_txns = NULL; } else { if (summary.num_auto_create_no_notify_instances != 0) { gnc_info_dialog (NULL, ngettext ("There are no Scheduled Transactions to be entered at this time. " "(%d transaction automatically created)", "There are no Scheduled Transactions to be entered at this time. " "(%d transactions automatically created)", summary.num_auto_create_no_notify_instances), summary.num_auto_create_no_notify_instances); } } g_list_free(auto_created_txns); g_object_unref(G_OBJECT(inst_model)); }
/* XXX This code is a cut-n-paste job from the SplitRegister code; * the split-register should be generalized to the point where a cut-n-paste * like this isn't required, and this should be trashed. */ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list) { GncEntry *blank_entry, *find_entry; CursorBuffer *cursor_buffer; Table *table; GList *node; CellBlock *cursor_header, *cursor; VirtualCellLocation vcell_loc; VirtualLocation save_loc; gboolean start_primary_color = TRUE; int new_entry_row = -1; if (!ledger) return; /* Load up cells */ load_discount_type_cells (ledger); load_discount_how_cells (ledger); gnc_entry_ledger_load_xfer_cells (ledger); blank_entry = gnc_entry_ledger_get_blank_entry (ledger); if (blank_entry == NULL && ledger->invoice == NULL && entry_list == NULL) return; if (blank_entry == NULL && ledger->invoice) { switch (ledger->type) { case GNCENTRY_ORDER_ENTRY: case GNCENTRY_INVOICE_ENTRY: case GNCENTRY_BILL_ENTRY: case GNCENTRY_EXPVOUCHER_ENTRY: case GNCENTRY_CUST_CREDIT_NOTE_ENTRY: case GNCENTRY_VEND_CREDIT_NOTE_ENTRY: case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY: gnc_suspend_gui_refresh (); blank_entry = gncEntryCreate (ledger->book); gncEntrySetDateGDate (blank_entry, &ledger->last_date_entered); ledger->blank_entry_guid = *gncEntryGetGUID (blank_entry); gnc_resume_gui_refresh (); /* The rest of this does not apply to expense vouchers */ if (ledger->type != GNCENTRY_EXPVOUCHER_ENTRY) { const GncOwner *owner = gncOwnerGetEndOwner (gncInvoiceGetOwner (ledger->invoice)); GncTaxTable *table = NULL; GncTaxIncluded taxincluded_p = GNC_TAXINCLUDED_USEGLOBAL; gboolean taxincluded = FALSE; gnc_numeric discount = gnc_numeric_zero (); /* Determine the TaxIncluded and Discount values */ switch (gncOwnerGetType (owner)) { case GNC_OWNER_CUSTOMER: taxincluded_p = gncCustomerGetTaxIncluded (owner->owner.customer); discount = gncCustomerGetDiscount (owner->owner.customer); break; case GNC_OWNER_VENDOR: taxincluded_p = gncVendorGetTaxIncluded (owner->owner.vendor); break; default: break; } /* Compute the default taxincluded */ switch (taxincluded_p) { case GNC_TAXINCLUDED_YES: taxincluded = TRUE; break; case GNC_TAXINCLUDED_NO: taxincluded = FALSE; break; case GNC_TAXINCLUDED_USEGLOBAL: if (ledger->gconf_section) { taxincluded = gnc_gconf_get_bool(ledger->gconf_section, "tax_included", NULL); } else { taxincluded = FALSE; } break; } /* Compute the proper taxtable */ switch (gncOwnerGetType (owner)) { case GNC_OWNER_CUSTOMER: // table = gnc_option_db_lookup_taxtable_option (odb, // "Business", // "Default Customer TaxTable", // NULL); // // if (gncCustomerGetTaxTableOverride (owner->owner.customer)) table = gncCustomerGetTaxTable (owner->owner.customer); break; case GNC_OWNER_VENDOR: // table = gnc_option_db_lookup_taxtable_option (odb, // "Business", // "Default Vendor TaxTable", // NULL); // // if (gncVendorGetTaxTableOverride (owner->owner.vendor)) table = gncVendorGetTaxTable (owner->owner.vendor); break; default: break; } if (ledger->is_cust_doc) { gncEntrySetInvTaxTable (blank_entry, table); gncEntrySetInvTaxIncluded (blank_entry, taxincluded); gncEntrySetInvDiscount (blank_entry, discount); } else { gncEntrySetBillTaxTable (blank_entry, table); gncEntrySetBillTaxIncluded (blank_entry, taxincluded); } } break; default: ledger->blank_entry_guid = *guid_null (); break; } ledger->blank_entry_edited = FALSE; } table = ledger->table; gnc_table_leave_update (table, table->current_cursor_loc); save_loc = table->current_cursor_loc; /* Figure out where we are going to */ if (ledger->traverse_to_new) { find_entry = blank_entry; } else if (ledger->hint_entry) { find_entry = ledger->hint_entry; } else { find_entry = gnc_entry_ledger_get_current_entry(ledger); /* XXX: get current entry (cursor_hint_xxx) */ } /* If the current cursor has changed we save the values for later * possible restoration. */ if (gnc_table_current_cursor_changed (table, TRUE) && (find_entry == gnc_entry_ledger_get_current_entry (ledger))) { cursor_buffer = gnc_cursor_buffer_new (); gnc_table_save_current_cursor (table, cursor_buffer); } else cursor_buffer = NULL; /* disable move callback -- we don't want the cascade of * callbacks while we are fiddling with loading the register */ gnc_table_control_allow_move (table->control, FALSE); /* invalidate the cursor */ { VirtualLocation virt_loc; virt_loc.vcell_loc.virt_row = -1; virt_loc.vcell_loc.virt_col = -1; virt_loc.phys_row_offset = -1; virt_loc.phys_col_offset = -1; gnc_table_move_cursor_gui (table, virt_loc); } /* make sure that the header is loaded */ vcell_loc.virt_row = 0; vcell_loc.virt_col = 0; cursor_header = gnc_table_layout_get_cursor (table->layout, CURSOR_HEADER); gnc_table_set_vcell (table, cursor_header, NULL, TRUE, TRUE, vcell_loc); vcell_loc.virt_row++; /* get the current time and reset the dividing row */ table->model->dividing_row_upper = -1; table->model->dividing_row = -1; cursor = gnc_table_layout_get_cursor (table->layout, "cursor"); /* Populate the table */ for (node = entry_list; node; node = node->next) { GncEntry *entry = node->data; /* Don't load the blank entry */ if (entry == blank_entry) continue; /* If this is the first load of the ledger, fill the quickfill cells */ { /* XXX */ } if (entry == find_entry) new_entry_row = vcell_loc.virt_row; gnc_table_set_vcell (table, cursor, gncEntryGetGUID (entry), TRUE, start_primary_color, vcell_loc); vcell_loc.virt_row++; /* Flip color for the next guy */ start_primary_color = !start_primary_color; } /* Add the blank entry at the end. */ if (blank_entry) { gnc_table_set_vcell (table, cursor, gncEntryGetGUID (blank_entry), TRUE, start_primary_color, vcell_loc); if (find_entry == blank_entry) new_entry_row = vcell_loc.virt_row; vcell_loc.virt_row++; } /* Resize the table */ gnc_table_set_size (table, vcell_loc.virt_row, 1); /* Restore the cursor to its rightful position */ if (new_entry_row > 0) save_loc.vcell_loc.virt_row = new_entry_row; if (gnc_table_find_close_valid_cell (table, &save_loc, FALSE)) { gnc_table_move_cursor_gui (table, save_loc); if (find_entry == gnc_entry_ledger_get_current_entry (ledger)) gnc_table_restore_current_cursor (table, cursor_buffer); } gnc_cursor_buffer_destroy (cursor_buffer); cursor_buffer = NULL; /* Reset the ledger */ ledger->traverse_to_new = FALSE; ledger->hint_entry = NULL; /* Set the cell fractions */ gnc_table_refresh_gui (table, TRUE); gnc_entry_ledger_show_entry (ledger, table->current_cursor_loc.vcell_loc); /* Set completion character */ gnc_combo_cell_set_complete_char ((ComboCell *) gnc_table_layout_get_cell (table->layout, ENTRY_IACCT_CELL), gnc_get_account_separator ()); gnc_combo_cell_set_complete_char ((ComboCell *) gnc_table_layout_get_cell (table->layout, ENTRY_BACCT_CELL), gnc_get_account_separator ()); /* enable callback for cursor user-driven moves */ gnc_table_control_allow_move (table->control, TRUE); }
static void gnc_main_window_summary_refresh (GNCMainSummary * summary) { Account *root; char asset_string[256]; char profit_string[256]; GNCCurrencyAcc *currency_accum; GList *currency_list; GList *current; GNCSummarybarOptions options; root = gnc_get_current_root_account (); options.default_currency = xaccAccountGetCommodity(root); if(options.default_currency == NULL) { options.default_currency = gnc_default_currency (); } options.euro = gnc_gconf_get_bool(GCONF_GENERAL, KEY_ENABLE_EURO, NULL); options.grand_total = gnc_gconf_get_bool(GCONF_SECTION, KEY_GRAND_TOTAL, NULL); options.non_currency = gnc_gconf_get_bool(GCONF_SECTION, KEY_NON_CURRENCY, NULL); options.start_date = gnc_accounting_period_fiscal_start(); options.end_date = gnc_accounting_period_fiscal_end(); currency_list = NULL; /* grand total should be first in the list */ if (options.grand_total) { gnc_ui_get_currency_accumulator (¤cy_list, options.default_currency, TOTAL_GRAND_TOTAL); } /* Make sure there's at least one accumulator in the list. */ gnc_ui_get_currency_accumulator (¤cy_list, options.default_currency, TOTAL_SINGLE); gnc_ui_accounts_recurse(root, ¤cy_list, options); { GtkTreeIter iter; char asset_amount_string[256], profit_amount_string[256]; struct lconv *lc; lc = gnc_localeconv(); g_object_ref(summary->datamodel); gtk_combo_box_set_model(GTK_COMBO_BOX(summary->totals_combo), NULL); gtk_list_store_clear(summary->datamodel); for (current = g_list_first(currency_list); current; current = g_list_next(current)) { const char *mnemonic; gchar *total_mode_label; currency_accum = current->data; if (gnc_commodity_equiv (currency_accum->currency, gnc_locale_default_currency ())) mnemonic = lc->currency_symbol; else mnemonic = gnc_commodity_get_mnemonic (currency_accum->currency); if (mnemonic == NULL) mnemonic = ""; *asset_string = '\0'; xaccSPrintAmount(asset_amount_string, currency_accum->assets, gnc_commodity_print_info(currency_accum->currency, TRUE)); *profit_string = '\0'; xaccSPrintAmount(profit_amount_string, currency_accum->profits, gnc_commodity_print_info(currency_accum->currency, TRUE)); gtk_list_store_append(summary->datamodel, &iter); total_mode_label = get_total_mode_label(mnemonic, currency_accum->total_mode); gtk_list_store_set(summary->datamodel, &iter, COLUMN_MNEMONIC_TYPE, total_mode_label, COLUMN_ASSETS, _("Net Assets:"), COLUMN_ASSETS_VALUE, asset_amount_string, COLUMN_PROFITS, _("Profits:"), COLUMN_PROFITS_VALUE, profit_amount_string, -1); g_free(total_mode_label); } gtk_combo_box_set_model(GTK_COMBO_BOX(summary->totals_combo), GTK_TREE_MODEL(summary->datamodel)); g_object_unref(summary->datamodel); gtk_combo_box_set_active(GTK_COMBO_BOX(summary->totals_combo), 0); } /* Free the list we created for this */ for (current = g_list_first(currency_list); current; current = g_list_next(current)) { g_free(current->data); } g_list_free(currency_list); }
static void inner_main (void *closure, int argc, char **argv) { SCM main_mod; char* fn; GError *error = NULL; scm_c_eval_string("(debug-set! stack 200000)"); main_mod = scm_c_resolve_module("gnucash main"); scm_set_current_module(main_mod); load_gnucash_modules(); /* Load the config before starting up the gui. This insures that * custom reports have been read into memory before the Reports * menu is created. */ load_system_config(); load_user_config(); /* Setting-up the report menu must come after the module loading but before the gui initialization. */ scm_c_use_module("gnucash report report-gnome"); scm_c_eval_string("(gnc:report-menu-setup)"); /* TODO: After some more guile-extraction, this should happen even before booting guile. */ gnc_main_gui_init(); gnc_hook_add_dangler(HOOK_UI_SHUTDOWN, (GFunc)gnc_file_quit, NULL); scm_c_eval_string("(gnc:main)"); /* Install Price Quote Sources */ gnc_update_splash_screen(_("Checking Finance::Quote..."), GNC_SPLASH_PERCENTAGE_UNKNOWN); scm_c_use_module("gnucash price-quotes"); scm_c_eval_string("(gnc:price-quotes-install-sources)"); gnc_hook_run(HOOK_STARTUP, NULL); if (!nofile && (fn = get_file_to_load())) { gnc_update_splash_screen(_("Loading data..."), GNC_SPLASH_PERCENTAGE_UNKNOWN); gnc_file_open_file(fn); g_free(fn); } else if (gnc_gconf_get_bool("dialogs/new_user", "first_startup", &error) && !error) { gnc_destroy_splash_screen(); gnc_ui_new_user_dialog(); } gnc_destroy_splash_screen(); gnc_main_window_show_all_windows(); gnc_hook_run(HOOK_UI_POST_STARTUP, NULL); gnc_ui_start_event_loop(); gnc_hook_remove_dangler(HOOK_UI_SHUTDOWN, (GFunc)gnc_file_quit); gnc_shutdown(0); return; }
static guint sxftd_compute_sx(SXFromTransInfo *sxfti) { GtkWidget *w; gchar *name; GDate date; GList *schedule = NULL; getEndTuple end_info; guint sxftd_errno = 0; /* 0 == OK, > 0 means dialog needs to be run again */ SchedXaction *sx = sxfti->sx; /* get the name */ w = glade_xml_get_widget(sxfti->gxml, SXFTD_NAME_ENTRY); name = gtk_editable_get_chars(GTK_EDITABLE(w), 0, -1); xaccSchedXactionSetName(sx, name); g_free(name); g_date_set_time_t( &date, gnc_date_edit_get_date( sxfti->startDateGDE ) ); sxftd_update_schedule(sxfti, &date, &schedule); if (sxftd_errno == 0) { gnc_sx_set_schedule(sx, schedule); xaccSchedXactionSetStartDate( sx, &date ); } end_info = sxftd_get_end_info(sxfti); switch (end_info.type) { case NEVER_END: break; case END_ON_DATE: xaccSchedXactionSetEndDate(sx, &(end_info.end_date)); break; case END_AFTER_N_OCCS: xaccSchedXactionSetNumOccur(sx, end_info.n_occurrences); break; default: sxftd_errno = 2; break; } gnc_sx_set_instance_count( sx, 1 ); /* Set the autocreate, days-in-advance and remind-in-advance values from * options. */ { gboolean autoCreateState, notifyState; gint daysInAdvance; autoCreateState = gnc_gconf_get_bool( SXED_GCONF_SECTION, KEY_CREATE_AUTO, NULL ); notifyState = gnc_gconf_get_bool( SXED_GCONF_SECTION, KEY_NOTIFY, NULL ); xaccSchedXactionSetAutoCreate( sx, autoCreateState, (autoCreateState & notifyState) ); daysInAdvance = gnc_gconf_get_float( SXED_GCONF_SECTION, KEY_CREATE_DAYS, NULL ); xaccSchedXactionSetAdvanceCreation( sx, daysInAdvance ); daysInAdvance = gnc_gconf_get_float( SXED_GCONF_SECTION, KEY_REMIND_DAYS, NULL ); xaccSchedXactionSetAdvanceReminder( sx, daysInAdvance ); } if ( sxftd_add_template_trans( sxfti ) != 0 ) { sxftd_errno = SXFTD_ERRNO_UNBALANCED_XACTION; } return sxftd_errno; }
gboolean gnc_gconf_get_bool_no_error (const gchar *section, const gchar *name) { return gnc_gconf_get_bool(section, name, NULL); }
gboolean gnc_AB_BANKING_execute (GtkWidget *parent, AB_BANKING *api, AB_JOB *job, GNCInteractor *inter) { int err; int resultcode = 3000; /* This code means: Warnings, but not errors */ int be_verbose = FALSE; g_assert (api); if (inter) GNCInteractor_show (inter); if (gnc_gconf_get_bool(GCONF_SECTION, KEY_VERBOSE_DEBUG, NULL)) { GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevelNotice); GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevelInfo); GWEN_Logger_SetLevel("aqhbci", GWEN_LoggerLevelInfo); be_verbose = TRUE; } else { GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevelError); GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevelError); GWEN_Logger_SetLevel("aqhbci", GWEN_LoggerLevelError); } do { if (inter) { GNCInteractor_show_nodelete (inter); AB_Banking_SetPinCacheEnabled (api, GNCInteractor_get_cache_valid(inter)); } err = AB_Banking_ExecuteQueue (api); /* Print result codes to interactor */ /* gnc_hbci_printresult(queue, inter); */ } while (gnc_hbci_Error_retry (parent, err, inter)); if (job) resultcode = gnc_hbci_debug_outboxjob (inter, job, be_verbose); if (!hbci_Error_isOk(err)) { if (job) gnc_hbci_debug_outboxjob (inter, job, TRUE); if (inter) GNCInteractor_show_nodelete (inter); return FALSE; } GNCInteractor_set_cache_valid (inter, TRUE); if (resultcode <= 20 && (! GNCInteractor_errorsLogged (inter)) ) { return TRUE; } else { g_message("gnc_AB_BANKING_execute: Some error at executeQueue (see gwen/aqbanking messages above); this does not necessarily mean that the results are unusable."); GNCInteractor_show_nodelete (inter); return TRUE; /* <- This used to be a FALSE but this was probably * as wrong as it could get. @%$! */ } }
static gboolean gnc_entry_ledger_auto_completion (GncEntryLedger *ledger, gncTableTraversalDir dir, VirtualLocation *p_new_virt_loc) { GncEntry *entry; GncEntry *blank_entry; GncEntry *auto_entry; const char* cell_name; const char *desc; BasicCell *cell = NULL; char *account_name = NULL; char *new_value = NULL; g_assert(ledger); g_assert(ledger->table); blank_entry = gnc_entry_ledger_get_blank_entry (ledger); /* auto-completion is only triggered by a tab out */ if (dir != GNC_TABLE_TRAVERSE_RIGHT) return FALSE; entry = gnc_entry_ledger_get_current_entry (ledger); if (entry == NULL) return FALSE; cell_name = gnc_table_get_current_cell_name (ledger->table); /* Auto-completion is done only in an entry ledger */ switch (ledger->type) { case GNCENTRY_ORDER_ENTRY: case GNCENTRY_INVOICE_ENTRY: case GNCENTRY_BILL_ENTRY: case GNCENTRY_EXPVOUCHER_ENTRY: case GNCENTRY_CUST_CREDIT_NOTE_ENTRY: case GNCENTRY_VEND_CREDIT_NOTE_ENTRY: case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY: break; default: return FALSE; } /* Further conditions before we actually do auto-completion: */ /* There must be a blank entry */ if (blank_entry == NULL) return FALSE; /* we must be on the blank entry */ if (entry != blank_entry) return FALSE; /* and leaving the description cell */ if (!gnc_cell_name_equal (cell_name, ENTRY_DESC_CELL)) return FALSE; /* nothing but the date and description should be changed */ /* FIXME, this should be refactored. */ if (gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_ACTN_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_QTY_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_PRIC_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_DISC_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_DISTYPE_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_DISHOW_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_IACCT_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_BACCT_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_TAXABLE_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_TAXINCLUDED_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_TAXTABLE_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_VALUE_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_TAXVAL_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_BILLABLE_CELL, TRUE) || gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_PAYMENT_CELL, TRUE)) return FALSE; /* and the description should indeed be changed */ if (!gnc_table_layout_get_cell_changed (ledger->table->layout, ENTRY_DESC_CELL, TRUE)) return FALSE; /* to a non-empty value */ desc = gnc_table_layout_get_cell_value (ledger->table->layout, ENTRY_DESC_CELL); if ((desc == NULL) || (*desc == '\0')) return FALSE; /* Ok, we are sure we want to trigger auto-completion. Now find an * entry to copy the values from. FIXME: Currently we only use * the entries from the current invoice/bill, but it would be * better to draw this from a larger set of entries. */ auto_entry = /* Use this for book-wide auto-completion of the invoice entries */ find_entry_in_book_by_desc(ledger, desc); /* #else */ /* gnc_find_entry_in_reg_by_desc(ledger, desc); */ /* #endif */ if (auto_entry == NULL) return FALSE; /* now perform the completion */ gnc_suspend_gui_refresh (); /* Auto-complete the action field */ cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_ACTN_CELL); set_value_combo_cell (cell, gncEntryGetAction (auto_entry)); /* Auto-complete the account field */ switch (ledger->type) { case GNCENTRY_INVOICE_ENTRY: case GNCENTRY_CUST_CREDIT_NOTE_ENTRY: cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_IACCT_CELL); account_name = gnc_get_account_name_for_register (gncEntryGetInvAccount(auto_entry)); break; case GNCENTRY_EXPVOUCHER_ENTRY: case GNCENTRY_BILL_ENTRY: case GNCENTRY_VEND_CREDIT_NOTE_ENTRY: case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY: cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_BACCT_CELL); account_name = gnc_get_account_name_for_register (gncEntryGetBillAccount(auto_entry)); break; case GNCENTRY_ORDER_ENTRY: default: cell = NULL; account_name = NULL; break; } set_value_combo_cell (cell, account_name); g_free (account_name); /* Auto-complete quantity cell * Note: we always autofill a positive quantity value. This allows us to * - reuse invoice entries on credit note ledgers, meaning you can credit * some invoice entry via autofill without having to manually fix the sign * on the credit note. * - autofill credit note entries on other credit note entries (without having * to juggle sign reversals internally) * - autofill credit note entries on invoice ledgers * * Disadvantage: invoice entries with explicitly set negative quantities will * be autofilled to positive quantities in later uses. But it seems less common * to me to require a negative entry again next time. */ cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_QTY_CELL); set_value_price_cell (cell, gnc_numeric_abs(gncEntryGetQuantity (auto_entry))); /* Auto-complete price cell */ { gnc_numeric price; switch (ledger->type) { case GNCENTRY_INVOICE_ENTRY: case GNCENTRY_CUST_CREDIT_NOTE_ENTRY: price = gncEntryGetInvPrice (auto_entry); break; default: price = gncEntryGetBillPrice (auto_entry); } /* Auto-complete price cell */ cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_PRIC_CELL); set_value_price_cell (cell, price); } /* We intentionally skip the discount column */ /* Taxable?, Tax-include?, Tax table */ { gboolean taxable, taxincluded; GncTaxTable *taxtable; switch (ledger->type) { case GNCENTRY_INVOICE_ENTRY: case GNCENTRY_CUST_CREDIT_NOTE_ENTRY: taxable = gncEntryGetInvTaxable (auto_entry); taxincluded = gncEntryGetInvTaxIncluded (auto_entry); taxtable = gncEntryGetInvTaxTable (auto_entry); break; default: taxable = gncEntryGetBillTaxable (auto_entry); taxincluded = gncEntryGetBillTaxIncluded (auto_entry); taxtable = gncEntryGetBillTaxTable (auto_entry); } /* Taxable? cell */ cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_TAXABLE_CELL); gnc_checkbox_cell_set_flag ((CheckboxCell *) cell, taxable); gnc_basic_cell_set_changed (cell, TRUE); /* taxincluded? cell */ cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_TAXINCLUDED_CELL); gnc_checkbox_cell_set_flag ((CheckboxCell *) cell, taxincluded); gnc_basic_cell_set_changed (cell, TRUE); /* Taxable? cell */ cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_TAXTABLE_CELL); set_value_combo_cell(cell, gncTaxTableGetName (taxtable)); } gnc_resume_gui_refresh (); /* now move to the non-empty amount column unless config setting says not */ if ( !gnc_gconf_get_bool(GCONF_GENERAL_REGISTER, "tab_includes_transfer_on_memorised", NULL) ) { VirtualLocation new_virt_loc; const char *cell_name = ENTRY_QTY_CELL; if (gnc_table_get_current_cell_location (ledger->table, cell_name, &new_virt_loc)) *p_new_virt_loc = new_virt_loc; } return TRUE; }