From 60dbedd7f4b5b1990b418c3f339c2331dd8e9612 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Sun, 25 Nov 2001 21:41:34 +0000 Subject: [PATCH] First-pass at A/R and A/P accounts. Right now there is nothing special about them compared the Asset and Liability accounts except the labels are slightly different. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6062 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/app-utils/gnc-ui-util.c | 1 + src/app-utils/prefs.scm | 8 ++++++-- src/engine/Account.c | 20 ++++++++++++++----- src/engine/Account.h | 14 ++++++++----- src/engine/gw-engine-spec.scm | 2 ++ src/gnome/window-acct-tree.c | 6 ++++++ src/gnome/window-main-summarybar.c | 2 ++ src/gnome/window-reconcile.c | 6 ++++-- src/register/ledger-core/gnc-ledger-display.c | 8 ++++++++ .../ledger-core/split-register-layout.c | 4 ++++ src/register/ledger-core/split-register.c | 12 +++++++++++ src/register/ledger-core/split-register.h | 2 ++ src/scm/main-window.scm | 6 ++++-- 13 files changed, 75 insertions(+), 16 deletions(-) diff --git a/src/app-utils/gnc-ui-util.c b/src/app-utils/gnc-ui-util.c index 3612908611..f07b4b7dff 100644 --- a/src/app-utils/gnc-ui-util.c +++ b/src/app-utils/gnc-ui-util.c @@ -134,6 +134,7 @@ gnc_configure_reverse_balance (void) else if (safe_strcmp (choice, "credit") == 0) { reverse_type[LIABILITY] = TRUE; + reverse_type[PAYABLE] = TRUE; reverse_type[EQUITY] = TRUE; reverse_type[INCOME] = TRUE; reverse_type[CREDIT] = TRUE; diff --git a/src/app-utils/prefs.scm b/src/app-utils/prefs.scm index 909846a806..3719a6ff90 100644 --- a/src/app-utils/prefs.scm +++ b/src/app-utils/prefs.scm @@ -111,6 +111,8 @@ (cons 'CURRENCY (N_ "Buy")) (cons 'INCOME (N_ "Charge")) (cons 'EXPENSE (N_ "Expense")) + (cons 'PAYABLE (N_ "Payment")) + (cons 'RECEIVABLE (N_ "Invoice")) (cons 'EQUITY (N_ "Decrease")))) (define gnc:*credit-strings* @@ -125,6 +127,8 @@ (cons 'CURRENCY (N_ "Sell")) (cons 'INCOME (N_ "Income")) (cons 'EXPENSE (N_ "Rebate")) + (cons 'PAYABLE (N_ "Invoice")) + (cons 'RECEIVABLE (N_ "Receipt")) (cons 'EQUITY (N_ "Increase")))) (define (gnc:get-debit-string type) @@ -331,7 +335,7 @@ not each row") (N_ "Reconcile") (N_ "Automatic interest transfer") "a" (N_ "Prior to reconciling an account which charges or pays interest, \ prompt the user to enter a transaction for the interest charge or payment. -Currently only enabled for Bank, Credit, Mutual, Asset, and Liability accounts.") +Currently only enabled for Bank, Credit, Mutual, Asset, Receivable, Payable, and Liability accounts.") #f)) (gnc:register-configuration-option @@ -450,7 +454,7 @@ Control Center")))))) (list->vector (list 'credit (N_ "Credit Accounts") - (N_ "Reverse Credit Card, Liability, Equity, and Income \ + (N_ "Reverse Credit Card, Payable, Liability, Equity, and Income \ Accounts"))) (list->vector (list 'none diff --git a/src/engine/Account.c b/src/engine/Account.c index 4b6f9cf2de..b312442a8d 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -1192,11 +1192,11 @@ xaccTransFixSplitDateOrder (Transaction *trans) * order for report generation */ static int typeorder[NUM_ACCOUNT_TYPES] = { - BANK, STOCK, MUTUAL, CURRENCY, CASH, ASSET, - CREDIT, LIABILITY, INCOME, EXPENSE, EQUITY }; + BANK, STOCK, MUTUAL, CURRENCY, CASH, ASSET, RECEIVABLE, + CREDIT, LIABILITY, PAYABLE, INCOME, EXPENSE, EQUITY }; static int revorder[NUM_ACCOUNT_TYPES] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; int @@ -1919,6 +1919,8 @@ xaccAccountTypeEnumAsString(GNCAccountType type) { GNC_RETURN_ENUM_AS_STRING(INCOME); GNC_RETURN_ENUM_AS_STRING(EXPENSE); GNC_RETURN_ENUM_AS_STRING(EQUITY); + GNC_RETURN_ENUM_AS_STRING(RECEIVABLE); + GNC_RETURN_ENUM_AS_STRING(PAYABLE); GNC_RETURN_ENUM_AS_STRING(CHECKING); GNC_RETURN_ENUM_AS_STRING(SAVINGS); GNC_RETURN_ENUM_AS_STRING(MONEYMRKT); @@ -1950,6 +1952,8 @@ xaccAccountStringToType(const char* str, GNCAccountType *type) { GNC_RETURN_ON_MATCH(INCOME); GNC_RETURN_ON_MATCH(EXPENSE); GNC_RETURN_ON_MATCH(EQUITY); + GNC_RETURN_ON_MATCH(RECEIVABLE); + GNC_RETURN_ON_MATCH(PAYABLE); GNC_RETURN_ON_MATCH(CHECKING); GNC_RETURN_ON_MATCH(SAVINGS); GNC_RETURN_ON_MATCH(MONEYMRKT); @@ -1989,7 +1993,9 @@ account_type_name[NUM_ACCOUNT_TYPES] = { N_("Currency"), N_("Income"), N_("Expense"), - N_("Equity") + N_("Equity"), + N_("A/Receivable"), + N_("A/Payable") /* N_("Checking"), N_("Savings"), @@ -2024,6 +2030,8 @@ xaccAccountTypesCompatible (GNCAccountType parent_type, case CURRENCY: case CREDIT: case LIABILITY: + case RECEIVABLE: + case PAYABLE: compatible = ((child_type == BANK) || (child_type == CASH) || (child_type == ASSET) || @@ -2031,7 +2039,9 @@ xaccAccountTypesCompatible (GNCAccountType parent_type, (child_type == MUTUAL) || (child_type == CURRENCY) || (child_type == CREDIT) || - (child_type == LIABILITY)); + (child_type == LIABILITY)|| + (child_type == RECEIVABLE)|| + (child_type == PAYABLE)); break; case INCOME: case EXPENSE: diff --git a/src/engine/Account.h b/src/engine/Account.h index 4fcb9ef893..cdbf11bae1 100644 --- a/src/engine/Account.h +++ b/src/engine/Account.h @@ -91,14 +91,18 @@ typedef enum EQUITY = 10, /* Equity account is used to balance the balance sheet. */ - NUM_ACCOUNT_TYPES = 11, + RECEIVABLE = 11, + PAYABLE = 12, + /* A/R and A/P account types */ + + NUM_ACCOUNT_TYPES = 13, /* stop here; the following types just aren't ready for prime time */ /* bank account types */ - CHECKING = 11, - SAVINGS = 12, - MONEYMRKT = 13, - CREDITLINE = 14, /* line of credit */ + CHECKING = 13, + SAVINGS = 14, + MONEYMRKT = 15, + CREDITLINE = 16, /* line of credit */ } GNCAccountType; /* ------------------ */ diff --git a/src/engine/gw-engine-spec.scm b/src/engine/gw-engine-spec.scm index c53a4e7c04..69889defe5 100644 --- a/src/engine/gw-engine-spec.scm +++ b/src/engine/gw-engine-spec.scm @@ -503,6 +503,8 @@ (gw:enum-add-value! we "INCOME" 'income) (gw:enum-add-value! we "EXPENSE" 'expense) (gw:enum-add-value! we "EQUITY" 'equity) + (gw:enum-add-value! we "RECEIVABLE" 'receivable) + (gw:enum-add-value! we "PAYABLE" 'payable) (gw:enum-add-value! we "NUM_ACCOUNT_TYPES" 'num-account-types) (gw:enum-add-value! we "CHECKING" 'checking) (gw:enum-add-value! we "SAVINGS" 'savings) diff --git a/src/gnome/window-acct-tree.c b/src/gnome/window-acct-tree.c index 39f6cb46b9..a5cbbb6700 100644 --- a/src/gnome/window-acct-tree.c +++ b/src/gnome/window-acct-tree.c @@ -644,6 +644,12 @@ gnc_acct_tree_window_configure (GNCAcctTreeWin * info) { else if (safe_strcmp(node->data, "equity") == 0) new_avi.include_type[EQUITY] = TRUE; + + else if (safe_strcmp(node->data, "payable") == 0) + new_avi.include_type[PAYABLE] = TRUE; + + else if (safe_strcmp(node->data, "receivable") == 0) + new_avi.include_type[RECEIVABLE] = TRUE; } gnc_free_list_option_value (list); diff --git a/src/gnome/window-main-summarybar.c b/src/gnome/window-main-summarybar.c index 5f00a43a66..6241a33fc3 100644 --- a/src/gnome/window-main-summarybar.c +++ b/src/gnome/window-main-summarybar.c @@ -290,6 +290,8 @@ gnc_ui_accounts_recurse (AccountGroup *group, GList **currency_list, case MUTUAL: case CREDIT: case LIABILITY: + case PAYABLE: + case RECEIVABLE: amount = gnc_ui_account_get_balance (account, FALSE); /* unreverse sign */ if (gnc_reverse_balance (account)) diff --git a/src/gnome/window-reconcile.c b/src/gnome/window-reconcile.c index aa05d63336..b9abf4b50d 100644 --- a/src/gnome/window-reconcile.c +++ b/src/gnome/window-reconcile.c @@ -137,11 +137,13 @@ typedef struct _startRecnWindowData * xfer dialog could pop up, if the user's preferences allow it. */ #define account_type_has_auto_interest_charge(type) (((type) == CREDIT) || \ - ((type) == LIABILITY)) + ((type) == LIABILITY) ||\ + ((type) == PAYABLE)) #define account_type_has_auto_interest_payment(type) (((type) == BANK) || \ ((type) == ASSET) || \ - ((type) == MUTUAL)) + ((type) == MUTUAL) || \ + ((type) == RECEIVABLE)) #define account_type_has_auto_interest_xfer(type) \ ( account_type_has_auto_interest_charge(type) || \ diff --git a/src/register/ledger-core/gnc-ledger-display.c b/src/register/ledger-core/gnc-ledger-display.c index f1507b0071..23b323885e 100644 --- a/src/register/ledger-core/gnc-ledger-display.c +++ b/src/register/ledger-core/gnc-ledger-display.c @@ -259,6 +259,12 @@ gnc_get_reg_type (Account *leader, GNCLedgerDisplayType ld_type) case LIABILITY: return LIABILITY_REGISTER; + case PAYABLE: + return PAYABLE_REGISTER; + + case RECEIVABLE: + return RECEIVABLE_REGISTER; + case STOCK: case MUTUAL: return STOCK_REGISTER; @@ -296,6 +302,8 @@ gnc_get_reg_type (Account *leader, GNCLedgerDisplayType ld_type) case ASSET: case CREDIT: case LIABILITY: + case RECEIVABLE: + case PAYABLE: /* if any of the sub-accounts have STOCK or MUTUAL types, * then we must use the PORTFOLIO_LEDGER ledger. Otherwise, * a plain old GENERAL_LEDGER will do. */ diff --git a/src/register/ledger-core/split-register-layout.c b/src/register/ledger-core/split-register-layout.c index 410a72e14f..22be0d96d0 100644 --- a/src/register/ledger-core/split-register-layout.c +++ b/src/register/ledger-core/split-register-layout.c @@ -88,6 +88,8 @@ gnc_split_register_set_cells (SplitRegister *reg, TableLayout *layout) case ASSET_REGISTER: case CREDIT_REGISTER: case LIABILITY_REGISTER: + case PAYABLE_REGISTER: + case RECEIVABLE_REGISTER: case INCOME_REGISTER: case EXPENSE_REGISTER: case EQUITY_REGISTER: @@ -371,6 +373,8 @@ gnc_split_register_layout_add_cursors (SplitRegister *reg, case ASSET_REGISTER: case CREDIT_REGISTER: case LIABILITY_REGISTER: + case PAYABLE_REGISTER: + case RECEIVABLE_REGISTER: case INCOME_REGISTER: case EXPENSE_REGISTER: case EQUITY_REGISTER: diff --git a/src/register/ledger-core/split-register.c b/src/register/ledger-core/split-register.c index 4d841d8ca8..7ef319977a 100644 --- a/src/register/ledger-core/split-register.c +++ b/src/register/ledger-core/split-register.c @@ -1822,6 +1822,10 @@ gnc_split_register_type_to_account_type (SplitRegisterType sr_type) return CREDIT; case LIABILITY_REGISTER: return LIABILITY; + case PAYABLE_REGISTER: + return PAYABLE; + case RECEIVABLE_REGISTER: + return RECEIVABLE; case INCOME_LEDGER: case INCOME_REGISTER: return INCOME; @@ -1988,6 +1992,14 @@ gnc_split_register_config_action (SplitRegister *reg) gnc_combo_cell_add_menu_item (cell, _("Int")); gnc_combo_cell_add_menu_item (cell, _("Payment")); break; + case RECEIVABLE_REGISTER: + gnc_combo_cell_add_menu_item (cell, _("Invoice")); + gnc_combo_cell_add_menu_item (cell, _("Receipt")); + break; + case PAYABLE_REGISTER: + gnc_combo_cell_add_menu_item (cell, _("Invoice")); + gnc_combo_cell_add_menu_item (cell, _("Payment")); + break; case INCOME_LEDGER: case INCOME_REGISTER: gnc_combo_cell_add_menu_item (cell, _("Buy")); diff --git a/src/register/ledger-core/split-register.h b/src/register/ledger-core/split-register.h index e8ebbe2f70..a6e6f6b02e 100644 --- a/src/register/ledger-core/split-register.h +++ b/src/register/ledger-core/split-register.h @@ -48,6 +48,8 @@ typedef enum EQUITY_REGISTER, STOCK_REGISTER, CURRENCY_REGISTER, + RECEIVABLE_REGISTER, + PAYABLE_REGISTER, NUM_SINGLE_REGISTER_TYPES, GENERAL_LEDGER = NUM_SINGLE_REGISTER_TYPES, diff --git a/src/scm/main-window.scm b/src/scm/main-window.scm index 61b3ff156a..7bc024e1de 100644 --- a/src/scm/main-window.scm +++ b/src/scm/main-window.scm @@ -56,7 +56,7 @@ the account instead of opening a register.") #f)) (N_ "Account Tree") (N_ "Account types to display") "b" "" (list 'bank 'cash 'credit 'asset 'liability 'stock - 'mutual 'currency 'income 'expense 'equity) + 'mutual 'currency 'income 'expense 'equity 'payable 'receivable) (list (list->vector (list 'bank (N_ "Bank") "")) (list->vector (list 'cash (N_ "Cash") "")) (list->vector (list 'credit (N_ "Credit") "")) @@ -67,7 +67,9 @@ the account instead of opening a register.") #f)) (list->vector (list 'currency (N_ "Currency") "")) (list->vector (list 'income (N_ "Income") "")) (list->vector (list 'expense (N_ "Expense") "")) - (list->vector (list 'equity (N_ "Equity") ""))))) + (list->vector (list 'equity (N_ "Equity") "")) + (list->vector (list 'payable (N_ "Accounts Payable") "")) + (list->vector (list 'receivable (N_ "Accounts Receivable") ""))))) (add-option (gnc:make-list-option