mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Rename internal function names for read-only option of r22107 also to "auto-read-only".
(Initially I thought there were a relation to the "freeze" state of a transaction, but this turned out to be not the case.) git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22118 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
ed581152b9
commit
176fba9b9f
@ -322,9 +322,9 @@
|
|||||||
|
|
||||||
(define gnc:*option-section-accounts* OPTION-SECTION-ACCOUNTS)
|
(define gnc:*option-section-accounts* OPTION-SECTION-ACCOUNTS)
|
||||||
(define gnc:*option-name-trading-accounts* OPTION-NAME-TRADING-ACCOUNTS)
|
(define gnc:*option-name-trading-accounts* OPTION-NAME-TRADING-ACCOUNTS)
|
||||||
(define gnc:*option-name-auto-freeze-days* OPTION-NAME-AUTO-FREEZE-DAYS)
|
(define gnc:*option-name-auto-readonly-days* OPTION-NAME-AUTO-READONLY-DAYS)
|
||||||
|
|
||||||
(export gnc:*option-section-accounts* gnc:*option-name-trading-accounts* gnc:*option-name-auto-freeze-days*)
|
(export gnc:*option-section-accounts* gnc:*option-name-trading-accounts* gnc:*option-name-auto-readonly-days*)
|
||||||
|
|
||||||
(define gnc:*option-section-budgeting* OPTION-SECTION-BUDGETING)
|
(define gnc:*option-section-budgeting* OPTION-SECTION-BUDGETING)
|
||||||
(define gnc:*option-name-default-budget* OPTION-NAME-DEFAULT-BUDGET)
|
(define gnc:*option-name-default-budget* OPTION-NAME-DEFAULT-BUDGET)
|
||||||
|
@ -133,7 +133,7 @@
|
|||||||
|
|
||||||
(reg-option
|
(reg-option
|
||||||
(gnc:make-number-range-option
|
(gnc:make-number-range-option
|
||||||
gnc:*option-section-accounts* gnc:*option-name-auto-freeze-days*
|
gnc:*option-section-accounts* gnc:*option-name-auto-readonly-days*
|
||||||
"b" (N_ "Choose the number of days after which transactions will be read-only and cannot be edited anymore. This threshold is marked by a red line in the account register windows. If zero, all transactions can be edited and none are read-only.")
|
"b" (N_ "Choose the number of days after which transactions will be read-only and cannot be edited anymore. This threshold is marked by a red line in the account register windows. If zero, all transactions can be edited and none are read-only.")
|
||||||
0 ;; default
|
0 ;; default
|
||||||
0 ;; lower bound
|
0 ;; lower bound
|
||||||
|
@ -1965,12 +1965,12 @@ gboolean xaccTransIsReadonlyByPostedDate(const Transaction *trans)
|
|||||||
gboolean result;
|
gboolean result;
|
||||||
g_assert(trans);
|
g_assert(trans);
|
||||||
|
|
||||||
if (!qof_book_uses_autofreeze(book))
|
if (!qof_book_uses_autoreadonly(book))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
threshold_date = qof_book_get_autofreeze_gdate(book);
|
threshold_date = qof_book_get_autoreadonly_gdate(book);
|
||||||
trans_date = xaccTransGetDatePostedGDate(trans);
|
trans_date = xaccTransGetDatePostedGDate(trans);
|
||||||
|
|
||||||
// g_warning("there is auto-read-only with days=%d, trans_date_day=%d, threshold_date_day=%d",
|
// g_warning("there is auto-read-only with days=%d, trans_date_day=%d, threshold_date_day=%d",
|
||||||
|
@ -295,7 +295,7 @@ KvpValue * kvp_frame_get_slot_path_gslist (KvpFrame *frame, GSList *key_path);
|
|||||||
|
|
||||||
SET_ENUM("OPTION-SECTION-ACCOUNTS");
|
SET_ENUM("OPTION-SECTION-ACCOUNTS");
|
||||||
SET_ENUM("OPTION-NAME-TRADING-ACCOUNTS");
|
SET_ENUM("OPTION-NAME-TRADING-ACCOUNTS");
|
||||||
SET_ENUM("OPTION-NAME-AUTO-FREEZE-DAYS");
|
SET_ENUM("OPTION-NAME-AUTO-READONLY-DAYS");
|
||||||
|
|
||||||
SET_ENUM("OPTION-SECTION-BUDGETING");
|
SET_ENUM("OPTION-SECTION-BUDGETING");
|
||||||
SET_ENUM("OPTION-NAME-DEFAULT-BUDGET");
|
SET_ENUM("OPTION-NAME-DEFAULT-BUDGET");
|
||||||
|
@ -641,13 +641,13 @@ qof_book_use_trading_accounts (const QofBook *book)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean qof_book_uses_autofreeze (const QofBook *book)
|
gboolean qof_book_uses_autoreadonly (const QofBook *book)
|
||||||
{
|
{
|
||||||
g_assert(book);
|
g_assert(book);
|
||||||
return (qof_book_get_num_days_autofreeze(book) != 0);
|
return (qof_book_get_num_days_autoreadonly(book) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gint qof_book_get_num_days_autofreeze (const QofBook *book)
|
gint qof_book_get_num_days_autoreadonly (const QofBook *book)
|
||||||
{
|
{
|
||||||
kvp_value *kvp_val;
|
kvp_value *kvp_val;
|
||||||
double tmp;
|
double tmp;
|
||||||
@ -655,12 +655,12 @@ gint qof_book_get_num_days_autofreeze (const QofBook *book)
|
|||||||
kvp_val = kvp_frame_get_slot_path (qof_book_get_slots (book),
|
kvp_val = kvp_frame_get_slot_path (qof_book_get_slots (book),
|
||||||
KVP_OPTION_PATH,
|
KVP_OPTION_PATH,
|
||||||
OPTION_SECTION_ACCOUNTS,
|
OPTION_SECTION_ACCOUNTS,
|
||||||
OPTION_NAME_AUTO_FREEZE_DAYS,
|
OPTION_NAME_AUTO_READONLY_DAYS,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (kvp_val == NULL)
|
if (kvp_val == NULL)
|
||||||
{
|
{
|
||||||
//g_warning("kvp_val for slot '%s' is NULL", OPTION_NAME_AUTO_FREEZE_DAYS);
|
//g_warning("kvp_val for slot '%s' is NULL", OPTION_NAME_AUTO_READONLY_DAYS);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,11 +668,18 @@ gint qof_book_get_num_days_autofreeze (const QofBook *book)
|
|||||||
return (gint) tmp;
|
return (gint) tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDate* qof_book_get_autofreeze_gdate (const QofBook *book)
|
GDate* qof_book_get_autoreadonly_gdate (const QofBook *book)
|
||||||
{
|
{
|
||||||
GDate* result = gnc_g_date_new_today();
|
gint num_days;
|
||||||
|
GDate* result = NULL;
|
||||||
|
|
||||||
g_assert(book);
|
g_assert(book);
|
||||||
g_date_subtract_days(result, qof_book_get_num_days_autofreeze(book));
|
num_days = qof_book_get_num_days_autoreadonly(book);
|
||||||
|
if (num_days > 0)
|
||||||
|
{
|
||||||
|
result = gnc_g_date_new_today();
|
||||||
|
g_date_subtract_days(result, num_days);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,22 +248,24 @@ void qof_book_mark_readonly(QofBook *book);
|
|||||||
/** Returns flag indicating whether this book uses trading accounts */
|
/** Returns flag indicating whether this book uses trading accounts */
|
||||||
gboolean qof_book_use_trading_accounts (const QofBook *book);
|
gboolean qof_book_use_trading_accounts (const QofBook *book);
|
||||||
|
|
||||||
/** Returns TRUE if the auto-freeze feature should be used, otherwise
|
/** Returns TRUE if the auto-read-only feature should be used, otherwise
|
||||||
* FALSE. This is just a wrapper on get_num_days_autofreeze == 0. */
|
* FALSE. This is just a wrapper on qof_book_get_num_days_autoreadonly() == 0. */
|
||||||
gboolean qof_book_uses_autofreeze (const QofBook *book);
|
gboolean qof_book_uses_autoreadonly (const QofBook *book);
|
||||||
|
|
||||||
/** Returns the number of days for auto-freeze transactions. If zero,
|
/** Returns the number of days for auto-read-only transactions. If zero,
|
||||||
* the auto-freeze feature should be disabled (and uses_autofreeze
|
* the auto-read-only feature should be disabled (and qof_book_uses_autoreadonly()
|
||||||
* returns FALSE). */
|
* returns FALSE). */
|
||||||
gint qof_book_get_num_days_autofreeze (const QofBook *book);
|
gint qof_book_get_num_days_autoreadonly (const QofBook *book);
|
||||||
|
|
||||||
/** Returns the GDate that is the threshold for autofreeze. Any txn
|
/** Returns the GDate that is the threshold for auto-read-only. Any txn
|
||||||
* with posted-date lesser or equal to this date should be set to
|
* with posted-date lesser than this date should be considered read-only.
|
||||||
* freeze.
|
*
|
||||||
|
* If the auto-read-only feature is not used (qof_book_uses_autoreadonly()
|
||||||
|
* returns FALSE), NULL is returned here.
|
||||||
*
|
*
|
||||||
* The returned object was allocated newly; the caller must
|
* The returned object was allocated newly; the caller must
|
||||||
* g_date_free() the object afterwards. */
|
* g_date_free() the object afterwards. */
|
||||||
GDate* qof_book_get_autofreeze_gdate (const QofBook *book);
|
GDate* qof_book_get_autoreadonly_gdate (const QofBook *book);
|
||||||
|
|
||||||
/** Is the book shutting down? */
|
/** Is the book shutting down? */
|
||||||
gboolean qof_book_shutting_down (const QofBook *book);
|
gboolean qof_book_shutting_down (const QofBook *book);
|
||||||
|
@ -64,7 +64,7 @@
|
|||||||
|
|
||||||
#define OPTION_SECTION_ACCOUNTS N_("Accounts")
|
#define OPTION_SECTION_ACCOUNTS N_("Accounts")
|
||||||
#define OPTION_NAME_TRADING_ACCOUNTS N_("Use Trading Accounts")
|
#define OPTION_NAME_TRADING_ACCOUNTS N_("Use Trading Accounts")
|
||||||
#define OPTION_NAME_AUTO_FREEZE_DAYS N_("Day Threshold for Read-Only Transactions (red line)")
|
#define OPTION_NAME_AUTO_READONLY_DAYS N_("Day Threshold for Read-Only Transactions (red line)")
|
||||||
|
|
||||||
#define OPTION_SECTION_BUDGETING N_("Budgeting")
|
#define OPTION_SECTION_BUDGETING N_("Budgeting")
|
||||||
#define OPTION_NAME_DEFAULT_BUDGET N_("Default Budget")
|
#define OPTION_NAME_DEFAULT_BUDGET N_("Default Budget")
|
||||||
@ -75,7 +75,7 @@
|
|||||||
* KVP-OPTION-PATH
|
* KVP-OPTION-PATH
|
||||||
* OPTION-SECTION-ACCOUNTS
|
* OPTION-SECTION-ACCOUNTS
|
||||||
* OPTION-NAME-TRADING-ACCOUNTS
|
* OPTION-NAME-TRADING-ACCOUNTS
|
||||||
* OPTION-NAME-AUTO-FREEZE-DAYS
|
* OPTION-NAME-AUTO-READONLY-DAYS
|
||||||
* OPTION-SECTION-BUDGETING
|
* OPTION-SECTION-BUDGETING
|
||||||
* OPTION-NAME-DEFAULT-BUDGET
|
* OPTION-NAME-DEFAULT-BUDGET
|
||||||
*/
|
*/
|
||||||
|
@ -393,32 +393,32 @@ test_book_get_num_days_autofreeze( Fixture *fixture, gconstpointer pData )
|
|||||||
const char *slot_path;
|
const char *slot_path;
|
||||||
|
|
||||||
/* create correct slot path */
|
/* create correct slot path */
|
||||||
slot_path = (const char *) g_strconcat( KVP_OPTION_PATH, "/", OPTION_SECTION_ACCOUNTS, "/", OPTION_NAME_AUTO_FREEZE_DAYS, NULL );
|
slot_path = (const char *) g_strconcat( KVP_OPTION_PATH, "/", OPTION_SECTION_ACCOUNTS, "/", OPTION_NAME_AUTO_READONLY_DAYS, NULL );
|
||||||
g_assert( slot_path != NULL );
|
g_assert( slot_path != NULL );
|
||||||
|
|
||||||
g_test_message( "Testing default: No auto-freeze days are set" );
|
g_test_message( "Testing default: No auto-freeze days are set" );
|
||||||
g_assert( qof_book_uses_autofreeze( fixture-> book ) == FALSE );
|
g_assert( qof_book_uses_autoreadonly( fixture-> book ) == FALSE );
|
||||||
g_assert( qof_book_get_num_days_autofreeze( fixture-> book ) == 0 );
|
g_assert( qof_book_get_num_days_autoreadonly( fixture-> book ) == 0 );
|
||||||
|
|
||||||
g_test_message( "Testing with incorrect slot path and some correct value - 17" );
|
g_test_message( "Testing with incorrect slot path and some correct value - 17" );
|
||||||
kvp_frame_set_double(qof_book_get_slots(fixture->book), OPTION_NAME_AUTO_FREEZE_DAYS, 17);
|
kvp_frame_set_double(qof_book_get_slots(fixture->book), OPTION_NAME_AUTO_READONLY_DAYS, 17);
|
||||||
g_assert( qof_book_uses_autofreeze( fixture-> book ) == FALSE );
|
g_assert( qof_book_uses_autoreadonly( fixture-> book ) == FALSE );
|
||||||
g_assert( qof_book_get_num_days_autofreeze( fixture-> book ) == 0 );
|
g_assert( qof_book_get_num_days_autoreadonly( fixture-> book ) == 0 );
|
||||||
|
|
||||||
g_test_message( "Testing when setting this correctly with some correct value - 17" );
|
g_test_message( "Testing when setting this correctly with some correct value - 17" );
|
||||||
kvp_frame_set_double(qof_book_get_slots(fixture->book), slot_path, 17);
|
kvp_frame_set_double(qof_book_get_slots(fixture->book), slot_path, 17);
|
||||||
g_assert( qof_book_uses_autofreeze( fixture-> book ) == TRUE );
|
g_assert( qof_book_uses_autoreadonly( fixture-> book ) == TRUE );
|
||||||
g_assert( qof_book_get_num_days_autofreeze( fixture-> book ) == 17 );
|
g_assert( qof_book_get_num_days_autoreadonly( fixture-> book ) == 17 );
|
||||||
|
|
||||||
g_test_message( "Testing when setting this correctly to zero again" );
|
g_test_message( "Testing when setting this correctly to zero again" );
|
||||||
kvp_frame_set_double(qof_book_get_slots(fixture->book), slot_path, 0);
|
kvp_frame_set_double(qof_book_get_slots(fixture->book), slot_path, 0);
|
||||||
g_assert( qof_book_uses_autofreeze( fixture-> book ) == FALSE );
|
g_assert( qof_book_uses_autoreadonly( fixture-> book ) == FALSE );
|
||||||
g_assert( qof_book_get_num_days_autofreeze( fixture-> book ) == 0 );
|
g_assert( qof_book_get_num_days_autoreadonly( fixture-> book ) == 0 );
|
||||||
|
|
||||||
g_test_message( "Testing when setting this correctly with some correct value - 32" );
|
g_test_message( "Testing when setting this correctly with some correct value - 32" );
|
||||||
kvp_frame_set_double(qof_book_get_slots(fixture->book), slot_path, 32);
|
kvp_frame_set_double(qof_book_get_slots(fixture->book), slot_path, 32);
|
||||||
g_assert( qof_book_uses_autofreeze( fixture-> book ) == TRUE );
|
g_assert( qof_book_uses_autoreadonly( fixture-> book ) == TRUE );
|
||||||
g_assert( qof_book_get_num_days_autofreeze( fixture-> book ) == 32 );
|
g_assert( qof_book_get_num_days_autoreadonly( fixture-> book ) == 32 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
|
|||||||
gboolean multi_line;
|
gboolean multi_line;
|
||||||
gboolean dynamic;
|
gboolean dynamic;
|
||||||
gboolean we_own_slist = FALSE;
|
gboolean we_own_slist = FALSE;
|
||||||
gboolean use_autofreeze = qof_book_uses_autofreeze(gnc_get_current_book());
|
gboolean use_autoreadonly = qof_book_uses_autoreadonly(gnc_get_current_book());
|
||||||
|
|
||||||
VirtualCellLocation vcell_loc;
|
VirtualCellLocation vcell_loc;
|
||||||
VirtualLocation save_loc;
|
VirtualLocation save_loc;
|
||||||
@ -277,7 +277,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
|
|||||||
int new_trans_split_row = -1;
|
int new_trans_split_row = -1;
|
||||||
int new_trans_row = -1;
|
int new_trans_row = -1;
|
||||||
int new_split_row = -1;
|
int new_split_row = -1;
|
||||||
time_t present, autofreeze_time;
|
time_t present, autoreadonly_time;
|
||||||
|
|
||||||
g_return_if_fail(reg);
|
g_return_if_fail(reg);
|
||||||
table = reg->table;
|
table = reg->table;
|
||||||
@ -435,8 +435,8 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
|
|||||||
/* get the current time and reset the dividing row */
|
/* get the current time and reset the dividing row */
|
||||||
present = gnc_timet_get_today_end ();
|
present = gnc_timet_get_today_end ();
|
||||||
{
|
{
|
||||||
GDate *d = qof_book_get_autofreeze_gdate(gnc_get_current_book());
|
GDate *d = qof_book_get_autoreadonly_gdate(gnc_get_current_book());
|
||||||
autofreeze_time = timespecToTime_t(gdate_to_timespec(*d));
|
autoreadonly_time = timespecToTime_t(gdate_to_timespec(*d));
|
||||||
g_date_free(d);
|
g_date_free(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,10 +538,10 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (info->show_present_divider &&
|
if (info->show_present_divider &&
|
||||||
use_autofreeze &&
|
use_autoreadonly &&
|
||||||
!found_divider_upper)
|
!found_divider_upper)
|
||||||
{
|
{
|
||||||
if (xaccTransGetDate (trans) >= autofreeze_time)
|
if (xaccTransGetDate (trans) >= autoreadonly_time)
|
||||||
{
|
{
|
||||||
table->model->dividing_row_upper = vcell_loc.virt_row;
|
table->model->dividing_row_upper = vcell_loc.virt_row;
|
||||||
found_divider_upper = TRUE;
|
found_divider_upper = TRUE;
|
||||||
@ -591,7 +591,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
|
|||||||
|
|
||||||
/* No upper divider yet? Store it now */
|
/* No upper divider yet? Store it now */
|
||||||
if (info->show_present_divider &&
|
if (info->show_present_divider &&
|
||||||
use_autofreeze &&
|
use_autoreadonly &&
|
||||||
!found_divider_upper && need_divider_upper)
|
!found_divider_upper && need_divider_upper)
|
||||||
{
|
{
|
||||||
table->model->dividing_row_upper = vcell_loc.virt_row;
|
table->model->dividing_row_upper = vcell_loc.virt_row;
|
||||||
|
Loading…
Reference in New Issue
Block a user