GnuCash
Contact   Instructions
Bug 796813 - Date validation inconsistent
Summary: Date validation inconsistent
Status: RESOLVED FIXED
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Register (show other bugs)
Version: git-maint
Hardware: PC All
: Normal normal
Target Milestone: ---
Assignee: ui
QA Contact: ui
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-16 09:01 EDT by Geert Janssens
Modified: 2018-08-31 18:18 EDT (History)
3 users (show)

See Also:


Attachments

Description Geert Janssens 2018-08-16 09:01:25 EDT
Assume a book with configured read-only threshold (File->Properties->Accounts) and a date older than the threshold was just entered in a date cell.
Now depending on how you leave the cell the user may or may not get a warning that the date is being reset to the day right after the threshold.

When leaving with mouse click, tab, arrow up or arrow down the warning is displayed.
When leaving with enter or return the warning isn't displayed.

Note in all cases the date is reset. This bug is about the warning not being displayed consistently.
Comment 1 Bob 2018-08-18 05:35:28 EDT
Partly see comment on Bug 796812.

Looks like I had missed the use of the gdate form in the function gnc_split_register_save_date_cell in file split-register-model-save.c

To fix this one could change this function to use the other form like...

    SRSaveData *sd = save_data;
    const char *value;
    time64 cell_time;

    g_return_if_fail (gnc_basic_cell_has_name (cell, DATE_CELL));

    value = gnc_basic_cell_get_value (cell);

    DEBUG ("DATE: %s", value ? value : "(null)");

    gnc_date_cell_get_date ((DateCell *) cell, &cell_time);

    /* commit any pending changes */
    gnc_date_cell_commit ((DateCell *) cell);

    xaccTransSetDatePostedSecsNormalized (sd->trans, cell_time);

Note the commit after call to gnc_date_cell_get_date.

A similar change can also be made to the equivalent function in gncEntryLedgerModel as below...

        BasicCell *cell;
        time64 cell_time;

        cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_DATE_CELL);

        gnc_date_cell_get_date ((DateCell *) cell, &cell_time);

        /* commit any pending changes */
        gnc_date_cell_commit ((DateCell *) cell);

        gncEntrySetDate (entry, time64CanonicalDayTime(cell_time));

Note the use of time64CanonicalDayTime to change time to midday.
Comment 2 Geert Janssens 2018-08-18 09:19:46 EDT
Ok that looks reasonable. Add my suggestions in bug 796812 to eliminate the gdate form completely and add a boolean warn parameter to gnc_date_cell_get_date.
Comment 3 Bob 2018-08-22 16:08:39 EDT
Fix hopefully in PR400 along the above lines.
Comment 4 Geert Janssens 2018-08-31 18:18:08 EDT
Merged for 3.3.

Note You need to log in before you can comment on or make changes to this bug.