mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* options.scm: Create gnc:make-account-list-limited-option
function that adds a list of valid account-types; this limits the account-tree dialog to only "reasonable" accounts. * option-util.[ch]: add function to obtain GList* of valid account-types. NULL means "all". * dialog-options: Limit account-list by types. * Update payables and receivables reports to limit account types. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7076 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
91a961d792
commit
702d5f3529
11
ChangeLog
11
ChangeLog
@ -18,6 +18,17 @@
|
|||||||
|
|
||||||
* add a hook in the entry ledger to obtain the current Query (to
|
* add a hook in the entry ledger to obtain the current Query (to
|
||||||
set the sort order).
|
set the sort order).
|
||||||
|
|
||||||
|
* options.scm: Create gnc:make-account-list-limited-option
|
||||||
|
function that adds a list of valid account-types; this limits the
|
||||||
|
account-tree dialog to only "reasonable" accounts.
|
||||||
|
|
||||||
|
* option-util.[ch]: add function to obtain GList* of valid
|
||||||
|
account-types. NULL means "all".
|
||||||
|
|
||||||
|
* dialog-options: Limit account-list by types.
|
||||||
|
|
||||||
|
* Update payables and receivables reports to limit account types.
|
||||||
|
|
||||||
2002-07-01 Derek Atkins <derek@ihtfp.com>
|
2002-07-01 Derek Atkins <derek@ihtfp.com>
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
(export gnc:date-option-absolute-time)
|
(export gnc:date-option-absolute-time)
|
||||||
(export gnc:date-option-relative-time)
|
(export gnc:date-option-relative-time)
|
||||||
(export gnc:make-account-list-option)
|
(export gnc:make-account-list-option)
|
||||||
|
(export gnc:make-account-list-limited-option)
|
||||||
(export gnc:multichoice-list-lookup)
|
(export gnc:multichoice-list-lookup)
|
||||||
(export gnc:make-multichoice-option)
|
(export gnc:make-multichoice-option)
|
||||||
(export gnc:make-multichoice-callback-option)
|
(export gnc:make-multichoice-callback-option)
|
||||||
|
@ -908,13 +908,62 @@ gnc_option_show_time(GNCOption *option)
|
|||||||
gboolean
|
gboolean
|
||||||
gnc_option_multiple_selection(GNCOption *option)
|
gnc_option_multiple_selection(GNCOption *option)
|
||||||
{
|
{
|
||||||
SCM value;
|
SCM pair;
|
||||||
|
|
||||||
initialize_getters();
|
initialize_getters();
|
||||||
|
|
||||||
value = gh_call1(getters.option_data, option->guile_option);
|
pair = gh_call1(getters.option_data, option->guile_option);
|
||||||
|
|
||||||
return !gh_scm2bool(gh_not(value));
|
return !gh_scm2bool(gh_not(gh_car(pair)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************************************************\
|
||||||
|
* gnc_option_get_account_type_list *
|
||||||
|
* returns the list of account_types in the option (or NULL if *
|
||||||
|
* no special list is provided). Only use this for account *
|
||||||
|
* options. *
|
||||||
|
* *
|
||||||
|
* Args: option - the GNCOption *
|
||||||
|
* Returns: GList of account types (must be freed by caller) *
|
||||||
|
\********************************************************************/
|
||||||
|
GList *
|
||||||
|
gnc_option_get_account_type_list(GNCOption *option)
|
||||||
|
{
|
||||||
|
SCM pair;
|
||||||
|
SCM lst;
|
||||||
|
SCM conv_func;
|
||||||
|
GList *type_list = NULL;
|
||||||
|
|
||||||
|
initialize_getters();
|
||||||
|
|
||||||
|
pair = gh_call1(getters.option_data, option->guile_option);
|
||||||
|
lst = gh_cdr(pair);
|
||||||
|
|
||||||
|
conv_func = gh_eval_str ("gw:enum-<gnc:AccountType>-val->int");
|
||||||
|
if (!gh_procedure_p (conv_func)) {
|
||||||
|
PERR ("Cannot obtain conv_func");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!gh_null_p (lst)) {
|
||||||
|
GNCAccountType type;
|
||||||
|
SCM item;
|
||||||
|
|
||||||
|
/* Compute this item and the rest of the list */
|
||||||
|
item = gh_car (lst);
|
||||||
|
lst = gh_cdr (lst);
|
||||||
|
|
||||||
|
item = gh_call1(conv_func, item);
|
||||||
|
|
||||||
|
if (SCM_FALSEP (scm_integer_p (item))) {
|
||||||
|
PERR ("Invalid type");
|
||||||
|
} else {
|
||||||
|
type = gh_scm2long (item);
|
||||||
|
type_list = g_list_prepend (type_list, GINT_TO_POINTER (type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_list_reverse (type_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ char * gnc_option_permissible_value_description(GNCOption *option, int index);
|
|||||||
gboolean gnc_option_show_time(GNCOption *option);
|
gboolean gnc_option_show_time(GNCOption *option);
|
||||||
|
|
||||||
gboolean gnc_option_multiple_selection(GNCOption *option);
|
gboolean gnc_option_multiple_selection(GNCOption *option);
|
||||||
|
GList * gnc_option_get_account_type_list(GNCOption *option);
|
||||||
|
|
||||||
gboolean gnc_option_get_range_info(GNCOption *option,
|
gboolean gnc_option_get_range_info(GNCOption *option,
|
||||||
double *lower_bound,
|
double *lower_bound,
|
||||||
|
@ -466,11 +466,9 @@
|
|||||||
#f
|
#f
|
||||||
(cdr option-value)))
|
(cdr option-value)))
|
||||||
|
|
||||||
;; account-list options use the option-data as a boolean value. If
|
;; Just like gnc:make-account-list-limited-option except it
|
||||||
;; true, the gui should allow the user to select multiple accounts.
|
;; does not limit the types of accounts that are available
|
||||||
;; Internally, values are always a list of guids. Externally, both
|
;; to the user.
|
||||||
;; guids and account pointers may be used to set the value of the
|
|
||||||
;; option. The option always returns a list of account pointers.
|
|
||||||
(define (gnc:make-account-list-option
|
(define (gnc:make-account-list-option
|
||||||
section
|
section
|
||||||
name
|
name
|
||||||
@ -480,6 +478,27 @@
|
|||||||
value-validator
|
value-validator
|
||||||
multiple-selection)
|
multiple-selection)
|
||||||
|
|
||||||
|
(gnc:make-account-list-limited-option
|
||||||
|
section name sort-tag documentation-string
|
||||||
|
default-getter value-validator multiple-selection '()))
|
||||||
|
|
||||||
|
;; account-list options use the option-data as a pair; the car is
|
||||||
|
;; a boolean value, the cdr is a list of account-types. If the boolean is
|
||||||
|
;; true, the gui should allow the user to select multiple accounts.
|
||||||
|
;; If the cdr is an empty list, then all account types are shown.
|
||||||
|
;; Internally, values are always a list of guids. Externally, both
|
||||||
|
;; guids and account pointers may be used to set the value of the
|
||||||
|
;; option. The option always returns a list of account pointers.
|
||||||
|
(define (gnc:make-account-list-limited-option
|
||||||
|
section
|
||||||
|
name
|
||||||
|
sort-tag
|
||||||
|
documentation-string
|
||||||
|
default-getter
|
||||||
|
value-validator
|
||||||
|
multiple-selection
|
||||||
|
acct-type-list)
|
||||||
|
|
||||||
(define (convert-to-guid item)
|
(define (convert-to-guid item)
|
||||||
(if (string? item)
|
(if (string? item)
|
||||||
item
|
item
|
||||||
@ -524,7 +543,7 @@
|
|||||||
(lambda () (map convert-to-account (default-getter)))
|
(lambda () (map convert-to-account (default-getter)))
|
||||||
(gnc:restore-form-generator value->string)
|
(gnc:restore-form-generator value->string)
|
||||||
validator
|
validator
|
||||||
multiple-selection #f #f #f)))
|
(cons multiple-selection acct-type-list) #f #f #f)))
|
||||||
|
|
||||||
(define (gnc:multichoice-list-lookup list item )
|
(define (gnc:multichoice-list-lookup list item )
|
||||||
(cond
|
(cond
|
||||||
|
@ -773,8 +773,10 @@ gnc_option_create_account_widget(GNCOption *option, char *name)
|
|||||||
GtkWidget *tree;
|
GtkWidget *tree;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
GtkWidget *bbox;
|
GtkWidget *bbox;
|
||||||
|
GList *acct_type_list;
|
||||||
|
|
||||||
multiple_selection = gnc_option_multiple_selection(option);
|
multiple_selection = gnc_option_multiple_selection(option);
|
||||||
|
acct_type_list = gnc_option_get_account_type_list(option);
|
||||||
|
|
||||||
frame = gtk_frame_new(name);
|
frame = gtk_frame_new(name);
|
||||||
|
|
||||||
@ -790,6 +792,25 @@ gnc_option_create_account_widget(GNCOption *option, char *name)
|
|||||||
else
|
else
|
||||||
gtk_clist_set_selection_mode(GTK_CLIST(tree), GTK_SELECTION_BROWSE);
|
gtk_clist_set_selection_mode(GTK_CLIST(tree), GTK_SELECTION_BROWSE);
|
||||||
|
|
||||||
|
if (acct_type_list) {
|
||||||
|
GList *node;
|
||||||
|
AccountViewInfo avi;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
gnc_account_tree_get_view_info (GNC_ACCOUNT_TREE (tree), &avi);
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
|
||||||
|
avi.include_type[i] = FALSE;
|
||||||
|
|
||||||
|
for (node = acct_type_list; node; node = node->next) {
|
||||||
|
GNCAccountType type = GPOINTER_TO_INT (node->data);
|
||||||
|
avi.include_type[type] = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gnc_account_tree_set_view_info (GNC_ACCOUNT_TREE (tree), &avi);
|
||||||
|
g_list_free (acct_type_list);
|
||||||
|
}
|
||||||
|
|
||||||
scroll_win = gtk_scrolled_window_new(NULL, NULL);
|
scroll_win = gtk_scrolled_window_new(NULL, NULL);
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
|
||||||
GTK_POLICY_AUTOMATIC,
|
GTK_POLICY_AUTOMATIC,
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
(use-modules (gnucash report aging))
|
(use-modules (gnucash report aging))
|
||||||
(use-modules (gnucash report standard-reports))
|
(use-modules (gnucash report standard-reports))
|
||||||
|
|
||||||
(define this-acc "this-account")
|
(define this-acc "Payable Account")
|
||||||
|
|
||||||
(define (options-generator)
|
(define (options-generator)
|
||||||
(let* ((options (gnc:new-options))
|
(let* ((options (gnc:new-options))
|
||||||
@ -42,12 +42,13 @@
|
|||||||
(gnc:register-option options new-option))))
|
(gnc:register-option options new-option))))
|
||||||
|
|
||||||
(add-option
|
(add-option
|
||||||
(gnc:make-account-list-option
|
(gnc:make-account-list-limited-option
|
||||||
"__reg" this-acc
|
"Account" this-acc
|
||||||
"" ""
|
"" ""
|
||||||
(lambda () '())
|
(lambda () '())
|
||||||
#f
|
#f
|
||||||
#f))
|
#f
|
||||||
|
'(payable)))
|
||||||
|
|
||||||
(aging-options-generator options)))
|
(aging-options-generator options)))
|
||||||
|
|
||||||
@ -77,7 +78,7 @@
|
|||||||
(define (op-value section name)
|
(define (op-value section name)
|
||||||
(gnc:option-value (get-op section name)))
|
(gnc:option-value (get-op section name)))
|
||||||
|
|
||||||
(let* ((payables-account (op-value "__reg" this-acc)))
|
(let* ((payables-account (op-value "Account" this-acc)))
|
||||||
(gnc:debug "payables-account" payables-account)
|
(gnc:debug "payables-account" payables-account)
|
||||||
|
|
||||||
(if (null? payables-account)
|
(if (null? payables-account)
|
||||||
@ -92,11 +93,11 @@
|
|||||||
'name (N_ "Payable Aging")
|
'name (N_ "Payable Aging")
|
||||||
'options-generator options-generator
|
'options-generator options-generator
|
||||||
'renderer payables-renderer
|
'renderer payables-renderer
|
||||||
'in-menu? #f)
|
'in-menu? #t)
|
||||||
|
|
||||||
(define (payables-report-create-internal acct)
|
(define (payables-report-create-internal acct)
|
||||||
(let* ((options (gnc:make-report-options "Payable Aging"))
|
(let* ((options (gnc:make-report-options "Payable Aging"))
|
||||||
(acct-op (gnc:lookup-option options "__reg" this-acc)))
|
(acct-op (gnc:lookup-option options "Account" this-acc)))
|
||||||
|
|
||||||
(gnc:option-set-value acct-op (list acct))
|
(gnc:option-set-value acct-op (list acct))
|
||||||
(gnc:make-report "Payable Aging" options)))
|
(gnc:make-report "Payable Aging" options)))
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
(use-modules (gnucash report aging))
|
(use-modules (gnucash report aging))
|
||||||
(use-modules (gnucash report standard-reports))
|
(use-modules (gnucash report standard-reports))
|
||||||
|
|
||||||
(define this-acc "this-account")
|
(define this-acc "Receivables Account")
|
||||||
|
|
||||||
(define (options-generator)
|
(define (options-generator)
|
||||||
(let* ((options (gnc:new-options))
|
(let* ((options (gnc:new-options))
|
||||||
@ -45,12 +45,13 @@
|
|||||||
; (gnc:make-internal-option "__reg" this-acc #f))
|
; (gnc:make-internal-option "__reg" this-acc #f))
|
||||||
|
|
||||||
(add-option
|
(add-option
|
||||||
(gnc:make-account-list-option
|
(gnc:make-account-list-limited-option
|
||||||
"__reg" this-acc
|
"Account" this-acc
|
||||||
"" ""
|
"" ""
|
||||||
(lambda () '())
|
(lambda () '())
|
||||||
#f
|
#f
|
||||||
#f))
|
#f
|
||||||
|
'(receivable)))
|
||||||
|
|
||||||
(aging-options-generator options)))
|
(aging-options-generator options)))
|
||||||
|
|
||||||
@ -80,7 +81,7 @@
|
|||||||
(define (op-value section name)
|
(define (op-value section name)
|
||||||
(gnc:option-value (get-op section name)))
|
(gnc:option-value (get-op section name)))
|
||||||
|
|
||||||
(let* ((receivables-account (op-value "__reg" this-acc)))
|
(let* ((receivables-account (op-value "Account" this-acc)))
|
||||||
(gnc:debug "receivables-account" receivables-account)
|
(gnc:debug "receivables-account" receivables-account)
|
||||||
|
|
||||||
(if (null? receivables-account)
|
(if (null? receivables-account)
|
||||||
@ -95,11 +96,11 @@
|
|||||||
'name (N_ "Receivable Aging")
|
'name (N_ "Receivable Aging")
|
||||||
'options-generator options-generator
|
'options-generator options-generator
|
||||||
'renderer receivables-renderer
|
'renderer receivables-renderer
|
||||||
'in-menu? #f)
|
'in-menu? #t)
|
||||||
|
|
||||||
(define (receivables-report-create-internal acct)
|
(define (receivables-report-create-internal acct)
|
||||||
(let* ((options (gnc:make-report-options "Receivable Aging"))
|
(let* ((options (gnc:make-report-options "Receivable Aging"))
|
||||||
(acct-op (gnc:lookup-option options "__reg" this-acc)))
|
(acct-op (gnc:lookup-option options "Account" this-acc)))
|
||||||
|
|
||||||
(gnc:option-set-value acct-op (list acct))
|
(gnc:option-set-value acct-op (list acct))
|
||||||
(gnc:make-report "Receivable Aging" options)))
|
(gnc:make-report "Receivable Aging" options)))
|
||||||
|
Loading…
Reference in New Issue
Block a user