diff --git a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts index 559a13b93..3c9a9e634 100644 --- a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts +++ b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts @@ -190,7 +190,7 @@ describe('Reports Page', () => { it('Should populate the users with the payload from the action executed', () => { const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject; - const usersArray = [] + const usersArray = []; const action = { type: UserActionTypes.LOAD_USERS_SUCCESS, payload: usersArray @@ -201,10 +201,10 @@ describe('Reports Page', () => { expect(component.users).toEqual(usersArray); }); - + it('The sum of the data dates is equal to {"hours": 3, "minutes":20,"seconds":0}', () => { - let {hours,minutes,seconds}: TotalHours = component.sumDates(timeEntryList); - expect({hours, minutes, seconds}).toEqual({hours:3,minutes:20,seconds:0}); + const {hours, minutes, seconds}: TotalHours = component.sumDates(timeEntryList); + expect({hours, minutes, seconds}).toEqual({hours: 3, minutes: 20, seconds: 0}); }); afterEach(() => { diff --git a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts index cfa6f98ee..9a7e693d2 100644 --- a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts +++ b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts @@ -127,22 +127,22 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn const durationColumnIndex = 3; return column === durationColumnIndex ? moment.duration(dataFormated).asHours().toFixed(2) : dataFormated; } - + sumDates(arrayData: Entry[]): TotalHours{ this.resultSum = new TotalHours(); - let arrayDurations= new Array(); - arrayData.forEach(entry =>{ - let start = moment(entry.end_date).diff(moment(entry.start_date)); - arrayDurations.push(moment.utc(start).format("HH:mm:ss")); + const arrayDurations = new Array(); + arrayData.forEach(entry => { + const start = moment(entry.end_date).diff(moment(entry.start_date)); + arrayDurations.push(moment.utc(start).format('HH:mm:ss')); }); - - let totalDurations = arrayDurations.slice(1) + + const totalDurations = arrayDurations.slice(1) .reduce((prev, cur) => { return prev.add(cur); }, moment.duration(arrayDurations[0])); - let daysInHours = totalDurations.days() * 24; - this.resultSum.hours=totalDurations.hours() + daysInHours; + const daysInHours = totalDurations.days() * 24; + this.resultSum.hours = totalDurations.hours() + daysInHours; this.resultSum.minutes = totalDurations.minutes(); this.resultSum.seconds = totalDurations.seconds(); return this.resultSum; diff --git a/src/app/modules/reports/models/total-hours-report.ts b/src/app/modules/reports/models/total-hours-report.ts index 0dc49b541..aeb19da9e 100644 --- a/src/app/modules/reports/models/total-hours-report.ts +++ b/src/app/modules/reports/models/total-hours-report.ts @@ -1,5 +1,5 @@ export class TotalHours { - + hours: number; minutes: number; seconds: number; @@ -9,4 +9,5 @@ export class TotalHours { this.minutes = 0; this.seconds = 0; } -} \ No newline at end of file +} + diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.ts b/src/app/modules/shared/components/details-fields/details-fields.component.ts index 1afceb347..32b8c408b 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.ts @@ -361,7 +361,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { const isStartDateInTheFuture = moment(startDateToSubmit).isAfter(moment()); const isEndDateInTheFuture = moment(endDateToSubmit).isAfter(moment()); - const timeEntryIsInTheFuture = isStartDateInTheFuture || isEndDateInTheFuture; + const timeEntryIsInTheFuture = isStartDateInTheFuture || (isEndDateInTheFuture && !this.goingToWorkOnThis); if (timeEntryIsInTheFuture) { this.toastrService.error('You cannot start a time-entry in the future'); diff --git a/src/app/modules/shared/formatters/parse-date-time-offset/parse-date-time-offset.ts b/src/app/modules/shared/formatters/parse-date-time-offset/parse-date-time-offset.ts index 7dd05aba1..8bbefd7f7 100644 --- a/src/app/modules/shared/formatters/parse-date-time-offset/parse-date-time-offset.ts +++ b/src/app/modules/shared/formatters/parse-date-time-offset/parse-date-time-offset.ts @@ -2,8 +2,10 @@ import * as moment from 'moment'; export class ParseDateTimeOffset { - parseDateTimeOffset(date:string, offset): string{ - if(date == null || date == undefined || date == '') return 'In progress'; - return moment.utc(date).utcOffset(-1*offset).format("HH:mm"); + parseDateTimeOffset(date: string, offset): string { + if (date === null || date === undefined || date === '') { + return 'In progress'; + } + return moment.utc(date).utcOffset(-1 * offset).format('HH:mm'); } }