Add auto-read-only feature for old transactions after N days, denoted by the new red line in the register.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22109 57a11ea4-9604-0410-9ed3-97b8803252fd
pull/1/head
Christian Stimming 14 years ago
parent 298eab78f5
commit 8cc8ffe374

@ -1770,6 +1770,41 @@ gnc_split_register_get_rbaln_entry (VirtualLocation virt_loc,
return xaccPrintAmount (balance, gnc_account_print_info (account, FALSE));
}
static gboolean posted_date_means_readonly(const Transaction *trans)
{
GDate *threshold_date;
GDate trans_date;
const QofBook *book = gnc_get_current_book ();
gboolean result;
g_assert(trans);
if (!qof_book_uses_autofreeze(book))
{
//g_warning("we don't use auto-read-only, num_days=%d", qof_book_get_num_days_autofreeze(book));
return FALSE;
}
threshold_date = qof_book_get_autofreeze_gdate(book);
trans_date = xaccTransGetDatePostedGDate(trans);
// g_warning("there is auto-read-only with days=%d, trans_date_day=%d, threshold_date_day=%d",
// qof_book_get_num_days_autofreeze(book),
// g_date_get_day(&trans_date),
// g_date_get_day(threshold_date));
if (g_date_compare(&trans_date, threshold_date) <= 0)
{
//g_warning("we must auto-read-only");
result = TRUE;
}
else
{
result = FALSE;
}
g_date_free(threshold_date);
return result;
}
static gboolean
gnc_split_register_cursor_is_readonly (VirtualLocation virt_loc,
gpointer user_data)
@ -1785,7 +1820,8 @@ gnc_split_register_cursor_is_readonly (VirtualLocation virt_loc,
txn = xaccSplitGetParent (split);
if (!txn) return FALSE;
if (xaccTransGetReadOnly(txn))
if (xaccTransGetReadOnly(txn)
|| posted_date_means_readonly(txn))
return(TRUE);
type = xaccTransGetTxnType (txn);

Loading…
Cancel
Save