business/business-core/gncInvoice.[c,h]

* Change the interface of PostToAccount to take a "memo" which is
  placed in the Transaction Description.  The Customer name is now
  placed in the Split Memo for the Split attached to the A/R account.

.../file/gnc-customer-xml-v2.c
.../file/gnc-employee-xml-v2.c
.../file/gnc-invoice-xml-v2.c
.../file/gnc-vendor-xml-v2.c

* Fix bugs in the parsing code so we get real commodities instead of
  "temporary" commodities.  This way we don't need to "fix" them
  later.

business/business-gnome/dialog-date-close.[c,h]
			date-close.glade

* Add a "description" field to the dialog.

business/business-gnome/dialog-invoice.c

* Hook into the new date-close and PostToAccount interfaces to
  provide a description for posted invoices.

gnome/window-register.c
register/ledger-core/gnc-ledger-display.[c,h]
register/ledger-core/split-register-layout.c
register/ledger-core/split-register-model.c

* Update the split-register for A/R and A/P.  Make it default to
  double-lined, basic ledger for A/R and A/P.  Fix some of the cell
  labels and help text.

report/standard-reports/aging.scm

* Look at Split Memo instead of Transaction Description by default.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6848 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins
2002-05-11 00:35:43 +00:00
parent a21c57d1ca
commit d4fd27e987
16 changed files with 210 additions and 73 deletions

View File

@@ -281,7 +281,7 @@ customer_commodity_handler (xmlNodePtr node, gpointer customer_pdata)
struct customer_pdata *pdata = customer_pdata;
gnc_commodity *com;
com = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
com = dom_tree_to_commodity_ref(node, pdata->book);
g_return_val_if_fail (com, FALSE);
gncCustomerSetCommodity (pdata->customer, com);

View File

@@ -249,7 +249,7 @@ employee_commodity_handler (xmlNodePtr node, gpointer employee_pdata)
struct employee_pdata *pdata = employee_pdata;
gnc_commodity *com;
com = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
com = dom_tree_to_commodity_ref(node, pdata->book);
g_return_val_if_fail (com, FALSE);
gncEmployeeSetCommodity (pdata->employee, com);

View File

@@ -307,7 +307,7 @@ invoice_commodity_handler (xmlNodePtr node, gpointer invoice_pdata)
struct invoice_pdata *pdata = invoice_pdata;
gnc_commodity *com;
com = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
com = dom_tree_to_commodity_ref(node, pdata->book);
g_return_val_if_fail (com, FALSE);
gncInvoiceSetCommonCommodity (pdata->invoice, com);

View File

@@ -228,7 +228,7 @@ vendor_commodity_handler (xmlNodePtr node, gpointer vendor_pdata)
struct vendor_pdata *pdata = vendor_pdata;
gnc_commodity *com;
com = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
com = dom_tree_to_commodity_ref(node, pdata->book);
g_return_val_if_fail (com, FALSE);
gncVendorSetCommodity (pdata->vendor, com);

View File

@@ -390,7 +390,7 @@ gncInvoiceAttachInvoiceToTxn (GncInvoice *invoice, Transaction *txn)
Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
Timespec *post_date, Timespec *due_date,
gboolean reverse)
const char * desc, gboolean reverse)
{
Transaction *txn;
GList *iter;
@@ -406,11 +406,8 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
txn = xaccMallocTransaction (invoice->book);
xaccTransBeginEdit (txn);
/* Set Transaction Description (customer), Num (invoice ID), Currency */
xaccTransSetDescription
(txn,
gncOwnerGetName (gncOwnerGetEndOwner (gncInvoiceGetOwner (invoice))));
/* Set Transaction Description, Num (invoice ID), Currency */
xaccTransSetDescription (txn, desc);
xaccTransSetNum (txn, gncInvoiceGetID (invoice));
xaccTransSetCurrency (txn, invoice->common_commodity);
@@ -444,8 +441,11 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
*/
GET_OR_ADD_ACCVAL (splitinfo, this_acc, acc_val);
acc_val->val = gnc_numeric_add_fixed (acc_val->val, value);
total = gnc_numeric_add_fixed (total, value);
if (gnc_numeric_check (value) == GNC_ERROR_OK) {
acc_val->val = gnc_numeric_add_fixed (acc_val->val, value);
total = gnc_numeric_add_fixed (total, value);
} else
g_warning ("bad value in our entry");
}
/* Repeat for the TaxValue */
@@ -453,8 +453,11 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
if (this_acc) {
GET_OR_ADD_ACCVAL (splitinfo, this_acc, acc_val);
acc_val->val = gnc_numeric_add_fixed (acc_val->val, tax);
total = gnc_numeric_add_fixed (total, tax);
if (gnc_numeric_check (tax) == GNC_ERROR_OK) {
acc_val->val = gnc_numeric_add_fixed (acc_val->val, tax);
total = gnc_numeric_add_fixed (total, tax);
} else
g_warning ("bad tax in our entry");
}
} /* for */
@@ -479,6 +482,12 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
{
Split *split = xaccMallocSplit (invoice->book);
/* Set action/memo */
/* The memo is the customer name */
xaccSplitSetMemo
(split,
gncOwnerGetName (gncOwnerGetEndOwner (gncInvoiceGetOwner (invoice))));
xaccSplitSetBaseValue (split, (reverse ? total : gnc_numeric_neg (total)),
invoice->common_commodity);
xaccAccountBeginEdit (acc);

View File

@@ -64,7 +64,7 @@ GList * gncInvoiceGetEntries (GncInvoice *invoice);
Transaction *
gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
Timespec *posted_date, Timespec *due_date,
gboolean reverse);
const char *description, gboolean reverse);
/* Given a transaction, find and return the Invoice */

View File

@@ -151,18 +151,19 @@
</widget>
<widget>
<class>GnomeDateEdit</class>
<name>date</name>
<show_time>False</show_time>
<use_24_format>True</use_24_format>
<week_start_monday>False</week_start_monday>
<lower_hour>7</lower_hour>
<upper_hour>19</upper_hour>
<class>GtkHBox</class>
<name>date_box</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>3</padding>
<expand>False</expand>
<fill>True</fill>
</child>
<widget>
<class>Placeholder</class>
</widget>
</widget>
<widget>
@@ -348,6 +349,23 @@
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>memo_label</name>
<label>Description</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>acct_label</name>
@@ -378,28 +396,45 @@
</child>
<widget>
<class>GnomeDateEdit</class>
<name>post_date</name>
<show_time>False</show_time>
<use_24_format>False</use_24_format>
<week_start_monday>False</week_start_monday>
<lower_hour>7</lower_hour>
<upper_hour>19</upper_hour>
<class>GtkHBox</class>
<name>post_date_box</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>Placeholder</class>
</widget>
</widget>
<widget>
<class>GnomeDateEdit</class>
<name>date</name>
<show_time>False</show_time>
<use_24_format>True</use_24_format>
<week_start_monday>False</week_start_monday>
<lower_hour>7</lower_hour>
<upper_hour>19</upper_hour>
<class>GtkHBox</class>
<name>date_box</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>Placeholder</class>
</widget>
</widget>
<widget>
<class>GtkEntry</class>
<name>memo_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>

View File

@@ -24,10 +24,12 @@ typedef struct _dialog_date_close_window {
GtkWidget *date;
GtkWidget *post_date;
GtkWidget *acct_combo;
GtkWidget *memo_entry;
Timespec *ts, *ts2;
GList * acct_types;
GNCBook *book;
Account *acct;
char **memo;
gboolean retval;
} DialogDateClose;
@@ -104,6 +106,10 @@ gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data)
if (ddc->post_date)
*(ddc->ts2) = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (ddc->post_date));
if (ddc->memo_entry && ddc->memo)
*(ddc->memo) = gtk_editable_get_chars (GTK_EDITABLE (ddc->memo_entry),
0, -1);
ddc->retval = TRUE;
gnome_dialog_close (GNOME_DIALOG (ddc->dialog));
}
@@ -262,7 +268,8 @@ gnc_dialog_dates_acct_parented (GtkWidget *parent, const char *message,
gboolean ok_is_default,
GList * acct_types, GNCBook *book,
/* Returned Data... */
Timespec *ddue, Timespec *post, Account **acct)
Timespec *ddue, Timespec *post,
char **memo, Account **acct)
{
DialogDateClose *ddc;
GtkWidget *hbox;
@@ -280,11 +287,13 @@ gnc_dialog_dates_acct_parented (GtkWidget *parent, const char *message,
ddc->ts2 = post;
ddc->book = book;
ddc->acct_types = acct_types;
ddc->memo = memo;
xml = gnc_glade_xml_new ("date-close.glade", "Date Account Dialog");
ddc->dialog = glade_xml_get_widget (xml, "Date Account Dialog");
ddc->acct_combo = glade_xml_get_widget (xml, "acct_combo");
hbox = glade_xml_get_widget (xml, "the_hbox");
ddc->memo_entry = glade_xml_get_widget (xml, "memo_entry");
date_box = glade_xml_get_widget (xml, "date_box");
ddc->date = gnc_date_edit_new (time(NULL), FALSE, FALSE);
@@ -403,6 +412,8 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
gtk_widget_hide_all (glade_xml_get_widget (xml, "postdate_label"));
gtk_widget_hide_all (glade_xml_get_widget (xml, "post_date"));
gtk_widget_hide_all (glade_xml_get_widget (xml, "memo_entry"));
gtk_widget_hide_all (glade_xml_get_widget (xml, "memo_label"));
gtk_main ();

View File

@@ -21,7 +21,8 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message,
/*
* Note that the dialog will "own" (and free) the acct_types list.
* it should be a list of GNCAccountTypes
* it should be a list of GNCAccountTypes. If memo is non-NULL,
* it will g_malloc() a string. The caller should g_free() it.
*/
gboolean
@@ -33,7 +34,7 @@ gnc_dialog_dates_acct_parented (GtkWidget *parent, const char *message,
GList * acct_types, GNCBook *book,
/* Returned Data... */
Timespec *ddue, Timespec *post,
Account **acct);
char **memo, Account **acct);
gboolean
gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,

View File

@@ -266,7 +266,7 @@ gnc_invoice_window_post_invoice_cb (GtkWidget *widget, gpointer data)
{
InvoiceWindow *iw = data;
GncInvoice *invoice;
char *message, *ddue_label, *post_label, *acct_label;
char *message, *memo, *ddue_label, *post_label, *acct_label;
Account *acc = NULL;
GList * acct_types = NULL;
Timespec ddue, postdate;
@@ -313,19 +313,26 @@ gnc_invoice_window_post_invoice_cb (GtkWidget *widget, gpointer data)
timespecFromTime_t (&postdate, time(NULL));
ddue = postdate;
ddue.tv_sec += 3600*24*30; /* XXX: due in 30 days */
memo = NULL;
if (!gnc_dialog_dates_acct_parented (iw->dialog, message, ddue_label,
post_label, acct_label, TRUE, acct_types,
iw->book, &ddue, &postdate, &acc))
iw->book, &ddue, &postdate, &memo, &acc))
return;
/* Yep, we're posting. So, save the invoice...
* Note that we can safely ignore the return value; we checked
* the verify_ok earlier, so we know it's ok.
*/
gnc_suspend_gui_refresh ();
gnc_invoice_window_ok_save (iw);
/* ... post it; post date is set to now ... */
gncInvoicePostToAccount (invoice, acc, &postdate, &ddue, reverse);
gncInvoicePostToAccount (invoice, acc, &postdate, &ddue, memo, reverse);
gnc_resume_gui_refresh ();
if (memo)
g_free (memo);
/* Reset the type; change to read-only! */
iw->dialog_type = VIEW_INVOICE;

View File

@@ -2181,9 +2181,7 @@ regWindowLedger (GNCLedgerDisplay *ledger)
gboolean use_double_line;
GtkCheckMenuItem *check;
use_double_line = gnc_lookup_boolean_option ("Register",
"Double Line Mode",
FALSE);
use_double_line = gnc_ledger_display_default_double_line (reg);
/* be sure to initialize the gui elements associated with the cursor */
gnc_split_register_config (reg, reg->type, reg->style, use_double_line);

View File

@@ -56,6 +56,7 @@ struct gnc_ledger_display
SplitRegister *reg;
gboolean loading;
gboolean use_double_line_default;
GNCLedgerDisplayDestroy destroy;
GNCLedgerDisplayGetParent get_parent;
@@ -76,6 +77,7 @@ gnc_ledger_display_internal (Account *lead_account, Query *q,
GNCLedgerDisplayType ld_type,
SplitRegisterType reg_type,
SplitRegisterStyle style,
gboolean use_double_line,
gboolean is_template);
static void gnc_ledger_display_refresh_internal (GNCLedgerDisplay *ld,
GList *splits);
@@ -205,24 +207,34 @@ find_by_reg (gpointer find_data, gpointer user_data)
}
static SplitRegisterStyle
gnc_get_default_register_style (void)
gnc_get_default_register_style (GNCAccountType type)
{
SplitRegisterStyle new_style = REG_STYLE_LEDGER;
char *style_string;
style_string = gnc_lookup_multichoice_option("Register",
"Default Register Style",
"ledger");
if (safe_strcmp(style_string, "ledger") == 0)
switch (type) {
case PAYABLE:
case RECEIVABLE:
new_style = REG_STYLE_LEDGER;
else if (safe_strcmp(style_string, "auto_ledger") == 0)
new_style = REG_STYLE_AUTO_LEDGER;
else if (safe_strcmp(style_string, "journal") == 0)
new_style = REG_STYLE_JOURNAL;
break;
if (style_string != NULL)
free(style_string);
default:
style_string = gnc_lookup_multichoice_option("Register",
"Default Register Style",
"ledger");
if (safe_strcmp(style_string, "ledger") == 0)
new_style = REG_STYLE_LEDGER;
else if (safe_strcmp(style_string, "auto_ledger") == 0)
new_style = REG_STYLE_AUTO_LEDGER;
else if (safe_strcmp(style_string, "journal") == 0)
new_style = REG_STYLE_JOURNAL;
if (style_string != NULL)
free(style_string);
break;
}
return new_style;
}
@@ -350,17 +362,38 @@ gnc_get_reg_type (Account *leader, GNCLedgerDisplayType ld_type)
return reg_type;
}
/* Returns a boolean of whether this display should be single or double lined
* mode by default */
gboolean
gnc_ledger_display_default_double_line (GNCLedgerDisplay *gld)
{
return (gld->use_double_line_default ||
gnc_lookup_boolean_option ("Register", "Double Line Mode", FALSE));
}
/* Opens up a register window to display a single account */
GNCLedgerDisplay *
gnc_ledger_display_simple (Account *account)
{
SplitRegisterType reg_type;
GNCAccountType acc_type = xaccAccountGetType (account);
gboolean use_double_line;
switch (acc_type) {
case PAYABLE:
case RECEIVABLE:
use_double_line = TRUE;
break;
default:
use_double_line = FALSE;
break;
}
reg_type = gnc_get_reg_type (account, LD_SINGLE);
return gnc_ledger_display_internal (account, NULL, LD_SINGLE, reg_type,
gnc_get_default_register_style (),
FALSE);
gnc_get_default_register_style(acc_type),
use_double_line, FALSE);
}
/* Opens up a register window to display an account, and all of its
@@ -373,7 +406,8 @@ gnc_ledger_display_subaccounts (Account *account)
reg_type = gnc_get_reg_type (account, LD_SUBACCOUNT);
return gnc_ledger_display_internal (account, NULL, LD_SUBACCOUNT,
reg_type, REG_STYLE_JOURNAL, FALSE);
reg_type, REG_STYLE_JOURNAL, FALSE,
FALSE);
}
@@ -412,7 +446,7 @@ gnc_ledger_display_gl (void)
return gnc_ledger_display_internal (NULL, query, LD_GL,
GENERAL_LEDGER,
REG_STYLE_JOURNAL, FALSE);
REG_STYLE_JOURNAL, FALSE, FALSE);
}
/**
@@ -451,7 +485,7 @@ gnc_ledger_display_template_gl (char *id)
ld = gnc_ledger_display_internal (NULL, q, LD_GL,
GENERAL_LEDGER,
REG_STYLE_JOURNAL,
TRUE); /* TRUE : template mode */
FALSE, TRUE); /* TRUE : template mode */
sr = gnc_ledger_display_get_split_register (ld);
gnc_split_register_set_template_account (sr, acct);
@@ -614,7 +648,8 @@ GNCLedgerDisplay *
gnc_ledger_display_query (Query *query, SplitRegisterType type,
SplitRegisterStyle style)
{
return gnc_ledger_display_internal (NULL, query, LD_GL, type, style, FALSE);
return gnc_ledger_display_internal (NULL, query, LD_GL, type, style,
FALSE, FALSE);
}
static GNCLedgerDisplay *
@@ -622,6 +657,7 @@ gnc_ledger_display_internal (Account *lead_account, Query *q,
GNCLedgerDisplayType ld_type,
SplitRegisterType reg_type,
SplitRegisterStyle style,
gboolean use_double_line,
gboolean is_template )
{
GNCLedgerDisplay *ld;
@@ -723,7 +759,9 @@ gnc_ledger_display_internal (Account *lead_account, Query *q,
* The main register window itself *
\******************************************************************/
ld->reg = gnc_split_register_new (reg_type, style, FALSE, is_template);
ld->use_double_line_default = use_double_line;
ld->reg = gnc_split_register_new (reg_type, style, use_double_line,
is_template);
gnc_split_register_set_data (ld->reg, ld, gnc_ledger_display_parent);

View File

@@ -119,4 +119,8 @@ void gnc_ledger_display_close (GNCLedgerDisplay * ledger_display);
/* close all ledger windows containing this account. */
void gnc_ledger_display_destroy_by_account (Account *account);
/* Returns a boolean of whether this display should be single or double lined
* mode by default */
gboolean gnc_ledger_display_default_double_line (GNCLedgerDisplay *gld);
#endif

View File

@@ -185,7 +185,7 @@ gnc_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
copy_cursor_row (layout, curs, curs_last, 0);
gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 1, 3);
gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 4);
gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 1, 4);
curs = gnc_table_layout_get_cursor (layout,
CURSOR_SINGLE_JOURNAL);
@@ -206,7 +206,7 @@ gnc_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
copy_cursor_row (layout, curs, curs_last, 0);
gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 4);
gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 1, 4);
curs = gnc_table_layout_get_cursor (layout,
CURSOR_SPLIT);

View File

@@ -127,7 +127,15 @@ static const char *
gnc_split_register_get_num_label (VirtualLocation virt_loc,
gpointer user_data)
{
return _("Num");
SplitRegister *reg = user_data;
switch (reg->type) {
case RECEIVABLE_REGISTER:
case PAYABLE_REGISTER:
return _("Ref");
default:
return _("Num");
}
}
static const char *
@@ -185,7 +193,16 @@ static const char *
gnc_split_register_get_memo_label (VirtualLocation virt_loc,
gpointer user_data)
{
return _("Memo");
SplitRegister *reg = user_data;
switch (reg->type) {
case RECEIVABLE_REGISTER:
return _("Customer");
case PAYABLE_REGISTER:
return _("Vendor");
default:
return _("Memo");
}
}
static const char *
@@ -797,7 +814,16 @@ gnc_split_register_get_num_help (VirtualLocation virt_loc,
help = gnc_table_get_entry (reg->table, virt_loc);
if (!help || *help == '\0')
help = _("Enter the transaction number, such as the check number");
switch (reg->type) {
case RECEIVABLE_REGISTER:
case PAYABLE_REGISTER:
help = _("Enter the transaction reference, "
"such as the invoice or check number");
break;
default:
help = _("Enter the transaction number, such as the check number");
break;
}
return g_strdup (help);
}
@@ -939,8 +965,16 @@ gnc_split_register_get_memo_help (VirtualLocation virt_loc,
help = gnc_table_get_entry (reg->table, virt_loc);
if (!help || *help == '\0')
help = _("Enter a description of the split");
switch (reg->type) {
case RECEIVABLE_REGISTER:
help = _("Enter the name of the Customer");
break;
case PAYABLE_REGISTER:
help = _("Enter the name of the Vendor");
break;
default:
help = _("Enter a description of the split");
}
return g_strdup (help);
}

View File

@@ -322,9 +322,9 @@ more than one currency. This report is not designed to cope with this possibili
gnc:pagename-general
optname-use-description
"h"
(N_ "Use the description to identify individual companys.\
(N_ "Use the description to identify individual companies.\
If false, use split memo")
#t))
#f))
(add-option