Merge remote-tracking branch 'origin/schoenau_23112023'
This commit is contained in:
commit
453ca266a5
@ -32,18 +32,20 @@ public:
|
|||||||
// Daily ticket
|
// Daily ticket
|
||||||
QDateTime GetDailyTicketDuration(Configuration* cfg, const QDateTime start_datetime, uint8_t payment_option, bool carry_over);
|
QDateTime GetDailyTicketDuration(Configuration* cfg, const QDateTime start_datetime, uint8_t payment_option, bool carry_over);
|
||||||
|
|
||||||
|
//
|
||||||
|
// helper function to find time steps for a tariff with PaymentMethod::Steps
|
||||||
|
// (e.g. Schoenau/Koenigsee)
|
||||||
|
//
|
||||||
|
QList<int> GetTimeSteps(Configuration *cfg) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Introduced for PaymentMethod::Steps (e.g. Schoenau)
|
// Introduced for PaymentMethod::Steps (e.g. Schoenau)
|
||||||
// For tariff of following structure: only steps, no special days, nonstop.
|
// For tariff of following structure: only steps, no special days, nonstop.
|
||||||
uint32_t GetCostFromDuration(Configuration const* cfg, QDateTime const &start, quint64 durationMinutes, uint8_t paymentMethod = PaymentMethod::Steps);
|
uint32_t GetCostFromDuration(Configuration *cfg, QDateTime const &start, quint64 durationMinutes) const;
|
||||||
uint32_t GetCostFromDuration(Configuration const* cfg, QDateTime const &start, QDateTime const &end, uint8_t paymentMethod = PaymentMethod::Steps);
|
uint32_t GetCostFromDuration(Configuration *cfg, QDateTime const &start, QDateTime const &end) const;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// helper functions for PaymentMethod::Steps
|
uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep) const;
|
||||||
//
|
uint32_t GetDurationForPrice(Configuration *cfg, int price) const;
|
||||||
QList<int> GetTimeSteps(Configuration const *cfg, int paymentMethod);
|
|
||||||
//
|
|
||||||
uint32_t GetPriceForTimeStep(Configuration const *cfg, uint8_t paymentMethod, int timeStep);
|
|
||||||
};
|
};
|
||||||
|
@ -118,6 +118,15 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
bool nextDay,
|
bool nextDay,
|
||||||
bool prepaid)
|
bool prepaid)
|
||||||
{
|
{
|
||||||
|
// use tariff with structure as for instance Schnau, Koenigsee:
|
||||||
|
// without given YearPeriod, SpecialDays and SpecialDaysWorktime
|
||||||
|
if (cfg->YearPeriod.size() == 0
|
||||||
|
&& cfg->SpecialDays.size() == 0
|
||||||
|
&& cfg->SpecialDaysWorktime.size() == 0)
|
||||||
|
{
|
||||||
|
return QString().setNum(GetDurationForPrice(cfg, price)).toStdString();
|
||||||
|
}
|
||||||
|
|
||||||
// Get input date
|
// Get input date
|
||||||
QDateTime inputDate = QDateTime::fromString(start_datetime,Qt::ISODate);
|
QDateTime inputDate = QDateTime::fromString(start_datetime,Qt::ISODate);
|
||||||
|
|
||||||
@ -341,30 +350,28 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
///
|
///
|
||||||
|
|
||||||
uint32_t Calculator::GetCostFromDuration(Configuration const* cfg,
|
uint32_t Calculator::GetCostFromDuration(Configuration *cfg,
|
||||||
QDateTime const &start,
|
QDateTime const &start,
|
||||||
quint64 timeStepInMinutes,
|
quint64 timeStepInMinutes) const {
|
||||||
uint8_t paymentMethod) {
|
|
||||||
// for instance, a tariff as used in Schoenau, Koenigssee: only steps, no
|
// for instance, a tariff as used in Schoenau, Koenigssee: only steps, no
|
||||||
// special days, nonstop.
|
// special days, nonstop.
|
||||||
if (paymentMethod == PaymentMethod::Steps
|
if (cfg->YearPeriod.size() == 0
|
||||||
&& cfg->SpecialDays.size() == 0
|
&& cfg->SpecialDays.size() == 0
|
||||||
&& cfg->SpecialDaysWorktime.size() == 0) {
|
&& cfg->SpecialDaysWorktime.size() == 0) {
|
||||||
QDateTime const end = start.addSecs(timeStepInMinutes*60);
|
QDateTime const end = start.addSecs(timeStepInMinutes*60);
|
||||||
return GetCostFromDuration(cfg, start, end, paymentMethod);
|
return GetCostFromDuration(cfg, start, end);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Calculator::GetCostFromDuration(Configuration const* cfg,
|
uint32_t Calculator::GetCostFromDuration(Configuration * cfg,
|
||||||
QDateTime const &start,
|
QDateTime const &start,
|
||||||
QDateTime const &end,
|
QDateTime const &end) const {
|
||||||
uint8_t paymentMethod) {
|
if (cfg->YearPeriod.size() == 0
|
||||||
if (paymentMethod == PaymentMethod::Steps
|
|
||||||
&& cfg->SpecialDays.size() == 0
|
&& cfg->SpecialDays.size() == 0
|
||||||
&& cfg->SpecialDaysWorktime.size() == 0) {
|
&& cfg->SpecialDaysWorktime.size() == 0) {
|
||||||
int const timeStepInMinutes = start.secsTo(end) / 60;
|
int const timeStepInMinutes = start.secsTo(end) / 60;
|
||||||
return GetPriceForTimeStep(cfg, paymentMethod, timeStepInMinutes);
|
return GetPriceForTimeStep(cfg, timeStepInMinutes);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -377,12 +384,12 @@ uint32_t Calculator::GetCostFromDuration(Configuration const* cfg,
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_option, const QDateTime start_datetime, QDateTime & end_datetime, double durationMin, bool nextDay, bool prepaid)
|
double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_option, const QDateTime start_datetime, QDateTime & end_datetime, double durationMin, bool nextDay, bool prepaid)
|
||||||
{
|
{
|
||||||
// condition for 'PaymentMethod::Steps' (e.g. 332/Schoenau):
|
if (cfg->YearPeriod.size() == 0
|
||||||
if (cfg->SpecialDays.size() == 0
|
&& cfg->SpecialDays.size() == 0
|
||||||
&& cfg->SpecialDaysWorktime.size() == 0)
|
&& cfg->SpecialDaysWorktime.size() == 0)
|
||||||
{
|
{
|
||||||
end_datetime = start_datetime.addSecs(durationMin*60);
|
end_datetime = start_datetime.addSecs(durationMin*60);
|
||||||
return GetCostFromDuration(cfg, start_datetime, end_datetime, PaymentMethod::Steps);
|
return GetCostFromDuration(cfg, start_datetime, end_datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get input date
|
// Get input date
|
||||||
@ -588,10 +595,10 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
QList<int> Calculator::GetTimeSteps(Configuration const *cfg, int paymentOption) {
|
QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
||||||
QList<int> timeSteps;
|
QList<int> timeSteps;
|
||||||
|
|
||||||
int const pop_id = cfg->PaymentOption.find(paymentOption)->second.pop_id;
|
int const pop_id = cfg->getPaymentOptions().pop_id;
|
||||||
|
|
||||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
|
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
|
||||||
{
|
{
|
||||||
@ -603,9 +610,9 @@ QList<int> Calculator::GetTimeSteps(Configuration const *cfg, int paymentOption)
|
|||||||
return timeSteps;
|
return timeSteps;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Calculator::GetPriceForTimeStep(Configuration const *cfg, uint8_t paymentOption, int timeStep) {
|
uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep) const {
|
||||||
|
|
||||||
int const pop_id = cfg->PaymentOption.find(paymentOption)->second.pop_id;
|
int const pop_id = cfg->getPaymentOptions().pop_id;
|
||||||
|
|
||||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
|
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
|
||||||
{
|
{
|
||||||
@ -616,7 +623,25 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration const *cfg, uint8_t payme
|
|||||||
|
|
||||||
int const pun_duration = cfg->Duration.find(payment_unit_id)->second.pun_duration;
|
int const pun_duration = cfg->Duration.find(payment_unit_id)->second.pun_duration;
|
||||||
if (timeStep == pun_duration) {
|
if (timeStep == pun_duration) {
|
||||||
return (uint32_t)(itr->second.pra_price);
|
return (uint32_t)(itr->second.pra_price);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Calculator::GetDurationForPrice(Configuration *cfg, int price) const {
|
||||||
|
int const pop_id = cfg->getPaymentOptions().pop_id;
|
||||||
|
|
||||||
|
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
|
||||||
|
{
|
||||||
|
int const payment_unit_id = itr->second.pra_payment_unit_id;
|
||||||
|
int const pra_price = cfg->PaymentRate.find(payment_unit_id)->second.pra_price;
|
||||||
|
|
||||||
|
if (price == pra_price) {
|
||||||
|
int const durationId = itr->second.pra_payment_unit_id;
|
||||||
|
int const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||||
|
return durationUnit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user