mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 02:56:10 +00:00
fix(trips): keep a visit's own stay when a trip is copied
insertAssignmentCopy took stay_minutes but never wrote it, so a copied trip fell back to the place's duration for every visit.
This commit is contained in:
@@ -568,6 +568,7 @@ export class DayAssignmentsRepository extends TrekRepository<DayAssignments> {
|
||||
assignment_end_time: input.assignment_end_time,
|
||||
end_day: input.end_day,
|
||||
tour_stage_key: input.tour_stage_key ?? null,
|
||||
stay_minutes: input.stay_minutes ?? null,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1059,6 +1059,8 @@ describe('Copy trip with data', () => {
|
||||
place: place.id,
|
||||
order_index: 0,
|
||||
notes: 'Visit in morning',
|
||||
// #3092: the visit's own stay, apart from the place's duration
|
||||
stay_minutes: 90,
|
||||
});
|
||||
|
||||
// Accommodation spanning days 0→1
|
||||
@@ -1103,6 +1105,7 @@ describe('Copy trip with data', () => {
|
||||
// Assignment copied
|
||||
const newAssignments = await findRows(orm, DayAssignments, { day: { trip: newId } });
|
||||
expect(newAssignments).toHaveLength(1);
|
||||
expect(newAssignments[0].stay_minutes).toBe(90);
|
||||
|
||||
// Accommodation copied
|
||||
const newAccom = await findRows(orm, DayAccommodations, { trip: newId });
|
||||
|
||||
@@ -1046,6 +1046,31 @@ describe('DayAssignmentsRepository.insertAssignmentCopy (TP49)', () => {
|
||||
accommodation_id: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("ASSIGNREPO-048: carries the visit's own stay_minutes, null when none is given (#3092)", async () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const day = createDay(testDb, trip.id);
|
||||
const place = createPlace(testDb, trip.id);
|
||||
const copy = {
|
||||
day_id: day.id,
|
||||
place_id: place.id,
|
||||
order_index: 0,
|
||||
notes: null,
|
||||
reservation_status: null,
|
||||
reservation_notes: null,
|
||||
reservation_datetime: null,
|
||||
assignment_time: null,
|
||||
assignment_end_time: null,
|
||||
end_day: 0,
|
||||
};
|
||||
|
||||
const withStay = await assignments.insertAssignmentCopy({ ...copy, stay_minutes: 90 });
|
||||
const without = await assignments.insertAssignmentCopy(copy);
|
||||
|
||||
expect(await assignmentCols(withStay, 'stay_minutes')).toEqual({ stay_minutes: 90 });
|
||||
expect(await assignmentCols(without, 'stay_minutes')).toEqual({ stay_minutes: null });
|
||||
});
|
||||
});
|
||||
|
||||
describe('DayAssignmentsRepository.setAccommodation (TP57)', () => {
|
||||
|
||||
Reference in New Issue
Block a user