Skip to content

Commit 2eb4062

Browse files
Guido Quezadajosepato87
authored andcommitted
TT-108 fix: edit the first running entry of the month after one hour
1 parent 2f675b2 commit 2eb4062

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/app/modules/shared/components/month-picker/month-picker.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('MonthPickerComponent', () => {
6262
it('selectMonth should call selectDate', () => {
6363
spyOn(component, 'selectDate');
6464
component.selectMonth(10);
65-
expect(component.selectDate).toHaveBeenCalledWith(10, 2020);
65+
expect(component.selectDate).toHaveBeenCalledWith(10, 2021);
6666
});
6767

6868
});

src/app/modules/time-clock/components/entry-fields/entry-fields.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class EntryFieldsComponent implements OnInit {
138138
return;
139139
}
140140

141-
const lastEntryStartDate = get(this.lastEntry, 'start_date', moment().subtract(1, 'hours'));
141+
const lastEntryStartDate = get(this.lastEntry, 'start_date', moment(newHourEntered).subtract(1, 'minutes'));
142142
const isEntryDateInLastStartDate = moment(newHourEntered).isSameOrBefore(lastEntryStartDate);
143143
if (isEntryDateInLastStartDate) {
144144
this.toastrService.error('There is another time entry registered in this time range');

src/app/modules/time-clock/store/entry.effects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export class EntryEffects {
232232
}).pipe(
233233
map((entries) => {
234234
const lastEntry = entries[1];
235-
const isStartTimeInLastEntry = moment(entry.start_date).isBefore(lastEntry.end_date);
235+
const isStartTimeInLastEntry = lastEntry && moment(entry.start_date).isBefore(lastEntry.end_date);
236236
if (isStartTimeInLastEntry) {
237237
return new actions.UpdateEntry({ id: lastEntry.id, end_date: entry.start_date });
238238
} else {

0 commit comments

Comments
 (0)