Files
gnucash/src/engine/SchedXaction.c

1327 lines
38 KiB
C
Raw Normal View History

/********************************************************************\
* SchedXaction.c -- Scheduled Transaction implementation. *
* Copyright (C) 2001,2007 Joshua Sled <jsled@asynchronous.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
* Boston, MA 02110-1301, USA gnu@gnu.org *
* *
\********************************************************************/
#include "config.h"
#include <glib.h>
#include <glib/gi18n.h>
#include <string.h>
#include "qof.h"
#include "Account.h"
#include "SX-book.h"
#include "SX-ttinfo.h"
#include "SchedXaction.h"
#include "Transaction.h"
#include "gnc-engine.h"
Implement a Book Option to give users the choice to use the transaction number field (default and current behaviour) or, alternatively, the split action field of the anchor split for 'Num' column on registers, reports, import and export, where applicable. The difference between the two is that with the default, the same 'Num' is displayed for a given transaction regardless of what register it is viewed in and with the new option, a different 'Num' can be entered/displayed for a given transaction in each register it is viewed in. In both cases, the 'next number logic' of the 'Num' cell is based on the account of the register the transaction is entered/viewed from but in one case it fills the transaction number, in the other, it fills the split action field of the anchor split (with the transaction number field displayed in the register cell labeled 'T-Num'). In both cases, both fields are visible and can be used as free-form text in double-line mode for any value the user wants. If the new option is not selected, there should be no change in Gnucash's behaviour with the exception of displaying the book options dialog in 'new book' situations. The changes made are: 1. Implement the new book option to select source for 'num' cell: libqof/qof/qofbookslots.h - define num source option engine/engine.i - define 'NUM-FIELD-SOURCE' as an option name and 'SPLIT-ACTION' as a term for sorting queries app-utils/business-prefs.scm - define book option for num-field-source app-utils/app-utils.scm - define and export book option for num-field-source 2. Implement functions to get book option setting and to test: libqof/qof/qofbook.c & .h - define function to get number source book option libqof/qof/test/test-qofbook.c - test function to get number source book option 3. Implement a notification mechanism for book option changes: engine/engine-helpers.c & .h - define functions to register callbacks, define function to remove callbacks and define function to initiate callbacks on book num-source option changes core-utils/gnc-features.c & .h - define feature for num-source app-utils/gnc-ui-util.c & .h - define gnc_book_option_num_field_source_change_cb; include setting of feature flag on initial use gnome-utils/gnc-main-window.c - change name of gnc_options_dialog_apply_cb function to gnc_book_options_dialog_apply_cb and adjust function to call function gnc_book_option_num_field_source_change_cb when book option for num-field-source changes; change name of gnc_options_dialog_close_cb to gnc_book_options_dialog_close_cb 4. Implement 'help' button response on Book Option Dialog: gnome-utils/gnc-ui.h - define "book-options" section of help manual gnome-utils/gnc-gnome-utils.c & .h - implement Book Options help callback gnome-utils/gnc-main-window.c - use gnc_options_dialog_set_book_options_help_cb to make help button active 5. Implement utility functions to get/set number/action based on book option: engine/engine-helpers.c & .h - define 'gnc_get_num_action' function define 'gnc_get_action_num' function define 'gnc_set_num_action' function engine/engine.i - make get/set num/action functions available to guile & allow #f to be used in place of NULL from guile engine/Transaction.h - add reference to utility functions in comments to xaccTransSetNum and xaccTransGetNum functions engine/Split.h - add reference to utility functions in comments to xaccSplitSetAction and xaccSplitGetAction functions 6. Implement register use of num source book option; for General, Income and Search Ledgers, since there is no anchor split, always show tran-num in transaction cursor, but vary label to correspond to book option: register/ledger-core/split-register.h - define TNUM_CELL define CURSOR_DOUBLE_LEDGER_NUM_ACTN cursor name to use TNUM_CELL define CURSOR_DOUBLE_JOURNAL_NUM_ACTN cursor name to use TNUM_CELL add boolean to split_reg structure to hold num source book option register/ledger-core/split-register-layout.c - add logic to define and set up new ledger/journal cursors with TNUM_CELLs add logic to add the new cursors to a layout add logic to add TNUM_CELL to a layout register/ledger-core/split-register-model.c - define function to get TNUM_CELL label add logic to recognize ledger/journal cursors with TNUM_CELL modify function to get NUM_CELL value based on book option and register type define function to get TNUM_CELL value adjust num help text to reflect book option choice define function to get TNUM_CELL help modify function to get action help to reflect book option choice set up handlers for TNUM_CELL register/ledger-core/split-register-model-save.c - use 'gnc_set_num_action' function to set num/action for NUM_CELL based on book option define function to save TNUM_CELL using 'gnc_set_num_action' function set save handler for TNUM_CELL register/ledger-core/split-register-util.c - modify logic to recognize ledger/journal cursors with tnum_cell register/ledger-core/split-register.c - define split_register_book_option_changed function register split_register_book_option_changed function in register init initialize register structure setting to book option remove split_register_book_option_changed function in register destroy modify gnc_split_register_save_to_scm to handle TNUM_CELL 7. Enhance transaction copy/duplicate logic to accommodate new book option: gnome/gtkbuilder/gnc-plugin-page-register.glade - add widgets to handle trans number and/or split action based on book option gnome-utils/dialog-dup-trans.c & .h - add capability to display and handle 'Num' field according to book option gnome/gnc-plugin-page-register.c - define gnc_find_register_by_account register/ledger-core/split-register.c - modify gnc_split_register_duplicate_current to accomodate book option setting register/ledger-core/Makefile.am - add GNOME_CFLAGS register/ledger-core/test/Makefile.am - add libgnc-gnome.la 8. Adjust register sort and sort labels related to Num/Action radio buttons to correspond to book option for clarity: gnome/gnc-plugin-page-register.c - define gnc_plugin_page_register_sort_book_option_changed to adjust labels register function in gnc_plugin_page_register_cmd_view_sort_by and save num and action radio widgets initialize radio widget labels to correspond to book option remove function in gnc_plugin_page_register_sort_response_cb and clear num and action radio widgets gnome/gnc-split-reg.c & h. - create versions of gnc_split_reg_sort and gnc_split_reg_set_sort to force a re-sort to be used when num-source book option changes engine/Transaction.c & .h - modify default sort to use split action in place of tran num per book option if called from xaccSplitOrder engine/Split.c - modify xaccSplitOrder to call xaccTransOrder_num_action to switch use of split action and tran num per book option engine/test/utest-Split.c - modify test_xaccSplitOrder to call xaccTransOrder_num_action based on book option 9. Adjust transaction find labels related to Num/Action to correspond to book option for clarity: gnome/dialog-find-transactions.c - adjust labels in search criteria based on book option gnome-search/dialog-search.c - define gnc_search_dialog_book_option_changed to adjust labels register function in gnc_search_dialog_init_widgets when searching for splits remove function in gnc_search_dialog_close_cb if registered 10. Modify new file process to allow setting of num-source (actually, all) book option(s) during New Account Hierarchy Setup: gnome-utils/gtkbuilder/dialog-preferences.glade - add a user preference for the default setting for 'num-source' for new books core-utils/gnc-gconf-utils.h - define KEY_NUM_SOURCE gnome-utils/gnc-gnome-utils.c & h. - define gnc_options_dialog_set_new_book_option_values to retrieve preference values gnome-utils/dialog-options.c & .h - define gnc_options_dialog_new_modal to surpress apply button gnome-utils/gnc-main-window.c - define function gnc_book_options_dialog_cb with arguments so that the window can be called in modal mode and the title changed and return dialog widget; call gnc_options_dialog_new_modal instead of gnc_options_dialog_new; call this function from gnc_main_window_cmd_file_properties with new arguments; for modal mode, call gnc-options-dialog-set-new-book-option-values to initialize values from preferences app-utils/gnc-ui-util.c & h. - create function gnc_is_new_book for determining when a new book is being created gnome-utils/dialog-utils.c & h. - define gnc_new_book_option_display to display book options dialog in modal mode gnome/gtkbuilder/assistant-hierarchy.glade - add notification about book options to currency page gnome/assistant-hierarchy.c - add ability to set book option initialized from preferences value for new books by using functions gnc_is_new_book and gnc_new_book_option_display 11. Modify Import QIF process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/qif-import/assistant-qif-import.glade - add notification about book options to currency page import-export/qif-import/assistant-qif-import.c - using function gnc_is_new_book to identify 'new book' situation and set flag; add logic to handle 'new-book' situation by calling gnc_new_book_option_display function import-export/qif-import/qif-to-gnc.scm - use 'gnc_set_num_action' function to import number to correct field based on book option 12. Modify Import OFX/QFX process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/ofx/gnc-ofx-import.c - use 'gnc_set_num_action' function to import number based on book option; identify 'new book' situation using function gnc_is_new_book and set flag; add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function import-export/import-backend.c - use 'gnc_get_num_action' function to retrieve number from transactions to be matched based on book option 13. Modify Import AqBanking process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number: import-export/aqbanking/gnc-file-aqb-import.c - identify 'new book' situation using function gnc_is_new_book and handle by raising book options dialog by calling gnc_new_book_option_display function import-export/aqbanking/gnc-ab-utils.c - use 'gnc_set_num_action' function to set number based on book option 14. Modify Import Transactions from CSV process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/csv-import/assistant-csv-trans-import.glade - modify commments to alert user of raising book options dialog in cases of csv import into a new book import-export/csv-import/gnc-csv-model.c & h. - use 'gnc_set_num_action' function to import number based on book option import-export/csv-import/assistant-csv-trans-import.c - add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function; identify 'new book' situation using function gnc_is_new_book and set flag 15. Modify Import Accounts from CSV process to recognize a new-book situation and allow setting of book options during first import into a new book import-export/csv-import/assistant-csv-account-import.c & .h - add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function; identify 'new book' situation using function gnc_is_new_book and set flag 16. Modify Export Transactions to CSV process to follow book option setting for num source in exporting transactions: import-export/csv-export/csv-transactions-export.c - modify headings to reflect num-source book option and use 'gnc_get_num_action' function to retrieve number and action 17. Modify register reporting to reflect book option setting for num source: gnome/gnc-plugin-page-register.c - determine and pass along ledger-type? argument to gnc:register-report-create function gnome/gnc-plugin-page-register2.c - determine and pass along ledger-type? argument to gnc:register-report-create function report/standard-reports/standard-reports.scm - add ledger-type? argument to gnc:register-report-create function; pass it along to gnc:register-report-create-internal function report/standard-reports/register.scm - add ledger-type? argument to gnc:register-report-create-internal function; use 'gnc-get-num-action' function in place of xaccTransGetNum and 'gnc-get-action-num' function in place of xaccSplitGetAction and modify report headings and option text accordingly 18. Modify all places that use xaccTransSetNum and/or xaccSplitSetAction to use 'gnc_set_num_action' function to set number based on book option except engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c, engine/Split.c & .h, engine/test/utest-Split.c, engine/engine-helpers.c & .h, engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c, backend/xml/io-gncxml-v1.c, import-export/log-replay/gnc-log-replay.c: engine/gncOwner.c - use 'gnc_set_num_action' function to set number based on book option engine/gncInvoice.c - use 'gnc_set_num_action' function to set number based on book option engine/SchedXaction.c - use 'gnc_set_num_action' function to set number and action engine/cap-gains.c - use 'gnc_set_num_action' function to set split-action gnome-utils/dialog-transfer.c - use 'gnc_set_num_action' function to set number based on book option gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_set_num_action' function to set number/action based on book option gnome/assistant-stock-split.c - use 'gnc_set_num_action' function to set split-action 19. Modify all places that use xaccTransGetNum and/or xaccSplitGetAction to use 'gnc_get_num_action' or 'gnc_get_action_num' functions to get number based on book option except engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c, engine/Split.c & h., engine/test/utest-Split.c, engine/engine-helpers.c, engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c, backend/xml/test/test-xml-transaction.c: gnome/dialog-lot-viewer.c - use 'gnc_get_num_action' function to retrieve number based on book option gnome/dialog-sx-from-trans.c - use 'gnc_get_num_action' function to retrieve number and action gnome/dialog-print-check.c - use 'gnc_get_num_action' function to retrieve number and 'gnc_get_action_num' function to retrieve action register/ledger-core/split-register-model.c - use 'gnc_get_num_action' function to retrieve number based on book option register/ledger-core/split-register-load.c - use 'gnc_get_num_action' function to retrieve number based on book option register/ledger-core/split-register-control.c - use 'gnc_get_num_action' function to retrieve action register/ledger-core/split-register.c - use 'gnc_get_num_action' function to retrieve transaction-num engine/cap-gains.c - use 'gnc_get_num_action' function to get split-action gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_get_num_action' function to retrieve number and 'gnc_get_action_num' function to retrieve action gnome-utils/gnc-tree-model-split-reg.c - use 'gnc_get_num_action' function to retrieve transaction-number but may not be getting what is expected if book option to use split-action for 'num' is set report/locale-specific/us/taxtxf.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum and 'gnc-get-action-num' function in place of xaccSplitGetAction and modify report headings and option text accordingly report/standard-reports/transaction.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum, adjust sorting based on book option and modify report headings and option text accordingly; add 'SPLIT-ACTION' as a term for sorting queries report/business-reports/customer-summary.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum report/business-reports/owner-report.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum report/business-reports/job-report.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum business/business-gnome/dialog-payment.c - use 'gnc_get_num_action' function to retrieve number based on book option git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22681 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-12-22 06:00:54 +00:00
#include "engine-helpers.h"
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "gnc.engine.sx"
enum
{
PROP_0,
PROP_NAME,
PROP_ENABLED,
PROP_NUM_OCCURANCE,
PROP_REM_OCCURANCE,
PROP_AUTO_CREATE,
PROP_AUTO_CREATE_NOTIFY,
PROP_ADVANCE_CREATION_DAYS,
PROP_ADVANCE_REMINDER_DAYS,
PROP_START_DATE,
PROP_END_DATE,
PROP_LAST_OCCURANCE_DATE,
PROP_INSTANCE_COUNT,
PROP_TEMPLATE_ACCOUNT
};
/* GObject initialization */
G_DEFINE_TYPE(SchedXaction, gnc_schedxaction, QOF_TYPE_INSTANCE);
static void
gnc_schedxaction_init(SchedXaction* sx)
{
sx->schedule = NULL;
g_date_clear( &sx->last_date, 1 );
g_date_clear( &sx->start_date, 1 );
g_date_clear( &sx->end_date, 1 );
sx->enabled = 1;
sx->num_occurances_total = 0;
sx->autoCreateOption = FALSE;
sx->autoCreateNotify = FALSE;
sx->advanceCreateDays = 0;
sx->advanceRemindDays = 0;
sx->instance_num = 0;
sx->deferredList = NULL;
}
static void
gnc_schedxaction_dispose(GObject *sxp)
{
G_OBJECT_CLASS(gnc_schedxaction_parent_class)->dispose(sxp);
}
static void
gnc_schedxaction_finalize(GObject* sxp)
{
G_OBJECT_CLASS(gnc_schedxaction_parent_class)->finalize(sxp);
}
static void
gnc_schedxaction_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SchedXaction *sx;
g_return_if_fail(GNC_IS_SCHEDXACTION(object));
sx = GNC_SCHEDXACTION(object);
switch (prop_id)
{
case PROP_NAME:
g_value_set_string(value, sx->name);
break;
case PROP_ENABLED:
g_value_set_boolean(value, sx->enabled);
break;
case PROP_NUM_OCCURANCE:
g_value_set_int(value, sx->num_occurances_total);
break;
case PROP_REM_OCCURANCE:
g_value_set_int(value, sx->num_occurances_remain);
break;
case PROP_AUTO_CREATE:
g_value_set_boolean(value, sx->autoCreateOption);
break;
case PROP_AUTO_CREATE_NOTIFY:
g_value_set_boolean(value, sx->autoCreateNotify);
break;
case PROP_ADVANCE_CREATION_DAYS:
g_value_set_int(value, sx->advanceCreateDays);
break;
case PROP_ADVANCE_REMINDER_DAYS:
g_value_set_int(value, sx->advanceRemindDays);
break;
case PROP_START_DATE:
g_value_set_boxed(value, &sx->start_date);
break;
case PROP_END_DATE:
/* g_value_set_boxed raises a critical error if sx->end_date
* is invalid */
if (g_date_valid (&sx->end_date))
g_value_set_boxed(value, &sx->end_date);
break;
case PROP_LAST_OCCURANCE_DATE:
/* g_value_set_boxed raises a critical error if sx->last_date
* is invalid */
if (g_date_valid (&sx->last_date))
g_value_set_boxed(value, &sx->last_date);
break;
case PROP_INSTANCE_COUNT:
g_value_set_int(value, sx->instance_num);
break;
case PROP_TEMPLATE_ACCOUNT:
g_value_set_object(value, sx->template_acct);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
gnc_schedxaction_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SchedXaction *sx;
g_return_if_fail(GNC_IS_SCHEDXACTION(object));
sx = GNC_SCHEDXACTION(object);
switch (prop_id)
{
case PROP_NAME:
xaccSchedXactionSetName(sx, g_value_get_string(value));
break;
case PROP_ENABLED:
xaccSchedXactionSetEnabled(sx, g_value_get_boolean(value));
break;
case PROP_NUM_OCCURANCE:
xaccSchedXactionSetNumOccur(sx, g_value_get_int(value));
break;
case PROP_REM_OCCURANCE:
xaccSchedXactionSetRemOccur(sx, g_value_get_int(value));
break;
case PROP_AUTO_CREATE:
xaccSchedXactionSetAutoCreate(sx, g_value_get_boolean(value), sx->autoCreateNotify);
break;
case PROP_AUTO_CREATE_NOTIFY:
xaccSchedXactionSetAutoCreate(sx, sx->autoCreateOption, g_value_get_boolean(value));
break;
case PROP_ADVANCE_CREATION_DAYS:
xaccSchedXactionSetAdvanceCreation(sx, g_value_get_int(value));
break;
case PROP_ADVANCE_REMINDER_DAYS:
xaccSchedXactionSetAdvanceReminder(sx, g_value_get_int(value));
break;
case PROP_START_DATE:
/* Note: when passed through a boxed gvalue, the julian value of the date is copied.
The date may appear invalid until a function requiring for dmy calculation is
called. */
xaccSchedXactionSetStartDate(sx, g_value_get_boxed(value));
break;
case PROP_END_DATE:
/* Note: when passed through a boxed gvalue, the julian value of the date is copied.
The date may appear invalid until a function requiring for dmy calculation is
called. */
xaccSchedXactionSetEndDate(sx, g_value_get_boxed(value));
break;
case PROP_LAST_OCCURANCE_DATE:
/* Note: when passed through a boxed gvalue, the julian value of the date is copied.
The date may appear invalid until a function requiring for dmy calculation is
called. */
xaccSchedXactionSetLastOccurDate(sx, g_value_get_boxed(value));
break;
case PROP_INSTANCE_COUNT:
gnc_sx_set_instance_count(sx, g_value_get_int(value));
break;
case PROP_TEMPLATE_ACCOUNT:
sx_set_template_account(sx, g_value_get_object(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
gnc_schedxaction_class_init (SchedXactionClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->dispose = gnc_schedxaction_dispose;
gobject_class->finalize = gnc_schedxaction_finalize;
gobject_class->set_property = gnc_schedxaction_set_property;
gobject_class->get_property = gnc_schedxaction_get_property;
g_object_class_install_property
(gobject_class,
PROP_NAME,
g_param_spec_string ("name",
"Scheduled Transaction Name",
"The name is an arbitrary string "
"assigned by the user. It is intended to "
"a short, 5 to 30 character long string "
"that is displayed by the GUI.",
NULL,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_ENABLED,
g_param_spec_boolean ("enabled",
"Enabled",
"TRUE if the scheduled transaction is enabled.",
TRUE,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_NUM_OCCURANCE,
g_param_spec_int ("num-occurance",
"Number of occurances",
"Total number of occurances for this scheduled transaction.",
0,
G_MAXINT16,
1,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_REM_OCCURANCE,
g_param_spec_int ("rem-occurance",
"Number of occurances remaining",
"Remaining number of occurances for this scheduled transaction.",
0,
G_MAXINT16,
1,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_AUTO_CREATE,
g_param_spec_boolean ("auto-create",
"Auto-create",
"TRUE if the transaction will be automatically "
"created when its time comes.",
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_AUTO_CREATE_NOTIFY,
g_param_spec_boolean ("auto-create-notify",
"Auto-create-notify",
"TRUE if the the user will be notified when the transaction "
"is automatically created.",
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_ADVANCE_CREATION_DAYS,
g_param_spec_int ("advance-creation-days",
"Days in advance to create",
"Number of days in advance to create this scheduled transaction.",
0,
G_MAXINT16,
0,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_ADVANCE_REMINDER_DAYS,
g_param_spec_int ("advance-reminder-days",
"Days in advance to remind",
"Number of days in advance to remind about this scheduled transaction.",
0,
G_MAXINT16,
0,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_START_DATE,
g_param_spec_boxed("start-date",
"Start Date",
"Date for the first occurence for the scheduled transaction.",
G_TYPE_DATE,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_END_DATE,
g_param_spec_boxed("end-date",
"End Date",
"Date for the scheduled transaction to end.",
G_TYPE_DATE,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_LAST_OCCURANCE_DATE,
g_param_spec_boxed("last-occurance-date",
"Last Occurance Date",
"Date for the last occurance of the scheduled transaction.",
G_TYPE_DATE,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_INSTANCE_COUNT,
g_param_spec_int ("instance-count",
"Instance count",
"Number of instances of this scheduled transaction.",
0,
G_MAXINT16,
0,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_TEMPLATE_ACCOUNT,
g_param_spec_object("template-account",
"Template account",
"Account which holds the template transactions.",
GNC_TYPE_ACCOUNT,
G_PARAM_READWRITE));
}
static void
xaccSchedXactionInit(SchedXaction *sx, QofBook *book)
{
Account *ra;
const GncGUID *guid;
qof_instance_init_data (&sx->inst, GNC_ID_SCHEDXACTION, book);
/* create a new template account for our splits */
sx->template_acct = xaccMallocAccount(book);
guid = qof_instance_get_guid( sx );
xaccAccountBeginEdit( sx->template_acct );
xaccAccountSetName( sx->template_acct, guid_to_string( guid ));
xaccAccountSetCommodity
(sx->template_acct,
gnc_commodity_table_lookup( gnc_commodity_table_get_table(book),
"template", "template") );
xaccAccountSetType( sx->template_acct, ACCT_TYPE_BANK );
xaccAccountCommitEdit( sx->template_acct );
ra = gnc_book_get_template_root( book );
gnc_account_append_child( ra, sx->template_acct );
}
SchedXaction*
xaccSchedXactionMalloc(QofBook *book)
{
SchedXaction *sx;
g_return_val_if_fail (book, NULL);
sx = g_object_new(GNC_TYPE_SCHEDXACTION, NULL);
xaccSchedXactionInit( sx, book );
qof_event_gen( &sx->inst, QOF_EVENT_CREATE , NULL);
return sx;
}
static void
sxprivTransMapDelete( gpointer data, gpointer user_data )
{
Transaction *t = (Transaction *) data;
xaccTransBeginEdit( t );
xaccTransDestroy( t );
xaccTransCommitEdit( t );
return;
}
static void
delete_template_trans(SchedXaction *sx)
{
GList *templ_acct_splits, *curr_split_listref;
Split *curr_split;
Transaction *split_trans;
GList *templ_acct_transactions = NULL;
templ_acct_splits
= xaccAccountGetSplitList(sx->template_acct);
for (curr_split_listref = templ_acct_splits;
curr_split_listref;
curr_split_listref = curr_split_listref->next)
{
curr_split = (Split *) curr_split_listref->data;
split_trans = xaccSplitGetParent(curr_split);
if (! (g_list_find(templ_acct_transactions, split_trans)))
{
templ_acct_transactions
= g_list_prepend(templ_acct_transactions, split_trans);
}
}
g_list_foreach(templ_acct_transactions,
sxprivTransMapDelete,
NULL);
return;
}
void
sx_set_template_account (SchedXaction *sx, Account *account)
{
Account *old;
old = sx->template_acct;
sx->template_acct = account;
if (old)
{
xaccAccountBeginEdit(old);
xaccAccountDestroy(old);
}
}
void
xaccSchedXactionDestroy( SchedXaction *sx )
{
qof_instance_set_destroying( QOF_INSTANCE(sx), TRUE );
gnc_sx_commit_edit( sx );
}
static void
xaccSchedXactionFree( SchedXaction *sx )
{
GList *l;
if ( sx == NULL ) return;
qof_event_gen( &sx->inst, QOF_EVENT_DESTROY , NULL);
if ( sx->name )
g_free( sx->name );
/*
* we have to delete the transactions in the
* template account ourselves
*/
delete_template_trans( sx );
/*
* xaccAccountDestroy removes the account from
* its group for us AFAICT. If shutting down,
* the account is being deleted separately.
*/
if (!qof_book_shutting_down(qof_instance_get_book(sx)))
{
xaccAccountBeginEdit(sx->template_acct);
xaccAccountDestroy(sx->template_acct);
}
for ( l = sx->deferredList; l; l = l->next )
{
gnc_sx_destroy_temporal_state( l->data );
l->data = NULL;
}
if ( sx->deferredList )
{
g_list_free( sx->deferredList );
sx->deferredList = NULL;
}
/* qof_instance_release (&sx->inst); */
g_object_unref( sx );
}
/* ============================================================ */
void
gnc_sx_begin_edit (SchedXaction *sx)
{
qof_begin_edit (&sx->inst);
}
static void sx_free(QofInstance* inst )
{
xaccSchedXactionFree( GNC_SX(inst) );
}
static void commit_err (QofInstance *inst, QofBackendError errcode)
{
g_critical("Failed to commit: %d", errcode);
gnc_engine_signal_commit_error( errcode );
}
static void commit_done(QofInstance *inst)
{
qof_event_gen (inst, QOF_EVENT_MODIFY, NULL);
}
void
gnc_sx_commit_edit (SchedXaction *sx)
{
if (!qof_commit_edit (QOF_INSTANCE(sx))) return;
qof_commit_edit_part2 (&sx->inst, commit_err, commit_done, sx_free);
}
/* ============================================================ */
GList*
gnc_sx_get_schedule(const SchedXaction *sx)
{
return sx->schedule;
}
void
gnc_sx_set_schedule(SchedXaction *sx, GList *schedule)
{
g_return_if_fail(sx);
gnc_sx_begin_edit(sx);
sx->schedule = schedule;
qof_instance_set_dirty(&sx->inst);
gnc_sx_commit_edit(sx);
}
gchar *
xaccSchedXactionGetName( const SchedXaction *sx )
{
return sx->name;
}
void
xaccSchedXactionSetName( SchedXaction *sx, const gchar *newName )
{
g_return_if_fail( newName != NULL );
gnc_sx_begin_edit(sx);
if ( sx->name != NULL )
{
g_free( sx->name );
sx->name = NULL;
}
sx->name = g_strdup( newName );
qof_instance_set_dirty(&sx->inst);
gnc_sx_commit_edit(sx);
}
const GDate*
xaccSchedXactionGetStartDate(const SchedXaction *sx )
{
g_assert (sx);
return &sx->start_date;
}
void
xaccSchedXactionSetStartDate( SchedXaction *sx, const GDate* newStart )
{
if ( newStart == NULL || !g_date_valid( newStart ))
{
/* XXX: I reject the bad data - is this the right
* thing to do <rgmerk>.
* This warning is only human readable - the caller
* doesn't know the call failed. This is bad
*/
g_critical("Invalid Start Date");
return;
}
gnc_sx_begin_edit(sx);
sx->start_date = *newStart;
qof_instance_set_dirty(&sx->inst);
gnc_sx_commit_edit(sx);
}
gboolean
xaccSchedXactionHasEndDate( const SchedXaction *sx )
{
return sx != NULL && g_date_valid( &sx->end_date );
}
const GDate*
xaccSchedXactionGetEndDate(const SchedXaction *sx )
{
g_assert (sx);
return &sx->end_date;
}
void
xaccSchedXactionSetEndDate( SchedXaction *sx, const GDate *newEnd )
{
if (newEnd == NULL
|| !g_date_valid( newEnd )
|| g_date_compare( newEnd, &sx->start_date ) < 0 )
{
/* XXX: I reject the bad data - is this the right
* thing to do <rgmerk>.
* This warning is only human readable - the caller
* doesn't know the call failed. This is bad
*/
g_critical("Bad End Date: Invalid or before Start Date");
return;
}
gnc_sx_begin_edit(sx);
sx->end_date = *newEnd;
qof_instance_set_dirty(&sx->inst);
gnc_sx_commit_edit(sx);
}
const GDate*
xaccSchedXactionGetLastOccurDate(const SchedXaction *sx )
{
return &sx->last_date;
}
void
xaccSchedXactionSetLastOccurDate(SchedXaction *sx, const GDate* new_last_occur)
{
if (g_date_valid(&sx->last_date)
&& g_date_compare(&sx->last_date, new_last_occur) == 0)
return;
gnc_sx_begin_edit(sx);
sx->last_date = *new_last_occur;
qof_instance_set_dirty(&sx->inst);
gnc_sx_commit_edit(sx);
}
gboolean
xaccSchedXactionHasOccurDef( const SchedXaction *sx )
{
return ( xaccSchedXactionGetNumOccur( sx ) != 0 );
}
gint
xaccSchedXactionGetNumOccur( const SchedXaction *sx )
{
return sx->num_occurances_total;
}
void
xaccSchedXactionSetNumOccur(SchedXaction *sx, gint new_num)
{
if (sx->num_occurances_total == new_num)
return;
gnc_sx_begin_edit(sx);
sx->num_occurances_remain = sx->num_occurances_total = new_num;
qof_instance_set_dirty(&sx->inst);
gnc_sx_commit_edit(sx);
}
gint
xaccSchedXactionGetRemOccur( const SchedXaction *sx )
{
return sx->num_occurances_remain;
}
void
xaccSchedXactionSetRemOccur(SchedXaction *sx, gint num_remain)
{
/* FIXME This condition can be tightened up */
if (num_remain > sx->num_occurances_total)
{
g_warning("number remaining [%d] > total occurrences [%d]",
num_remain, sx->num_occurances_total);
}
else
{
if (num_remain == sx->num_occurances_remain)
return;
gnc_sx_begin_edit(sx);
sx->num_occurances_remain = num_remain;
qof_instance_set_dirty(&sx->inst);
gnc_sx_commit_edit(sx);
}
}
gint gnc_sx_get_num_occur_daterange(const SchedXaction *sx, const GDate* start_date, const GDate* end_date)
{
gint result = 0;
SXTmpStateData *tmpState;
gboolean countFirstDate;
/* SX still active? If not, return now. */
if ((xaccSchedXactionHasOccurDef(sx)
&& xaccSchedXactionGetRemOccur(sx) <= 0)
|| (xaccSchedXactionHasEndDate(sx)
&& g_date_compare(xaccSchedXactionGetEndDate(sx), start_date) < 0))
{
return result;
}
tmpState = gnc_sx_create_temporal_state (sx);
/* Should we count the first valid date we encounter? Only if the
* SX has not yet occurred so far, or if its last valid date was
* before the start date. */
countFirstDate = !g_date_valid(&tmpState->last_date)
|| (g_date_compare(&tmpState->last_date, start_date) < 0);
/* No valid date? SX has never occurred so far. */
if (!g_date_valid(&tmpState->last_date))
{
/* SX has never occurred so far */
gnc_sx_incr_temporal_state (sx, tmpState);
if (xaccSchedXactionHasOccurDef(sx) && tmpState->num_occur_rem < 0)
{
gnc_sx_destroy_temporal_state (tmpState);
return result;
}
}
/* Increase the tmpState until we are in our interval of
* interest. Only calculate anything if the sx hasn't already
* ended. */
while (g_date_compare(&tmpState->last_date, start_date) < 0)
{
gnc_sx_incr_temporal_state (sx, tmpState);
if (xaccSchedXactionHasOccurDef(sx) && tmpState->num_occur_rem < 0)
{
gnc_sx_destroy_temporal_state (tmpState);
return result;
}
}
/* Now we are in our interval of interest. Increment the
* occurrence date until we are beyond the end of our
* interval. Make sure to check for invalid dates here: It means
* the SX has ended. */
while (g_date_valid(&tmpState->last_date)
&& (g_date_compare(&tmpState->last_date, end_date) <= 0)
&& (!xaccSchedXactionHasEndDate(sx)
|| g_date_compare(&tmpState->last_date, xaccSchedXactionGetEndDate(sx)) <= 0)
&& (!xaccSchedXactionHasOccurDef(sx)
/* The >=0 (i.e. the ==) is important here, otherwise
* we miss the last valid occurrence of a SX which is
* limited by num_occur */
|| tmpState->num_occur_rem >= 0))
{
++result;
gnc_sx_incr_temporal_state (sx, tmpState);
}
/* If the first valid date shouldn't be counted, decrease the
* result number by one. */
if (!countFirstDate && result > 0)
--result;
gnc_sx_destroy_temporal_state (tmpState);
return result;
}
gboolean
xaccSchedXactionGetEnabled( const SchedXaction *sx )
{
return sx->enabled;
}
void
xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled)
{
gnc_sx_begin_edit(sx);
sx->enabled = newEnabled;
qof_instance_set_dirty(&sx->inst);
gnc_sx_commit_edit(sx);
}
void
xaccSchedXactionGetAutoCreate( const SchedXaction *sx,
gboolean *outAutoCreate,
gboolean *outNotify )
{
if (outAutoCreate != NULL)
*outAutoCreate = sx->autoCreateOption;
if (outNotify != NULL)
*outNotify = sx->autoCreateNotify;
return;
}
void
xaccSchedXactionSetAutoCreate( SchedXaction *sx,
gboolean newAutoCreate,
gboolean newNotify )
{
gnc_sx_begin_edit(sx);
sx->autoCreateOption = newAutoCreate;
sx->autoCreateNotify = newNotify;
qof_instance_set_dirty(&sx->inst);
gnc_sx_commit_edit(sx);
return;
}
gint
xaccSchedXactionGetAdvanceCreation( const SchedXaction *sx )
{
return sx->advanceCreateDays;
}
void
xaccSchedXactionSetAdvanceCreation( SchedXaction *sx, gint createDays )
{
gnc_sx_begin_edit(sx);
sx->advanceCreateDays = createDays;
qof_instance_set_dirty(&sx->inst);
gnc_sx_commit_edit(sx);
}
gint
xaccSchedXactionGetAdvanceReminder( const SchedXaction *sx )
{
return sx->advanceRemindDays;
}
void
xaccSchedXactionSetAdvanceReminder( SchedXaction *sx, gint reminderDays )
{
gnc_sx_begin_edit(sx);
sx->advanceRemindDays = reminderDays;
qof_instance_set_dirty(&sx->inst);
gnc_sx_commit_edit(sx);
}
GDate
xaccSchedXactionGetNextInstance(const SchedXaction *sx, SXTmpStateData *stateData )
{
GDate last_occur, next_occur, tmpDate;
g_date_clear( &last_occur, 1 );
g_date_clear( &next_occur, 1 );
g_date_clear( &tmpDate, 1 );
if ( g_date_valid( &sx->last_date ) )
{
last_occur = sx->last_date;
}
if ( stateData != NULL )
{
SXTmpStateData *tsd = (SXTmpStateData*)stateData;
last_occur = tsd->last_date;
}
if ( g_date_valid( &sx->start_date ) )
{
if ( g_date_valid(&last_occur) )
{
last_occur =
( g_date_compare( &last_occur,
&sx->start_date ) > 0 ?
last_occur : sx->start_date );
}
else
{
/* Think about this for a second, and you realize that if the
* start date is _today_, we need a last-occur date such that
* the 'next instance' is after that date, and equal to the
* start date... one day should be good.
*
* This only holds for the first instance [read: if the
* last[-occur]_date is invalid] */
last_occur = sx->start_date;
g_date_subtract_days( &last_occur, 1 );
}
}
recurrenceListNextInstance(sx->schedule, &last_occur, &next_occur);
/* out-of-bounds check */
if ( xaccSchedXactionHasEndDate( sx ) )
{
const GDate *end_date = xaccSchedXactionGetEndDate( sx );
if ( g_date_compare( &next_occur, end_date ) > 0 )
{
g_debug("next_occur past end date");
g_date_clear( &next_occur, 1 );
}
}
else if ( xaccSchedXactionHasOccurDef( sx ) )
{
if ( stateData )
{
SXTmpStateData *tsd = (SXTmpStateData*)stateData;
if ( tsd->num_occur_rem == 0 )
{
g_debug("no more occurances remain");
g_date_clear( &next_occur, 1 );
}
}
else
{
if ( sx->num_occurances_remain == 0 )
{
g_date_clear( &next_occur, 1 );
}
}
}
return next_occur;
}
2001-10-22 Joshua Sled <jsled@asynchronous.org> * src/gnome/Makefile.am: Removed obsolete dialog-nextrun.{c,h} * src/gnome/window-main.c (gnc_main_window_create_menus): Added both Scheduled Transaction-related items to "Scheduled Transactions" sub-menu of "Tools". (gnc_main_window_about_cb): Added self to GUI About dlg. * src/gnome/dialog-scheduledxaction.c: Renamed '_'-led functions. * src/gnome/dialog-sxsincelast.c: Changed from a loose confederation of multiple dialogs to the strong central authority of a GnomeDruid-based since-last-run UI. Renamed '_'-led functions. * src/gnome/glade/sched-xact.glade: Fixed a non-unique-name problem between the GnomeNumberEntry "end_nentry" and it's GtkEntry "end_nentry". Added Druid-based Since-Last-Run dialog. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate), (editor_ok_button_clicked): Added support for now-uniquely-named "end_gnome_nentry". * src/engine/SchedXaction.c (xaccSchedXactionCreateSequenceState): Added. (xaccSchedXactionIncrSequenceState): Added. (xaccSchedXactionDestroySequenceState): Added. Added support for opaque state data when generating a sequence of SX instances to support number-of-occurance-terminated SXes. * src/backend/file/gnc-freqspec-xml-v2.c (dom_tree_to_freqSpec): Added missing instance of GNCSession propogation. * src/backend/file/io-gncxml-v2.c (write_template_transaction_data): Added correct determination for writing out the template-transaction section [before: only if transactions existed in accounts; now: if any accounts exist] to prevent read errors from SXes with valid-and-referenced Accounts, but no Transactions in them. * src/gnome-utils/gnc-frequency.c (gnc_frequency_setup): Better error text when UIFreqType isn't recognized or appropriate. * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): Correctly sets SXes to have no occurance data if that's the case. Better option variable naming, usage. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5710 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-10-22 09:17:34 +00:00
GDate
xaccSchedXactionGetInstanceAfter( const SchedXaction *sx,
2001-10-22 Joshua Sled <jsled@asynchronous.org> * src/gnome/Makefile.am: Removed obsolete dialog-nextrun.{c,h} * src/gnome/window-main.c (gnc_main_window_create_menus): Added both Scheduled Transaction-related items to "Scheduled Transactions" sub-menu of "Tools". (gnc_main_window_about_cb): Added self to GUI About dlg. * src/gnome/dialog-scheduledxaction.c: Renamed '_'-led functions. * src/gnome/dialog-sxsincelast.c: Changed from a loose confederation of multiple dialogs to the strong central authority of a GnomeDruid-based since-last-run UI. Renamed '_'-led functions. * src/gnome/glade/sched-xact.glade: Fixed a non-unique-name problem between the GnomeNumberEntry "end_nentry" and it's GtkEntry "end_nentry". Added Druid-based Since-Last-Run dialog. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate), (editor_ok_button_clicked): Added support for now-uniquely-named "end_gnome_nentry". * src/engine/SchedXaction.c (xaccSchedXactionCreateSequenceState): Added. (xaccSchedXactionIncrSequenceState): Added. (xaccSchedXactionDestroySequenceState): Added. Added support for opaque state data when generating a sequence of SX instances to support number-of-occurance-terminated SXes. * src/backend/file/gnc-freqspec-xml-v2.c (dom_tree_to_freqSpec): Added missing instance of GNCSession propogation. * src/backend/file/io-gncxml-v2.c (write_template_transaction_data): Added correct determination for writing out the template-transaction section [before: only if transactions existed in accounts; now: if any accounts exist] to prevent read errors from SXes with valid-and-referenced Accounts, but no Transactions in them. * src/gnome-utils/gnc-frequency.c (gnc_frequency_setup): Better error text when UIFreqType isn't recognized or appropriate. * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): Correctly sets SXes to have no occurance data if that's the case. Better option variable naming, usage. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5710 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-10-22 09:17:34 +00:00
GDate *date,
SXTmpStateData *stateData )
{
GDate prev_occur, next_occur;
g_date_clear( &prev_occur, 1 );
if ( date )
{
prev_occur = *date;
}
if ( stateData != NULL )
{
SXTmpStateData *tsd = (SXTmpStateData*)stateData;
prev_occur = tsd->last_date;
}
if ( ! g_date_valid( &prev_occur ) )
{
/* We must be at the beginning. */
prev_occur = sx->start_date;
g_date_subtract_days( &prev_occur, 1 );
}
recurrenceListNextInstance(sx->schedule, &prev_occur, &next_occur);
if ( xaccSchedXactionHasEndDate( sx ) )
{
const GDate *end_date = xaccSchedXactionGetEndDate( sx );
if ( g_date_compare( &next_occur, end_date ) > 0 )
{
g_date_clear( &next_occur, 1 );
}
}
else if ( xaccSchedXactionHasOccurDef( sx ) )
{
if ( stateData )
{
SXTmpStateData *tsd = (SXTmpStateData*)stateData;
if ( tsd->num_occur_rem == 0 )
{
g_date_clear( &next_occur, 1 );
}
}
else
{
if ( sx->num_occurances_remain == 0 )
{
g_date_clear( &next_occur, 1 );
}
}
}
return next_occur;
}
2002-07-24 Joshua Sled <jsled@asynchronous.org> * src/scm/fin.scm: Made the exposed calcualtion functions output positive values. * src/gnome/window-main.c (gnc_main_window_create_menus): Added accelerators to SX-related menu items. * src/gnome/druid-loan.c: Primary change: actually create the Scheduled Transactions which are setup by the user. Miscellaneous other cleanups, text, layout and consistency changes. * src/gnome/dialog-sxsincelast.c: Support handling of the instance-count in forward-looking transaction creation. Simplfied some of the internal data-representation regarding lists of items to be created [removed autoCreateTuple, now uses toCreateTuple]. Removed some DEBUGging output. Handles setting up the implicit 'i' variable. * src/gnome/dialog-sx-from-trans.c (sxftd_compute_sx): Create SXes with an appropriate initial instance-count value. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate): Create SXes with an appropriate initial instance-count value. * src/engine/SchedXaction.[ch]: Added support for an instance-count, in order to support an implicit 'i' [of N] variable to SX formula/function processing. * src/engine/SX-ttinfo.c (gnc_ttsplitinfo_free): Made the ttsplitinfo_free'ing a bit safer. * src/calculation/expression_parser.c: Added support for parsing/handling quoted strings. Intended to be parameters to functions. Fixed bug regarding nested handling of strings in the parser. * src/backend/file/gnc-schedxaction-xml-v2.c: Added support for saving/restoring instance-count field of SXes. * src/app-utils/test/test-exp-parser.c (run_parser_test): Fixed pass/fail indication check. (test_parser): Added tests for string params to functions. * ChangeLog: Added entry I forgot from last time. * src/app-utils/gnc-exp-parser.c (func_op): Added support for typed parameters to functions; params are either numerics or strings. Result of function is now parsed correctly. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7125 57a11ea4-9604-0410-9ed3-97b8803252fd
2002-07-24 22:04:57 +00:00
gint
gnc_sx_get_instance_count( const SchedXaction *sx, SXTmpStateData *stateData )
2002-07-24 Joshua Sled <jsled@asynchronous.org> * src/scm/fin.scm: Made the exposed calcualtion functions output positive values. * src/gnome/window-main.c (gnc_main_window_create_menus): Added accelerators to SX-related menu items. * src/gnome/druid-loan.c: Primary change: actually create the Scheduled Transactions which are setup by the user. Miscellaneous other cleanups, text, layout and consistency changes. * src/gnome/dialog-sxsincelast.c: Support handling of the instance-count in forward-looking transaction creation. Simplfied some of the internal data-representation regarding lists of items to be created [removed autoCreateTuple, now uses toCreateTuple]. Removed some DEBUGging output. Handles setting up the implicit 'i' variable. * src/gnome/dialog-sx-from-trans.c (sxftd_compute_sx): Create SXes with an appropriate initial instance-count value. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate): Create SXes with an appropriate initial instance-count value. * src/engine/SchedXaction.[ch]: Added support for an instance-count, in order to support an implicit 'i' [of N] variable to SX formula/function processing. * src/engine/SX-ttinfo.c (gnc_ttsplitinfo_free): Made the ttsplitinfo_free'ing a bit safer. * src/calculation/expression_parser.c: Added support for parsing/handling quoted strings. Intended to be parameters to functions. Fixed bug regarding nested handling of strings in the parser. * src/backend/file/gnc-schedxaction-xml-v2.c: Added support for saving/restoring instance-count field of SXes. * src/app-utils/test/test-exp-parser.c (run_parser_test): Fixed pass/fail indication check. (test_parser): Added tests for string params to functions. * ChangeLog: Added entry I forgot from last time. * src/app-utils/gnc-exp-parser.c (func_op): Added support for typed parameters to functions; params are either numerics or strings. Result of function is now parsed correctly. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7125 57a11ea4-9604-0410-9ed3-97b8803252fd
2002-07-24 22:04:57 +00:00
{
gint toRet = -1;
SXTmpStateData *tsd;
2002-07-24 Joshua Sled <jsled@asynchronous.org> * src/scm/fin.scm: Made the exposed calcualtion functions output positive values. * src/gnome/window-main.c (gnc_main_window_create_menus): Added accelerators to SX-related menu items. * src/gnome/druid-loan.c: Primary change: actually create the Scheduled Transactions which are setup by the user. Miscellaneous other cleanups, text, layout and consistency changes. * src/gnome/dialog-sxsincelast.c: Support handling of the instance-count in forward-looking transaction creation. Simplfied some of the internal data-representation regarding lists of items to be created [removed autoCreateTuple, now uses toCreateTuple]. Removed some DEBUGging output. Handles setting up the implicit 'i' variable. * src/gnome/dialog-sx-from-trans.c (sxftd_compute_sx): Create SXes with an appropriate initial instance-count value. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate): Create SXes with an appropriate initial instance-count value. * src/engine/SchedXaction.[ch]: Added support for an instance-count, in order to support an implicit 'i' [of N] variable to SX formula/function processing. * src/engine/SX-ttinfo.c (gnc_ttsplitinfo_free): Made the ttsplitinfo_free'ing a bit safer. * src/calculation/expression_parser.c: Added support for parsing/handling quoted strings. Intended to be parameters to functions. Fixed bug regarding nested handling of strings in the parser. * src/backend/file/gnc-schedxaction-xml-v2.c: Added support for saving/restoring instance-count field of SXes. * src/app-utils/test/test-exp-parser.c (run_parser_test): Fixed pass/fail indication check. (test_parser): Added tests for string params to functions. * ChangeLog: Added entry I forgot from last time. * src/app-utils/gnc-exp-parser.c (func_op): Added support for typed parameters to functions; params are either numerics or strings. Result of function is now parsed correctly. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7125 57a11ea4-9604-0410-9ed3-97b8803252fd
2002-07-24 22:04:57 +00:00
if ( stateData )
{
tsd = (SXTmpStateData*)stateData;
toRet = tsd->num_inst;
}
else
{
toRet = sx->instance_num;
}
2002-07-24 Joshua Sled <jsled@asynchronous.org> * src/scm/fin.scm: Made the exposed calcualtion functions output positive values. * src/gnome/window-main.c (gnc_main_window_create_menus): Added accelerators to SX-related menu items. * src/gnome/druid-loan.c: Primary change: actually create the Scheduled Transactions which are setup by the user. Miscellaneous other cleanups, text, layout and consistency changes. * src/gnome/dialog-sxsincelast.c: Support handling of the instance-count in forward-looking transaction creation. Simplfied some of the internal data-representation regarding lists of items to be created [removed autoCreateTuple, now uses toCreateTuple]. Removed some DEBUGging output. Handles setting up the implicit 'i' variable. * src/gnome/dialog-sx-from-trans.c (sxftd_compute_sx): Create SXes with an appropriate initial instance-count value. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate): Create SXes with an appropriate initial instance-count value. * src/engine/SchedXaction.[ch]: Added support for an instance-count, in order to support an implicit 'i' [of N] variable to SX formula/function processing. * src/engine/SX-ttinfo.c (gnc_ttsplitinfo_free): Made the ttsplitinfo_free'ing a bit safer. * src/calculation/expression_parser.c: Added support for parsing/handling quoted strings. Intended to be parameters to functions. Fixed bug regarding nested handling of strings in the parser. * src/backend/file/gnc-schedxaction-xml-v2.c: Added support for saving/restoring instance-count field of SXes. * src/app-utils/test/test-exp-parser.c (run_parser_test): Fixed pass/fail indication check. (test_parser): Added tests for string params to functions. * ChangeLog: Added entry I forgot from last time. * src/app-utils/gnc-exp-parser.c (func_op): Added support for typed parameters to functions; params are either numerics or strings. Result of function is now parsed correctly. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7125 57a11ea4-9604-0410-9ed3-97b8803252fd
2002-07-24 22:04:57 +00:00
return toRet;
2002-07-24 Joshua Sled <jsled@asynchronous.org> * src/scm/fin.scm: Made the exposed calcualtion functions output positive values. * src/gnome/window-main.c (gnc_main_window_create_menus): Added accelerators to SX-related menu items. * src/gnome/druid-loan.c: Primary change: actually create the Scheduled Transactions which are setup by the user. Miscellaneous other cleanups, text, layout and consistency changes. * src/gnome/dialog-sxsincelast.c: Support handling of the instance-count in forward-looking transaction creation. Simplfied some of the internal data-representation regarding lists of items to be created [removed autoCreateTuple, now uses toCreateTuple]. Removed some DEBUGging output. Handles setting up the implicit 'i' variable. * src/gnome/dialog-sx-from-trans.c (sxftd_compute_sx): Create SXes with an appropriate initial instance-count value. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate): Create SXes with an appropriate initial instance-count value. * src/engine/SchedXaction.[ch]: Added support for an instance-count, in order to support an implicit 'i' [of N] variable to SX formula/function processing. * src/engine/SX-ttinfo.c (gnc_ttsplitinfo_free): Made the ttsplitinfo_free'ing a bit safer. * src/calculation/expression_parser.c: Added support for parsing/handling quoted strings. Intended to be parameters to functions. Fixed bug regarding nested handling of strings in the parser. * src/backend/file/gnc-schedxaction-xml-v2.c: Added support for saving/restoring instance-count field of SXes. * src/app-utils/test/test-exp-parser.c (run_parser_test): Fixed pass/fail indication check. (test_parser): Added tests for string params to functions. * ChangeLog: Added entry I forgot from last time. * src/app-utils/gnc-exp-parser.c (func_op): Added support for typed parameters to functions; params are either numerics or strings. Result of function is now parsed correctly. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7125 57a11ea4-9604-0410-9ed3-97b8803252fd
2002-07-24 22:04:57 +00:00
}
void
gnc_sx_set_instance_count(SchedXaction *sx, gint instance_num)
2002-07-24 Joshua Sled <jsled@asynchronous.org> * src/scm/fin.scm: Made the exposed calcualtion functions output positive values. * src/gnome/window-main.c (gnc_main_window_create_menus): Added accelerators to SX-related menu items. * src/gnome/druid-loan.c: Primary change: actually create the Scheduled Transactions which are setup by the user. Miscellaneous other cleanups, text, layout and consistency changes. * src/gnome/dialog-sxsincelast.c: Support handling of the instance-count in forward-looking transaction creation. Simplfied some of the internal data-representation regarding lists of items to be created [removed autoCreateTuple, now uses toCreateTuple]. Removed some DEBUGging output. Handles setting up the implicit 'i' variable. * src/gnome/dialog-sx-from-trans.c (sxftd_compute_sx): Create SXes with an appropriate initial instance-count value. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate): Create SXes with an appropriate initial instance-count value. * src/engine/SchedXaction.[ch]: Added support for an instance-count, in order to support an implicit 'i' [of N] variable to SX formula/function processing. * src/engine/SX-ttinfo.c (gnc_ttsplitinfo_free): Made the ttsplitinfo_free'ing a bit safer. * src/calculation/expression_parser.c: Added support for parsing/handling quoted strings. Intended to be parameters to functions. Fixed bug regarding nested handling of strings in the parser. * src/backend/file/gnc-schedxaction-xml-v2.c: Added support for saving/restoring instance-count field of SXes. * src/app-utils/test/test-exp-parser.c (run_parser_test): Fixed pass/fail indication check. (test_parser): Added tests for string params to functions. * ChangeLog: Added entry I forgot from last time. * src/app-utils/gnc-exp-parser.c (func_op): Added support for typed parameters to functions; params are either numerics or strings. Result of function is now parsed correctly. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7125 57a11ea4-9604-0410-9ed3-97b8803252fd
2002-07-24 22:04:57 +00:00
{
g_return_if_fail(sx);
if (sx->instance_num == instance_num)
return;
sx->instance_num = instance_num;
2002-07-24 Joshua Sled <jsled@asynchronous.org> * src/scm/fin.scm: Made the exposed calcualtion functions output positive values. * src/gnome/window-main.c (gnc_main_window_create_menus): Added accelerators to SX-related menu items. * src/gnome/druid-loan.c: Primary change: actually create the Scheduled Transactions which are setup by the user. Miscellaneous other cleanups, text, layout and consistency changes. * src/gnome/dialog-sxsincelast.c: Support handling of the instance-count in forward-looking transaction creation. Simplfied some of the internal data-representation regarding lists of items to be created [removed autoCreateTuple, now uses toCreateTuple]. Removed some DEBUGging output. Handles setting up the implicit 'i' variable. * src/gnome/dialog-sx-from-trans.c (sxftd_compute_sx): Create SXes with an appropriate initial instance-count value. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate): Create SXes with an appropriate initial instance-count value. * src/engine/SchedXaction.[ch]: Added support for an instance-count, in order to support an implicit 'i' [of N] variable to SX formula/function processing. * src/engine/SX-ttinfo.c (gnc_ttsplitinfo_free): Made the ttsplitinfo_free'ing a bit safer. * src/calculation/expression_parser.c: Added support for parsing/handling quoted strings. Intended to be parameters to functions. Fixed bug regarding nested handling of strings in the parser. * src/backend/file/gnc-schedxaction-xml-v2.c: Added support for saving/restoring instance-count field of SXes. * src/app-utils/test/test-exp-parser.c (run_parser_test): Fixed pass/fail indication check. (test_parser): Added tests for string params to functions. * ChangeLog: Added entry I forgot from last time. * src/app-utils/gnc-exp-parser.c (func_op): Added support for typed parameters to functions; params are either numerics or strings. Result of function is now parsed correctly. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7125 57a11ea4-9604-0410-9ed3-97b8803252fd
2002-07-24 22:04:57 +00:00
}
GList *
xaccSchedXactionGetSplits( const SchedXaction *sx )
{
g_return_val_if_fail( sx, NULL );
return xaccAccountGetSplitList(sx->template_acct);
}
static Split *
pack_split_info (TTSplitInfo *s_info, Account *parent_acct,
Transaction *parent_trans, QofBook *book)
{
Split *split;
KvpFrame *split_frame;
KvpValue *tmp_value;
const GncGUID *acc_guid;
split = xaccMallocSplit(book);
xaccSplitSetMemo(split,
gnc_ttsplitinfo_get_memo(s_info));
Implement a Book Option to give users the choice to use the transaction number field (default and current behaviour) or, alternatively, the split action field of the anchor split for 'Num' column on registers, reports, import and export, where applicable. The difference between the two is that with the default, the same 'Num' is displayed for a given transaction regardless of what register it is viewed in and with the new option, a different 'Num' can be entered/displayed for a given transaction in each register it is viewed in. In both cases, the 'next number logic' of the 'Num' cell is based on the account of the register the transaction is entered/viewed from but in one case it fills the transaction number, in the other, it fills the split action field of the anchor split (with the transaction number field displayed in the register cell labeled 'T-Num'). In both cases, both fields are visible and can be used as free-form text in double-line mode for any value the user wants. If the new option is not selected, there should be no change in Gnucash's behaviour with the exception of displaying the book options dialog in 'new book' situations. The changes made are: 1. Implement the new book option to select source for 'num' cell: libqof/qof/qofbookslots.h - define num source option engine/engine.i - define 'NUM-FIELD-SOURCE' as an option name and 'SPLIT-ACTION' as a term for sorting queries app-utils/business-prefs.scm - define book option for num-field-source app-utils/app-utils.scm - define and export book option for num-field-source 2. Implement functions to get book option setting and to test: libqof/qof/qofbook.c & .h - define function to get number source book option libqof/qof/test/test-qofbook.c - test function to get number source book option 3. Implement a notification mechanism for book option changes: engine/engine-helpers.c & .h - define functions to register callbacks, define function to remove callbacks and define function to initiate callbacks on book num-source option changes core-utils/gnc-features.c & .h - define feature for num-source app-utils/gnc-ui-util.c & .h - define gnc_book_option_num_field_source_change_cb; include setting of feature flag on initial use gnome-utils/gnc-main-window.c - change name of gnc_options_dialog_apply_cb function to gnc_book_options_dialog_apply_cb and adjust function to call function gnc_book_option_num_field_source_change_cb when book option for num-field-source changes; change name of gnc_options_dialog_close_cb to gnc_book_options_dialog_close_cb 4. Implement 'help' button response on Book Option Dialog: gnome-utils/gnc-ui.h - define "book-options" section of help manual gnome-utils/gnc-gnome-utils.c & .h - implement Book Options help callback gnome-utils/gnc-main-window.c - use gnc_options_dialog_set_book_options_help_cb to make help button active 5. Implement utility functions to get/set number/action based on book option: engine/engine-helpers.c & .h - define 'gnc_get_num_action' function define 'gnc_get_action_num' function define 'gnc_set_num_action' function engine/engine.i - make get/set num/action functions available to guile & allow #f to be used in place of NULL from guile engine/Transaction.h - add reference to utility functions in comments to xaccTransSetNum and xaccTransGetNum functions engine/Split.h - add reference to utility functions in comments to xaccSplitSetAction and xaccSplitGetAction functions 6. Implement register use of num source book option; for General, Income and Search Ledgers, since there is no anchor split, always show tran-num in transaction cursor, but vary label to correspond to book option: register/ledger-core/split-register.h - define TNUM_CELL define CURSOR_DOUBLE_LEDGER_NUM_ACTN cursor name to use TNUM_CELL define CURSOR_DOUBLE_JOURNAL_NUM_ACTN cursor name to use TNUM_CELL add boolean to split_reg structure to hold num source book option register/ledger-core/split-register-layout.c - add logic to define and set up new ledger/journal cursors with TNUM_CELLs add logic to add the new cursors to a layout add logic to add TNUM_CELL to a layout register/ledger-core/split-register-model.c - define function to get TNUM_CELL label add logic to recognize ledger/journal cursors with TNUM_CELL modify function to get NUM_CELL value based on book option and register type define function to get TNUM_CELL value adjust num help text to reflect book option choice define function to get TNUM_CELL help modify function to get action help to reflect book option choice set up handlers for TNUM_CELL register/ledger-core/split-register-model-save.c - use 'gnc_set_num_action' function to set num/action for NUM_CELL based on book option define function to save TNUM_CELL using 'gnc_set_num_action' function set save handler for TNUM_CELL register/ledger-core/split-register-util.c - modify logic to recognize ledger/journal cursors with tnum_cell register/ledger-core/split-register.c - define split_register_book_option_changed function register split_register_book_option_changed function in register init initialize register structure setting to book option remove split_register_book_option_changed function in register destroy modify gnc_split_register_save_to_scm to handle TNUM_CELL 7. Enhance transaction copy/duplicate logic to accommodate new book option: gnome/gtkbuilder/gnc-plugin-page-register.glade - add widgets to handle trans number and/or split action based on book option gnome-utils/dialog-dup-trans.c & .h - add capability to display and handle 'Num' field according to book option gnome/gnc-plugin-page-register.c - define gnc_find_register_by_account register/ledger-core/split-register.c - modify gnc_split_register_duplicate_current to accomodate book option setting register/ledger-core/Makefile.am - add GNOME_CFLAGS register/ledger-core/test/Makefile.am - add libgnc-gnome.la 8. Adjust register sort and sort labels related to Num/Action radio buttons to correspond to book option for clarity: gnome/gnc-plugin-page-register.c - define gnc_plugin_page_register_sort_book_option_changed to adjust labels register function in gnc_plugin_page_register_cmd_view_sort_by and save num and action radio widgets initialize radio widget labels to correspond to book option remove function in gnc_plugin_page_register_sort_response_cb and clear num and action radio widgets gnome/gnc-split-reg.c & h. - create versions of gnc_split_reg_sort and gnc_split_reg_set_sort to force a re-sort to be used when num-source book option changes engine/Transaction.c & .h - modify default sort to use split action in place of tran num per book option if called from xaccSplitOrder engine/Split.c - modify xaccSplitOrder to call xaccTransOrder_num_action to switch use of split action and tran num per book option engine/test/utest-Split.c - modify test_xaccSplitOrder to call xaccTransOrder_num_action based on book option 9. Adjust transaction find labels related to Num/Action to correspond to book option for clarity: gnome/dialog-find-transactions.c - adjust labels in search criteria based on book option gnome-search/dialog-search.c - define gnc_search_dialog_book_option_changed to adjust labels register function in gnc_search_dialog_init_widgets when searching for splits remove function in gnc_search_dialog_close_cb if registered 10. Modify new file process to allow setting of num-source (actually, all) book option(s) during New Account Hierarchy Setup: gnome-utils/gtkbuilder/dialog-preferences.glade - add a user preference for the default setting for 'num-source' for new books core-utils/gnc-gconf-utils.h - define KEY_NUM_SOURCE gnome-utils/gnc-gnome-utils.c & h. - define gnc_options_dialog_set_new_book_option_values to retrieve preference values gnome-utils/dialog-options.c & .h - define gnc_options_dialog_new_modal to surpress apply button gnome-utils/gnc-main-window.c - define function gnc_book_options_dialog_cb with arguments so that the window can be called in modal mode and the title changed and return dialog widget; call gnc_options_dialog_new_modal instead of gnc_options_dialog_new; call this function from gnc_main_window_cmd_file_properties with new arguments; for modal mode, call gnc-options-dialog-set-new-book-option-values to initialize values from preferences app-utils/gnc-ui-util.c & h. - create function gnc_is_new_book for determining when a new book is being created gnome-utils/dialog-utils.c & h. - define gnc_new_book_option_display to display book options dialog in modal mode gnome/gtkbuilder/assistant-hierarchy.glade - add notification about book options to currency page gnome/assistant-hierarchy.c - add ability to set book option initialized from preferences value for new books by using functions gnc_is_new_book and gnc_new_book_option_display 11. Modify Import QIF process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/qif-import/assistant-qif-import.glade - add notification about book options to currency page import-export/qif-import/assistant-qif-import.c - using function gnc_is_new_book to identify 'new book' situation and set flag; add logic to handle 'new-book' situation by calling gnc_new_book_option_display function import-export/qif-import/qif-to-gnc.scm - use 'gnc_set_num_action' function to import number to correct field based on book option 12. Modify Import OFX/QFX process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/ofx/gnc-ofx-import.c - use 'gnc_set_num_action' function to import number based on book option; identify 'new book' situation using function gnc_is_new_book and set flag; add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function import-export/import-backend.c - use 'gnc_get_num_action' function to retrieve number from transactions to be matched based on book option 13. Modify Import AqBanking process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number: import-export/aqbanking/gnc-file-aqb-import.c - identify 'new book' situation using function gnc_is_new_book and handle by raising book options dialog by calling gnc_new_book_option_display function import-export/aqbanking/gnc-ab-utils.c - use 'gnc_set_num_action' function to set number based on book option 14. Modify Import Transactions from CSV process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/csv-import/assistant-csv-trans-import.glade - modify commments to alert user of raising book options dialog in cases of csv import into a new book import-export/csv-import/gnc-csv-model.c & h. - use 'gnc_set_num_action' function to import number based on book option import-export/csv-import/assistant-csv-trans-import.c - add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function; identify 'new book' situation using function gnc_is_new_book and set flag 15. Modify Import Accounts from CSV process to recognize a new-book situation and allow setting of book options during first import into a new book import-export/csv-import/assistant-csv-account-import.c & .h - add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function; identify 'new book' situation using function gnc_is_new_book and set flag 16. Modify Export Transactions to CSV process to follow book option setting for num source in exporting transactions: import-export/csv-export/csv-transactions-export.c - modify headings to reflect num-source book option and use 'gnc_get_num_action' function to retrieve number and action 17. Modify register reporting to reflect book option setting for num source: gnome/gnc-plugin-page-register.c - determine and pass along ledger-type? argument to gnc:register-report-create function gnome/gnc-plugin-page-register2.c - determine and pass along ledger-type? argument to gnc:register-report-create function report/standard-reports/standard-reports.scm - add ledger-type? argument to gnc:register-report-create function; pass it along to gnc:register-report-create-internal function report/standard-reports/register.scm - add ledger-type? argument to gnc:register-report-create-internal function; use 'gnc-get-num-action' function in place of xaccTransGetNum and 'gnc-get-action-num' function in place of xaccSplitGetAction and modify report headings and option text accordingly 18. Modify all places that use xaccTransSetNum and/or xaccSplitSetAction to use 'gnc_set_num_action' function to set number based on book option except engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c, engine/Split.c & .h, engine/test/utest-Split.c, engine/engine-helpers.c & .h, engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c, backend/xml/io-gncxml-v1.c, import-export/log-replay/gnc-log-replay.c: engine/gncOwner.c - use 'gnc_set_num_action' function to set number based on book option engine/gncInvoice.c - use 'gnc_set_num_action' function to set number based on book option engine/SchedXaction.c - use 'gnc_set_num_action' function to set number and action engine/cap-gains.c - use 'gnc_set_num_action' function to set split-action gnome-utils/dialog-transfer.c - use 'gnc_set_num_action' function to set number based on book option gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_set_num_action' function to set number/action based on book option gnome/assistant-stock-split.c - use 'gnc_set_num_action' function to set split-action 19. Modify all places that use xaccTransGetNum and/or xaccSplitGetAction to use 'gnc_get_num_action' or 'gnc_get_action_num' functions to get number based on book option except engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c, engine/Split.c & h., engine/test/utest-Split.c, engine/engine-helpers.c, engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c, backend/xml/test/test-xml-transaction.c: gnome/dialog-lot-viewer.c - use 'gnc_get_num_action' function to retrieve number based on book option gnome/dialog-sx-from-trans.c - use 'gnc_get_num_action' function to retrieve number and action gnome/dialog-print-check.c - use 'gnc_get_num_action' function to retrieve number and 'gnc_get_action_num' function to retrieve action register/ledger-core/split-register-model.c - use 'gnc_get_num_action' function to retrieve number based on book option register/ledger-core/split-register-load.c - use 'gnc_get_num_action' function to retrieve number based on book option register/ledger-core/split-register-control.c - use 'gnc_get_num_action' function to retrieve action register/ledger-core/split-register.c - use 'gnc_get_num_action' function to retrieve transaction-num engine/cap-gains.c - use 'gnc_get_num_action' function to get split-action gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_get_num_action' function to retrieve number and 'gnc_get_action_num' function to retrieve action gnome-utils/gnc-tree-model-split-reg.c - use 'gnc_get_num_action' function to retrieve transaction-number but may not be getting what is expected if book option to use split-action for 'num' is set report/locale-specific/us/taxtxf.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum and 'gnc-get-action-num' function in place of xaccSplitGetAction and modify report headings and option text accordingly report/standard-reports/transaction.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum, adjust sorting based on book option and modify report headings and option text accordingly; add 'SPLIT-ACTION' as a term for sorting queries report/business-reports/customer-summary.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum report/business-reports/owner-report.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum report/business-reports/job-report.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum business/business-gnome/dialog-payment.c - use 'gnc_get_num_action' function to retrieve number based on book option git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22681 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-12-22 06:00:54 +00:00
/* Set split-action with gnc_set_num_action which is the same as
* xaccSplitSetAction with these arguments */
gnc_set_num_action(NULL, split, NULL,
gnc_ttsplitinfo_get_action(s_info));
xaccAccountInsertSplit(parent_acct,
split);
split_frame = xaccSplitGetSlots(split);
tmp_value
= kvp_value_new_string(gnc_ttsplitinfo_get_credit_formula(s_info));
kvp_frame_set_slot_path(split_frame,
tmp_value,
GNC_SX_ID,
GNC_SX_CREDIT_FORMULA,
NULL);
kvp_value_delete(tmp_value);
tmp_value
= kvp_value_new_string(gnc_ttsplitinfo_get_debit_formula(s_info));
kvp_frame_set_slot_path(split_frame,
tmp_value,
GNC_SX_ID,
GNC_SX_DEBIT_FORMULA,
NULL);
kvp_value_delete(tmp_value);
acc_guid = qof_entity_get_guid(QOF_INSTANCE(gnc_ttsplitinfo_get_account(s_info)));
tmp_value = kvp_value_new_guid(acc_guid);
kvp_frame_set_slot_path(split_frame,
tmp_value,
GNC_SX_ID,
GNC_SX_ACCOUNT,
NULL);
kvp_value_delete(tmp_value);
return split;
}
void
xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list,
QofBook *book)
{
Transaction *new_trans;
TTInfo *tti;
TTSplitInfo *s_info;
Split *new_split;
GList *split_list;
g_return_if_fail (book);
/* delete any old transactions, if there are any */
delete_template_trans( sx );
for (; t_t_list != NULL; t_t_list = t_t_list->next)
{
tti = t_t_list->data;
new_trans = xaccMallocTransaction(book);
xaccTransBeginEdit(new_trans);
xaccTransSetDescription(new_trans,
gnc_ttinfo_get_description(tti));
xaccTransSetDatePostedSecs(new_trans, gnc_time (NULL));
Implement a Book Option to give users the choice to use the transaction number field (default and current behaviour) or, alternatively, the split action field of the anchor split for 'Num' column on registers, reports, import and export, where applicable. The difference between the two is that with the default, the same 'Num' is displayed for a given transaction regardless of what register it is viewed in and with the new option, a different 'Num' can be entered/displayed for a given transaction in each register it is viewed in. In both cases, the 'next number logic' of the 'Num' cell is based on the account of the register the transaction is entered/viewed from but in one case it fills the transaction number, in the other, it fills the split action field of the anchor split (with the transaction number field displayed in the register cell labeled 'T-Num'). In both cases, both fields are visible and can be used as free-form text in double-line mode for any value the user wants. If the new option is not selected, there should be no change in Gnucash's behaviour with the exception of displaying the book options dialog in 'new book' situations. The changes made are: 1. Implement the new book option to select source for 'num' cell: libqof/qof/qofbookslots.h - define num source option engine/engine.i - define 'NUM-FIELD-SOURCE' as an option name and 'SPLIT-ACTION' as a term for sorting queries app-utils/business-prefs.scm - define book option for num-field-source app-utils/app-utils.scm - define and export book option for num-field-source 2. Implement functions to get book option setting and to test: libqof/qof/qofbook.c & .h - define function to get number source book option libqof/qof/test/test-qofbook.c - test function to get number source book option 3. Implement a notification mechanism for book option changes: engine/engine-helpers.c & .h - define functions to register callbacks, define function to remove callbacks and define function to initiate callbacks on book num-source option changes core-utils/gnc-features.c & .h - define feature for num-source app-utils/gnc-ui-util.c & .h - define gnc_book_option_num_field_source_change_cb; include setting of feature flag on initial use gnome-utils/gnc-main-window.c - change name of gnc_options_dialog_apply_cb function to gnc_book_options_dialog_apply_cb and adjust function to call function gnc_book_option_num_field_source_change_cb when book option for num-field-source changes; change name of gnc_options_dialog_close_cb to gnc_book_options_dialog_close_cb 4. Implement 'help' button response on Book Option Dialog: gnome-utils/gnc-ui.h - define "book-options" section of help manual gnome-utils/gnc-gnome-utils.c & .h - implement Book Options help callback gnome-utils/gnc-main-window.c - use gnc_options_dialog_set_book_options_help_cb to make help button active 5. Implement utility functions to get/set number/action based on book option: engine/engine-helpers.c & .h - define 'gnc_get_num_action' function define 'gnc_get_action_num' function define 'gnc_set_num_action' function engine/engine.i - make get/set num/action functions available to guile & allow #f to be used in place of NULL from guile engine/Transaction.h - add reference to utility functions in comments to xaccTransSetNum and xaccTransGetNum functions engine/Split.h - add reference to utility functions in comments to xaccSplitSetAction and xaccSplitGetAction functions 6. Implement register use of num source book option; for General, Income and Search Ledgers, since there is no anchor split, always show tran-num in transaction cursor, but vary label to correspond to book option: register/ledger-core/split-register.h - define TNUM_CELL define CURSOR_DOUBLE_LEDGER_NUM_ACTN cursor name to use TNUM_CELL define CURSOR_DOUBLE_JOURNAL_NUM_ACTN cursor name to use TNUM_CELL add boolean to split_reg structure to hold num source book option register/ledger-core/split-register-layout.c - add logic to define and set up new ledger/journal cursors with TNUM_CELLs add logic to add the new cursors to a layout add logic to add TNUM_CELL to a layout register/ledger-core/split-register-model.c - define function to get TNUM_CELL label add logic to recognize ledger/journal cursors with TNUM_CELL modify function to get NUM_CELL value based on book option and register type define function to get TNUM_CELL value adjust num help text to reflect book option choice define function to get TNUM_CELL help modify function to get action help to reflect book option choice set up handlers for TNUM_CELL register/ledger-core/split-register-model-save.c - use 'gnc_set_num_action' function to set num/action for NUM_CELL based on book option define function to save TNUM_CELL using 'gnc_set_num_action' function set save handler for TNUM_CELL register/ledger-core/split-register-util.c - modify logic to recognize ledger/journal cursors with tnum_cell register/ledger-core/split-register.c - define split_register_book_option_changed function register split_register_book_option_changed function in register init initialize register structure setting to book option remove split_register_book_option_changed function in register destroy modify gnc_split_register_save_to_scm to handle TNUM_CELL 7. Enhance transaction copy/duplicate logic to accommodate new book option: gnome/gtkbuilder/gnc-plugin-page-register.glade - add widgets to handle trans number and/or split action based on book option gnome-utils/dialog-dup-trans.c & .h - add capability to display and handle 'Num' field according to book option gnome/gnc-plugin-page-register.c - define gnc_find_register_by_account register/ledger-core/split-register.c - modify gnc_split_register_duplicate_current to accomodate book option setting register/ledger-core/Makefile.am - add GNOME_CFLAGS register/ledger-core/test/Makefile.am - add libgnc-gnome.la 8. Adjust register sort and sort labels related to Num/Action radio buttons to correspond to book option for clarity: gnome/gnc-plugin-page-register.c - define gnc_plugin_page_register_sort_book_option_changed to adjust labels register function in gnc_plugin_page_register_cmd_view_sort_by and save num and action radio widgets initialize radio widget labels to correspond to book option remove function in gnc_plugin_page_register_sort_response_cb and clear num and action radio widgets gnome/gnc-split-reg.c & h. - create versions of gnc_split_reg_sort and gnc_split_reg_set_sort to force a re-sort to be used when num-source book option changes engine/Transaction.c & .h - modify default sort to use split action in place of tran num per book option if called from xaccSplitOrder engine/Split.c - modify xaccSplitOrder to call xaccTransOrder_num_action to switch use of split action and tran num per book option engine/test/utest-Split.c - modify test_xaccSplitOrder to call xaccTransOrder_num_action based on book option 9. Adjust transaction find labels related to Num/Action to correspond to book option for clarity: gnome/dialog-find-transactions.c - adjust labels in search criteria based on book option gnome-search/dialog-search.c - define gnc_search_dialog_book_option_changed to adjust labels register function in gnc_search_dialog_init_widgets when searching for splits remove function in gnc_search_dialog_close_cb if registered 10. Modify new file process to allow setting of num-source (actually, all) book option(s) during New Account Hierarchy Setup: gnome-utils/gtkbuilder/dialog-preferences.glade - add a user preference for the default setting for 'num-source' for new books core-utils/gnc-gconf-utils.h - define KEY_NUM_SOURCE gnome-utils/gnc-gnome-utils.c & h. - define gnc_options_dialog_set_new_book_option_values to retrieve preference values gnome-utils/dialog-options.c & .h - define gnc_options_dialog_new_modal to surpress apply button gnome-utils/gnc-main-window.c - define function gnc_book_options_dialog_cb with arguments so that the window can be called in modal mode and the title changed and return dialog widget; call gnc_options_dialog_new_modal instead of gnc_options_dialog_new; call this function from gnc_main_window_cmd_file_properties with new arguments; for modal mode, call gnc-options-dialog-set-new-book-option-values to initialize values from preferences app-utils/gnc-ui-util.c & h. - create function gnc_is_new_book for determining when a new book is being created gnome-utils/dialog-utils.c & h. - define gnc_new_book_option_display to display book options dialog in modal mode gnome/gtkbuilder/assistant-hierarchy.glade - add notification about book options to currency page gnome/assistant-hierarchy.c - add ability to set book option initialized from preferences value for new books by using functions gnc_is_new_book and gnc_new_book_option_display 11. Modify Import QIF process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/qif-import/assistant-qif-import.glade - add notification about book options to currency page import-export/qif-import/assistant-qif-import.c - using function gnc_is_new_book to identify 'new book' situation and set flag; add logic to handle 'new-book' situation by calling gnc_new_book_option_display function import-export/qif-import/qif-to-gnc.scm - use 'gnc_set_num_action' function to import number to correct field based on book option 12. Modify Import OFX/QFX process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/ofx/gnc-ofx-import.c - use 'gnc_set_num_action' function to import number based on book option; identify 'new book' situation using function gnc_is_new_book and set flag; add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function import-export/import-backend.c - use 'gnc_get_num_action' function to retrieve number from transactions to be matched based on book option 13. Modify Import AqBanking process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number: import-export/aqbanking/gnc-file-aqb-import.c - identify 'new book' situation using function gnc_is_new_book and handle by raising book options dialog by calling gnc_new_book_option_display function import-export/aqbanking/gnc-ab-utils.c - use 'gnc_set_num_action' function to set number based on book option 14. Modify Import Transactions from CSV process to recognize a new-book situation and allow setting of book options during first import into a new book; also follow book option setting for num source in importing number whether new book or not: import-export/csv-import/assistant-csv-trans-import.glade - modify commments to alert user of raising book options dialog in cases of csv import into a new book import-export/csv-import/gnc-csv-model.c & h. - use 'gnc_set_num_action' function to import number based on book option import-export/csv-import/assistant-csv-trans-import.c - add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function; identify 'new book' situation using function gnc_is_new_book and set flag 15. Modify Import Accounts from CSV process to recognize a new-book situation and allow setting of book options during first import into a new book import-export/csv-import/assistant-csv-account-import.c & .h - add logic to handle 'new-book' situation by raising book options dialog by calling gnc_new_book_option_display function; identify 'new book' situation using function gnc_is_new_book and set flag 16. Modify Export Transactions to CSV process to follow book option setting for num source in exporting transactions: import-export/csv-export/csv-transactions-export.c - modify headings to reflect num-source book option and use 'gnc_get_num_action' function to retrieve number and action 17. Modify register reporting to reflect book option setting for num source: gnome/gnc-plugin-page-register.c - determine and pass along ledger-type? argument to gnc:register-report-create function gnome/gnc-plugin-page-register2.c - determine and pass along ledger-type? argument to gnc:register-report-create function report/standard-reports/standard-reports.scm - add ledger-type? argument to gnc:register-report-create function; pass it along to gnc:register-report-create-internal function report/standard-reports/register.scm - add ledger-type? argument to gnc:register-report-create-internal function; use 'gnc-get-num-action' function in place of xaccTransGetNum and 'gnc-get-action-num' function in place of xaccSplitGetAction and modify report headings and option text accordingly 18. Modify all places that use xaccTransSetNum and/or xaccSplitSetAction to use 'gnc_set_num_action' function to set number based on book option except engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c, engine/Split.c & .h, engine/test/utest-Split.c, engine/engine-helpers.c & .h, engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c, backend/xml/io-gncxml-v1.c, import-export/log-replay/gnc-log-replay.c: engine/gncOwner.c - use 'gnc_set_num_action' function to set number based on book option engine/gncInvoice.c - use 'gnc_set_num_action' function to set number based on book option engine/SchedXaction.c - use 'gnc_set_num_action' function to set number and action engine/cap-gains.c - use 'gnc_set_num_action' function to set split-action gnome-utils/dialog-transfer.c - use 'gnc_set_num_action' function to set number based on book option gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_set_num_action' function to set number/action based on book option gnome/assistant-stock-split.c - use 'gnc_set_num_action' function to set split-action 19. Modify all places that use xaccTransGetNum and/or xaccSplitGetAction to use 'gnc_get_num_action' or 'gnc_get_action_num' functions to get number based on book option except engine/Transaction.c & .h, engine/test-core/test-engine-stuff.c, engine/Split.c & h., engine/test/utest-Split.c, engine/engine-helpers.c, engine/engine-interface.scm, backend/xml/gnc-transaction-xml-v2.c, backend/xml/test/test-xml-transaction.c: gnome/dialog-lot-viewer.c - use 'gnc_get_num_action' function to retrieve number based on book option gnome/dialog-sx-from-trans.c - use 'gnc_get_num_action' function to retrieve number and action gnome/dialog-print-check.c - use 'gnc_get_num_action' function to retrieve number and 'gnc_get_action_num' function to retrieve action register/ledger-core/split-register-model.c - use 'gnc_get_num_action' function to retrieve number based on book option register/ledger-core/split-register-load.c - use 'gnc_get_num_action' function to retrieve number based on book option register/ledger-core/split-register-control.c - use 'gnc_get_num_action' function to retrieve action register/ledger-core/split-register.c - use 'gnc_get_num_action' function to retrieve transaction-num engine/cap-gains.c - use 'gnc_get_num_action' function to get split-action gnome-utils/gnc-tree-view-split-reg.c - use 'gnc_get_num_action' function to retrieve number and 'gnc_get_action_num' function to retrieve action gnome-utils/gnc-tree-model-split-reg.c - use 'gnc_get_num_action' function to retrieve transaction-number but may not be getting what is expected if book option to use split-action for 'num' is set report/locale-specific/us/taxtxf.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum and 'gnc-get-action-num' function in place of xaccSplitGetAction and modify report headings and option text accordingly report/standard-reports/transaction.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum, adjust sorting based on book option and modify report headings and option text accordingly; add 'SPLIT-ACTION' as a term for sorting queries report/business-reports/customer-summary.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum report/business-reports/owner-report.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum report/business-reports/job-report.scm - use 'gnc-get-num-action' function in place of xaccTransGetNum business/business-gnome/dialog-payment.c - use 'gnc_get_num_action' function to retrieve number based on book option git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22681 57a11ea4-9604-0410-9ed3-97b8803252fd
2012-12-22 06:00:54 +00:00
/* Set tran-num with gnc_set_num_action which is the same as
* xaccTransSetNum with these arguments */
gnc_set_num_action(new_trans, NULL,
gnc_ttinfo_get_num(tti), NULL);
xaccTransSetCurrency( new_trans,
gnc_ttinfo_get_currency(tti) );
for (split_list = gnc_ttinfo_get_template_splits(tti);
split_list;
split_list = split_list->next)
{
s_info = split_list->data;
new_split = pack_split_info(s_info, sx->template_acct,
new_trans, book);
xaccTransAppendSplit(new_trans, new_split);
}
xaccTransCommitEdit(new_trans);
}
}
2001-10-22 Joshua Sled <jsled@asynchronous.org> * src/gnome/Makefile.am: Removed obsolete dialog-nextrun.{c,h} * src/gnome/window-main.c (gnc_main_window_create_menus): Added both Scheduled Transaction-related items to "Scheduled Transactions" sub-menu of "Tools". (gnc_main_window_about_cb): Added self to GUI About dlg. * src/gnome/dialog-scheduledxaction.c: Renamed '_'-led functions. * src/gnome/dialog-sxsincelast.c: Changed from a loose confederation of multiple dialogs to the strong central authority of a GnomeDruid-based since-last-run UI. Renamed '_'-led functions. * src/gnome/glade/sched-xact.glade: Fixed a non-unique-name problem between the GnomeNumberEntry "end_nentry" and it's GtkEntry "end_nentry". Added Druid-based Since-Last-Run dialog. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate), (editor_ok_button_clicked): Added support for now-uniquely-named "end_gnome_nentry". * src/engine/SchedXaction.c (xaccSchedXactionCreateSequenceState): Added. (xaccSchedXactionIncrSequenceState): Added. (xaccSchedXactionDestroySequenceState): Added. Added support for opaque state data when generating a sequence of SX instances to support number-of-occurance-terminated SXes. * src/backend/file/gnc-freqspec-xml-v2.c (dom_tree_to_freqSpec): Added missing instance of GNCSession propogation. * src/backend/file/io-gncxml-v2.c (write_template_transaction_data): Added correct determination for writing out the template-transaction section [before: only if transactions existed in accounts; now: if any accounts exist] to prevent read errors from SXes with valid-and-referenced Accounts, but no Transactions in them. * src/gnome-utils/gnc-frequency.c (gnc_frequency_setup): Better error text when UIFreqType isn't recognized or appropriate. * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): Correctly sets SXes to have no occurance data if that's the case. Better option variable naming, usage. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5710 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-10-22 09:17:34 +00:00
SXTmpStateData*
gnc_sx_create_temporal_state(const SchedXaction *sx )
2001-10-22 Joshua Sled <jsled@asynchronous.org> * src/gnome/Makefile.am: Removed obsolete dialog-nextrun.{c,h} * src/gnome/window-main.c (gnc_main_window_create_menus): Added both Scheduled Transaction-related items to "Scheduled Transactions" sub-menu of "Tools". (gnc_main_window_about_cb): Added self to GUI About dlg. * src/gnome/dialog-scheduledxaction.c: Renamed '_'-led functions. * src/gnome/dialog-sxsincelast.c: Changed from a loose confederation of multiple dialogs to the strong central authority of a GnomeDruid-based since-last-run UI. Renamed '_'-led functions. * src/gnome/glade/sched-xact.glade: Fixed a non-unique-name problem between the GnomeNumberEntry "end_nentry" and it's GtkEntry "end_nentry". Added Druid-based Since-Last-Run dialog. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate), (editor_ok_button_clicked): Added support for now-uniquely-named "end_gnome_nentry". * src/engine/SchedXaction.c (xaccSchedXactionCreateSequenceState): Added. (xaccSchedXactionIncrSequenceState): Added. (xaccSchedXactionDestroySequenceState): Added. Added support for opaque state data when generating a sequence of SX instances to support number-of-occurance-terminated SXes. * src/backend/file/gnc-freqspec-xml-v2.c (dom_tree_to_freqSpec): Added missing instance of GNCSession propogation. * src/backend/file/io-gncxml-v2.c (write_template_transaction_data): Added correct determination for writing out the template-transaction section [before: only if transactions existed in accounts; now: if any accounts exist] to prevent read errors from SXes with valid-and-referenced Accounts, but no Transactions in them. * src/gnome-utils/gnc-frequency.c (gnc_frequency_setup): Better error text when UIFreqType isn't recognized or appropriate. * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): Correctly sets SXes to have no occurance data if that's the case. Better option variable naming, usage. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5710 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-10-22 09:17:34 +00:00
{
SXTmpStateData *toRet =
g_new0( SXTmpStateData, 1 );
toRet->last_date = sx->last_date;
toRet->num_occur_rem = sx->num_occurances_remain;
toRet->num_inst = sx->instance_num;
return toRet;
2001-10-22 Joshua Sled <jsled@asynchronous.org> * src/gnome/Makefile.am: Removed obsolete dialog-nextrun.{c,h} * src/gnome/window-main.c (gnc_main_window_create_menus): Added both Scheduled Transaction-related items to "Scheduled Transactions" sub-menu of "Tools". (gnc_main_window_about_cb): Added self to GUI About dlg. * src/gnome/dialog-scheduledxaction.c: Renamed '_'-led functions. * src/gnome/dialog-sxsincelast.c: Changed from a loose confederation of multiple dialogs to the strong central authority of a GnomeDruid-based since-last-run UI. Renamed '_'-led functions. * src/gnome/glade/sched-xact.glade: Fixed a non-unique-name problem between the GnomeNumberEntry "end_nentry" and it's GtkEntry "end_nentry". Added Druid-based Since-Last-Run dialog. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate), (editor_ok_button_clicked): Added support for now-uniquely-named "end_gnome_nentry". * src/engine/SchedXaction.c (xaccSchedXactionCreateSequenceState): Added. (xaccSchedXactionIncrSequenceState): Added. (xaccSchedXactionDestroySequenceState): Added. Added support for opaque state data when generating a sequence of SX instances to support number-of-occurance-terminated SXes. * src/backend/file/gnc-freqspec-xml-v2.c (dom_tree_to_freqSpec): Added missing instance of GNCSession propogation. * src/backend/file/io-gncxml-v2.c (write_template_transaction_data): Added correct determination for writing out the template-transaction section [before: only if transactions existed in accounts; now: if any accounts exist] to prevent read errors from SXes with valid-and-referenced Accounts, but no Transactions in them. * src/gnome-utils/gnc-frequency.c (gnc_frequency_setup): Better error text when UIFreqType isn't recognized or appropriate. * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): Correctly sets SXes to have no occurance data if that's the case. Better option variable naming, usage. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5710 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-10-22 09:17:34 +00:00
}
void
gnc_sx_incr_temporal_state(const SchedXaction *sx, SXTmpStateData *stateData )
2001-10-22 Joshua Sled <jsled@asynchronous.org> * src/gnome/Makefile.am: Removed obsolete dialog-nextrun.{c,h} * src/gnome/window-main.c (gnc_main_window_create_menus): Added both Scheduled Transaction-related items to "Scheduled Transactions" sub-menu of "Tools". (gnc_main_window_about_cb): Added self to GUI About dlg. * src/gnome/dialog-scheduledxaction.c: Renamed '_'-led functions. * src/gnome/dialog-sxsincelast.c: Changed from a loose confederation of multiple dialogs to the strong central authority of a GnomeDruid-based since-last-run UI. Renamed '_'-led functions. * src/gnome/glade/sched-xact.glade: Fixed a non-unique-name problem between the GnomeNumberEntry "end_nentry" and it's GtkEntry "end_nentry". Added Druid-based Since-Last-Run dialog. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate), (editor_ok_button_clicked): Added support for now-uniquely-named "end_gnome_nentry". * src/engine/SchedXaction.c (xaccSchedXactionCreateSequenceState): Added. (xaccSchedXactionIncrSequenceState): Added. (xaccSchedXactionDestroySequenceState): Added. Added support for opaque state data when generating a sequence of SX instances to support number-of-occurance-terminated SXes. * src/backend/file/gnc-freqspec-xml-v2.c (dom_tree_to_freqSpec): Added missing instance of GNCSession propogation. * src/backend/file/io-gncxml-v2.c (write_template_transaction_data): Added correct determination for writing out the template-transaction section [before: only if transactions existed in accounts; now: if any accounts exist] to prevent read errors from SXes with valid-and-referenced Accounts, but no Transactions in them. * src/gnome-utils/gnc-frequency.c (gnc_frequency_setup): Better error text when UIFreqType isn't recognized or appropriate. * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): Correctly sets SXes to have no occurance data if that's the case. Better option variable naming, usage. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5710 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-10-22 09:17:34 +00:00
{
GDate unused;
SXTmpStateData *tsd = (SXTmpStateData*)stateData;
g_date_clear( &unused, 1 );
tsd->last_date =
xaccSchedXactionGetInstanceAfter( sx,
&unused,
stateData );
if ( xaccSchedXactionHasOccurDef( sx ) )
{
tsd->num_occur_rem -= 1;
}
tsd->num_inst += 1;
2001-10-22 Joshua Sled <jsled@asynchronous.org> * src/gnome/Makefile.am: Removed obsolete dialog-nextrun.{c,h} * src/gnome/window-main.c (gnc_main_window_create_menus): Added both Scheduled Transaction-related items to "Scheduled Transactions" sub-menu of "Tools". (gnc_main_window_about_cb): Added self to GUI About dlg. * src/gnome/dialog-scheduledxaction.c: Renamed '_'-led functions. * src/gnome/dialog-sxsincelast.c: Changed from a loose confederation of multiple dialogs to the strong central authority of a GnomeDruid-based since-last-run UI. Renamed '_'-led functions. * src/gnome/glade/sched-xact.glade: Fixed a non-unique-name problem between the GnomeNumberEntry "end_nentry" and it's GtkEntry "end_nentry". Added Druid-based Since-Last-Run dialog. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate), (editor_ok_button_clicked): Added support for now-uniquely-named "end_gnome_nentry". * src/engine/SchedXaction.c (xaccSchedXactionCreateSequenceState): Added. (xaccSchedXactionIncrSequenceState): Added. (xaccSchedXactionDestroySequenceState): Added. Added support for opaque state data when generating a sequence of SX instances to support number-of-occurance-terminated SXes. * src/backend/file/gnc-freqspec-xml-v2.c (dom_tree_to_freqSpec): Added missing instance of GNCSession propogation. * src/backend/file/io-gncxml-v2.c (write_template_transaction_data): Added correct determination for writing out the template-transaction section [before: only if transactions existed in accounts; now: if any accounts exist] to prevent read errors from SXes with valid-and-referenced Accounts, but no Transactions in them. * src/gnome-utils/gnc-frequency.c (gnc_frequency_setup): Better error text when UIFreqType isn't recognized or appropriate. * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): Correctly sets SXes to have no occurance data if that's the case. Better option variable naming, usage. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5710 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-10-22 09:17:34 +00:00
}
void
gnc_sx_destroy_temporal_state( SXTmpStateData *stateData )
{
g_free( (SXTmpStateData*)stateData );
}
SXTmpStateData*
gnc_sx_clone_temporal_state( SXTmpStateData *stateData )
{
SXTmpStateData *toRet, *tsd;
tsd = (SXTmpStateData*)stateData;
toRet = g_memdup( tsd, sizeof( SXTmpStateData ) );
return toRet;
2001-10-22 Joshua Sled <jsled@asynchronous.org> * src/gnome/Makefile.am: Removed obsolete dialog-nextrun.{c,h} * src/gnome/window-main.c (gnc_main_window_create_menus): Added both Scheduled Transaction-related items to "Scheduled Transactions" sub-menu of "Tools". (gnc_main_window_about_cb): Added self to GUI About dlg. * src/gnome/dialog-scheduledxaction.c: Renamed '_'-led functions. * src/gnome/dialog-sxsincelast.c: Changed from a loose confederation of multiple dialogs to the strong central authority of a GnomeDruid-based since-last-run UI. Renamed '_'-led functions. * src/gnome/glade/sched-xact.glade: Fixed a non-unique-name problem between the GnomeNumberEntry "end_nentry" and it's GtkEntry "end_nentry". Added Druid-based Since-Last-Run dialog. * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate), (editor_ok_button_clicked): Added support for now-uniquely-named "end_gnome_nentry". * src/engine/SchedXaction.c (xaccSchedXactionCreateSequenceState): Added. (xaccSchedXactionIncrSequenceState): Added. (xaccSchedXactionDestroySequenceState): Added. Added support for opaque state data when generating a sequence of SX instances to support number-of-occurance-terminated SXes. * src/backend/file/gnc-freqspec-xml-v2.c (dom_tree_to_freqSpec): Added missing instance of GNCSession propogation. * src/backend/file/io-gncxml-v2.c (write_template_transaction_data): Added correct determination for writing out the template-transaction section [before: only if transactions existed in accounts; now: if any accounts exist] to prevent read errors from SXes with valid-and-referenced Accounts, but no Transactions in them. * src/gnome-utils/gnc-frequency.c (gnc_frequency_setup): Better error text when UIFreqType isn't recognized or appropriate. * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): Correctly sets SXes to have no occurance data if that's the case. Better option variable naming, usage. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5710 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-10-22 09:17:34 +00:00
}
static
gint
_temporal_state_data_cmp( gconstpointer a, gconstpointer b )
{
SXTmpStateData *tsd_a, *tsd_b;
tsd_a = (SXTmpStateData*)a;
tsd_b = (SXTmpStateData*)b;
if ( !tsd_a && !tsd_b )
return 0;
if (tsd_a == tsd_b)
return 0;
if ( !tsd_a )
return 1;
if ( !tsd_b )
return -1;
return g_date_compare( &tsd_a->last_date,
&tsd_b->last_date );
}
/**
* Adds an instance to the deferred list of the SX. Added instances are
* added in (date-)sorted order.
**/
void
gnc_sx_add_defer_instance( SchedXaction *sx, void *deferStateData )
{
sx->deferredList = g_list_insert_sorted( sx->deferredList,
deferStateData,
_temporal_state_data_cmp );
}
/**
* Removes an instance from the deferred list. If the instance is no longer
* useful; gnc_sx_destroy_temporal_state() it.
**/
void
gnc_sx_remove_defer_instance( SchedXaction *sx, void *deferStateData )
{
GList *found_by_value;
found_by_value = g_list_find_custom(
sx->deferredList, deferStateData, _temporal_state_data_cmp);
if (found_by_value == NULL)
{
g_warning("unable to find deferred instance");
return;
}
gnc_sx_destroy_temporal_state(found_by_value->data);
sx->deferredList = g_list_delete_link(sx->deferredList, found_by_value);
}
/**
* Returns the defer list from the SX; this is a (date-)sorted
* temporal-state-data instance list. The list should not be modified by the
* caller; use the gnc_sx_{add,remove}_defer_instance() functions to modifiy
* the list.
*
* @param sx Scheduled transaction
* @return Defer list which must not be modified by the caller
**/
GList*
gnc_sx_get_defer_instances( SchedXaction *sx )
{
return sx->deferredList;
}
static void
destroy_sx_on_book_close(QofInstance *ent, gpointer data)
{
SchedXaction* sx = GNC_SCHEDXACTION(ent);
gnc_sx_begin_edit(sx);
xaccSchedXactionDestroy(sx);
}
/**
* Destroys all SXes in the book because the book is being destroyed.
*
* @param book Book being destroyed
*/
static void
gnc_sx_book_end(QofBook* book)
{
QofCollection *col;
col = qof_book_get_collection(book, GNC_ID_SCHEDXACTION);
qof_collection_foreach(col, destroy_sx_on_book_close, NULL);
}
#ifdef _MSC_VER
/* MSVC compiler doesn't have C99 "designated initializers"
* so we wrap them in a macro that is empty on MSVC. */
# define DI(x) /* */
#else
# define DI(x) x
#endif
static QofObject SXDesc =
{
DI(.interface_version = ) QOF_OBJECT_VERSION,
DI(.e_type = ) GNC_SX_ID,
DI(.type_label = ) "Scheduled Transaction",
DI(.create = ) (gpointer)xaccSchedXactionMalloc,
DI(.book_begin = ) NULL,
DI(.book_end = ) gnc_sx_book_end,
DI(.is_dirty = ) qof_collection_is_dirty,
DI(.mark_clean = ) qof_collection_mark_clean,
DI(.foreach = ) qof_collection_foreach,
DI(.printable = ) NULL,
DI(.version_cmp = ) (int (*)(gpointer, gpointer)) qof_instance_version_cmp,
};
gboolean
SXRegister(void)
{
static QofParam params[] =
{
{
GNC_SX_NAME, QOF_TYPE_STRING, (QofAccessFunc)xaccSchedXactionGetName,
(QofSetterFunc)xaccSchedXactionSetName
},
{
GNC_SX_START_DATE, QOF_TYPE_DATE, (QofAccessFunc)xaccSchedXactionGetStartDate,
(QofSetterFunc)xaccSchedXactionSetStartDate
},
{
GNC_SX_LAST_DATE, QOF_TYPE_DATE, (QofAccessFunc)xaccSchedXactionGetLastOccurDate,
(QofSetterFunc)xaccSchedXactionSetLastOccurDate
},
{
GNC_SX_NUM_OCCUR, QOF_TYPE_INT64, (QofAccessFunc)xaccSchedXactionGetNumOccur,
(QofSetterFunc)xaccSchedXactionSetNumOccur
},
{
GNC_SX_REM_OCCUR, QOF_TYPE_INT64, (QofAccessFunc)xaccSchedXactionGetRemOccur,
(QofSetterFunc)xaccSchedXactionSetRemOccur
},
{ QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
{ NULL },
};
qof_class_register(GNC_SX_ID, NULL, params);
return qof_object_register(&SXDesc);
}