|
3 | 3 | import java.time.LocalDateTime; |
4 | 4 |
|
5 | 5 | public final class Booking { |
6 | | - private final BookingId id; |
7 | | - private final LocalDateTime startDate; |
8 | | - private final LocalDateTime endDate; |
9 | | - private final Customer customer; |
10 | | - private final BookingType bookingType; |
11 | | - private final Discount discount; |
12 | | - private final Tax tax; |
| 6 | + private final BookingId id; |
| 7 | + private final DateRange dateRange; |
| 8 | + private final Customer customer; |
| 9 | + private final BookingType bookingType; |
| 10 | + private final Discount discount; |
| 11 | + private final Tax tax; |
13 | 12 |
|
14 | 13 | public Booking( |
15 | 14 | BookingId id, |
16 | | - DateRange bookingDateRange, |
| 15 | + DateRange dateRange, |
17 | 16 | Customer customer, |
18 | 17 | BookingType bookingType, |
19 | 18 | Discount discount, |
20 | 19 | Tax tax |
21 | 20 | ) { |
22 | 21 | this.id = id; |
23 | | - this.startDate = bookingDateRange.startDate(); |
24 | | - this.endDate = bookingDateRange.endDate(); |
| 22 | + this.dateRange = dateRange; |
25 | 23 | this.customer = customer; |
26 | 24 | this.bookingType = bookingType; |
27 | 25 | this.discount = discount; |
28 | 26 | this.tax = tax; |
29 | 27 | } |
30 | 28 |
|
31 | 29 | public BookingStatus statusFor(LocalDateTime date) { |
32 | | - if (date.isBefore(startDate)) { |
| 30 | + if (date.isBefore(dateRange.startDate())) { |
33 | 31 | return BookingStatus.NOT_STARTED; |
34 | 32 | } |
35 | 33 |
|
36 | | - if (date.isAfter(startDate) && date.isBefore(endDate)) { |
| 34 | + if (date.isAfter(dateRange.startDate()) && date.isBefore(dateRange.endDate())) { |
37 | 35 | return BookingStatus.ACTIVE; |
38 | 36 | } |
39 | 37 |
|
|
0 commit comments