check for time-step-config == STATIC
This commit is contained in:
parent
f8805e9e78
commit
a3983ed427
@ -915,6 +915,7 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
bool prepaid = true;
|
||||
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||
int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||
|
||||
if (prepaid_option_id == 2) {
|
||||
prepaid = false;
|
||||
}
|
||||
@ -930,20 +931,23 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
|
||||
if (start_parking_time.isValid()) {
|
||||
|
||||
// handle prepaid option
|
||||
QDateTime effectiveStartTime(start_parking_time);
|
||||
int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||
std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
|
||||
if (prepaidOption.has_value()) {
|
||||
ATBPrepaid const &p = prepaidOption.value();
|
||||
if (p.never) {
|
||||
qCritical() << __func__ << __LINE__ << "prepaid: no";
|
||||
} else {
|
||||
if (start_parking_time.time() < p.static_end) { // static_end: e.g. 08:00:00
|
||||
effectiveStartTime.setTime(p.static_end);
|
||||
} else
|
||||
if (start_parking_time.time() > p.static_start) { // static_start: e.g. 22:00:00
|
||||
effectiveStartTime.setTime(p.static_start);
|
||||
int const pop_time_step_config = tariff->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
|
||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::STATIC) {
|
||||
// handle prepaid option
|
||||
QDateTime effectiveStartTime(start_parking_time);
|
||||
int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||
std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
|
||||
if (prepaidOption.has_value()) {
|
||||
ATBPrepaid const &p = prepaidOption.value();
|
||||
if (p.never) {
|
||||
qCritical() << __func__ << __LINE__ << "prepaid: no";
|
||||
} else {
|
||||
if (start_parking_time.time() < p.static_end) { // static_end: e.g. 08:00:00
|
||||
effectiveStartTime.setTime(p.static_end);
|
||||
} else
|
||||
if (start_parking_time.time() > p.static_start) { // static_start: e.g. 22:00:00
|
||||
effectiveStartTime.setTime(p.static_start);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1020,53 +1024,55 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
return calcState.set(CalcState::State::WRONG_ISO_TIME_FORMAT);
|
||||
}
|
||||
|
||||
// handle carry over for ticket-end-time
|
||||
qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
|
||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::STATIC) {
|
||||
// handle carry over for ticket-end-time
|
||||
qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
|
||||
|
||||
int weekDay = start_parking_time.date().dayOfWeek();
|
||||
int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
||||
qCritical() << __func__ << __LINE__ << "configured carry-over-id" << pop_carry_over_option_id;
|
||||
int weekDay = start_parking_time.date().dayOfWeek();
|
||||
int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
||||
qCritical() << __func__ << __LINE__ << "configured carry-over-id" << pop_carry_over_option_id;
|
||||
|
||||
std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
|
||||
if (yperiod.has_value()) {
|
||||
ATBPeriodYear const &period = yperiod.value();
|
||||
pop_carry_over_option_id = period.pye_id;
|
||||
qCritical() << __func__ << __LINE__ << "re-computed carry-over-id" << pop_carry_over_option_id;
|
||||
}
|
||||
std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
|
||||
if (yperiod.has_value()) {
|
||||
ATBPeriodYear const &period = yperiod.value();
|
||||
pop_carry_over_option_id = period.pye_id;
|
||||
qCritical() << __func__ << __LINE__ << "re-computed carry-over-id" << pop_carry_over_option_id;
|
||||
}
|
||||
|
||||
QTime carryOverStart;
|
||||
QTime carryOverEnd;
|
||||
int carryOverDuration = -1;
|
||||
QTime carryOverStart;
|
||||
QTime carryOverEnd;
|
||||
int carryOverDuration = -1;
|
||||
|
||||
// using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
|
||||
std::multimap<int, ATBCarryOver>::const_iterator it;
|
||||
if ((it = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)) !=
|
||||
tariff->TariffCarryOverOptions.cend()) {
|
||||
carryOverStart = it->second.carryover[weekDay].static_start;
|
||||
carryOverEnd = it->second.carryover[weekDay].static_end;
|
||||
carryOverDuration = it->second.carryover[weekDay].duration;
|
||||
}
|
||||
// using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
|
||||
std::multimap<int, ATBCarryOver>::const_iterator it;
|
||||
if ((it = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)) !=
|
||||
tariff->TariffCarryOverOptions.cend()) {
|
||||
carryOverStart = it->second.carryover[weekDay].static_start;
|
||||
carryOverEnd = it->second.carryover[weekDay].static_end;
|
||||
carryOverDuration = it->second.carryover[weekDay].duration;
|
||||
}
|
||||
|
||||
if (carryOverStart.isValid() && carryOverEnd.isValid()) {
|
||||
qCritical() << __func__ << __LINE__ << "carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << __LINE__ << "carryOverEnd" << carryOverEnd.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << __LINE__ << "carryOverDuration" << carryOverDuration;
|
||||
}
|
||||
if (carryOverStart.isValid() && carryOverEnd.isValid()) {
|
||||
qCritical() << __func__ << __LINE__ << "carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << __LINE__ << "carryOverEnd" << carryOverEnd.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << __LINE__ << "carryOverDuration" << carryOverDuration;
|
||||
}
|
||||
|
||||
if (carryOverStart.isValid() && carryOverEnd.isValid() && carryOverDuration != -1) {
|
||||
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||
if (ticketEndTime.time() > carryOverStart) {
|
||||
if (carryOverStart.isValid() && carryOverEnd.isValid() && carryOverDuration != -1) {
|
||||
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
||||
} else {
|
||||
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||
if (ticketEndTime.time() < carryOverEnd) {
|
||||
if (ticketEndTime.time() > carryOverStart) {
|
||||
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
||||
} else {
|
||||
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||
if (ticketEndTime.time() < carryOverEnd) {
|
||||
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCritical() << __func__ << __LINE__ << "WARNING: wrong carry-over-settings";
|
||||
}
|
||||
} else {
|
||||
qCritical() << __func__ << __LINE__ << "WARNING: wrong carry-over-settings";
|
||||
}
|
||||
|
||||
if (ticketEndTime.time().hour() == 0 && ticketEndTime.time().minute() == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user