|
@@ -70,7 +70,8 @@ public class ParkingFeeCalculator {
|
|
|
.orElse(null);
|
|
|
|
|
|
|
|
|
- if (lastPaymentTime != null && Duration.between(lastPaymentTime, billingEndTime).toMinutes() <= feeRule.gracePeriodMinutes) {
|
|
|
+ if (lastPaymentTime != null && Duration.between(lastPaymentTime, billingEndTime).toMinutes() <= feeRule.gracePeriodMinutes
|
|
|
+ && billingDuration.toMinutes() > feeRule.gracePeriodMinutes) {
|
|
|
billingDuration = billingDuration.minusMinutes(feeRule.gracePeriodMinutes);
|
|
|
}
|
|
|
}
|
|
@@ -144,7 +145,7 @@ public class ParkingFeeCalculator {
|
|
|
public static void e2(){
|
|
|
|
|
|
FeeRule feeRule = new FeeRule();
|
|
|
- feeRule.freeDurationMinutes = 10;
|
|
|
+ feeRule.freeDurationMinutes = 0;
|
|
|
feeRule.firstCycleFee = 20.0;
|
|
|
feeRule.firstCycleDurationMinutes = 60;
|
|
|
feeRule.cycleDurationMinutes = 30;
|
|
@@ -154,13 +155,13 @@ public class ParkingFeeCalculator {
|
|
|
|
|
|
|
|
|
ParkingRecord parkingRecord = new ParkingRecord();
|
|
|
- parkingRecord.entryTime = LocalDateTime.of(2025, 3, 13, 15, 39);
|
|
|
- parkingRecord.exitTime = LocalDateTime.of(2025, 3, 13, 16, 45);
|
|
|
+ parkingRecord.entryTime = LocalDateTime.of(2025, 3, 14, 10, 0);
|
|
|
+ parkingRecord.exitTime = LocalDateTime.of(2025, 3, 14, 10, 20);
|
|
|
parkingRecord.monthlyCardExpiryTime = null;
|
|
|
parkingRecord.paidAmount = 0.01;
|
|
|
parkingRecord.paymentRecords=new ArrayList<>();
|
|
|
PaymentRecord paymentRecord = new PaymentRecord();
|
|
|
- paymentRecord.paymentTime = LocalDateTime.of(2025, 3, 13, 16, 29);
|
|
|
+ paymentRecord.paymentTime = LocalDateTime.of(2025, 3, 14, 10, 0);
|
|
|
parkingRecord.paymentRecords.add(paymentRecord);
|
|
|
|
|
|
double fee = calculateParkingFee(parkingRecord, feeRule, false);
|