static void gnc_reconcile_view_init (GNCReconcileView *view) { GNCSearchParamSimple *param; GList *columns = NULL; gboolean num_action = qof_book_use_split_action_for_num_field(gnc_get_current_book()); view->reconciled = g_hash_table_new (NULL, NULL); view->account = NULL; view->sibling = NULL; param = gnc_search_param_simple_new(); gnc_search_param_set_param_fcn (param, QOF_TYPE_BOOLEAN, gnc_reconcile_view_is_reconciled, view); gnc_search_param_set_title ((GNCSearchParam *) param, _("Reconciled:R") + 11); gnc_search_param_set_justify ((GNCSearchParam *) param, GTK_JUSTIFY_CENTER); gnc_search_param_set_passive ((GNCSearchParam *) param, TRUE); gnc_search_param_set_non_resizeable ((GNCSearchParam *) param, TRUE); columns = g_list_prepend (columns, param); columns = gnc_search_param_prepend_with_justify (columns, _("Amount"), GTK_JUSTIFY_RIGHT, NULL, GNC_ID_SPLIT, SPLIT_AMOUNT, NULL); columns = gnc_search_param_prepend (columns, _("Description"), NULL, GNC_ID_SPLIT, SPLIT_TRANS, TRANS_DESCRIPTION, NULL); columns = num_action ? gnc_search_param_prepend_with_justify (columns, _("Num"), GTK_JUSTIFY_CENTER, NULL, GNC_ID_SPLIT, SPLIT_ACTION, NULL) : gnc_search_param_prepend_with_justify (columns, _("Num"), GTK_JUSTIFY_CENTER, NULL, GNC_ID_SPLIT, SPLIT_TRANS, TRANS_NUM, NULL); columns = gnc_search_param_prepend (columns, _("Date"), NULL, GNC_ID_SPLIT, SPLIT_TRANS, TRANS_DATE_POSTED, NULL); view->column_list = columns; }
GNCSearchWindow * gnc_ui_find_transactions_dialog_create2 (GNCLedgerDisplay2 * orig_ledg) { QofIdType type = GNC_ID_SPLIT; struct _ftd_data *ftd; static GList *params = NULL; QofQuery *start_q, *show_q = NULL; gboolean num_action = qof_book_use_split_action_for_num_field(gnc_get_current_book()); /* Build parameter list in reverse order */ if (params == NULL) { params = gnc_search_param_prepend (params, N_("All Accounts"), ACCOUNT_MATCH_ALL_TYPE, type, SPLIT_TRANS, TRANS_SPLITLIST, SPLIT_ACCOUNT_GUID, NULL); params = gnc_search_param_prepend (params, N_("Account"), GNC_ID_ACCOUNT, type, SPLIT_ACCOUNT, QOF_PARAM_GUID, NULL); params = gnc_search_param_prepend (params, N_("Balanced"), NULL, type, SPLIT_TRANS, TRANS_IS_BALANCED, NULL); params = gnc_search_param_prepend (params, N_("Reconcile"), RECONCILED_MATCH_TYPE, type, SPLIT_RECONCILE, NULL); params = gnc_search_param_prepend (params, N_("Share Price"), NULL, type, SPLIT_SHARE_PRICE, NULL); params = gnc_search_param_prepend (params, N_("Shares"), NULL, type, SPLIT_AMOUNT, NULL); params = gnc_search_param_prepend (params, N_("Value"), NULL, type, SPLIT_VALUE, NULL); params = gnc_search_param_prepend (params, N_("Date Posted"), NULL, type, SPLIT_TRANS, TRANS_DATE_POSTED, NULL); params = gnc_search_param_prepend (params, N_("Notes"), NULL, type, SPLIT_TRANS, TRANS_NOTES, NULL); params = gnc_search_param_prepend (params, (num_action ? N_("Number/Action") : N_("Action")), NULL, type, SPLIT_ACTION, NULL); params = gnc_search_param_prepend (params, (num_action ? N_("Transaction Number") : N_("Number")), NULL, type, SPLIT_TRANS, TRANS_NUM, NULL); params = gnc_search_param_prepend (params, N_("Memo"), NULL, type, SPLIT_MEMO, NULL); params = gnc_search_param_prepend (params, N_("Description"), NULL, type, SPLIT_TRANS, TRANS_DESCRIPTION, NULL); } else { GList *l; for (l = params; l; l = l->next) { GNCSearchParam *param = l->data; if (num_action) { if (strcmp (param->title, N_("Action")) == 0) gnc_search_param_set_title (param, N_("Number/Action")); if (strcmp (param->title, N_("Number")) == 0) gnc_search_param_set_title (param, N_("Transaction Number")); } else { if (strcmp (param->title, N_("Number/Action")) == 0) gnc_search_param_set_title (param, N_("Action")); if (strcmp (param->title, N_("Transaction Number")) == 0) gnc_search_param_set_title (param, N_("Number")); } } } ftd = g_new0 (struct _ftd_data, 1); if (orig_ledg) { ftd->ledger_q = gnc_ledger_display2_get_query (orig_ledg); start_q = show_q = qof_query_copy (ftd->ledger_q); } else { start_q = qof_query_create (); qof_query_set_book (start_q, gnc_get_current_book ()); /* In lieu of not "mis-using" some portion of the infrastructure by writing * a bunch of new code, we just filter out the accounts of the template * transactions. While these are in a seperate Account trees just for this * reason, the query engine makes no distinction between Account trees. * See Gnome Bug 86302. * -- jsled * * copied from gnc-ledger-display2.c:gnc_ledger_display2_gl() -- warlord * * <jsled> Alternatively, you could look for a GNC_SX_ACCOUNT [SchedAction.h] * key in the KVP frame of the split. */ { Account *tRoot; GList *al; tRoot = gnc_book_get_template_root( gnc_get_current_book() ); al = gnc_account_get_descendants( tRoot ); xaccQueryAddAccountMatch( start_q, al, QOF_GUID_MATCH_NONE, QOF_QUERY_AND ); g_list_free (al); al = NULL; tRoot = NULL; } ftd->q = start_q; /* save this to destroy it later */ } ftd->sw = gnc_search_dialog_create (type, _("Find Transaction"), params, NULL, start_q, show_q, NULL, do_find_cb, NULL, ftd, free_ftd_cb, GNC_PREFS_GROUP_SEARCH, NULL); if (!ftd->sw) { free_ftd_cb (ftd); return NULL; } return ftd->sw; }
/******************************************************* * csv_transactions_export * * write a list of transactions to a text file *******************************************************/ void csv_transactions_export (CsvExportInfo *info) { FILE *fh; Account *acc; GList *ptr; gboolean num_action = qof_book_use_split_action_for_num_field (gnc_get_current_book()); ENTER(""); DEBUG("File name is : %s", info->file_name); info->failed = FALSE; /* Set up separators */ if (info->use_quotes) { info->end_sep = "\""; info->mid_sep = g_strconcat ("\"", info->separator_str, "\"", NULL); } else { info->end_sep = ""; info->mid_sep = g_strconcat (info->separator_str, NULL); } /* Open File for writing */ fh = g_fopen (info->file_name, "w" ); if (fh != NULL) { gchar *header; int i; /* Header string */ if (info->simple_layout) { header = g_strconcat (info->end_sep, _("Date"), info->mid_sep, _("Account Name"), info->mid_sep, (num_action ? _("Transaction Number") : _("Number")), info->mid_sep, _("Description"), info->mid_sep, _("Full Category Path"), info->mid_sep, _("Reconcile"), info->mid_sep, _("Amount With Sym"), info->mid_sep, _("Amount Num."), info->mid_sep, _("Rate/Price"), info->end_sep, EOLSTR, NULL); } else { header = g_strconcat (info->end_sep, _("Date"), info->mid_sep, _("Transaction Type"), info->mid_sep, _("Second Date"), info->mid_sep, _("Account Name"), info->mid_sep, (num_action ? _("Transaction Number") : _("Number")), info->mid_sep, _("Description"), info->mid_sep, _("Notes"), info->mid_sep, _("Memo"), info->mid_sep, _("Full Category Path"), info->mid_sep, _("Category"), info->mid_sep, _("Row Type"), info->mid_sep, (num_action ? _("Number/Action") : _("Action")), info->mid_sep, _("Reconcile"), info->mid_sep, _("Amount With Sym"), info->mid_sep, _("Commodity Mnemonic"), info->mid_sep, _("Commodity Namespace"), info->mid_sep, _("Amount Num."), info->mid_sep, _("Rate/Price"), info->end_sep, EOLSTR, NULL); } DEBUG("Header String: %s", header); /* Write header line */ if (!write_line_to_file (fh, header)) { info->failed = TRUE; g_free (header); return; } g_free (header); /* Go through list of accounts */ for (ptr = info->csva.account_list, i = 0; ptr; ptr = g_list_next(ptr), i++) { acc = ptr->data; DEBUG("Account being processed is : %s", xaccAccountGetName (acc)); account_splits (info, acc, fh); } g_list_free (info->trans_list); // free trans_list } else info->failed = TRUE; if (fh) fclose (fh); LEAVE(""); }