Keep bacjward compatibility before using payment-method Unified.
This commit is contained in:
parent
fd99c20bd9
commit
d4363e71cd
@ -989,7 +989,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
netto_parking_time, // minutes, netto
|
netto_parking_time, // minutes, netto
|
||||||
false, prepaid);
|
false, prepaid);
|
||||||
}
|
}
|
||||||
// qCritical() << __func__ << __LINE__;
|
|
||||||
double minCost = tariff->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
double minCost = tariff->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||||
if (cost < minCost) {
|
if (cost < minCost) {
|
||||||
calcState.setDesc(QString("line=%1 minCost=%2, cost=%3").arg(__LINE__).arg(minCost).arg(cost));
|
calcState.setDesc(QString("line=%1 minCost=%2, cost=%3").arg(__LINE__).arg(minCost).arg(cost));
|
||||||
@ -1145,6 +1145,9 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
QString endTime = p_endTime.first.c_str();
|
QString endTime = p_endTime.first.c_str();
|
||||||
ticketEndTime = p_endTime.second;
|
ticketEndTime = p_endTime.second;
|
||||||
|
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << endTime;
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ticketEndTime.toString(Qt::ISODate);
|
||||||
|
|
||||||
if (endTime == CalcState::SUCCESS) {
|
if (endTime == CalcState::SUCCESS) {
|
||||||
calcState.setDesc(QString("SUCCESS"));
|
calcState.setDesc(QString("SUCCESS"));
|
||||||
calcState.setStatus(endTime);
|
calcState.setStatus(endTime);
|
||||||
@ -1225,154 +1228,157 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
return calcState.set(CalcState::State::WRONG_ISO_TIME_FORMAT);
|
return calcState.set(CalcState::State::WRONG_ISO_TIME_FORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::STATIC) {
|
if (tariff->getPaymentOptions().pop_payment_method_id != PaymentMethod::Unified) {
|
||||||
// handle carry over for ticket-end-time
|
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
|
|
||||||
|
|
||||||
int weekDay = start_parking_time.date().dayOfWeek();
|
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::STATIC) {
|
||||||
int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
// handle carry over for ticket-end-time
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "configured carry-over-id" << pop_carry_over_option_id;
|
qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
|
||||||
|
|
||||||
std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
|
int weekDay = start_parking_time.date().dayOfWeek();
|
||||||
if (yperiod.has_value()) {
|
int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
||||||
ATBPeriodYear const &period = yperiod.value();
|
qCritical() << __func__ << ":" << __LINE__ << "configured carry-over-id" << pop_carry_over_option_id;
|
||||||
pop_carry_over_option_id = period.pye_id;
|
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "re-computed carry-over-id" << pop_carry_over_option_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTime carryOverStart;
|
std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
|
||||||
QTime carryOverEnd;
|
if (yperiod.has_value()) {
|
||||||
int carryOverDuration = -1;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
|
QTime carryOverStart;
|
||||||
std::multimap<int, ATBCarryOver>::const_iterator it;
|
QTime carryOverEnd;
|
||||||
if ((it = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)) !=
|
int carryOverDuration = -1;
|
||||||
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()) {
|
// using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
std::multimap<int, ATBCarryOver>::const_iterator it;
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "carryOverEnd" << carryOverEnd.toString(Qt::ISODate);
|
if ((it = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)) !=
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "carryOverDuration" << carryOverDuration;
|
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() && carryOverDuration != -1) {
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// note: in such a case (direct coins) carry-over has been handled
|
if (carryOverStart.isValid() && carryOverEnd.isValid() && carryOverDuration != -1) {
|
||||||
// already in GetDurationFromCost()
|
|
||||||
netto_parking_time -= carryOverDuration;
|
// note: in such a case (direct coins) carry-over has been handled
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "netto-parking-time" << netto_parking_time;
|
// already in GetDurationFromCost()
|
||||||
|
netto_parking_time -= carryOverDuration;
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "netto-parking-time" << netto_parking_time;
|
||||||
|
|
||||||
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
|
||||||
if (ticketEndTime.time() > carryOverStart) {
|
|
||||||
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
if (ticketEndTime.time() > carryOverStart) {
|
||||||
} else
|
|
||||||
if (ticketEndTime.time() == carryOverStart) {
|
|
||||||
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
|
||||||
qCritical() << __func__ << ":" << __LINE__ << " carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
|
||||||
ATBPaymentOption const &po = tariff->getPaymentOptions(paymentOptionIndex);
|
|
||||||
if (po.pop_apply_carry_over_to_ticket_endtime) {
|
|
||||||
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
|
||||||
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
|
||||||
}
|
|
||||||
} 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);
|
// qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
||||||
|
} else
|
||||||
|
if (ticketEndTime.time() == carryOverStart) {
|
||||||
|
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << " carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
||||||
|
ATBPaymentOption const &po = tariff->getPaymentOptions(paymentOptionIndex);
|
||||||
|
if (po.pop_apply_carry_over_to_ticket_endtime) {
|
||||||
|
ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
|
||||||
|
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
|
}
|
||||||
|
} 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";
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
|
qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
|
||||||
|
|
||||||
for (auto[itr, rangeEnd] = tariff->WeekDays.equal_range((Qt::DayOfWeek)(ticketEndTime.date().dayOfWeek()));
|
for (auto[itr, rangeEnd] = tariff->WeekDays.equal_range((Qt::DayOfWeek)(ticketEndTime.date().dayOfWeek()));
|
||||||
itr != rangeEnd;
|
itr != rangeEnd;
|
||||||
++itr) {
|
++itr) {
|
||||||
ATBWeekDay const &wd = itr->second;
|
ATBWeekDay const &wd = itr->second;
|
||||||
bool parkTimeLimitViolated = wd.getTariffCarryOverSettings().parkingTimeLimitExceeded(start_parking_time,
|
bool parkTimeLimitViolated = wd.getTariffCarryOverSettings().parkingTimeLimitExceeded(start_parking_time,
|
||||||
ticketEndTime,
|
ticketEndTime,
|
||||||
paymentOptionIndex);
|
paymentOptionIndex);
|
||||||
if (parkTimeLimitViolated) {
|
if (parkTimeLimitViolated) {
|
||||||
//QTime const &tlimit = wd.getTariffCarryOverSettings().parkingTimeLimit();
|
//QTime const &tlimit = wd.getTariffCarryOverSettings().parkingTimeLimit();
|
||||||
//ticketEndTime.setTime(tlimit);
|
//ticketEndTime.setTime(tlimit);
|
||||||
|
|
||||||
QList<int> const &stepList = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex);
|
QList<int> const &stepList = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex);
|
||||||
|
|
||||||
QDateTime newTicketEndTime = ticketEndTime;
|
QDateTime newTicketEndTime = ticketEndTime;
|
||||||
|
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "PARK-TIME VIOLATED";
|
qCritical() << __func__ << ":" << __LINE__ << "PARK-TIME VIOLATED";
|
||||||
|
|
||||||
for (int i = stepList.size() - 1; i > 0; --i) {
|
for (int i = stepList.size() - 1; i > 0; --i) {
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "step[" << i << "]" << stepList.at(i);
|
// qCritical() << __func__ << ":" << __LINE__ << "step[" << i << "]" << stepList.at(i);
|
||||||
|
|
||||||
if (netto_parking_time > 0 && stepList.at(i) <= netto_parking_time) {
|
if (netto_parking_time > 0 && stepList.at(i) <= netto_parking_time) {
|
||||||
int const diff = stepList.at(i-1) - stepList.at(i);
|
int const diff = stepList.at(i-1) - stepList.at(i);
|
||||||
newTicketEndTime = newTicketEndTime.addSecs(diff * 60);
|
newTicketEndTime = newTicketEndTime.addSecs(diff * 60);
|
||||||
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "new-ticket-end-time" << newTicketEndTime.toString(Qt::ISODate);
|
// qCritical() << __func__ << ":" << __LINE__ << "new-ticket-end-time" << newTicketEndTime.toString(Qt::ISODate);
|
||||||
|
|
||||||
parkTimeLimitViolated
|
parkTimeLimitViolated
|
||||||
= wd.getTariffCarryOverSettings()
|
= wd.getTariffCarryOverSettings()
|
||||||
.parkingTimeLimitExceeded(start_parking_time, newTicketEndTime, paymentOptionIndex);
|
.parkingTimeLimitExceeded(start_parking_time, newTicketEndTime, paymentOptionIndex);
|
||||||
|
|
||||||
if (!parkTimeLimitViolated) {
|
if (!parkTimeLimitViolated) {
|
||||||
|
|
||||||
qCritical() << __func__ << ":" << __LINE__
|
qCritical() << __func__ << ":" << __LINE__
|
||||||
<< "PARK-TIME NOT VIOLATED FOR" << newTicketEndTime.toString(Qt::ISODate);
|
<< "PARK-TIME NOT VIOLATED FOR" << newTicketEndTime.toString(Qt::ISODate);
|
||||||
|
|
||||||
int duration = stepList.at(i-1);
|
int duration = stepList.at(i-1);
|
||||||
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "duration" << duration;
|
// qCritical() << __func__ << ":" << __LINE__ << "duration" << duration;
|
||||||
|
|
||||||
std::multimap<int, ATBDuration>::const_iterator it;
|
std::multimap<int, ATBDuration>::const_iterator it;
|
||||||
for (it = tariff->Duration.cbegin();
|
for (it = tariff->Duration.cbegin();
|
||||||
it != tariff->Duration.cend();
|
it != tariff->Duration.cend();
|
||||||
++it) {
|
++it) {
|
||||||
if (duration == it->second.pun_duration) {
|
if (duration == it->second.pun_duration) {
|
||||||
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "duration" << duration;
|
// qCritical() << __func__ << ":" << __LINE__ << "duration" << duration;
|
||||||
|
|
||||||
ATBPaymentOption &po = tariff->getPaymentOptions(paymentOptionIndex);
|
ATBPaymentOption &po = tariff->getPaymentOptions(paymentOptionIndex);
|
||||||
int const pop_id = po.pop_id;
|
int const pop_id = po.pop_id;
|
||||||
for (auto[itr, rangeEnd] = tariff->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
for (auto[itr, rangeEnd] = tariff->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||||
int const durationId = itr->second.pra_payment_unit_id;
|
int const durationId = itr->second.pra_payment_unit_id;
|
||||||
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "durationId" << durationId << it->second.pun_id;
|
// qCritical() << __func__ << ":" << __LINE__ << "durationId" << durationId << it->second.pun_id;
|
||||||
|
|
||||||
// note: for this to work, Duration and PaymentRate must have
|
// note: for this to work, Duration and PaymentRate must have
|
||||||
// exactly the same structure
|
// exactly the same structure
|
||||||
if (durationId == it->second.pun_id) {
|
if (durationId == it->second.pun_id) {
|
||||||
int const pra_price = itr->second.pra_price;
|
int const pra_price = itr->second.pra_price;
|
||||||
po.pop_max_price = pra_price;
|
po.pop_max_price = pra_price;
|
||||||
|
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "new max-price" << po.pop_max_price;
|
qCritical() << __func__ << ":" << __LINE__ << "new max-price" << po.pop_max_price;
|
||||||
|
|
||||||
// note: ABOVE_MAX_PARKING_TIME would also be possible
|
// note: ABOVE_MAX_PARKING_TIME would also be possible
|
||||||
// but here max-parking-time is dynamic. And for
|
// but here max-parking-time is dynamic. And for
|
||||||
// this dynamic value, opverpaid is actually correct
|
// this dynamic value, opverpaid is actually correct
|
||||||
|
|
||||||
calcState.setDesc(CalcState::OVERPAID);
|
calcState.setDesc(CalcState::OVERPAID);
|
||||||
calcState.setStatus(CalcState::OVERPAID);
|
calcState.setStatus(CalcState::OVERPAID);
|
||||||
return calcState;
|
return calcState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
calcState.setDesc(QString("line=%1 endTime=%2: park-time-limit violated").arg(__LINE__)
|
calcState.setDesc(QString("line=%1 endTime=%2: park-time-limit violated").arg(__LINE__)
|
||||||
.arg(ticketEndTime.time().toString(Qt::ISODate)));
|
.arg(ticketEndTime.time().toString(Qt::ISODate)));
|
||||||
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
|
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user