Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
a3983ed427 | |||
f8805e9e78 | |||
7a6360f392 | |||
08a249f393 | |||
7c173ae292 | |||
80637260f3 | |||
9b524d63e5 |
@@ -42,6 +42,7 @@ public:
|
|||||||
pop_use_only_for_duration = 0; // deprecated
|
pop_use_only_for_duration = 0; // deprecated
|
||||||
pop_plus_steps = 1; // +: jump <x=1> steps forward
|
pop_plus_steps = 1; // +: jump <x=1> steps forward
|
||||||
pop_minus_steps = 1; // -: jump <x=1> steps backward
|
pop_minus_steps = 1; // -: jump <x=1> steps backward
|
||||||
|
pop_allow_overpay = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pop_id;
|
int pop_id;
|
||||||
@@ -73,6 +74,7 @@ public:
|
|||||||
bool pop_accumulate_durations;
|
bool pop_accumulate_durations;
|
||||||
int pop_plus_steps;
|
int pop_plus_steps;
|
||||||
int pop_minus_steps;
|
int pop_minus_steps;
|
||||||
|
bool pop_allow_overpay;
|
||||||
|
|
||||||
struct ATBMaxDateTime {
|
struct ATBMaxDateTime {
|
||||||
int direction;
|
int direction;
|
||||||
|
@@ -915,6 +915,7 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
bool prepaid = true;
|
bool prepaid = true;
|
||||||
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||||
int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||||
|
|
||||||
if (prepaid_option_id == 2) {
|
if (prepaid_option_id == 2) {
|
||||||
prepaid = false;
|
prepaid = false;
|
||||||
}
|
}
|
||||||
@@ -929,6 +930,28 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (start_parking_time.isValid()) {
|
if (start_parking_time.isValid()) {
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString cs = start_parking_time.toString(Qt::ISODate);
|
QString cs = start_parking_time.toString(Qt::ISODate);
|
||||||
QString endTime = Calculator::GetInstance().GetDurationFromCost(
|
QString endTime = Calculator::GetInstance().GetDurationFromCost(
|
||||||
tariff,
|
tariff,
|
||||||
@@ -1001,15 +1024,65 @@ 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) {
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
// 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() && carryOverDuration != -1) {
|
||||||
|
qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ticketEndTime.time().hour() == 0 && ticketEndTime.time().minute() == 0) {
|
if (ticketEndTime.time().hour() == 0 && ticketEndTime.time().minute() == 0) {
|
||||||
ticketEndTime = ticketEndTime.addDays(-1);
|
ticketEndTime = ticketEndTime.addDays(-1);
|
||||||
ticketEndTime.setTime(QTime(23, 59, 0));
|
ticketEndTime.setTime(QTime(23, 59, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
qCritical() << "compute_duration_for_parking_ticket(): ";
|
qCritical() << __func__ << __LINE__ << " endTime:" << endTime;
|
||||||
qCritical() << " endTime: " << endTime;
|
qCritical() << __func__ << __LINE__ << "ticketEndTime:" << ticketEndTime;
|
||||||
qCritical() << " ticketEndTime: " << ticketEndTime;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return calcState.set(CalcState::State::INVALID_START_DATE);
|
return calcState.set(CalcState::State::INVALID_START_DATE);
|
||||||
|
@@ -262,11 +262,15 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||||
int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
|
int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
|
||||||
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||||
|
int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
|
||||||
|
|
||||||
if (cost > pop_max_price) {
|
if (cost > pop_max_price) {
|
||||||
cost = pop_max_price;
|
|
||||||
qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
|
qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
|
||||||
//return CalcState::OVERPAID.toStdString();
|
if (pop_allow_overpay == false) {
|
||||||
|
return CalcState::OVERPAID.toStdString();
|
||||||
|
}
|
||||||
|
cost = pop_max_price;
|
||||||
|
// return CalcState::OVERPAID.toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cost < pop_min_price) {
|
if (cost < pop_min_price) {
|
||||||
|
@@ -606,6 +606,10 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
if (k->value.IsInt()) {
|
if (k->value.IsInt()) {
|
||||||
this->currentPaymentOptions.last().pop_minus_steps = k->value.GetInt();
|
this->currentPaymentOptions.last().pop_minus_steps = k->value.GetInt();
|
||||||
}
|
}
|
||||||
|
} else if (strcmp(inner_obj_name, "pop_allow_overpay") == 0) {
|
||||||
|
if (k->value.IsBool()) {
|
||||||
|
this->currentPaymentOptions.last().pop_allow_overpay = k->value.GetBool();
|
||||||
|
}
|
||||||
} else if (strcmp(inner_obj_name, "pop_payment_method_id") == 0) {
|
} else if (strcmp(inner_obj_name, "pop_payment_method_id") == 0) {
|
||||||
this->currentPaymentOptions.last().pop_payment_method_id = k->value.GetInt();
|
this->currentPaymentOptions.last().pop_payment_method_id = k->value.GetInt();
|
||||||
} else if (strcmp(inner_obj_name, "pop_day_end_time") == 0) {
|
} else if (strcmp(inner_obj_name, "pop_day_end_time") == 0) {
|
||||||
|
@@ -207,7 +207,13 @@ bool Utilities::IsYearPeriodActive(Configuration const *cfg, QDateTime const &dt
|
|||||||
dt.date().day());
|
dt.date().day());
|
||||||
QDate const s(2004, year.second.pye_start_month, year.second.pye_start_day);
|
QDate const s(2004, year.second.pye_start_month, year.second.pye_start_day);
|
||||||
QDate const e(2004, year.second.pye_end_month, year.second.pye_end_day);
|
QDate const e(2004, year.second.pye_end_month, year.second.pye_end_day);
|
||||||
return (d >= s && d <= e);
|
//qCritical() << __func__ << __LINE__ << " d" << d.toString(Qt::ISODate);
|
||||||
|
//qCritical() << __func__ << __LINE__ << "start" << s.toString(Qt::ISODate);
|
||||||
|
//qCritical() << __func__ << __LINE__ << " end" << e.toString(Qt::ISODate);
|
||||||
|
if (s <= e) {
|
||||||
|
return (d >= s && d <= e);
|
||||||
|
}
|
||||||
|
return (d >= s || d <= e);
|
||||||
})) {
|
})) {
|
||||||
qCritical() << "NO VALID YEAR PERIOD";
|
qCritical() << "NO VALID YEAR PERIOD";
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user