Compare commits
3 Commits
2.3.99-19
...
6ef57792ce
Author | SHA1 | Date | |
---|---|---|---|
6ef57792ce | |||
ec9f7d9262 | |||
a2c40fa32a |
@@ -28,6 +28,7 @@
|
||||
#include "tariff_interpolation.h"
|
||||
#include "tariff_prepaid.h"
|
||||
#include "tariff_carryover.h"
|
||||
#include "tariff_prepay.h"
|
||||
#include "tariff_permit_type.h"
|
||||
|
||||
#include <QVector>
|
||||
@@ -47,6 +48,7 @@ public:
|
||||
using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
|
||||
using TariffInterpolationType = std::multimap<int, ATBInterpolation>;
|
||||
using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
|
||||
using TariffPrepayOptionType = std::multimap<int, ATBPrepay>;
|
||||
using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
|
||||
using TariffDurationType = std::multimap<int, ATBDuration>;
|
||||
|
||||
@@ -71,6 +73,7 @@ public:
|
||||
TariffProductType TariffProduct;
|
||||
TariffInterpolationType TariffInterpolations;
|
||||
TariffPrepaidType TariffPrepaidOptions;
|
||||
TariffPrepayOptionType TariffPrepayOptions;
|
||||
TariffCarryOverType TariffCarryOverOptions;
|
||||
|
||||
/// <summary>
|
||||
|
@@ -12,7 +12,12 @@ public:
|
||||
, pun_duration_saved(0)
|
||||
, pun_duration_min(0)
|
||||
, pun_duration_max(0)
|
||||
, pun_interpolation_id(-1) {
|
||||
, pun_interpolation_id(-1)
|
||||
, pun_netto(false)
|
||||
, pun_brutto(false)
|
||||
, pun_fixed(false)
|
||||
, pun_requires_change(false)
|
||||
, pun_next_step_correction(0) {
|
||||
}
|
||||
|
||||
friend QDebug operator<<(QDebug debug, ATBDuration const &td) {
|
||||
@@ -25,6 +30,10 @@ public:
|
||||
<< " pun_duration_saved: " << td.pun_duration_saved << "\n"
|
||||
<< " pun_duration_min: " << td.pun_duration_min << "\n"
|
||||
<< " pun_duration_max: " << td.pun_duration_max << "\n"
|
||||
<< " pun_netto: " << td.pun_netto << "\n"
|
||||
<< " pun_brutto: " << td.pun_brutto << "\n"
|
||||
<< " pun_fixed: " << td.pun_fixed << "\n"
|
||||
<< " pun_requires_change: " << td.pun_requires_change << "\n"
|
||||
<< "pun_interpolation_id: " << td.pun_interpolation_id << "\n";
|
||||
|
||||
return debug;
|
||||
@@ -37,4 +46,9 @@ public:
|
||||
int pun_duration_min;
|
||||
int pun_duration_max;
|
||||
int pun_interpolation_id;
|
||||
bool pun_netto; // the timestep expressed by this duration is a netto timestep
|
||||
bool pun_brutto; // the timestep expressed by this duration is a brutto timestep
|
||||
bool pun_fixed; // the value given in tariff-file is fixed (constant)
|
||||
bool pun_requires_change; // the value has to be changes (controlled by other parameters)
|
||||
int pun_next_step_correction;
|
||||
};
|
||||
|
@@ -21,8 +21,9 @@ enum MemberType
|
||||
TimeStepConfigType = 0x0E,
|
||||
ProductType = 0x0F,
|
||||
InterpolationType = 0x10,
|
||||
PrepaidType = 0x11,
|
||||
CarryOverType = 0x12
|
||||
PrepaidType = 0x11, // deprecated
|
||||
CarryOverType = 0x12,
|
||||
PrepaidOptionType = 0x13,
|
||||
};
|
||||
|
||||
#endif // MEMBER_TYPE_H_INCLUDED
|
||||
|
@@ -42,7 +42,6 @@ public:
|
||||
pop_use_only_for_duration = 0; // deprecated
|
||||
pop_plus_steps = 1; // +: jump <x=1> steps forward
|
||||
pop_minus_steps = 1; // -: jump <x=1> steps backward
|
||||
pop_allow_overpay = false;
|
||||
}
|
||||
|
||||
int pop_id;
|
||||
@@ -74,7 +73,6 @@ public:
|
||||
bool pop_accumulate_durations;
|
||||
int pop_plus_steps;
|
||||
int pop_minus_steps;
|
||||
bool pop_allow_overpay;
|
||||
|
||||
struct ATBMaxDateTime {
|
||||
int direction;
|
||||
|
@@ -915,7 +915,6 @@ 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,28 +929,6 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
}
|
||||
|
||||
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 endTime = Calculator::GetInstance().GetDurationFromCost(
|
||||
tariff,
|
||||
@@ -1024,65 +1001,15 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
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) {
|
||||
ticketEndTime = ticketEndTime.addDays(-1);
|
||||
ticketEndTime.setTime(QTime(23, 59, 0));
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
qCritical() << __func__ << __LINE__ << " endTime:" << endTime;
|
||||
qCritical() << __func__ << __LINE__ << "ticketEndTime:" << ticketEndTime;
|
||||
qCritical() << "compute_duration_for_parking_ticket(): ";
|
||||
qCritical() << " endTime: " << endTime;
|
||||
qCritical() << " ticketEndTime: " << ticketEndTime;
|
||||
}
|
||||
} else {
|
||||
return calcState.set(CalcState::State::INVALID_START_DATE);
|
||||
|
@@ -262,14 +262,10 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
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_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
|
||||
|
||||
if (cost > pop_max_price) {
|
||||
qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
|
||||
if (pop_allow_overpay == false) {
|
||||
return CalcState::OVERPAID.toStdString();
|
||||
}
|
||||
cost = pop_max_price;
|
||||
qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
|
||||
//return CalcState::OVERPAID.toStdString();
|
||||
}
|
||||
|
||||
|
@@ -606,10 +606,6 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
if (k->value.IsInt()) {
|
||||
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) {
|
||||
this->currentPaymentOptions.last().pop_payment_method_id = k->value.GetInt();
|
||||
} else if (strcmp(inner_obj_name, "pop_day_end_time") == 0) {
|
||||
|
@@ -207,13 +207,7 @@ bool Utilities::IsYearPeriodActive(Configuration const *cfg, QDateTime const &dt
|
||||
dt.date().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);
|
||||
//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";
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user