Skip to content

Commit

Permalink
Fix rounded value of recovered overtime
Browse files Browse the repository at this point in the history
  • Loading branch information
yannlugrin committed Jul 5, 2023
1 parent 38b43ba commit 028213e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
9 changes: 2 additions & 7 deletions pages/api/summaries/me.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { sheets_v4 } from 'googleapis';
import type { NextApiRequest, NextApiResponse } from 'next';
import { User } from 'next-auth';

import {
HOURS_PER_DAY,
RANGE_END,
RANGE_START,
SHEET_NAME,
} from '@/configs/dashboard';
import { RANGE_END, RANGE_START, SHEET_NAME } from '@/configs/dashboard';
import ApiError from '@/interfaces/apiError';
import Summary from '@/interfaces/summary';
import authorize from '@/middlewares/authorize';
Expand Down Expand Up @@ -43,7 +38,7 @@ const handler = async (
formationExpenses: row[4],
justifiedAbsence: Number(row[5]),
overtimeRecovery: Number(row[6]),
overtimePaid: Number(row[7]) * HOURS_PER_DAY,
overtimePaid: Number(row[7]),
workingPercent: Number(row[8]),
overtimeRemaining: Number(row[9]),
vacationPreviousYearRemaining: Number(row[11]),
Expand Down
9 changes: 3 additions & 6 deletions pages/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const Dashboard = () => {
const { data: summary, isLoading } = useSummary();

const remainingOverTimeDays = summary
? summary.overtimeRemaining / HOURS_PER_DAY
? Number((summary.overtimeRemaining / HOURS_PER_DAY).toFixed(2))
: 0;

const totalOvertimeRecoveryDays = summary
? (summary.overtimeRemaining + summary.overtimePaid) / HOURS_PER_DAY
? Number((summary.overtimeRecovery + summary.overtimePaid).toFixed(2))
: 0;

const currentYear = new Date().getFullYear();
Expand Down Expand Up @@ -50,10 +50,7 @@ const Dashboard = () => {
'jour'
)} de vacances`}</p>
<p>
{`${pluralize(
Number(remainingOverTimeDays.toFixed(2)),
'jour'
)}
{`${pluralize(remainingOverTimeDays, 'jour')}
(${summary.overtimeRemaining}h) supplémentaires`}
</p>
</div>
Expand Down

0 comments on commit 028213e

Please sign in to comment.