mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug #600374: Add editable transaction field in the register for bank accounts
Patch by James Raehl: Currently, the only editable date in the register is the bank posting date. This patch implements a second editable date in the first field of the second line of a double-line mode register. The entry date is borrowed in this implementation. I understand the entry date is used for such as stock transactions, but to me is mostly useless for those keeping track of personal finances. This feature has been requested on occasion, such as at https://lists.gnucash.org/pipermail/gnucash-devel/2003-August/010279.html and https://bugzilla.gnome.org/show_bug.cgi?id=92274 and http://lists.gnucash.org/pipermail/gnucash-user/2009-October/031839.html "Transaction date" refers to such as the date the purchase was rung up in the store cash register, payment mailed or possibly received by the recipient, payment received by you, date you walked into the bank to make a deposit, or even the date the expense was scheduled. Your intent to expend the money is definitely determined. "Bank posting date" is when the bank has finally debited or credited your account. "Date entered" in Gnucash would be identical to "transaction date", if you always without fail entered the transaction into Gnucash on the same date as the purchase, bank deposit, etc. Bug #92274 describes it better. That mentions 3 dates, date mailed, date gas company posts the payment, and date the bank debits the payment. I track even more dates on credit card transactions: statement date, date bill received, payment mailing date, card payment received (card transaction) date, card posting date, and bank posting date. These are currently entered into my transaction Notes field, which is one reason for my multi-line up/down Notes field scroll patch, but Notes dates are not sortable. Obviously, the use of sortable dates is flexible. I use one date as a budget date (group budgeted expenses with paychecks), and the second as bank posting date. I could obviously use a third date, the "transaction date", but haven't implemented that yet (much more work). git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18428 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
9eb0192147
commit
20197b89af
@ -120,6 +120,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, DTRANS_CELL, 1, 0);
|
||||
gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 1, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
|
||||
@ -141,6 +142,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, DTRANS_CELL, 1, 0);
|
||||
gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
|
||||
|
||||
@ -531,6 +533,14 @@ gnc_split_register_layout_add_cells (SplitRegister *reg,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
DTRANS_CELL,
|
||||
DATE_CELL_TYPE_NAME,
|
||||
N_("sample:12/12/2000") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
NUM_CELL,
|
||||
NUM_CELL_TYPE_NAME,
|
||||
|
@ -110,6 +110,31 @@ gnc_split_register_save_due_date_cell (BasicCell * cell,
|
||||
xaccTransSetDateDueTS (sd->trans, &ts);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_split_register_save_trans_date_cell (BasicCell * cell,
|
||||
gpointer save_data,
|
||||
gpointer user_data)
|
||||
{
|
||||
SRSaveData *sd = save_data;
|
||||
const char *value;
|
||||
Timespec ts;
|
||||
|
||||
|
||||
g_return_if_fail (gnc_basic_cell_has_name (cell, DTRANS_CELL));
|
||||
|
||||
value = gnc_basic_cell_get_value (cell);
|
||||
|
||||
/* commit any pending changes */
|
||||
gnc_date_cell_commit ((DateCell *) cell);
|
||||
|
||||
|
||||
DEBUG ("TRANSACTION: %s", value ? value : "(null)");
|
||||
|
||||
gnc_date_cell_get_date ((DateCell *) cell, &ts);
|
||||
|
||||
xaccTransSetDateEnteredTS (sd->trans, &ts);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_split_register_save_num_cell (BasicCell * cell,
|
||||
gpointer save_data,
|
||||
@ -711,6 +736,11 @@ gnc_split_register_model_add_save_handlers (TableModel *model)
|
||||
gnc_split_register_save_due_date_cell,
|
||||
DDUE_CELL);
|
||||
|
||||
|
||||
gnc_table_model_set_save_handler (model,
|
||||
gnc_split_register_save_trans_date_cell,
|
||||
DTRANS_CELL);
|
||||
|
||||
gnc_table_model_set_save_handler (model,
|
||||
gnc_split_register_save_type_cell,
|
||||
TYPE_CELL);
|
||||
@ -785,6 +815,12 @@ gnc_template_register_model_add_save_handlers (TableModel *model)
|
||||
gnc_template_register_save_unexpected_cell,
|
||||
DDUE_CELL);
|
||||
|
||||
|
||||
gnc_table_model_set_save_handler (model,
|
||||
gnc_template_register_save_unexpected_cell,
|
||||
DTRANS_CELL);
|
||||
|
||||
|
||||
gnc_table_model_set_save_handler (model,
|
||||
gnc_template_register_save_xfrm_cell,
|
||||
XFRM_CELL);
|
||||
|
@ -180,6 +180,13 @@ gnc_split_register_get_due_date_label (VirtualLocation virt_loc,
|
||||
return _("Due Date");
|
||||
}
|
||||
|
||||
static const char *
|
||||
gnc_split_register_get_trans_date_label (VirtualLocation virt_loc,
|
||||
gpointer user_data)
|
||||
{
|
||||
return _("Transaction");
|
||||
}
|
||||
|
||||
static const char *
|
||||
gnc_split_register_get_num_label (VirtualLocation virt_loc,
|
||||
gpointer user_data)
|
||||
@ -818,10 +825,51 @@ gnc_split_register_get_due_date_entry (VirtualLocation virt_loc,
|
||||
|
||||
xaccTransGetDateDueTS (trans, &ts);
|
||||
//PWARN ("returning valid due_date entry");
|
||||
|
||||
|
||||
return gnc_print_date (ts);
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
gnc_split_register_get_trans_date_entry (VirtualLocation virt_loc,
|
||||
gboolean translate,
|
||||
gboolean *conditionally_changed,
|
||||
gpointer user_data)
|
||||
{
|
||||
SplitRegister *reg = user_data;
|
||||
Transaction *trans;
|
||||
Split *split;
|
||||
Timespec ts;
|
||||
|
||||
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
|
||||
trans = xaccSplitGetParent (split);
|
||||
if (!trans) {
|
||||
//PWARN ("No transaction in transaction_date entry");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xaccTransGetDateEnteredTS (trans, &ts);
|
||||
//PWARN ("returning valid transaction_date entry");
|
||||
|
||||
return gnc_print_date (ts);
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
gnc_split_register_get_trans_date_help (VirtualLocation virt_loc,
|
||||
gpointer user_data)
|
||||
{
|
||||
SplitRegister *reg = user_data;
|
||||
const char *help;
|
||||
|
||||
help = gnc_table_get_entry (reg->table, virt_loc);
|
||||
if (!help || *help == '\0')
|
||||
help = _("Enter the transaction date");
|
||||
|
||||
return g_strdup (help);
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
gnc_split_register_get_date_entry (VirtualLocation virt_loc,
|
||||
gboolean translate,
|
||||
@ -2061,6 +2109,10 @@ gnc_split_register_model_new (void)
|
||||
gnc_split_register_get_date_entry,
|
||||
DATE_CELL);
|
||||
|
||||
gnc_table_model_set_entry_handler (model,
|
||||
gnc_split_register_get_trans_date_entry,
|
||||
DTRANS_CELL);
|
||||
|
||||
gnc_table_model_set_entry_handler (model,
|
||||
gnc_split_register_get_due_date_entry,
|
||||
DDUE_CELL);
|
||||
@ -2154,6 +2206,10 @@ gnc_split_register_model_new (void)
|
||||
gnc_split_register_get_date_label,
|
||||
DATE_CELL);
|
||||
|
||||
gnc_table_model_set_label_handler (model,
|
||||
gnc_split_register_get_trans_date_label,
|
||||
DTRANS_CELL);
|
||||
|
||||
gnc_table_model_set_label_handler (model,
|
||||
gnc_split_register_get_due_date_label,
|
||||
DDUE_CELL);
|
||||
@ -2250,6 +2306,10 @@ gnc_split_register_model_new (void)
|
||||
gnc_split_register_get_date_help,
|
||||
DATE_CELL);
|
||||
|
||||
gnc_table_model_set_help_handler (model,
|
||||
gnc_split_register_get_trans_date_help,
|
||||
DTRANS_CELL);
|
||||
|
||||
gnc_table_model_set_help_handler (model,
|
||||
gnc_split_register_get_date_help,
|
||||
DDUE_CELL);
|
||||
@ -2306,6 +2366,10 @@ gnc_split_register_model_new (void)
|
||||
gnc_table_model_set_io_flags_handler(
|
||||
model, gnc_split_register_get_standard_io_flags, DATE_CELL);
|
||||
|
||||
gnc_table_model_set_io_flags_handler(
|
||||
model, gnc_split_register_get_standard_io_flags, DTRANS_CELL);
|
||||
|
||||
|
||||
/* FIXME: We really only need a due date for 'invoices', not for
|
||||
* 'payments' or 'receipts'. This implies we really only need the
|
||||
* due-date for transactions that credit the ACCT_TYPE_RECEIVABLE or
|
||||
@ -2427,12 +2491,18 @@ gnc_template_register_model_new (void)
|
||||
gnc_table_model_set_entry_handler(
|
||||
model, gnc_split_register_get_inactive_date_entry, DATE_CELL );
|
||||
|
||||
gnc_table_model_set_entry_handler(
|
||||
model, gnc_split_register_get_inactive_date_entry, DTRANS_CELL );
|
||||
|
||||
gnc_table_model_set_entry_handler(
|
||||
model, gnc_split_register_get_inactive_date_entry, DDUE_CELL );
|
||||
|
||||
gnc_table_model_set_io_flags_handler(
|
||||
model, gnc_split_register_get_inactive_io_flags, DATE_CELL );
|
||||
|
||||
gnc_table_model_set_io_flags_handler(
|
||||
model, gnc_split_register_get_inactive_io_flags, DTRANS_CELL );
|
||||
|
||||
gnc_table_model_set_io_flags_handler(
|
||||
model, gnc_split_register_get_inactive_io_flags, DDUE_CELL );
|
||||
|
||||
|
@ -190,6 +190,7 @@ typedef enum
|
||||
#define CRED_CELL "credit"
|
||||
#define DATE_CELL "date"
|
||||
#define DDUE_CELL "date-due"
|
||||
#define DTRANS_CELL "transaction-date"
|
||||
#define DEBT_CELL "debit"
|
||||
#define DESC_CELL "description"
|
||||
#define FCRED_CELL "credit-formula"
|
||||
|
Loading…
Reference in New Issue
Block a user