Compare commits
49 Commits
b4b2e27fe3
...
2.3.99-10
Author | SHA1 | Date | |
---|---|---|---|
3a98a14eb0
|
|||
7bf7108668 | |||
e5629ba4fd | |||
0d0d34cb87
|
|||
e4cb992aae | |||
cdeb625a15 | |||
589d89b73a | |||
7536f89d75 | |||
9a6b2b195d | |||
7233bc55c2 | |||
8fff7a76f6
|
|||
52b7c2390a | |||
894e23332f | |||
fbc255a6f2 | |||
24ab01695d | |||
37652d3b6a | |||
14fd7ddd39 | |||
ca3c3921d4 | |||
37620a06c1 | |||
9f4affca5a | |||
4f2c33cdc2 | |||
3cd02296b0 | |||
f1493f417f | |||
356e3be178 | |||
31b1dd1690 | |||
84d807930e
|
|||
dbf5b1f11d | |||
18f4e74eea
|
|||
29368ea850 | |||
b84f80887e | |||
bfd9f3b80c
|
|||
cb69d3ca2f
|
|||
4a2b15d086 | |||
63043931c2
|
|||
8dad8f00e8 | |||
1ea03f522c
|
|||
805a732c52 | |||
ac20a767df
|
|||
b7facb9d60 | |||
8344b04b15 | |||
b0ecef0361 | |||
003b7e8e8a | |||
7ef2d44fc4 | |||
8f203184b6 | |||
0bfec6a938 | |||
070446d01a | |||
4d7e5263ee | |||
7d452c82b7 | |||
0a08221381 |
@@ -266,7 +266,8 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff,
|
||||
void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff);
|
||||
int CALCULATE_LIBRARY_API get_zone_nr(int zone = -1);
|
||||
|
||||
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes, int UpDown);
|
||||
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes,
|
||||
int UpDown, PermitType const &permitType);
|
||||
|
||||
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg);
|
||||
|
||||
@@ -297,7 +298,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket( // depre
|
||||
parking_tariff_t *tariff,
|
||||
time_t start_parking_time,
|
||||
time_t end_parking_time,
|
||||
struct price_t *price);
|
||||
struct price_t *price,
|
||||
PermitType permitType);
|
||||
|
||||
CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
parking_tariff_t *tariff,
|
||||
@@ -305,24 +307,28 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
int netto_parking_time,
|
||||
QDateTime &end_parking_time, // return value
|
||||
struct price_t *price, // return value
|
||||
PermitType permitType,
|
||||
bool prepaid = true);
|
||||
|
||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket( // deprecated
|
||||
parking_tariff_t *tariff,
|
||||
time_t start_parking_time,
|
||||
double cost,
|
||||
QString &duration);
|
||||
QString &duration,
|
||||
PermitType permitType);
|
||||
|
||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
parking_tariff_t *tariff,
|
||||
QDateTime const &start_parking_time,
|
||||
double cost,
|
||||
QDateTime &ticketEndTime); // return value
|
||||
QDateTime &ticketEndTime,
|
||||
PermitType permitType); // return value
|
||||
|
||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(
|
||||
parking_tariff_t *tariff,
|
||||
QDateTime const &start_parking_time,
|
||||
QDateTime &ticketEndTime);
|
||||
QDateTime &ticketEndTime,
|
||||
PermitType permitType);
|
||||
|
||||
CalcState CALCULATE_LIBRARY_API compute_price_for_daily_ticket(
|
||||
parking_tariff_t *tariff,
|
||||
|
@@ -40,12 +40,12 @@ public:
|
||||
}
|
||||
|
||||
void ResetTimeSteps(int paymentOptionIndex) {
|
||||
if (m_timeSteps.size() > 0) {
|
||||
if (m_timeSteps.size() > 0 && paymentOptionIndex < m_timeSteps.size()) {
|
||||
m_timeSteps[paymentOptionIndex].clear();
|
||||
}
|
||||
}
|
||||
QList<int> timeSteps(int paymentOptionIndex=0) const {
|
||||
if (m_timeSteps.size() > 0) {
|
||||
if (m_timeSteps.size() > 0 && paymentOptionIndex < m_timeSteps.size()) {
|
||||
return m_timeSteps[paymentOptionIndex];
|
||||
}
|
||||
return QList<int>();
|
||||
@@ -70,7 +70,8 @@ public:
|
||||
/// <param name="start_datetime">Date/time of payment to be conducted in ISO8601 format (e.g. 2022-12-25T08:00:00Z)</param>
|
||||
/// <param name="price"></param>
|
||||
/// <returns>Returns duration in seconds (data type: double)</returns>
|
||||
std::string GetDurationFromCost(Configuration* cfg, uint8_t vehicle_type, char const* start_datetime, double price, bool nextDay = false, bool prepaid = false);
|
||||
std::string GetDurationFromCost(Configuration* cfg, uint8_t vehicle_type, char const* start_datetime, double price,
|
||||
PermitType permitType, bool nextDay = false, bool prepaid = false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets cost from duration in seconds
|
||||
@@ -81,7 +82,8 @@ public:
|
||||
/// <param name="end_datetime">Date/time of park end to be conducted in ISO8601 format (e.g. 2022-12-25T08:00:00Z) </param>
|
||||
/// <param name="durationMin">Duration of parking in minutes</param>
|
||||
/// <returns>Returns cost (data type: double)</returns>
|
||||
double GetCostFromDuration(Configuration* cfg, uint8_t vehicle_type, QDateTime &start_datetime, QDateTime & end_datetime, int durationMin, bool nextDay = false, bool prepaid = false);
|
||||
double GetCostFromDuration(Configuration* cfg, uint8_t vehicle_type, QDateTime &start_datetime, QDateTime & end_datetime, int durationMin,
|
||||
PermitType permitType, bool nextDay = false, bool prepaid = false);
|
||||
|
||||
// Daily ticket
|
||||
QDateTime GetDailyTicketDuration(Configuration* cfg, const QDateTime start_datetime, uint8_t payment_option, bool carry_over);
|
||||
@@ -131,10 +133,10 @@ private:
|
||||
int durationMinutes);
|
||||
|
||||
//
|
||||
uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex=0) const;
|
||||
uint32_t GetPriceForStep(Configuration *cfg, int step) const {
|
||||
return GetPriceForTimeStep(cfg, step);
|
||||
}
|
||||
uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex) const;
|
||||
//uint32_t GetPriceForStep(Configuration *cfg, int step) const {
|
||||
// return GetPriceForTimeStep(cfg, step, 0);
|
||||
//}
|
||||
uint32_t GetDurationForPrice(Configuration *cfg, int price) const;
|
||||
uint32_t GetStepForPrice(Configuration *cfg, int price) const {
|
||||
return GetDurationForPrice(cfg, price);
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "tariff_interpolation.h"
|
||||
#include "tariff_prepaid.h"
|
||||
#include "tariff_carryover.h"
|
||||
#include "tariff_permit_type.h"
|
||||
|
||||
#include <QVector>
|
||||
#include <optional>
|
||||
@@ -47,12 +48,13 @@ public:
|
||||
using TariffInterpolationType = std::multimap<int, ATBInterpolation>;
|
||||
using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
|
||||
using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
|
||||
using TariffDurationType = std::multimap<int, ATBDuration>;
|
||||
|
||||
ATBProject project;
|
||||
ATBCurrency Currency;
|
||||
ATBDuration duration;
|
||||
|
||||
multimap<int, ATBDuration> Duration;
|
||||
TariffDurationType Duration;
|
||||
multimap<int, ATBPaymentMethod> PaymentMethod;
|
||||
multimap<int, ATBPaymentRate> PaymentRate;
|
||||
SpecialDaysWorktimeType SpecialDaysWorktime;
|
||||
@@ -91,7 +93,12 @@ public:
|
||||
bool isDayIncludedAsSpecialDay(uint64_t businessHours, QDateTime const &dt) const;
|
||||
bool isDayIncludedAsSpecialDay(uint64_t businessHours, int specialDayId) const;
|
||||
std::optional<QVector<ATBPaymentRate>> getPaymentRateForAllKeys() const;
|
||||
std::optional<QVector<ATBPaymentOption>> getPaymentOptionsForAllKeys() const;
|
||||
std::optional<ATBPaymentOption> getPaymentOptionForId(int key) const;
|
||||
std::optional<QVector<ATBPaymentRate>> getPaymentRateForKey(int key) const;
|
||||
std::optional<ATBPaymentOption> getPaymentOptionForKey(PERMIT_TYPE permitType) const;
|
||||
std::optional<ATBPaymentOption> getPaymentOptionForKey(int permitType) const;
|
||||
std::optional<ATBPaymentOption> getPaymentOptionForKey(QString const &permitType) const;
|
||||
std::optional<QVector<ATBDailyTicket>> getDailyTicketsForAllKeys() const;
|
||||
std::optional<QVector<ATBDailyTicket>> getDailyTicketsForKey(int key) const;
|
||||
std::optional<ATBInterpolation> getInterpolationType(int type) const;
|
||||
@@ -103,8 +110,11 @@ public:
|
||||
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductTypeName(QString const &permitTypeName) const;
|
||||
std::optional<ATBCustomer> getCustomerForType(ATBCustomer::CustomerType customerType);
|
||||
std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek);
|
||||
std::optional<QVector<ATBWeekDaysWorktime>> getAllWeekDayWorkTimes();
|
||||
|
||||
std::optional<QDateTime> prepaidStart(QDateTime const &start, int prepaid_option_id);
|
||||
int getPaymentOptionIndex(PERMIT_TYPE permitType);
|
||||
int getPaymentOptionIndex(PERMIT_TYPE permitType) const;
|
||||
|
||||
private:
|
||||
/// <summary>
|
||||
|
@@ -15,6 +15,8 @@ public:
|
||||
void reset() {
|
||||
pop_id = 0;
|
||||
pop_label = "";
|
||||
pop_product_id = -1;
|
||||
pop_product_name = "";
|
||||
pop_payment_method_id = 0;
|
||||
pop_day_end_time = "";
|
||||
pop_day_night_end_time = "";
|
||||
@@ -36,11 +38,17 @@ public:
|
||||
pop_daily_card_price = -1;
|
||||
pop_business_hours = -1;
|
||||
pop_time_step_config = -1;
|
||||
pop_use_only_upto_datetime = "";
|
||||
pop_use_only_for_duration = 0;
|
||||
}
|
||||
|
||||
int pop_id;
|
||||
std::string pop_label;
|
||||
int pop_product_id;
|
||||
QString pop_product_name;
|
||||
int pop_payment_method_id;
|
||||
QString pop_use_only_upto_datetime;
|
||||
int pop_use_only_for_duration;
|
||||
std::string pop_day_end_time;
|
||||
std::string pop_day_night_end_time;
|
||||
double pop_price_night;
|
||||
|
@@ -122,6 +122,59 @@ struct PermitType {
|
||||
return 7;
|
||||
}
|
||||
|
||||
static PERMIT_TYPE toPermitType(QString const permitTypeStr) {
|
||||
if (permitTypeStr == "DAY_TICKET") {
|
||||
return PERMIT_TYPE::DAY_TICKET;
|
||||
} else
|
||||
if (permitTypeStr == "DAY_TICKET_ADULT") {
|
||||
return PERMIT_TYPE::DAY_TICKET_ADULT;
|
||||
} else
|
||||
if (permitTypeStr == "DAY_TICKET_CHILD") {
|
||||
return PERMIT_TYPE::DAY_TICKET_CHILD;
|
||||
} else
|
||||
if (permitTypeStr == "DAY_TICKET_ADULT") {
|
||||
return PERMIT_TYPE::DAY_TICKET_ADULT;
|
||||
} else
|
||||
if (permitTypeStr == "DAY_TICKET_TEEN") {
|
||||
return PERMIT_TYPE::DAY_TICKET_TEEN;
|
||||
} else
|
||||
if (permitTypeStr == "SHORT_TERM_PARKING") {
|
||||
return PERMIT_TYPE::SHORT_TERM_PARKING;
|
||||
} else
|
||||
if (permitTypeStr == "SZEGED_START") {
|
||||
return PERMIT_TYPE::SZEGED_START;
|
||||
} else
|
||||
if (permitTypeStr == "SZEGED_STOP") {
|
||||
return PERMIT_TYPE::SZEGED_STOP;
|
||||
} else
|
||||
if (permitTypeStr == "FOOD_STAMP") {
|
||||
return PERMIT_TYPE::FOOD_STAMP;
|
||||
} else
|
||||
if (permitTypeStr == "TWENTY_FOUR_HOURS_TICKET") {
|
||||
return PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET;
|
||||
} else
|
||||
if (permitTypeStr == "SHORT_TERM_PARKING_PKW") {
|
||||
return PERMIT_TYPE::SHORT_TERM_PARKING_PKW;
|
||||
} else
|
||||
if (permitTypeStr == "SHORT_TERM_PARKING_BUS") {
|
||||
return PERMIT_TYPE::SHORT_TERM_PARKING_BUS;
|
||||
} else
|
||||
if (permitTypeStr == "SHORT_TERM_PARKING_CAMPER") {
|
||||
return PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER;
|
||||
} else
|
||||
if (permitTypeStr == "DAY_TICKET_PKW") {
|
||||
return PERMIT_TYPE::DAY_TICKET_PKW;
|
||||
} else
|
||||
if (permitTypeStr == "DAY_TICKET_BUS") {
|
||||
return PERMIT_TYPE::DAY_TICKET_BUS;
|
||||
} else
|
||||
if (permitTypeStr == "DAY_TICKET_CAMPER") {
|
||||
return PERMIT_TYPE::DAY_TICKET_CAMPER;
|
||||
}
|
||||
|
||||
return PERMIT_TYPE::INVALID;
|
||||
}
|
||||
|
||||
QString toString() {
|
||||
switch(m_permitType) {
|
||||
case PERMIT_TYPE::DAY_TICKET:
|
||||
|
@@ -5,6 +5,8 @@ class ATBWeekDaysWorktime
|
||||
{
|
||||
public:
|
||||
int pwd_id;
|
||||
int pwd_pop_id;
|
||||
int pwd_next_id;
|
||||
int pwd_period_week_day_id;
|
||||
int pwd_period_day_in_week_id;
|
||||
std::string pwd_time_from;
|
||||
|
@@ -34,9 +34,16 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
||||
int paymentOptionIndex) {
|
||||
int minTime = 0;
|
||||
|
||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||
|
||||
qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
|
||||
qCritical() << __func__ << __LINE__ << "permit" << PermitType(permitType).toString();
|
||||
|
||||
switch(permitType) {
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||
qCritical() << __LINE__ << Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex);
|
||||
minTime = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||
qCritical() << __func__ << __LINE__ << minTime;
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_ADULT: {
|
||||
} break;
|
||||
@@ -48,16 +55,19 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
||||
// for each new sell-procedure, recomute the timesteps. implicitly, set
|
||||
// the minimal parking time.
|
||||
Calculator::GetInstance().ResetTimeSteps(paymentOptionIndex);
|
||||
Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex);
|
||||
qCritical() << __LINE__ << Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex);
|
||||
minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time);
|
||||
}
|
||||
|
||||
qCritical() << "minTime" << minTime;
|
||||
return minTime;
|
||||
}
|
||||
|
||||
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
||||
PERMIT_TYPE permitType,
|
||||
int paymentOptionIndex) {
|
||||
|
||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||
int maxTime = 0;
|
||||
|
||||
switch(permitType) {
|
||||
@@ -71,10 +81,10 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
||||
case PERMIT_TYPE::DAY_TICKET_CHILD: {
|
||||
} break;
|
||||
default: ;
|
||||
maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
|
||||
}
|
||||
|
||||
return maxTime;
|
||||
|
||||
}
|
||||
|
||||
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
||||
@@ -82,7 +92,42 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
||||
int paymentOptionIndex,
|
||||
QDateTime const &start) {
|
||||
int minPrice = -1;
|
||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||
|
||||
int payment_method_id = cfg->getPaymentOptions(paymentOptionIndex).pop_payment_method_id;
|
||||
|
||||
if (payment_method_id == PaymentMethod::Degressive) {
|
||||
// Degressive: new for Fuchs Technik (500), ValserAlm (Fane):
|
||||
// the minimal price has to be calculated, in cannot be hard coded into
|
||||
// the tariff file.
|
||||
// The working times have a reference into the payment rates. Two special
|
||||
// entries (with the numbers 1000/1001) point to the respective prices.
|
||||
switch(permitType) {
|
||||
default: {
|
||||
// find the correct work time range
|
||||
int weekDay = start.date().dayOfWeek();
|
||||
std::optional<QVector<ATBWeekDaysWorktime>> const &wd = cfg->getAllWeekDayWorkTimes();
|
||||
if (wd.has_value()) {
|
||||
QVector<ATBWeekDaysWorktime> const &vec = wd.value();
|
||||
for (int i = 0; i < vec.size(); ++i) {
|
||||
ATBWeekDaysWorktime const &wt = vec[i];
|
||||
if (wt.pwd_period_day_in_week_id == weekDay) {
|
||||
if (start.time() >= QTime::fromString(QString::fromStdString(wt.pwd_time_from), Qt::ISODate)
|
||||
&& start.time() <= QTime::fromString(QString::fromStdString(wt.pwd_time_to), Qt::ISODate)) {
|
||||
// found worktime range
|
||||
int pop_id = wt.pwd_pop_id; // 1000 or 1001
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
i = vec.size(); // to leave outer loop
|
||||
minPrice = itr->second.pra_price; // this is now the minimal price
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch(permitType) {
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||
minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||
@@ -96,7 +141,9 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
||||
case PERMIT_TYPE::DAY_TICKET: {
|
||||
minPrice = compute_product_price(cfg, permitType, start);
|
||||
} break;
|
||||
default: ;
|
||||
default:
|
||||
minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||
}
|
||||
}
|
||||
|
||||
return minPrice;
|
||||
@@ -199,8 +246,8 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
||||
|
||||
if (product.size() > 0) {
|
||||
if (productStart && productEnd) {
|
||||
int pop_min_time = get_minimal_parkingtime(cfg); // in minutes
|
||||
int pop_max_time = get_maximal_parkingtime(cfg); // in minutes
|
||||
int pop_min_time = get_minimal_parkingtime(cfg, PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET); // in minutes
|
||||
int pop_max_time = get_maximal_parkingtime(cfg, PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET); // in minutes
|
||||
if (pop_max_time >= pop_min_time) {
|
||||
*productStart = start;
|
||||
*productEnd = start.addSecs(pop_max_time*60);
|
||||
@@ -214,7 +261,14 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
||||
|
||||
} break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW: {
|
||||
qCritical() << "TODO: SHORT_TERM_PARKING_PKW";
|
||||
PermitType p(permitType);
|
||||
std::optional<ATBPaymentOption> const paymentOption = cfg->getPaymentOptionForKey(p.get());
|
||||
if (paymentOption.has_value()) {
|
||||
ATBPaymentOption option = paymentOption.value();
|
||||
int const pop_daily_card_price = option.pop_daily_card_price;
|
||||
qCritical() << "SHORT_TERM_PARKING_PKW: daily ticket price" << pop_daily_card_price;
|
||||
return pop_daily_card_price;
|
||||
}
|
||||
} break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS: {
|
||||
qCritical() << "TODO: SHORT_TERM_PARKING_BUS";
|
||||
@@ -223,15 +277,34 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
||||
qCritical() << "TODO: SHORT_TERM_PARKING_CAMPER";
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_PKW: {
|
||||
int const pop_daily_card_price = cfg->getPaymentOptions().pop_daily_card_price;
|
||||
PermitType p(permitType);
|
||||
std::optional<ATBPaymentOption> const paymentOption = cfg->getPaymentOptionForKey(p.get());
|
||||
if (paymentOption.has_value()) {
|
||||
ATBPaymentOption option = paymentOption.value();
|
||||
int const pop_daily_card_price = option.pop_daily_card_price;
|
||||
qCritical() << "DAY_TICKET_PKW: daily ticket price" << pop_daily_card_price;
|
||||
return pop_daily_card_price;
|
||||
}
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_BUS: {
|
||||
qCritical() << "TODO: DAY_TICKET_BUS";
|
||||
PermitType p(permitType);
|
||||
std::optional<ATBPaymentOption> const paymentOption = cfg->getPaymentOptionForKey(p.get());
|
||||
if (paymentOption.has_value()) {
|
||||
ATBPaymentOption option = paymentOption.value();
|
||||
int const pop_daily_card_price = option.pop_daily_card_price;
|
||||
qCritical() << "DAY_TICKET_BUS: daily ticket price" << pop_daily_card_price;
|
||||
return pop_daily_card_price;
|
||||
}
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_CAMPER: {
|
||||
qCritical() << "TODO: DAY_TICKET_CAMPER";
|
||||
PermitType p(permitType);
|
||||
std::optional<ATBPaymentOption> const paymentOption = cfg->getPaymentOptionForKey(p.get());
|
||||
if (paymentOption.has_value()) {
|
||||
ATBPaymentOption option = paymentOption.value();
|
||||
int const pop_daily_card_price = option.pop_daily_card_price;
|
||||
qCritical() << "DAY_TICKET_CAMPER: daily ticket price" << pop_daily_card_price;
|
||||
return pop_daily_card_price;
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
@@ -246,6 +319,8 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
||||
int maxPrice = -1;
|
||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
|
||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||
|
||||
switch(permitType) {
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||
if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
|
||||
@@ -269,6 +344,28 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
||||
break;
|
||||
case PERMIT_TYPE::DAY_TICKET_CHILD:
|
||||
break;
|
||||
case PERMIT_TYPE::DAY_TICKET_BUS:
|
||||
break;
|
||||
case PERMIT_TYPE::DAY_TICKET_CAMPER:
|
||||
break;
|
||||
case PERMIT_TYPE::DAY_TICKET_PKW:
|
||||
break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS: {
|
||||
std::optional<ATBPaymentOption> po = cfg->getPaymentOptionForKey(permitType);
|
||||
if (po.has_value()) {
|
||||
ATBPaymentOption option = po.value();
|
||||
return option.pop_max_price;
|
||||
}
|
||||
} break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW: {
|
||||
std::optional<ATBPaymentOption> po = cfg->getPaymentOptionForKey(permitType);
|
||||
if (po.has_value()) {
|
||||
ATBPaymentOption option = po.value();
|
||||
return option.pop_max_price;
|
||||
}
|
||||
} break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER:
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
|
||||
@@ -338,11 +435,13 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff, char cons
|
||||
if (! (*tariff)->ParseJson(*tariff, json.toStdString().c_str())) {
|
||||
delete *tariff;
|
||||
*tariff = nullptr;
|
||||
qCritical() << " ... error parsing tariff";
|
||||
return calcState.set(CalcState::State::ERROR_PARSING_TARIFF);
|
||||
}
|
||||
} else {
|
||||
delete *tariff;
|
||||
*tariff = nullptr;
|
||||
qCritical() << " ... error loading tariff";
|
||||
return calcState.set(CalcState::State::ERROR_LOADING_TARIFF);
|
||||
}
|
||||
|
||||
@@ -359,30 +458,42 @@ void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff) {
|
||||
|
||||
//
|
||||
// UpDown 1 -> up; 0 -> down
|
||||
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes, int UpDown)
|
||||
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes,
|
||||
int UpDown, PermitType const &permitType)
|
||||
{
|
||||
|
||||
qCritical() << " compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes;
|
||||
qCritical() << " compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
|
||||
|
||||
// FIXME
|
||||
//std::optional<ATBPaymentOption> paymentOption = tariff->getPaymentOptionForKey(permitType.get());
|
||||
//if (!paymentOption.has_value()) {
|
||||
// qCritical() << " compute_next_timestep() ERROR";
|
||||
// return currentTimeMinutes;
|
||||
//}
|
||||
|
||||
int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||
qCritical() << " compute_next_timestep() payment option index: " << paymentOptionIndex;
|
||||
|
||||
Configuration const *cfg = tariff;
|
||||
|
||||
// compute payment method id (e.g. Linear=3, Steps=4)
|
||||
PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
switch (paymentMethodId) {
|
||||
case PaymentMethod::Progressive:
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Progressive";
|
||||
qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Progressive";
|
||||
break;
|
||||
case PaymentMethod::Degressive:
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Degressive";
|
||||
qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Degressive";
|
||||
break;
|
||||
case PaymentMethod::Linear:
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Linear";
|
||||
qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Linear";
|
||||
break;
|
||||
case PaymentMethod::Steps:
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Steps";
|
||||
qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Steps";
|
||||
break;
|
||||
case PaymentMethod::Undefined:
|
||||
qCritical() << " compute_next_timestep() paymentMethodId: Undefined";
|
||||
qCritical() << __LINE__ << " compute_next_timestep() paymentMethodId: Undefined";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -392,7 +503,9 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
||||
// progressive tariff: e.g. Neuhauser, Kirchdorf (743)
|
||||
(paymentMethodId == PaymentMethod::Progressive))
|
||||
{
|
||||
QList<int> &stepList = Calculator::GetInstance().GetTimeSteps(tariff);
|
||||
// int paymentOptionIndex = 1;
|
||||
|
||||
QList<int> &stepList = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex);
|
||||
int const size = stepList.size();
|
||||
if (size == 0) {
|
||||
qCritical() << "compute_next_timestep() *ERROR empty step-list*";
|
||||
@@ -433,6 +546,7 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
||||
return currentTimeMinutes;
|
||||
}
|
||||
else {
|
||||
qCritical() << " compute_next_timestep() return next time step:" << stepList[currentStepIndex + 1];
|
||||
return stepList[currentStepIndex + 1];
|
||||
}
|
||||
}
|
||||
@@ -442,6 +556,7 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
||||
return currentTimeMinutes;
|
||||
}
|
||||
else {
|
||||
qCritical() << " compute_next_timestep() return next time step:" << stepList[currentStepIndex - 1];
|
||||
return stepList[currentStepIndex - 1];
|
||||
}
|
||||
}
|
||||
@@ -484,10 +599,15 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
parking_tariff_t *tariff,
|
||||
time_t start_parking_time, // in minutes
|
||||
time_t end_parking_time, // netto time in minutes
|
||||
struct price_t *price) {
|
||||
struct price_t *price,
|
||||
PermitType permitType) { // permitType maps to product
|
||||
|
||||
CalcState calcState;
|
||||
double minMin = tariff->PaymentOption.find(tariff->getPaymentOptions().pop_payment_method_id)->second.pop_min_time;
|
||||
double maxMin = tariff->PaymentOption.find(tariff->getPaymentOptions().pop_payment_method_id)->second.pop_max_time;
|
||||
|
||||
int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
|
||||
|
||||
double minMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_min_time;
|
||||
double maxMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_max_time;
|
||||
|
||||
if (minMin < 0 || maxMin < 0 || maxMin < minMin) {
|
||||
calcState.setDesc(QString("minMin=%1, maxMin=%2").arg(minMin).arg(maxMin));
|
||||
@@ -520,13 +640,13 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
if (start.isValid()) {
|
||||
double cost = Calculator::GetInstance().GetCostFromDuration(
|
||||
tariff,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id,
|
||||
start,
|
||||
end,
|
||||
duration, false, true);
|
||||
double minCost = tariff->PaymentOption.find(tariff->getPaymentOptions().pop_payment_method_id)->second.pop_min_price;
|
||||
double minCost = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_min_price;
|
||||
if (cost < minCost) {
|
||||
calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost).arg(cost));
|
||||
calcState.setDesc(QString("line=%1 minCost=%2, cost=%3").arg(__LINE__).arg(minCost).arg(cost));
|
||||
return calcState.set(CalcState::State::BELOW_MIN_PARKING_PRICE);
|
||||
}
|
||||
price->units = cost;
|
||||
@@ -544,11 +664,12 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
int netto_parking_time,
|
||||
QDateTime &end_parking_time,
|
||||
struct price_t *price,
|
||||
PermitType permitType,
|
||||
bool prepaid)
|
||||
{
|
||||
CalcState calcState;
|
||||
|
||||
int paymentOptionIndex = tariff->getPaymentOptionIndex(start_parking_time);
|
||||
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||
|
||||
double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||
double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
|
||||
@@ -560,7 +681,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
<< " netto_parking_time: " << netto_parking_time << endl
|
||||
<< " start + netto: " << start_parking_time.addSecs(netto_parking_time * 60) << endl
|
||||
<< " minMin: " << minMin << endl
|
||||
<< " maxMin: " << maxMin;
|
||||
<< " maxMin: " << maxMin
|
||||
<< " permitType: " << permitType.toString();
|
||||
|
||||
|
||||
if (netto_parking_time < 0) {
|
||||
@@ -583,22 +705,59 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
|
||||
double cost = -1;
|
||||
if (start_parking_time.isValid()) {
|
||||
if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps) {
|
||||
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
|
||||
if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps ||
|
||||
tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Degressive) {
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
// hier muesste man unterscheiden: uebertrag oder nicht?
|
||||
calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time,
|
||||
netto_parking_time, paymentOptionIndex);
|
||||
if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
// << calcState.toString();
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< calcState.toString();
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
return calcState;
|
||||
}
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
|
||||
QList<int> lll = Calculator::GetInstance().GetTimeSteps(tariff);
|
||||
|
||||
// netto_parking_time = compute_next_timestep(tariff, netto_parking_time, 1, permitType);
|
||||
|
||||
qCritical() << "LINE" << __LINE__ << "netto" << netto_parking_time << lll;
|
||||
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex);
|
||||
|
||||
int weekDay = start_parking_time.date().dayOfWeek();
|
||||
int const pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
||||
QTime const carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
|
||||
//QTime const carryOverEnd = cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end;
|
||||
int const carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
|
||||
|
||||
qCritical() << "LINE" << __LINE__ << "carryStart" << carryOverStart.toString(Qt::ISODate);
|
||||
qCritical() << "LINE" << __LINE__ << "carryDur" << carryOverDuration;
|
||||
qCritical() << "LINE" << __LINE__ << "start" << start_parking_time.toString(Qt::ISODate);
|
||||
|
||||
if (start_parking_time.time() > carryOverStart) {
|
||||
//int const backTime = carryOverStart.secsTo(start_parking_time.time()) / 60;
|
||||
//qCritical() << "LINE" << __LINE__ << "backTime" << backTime;
|
||||
//qCritical() << "LINE" << __LINE__ << "backTime + dur" << backTime + carryOverDuration;
|
||||
start_parking_time.setTime(carryOverStart);
|
||||
start_parking_time = start_parking_time.addSecs(carryOverDuration * 60);
|
||||
}
|
||||
|
||||
end_parking_time = start_parking_time.addSecs(netto_parking_time*60);
|
||||
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
// << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
|
||||
qCritical() << "LINE" << __LINE__ << "netto" << netto_parking_time;
|
||||
qCritical() << "LINE" << __LINE__ << "start" << start_parking_time.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< "end_parking_time" << end_parking_time.toString(Qt::ISODate);
|
||||
|
||||
} else {
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
cost = Calculator::GetInstance().GetCostFromDuration(
|
||||
tariff,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
@@ -607,15 +766,16 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
netto_parking_time, // minutes, netto
|
||||
false, prepaid);
|
||||
}
|
||||
// qCritical() << __func__ << __LINE__;
|
||||
double minCost = tariff->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||
if (cost < minCost) {
|
||||
calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost).arg(cost));
|
||||
calcState.setDesc(QString("line=%1 minCost=%2, cost=%3").arg(__LINE__).arg(minCost).arg(cost));
|
||||
return calcState.set(CalcState::State::BELOW_MIN_PARKING_PRICE);
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
qCritical() << " end_parking_time: " << end_parking_time;
|
||||
qCritical() << " -> calculated cost (netto): " << cost;
|
||||
qCritical() << __LINE__ << " end_parking_time: " << end_parking_time;
|
||||
qCritical() << __LINE__ << " -> calculated cost (netto): " << cost;
|
||||
|
||||
price->brutto = price->vat = price->vat_percentage = 0;
|
||||
price->units = cost;
|
||||
@@ -632,7 +792,8 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
parking_tariff_t *tariff,
|
||||
time_t start_parking_time,
|
||||
double price,
|
||||
QString &duration) {
|
||||
QString &duration,
|
||||
PermitType permitType) {
|
||||
CalcState calcState;
|
||||
QDate const d(1970, 1, 1);
|
||||
QTime const t(0, 0, 0);
|
||||
@@ -641,15 +802,25 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
if (start.isValid()) {
|
||||
QString cs = start.toString(Qt::ISODate);
|
||||
|
||||
bool prepaid = true;
|
||||
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||
int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||
if (prepaid_option_id == 2) { // see tariff03.json for 502: 2 means no prepaid-option
|
||||
prepaid = false;
|
||||
}
|
||||
bool const nextDay = false;
|
||||
|
||||
// DEBUG
|
||||
qCritical() << "compute_duration_for_parking_ticket(): ";
|
||||
qCritical() << "compute_duration_for_parking_ticket(1): ";
|
||||
qCritical() << " payment option index: " << paymentOptionIndex;
|
||||
qCritical() << " prepaid: " << prepaid;
|
||||
qCritical() << " start (cs): " << cs;
|
||||
qCritical() << " price: " << price;
|
||||
|
||||
duration = Calculator::GetInstance().GetDurationFromCost(tariff,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id,
|
||||
cs.toLocal8Bit().constData(),
|
||||
price, false, true).c_str();
|
||||
price, permitType, nextDay, prepaid).c_str();
|
||||
QDateTime d = QDateTime::fromString(duration, Qt::ISODate);
|
||||
if (!d.isValid()) {
|
||||
calcState.setDesc(QString("ticketEndTime=%1").arg(duration));
|
||||
@@ -666,16 +837,32 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
parking_tariff_t *tariff,
|
||||
QDateTime const &start_parking_time,
|
||||
double price,
|
||||
QDateTime &ticketEndTime)
|
||||
QDateTime &ticketEndTime,
|
||||
PermitType permitType)
|
||||
{
|
||||
CalcState calcState;
|
||||
|
||||
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;
|
||||
}
|
||||
bool const nextDay = false;
|
||||
|
||||
// DEBUG
|
||||
qCritical() << "compute_duration_for_parking_ticket(2): ";
|
||||
qCritical() << " payment option index: " << paymentOptionIndex;
|
||||
qCritical() << " prepaid: " << prepaid;
|
||||
qCritical() << " price: " << price;
|
||||
|
||||
if (start_parking_time.isValid()) {
|
||||
QString cs = start_parking_time.toString(Qt::ISODate);
|
||||
QString endTime = Calculator::GetInstance().GetDurationFromCost(
|
||||
tariff,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
cs.toLocal8Bit().constData(),
|
||||
price, false, true).c_str();
|
||||
price, permitType, nextDay, prepaid).c_str();
|
||||
|
||||
if (endTime == CalcState::SUCCESS) {
|
||||
calcState.setDesc(QString("SUCCESS"));
|
||||
@@ -754,7 +941,10 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
||||
return calcState.set(CalcState::State::SUCCESS);
|
||||
}
|
||||
|
||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff, QDateTime const &start_parking_time, QDateTime &ticketEndTime)
|
||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff,
|
||||
QDateTime const &start_parking_time,
|
||||
QDateTime &ticketEndTime,
|
||||
PermitType PermitType)
|
||||
{
|
||||
CalcState calcState;
|
||||
if (start_parking_time.isValid()) {
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
#include <QDateTime>
|
||||
#include <QScopedArrayPointer>
|
||||
#include <QDebug>
|
||||
@@ -121,6 +122,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
uint8_t payment_option,
|
||||
char const *startDatetimePassed, // given in local time
|
||||
double cost,
|
||||
PermitType permitType,
|
||||
bool nextDay,
|
||||
bool prepaid)
|
||||
{
|
||||
@@ -128,14 +130,108 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
Q_UNUSED(nextDay);
|
||||
|
||||
// Get input date
|
||||
QDateTime inputDate = QDateTime::fromString(startDatetimePassed,Qt::ISODate);
|
||||
QDateTime inputDate = QDateTime::fromString(startDatetimePassed, Qt::ISODate);
|
||||
inputDate.setTime(QTime(inputDate.time().hour(), inputDate.time().minute(), 0));
|
||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
int const paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get());
|
||||
|
||||
//qCritical() << DBG_HEADER << " start" << inputDate.toString(Qt::ISODate);
|
||||
//qCritical() << DBG_HEADER << "paymentMethodId" << static_cast<int>(paymentMethodId);
|
||||
qCritical() << DBG_HEADER << " start:" << inputDate.toString(Qt::ISODate);
|
||||
qCritical() << DBG_HEADER << " option index:" << paymentOptionIndex;
|
||||
qCritical() << DBG_HEADER << "paymentMethodId:" << static_cast<int>(paymentMethodId);
|
||||
qCritical() << DBG_HEADER << " prepaid:" << prepaid;
|
||||
qCritical() << DBG_HEADER << " cost (price):" << cost;
|
||||
|
||||
Calculator::GetInstance().GetTimeSteps(cfg, 0, inputDate);
|
||||
QList<int> tsteps = Calculator::GetInstance().GetTimeSteps(cfg, paymentOptionIndex, inputDate);
|
||||
qCritical() << DBG_HEADER << " time steps:" << tsteps;
|
||||
|
||||
if (paymentMethodId == PaymentMethod::Degressive) {
|
||||
|
||||
if (static_cast<int>(cost) < cfg->getPaymentOptions(paymentOptionIndex).pop_min_price) {
|
||||
// minimal price is set by GetTimeSteps()
|
||||
qCritical() << DBG_HEADER << " provided price (cost):" << cost;
|
||||
qCritical() << DBG_HEADER << "configured minimal price:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||
return CalcState::BELOW_MIN_PARKING_PRICE.toStdString();
|
||||
}
|
||||
|
||||
if (prepaid == false) {
|
||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
|
||||
int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
|
||||
|
||||
// qCritical() << DBG_HEADER << " pop id:" << pop_id;
|
||||
|
||||
int price = 0;
|
||||
int new_price = 0;
|
||||
int durationInMinutes = 0;
|
||||
uint32_t duration_previous = 0;
|
||||
// bool found = false;
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
int const pra_price = itr->second.pra_price;
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
if (pop_accumulate_prices) {
|
||||
price += pra_price;
|
||||
} else {
|
||||
price = pra_price;
|
||||
}
|
||||
|
||||
//qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
|
||||
//qCritical() << DBG_HEADER << " duration id" << durationId;
|
||||
|
||||
auto search = cfg->Duration.find(durationId);
|
||||
if (search != cfg->Duration.end()) {
|
||||
// found now the duration in minutes
|
||||
// check if we are still inside the working-time-range
|
||||
ATBDuration duration = search->second;
|
||||
|
||||
if (pop_accumulate_prices) {
|
||||
uint32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||
|
||||
new_price += pra_price;
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") old price" << price << ", new_price:" << new_price;
|
||||
if (new_price <= cost) {
|
||||
duration_previous = durationUnit;
|
||||
if (pop_accumulate_durations) {
|
||||
durationInMinutes += durationUnit;
|
||||
}
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration in minutes" << durationInMinutes;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") old price" << price << ", new_price:" << new_price;
|
||||
} else {
|
||||
//found = true;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration in minutes" << durationInMinutes;
|
||||
QDateTime d(inputDate.addSecs(duration_previous * 60));
|
||||
|
||||
qCritical() << DBG_HEADER << " provided price (cost):" << cost;
|
||||
qCritical() << DBG_HEADER << " computed time for price (minutes):" << duration_previous;
|
||||
qCritical() << DBG_HEADER << "configured minimal parking time (minutes):" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||
|
||||
if (duration_previous < cfg->getPaymentOptions(paymentOptionIndex).pop_min_time) {
|
||||
return CalcState::BELOW_MIN_PARKING_TIME.toStdString(); // minimal parking time is set by GetTimeSteps()
|
||||
}
|
||||
return d.toString(Qt::ISODate).toStdString();
|
||||
}
|
||||
}
|
||||
|
||||
if ((double)price == cost) {
|
||||
QDateTime d(inputDate.addSecs(durationInMinutes * 60));
|
||||
|
||||
QString const durationStr(d.toString(Qt::ISODate));
|
||||
|
||||
qCritical() << DBG_HEADER << " duration in minutes:" << durationInMinutes;
|
||||
qCritical() << DBG_HEADER << " provided price (cost):" << cost;
|
||||
qCritical() << DBG_HEADER << " duration for price:" << durationStr;
|
||||
|
||||
return durationStr.toStdString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
qCritical() << DBG_HEADER << " TODO";
|
||||
}
|
||||
} else
|
||||
if (paymentMethodId == PaymentMethod::Steps) {
|
||||
if (tariffIs24_7(cfg)) {
|
||||
// use tariff with structure as for instance Schoenau, Koenigsee:
|
||||
@@ -152,15 +248,14 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: man braucht den richtigen Index
|
||||
int paymentOptionIndex = 0;
|
||||
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;
|
||||
|
||||
if (cost > pop_max_price) {
|
||||
cost = pop_max_price;
|
||||
qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
|
||||
return CalcState::OVERPAID.toStdString();
|
||||
//return CalcState::OVERPAID.toStdString();
|
||||
}
|
||||
|
||||
if (cost < pop_min_price) {
|
||||
@@ -178,7 +273,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
// in this case, adapt inputDate accordingly.
|
||||
|
||||
|
||||
// #define DEBUG_GET_DURATION_FROM_COST 1
|
||||
#define DEBUG_GET_DURATION_FROM_COST 0
|
||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||
qCritical() << DBG_HEADER << "PRE-PAID-OPTION: ADAPT-INPUT-DATE" << inputDate.toString(Qt::ISODate);
|
||||
#endif
|
||||
@@ -228,15 +323,21 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "no prepaid";
|
||||
}
|
||||
|
||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||
qCritical() << DBG_HEADER << "(ADAPTED) INPUT-DATE" << inputDate.toString(Qt::ISODate);
|
||||
#endif
|
||||
//qCritical() << __func__ << __LINE__;
|
||||
|
||||
// inputDate is now located in a valid operational-working-range
|
||||
// find this working-time-range
|
||||
int pwd_period_day_in_week_id = inputDate.date().dayOfWeek();
|
||||
//qCritical() << __func__ << __LINE__ << pwd_period_day_in_week_id;
|
||||
//qCritical() << __func__ << __LINE__ << cfg->WeekDaysWorktime.count(pwd_period_day_in_week_id);
|
||||
|
||||
if (cfg->WeekDaysWorktime.count(pwd_period_day_in_week_id) == 0) {
|
||||
qCritical() << DBG_HEADER
|
||||
<< "ERROR" << inputDate.toString(Qt::ISODate)
|
||||
@@ -244,12 +345,17 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
return "";
|
||||
}
|
||||
|
||||
//qCritical() << __func__ << __LINE__;
|
||||
|
||||
QTime current_working_time_from;
|
||||
QTime current_working_time_to;
|
||||
|
||||
for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(pwd_period_day_in_week_id); iter != rEnd; ++iter) {
|
||||
QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
|
||||
QTime pwd_time_to = QTime::fromString(QString::fromStdString(iter->second.pwd_time_to), Qt::ISODate);
|
||||
//qCritical() << __func__ << pwd_time_from.toString(Qt::ISODate);
|
||||
//qCritical() << __func__ << pwd_time_to.toString(Qt::ISODate);
|
||||
//qCritical() << __func__ << inputDate.toString(Qt::ISODate);
|
||||
if (pwd_time_from <= inputDate.time() && inputDate.time() <= pwd_time_to) {
|
||||
current_working_time_from = pwd_time_from;
|
||||
current_working_time_to = pwd_time_to;
|
||||
@@ -269,11 +375,14 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
qCritical() << DBG_HEADER << " CURRENT WORKING-TIME-TO" << current_working_time_to.toString(Qt::ISODate);
|
||||
#endif
|
||||
|
||||
|
||||
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
|
||||
int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
|
||||
// int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
|
||||
int price = 0;
|
||||
int new_price = 0;
|
||||
int durationInSecs = 0;
|
||||
uint32_t duration_previous = 0;
|
||||
bool found = false;
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
int const pra_price = itr->second.pra_price;
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
@@ -283,18 +392,33 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
price = pra_price;
|
||||
}
|
||||
|
||||
//qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
|
||||
// qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
|
||||
|
||||
auto search = cfg->Duration.find(durationId);
|
||||
if (search != cfg->Duration.end()) {
|
||||
// found now the duration in minutes
|
||||
// check if we are still inside the working-time-range
|
||||
ATBDuration duration = search->second;
|
||||
//if (pop_accumulate_durations) {
|
||||
// durationInSecs += duration.pun_duration * 60;
|
||||
//} else {
|
||||
durationInSecs = duration.pun_duration * 60;
|
||||
//}
|
||||
|
||||
if (pop_accumulate_prices) {
|
||||
uint32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||
|
||||
new_price += pra_price;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX price:" << price;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") YYYYYY new_price:" << new_price;
|
||||
if (new_price <= cost) {
|
||||
duration_previous = durationUnit;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") ZZZZZZ duration_previous" << duration_previous;
|
||||
} else {
|
||||
found = true;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") WWWWWW duration_previous" << duration_previous;
|
||||
QString s = inputDate.toString(Qt::ISODate);
|
||||
QDateTime d(QDateTime::fromString(s, Qt::ISODate));
|
||||
d = d.addSecs(duration_previous * 60);
|
||||
//qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << d;
|
||||
return d.toString(Qt::ISODate).toStdString();
|
||||
}
|
||||
}
|
||||
|
||||
if ((double)price == cost) {
|
||||
QDateTime current_working_date_time_to = inputDate;
|
||||
@@ -345,13 +469,25 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
}
|
||||
}
|
||||
|
||||
//qCritical() << DBG_HEADER << "DAYS" << days;
|
||||
//qCritical() << DBG_HEADER << "DURATION-SECS" << durationInSecs;
|
||||
//qCritical() << DBG_HEADER << "DURATION-MINS" << durationInSecs / 60;
|
||||
|
||||
QDateTime upper = inputDate.addDays(days);
|
||||
upper.setTime(next_working_time_from);
|
||||
|
||||
//qCritical() << DBG_HEADER << "UPPER" << upper.toString(Qt::ISODate);
|
||||
|
||||
QDateTime lower = inputDate;
|
||||
lower.setTime(current_working_time_to);
|
||||
|
||||
inputDate = inputDate.addSecs(lower.secsTo(upper) + durationInSecs);
|
||||
//qCritical() << DBG_HEADER << "LOWER" << lower.toString(Qt::ISODate);
|
||||
|
||||
// inputDate = inputDate.addSecs(lower.secsTo(upper));
|
||||
|
||||
//qCritical() << DBG_HEADER << "NEW INPUT" << inputDate.toString(Qt::ISODate);
|
||||
|
||||
inputDate = inputDate.addSecs(durationInSecs);
|
||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||
qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate);
|
||||
#endif
|
||||
@@ -388,6 +524,11 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
|
||||
return s.toStdString();
|
||||
} // if ((double)price == cost) {
|
||||
else {
|
||||
//qCritical() << DBG_HEADER;
|
||||
}
|
||||
} else {
|
||||
//qCritical() << __func__ << __LINE__;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -841,8 +982,11 @@ uint32_t Calculator::GetCostFromDuration(Configuration *cfg,
|
||||
int paymentOptionIndex) const {
|
||||
// for instance, a tariff as used in Schoenau, Koenigssee: only steps, no
|
||||
// special days, nonstop.
|
||||
//qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
|
||||
|
||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
if (paymentMethodId == PaymentMethod::Steps) {
|
||||
if (paymentMethodId == PaymentMethod::Steps ||
|
||||
paymentMethodId == PaymentMethod::Degressive) {
|
||||
QDateTime const end = start.addSecs(timeStepInMinutes*60);
|
||||
return GetCostFromDuration(cfg, start, end, paymentOptionIndex);
|
||||
}
|
||||
@@ -854,8 +998,15 @@ uint32_t Calculator::GetCostFromDuration(Configuration * cfg,
|
||||
QDateTime const &end,
|
||||
int paymentOptionIndex) const {
|
||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
if (paymentMethodId == PaymentMethod::Steps) {
|
||||
|
||||
//qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
|
||||
|
||||
if (paymentMethodId == PaymentMethod::Steps ||
|
||||
paymentMethodId == PaymentMethod::Degressive) {
|
||||
int const timeStepInMinutes = start.secsTo(end) / 60;
|
||||
|
||||
qCritical() << DBG_HEADER << "timeStepInMinutes" << timeStepInMinutes << start.toString(Qt::ISODate);
|
||||
|
||||
return GetPriceForTimeStep(cfg, timeStepInMinutes, paymentOptionIndex);
|
||||
}
|
||||
return 0;
|
||||
@@ -866,8 +1017,8 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
|
||||
int netto_parking_time,
|
||||
int paymentOptionIndex) {
|
||||
|
||||
qCritical() << DBG_HEADER << "start" << start.toString(Qt::ISODate)
|
||||
<< "paymentOptionIndex" << paymentOptionIndex;
|
||||
//qCritical() << DBG_HEADER << "start" << start.toString(Qt::ISODate)
|
||||
// << "paymentOptionIndex" << paymentOptionIndex;
|
||||
|
||||
// TODO: wieder entfernen
|
||||
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED", QTime(), QTime());
|
||||
@@ -1239,23 +1390,25 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
|
||||
QDateTime &start_datetime,
|
||||
QDateTime &end_datetime,
|
||||
int durationMinutes,
|
||||
PermitType permitType,
|
||||
bool nextDay,
|
||||
bool prepaid) {
|
||||
Q_UNUSED(payment_option);
|
||||
Q_UNUSED(nextDay);
|
||||
|
||||
int const paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get());
|
||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
if (paymentMethodId == PaymentMethod::Steps) {
|
||||
if (tariffIs24_7(cfg)) {
|
||||
end_datetime = start_datetime.addSecs(durationMinutes*60);
|
||||
return GetCostFromDuration(cfg, start_datetime, end_datetime);
|
||||
return GetCostFromDuration(cfg, start_datetime, end_datetime, paymentOptionIndex);
|
||||
} else {
|
||||
if (Utilities::IsYearPeriodActive(cfg, start_datetime)) {
|
||||
if (!prepaid) {
|
||||
CalcState cs = isParkingAllowed(cfg, start_datetime);
|
||||
if (cs) {
|
||||
end_datetime = start_datetime.addSecs(durationMinutes*60);
|
||||
double cost = GetCostFromDuration(cfg, start_datetime, end_datetime);
|
||||
double cost = GetCostFromDuration(cfg, start_datetime, end_datetime, paymentOptionIndex);
|
||||
end_datetime = start_datetime;
|
||||
end_datetime.setTime(cs.getAllowedTimeRange().getTimeUntil());
|
||||
return cost;
|
||||
@@ -2130,9 +2283,6 @@ QList<int> Calculator::GetPriceSteps(Configuration * /*cfg*/) const {
|
||||
QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
QDateTime const &s) const {
|
||||
|
||||
// TEST
|
||||
// paymentOptionIndex = 1;
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
|
||||
}
|
||||
@@ -2147,26 +2297,31 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
m_timeSteps[paymentOptionIndex].clear();
|
||||
|
||||
} else {
|
||||
// int diff = paymentOp m_timeSteps.size()
|
||||
while (m_timeSteps.size() <= paymentOptionIndex) {
|
||||
m_timeSteps.push_back(QList<int>());
|
||||
}
|
||||
}
|
||||
|
||||
QDateTime start = s;
|
||||
start.setTime(QTime(s.time().hour(), s.time().minute(), 0));
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
|
||||
}
|
||||
|
||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
|
||||
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
||||
int const pop_time_step_config = cfg->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
|
||||
int const pop_prepaid_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
|
||||
|
||||
static PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start parking time:" << start.toString(Qt::ISODate);
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start parking time:" << start.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step configuration:" << pop_time_step_config;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment method id:" << static_cast<int>(paymentMethodId);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") time step config:" << pop_time_step_config;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid option id:" << pop_prepaid_option_id;
|
||||
}
|
||||
|
||||
@@ -2179,6 +2334,108 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
int const step = Utilities::getTimeRangeStep(cfg, id, paymentMethodId);
|
||||
m_timeSteps[paymentOptionIndex].append(step);
|
||||
}
|
||||
} else
|
||||
if (paymentMethodId == PaymentMethod::Degressive) { // e.g. fuchs, valser alm (fane) (502)
|
||||
// with growing time, the price goes down
|
||||
// for instance: until 13.59: price 8, from 14:00: price 5, then for the next day: 8
|
||||
// for the following days: 8 euros
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") degressive:";
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
|
||||
m_timeSteps[paymentOptionIndex].clear();
|
||||
|
||||
// lookup pop_next_id in worktimes;
|
||||
std::optional<QVector<ATBWeekDaysWorktime>> const &w = cfg->getAllWeekDayWorkTimes();
|
||||
if (w.has_value()) {
|
||||
QVector<ATBWeekDaysWorktime> const &vec = w.value();
|
||||
|
||||
//if (pop_carry_over == false) {
|
||||
for (int i = 1; i <= vec.size(); ++i) {
|
||||
QTime const &from = QTime::fromString(QString::fromStdString(vec[i-1].pwd_time_from), Qt::ISODate);
|
||||
QString const &toStr = QString::fromStdString(vec[i-1].pwd_time_to);
|
||||
QTime const &to = QTime::fromString(toStr, Qt::ISODate);
|
||||
|
||||
int weekDayId = vec[i-1].pwd_period_day_in_week_id;
|
||||
if (start.date().dayOfWeek() == weekDayId) {
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << weekDayId;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") from" << from.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") to" << to.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << start.toString(Qt::ISODate);
|
||||
}
|
||||
|
||||
if (start.time() >= from && start.time() < to) {
|
||||
int runtimeInMinutes = (start.time().secsTo(to) / 60);
|
||||
if (to.hour() == 23 && to.minute() == 59) {
|
||||
runtimeInMinutes += 1;
|
||||
}
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes" << runtimeInMinutes;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") index" << paymentOptionIndex;
|
||||
}
|
||||
// m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
|
||||
|
||||
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes;
|
||||
|
||||
int pop_id = vec[i-1].pwd_pop_id;
|
||||
// int pwd_id = vec[i-1].pwd_id;
|
||||
// int pwd_next_id = vec[i-1].pwd_next_id;
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
|
||||
}
|
||||
|
||||
int price = -1;
|
||||
int durationId = -1;
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
durationId = itr->second.pra_payment_unit_id;
|
||||
|
||||
price = itr->second.pra_price;
|
||||
|
||||
auto search = cfg->Duration.find(durationId);
|
||||
if (search != cfg->Duration.end()) {
|
||||
ATBDuration duration = search->second;
|
||||
duration.pun_duration = runtimeInMinutes;
|
||||
search->second = duration;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (price >= 0 && durationId >= 0) {
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
|
||||
}
|
||||
|
||||
pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
if (durationId == itr->second.pra_payment_unit_id) {
|
||||
itr->second.pra_price = price;
|
||||
cfg->getPaymentOptions(paymentOptionIndex).pop_min_price = price;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") park min price" << price;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
} // if (start.time() >= from && start.time() < to) {
|
||||
} // if (start.date().dayOfWeek() == weekDayId) {
|
||||
} // for (int i = 1; i <= vec.size(); ++i) {
|
||||
|
||||
m_timeSteps[paymentOptionIndex].clear();
|
||||
int runtimeInMinutes = 0;
|
||||
for (Configuration::TariffDurationType::const_iterator it = cfg->Duration.cbegin();
|
||||
it != cfg->Duration.cend();
|
||||
++it) {
|
||||
runtimeInMinutes += it->second.pun_duration;
|
||||
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
|
||||
}
|
||||
|
||||
//} // if (pop_carry_over == false) {
|
||||
} // if (w.has_value()) {
|
||||
} else {
|
||||
uint16_t timeStepCompensation = 0;
|
||||
|
||||
@@ -2255,10 +2512,10 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
}
|
||||
}
|
||||
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
//if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range from:" << carryOverTimeRangeFrom.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
|
||||
}
|
||||
//}
|
||||
|
||||
m_timeSteps[paymentOptionIndex].clear();
|
||||
|
||||
@@ -2289,6 +2546,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
QDateTime nextTimeStep = start;
|
||||
int runtimeInMinutes = 0;
|
||||
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
|
||||
|
||||
int const pop_truncate_last_interpolation_step = cfg->getPaymentOptions(paymentOptionIndex).pop_truncate_last_interpolation_step;
|
||||
|
||||
// TODO: auslagern
|
||||
@@ -2303,8 +2562,12 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
}
|
||||
}
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
|
||||
// int const price = itr->second.pra_price;
|
||||
|
||||
auto search = cfg->Duration.find(durationId);
|
||||
@@ -2321,11 +2584,14 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
break;
|
||||
}
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
|
||||
|
||||
std::optional<ATBInterpolation> ipolCheck = cfg->getInterpolationType(duration.pun_interpolation_id);
|
||||
if (ipolCheck) {
|
||||
ATBInterpolation interpolation = ipolCheck.value();
|
||||
|
||||
if (duration.pun_interpolation_id == (int)ATBInterpolation::DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_PRICE) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") HIER NICHT";
|
||||
|
||||
interpolation.dynamic_start = start.time();
|
||||
interpolation.dynamic_start.setHMS(start.time().hour(), start.time().minute(), 0);
|
||||
@@ -2342,6 +2608,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
runtimeInMinutes += duration.pun_duration;
|
||||
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
|
||||
|
||||
if (nextTimeStep.time() > carryOverStart) {
|
||||
int const backTime = carryOverStart.secsTo(nextTimeStep.time()) / 60;
|
||||
runtimeInMinutes -= backTime;
|
||||
@@ -2376,15 +2644,45 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
search->second = duration;
|
||||
} else
|
||||
if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
|
||||
#if 0
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (2):" << runtimeInMinutes;
|
||||
|
||||
if (paymentOptionIndex == 1) { // testing TODO: muss in die payment options hinein
|
||||
if (runtimeInMinutes == 0) {
|
||||
if (start.time() < carryOverStart) {
|
||||
runtimeInMinutes = start.time().secsTo(carryOverStart) / 60;
|
||||
duration.pun_duration = runtimeInMinutes;
|
||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||
search->second = duration;
|
||||
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (runtimeInMinutes == 0) {
|
||||
if (start.time() < carryOverStart) {
|
||||
runtimeInMinutes = start.time().secsTo(carryOverStart) / 60;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carryOverStart:" << carryOverStart.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||
duration.pun_duration = runtimeInMinutes;
|
||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||
search->second = duration;
|
||||
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
|
||||
|
||||
QDateTime s = start.addSecs(runtimeInMinutes * 60);
|
||||
int const minutes = s.time().secsTo(carryOverStart) / 60;
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") minutes:" << minutes;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") s:" << s.toString(Qt::ISODate);
|
||||
#if 0
|
||||
if (minutes > 0) {
|
||||
runtimeInMinutes += minutes;
|
||||
previous.pun_duration += minutes;
|
||||
@@ -2397,16 +2695,14 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
}
|
||||
#endif
|
||||
|
||||
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (0):" << runtimeInMinutes;
|
||||
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||
|
||||
runtimeInMinutes += duration.pun_duration;
|
||||
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over start:" << carryOverStart.toString(Qt::ISODate);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") carryOverStart:" << carryOverStart.toString(Qt::ISODate);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
|
||||
|
||||
// TOOO: truncate-flag == false
|
||||
if (nextTimeStep.time() > carryOverStart) {
|
||||
@@ -2415,27 +2711,30 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
nextTimeStep.setTime(carryOverStart);
|
||||
nextTimeStep = nextTimeStep.addSecs((backTime + carryOverDuration) * 60);
|
||||
runtimeInMinutes += (backTime + carryOverDuration);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes:" << runtimeInMinutes;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
|
||||
} else
|
||||
if (nextTimeStep.time() < carryOverStart) {
|
||||
int const forwardTime = nextTimeStep.time().secsTo(carryOverStart) / 60;
|
||||
runtimeInMinutes += forwardTime;
|
||||
nextTimeStep.setTime(carryOverStart);
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes:" << runtimeInMinutes;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep.time():" << nextTimeStep.time().toString(Qt::ISODate);
|
||||
}
|
||||
|
||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (2):" << runtimeInMinutes;
|
||||
}
|
||||
|
||||
duration.pun_duration = runtimeInMinutes;
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
||||
|
||||
// duration.pun_duration = runtimeInMinutes - carryOverDuration;
|
||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||
search->second = duration;
|
||||
} else {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") HIER NICHT";
|
||||
cfg->Duration.erase(search);
|
||||
}
|
||||
}
|
||||
@@ -2492,12 +2791,17 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
||||
|
||||
uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex) const {
|
||||
|
||||
// test
|
||||
// paymentOptionIndex = 1;
|
||||
|
||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
|
||||
|
||||
uint32_t price = 0;
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex" << paymentOptionIndex;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
|
||||
{
|
||||
@@ -2506,7 +2810,11 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
|
||||
|
||||
Q_ASSERT(pun_id == payment_unit_id);
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
|
||||
|
||||
int const pun_duration = cfg->Duration.find(payment_unit_id)->second.pun_duration;
|
||||
//int const pun_duration = cfg->Duration.find(2)->second.pun_duration;
|
||||
if (pop_accumulate_prices) {
|
||||
price += itr->second.pra_price;
|
||||
} else {
|
||||
@@ -2514,10 +2822,13 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
|
||||
}
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << cfg->Duration.find(payment_unit_id)->second.pun_id;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << pun_duration;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
|
||||
|
||||
if (timeStep == pun_duration) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
|
||||
return price;
|
||||
}
|
||||
}
|
||||
@@ -2527,8 +2838,13 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
|
||||
|
||||
uint32_t Calculator::GetDurationForPrice(Configuration *cfg, int price) const {
|
||||
int const pop_id = cfg->getPaymentOptions().pop_id;
|
||||
int const pop_accumulate_prices = cfg->getPaymentOptions().pop_accumulate_prices;
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") accumulate prices" << pop_accumulate_prices;
|
||||
|
||||
int new_price = 0;
|
||||
uint32_t duration = 0;
|
||||
uint32_t duration_previous = 0;
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
|
||||
{
|
||||
@@ -2544,8 +2860,22 @@ uint32_t Calculator::GetDurationForPrice(Configuration *cfg, int price) const {
|
||||
if (pra_price < price) {
|
||||
duration = durationUnit;
|
||||
}
|
||||
|
||||
if (pop_accumulate_prices) {
|
||||
new_price += pra_price;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pra_price:" << pra_price;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") new_price:" << new_price;
|
||||
if (new_price <= price) {
|
||||
duration_previous = durationUnit;
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
|
||||
} else {
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
|
||||
return duration_previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration" << duration << "for price" << price;
|
||||
return duration;
|
||||
}
|
||||
|
||||
@@ -2657,14 +2987,53 @@ Calculator::GetDailyTicketPrice(Configuration* cfg,
|
||||
}
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::DAY_TICKET: {
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_PKW: {
|
||||
PermitType const permitType(PERMIT_TYPE::DAY_TICKET_PKW);
|
||||
std::optional<ATBPaymentOption> paymentOption = cfg->getPaymentOptionForKey(permitType.get());
|
||||
if (paymentOption) {
|
||||
ATBPaymentOption option = paymentOption.value();
|
||||
int pop_id = option.pop_id;
|
||||
int pop_daily_card_price = option.pop_daily_card_price;
|
||||
qCritical() << "( GetDailyTicketPrice():" << __LINE__ << ")";
|
||||
qCritical() << " PERMIT-TYPE:" << permitType.toString();
|
||||
qCritical() << " option id:" << pop_id;
|
||||
qCritical() << "daily_ticket_card_price:" << pop_daily_card_price;
|
||||
|
||||
price.netto = pop_daily_card_price;
|
||||
value = value.value_or(price);
|
||||
}
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::SZEGED_START:
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::SZEGED_STOP:
|
||||
// [[fallthrough]];
|
||||
case PERMIT_TYPE::INVALID:
|
||||
break;
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_BUS: {
|
||||
} break;
|
||||
case PERMIT_TYPE::DAY_TICKET_CAMPER: {
|
||||
} break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW: {
|
||||
PermitType const permitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
std::optional<ATBPaymentOption> paymentOption = cfg->getPaymentOptionForKey(permitType.get());
|
||||
if (paymentOption) {
|
||||
ATBPaymentOption option = paymentOption.value();
|
||||
int pop_id = option.pop_id;
|
||||
int pop_daily_card_price = option.pop_daily_card_price;
|
||||
qCritical() << "( GetDailyTicketPrice():" << __LINE__ << ")";
|
||||
qCritical() << " PERMIT-TYPE:" << permitType.toString();
|
||||
qCritical() << " option id:" << pop_id;
|
||||
qCritical() << "daily_ticket_card_price:" << pop_daily_card_price;
|
||||
|
||||
price.netto = pop_daily_card_price;
|
||||
value = value.value_or(price);
|
||||
}
|
||||
} break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS: {
|
||||
} break;
|
||||
case PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER: {
|
||||
} break;
|
||||
case PERMIT_TYPE::SZEGED_START: {
|
||||
} break;
|
||||
case PERMIT_TYPE::SZEGED_STOP: {
|
||||
} break;
|
||||
case PERMIT_TYPE::INVALID: {
|
||||
} break;
|
||||
}
|
||||
} else {
|
||||
// for projects which have not defined a daily ticket in their
|
||||
|
@@ -582,6 +582,22 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
this->currentPaymentOptions.last().pop_id = k->value.GetInt();
|
||||
} else if (strcmp(inner_obj_name, "pop_label") == 0) {
|
||||
this->currentPaymentOptions.last().pop_label = k->value.GetString();
|
||||
} else if (strcmp(inner_obj_name, "pop_product_id") == 0) {
|
||||
this->currentPaymentOptions.last().pop_product_id = k->value.GetInt();
|
||||
} else if (strcmp(inner_obj_name, "pop_product_name") == 0) {
|
||||
if (k->value.IsString()) {
|
||||
QString const &s = QString::fromStdString(k->value.GetString());
|
||||
this->currentPaymentOptions.last().pop_product_name = s;
|
||||
}
|
||||
} else if (strcmp(inner_obj_name, "pop_use_only_upto_datetime") == 0) {
|
||||
if (k->value.IsString()) {
|
||||
QString const &s = QString::fromStdString(k->value.GetString());
|
||||
this->currentPaymentOptions.last().pop_use_only_upto_datetime = s;
|
||||
}
|
||||
} else if (strcmp(inner_obj_name, "pop_use_only_for_duration") == 0) {
|
||||
if (k->value.IsInt()) {
|
||||
this->currentPaymentOptions.last().pop_use_only_for_duration = k->value.GetInt();
|
||||
}
|
||||
} 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) {
|
||||
@@ -712,6 +728,8 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
break;*/
|
||||
case MemberType::WeekDaysWorkTimeType:
|
||||
if (strcmp(inner_obj_name, "pwd_id") == 0) WeekDaysWorktime.pwd_id = k->value.GetInt();
|
||||
if (strcmp(inner_obj_name, "pwd_pop_id") == 0) WeekDaysWorktime.pwd_pop_id = k->value.GetInt();
|
||||
if (strcmp(inner_obj_name, "pwd_next_id") == 0) WeekDaysWorktime.pwd_next_id = k->value.GetInt();
|
||||
else if (strcmp(inner_obj_name, "pwd_period_week_day_id") == 0) WeekDaysWorktime.pwd_period_week_day_id = k->value.GetInt();
|
||||
else if (strcmp(inner_obj_name, "pwd_period_day_in_week_id") == 0) WeekDaysWorktime.pwd_period_day_in_week_id = k->value.GetInt();
|
||||
else if (strcmp(inner_obj_name, "pwd_time_from") == 0) WeekDaysWorktime.pwd_time_from = k->value.GetString();
|
||||
@@ -864,7 +882,7 @@ std::optional<QDateTime> Configuration::getInterpolationEnd(QDateTime const &sta
|
||||
ATBInterpolation interpolation = ipolCheck.value();
|
||||
switch (duration.pun_interpolation_id) {
|
||||
case static_cast<int>(ATBInterpolation::NO_INTERPOLATION):
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") NO_INTERPOLATION";
|
||||
break;
|
||||
case static_cast<int>(ATBInterpolation::STATIC_WALLCLOCK_TIME_VALUES):
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
||||
@@ -969,6 +987,9 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
|
||||
for (int opt=0; opt < numOptions; ++opt) {
|
||||
uint64_t const pop_id = getPaymentOptions(opt).pop_id;
|
||||
if (pop_id == (uint64_t)sd.ped_payment_option_id) {
|
||||
|
||||
qCritical() << __func__ << __LINE__ << opt;
|
||||
|
||||
return opt;
|
||||
}
|
||||
}
|
||||
@@ -1008,6 +1029,9 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
|
||||
}
|
||||
|
||||
if ((pop_business_hours & p) == p) {
|
||||
|
||||
qCritical() << __func__ << __LINE__ << opt;
|
||||
|
||||
return opt;
|
||||
}
|
||||
}
|
||||
@@ -1124,6 +1148,41 @@ Configuration::getTariffProductForProductTypeName(QString const &permitTypeName)
|
||||
return value;
|
||||
}
|
||||
|
||||
int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) {
|
||||
|
||||
std::optional<QVector<ATBPaymentOption>> paymentOptions = getPaymentOptionsForAllKeys();
|
||||
if (paymentOptions) {
|
||||
QVector<ATBPaymentOption> const vec = paymentOptions.value();
|
||||
PermitType const p(permitType);
|
||||
|
||||
for (int i = 0; i < vec.size(); ++i) {
|
||||
if (vec[i].pop_product_name == p.toString()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) const {
|
||||
std::optional<QVector<ATBPaymentOption>> paymentOptions = getPaymentOptionsForAllKeys();
|
||||
if (paymentOptions) {
|
||||
|
||||
|
||||
QVector<ATBPaymentOption> const vec = paymentOptions.value();
|
||||
PermitType const p(permitType);
|
||||
|
||||
for (int i = 0; i < vec.size(); ++i) {
|
||||
if (vec[i].pop_product_name == p.toString()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::optional<QVector<ATBTariffProduct>>
|
||||
Configuration::getTariffProductForProductId(PermitType permitType) const {
|
||||
QString permitTypeName(permitType);
|
||||
@@ -1233,6 +1292,65 @@ Configuration::getDailyTicketsForKey(int key) const {
|
||||
return value;
|
||||
}
|
||||
|
||||
std::optional<ATBPaymentOption>
|
||||
Configuration::getPaymentOptionForId(int key) const {
|
||||
ATBPaymentOption option;
|
||||
std::optional<ATBPaymentOption> value;
|
||||
|
||||
for (auto[it, rangeEnd] = this->PaymentOption.equal_range(key); it != rangeEnd; ++it) {
|
||||
value = value.value_or(it->second);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
std::optional<QVector<ATBPaymentOption>>
|
||||
Configuration::getPaymentOptionsForAllKeys() const {
|
||||
QVector<ATBPaymentOption> paymentOptions;
|
||||
std::optional<QVector<ATBPaymentOption>> value;
|
||||
for (std::multimap<int, ATBPaymentOption>::const_iterator it = this->PaymentOption.cbegin();
|
||||
it != this->PaymentOption.cend(); ++it) {
|
||||
paymentOptions.append(it->second);
|
||||
}
|
||||
|
||||
if (paymentOptions.size() > 0) {
|
||||
value = value.value_or(paymentOptions);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// TODO: umbenennen: getPaymentOptionForPermitType
|
||||
std::optional<ATBPaymentOption>
|
||||
Configuration::getPaymentOptionForKey(PERMIT_TYPE permitType) const {
|
||||
return getPaymentOptionForKey(static_cast<int>(permitType));
|
||||
}
|
||||
|
||||
|
||||
// TODO: umbenennen: getPaymentOptionForPermitType
|
||||
std::optional<ATBPaymentOption>
|
||||
Configuration::getPaymentOptionForKey(int permitType) const {
|
||||
std::optional<ATBPaymentOption> value;
|
||||
|
||||
for (std::multimap<int, ATBPaymentOption>::const_iterator it = this->PaymentOption.cbegin();
|
||||
it != this->PaymentOption.cend(); ++it) {
|
||||
ATBPaymentOption const &paymentOption = it->second;
|
||||
if (paymentOption.pop_product_id == permitType) {
|
||||
value = value.value_or(paymentOption);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// TODO: umbenennen: getPaymentOptionForPermitType
|
||||
std::optional<ATBPaymentOption>
|
||||
Configuration::getPaymentOptionForKey(QString const &permitTypeStr) const {
|
||||
PERMIT_TYPE permitType = PermitType::toPermitType(permitTypeStr);
|
||||
return getPaymentOptionForKey(static_cast<int>(permitType));
|
||||
}
|
||||
|
||||
std::optional<QVector<ATBPaymentRate>>
|
||||
Configuration::getPaymentRateForAllKeys() const {
|
||||
QVector<ATBPaymentRate> paymentRates;
|
||||
@@ -1282,6 +1400,25 @@ Configuration::getCustomerForType(ATBCustomer::CustomerType customerType) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<QVector<ATBWeekDaysWorktime>>
|
||||
Configuration::getAllWeekDayWorkTimes() {
|
||||
QVector<ATBWeekDaysWorktime> worktimes;
|
||||
std::optional<QVector<ATBWeekDaysWorktime>> value;
|
||||
|
||||
worktimes.clear();
|
||||
|
||||
for (std::multimap<int, ATBWeekDaysWorktime>::const_iterator it = this->WeekDaysWorktime.cbegin();
|
||||
it != this->WeekDaysWorktime.cend(); ++it) {
|
||||
worktimes.append(it->second);
|
||||
}
|
||||
|
||||
if (worktimes.size() > 0) {
|
||||
value = value.value_or(worktimes);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
std::optional<ATBWeekDaysWorktime>
|
||||
Configuration::getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek) {
|
||||
ATBWeekDaysWorktime worktime;
|
||||
|
214
main/main.cpp
214
main/main.cpp
@@ -49,9 +49,9 @@ extern "C" char* strptime(const char* s,
|
||||
#define NEUHAUSER_STOCKERAU (0)
|
||||
#define KLEIPEDA_LITAUEN (0)
|
||||
#define SEXTEN (0)
|
||||
#define SCHNALS_LEITER_KIRCHL (1)
|
||||
#define SCHNALS_LEITER_KIRCHL (0)
|
||||
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
|
||||
#define VALSER_ALM (0)
|
||||
#define VALSER_ALM (1)
|
||||
|
||||
#if NEUHAUSER_KIRCHDORF==1
|
||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||
@@ -738,10 +738,11 @@ int main() {
|
||||
}
|
||||
|
||||
#if 1
|
||||
PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
|
||||
for (int i = 200; i <= 200; i += 10) {
|
||||
cost = i;
|
||||
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
|
||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, permitType))) { // return value
|
||||
}
|
||||
|
||||
if (!cs) {
|
||||
@@ -800,7 +801,7 @@ int main() {
|
||||
int pop_max_price;
|
||||
int pop_daily_card_price;
|
||||
|
||||
int zone = 2;
|
||||
int zone = 3;
|
||||
|
||||
if (zone == 1) {
|
||||
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json");
|
||||
@@ -822,6 +823,33 @@ int main() {
|
||||
cout << endl;
|
||||
|
||||
if (isParsed) {
|
||||
|
||||
if (zone == 1 || zone == 3) {
|
||||
/*
|
||||
pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
||||
|
||||
qCritical() << " pop_min_time_pkw: " << pop_min_time;
|
||||
qCritical() << " pop_max_time_pkw: " << pop_max_time;
|
||||
qCritical() << " pop_min_price_pkw: " << pop_min_price;
|
||||
qCritical() << " pop_max_price_pkw: " << pop_max_price;
|
||||
|
||||
pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
|
||||
pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
|
||||
pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
|
||||
pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
|
||||
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
||||
|
||||
qCritical() << " pop_min_time_bus: " << pop_min_time;
|
||||
qCritical() << " pop_max_time_bus: " << pop_max_time;
|
||||
qCritical() << " pop_min_price_bus: " << pop_min_price;
|
||||
qCritical() << " pop_max_price_bus: " << pop_max_price;
|
||||
*/
|
||||
}
|
||||
if (zone == 2) {
|
||||
pop_min_time = get_minimal_parkingtime(&cfg);
|
||||
pop_max_time = get_maximal_parkingtime(&cfg);
|
||||
pop_min_price = get_minimal_parkingprice(&cfg);
|
||||
@@ -832,12 +860,48 @@ int main() {
|
||||
qCritical() << " pop_max_time: " << pop_max_time;
|
||||
qCritical() << " pop_min_price: " << pop_min_price;
|
||||
qCritical() << " pop_max_price: " << pop_max_price;
|
||||
}
|
||||
|
||||
//QDateTime start = QDateTime::currentDateTime();
|
||||
//start.setTime(QTime(12, 0, 0));
|
||||
//QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, start);
|
||||
//qCritical() << "TimeSteps" << timeSteps;
|
||||
//return 0;
|
||||
if (zone == 1) {
|
||||
//int minParkingTime = get_minimal_parkingtime(&cfg);
|
||||
QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
|
||||
qCritical() << timeSteps;
|
||||
int Down = 0;
|
||||
int Up = 1;
|
||||
|
||||
QDateTime const start = QDateTime::currentDateTime();
|
||||
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
|
||||
|
||||
if (paymentOptionIndex < 0) {
|
||||
qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex
|
||||
<< "< 0 for start" << start.toString(Qt::ISODate);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
QSet<uint32_t> const prices_pkw{600, 1200, 1800, 2400, 3000, 3600, 4200};
|
||||
QSet<uint32_t> const prices_bus{3000, 6000, 9000, 12000, 15000, 18000, 21000};
|
||||
|
||||
QDateTime end;
|
||||
CalcState calcState;
|
||||
QDateTime s(QDateTime::currentDateTime());
|
||||
|
||||
s.setTime(QTime(12, 0, 0));
|
||||
|
||||
//calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
// (double)1200, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
||||
//qCritical() << end.toString(Qt::ISODate);
|
||||
//qCritical() << calcState.toString();
|
||||
|
||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
(double)9000, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
|
||||
qCritical() << end.toString(Qt::ISODate);
|
||||
qCritical() << calcState.toString();
|
||||
}
|
||||
|
||||
if (zone == 2) {
|
||||
//int minParkingTime = get_minimal_parkingtime(&cfg);
|
||||
@@ -857,6 +921,16 @@ int main() {
|
||||
|
||||
QSet<uint32_t> const prices{600, 1200, 1800, 2400, 3000, 3600, 4200};
|
||||
|
||||
QDateTime end;
|
||||
CalcState calcState;
|
||||
QDateTime s(QDateTime::currentDateTime());
|
||||
|
||||
s.setTime(QTime(18, 0, 0));
|
||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
(double)600, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
||||
qCritical() << end.toString(Qt::ISODate);
|
||||
qCritical() << calcState.toString();
|
||||
#if 0
|
||||
|
||||
for (int i=0; i<timeSteps.size(); ++i) {
|
||||
int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
|
||||
@@ -881,91 +955,65 @@ int main() {
|
||||
<< "(price so far:" << price << ")";
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (zone == 3) {
|
||||
int price;
|
||||
QDateTime productStart;
|
||||
QDateTime productEnd;
|
||||
QDateTime start = QDateTime::currentDateTime();
|
||||
//QDateTime xx(QDateTime::fromString("2024-07-31T00:00:00", Qt::ISODate));
|
||||
//xx = xx.addSecs(-60); // --> "2024-07-30T23:59:00"
|
||||
//qCritical() << xx.toString(Qt::ISODate);
|
||||
|
||||
#if 0
|
||||
start.setTime(QTime(0, 0, 0));
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start);
|
||||
qCritical() << QString("line=%1 price (%2) :")
|
||||
.arg(__LINE__)
|
||||
.arg(start.time().toString(Qt::ISODate)) << price;
|
||||
//QDateTime s(QDateTime::currentDateTime());
|
||||
//s.setTime(QTime(12, 0, 0));
|
||||
//QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, s);
|
||||
//qCritical() << timeSteps;
|
||||
int Down = 0;
|
||||
int Up = 1;
|
||||
|
||||
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
||||
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
||||
QDateTime const start = QDateTime::currentDateTime();
|
||||
int paymentOptionIndex = cfg.getPaymentOptionIndex(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||
|
||||
start.setTime(QTime(14, 0, 0));
|
||||
productStart = productEnd = QDateTime();
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||
qCritical() << QString("line=%1 price (%2-%3) :")
|
||||
.arg(__LINE__)
|
||||
.arg(productStart.time().toString(Qt::ISODate))
|
||||
.arg(productEnd.time().toString(Qt::ISODate))
|
||||
<< price;
|
||||
|
||||
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
||||
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__)
|
||||
<< price;
|
||||
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start);
|
||||
qCritical() << QString("line=%1 price:").arg(__LINE__) << price;
|
||||
|
||||
start.setTime(QTime(15, 0, 0));
|
||||
productStart = productEnd = QDateTime();
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||
qCritical() << QString("line=%1 price (%2-%3) :")
|
||||
.arg(__LINE__)
|
||||
.arg(productStart.time().toString(Qt::ISODate))
|
||||
.arg(productEnd.time().toString(Qt::ISODate))
|
||||
<< price;
|
||||
|
||||
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
||||
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
||||
|
||||
start.setTime(QTime(16, 0, 0));
|
||||
productStart = productEnd = QDateTime();
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||
qCritical() << QString("line=%1 price (%2-%3) :")
|
||||
.arg(__LINE__)
|
||||
.arg(productStart.time().toString(Qt::ISODate))
|
||||
.arg(productEnd.time().toString(Qt::ISODate))
|
||||
<< price;
|
||||
|
||||
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
||||
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
||||
|
||||
start.setTime(QTime(17, 0, 0));
|
||||
productStart = productEnd = QDateTime();
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||
qCritical() << QString("line=%1 price (%2-%3) :")
|
||||
.arg(__LINE__)
|
||||
.arg(productStart.time().toString(Qt::ISODate))
|
||||
.arg(productEnd.time().toString(Qt::ISODate))
|
||||
<< price;
|
||||
|
||||
//price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
|
||||
//qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
||||
|
||||
//price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET);
|
||||
//qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
||||
|
||||
#else
|
||||
for (int h = 0; h < 24; ++h) {
|
||||
start.setTime(QTime(h, 0, 0));
|
||||
productStart = productEnd = QDateTime();
|
||||
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||
qCritical() << QString("line=%1 %2 price (%3-%4) :")
|
||||
.arg(__LINE__)
|
||||
.arg(start.time().toString(Qt::ISODate))
|
||||
.arg(productStart.time().toString(Qt::ISODate))
|
||||
.arg(productEnd.time().toString(Qt::ISODate))
|
||||
<< price;
|
||||
if (paymentOptionIndex != 0) {
|
||||
qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex
|
||||
<< "< 0 for start" << start.toString(Qt::ISODate);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
//QSet<uint32_t> const prices1{800, 1600, 2400, 3200, 4000, 4800, 5600};
|
||||
//QSet<uint32_t> const prices2{500, 1600, 2400, 3200, 4000, 4800, 5600};
|
||||
|
||||
QDateTime end;
|
||||
CalcState calcState;
|
||||
|
||||
QDateTime s(QDateTime::currentDateTime());
|
||||
s.setTime(QTime(12, 0, 0));
|
||||
|
||||
int minimal_parking_price = get_minimal_parkingprice(&cfg,
|
||||
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
|
||||
paymentOptionIndex, s);
|
||||
|
||||
qCritical() << "minimal parking price" << minimal_parking_price;
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
(double)minimal_parking_price + i*800,
|
||||
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
||||
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
|
||||
}
|
||||
|
||||
s.setTime(QTime(15, 0, 0));
|
||||
|
||||
minimal_parking_price = get_minimal_parkingprice(&cfg,
|
||||
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
|
||||
paymentOptionIndex, s);
|
||||
|
||||
qCritical() << "minimal parking price" << minimal_parking_price;
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||
(double)minimal_parking_price + i*800,
|
||||
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
||||
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -30,7 +30,9 @@ SOURCES += main.cpp
|
||||
# HEADERS +=
|
||||
|
||||
OTHER_FILES += \
|
||||
/home/linux/customer_505/etc/psa_tariff/tariff01.json
|
||||
/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json \
|
||||
/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json \
|
||||
/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user