fixed bug where wrong month was selected in estimate_by_month

This commit is contained in:
Patrick 2025-10-16 01:43:14 +02:00
parent 2b15580e3c
commit b7563a2274
2 changed files with 3 additions and 3 deletions

View File

@ -361,9 +361,9 @@ export class User {
get_estimate_by_month(year: number, month: number): number {
const query = this._database.query(ESTIMATES_DATABASE_GET_QUART);
const res = query.get({ year: year, quarter: Math.floor(month / 4 + 1) }) as EstimatesEntry;
const res = query.get({ year: year, quarter: Math.floor((month-1) / 3) }) as EstimatesEntry;
return res?.[`estimate_${month % 3}`] ?? NaN;
return res?.[`estimate_${(month - 1) % 3}`] ?? NaN;
}
insert_estimate(year: number, quarter: number, estimate_0: number, estimate_1: number, estimate_2: number) {

View File

@ -235,7 +235,7 @@ async function _genLatexRec(user: User, file_pref: string, year: number, month:
}
const records = user.get_entries_by_month(year, month);
const estimate = user.get_estimate_by_month(year, month-1);
const estimate = user.get_estimate_by_month(year, month);
const hr_sum = (() => { let s = 0; records.forEach((r) => { s += calculateDuration(r.start, r.end) }); return s; })()
if (estimate == null || isNaN(estimate)) {