Configure debit/credit synonyms in guile.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2347 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-05-17 11:08:49 +00:00
parent 6e6332c35f
commit 8c0b2fc6fb
6 changed files with 162 additions and 155 deletions

View File

@ -1,3 +1,16 @@
2000-05-17 Dave Peticolas <peticola@cs.ucdavis.edu>
* src/gnome/window-reconcile.c (gnc_recn_create_tool_bar): add a
'Finish' reconcile button to the toolbar.
* src/register/splitreg.c (configLabels): use callbacks to get
debit/credit headings.
* src/guile/guile-util.c: new functions to access guile
debit/credit synonyms by account type.
* src/scm/prefs.scm: added debit/credit synonym configuration.
2000-05-16 Dave Peticolas <peticola@cs.ucdavis.edu>
* src/engine/guid/guid.h: change the GUID struct to a union with

View File

@ -50,6 +50,7 @@
#include "date.h"
#include "AccWindow.h"
#include "SplitLedger.h"
#include "guile-util.h"
#include "splitreg.h"
@ -66,8 +67,7 @@ static void gnc_configure_register_borders_cb(void *);
static void gnc_configure_register_borders(void);
static void gnc_configure_reverse_balance_cb(void *);
static void gnc_configure_reverse_balance(void);
static void gnc_configure_debit_credit_labels_cb(void *);
static void gnc_configure_debit_credit_labels(void);
static void gnc_configure_sr_label_callbacks();
/** GLOBALS *********************************************************/
/* This static indicates the debugging module that this .o belongs to. */
@ -85,7 +85,6 @@ static SCM account_separator_callback_id = SCM_UNDEFINED;
static SCM register_colors_callback_id = SCM_UNDEFINED;
static SCM register_borders_callback_id = SCM_UNDEFINED;
static SCM reverse_balance_callback_id = SCM_UNDEFINED;
static SCM debit_credit_labels_callback_id = SCM_UNDEFINED;
/* ============================================================== */
@ -170,11 +169,7 @@ gnucash_ui_init()
NULL, "General",
"Reversed-balance account types");
gnc_configure_debit_credit_labels();
debit_credit_labels_callback_id =
gnc_register_option_change_callback(gnc_configure_debit_credit_labels_cb,
NULL, "Register",
"Always use debit/credit labels");
gnc_configure_sr_label_callbacks();
mainWindow();
@ -226,7 +221,6 @@ gnc_ui_destroy (void)
gnc_unregister_option_change_callback_id(register_colors_callback_id);
gnc_unregister_option_change_callback_id(register_borders_callback_id);
gnc_unregister_option_change_callback_id(reverse_balance_callback_id);
gnc_unregister_option_change_callback_id(debit_credit_labels_callback_id);
if (app != NULL)
{
@ -281,6 +275,61 @@ gnucash_ui_select_file()
/* ============================================================== */
static GNCAccountType
sr_type_to_account_type(SplitRegisterType sr_type)
{
switch (sr_type)
{
case BANK_REGISTER:
return BANK;
case CASH_REGISTER:
return CASH;
case ASSET_REGISTER:
return ASSET;
case CREDIT_REGISTER:
return CREDIT;
case LIABILITY_REGISTER:
return LIABILITY;
case INCOME_LEDGER:
case INCOME_REGISTER:
return INCOME;
case EXPENSE_REGISTER:
return EXPENSE;
case STOCK_REGISTER:
case PORTFOLIO_LEDGER:
return STOCK;
case CURRENCY_REGISTER:
return CURRENCY;
case GENERAL_LEDGER:
return NO_TYPE;
case EQUITY_REGISTER:
return EQUITY;
case SEARCH_LEDGER:
return NO_TYPE;
default:
return NO_TYPE;
}
}
static char *
gnc_sr_debit_string(SplitRegisterType sr_type)
{
return gnc_get_debit_string(sr_type_to_account_type(sr_type));
}
static char *
gnc_sr_credit_string(SplitRegisterType sr_type)
{
return gnc_get_credit_string(sr_type_to_account_type(sr_type));
}
static void
gnc_configure_sr_label_callbacks()
{
xaccSplitRegisterSetDebitStringGetter(gnc_sr_debit_string);
xaccSplitRegisterSetCreditStringGetter(gnc_sr_credit_string);
}
/* gnc_configure_date_format_cb
* Callback called when options change - sets dateFormat to the current
* value on the scheme side and refreshes register windows
@ -626,36 +675,4 @@ gnc_configure_reverse_balance(void)
free(choice);
}
/* gnc_configure_debit_credit_labels_cb
* Callback called when options change - sets
* register debit/credit labels
*
* Args: Nothing
* Returns: Nothing
*/
static void
gnc_configure_debit_credit_labels_cb(void *not_used)
{
gnc_configure_debit_credit_labels();
}
/* gnc_configure_debit_credit_labels
* sets usage of debit/credit labels
*
* Args: Nothing
* Returns: Nothing
*/
static void
gnc_configure_debit_credit_labels(void)
{
gncBoolean only_debit_credit_labels;
only_debit_credit_labels =
gnc_lookup_boolean_option("Register",
"Always use debit/credit labels",
GNC_F);
xaccSplitRegisterSetLabelMode(only_debit_credit_labels);
}
/****************** END OF FILE **********************/

View File

@ -1,4 +1,4 @@
# Makefile -- makefile for xacc/src/register
# Makefile -- makefile for gnucash/src/register
# Copyright (C) 1997 Robin Clark
# Copyright (C) 1998, 1999, 2000 Linas Vepstas
#
@ -13,13 +13,11 @@
# 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, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Author: Robin Clark
# Internet: rclark@rush.aero.org
# Address: 609 8th Street
# Huntington Beach, CA 92648-4632
# along with this program; if not, contact:
#
# Free Software Foundation Voice: +1-617-542-5942
# 59 Temple Place - Suite 330 Fax: +1-617-542-2652
# Boston, MA 02111-1307, USA gnu@gnu.org
include @top_srcdir@/Makefile.init
@ -38,8 +36,8 @@ CFLAGS := @CFLAGS@ @X_CFLAGS@ -DCELL_WIDGETS=1 ${INCLPATH} ${CPPFLAGS}
######################################################################
# See Makefile.common for information about these variables.
COMMON_SRCS := basiccell.c cellblock.c \
datecell.c pricecell.c QuickFill.c quickfillcell.c \
COMMON_SRCS := basiccell.c cellblock.c datecell.c \
pricecell.c QuickFill.c quickfillcell.c \
recncell.c splitreg.c numcell.c \
table-allgui.c table-html.c textcell.c
MOTIF_SRCS := table-motif.c combocell-motif.c quickfillcell-motif.c

View File

@ -49,7 +49,8 @@
/* This static indicates the debugging module that this .o belongs to. */
static short module = MOD_REGISTER;
static gncBoolean only_debit_credit_labels = FALSE;
static SRStringGetter debit_getter = NULL;
static SRStringGetter credit_getter = NULL;
typedef struct _CellBuffer CellBuffer;
struct _CellBuffer
@ -163,14 +164,6 @@ static SplitRegisterColors reg_colors = {
/* ============================================== */
void
xaccSplitRegisterSetLabelMode(gncBoolean only_debit_credit)
{
only_debit_credit_labels = only_debit_credit;
}
/* ============================================== */
#define LABEL(NAME,label) \
{ \
BasicCell *hcell; \
@ -178,6 +171,20 @@ xaccSplitRegisterSetLabelMode(gncBoolean only_debit_credit)
xaccSetBasicCellValue (hcell, label); \
}
/* ============================================== */
void
xaccSplitRegisterSetDebitStringGetter(SRStringGetter getter)
{
debit_getter = getter;
}
void
xaccSplitRegisterSetCreditStringGetter(SRStringGetter getter)
{
credit_getter = getter;
}
/* ============================================== */
/* configLabels merely puts strings into the label cells
* it does *not* copy them to the header cursor */
@ -185,80 +192,49 @@ xaccSplitRegisterSetLabelMode(gncBoolean only_debit_credit)
static void
configLabels (SplitRegister *reg)
{
BasicCell *hc;
int type = (reg->type) & REG_TYPE_MASK;
BasicCell *hc;
int type = (reg->type) & REG_TYPE_MASK;
char *string;
LABEL (DATE, DATE_STR);
LABEL (NUM, NUM_STR);
LABEL (DESC, DESC_STR);
LABEL (RECN, "R");
LABEL (SHRS, TOTAL_SHARES_STR);
LABEL (BALN, BALN_STR);
LABEL (ACTN, ACTION_STR);
LABEL (XFRM, XFRM_STR);
LABEL (MXFRM, XFRM_STR);
LABEL (XTO, XFTO_STR);
LABEL (MEMO, MEMO_STR);
LABEL (CRED, CREDIT_STR);
LABEL (DEBT, DEBIT_STR);
LABEL (PRIC, PRICE_STR);
LABEL (VALU, VALUE_STR);
LABEL (DATE, DATE_STR);
LABEL (NUM, NUM_STR);
LABEL (DESC, DESC_STR);
LABEL (RECN, "R");
LABEL (SHRS, TOTAL_SHARES_STR);
LABEL (BALN, BALN_STR);
LABEL (ACTN, ACTION_STR);
LABEL (XFRM, XFRM_STR);
LABEL (MXFRM, XFRM_STR);
LABEL (XTO, XFTO_STR);
LABEL (MEMO, MEMO_STR);
LABEL (CRED, CREDIT_STR);
LABEL (DEBT, DEBIT_STR);
LABEL (PRIC, PRICE_STR);
LABEL (VALU, VALUE_STR);
if (debit_getter != NULL)
{
string = debit_getter(type);
/* setup custom labels for the debit/credit columns */
if (!only_debit_credit_labels) {
switch (type) {
case BANK_REGISTER:
LABEL (DEBT, DEPOSIT_STR);
LABEL (CRED, PAYMENT_STR);
break;
case CASH_REGISTER:
LABEL (DEBT, RECEIVE_STR);
LABEL (CRED, SPEND_STR);
break;
case ASSET_REGISTER:
LABEL (DEBT, DEBIT_STR);
LABEL (CRED, CREDIT_STR);
break;
case CREDIT_REGISTER:
LABEL (DEBT, PAYMENT_STR);
LABEL (CRED, CHARGE_STR);
break;
case LIABILITY_REGISTER:
LABEL (DEBT, DEBIT_STR);
LABEL (CRED, CREDIT_STR);
break;
case INCOME_LEDGER:
case INCOME_REGISTER:
LABEL (DEBT, CHARGE_STR);
LABEL (CRED, INCOME_STR);
break;
case EXPENSE_REGISTER:
LABEL (DEBT, EXPENSE_STR);
LABEL (CRED, REBATE_STR);
break;
case STOCK_REGISTER:
case PORTFOLIO_LEDGER:
case CURRENCY_REGISTER:
LABEL (DEBT, BOUGHT_STR);
LABEL (CRED, SOLD_STR);
break;
case GENERAL_LEDGER:
case EQUITY_REGISTER:
case SEARCH_LEDGER:
LABEL (DEBT, DEBIT_STR);
LABEL (CRED, CREDIT_STR);
break;
default:
break;
}
}
LABEL (DEBT, string);
/* copy debit, dredit strings to ndebit, ncredit cells */
hc = reg->header_label_cells[DEBT_CELL];
LABEL (NDEBT, hc->value);
hc = reg->header_label_cells[CRED_CELL];
LABEL (NCRED, hc->value);
free(string);
}
if (credit_getter != NULL)
{
string = credit_getter(type);
LABEL (CRED, string);
free(string);
}
/* copy debit, dredit strings to ndebit, ncredit cells */
hc = reg->header_label_cells[DEBT_CELL];
LABEL (NDEBT, hc->value);
hc = reg->header_label_cells[CRED_CELL];
LABEL (NCRED, hc->value);
}
/* ============================================== */

View File

@ -61,21 +61,24 @@
/* defined register types */
/* "registers" are single-account display windows.
* "ledgers" are multiple-account display windows */
#define BANK_REGISTER 1
#define CASH_REGISTER 2
#define ASSET_REGISTER 3
#define CREDIT_REGISTER 4
#define LIABILITY_REGISTER 5
#define INCOME_REGISTER 6
#define EXPENSE_REGISTER 7
#define EQUITY_REGISTER 8
#define STOCK_REGISTER 9
#define CURRENCY_REGISTER 10
typedef enum
{
BANK_REGISTER = 1,
CASH_REGISTER = 2,
ASSET_REGISTER = 3,
CREDIT_REGISTER = 4,
LIABILITY_REGISTER = 5,
INCOME_REGISTER = 6,
EXPENSE_REGISTER = 7,
EQUITY_REGISTER = 8,
STOCK_REGISTER = 9,
CURRENCY_REGISTER = 10,
#define GENERAL_LEDGER 11
#define INCOME_LEDGER 12
#define PORTFOLIO_LEDGER 13
#define SEARCH_LEDGER 14
GENERAL_LEDGER = 11,
INCOME_LEDGER = 12,
PORTFOLIO_LEDGER = 13,
SEARCH_LEDGER = 14
} SplitRegisterType;
#define REG_TYPE_MASK 0xff
@ -212,6 +215,10 @@ struct _SplitRegisterColors
uint32 header_bg_color;
};
typedef char* (*SRStringGetter) (SplitRegisterType);
void xaccSplitRegisterSetDebitStringGetter(SRStringGetter getter);
void xaccSplitRegisterSetCreditStringGetter(SRStringGetter getter);
SplitRegister * xaccMallocSplitRegister (int type);
void xaccInitSplitRegister (SplitRegister *, int type);
@ -221,10 +228,6 @@ void xaccDestroySplitRegister (SplitRegister *);
void xaccSetSplitRegisterColors (SplitRegisterColors reg_colors);
void xaccSplitRegisterConfigColors (SplitRegister *reg);
/* determines whether the register uses only debit/credit as labels
* or uses 'informal' names like deposit/payment, etc. */
void xaccSplitRegisterSetLabelMode(gncBoolean only_debit_credit);
/* returns non-zero value if updates have been made to data */
unsigned int xaccSplitRegisterGetChangeFlag (SplitRegister *);

View File

@ -119,10 +119,10 @@
(map thunk gnc:*credit-strings*)))
(define (gnc:get-debit-string type)
(assoc-ref gnc:*debit-strings* type))
(gnc:_ (assoc-ref gnc:*debit-strings* type)))
(define (gnc:get-credit-string type)
(assoc-ref gnc:*debit-strings* type))
(gnc:_ (assoc-ref gnc:*credit-strings* type)))
;; Main Window options
@ -212,11 +212,6 @@ the account instead of opening a register." #f))
#(auto_double "Auto Double" "Double line mode with a multi-line cursor")
)))
(gnc:register-configuration-option
(gnc:make-simple-boolean-option
"Register" "Always use debit/credit labels"
"aa" "Only use 'debit' and 'credit' as register column titles." #f))
(gnc:register-configuration-option
(gnc:make-simple-boolean-option
"Register" "Auto-Raise Lists"
@ -382,6 +377,11 @@ the account instead of opening a register." #f))
#(credit "Credit Accounts" "Reverse Credit Card, Liability, Equity, and Income Accounts")
#(none "None" "Don't reverse any accounts"))))
(gnc:register-configuration-option
(gnc:make-simple-boolean-option
"General" "Use accounting labels"
"e" "Only use 'debit' and 'credit' instead of informal synonyms." #f))
;; Configuation variables