Bug 798501 - Balance wrong date end of account period

With the accounting period preference settings set to 'Start/End of
previous quarter' and balance sheet report using 'End of accounting
period' the date is wrong, currently is 30/03/2022 when it should be
31/03/2022.

Simplify gnc_gdate_set_quarter_end to get correct last day and
subtract the 3 months befor calling said function.
pull/1326/head
Robert Fewell 4 years ago
parent 2b198dbce4
commit c000a890ad

@ -1532,17 +1532,13 @@ gnc_gdate_set_quarter_start (GDate *date)
void
gnc_gdate_set_quarter_end (GDate *date)
{
gint months;
const GDateMonth months[] = {G_DATE_MARCH, G_DATE_JUNE,
G_DATE_SEPTEMBER, G_DATE_DECEMBER};
const GDateDay days[] = {31, 30, 30, 31};
int quarter = (g_date_get_month (date) - 1) / 3;
/* Set the date to the first day of the specified month. */
g_date_set_day(date, 1);
/* Add 1-3 months to get the first day of the next quarter.*/
months = (g_date_get_month(date) - G_DATE_JANUARY) % 3;
g_date_add_months(date, 3 - months);
/* Now back up one day */
g_date_subtract_days(date, 1);
g_date_set_month (date, months[quarter]);
g_date_set_day (date, days[quarter]);
}
void
@ -1555,8 +1551,8 @@ gnc_gdate_set_prev_quarter_start (GDate *date)
void
gnc_gdate_set_prev_quarter_end (GDate *date)
{
gnc_gdate_set_quarter_end(date);
g_date_subtract_months(date, 3);
gnc_gdate_set_quarter_end(date);
}
/* ================================================= */

Loading…
Cancel
Save