Compare commits
21 Commits
2.3.99-18
...
fuchs-expe
Author | SHA1 | Date | |
---|---|---|---|
b05950fc37 | |||
1c6c9f934d | |||
9baaca1c80 | |||
18f2895250 | |||
fc78eff0a4 | |||
b303a59964 | |||
77ca6a4736 | |||
8b65bb3e2c | |||
82ca274c45 | |||
75c98c18ad | |||
21534ba153 | |||
8d9119ac83 | |||
da7a3cf67b | |||
449fb163bd | |||
19032349ae | |||
2c2fd3845b | |||
5131892744 | |||
6d6615b81e | |||
eafbfd60c3 | |||
41fc924a7c | |||
cbcf8391b3 |
@@ -27,6 +27,13 @@ class Calculator {
|
|||||||
int netto_parking_time,
|
int netto_parking_time,
|
||||||
int paymentOptionIndex);
|
int paymentOptionIndex);
|
||||||
|
|
||||||
|
int computeBruttoDurationInSecs(Configuration const *cfg,
|
||||||
|
QDateTime const &from,
|
||||||
|
int durationInSecs, bool maxBrutto = false);
|
||||||
|
|
||||||
|
QDateTime computeBruttoDateTime(Configuration const *cfg,
|
||||||
|
QDateTime const &from,
|
||||||
|
int durationInSecs, bool maxBrutto = false);
|
||||||
protected:
|
protected:
|
||||||
explicit Calculator() = default;
|
explicit Calculator() = default;
|
||||||
|
|
||||||
@@ -70,8 +77,7 @@ 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="start_datetime">Date/time of payment to be conducted in ISO8601 format (e.g. 2022-12-25T08:00:00Z)</param>
|
||||||
/// <param name="price"></param>
|
/// <param name="price"></param>
|
||||||
/// <returns>Returns duration in seconds (data type: double)</returns>
|
/// <returns>Returns duration in seconds (data type: double)</returns>
|
||||||
std::string GetDurationFromCost(Configuration* cfg, uint8_t vehicle_type, char const* start_datetime, double price,
|
std::string GetDurationFromCost(Configuration* cfg, uint8_t vehicle_type, char const* start_datetime, double price, PermitType permitType, bool nextDay = false, bool prepaid = false);
|
||||||
PermitType permitType, bool nextDay = false, bool prepaid = false);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets cost from duration in seconds
|
/// Gets cost from duration in seconds
|
||||||
@@ -79,11 +85,10 @@ public:
|
|||||||
/// <param name="tariff_cfg">Pointer to configuration</param>
|
/// <param name="tariff_cfg">Pointer to configuration</param>
|
||||||
/// <param name="vehicle_type">Type of vehicle</param>
|
/// <param name="vehicle_type">Type of vehicle</param>
|
||||||
/// <param name="start_datetime">Date/time of payment to be conducted in ISO8601 format (e.g. 2022-12-25T08:00:00Z) </param>
|
/// <param name="start_datetime">Date/time of payment to be conducted in ISO8601 format (e.g. 2022-12-25T08:00:00Z) </param>
|
||||||
/// <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="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>
|
/// <param name="durationMin">Duration of parking in minutes</param>
|
||||||
/// <returns>Returns cost (data type: double)</returns>
|
/// <returns>Returns cost (data type: double)</returns>
|
||||||
double GetCostFromDuration(Configuration* cfg, uint8_t vehicle_type, QDateTime &start_datetime, QDateTime & end_datetime, int durationMin,
|
double GetCostFromDuration(Configuration* cfg, uint8_t vehicle_type, QDateTime &start_datetime, QDateTime & end_datetime, int durationMin, PermitType permitType, bool nextDay = false, bool prepaid = false);
|
||||||
PermitType permitType, bool nextDay = false, bool prepaid = false);
|
|
||||||
|
|
||||||
// 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);
|
||||||
|
@@ -28,7 +28,6 @@
|
|||||||
#include "tariff_interpolation.h"
|
#include "tariff_interpolation.h"
|
||||||
#include "tariff_prepaid.h"
|
#include "tariff_prepaid.h"
|
||||||
#include "tariff_carryover.h"
|
#include "tariff_carryover.h"
|
||||||
#include "tariff_prepay.h"
|
|
||||||
#include "tariff_permit_type.h"
|
#include "tariff_permit_type.h"
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
@@ -48,7 +47,6 @@ public:
|
|||||||
using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
|
using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
|
||||||
using TariffInterpolationType = std::multimap<int, ATBInterpolation>;
|
using TariffInterpolationType = std::multimap<int, ATBInterpolation>;
|
||||||
using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
|
using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
|
||||||
using TariffPrepayOptionType = std::multimap<int, ATBPrepay>;
|
|
||||||
using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
|
using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
|
||||||
using TariffDurationType = std::multimap<int, ATBDuration>;
|
using TariffDurationType = std::multimap<int, ATBDuration>;
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ public:
|
|||||||
ATBCurrency Currency;
|
ATBCurrency Currency;
|
||||||
ATBDuration duration;
|
ATBDuration duration;
|
||||||
|
|
||||||
TariffDurationType Duration;
|
TariffDurationType Duration;
|
||||||
multimap<int, ATBPaymentMethod> PaymentMethod;
|
multimap<int, ATBPaymentMethod> PaymentMethod;
|
||||||
multimap<int, ATBPaymentRate> PaymentRate;
|
multimap<int, ATBPaymentRate> PaymentRate;
|
||||||
SpecialDaysWorktimeType SpecialDaysWorktime;
|
SpecialDaysWorktimeType SpecialDaysWorktime;
|
||||||
@@ -73,7 +71,6 @@ public:
|
|||||||
TariffProductType TariffProduct;
|
TariffProductType TariffProduct;
|
||||||
TariffInterpolationType TariffInterpolations;
|
TariffInterpolationType TariffInterpolations;
|
||||||
TariffPrepaidType TariffPrepaidOptions;
|
TariffPrepaidType TariffPrepaidOptions;
|
||||||
TariffPrepayOptionType TariffPrepayOptions;
|
|
||||||
TariffCarryOverType TariffCarryOverOptions;
|
TariffCarryOverType TariffCarryOverOptions;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDateTime>
|
|
||||||
|
|
||||||
class ATBDuration
|
class ATBDuration
|
||||||
{
|
{
|
||||||
@@ -13,35 +12,20 @@ public:
|
|||||||
, pun_duration_saved(0)
|
, pun_duration_saved(0)
|
||||||
, pun_duration_min(0)
|
, pun_duration_min(0)
|
||||||
, pun_duration_max(0)
|
, pun_duration_max(0)
|
||||||
, pun_interpolation_id(-1)
|
, pun_interpolation_id(-1) {
|
||||||
, pun_netto(false)
|
|
||||||
, pun_brutto(false)
|
|
||||||
, pun_fixed(false)
|
|
||||||
, pun_mutable(false)
|
|
||||||
, pun_round_to_next_24h_boundary(false)
|
|
||||||
, pun_round_to_prev_24h_boundary(false)
|
|
||||||
, pun_align_with_timepoint(QDateTime())
|
|
||||||
, pun_next_step_correction(0) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
friend QDebug operator<<(QDebug debug, ATBDuration const &td) {
|
friend QDebug operator<<(QDebug debug, ATBDuration const &td) {
|
||||||
QDebugStateSaver saver(debug);
|
QDebugStateSaver saver(debug);
|
||||||
|
|
||||||
debug.nospace()
|
debug.nospace()
|
||||||
<< " pun_id: " << td.pun_id << "\n"
|
<< " pun_id: " << td.pun_id << "\n"
|
||||||
<< " pun_label: " << QString::fromStdString(td.pun_label) << "\n"
|
<< " pun_label: " << QString::fromStdString(td.pun_label) << "\n"
|
||||||
<< " pun_duration: " << td.pun_duration << "\n"
|
<< " pun_duration: " << td.pun_duration << "\n"
|
||||||
<< " pun_duration_saved: " << td.pun_duration_saved << "\n"
|
<< " pun_duration_saved: " << td.pun_duration_saved << "\n"
|
||||||
<< " pun_duration_min: " << td.pun_duration_min << "\n"
|
<< " pun_duration_min: " << td.pun_duration_min << "\n"
|
||||||
<< " pun_duration_max: " << td.pun_duration_max << "\n"
|
<< " pun_duration_max: " << td.pun_duration_max << "\n"
|
||||||
<< " pun_interpolation_id: " << td.pun_interpolation_id << "\n"
|
<< "pun_interpolation_id: " << td.pun_interpolation_id << "\n";
|
||||||
<< " pun_netto: " << td.pun_netto << "\n"
|
|
||||||
<< " pun_brutto: " << td.pun_brutto << "\n"
|
|
||||||
<< " pun_fixed: " << td.pun_fixed << "\n"
|
|
||||||
<< " pun_mutable: " << td.pun_mutable << "\n"
|
|
||||||
<< "pun_round_to_next_24h_boundary: " << td.pun_round_to_next_24h_boundary << "\n"
|
|
||||||
<< "pun_round_to_prev_24h_boundary: " << td.pun_round_to_prev_24h_boundary << "\n"
|
|
||||||
<< " pun_align_with_timepoint: " << td.pun_align_with_timepoint << endl;
|
|
||||||
|
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
@@ -49,16 +33,8 @@ public:
|
|||||||
int pun_id;
|
int pun_id;
|
||||||
std::string pun_label;
|
std::string pun_label;
|
||||||
int pun_duration;
|
int pun_duration;
|
||||||
int pun_duration_saved;
|
int pun_duration_saved;
|
||||||
int pun_duration_min;
|
int pun_duration_min;
|
||||||
int pun_duration_max;
|
int pun_duration_max;
|
||||||
int pun_interpolation_id;
|
int pun_interpolation_id;
|
||||||
bool pun_netto; // the timestep expressed by this duration is a netto timestep
|
|
||||||
bool pun_brutto; // the timestep expressed by this duration is a brutto timestep
|
|
||||||
bool pun_fixed; // the value given in tariff-file is fixed (constant)
|
|
||||||
bool pun_mutable; // the value could change
|
|
||||||
bool pun_round_to_next_24h_boundary;
|
|
||||||
bool pun_round_to_prev_24h_boundary;
|
|
||||||
QDateTime pun_align_with_timepoint;
|
|
||||||
int pun_next_step_correction;
|
|
||||||
};
|
};
|
||||||
|
@@ -13,17 +13,16 @@ enum MemberType
|
|||||||
WeekDaysWorkTimeType = 0x06,
|
WeekDaysWorkTimeType = 0x06,
|
||||||
SpecialDaysWorktimeType = 0x07,
|
SpecialDaysWorktimeType = 0x07,
|
||||||
SpecialDaysType = 0x08,
|
SpecialDaysType = 0x08,
|
||||||
PeriodYearType = 0x09,
|
PeriodYearType = 0x09,
|
||||||
DailyTicketType = 0x0A,
|
DailyTicketType = 0x0A,
|
||||||
CustomerType = 0x0B,
|
CustomerType = 0x0B,
|
||||||
TimeBaseType = 0x0C,
|
TimeBaseType = 0x0C,
|
||||||
TimeRangeType = 0x0D,
|
TimeRangeType = 0x0D,
|
||||||
TimeStepConfigType = 0x0E,
|
TimeStepConfigType = 0x0E,
|
||||||
ProductType = 0x0F,
|
ProductType = 0x0F,
|
||||||
InterpolationType = 0x10,
|
InterpolationType = 0x10,
|
||||||
PrepaidType = 0x11, // deprecated
|
PrepaidType = 0x11,
|
||||||
CarryOverType = 0x12,
|
CarryOverType = 0x12
|
||||||
PrepaidOptionType = 0x13,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MEMBER_TYPE_H_INCLUDED
|
#endif // MEMBER_TYPE_H_INCLUDED
|
||||||
|
@@ -28,7 +28,6 @@ public:
|
|||||||
pop_carry_over = -1;
|
pop_carry_over = -1;
|
||||||
pop_carry_over_option_id = -1;
|
pop_carry_over_option_id = -1;
|
||||||
pop_prepaid_option_id = -1;
|
pop_prepaid_option_id = -1;
|
||||||
pop_prepay_option_id = -1;
|
|
||||||
pop_truncate_last_interpolation_step = false;
|
pop_truncate_last_interpolation_step = false;
|
||||||
pop_accumulate_prices = false;
|
pop_accumulate_prices = false;
|
||||||
pop_accumulate_durations = false;
|
pop_accumulate_durations = false;
|
||||||
@@ -62,8 +61,7 @@ public:
|
|||||||
int pop_carry_over;
|
int pop_carry_over;
|
||||||
int pop_carry_over_option_id;
|
int pop_carry_over_option_id;
|
||||||
bool pop_truncate_last_interpolation_step;
|
bool pop_truncate_last_interpolation_step;
|
||||||
int pop_prepaid_option_id; // deprecated
|
int pop_prepaid_option_id;
|
||||||
int pop_prepay_option_id;
|
|
||||||
bool pop_carry_over_target;
|
bool pop_carry_over_target;
|
||||||
int pop_carry_over_time_range_id;
|
int pop_carry_over_time_range_id;
|
||||||
int pop_carry_over_start_time_range;
|
int pop_carry_over_start_time_range;
|
||||||
|
@@ -1,68 +0,0 @@
|
|||||||
#ifndef TARIFF_PREPAY_H_INCLUDED
|
|
||||||
#define TARIFF_PREPAY_H_INCLUDED
|
|
||||||
|
|
||||||
#include <QTime>
|
|
||||||
|
|
||||||
struct ATBPrepay {
|
|
||||||
struct week {
|
|
||||||
int day;
|
|
||||||
bool prepaid; // yes/no
|
|
||||||
QTime start; // only valid if prepaid == true
|
|
||||||
QTime end;
|
|
||||||
int duration;
|
|
||||||
} prepay[8];
|
|
||||||
|
|
||||||
int id;
|
|
||||||
|
|
||||||
friend QDebug operator<<(QDebug debug, ATBPrepay const &pp) {
|
|
||||||
QDebugStateSaver saver(debug);
|
|
||||||
|
|
||||||
debug.nospace()
|
|
||||||
<< " id:" << pp.id << "\n"
|
|
||||||
<< " **** Monday **** \n"
|
|
||||||
<< " day: " << pp.prepay[(int)Qt::Monday].day << "\n"
|
|
||||||
<< " start: " << pp.prepay[(int)Qt::Monday].start.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " end: " << pp.prepay[(int)Qt::Monday].end.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
|
||||||
<< " prepaid: " << pp.prepay[(int)Qt::Monday].prepaid << "\n"
|
|
||||||
<< " **** Tuesday **** \n"
|
|
||||||
<< " day: " << pp.prepay[(int)Qt::Tuesday].day << "\n"
|
|
||||||
<< " start: " << pp.prepay[(int)Qt::Tuesday].start.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " end: " << pp.prepay[(int)Qt::Tuesday].end.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
|
||||||
<< " prepaid: " << pp.prepay[(int)Qt::Tuesday].prepaid << "\n"
|
|
||||||
<< " **** Wednesday **** \n"
|
|
||||||
<< " day: " << pp.prepay[(int)Qt::Wednesday].day << "\n"
|
|
||||||
<< " start: " << pp.prepay[(int)Qt::Wednesday].start.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " end: " << pp.prepay[(int)Qt::Wednesday].end.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
|
||||||
<< " prepaid: " << pp.prepay[(int)Qt::Wednesday].prepaid << "\n"
|
|
||||||
<< " **** Thursday **** \n"
|
|
||||||
<< " day: " << pp.prepay[(int)Qt::Thursday].day << "\n"
|
|
||||||
<< " start: " << pp.prepay[(int)Qt::Thursday].start.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " end: " << pp.prepay[(int)Qt::Thursday].end.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
|
||||||
<< " prepaid: " << pp.prepay[(int)Qt::Thursday].prepaid << "\n"
|
|
||||||
<< " **** Friday **** \n"
|
|
||||||
<< " day: " << pp.prepay[(int)Qt::Friday].day << "\n"
|
|
||||||
<< " start: " << pp.prepay[(int)Qt::Friday].start.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " end: " << pp.prepay[(int)Qt::Friday].end.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " prepaid: " << pp.prepay[(int)Qt::Friday].prepaid << "\n"
|
|
||||||
<< " **** Saturday **** \n"
|
|
||||||
<< " day: " << pp.prepay[(int)Qt::Saturday].day << "\n"
|
|
||||||
<< " start: " << pp.prepay[(int)Qt::Saturday].start.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " end: " << pp.prepay[(int)Qt::Saturday].end.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
|
||||||
<< " prepaid: " << pp.prepay[(int)Qt::Saturday].prepaid << "\n"
|
|
||||||
<< " **** Sunday **** \n"
|
|
||||||
<< " day: " << pp.prepay[(int)Qt::Sunday].day << "\n"
|
|
||||||
<< " start: " << pp.prepay[(int)Qt::Sunday].start.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " end: " << pp.prepay[(int)Qt::Sunday].end.toString(Qt::ISODate) << "\n"
|
|
||||||
<< " duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
|
|
||||||
<< " prepaid: " << pp.prepay[(int)Qt::Sunday].prepaid << "\n";
|
|
||||||
|
|
||||||
return debug;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TARIFF_CARRYOVER_H_INCLUDED
|
|
@@ -6,7 +6,7 @@
|
|||||||
#include <QDebugStateSaver>
|
#include <QDebugStateSaver>
|
||||||
|
|
||||||
struct ATBTimeStepConfig {
|
struct ATBTimeStepConfig {
|
||||||
enum class TimeStepConfig {STATIC=1, DYNAMIC=2, RECOMPUTE_SOME=3};
|
enum class TimeStepConfig {STATIC=1, DYNAMIC=2};
|
||||||
|
|
||||||
ATBTimeStepConfig() = default;
|
ATBTimeStepConfig() = default;
|
||||||
int tsconfig_id;
|
int tsconfig_id;
|
||||||
|
@@ -38,24 +38,24 @@ SOURCES += \
|
|||||||
src/tariff_global_defines.cpp
|
src/tariff_global_defines.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
include/mobilisis/calculator_functions.h \
|
include/mobilisis/calculator_functions.h \
|
||||||
include/mobilisis/duration.h \
|
include/mobilisis/duration.h \
|
||||||
include/mobilisis/payment_opt.h \
|
include/mobilisis/payment_opt.h \
|
||||||
include/mobilisis/spec_days.h \
|
include/mobilisis/spec_days.h \
|
||||||
include/mobilisis/utilities.h \
|
include/mobilisis/utilities.h \
|
||||||
include/mobilisis/configuration.h \
|
include/mobilisis/configuration.h \
|
||||||
include/mobilisis/member_type.h \
|
include/mobilisis/member_type.h \
|
||||||
include/mobilisis/payment_option.h \
|
include/mobilisis/payment_option.h \
|
||||||
include/mobilisis/spec_days_worktime.h \
|
include/mobilisis/spec_days_worktime.h \
|
||||||
include/mobilisis/weekdays.h \
|
include/mobilisis/weekdays.h \
|
||||||
include/mobilisis/currency.h \
|
include/mobilisis/currency.h \
|
||||||
include/mobilisis/payment_method.h \
|
include/mobilisis/payment_method.h \
|
||||||
include/mobilisis/payment_rate.h \
|
include/mobilisis/payment_rate.h \
|
||||||
include/mobilisis/time_range.h \
|
include/mobilisis/time_range.h \
|
||||||
include/mobilisis/weekdays_worktime.h \
|
include/mobilisis/weekdays_worktime.h \
|
||||||
include/mobilisis/day_of_week.h \
|
include/mobilisis/day_of_week.h \
|
||||||
include/mobilisis/payment_mtd.h \
|
include/mobilisis/payment_mtd.h \
|
||||||
include/mobilisis/period_year.h \
|
include/mobilisis/period_year.h \
|
||||||
include/mobilisis/time_range_header.h \
|
include/mobilisis/time_range_header.h \
|
||||||
include/mobilisis/tariff_cfg.h \
|
include/mobilisis/tariff_cfg.h \
|
||||||
include/mobilisis/tariff_calc.h \
|
include/mobilisis/tariff_calc.h \
|
||||||
@@ -89,14 +89,12 @@ HEADERS += \
|
|||||||
include/mobilisis/tariff_interpolation.h \
|
include/mobilisis/tariff_interpolation.h \
|
||||||
include/mobilisis/tariff_prepaid.h \
|
include/mobilisis/tariff_prepaid.h \
|
||||||
include/mobilisis/tariff_carryover.h \
|
include/mobilisis/tariff_carryover.h \
|
||||||
include/mobilisis/tariff_prepay.h \
|
|
||||||
include/mobilisis/tariff_global_defines.h
|
include/mobilisis/tariff_global_defines.h
|
||||||
|
|
||||||
# OTHER_FILES += src/main.cpp \
|
OTHER_FILES += src/main.cpp \
|
||||||
# ../tariffs/tariff_korneuburg.json \
|
../tariffs/tariff_korneuburg.json \
|
||||||
# ../tariffs/tariff_linsinger_maschinenbau.json \
|
../tariffs/tariff_linsinger_maschinenbau.json \
|
||||||
# ../tariffs/tariff_naz.json \
|
../tariffs/tariff_naz.json
|
||||||
# /home/linux/customer_502/etc/psa_tariff/tariff03.json
|
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
|
@@ -36,10 +36,11 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
|||||||
int paymentOptionIndex) {
|
int paymentOptionIndex) {
|
||||||
int minTime = 0;
|
int minTime = 0;
|
||||||
|
|
||||||
|
qCritical() << __func__ << __LINE__ << "permit" << PermitType(permitType).toString();
|
||||||
|
|
||||||
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||||
|
|
||||||
qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
|
qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
|
||||||
qCritical() << __func__ << __LINE__ << "permit" << PermitType(permitType).toString();
|
|
||||||
|
|
||||||
switch(permitType) {
|
switch(permitType) {
|
||||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||||
@@ -326,8 +327,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
|||||||
switch(permitType) {
|
switch(permitType) {
|
||||||
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
|
||||||
if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
|
if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
|
||||||
maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
|
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||||
} else if (paymentMethodId == PaymentMethod::Degressive) {
|
|
||||||
maxPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
|
maxPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
|
||||||
} else { // PaymentMethod::Linear -> e.g. szeged
|
} else { // PaymentMethod::Linear -> e.g. szeged
|
||||||
int const key = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
int const key = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||||
@@ -717,27 +717,34 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
QDateTime &end_parking_time,
|
QDateTime &end_parking_time,
|
||||||
struct price_t *price,
|
struct price_t *price,
|
||||||
PermitType permitType,
|
PermitType permitType,
|
||||||
bool prepaid)
|
bool prepaid) {
|
||||||
{
|
|
||||||
CalcState calcState;
|
CalcState calcState;
|
||||||
|
|
||||||
QDateTime start_parking_time(start_parking_time_);
|
QDateTime start_parking_time(start_parking_time_);
|
||||||
|
|
||||||
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||||
|
|
||||||
|
QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex, start_parking_time);
|
||||||
|
//Q_UNUSED(tlist);
|
||||||
|
qCritical() << __func__ << __LINE__ << tlist;
|
||||||
|
|
||||||
double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||||
double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
|
double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
|
||||||
|
|
||||||
// DEBUG
|
// netto_parking_time = minMin;
|
||||||
qCritical() << "compute_price_for_parking_ticket() " << endl
|
|
||||||
<< " paymentOptionIndex: " << paymentOptionIndex << endl
|
//if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
<< " start_parking_time: " << start_parking_time << endl
|
qCritical() << "compute_price_for_parking_ticket() " << endl
|
||||||
<< " netto_parking_time: " << netto_parking_time << endl
|
<< " paymentOptionIndex: " << paymentOptionIndex << endl
|
||||||
<< " start + netto: " << start_parking_time.addSecs(netto_parking_time * 60) << endl
|
<< " start_parking_time: " << start_parking_time << endl
|
||||||
<< " minMin: " << minMin << endl
|
<< " start_parking_time_: " << start_parking_time_ << endl
|
||||||
<< " maxMin: " << maxMin
|
<< " netto_parking_time: " << netto_parking_time << endl
|
||||||
<< " prepaid: " << prepaid
|
<< " start + netto: " << start_parking_time.addSecs(netto_parking_time * 60) << endl
|
||||||
<< " permitType: " << permitType.toString();
|
<< " minMin: " << minMin << endl
|
||||||
|
<< " maxMin: " << maxMin << endl
|
||||||
|
<< " prepaid: " << prepaid << endl
|
||||||
|
<< " permitType: " << permitType.toString();
|
||||||
|
//}
|
||||||
|
|
||||||
if (netto_parking_time < 0) {
|
if (netto_parking_time < 0) {
|
||||||
calcState.setDesc(QString("end=%1, start=%2")
|
calcState.setDesc(QString("end=%1, start=%2")
|
||||||
@@ -745,14 +752,17 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
start_parking_time.toString(Qt::ISODate)));
|
start_parking_time.toString(Qt::ISODate)));
|
||||||
return calcState.set(CalcState::State::NEGATIVE_PARKING_TIME);
|
return calcState.set(CalcState::State::NEGATIVE_PARKING_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (netto_parking_time > maxMin) {
|
if (netto_parking_time > maxMin) {
|
||||||
calcState.setDesc(QString("duration=%1, maxMin=%2").arg(netto_parking_time).arg(maxMin));
|
calcState.setDesc(QString("duration=%1, maxMin=%2").arg(netto_parking_time).arg(maxMin));
|
||||||
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
|
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (netto_parking_time < minMin) {
|
if (netto_parking_time < minMin) {
|
||||||
calcState.setDesc(QString("duration=%1, minMin=%2").arg(netto_parking_time).arg(minMin));
|
calcState.setDesc(QString("duration=%1, minMin=%2").arg(netto_parking_time).arg(minMin));
|
||||||
return calcState.set(CalcState::State::BELOW_MIN_PARKING_TIME);
|
return calcState.set(CalcState::State::BELOW_MIN_PARKING_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (netto_parking_time == 0) {
|
if (netto_parking_time == 0) {
|
||||||
return calcState.set(CalcState::State::SUCCESS);
|
return calcState.set(CalcState::State::SUCCESS);
|
||||||
}
|
}
|
||||||
@@ -770,28 +780,25 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
return calcState;
|
return calcState;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex, start_parking_time_);
|
|
||||||
Q_UNUSED(tlist);
|
|
||||||
|
|
||||||
// compute cost (price)
|
// compute cost (price)
|
||||||
cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex);
|
cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex);
|
||||||
|
|
||||||
int weekDay = start_parking_time.date().dayOfWeek();
|
int weekDay = start_parking_time.date().dayOfWeek();
|
||||||
int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
||||||
qCritical() << __func__ << __LINE__ << "configured carry-over-id" << pop_carry_over_option_id;
|
|
||||||
|
|
||||||
std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
|
std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
|
||||||
if (yperiod.has_value()) {
|
if (yperiod.has_value()) {
|
||||||
ATBPeriodYear const &period = yperiod.value();
|
ATBPeriodYear const &period = yperiod.value();
|
||||||
pop_carry_over_option_id = period.pye_id;
|
pop_carry_over_option_id = period.pye_id;
|
||||||
qCritical() << __func__ << __LINE__ << "re-computed carry-over-id" << pop_carry_over_option_id;
|
//qCritical() << __func__ << __LINE__ << "re-computed carry-over-id" << pop_carry_over_option_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTime const carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
|
QTime const carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
|
||||||
int const carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
|
int const carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
|
||||||
|
|
||||||
qCritical() << __func__ << __LINE__ << "carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
//qCritical() << __func__ << __LINE__ << "carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
||||||
qCritical() << __func__ << __LINE__ << "carryOverDuration" << carryOverDuration;
|
//qCritical() << __func__ << __LINE__ << "carryOverDuration" << carryOverDuration;
|
||||||
|
|
||||||
// handle prepaid option
|
// handle prepaid option
|
||||||
QDateTime effectiveStartTime(start_parking_time);
|
QDateTime effectiveStartTime(start_parking_time);
|
||||||
@@ -807,13 +814,14 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
} else
|
} else
|
||||||
if (start_parking_time.time() > p.static_start) { // static_start: e.g. 22:00:00
|
if (start_parking_time.time() > p.static_start) { // static_start: e.g. 22:00:00
|
||||||
effectiveStartTime.setTime(p.static_start);
|
effectiveStartTime.setTime(p.static_start);
|
||||||
|
effectiveStartTime == effectiveStartTime.addSecs(carryOverDuration * 60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle carry over
|
// handle carry over
|
||||||
int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
|
int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
|
||||||
if (netto_parking_time > minutesUntilCarryOver) {
|
if (netto_parking_time >= minutesUntilCarryOver) {
|
||||||
int const rest = netto_parking_time - minutesUntilCarryOver;
|
int const rest = netto_parking_time - minutesUntilCarryOver;
|
||||||
QDateTime s(effectiveStartTime);
|
QDateTime s(effectiveStartTime);
|
||||||
s = s.addSecs(minutesUntilCarryOver * 60);
|
s = s.addSecs(minutesUntilCarryOver * 60);
|
||||||
@@ -840,8 +848,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
//qCritical() << __LINE__ << " end_parking_time: " << end_parking_time;
|
// qCritical() << __LINE__ << " end_parking_time: " << end_parking_time;
|
||||||
//qCritical() << __LINE__ << " -> calculated cost (netto): " << cost;
|
qCritical() << __LINE__ << " -> calculated cost (netto): " << cost;
|
||||||
|
|
||||||
price->brutto = price->vat = price->vat_percentage = 0;
|
price->brutto = price->vat = price->vat_percentage = 0;
|
||||||
price->units = cost;
|
price->units = cost;
|
||||||
@@ -855,6 +863,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
end_parking_time = end_parking_time.addDays(-1);
|
end_parking_time = end_parking_time.addDays(-1);
|
||||||
end_parking_time.setTime(QTime(23, 59, 0));
|
end_parking_time.setTime(QTime(23, 59, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
qCritical() << __func__ << __LINE__ << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
|
qCritical() << __func__ << __LINE__ << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
|
||||||
|
|
||||||
return calcState.set(CalcState::State::SUCCESS);
|
return calcState.set(CalcState::State::SUCCESS);
|
||||||
@@ -923,15 +932,12 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
bool const nextDay = false;
|
bool const nextDay = false;
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
// if (DBG_LEVEL >= DBG_DEBUG) {
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
qCritical() << "\ncompute_duration_for_parking_ticket(2):";
|
qCritical() << "compute_duration_for_parking_ticket(2): ";
|
||||||
qCritical() << " start time:" << start_parking_time.toString(Qt::ISODate);
|
qCritical() << " payment option index: " << paymentOptionIndex;
|
||||||
qCritical() << " payment option index:" << paymentOptionIndex;
|
qCritical() << " prepaid: " << prepaid;
|
||||||
qCritical() << " prepaid:" << prepaid;
|
qCritical() << " price: " << price;
|
||||||
qCritical() << " price:" << price;
|
}
|
||||||
qCritical() << " permit type:" << permitType.toString() << endl;
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (start_parking_time.isValid()) {
|
if (start_parking_time.isValid()) {
|
||||||
QString cs = start_parking_time.toString(Qt::ISODate);
|
QString cs = start_parking_time.toString(Qt::ISODate);
|
||||||
@@ -1012,10 +1018,9 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
qCritical() << "\ncompute_duration_for_parking_ticket():";
|
qCritical() << "compute_duration_for_parking_ticket(): ";
|
||||||
qCritical() << " start time:" << start_parking_time.toString(Qt::ISODate);
|
qCritical() << " endTime: " << endTime;
|
||||||
qCritical() << " endTime:" << endTime;
|
qCritical() << " ticketEndTime: " << ticketEndTime;
|
||||||
qCritical() << " ticketEndTime:" << ticketEndTime.toString(Qt::ISODate) << endl;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return calcState.set(CalcState::State::INVALID_START_DATE);
|
return calcState.set(CalcState::State::INVALID_START_DATE);
|
||||||
|
@@ -10,12 +10,9 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <iterator>
|
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QScopedArrayPointer>
|
#include <QScopedArrayPointer>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTimeZone>
|
|
||||||
|
|
||||||
double total_duration_min = 0.0f;
|
double total_duration_min = 0.0f;
|
||||||
double total_cost = 0.0f;
|
double total_cost = 0.0f;
|
||||||
@@ -120,6 +117,117 @@ QDateTime Calculator::GetDailyTicketDuration(Configuration* cfg, const QDateTime
|
|||||||
|
|
||||||
return QDateTime();
|
return QDateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Calculator::computeBruttoDurationInSecs(Configuration const *cfg,
|
||||||
|
QDateTime const &start,
|
||||||
|
int nettoDurationInSecs,
|
||||||
|
bool maxBrutto) {
|
||||||
|
QDateTime from(start);
|
||||||
|
int bruttoDurationInSecs = 0;
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
|
qCritical() << DBG_HEADER << "netto duration in secs" << nettoDurationInSecs;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (nettoDurationInSecs > 0) {
|
||||||
|
int day_in_week_id = from.date().dayOfWeek();
|
||||||
|
int count = cfg->WeekDaysWorktime.count(day_in_week_id);
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
|
qCritical() << DBG_HEADER << "count for " << day_in_week_id << ": " << count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(day_in_week_id); iter != rEnd; ++iter) {
|
||||||
|
QTime const &pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
|
||||||
|
QTime const &pwd_time_to = QTime::fromString(QString::fromStdString(iter->second.pwd_time_to), Qt::ISODate);
|
||||||
|
QTime fromTime = from.time();
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
|
qCritical() << DBG_HEADER;
|
||||||
|
qCritical() << DBG_HEADER << " wd-from" << pwd_time_from.toString(Qt::ISODate);
|
||||||
|
qCritical() << DBG_HEADER << " wd-to" << pwd_time_to.toString(Qt::ISODate);
|
||||||
|
qCritical() << DBG_HEADER << "fromTime" << fromTime.toString(Qt::ISODate);
|
||||||
|
qCritical() << DBG_HEADER << " from" << from.toString(Qt::ISODate);
|
||||||
|
qCritical() << DBG_HEADER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fromTime <= pwd_time_from) {
|
||||||
|
int secs = fromTime.secsTo(pwd_time_from);
|
||||||
|
bruttoDurationInSecs += secs;
|
||||||
|
fromTime = pwd_time_from;
|
||||||
|
from.setTime(pwd_time_from);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
|
qCritical() << DBG_HEADER << "fromTime" << fromTime.toString(Qt::ISODate);
|
||||||
|
qCritical() << DBG_HEADER << " from" << from.toString(Qt::ISODate);
|
||||||
|
qCritical() << DBG_HEADER << " netto" << nettoDurationInSecs;
|
||||||
|
qCritical() << DBG_HEADER << " brutto" << bruttoDurationInSecs;
|
||||||
|
qCritical() << DBG_HEADER << " br-date" << start.addSecs(bruttoDurationInSecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (fromTime < pwd_time_to && nettoDurationInSecs > 0) {
|
||||||
|
bruttoDurationInSecs += 60;
|
||||||
|
nettoDurationInSecs -= 60;
|
||||||
|
fromTime = fromTime.addSecs(60);
|
||||||
|
from = from.addSecs(60);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
|
qCritical() << DBG_HEADER;
|
||||||
|
qCritical() << DBG_HEADER << " netto" << nettoDurationInSecs;
|
||||||
|
qCritical() << DBG_HEADER << " brutto" << bruttoDurationInSecs;
|
||||||
|
qCritical() << DBG_HEADER << " br-date" << start.addSecs(bruttoDurationInSecs);
|
||||||
|
qCritical() << DBG_HEADER << "fromTime" << fromTime.toString(Qt::ISODate);
|
||||||
|
qCritical() << DBG_HEADER << " from" << from.toString(Qt::ISODate);
|
||||||
|
qCritical() << DBG_HEADER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (--count == 0 && fromTime == pwd_time_to) {
|
||||||
|
// handle rest
|
||||||
|
QDateTime midnight(from);
|
||||||
|
midnight = midnight.addDays(1);
|
||||||
|
midnight.setTime(QTime(0, 0, 0));
|
||||||
|
int secs = from.secsTo(midnight);
|
||||||
|
bruttoDurationInSecs += secs;
|
||||||
|
from = midnight;
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
|
qCritical() << DBG_HEADER;
|
||||||
|
qCritical() << DBG_HEADER << " netto" << nettoDurationInSecs;
|
||||||
|
qCritical() << DBG_HEADER << " brutto" << bruttoDurationInSecs;
|
||||||
|
qCritical() << DBG_HEADER << " br-date" << start.addSecs(bruttoDurationInSecs);
|
||||||
|
qCritical() << DBG_HEADER << " from" << from.toString(Qt::ISODate);
|
||||||
|
qCritical() << DBG_HEADER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bruttoDurationInSecs += (24 * 3600);
|
||||||
|
from = from.addDays(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxBrutto) {
|
||||||
|
qCritical() << DBG_HEADER << "TODO";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
|
qCritical() << DBG_HEADER << " br-date" << start.addSecs(bruttoDurationInSecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bruttoDurationInSecs;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDateTime Calculator::computeBruttoDateTime(Configuration const *cfg,
|
||||||
|
QDateTime const &from,
|
||||||
|
int durationInSecs,
|
||||||
|
bool maxBrutto) {
|
||||||
|
return from.addSecs(computeBruttoDurationInSecs(cfg, from, durationInSecs, maxBrutto));
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
||||||
uint8_t payment_option,
|
uint8_t payment_option,
|
||||||
@@ -162,8 +270,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
return CalcState::BELOW_MIN_PARKING_PRICE.toStdString();
|
return CalcState::BELOW_MIN_PARKING_PRICE.toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
int const pop_time_step_config = cfg->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
|
if (prepaid == false) {
|
||||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::RECOMPUTE_SOME || prepaid == false) {
|
|
||||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||||
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
|
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;
|
||||||
@@ -178,9 +285,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
|
|
||||||
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) {
|
||||||
int const pra_price = itr->second.pra_price;
|
int const pra_price = itr->second.pra_price;
|
||||||
|
|
||||||
// qCritical() << DBG_HEADER << "pra_price" << pra_price;
|
|
||||||
|
|
||||||
int const durationId = itr->second.pra_payment_unit_id;
|
int const durationId = itr->second.pra_payment_unit_id;
|
||||||
if (pop_accumulate_prices) {
|
if (pop_accumulate_prices) {
|
||||||
price += pra_price;
|
price += pra_price;
|
||||||
@@ -188,8 +292,8 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
price = pra_price;
|
price = pra_price;
|
||||||
}
|
}
|
||||||
|
|
||||||
// qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
|
//qCritical() << DBG_HEADER << " PRICE" << price << "COST" << cost;
|
||||||
// qCritical() << DBG_HEADER << " duration id" << durationId;
|
//qCritical() << DBG_HEADER << " duration id" << durationId;
|
||||||
|
|
||||||
auto search = cfg->Duration.find(durationId);
|
auto search = cfg->Duration.find(durationId);
|
||||||
if (search != cfg->Duration.end()) {
|
if (search != cfg->Duration.end()) {
|
||||||
@@ -198,9 +302,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
ATBDuration duration = search->second;
|
ATBDuration duration = search->second;
|
||||||
|
|
||||||
if (pop_accumulate_prices) {
|
if (pop_accumulate_prices) {
|
||||||
int32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
uint32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||||
|
|
||||||
// qCritical() << DBG_HEADER << " duration unit" << durationUnit;
|
|
||||||
|
|
||||||
new_price += pra_price;
|
new_price += pra_price;
|
||||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") old price" << price << ", new_price:" << new_price;
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") old price" << price << ", new_price:" << new_price;
|
||||||
@@ -225,7 +327,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
|
|
||||||
qCritical() << DBG_HEADER << " provided price (cost):" << cost;
|
qCritical() << DBG_HEADER << " provided price (cost):" << cost;
|
||||||
qCritical() << DBG_HEADER << " computed time for price (minutes):" << duration_previous;
|
qCritical() << DBG_HEADER << " computed time for price (minutes):" << duration_previous;
|
||||||
qCritical() << DBG_HEADER << " minimal parking time (minutes):" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
qCritical() << DBG_HEADER << "configured minimal parking time (minutes):" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||||
|
|
||||||
if (duration_previous < 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 CalcState::BELOW_MIN_PARKING_TIME.toStdString(); // minimal parking time is set by GetTimeSteps()
|
||||||
@@ -353,8 +455,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||||
qCritical() << DBG_HEADER << "(ADAPTED) INPUT-DATE" << inputDate.toString(Qt::ISODate);
|
qCritical() << DBG_HEADER << "(ADAPTED) INPUT-DATE" << inputDate.toString(Qt::ISODate);
|
||||||
#endif
|
#endif
|
||||||
//qCritical() << __func__ << __LINE__;
|
|
||||||
|
|
||||||
// inputDate is now located in a valid operational-working-range
|
// inputDate is now located in a valid operational-working-range
|
||||||
// find this working-time-range
|
// find this working-time-range
|
||||||
int pwd_period_day_in_week_id = inputDate.date().dayOfWeek();
|
int pwd_period_day_in_week_id = inputDate.date().dayOfWeek();
|
||||||
@@ -368,8 +468,6 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
//qCritical() << __func__ << __LINE__;
|
|
||||||
|
|
||||||
QTime current_working_time_from;
|
QTime current_working_time_from;
|
||||||
QTime current_working_time_to;
|
QTime current_working_time_to;
|
||||||
|
|
||||||
@@ -399,12 +497,11 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
|
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 price = 0;
|
||||||
int new_price = 0;
|
int new_price = 0;
|
||||||
int durationInSecs = 0;
|
int durationInSecs = 0;
|
||||||
uint32_t duration_previous = 0;
|
uint32_t duration_previous = 0;
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
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) {
|
||||||
int const pra_price = itr->second.pra_price;
|
int const pra_price = itr->second.pra_price;
|
||||||
@@ -427,24 +524,39 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
uint32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
uint32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||||
|
|
||||||
new_price += pra_price;
|
new_price += pra_price;
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX price:" << price;
|
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") YYYYYY new_price:" << new_price;
|
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pra_price:" << pra_price;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price:" << price;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") cost:" << cost;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") new_price:" << new_price;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (new_price <= cost) {
|
if (new_price <= cost) {
|
||||||
duration_previous = durationUnit;
|
if (pop_accumulate_durations) {
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") ZZZZZZ duration_previous" << duration_previous;
|
duration_previous += durationUnit;
|
||||||
|
} else {
|
||||||
|
duration_previous = durationUnit;
|
||||||
|
}
|
||||||
|
durationInSecs = duration_previous * 60;
|
||||||
|
|
||||||
|
#if DEBUG_GET_DURATION_FROM_COST==1
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationUnit" << durationUnit;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationInSecs" << durationInSecs;
|
||||||
|
#endif
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
found = true;
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") WWWWWW duration_previous" << duration_previous;
|
|
||||||
QString s = inputDate.toString(Qt::ISODate);
|
QString s = inputDate.toString(Qt::ISODate);
|
||||||
QDateTime d(QDateTime::fromString(s, Qt::ISODate));
|
QDateTime d(QDateTime::fromString(s, Qt::ISODate));
|
||||||
d = d.addSecs(duration_previous * 60);
|
d = d.addSecs(duration_previous * 60);
|
||||||
//qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << d;
|
|
||||||
return d.toString(Qt::ISODate).toStdString();
|
return d.toString(Qt::ISODate).toStdString();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
durationInSecs = cfg->Duration.find(durationId)->second.pun_duration * 60;
|
durationInSecs = cfg->Duration.find(durationId)->second.pun_duration * 60;
|
||||||
//qCritical() << DBG_HEADER << "DURATION-SECS" << durationInSecs;
|
qCritical() << DBG_HEADER << "DURATION-SECS" << durationInSecs;
|
||||||
//qCritical() << DBG_HEADER << "DURATION-MINS" << durationInSecs / 60;
|
qCritical() << DBG_HEADER << "DURATION-MINS" << durationInSecs / 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((double)price == cost) {
|
if ((double)price == cost) {
|
||||||
@@ -457,25 +569,50 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
qCritical() << DBG_HEADER << "DURATION IN SECONDS" << durationInSecs;
|
qCritical() << DBG_HEADER << "DURATION IN SECONDS" << durationInSecs;
|
||||||
qCritical() << DBG_HEADER << "CURRENT-WORKING-DATE-TIME-TO"
|
qCritical() << DBG_HEADER << "CURRENT-WORKING-DATE-TIME-TO"
|
||||||
<< current_working_date_time_to.toString(Qt::ISODate);
|
<< current_working_date_time_to.toString(Qt::ISODate);
|
||||||
|
qCritical() << DBG_HEADER << " INPUT DATE" << inputDate.toString(Qt::ISODate);
|
||||||
qCritical() << DBG_HEADER << "NEW INPUT DATE" << inputDate.addSecs(durationInSecs).toString(Qt::ISODate);
|
qCritical() << DBG_HEADER << "NEW INPUT DATE" << inputDate.addSecs(durationInSecs).toString(Qt::ISODate);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (inputDate.addSecs(durationInSecs) > current_working_date_time_to) {
|
if (inputDate.addSecs(durationInSecs) > current_working_date_time_to) {
|
||||||
|
int bruttoDurationInSecs = computeBruttoDurationInSecs(cfg, inputDate, durationInSecs);
|
||||||
|
// qCritical() << DBG_HEADER << "DURATION IN SECONDS (NETTO)" << durationInSecs;
|
||||||
|
// qCritical() << DBG_HEADER << "DURATION IN SECONDS (BRUTTO)" << bruttoDurationInSecs;
|
||||||
|
|
||||||
|
inputDate = inputDate.addSecs(bruttoDurationInSecs);
|
||||||
|
#if 0
|
||||||
|
// durationInSecs is a netto time
|
||||||
|
// needed is the corresponding brutto-time
|
||||||
|
int day_in_week_id = inputDate.date().dayOfWeek();
|
||||||
|
int nettoDurationInSecs = 0;
|
||||||
|
|
||||||
|
while (nettoDurationInSecs <= durationInSecs) {
|
||||||
|
if (cfg->WeekDaysWorktime.count(day_in_week_id) > 0) {
|
||||||
|
for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(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);
|
||||||
|
nettoDurationInSecs += pwd_time_from.secsTo(pwd_time_to);
|
||||||
|
if (nettoDurationInSecs > durationInSecs) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
day_in_week_id += 1;
|
||||||
|
if (day_in_week_id > (int)Qt::Sunday) {
|
||||||
|
day_in_week_id = Qt::Monday;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qCritical() << DBG_HEADER;
|
||||||
|
|
||||||
QTime next_working_time_from;
|
QTime next_working_time_from;
|
||||||
if (cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over != 0) {
|
if (cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over != 0) {
|
||||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
|
||||||
qCritical() << DBG_HEADER << "CARRY-OVER SET";
|
qCritical() << DBG_HEADER << "CARRY-OVER SET";
|
||||||
#endif
|
|
||||||
// check for next working-time-range on same day
|
// check for next working-time-range on same day
|
||||||
int day_in_week_id = inputDate.date().dayOfWeek();
|
int day_in_week_id = inputDate.date().dayOfWeek();
|
||||||
for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(day_in_week_id); iter != rEnd; ++iter) {
|
for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(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_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
|
||||||
if (pwd_time_from > current_working_time_to) {
|
if (pwd_time_from > current_working_time_to) {
|
||||||
next_working_time_from = pwd_time_from;
|
next_working_time_from = pwd_time_from;
|
||||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
|
||||||
qCritical() << DBG_HEADER << "NEXT-WORKING-TIME-FROM"
|
qCritical() << DBG_HEADER << "NEXT-WORKING-TIME-FROM"
|
||||||
<< next_working_time_from.toString(Qt::ISODate);
|
<< next_working_time_from.toString(Qt::ISODate);
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -492,33 +629,33 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
|
QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
|
||||||
if (next_working_time_from < pwd_time_from) {
|
if (next_working_time_from < pwd_time_from) {
|
||||||
next_working_time_from = pwd_time_from;
|
next_working_time_from = pwd_time_from;
|
||||||
|
qCritical() << DBG_HEADER << " day in week" << day_in_week_id;
|
||||||
qCritical() << DBG_HEADER << "next working time from" << next_working_time_from.toString(Qt::ISODate);
|
qCritical() << DBG_HEADER << "next working time from" << next_working_time_from.toString(Qt::ISODate);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//qCritical() << DBG_HEADER << "DAYS" << days;
|
qCritical() << DBG_HEADER << "DAYS" << days;
|
||||||
//qCritical() << DBG_HEADER << "DURATION-SECS" << durationInSecs;
|
qCritical() << DBG_HEADER << "DURATION-SECS" << durationInSecs;
|
||||||
//qCritical() << DBG_HEADER << "DURATION-MINS" << durationInSecs / 60;
|
qCritical() << DBG_HEADER << "DURATION-MINS" << durationInSecs / 60;
|
||||||
|
|
||||||
QDateTime upper = inputDate.addDays(days);
|
QDateTime upper = inputDate.addDays(days);
|
||||||
upper.setTime(next_working_time_from);
|
upper.setTime(next_working_time_from);
|
||||||
|
|
||||||
//qCritical() << DBG_HEADER << "UPPER" << upper.toString(Qt::ISODate);
|
qCritical() << DBG_HEADER << "UPPER" << upper.toString(Qt::ISODate);
|
||||||
|
|
||||||
QDateTime lower = inputDate;
|
QDateTime lower = inputDate;
|
||||||
lower.setTime(current_working_time_to);
|
lower.setTime(current_working_time_to);
|
||||||
|
|
||||||
//qCritical() << DBG_HEADER << "LOWER" << lower.toString(Qt::ISODate);
|
qCritical() << DBG_HEADER << "LOWER" << lower.toString(Qt::ISODate);
|
||||||
|
|
||||||
// inputDate = inputDate.addSecs(lower.secsTo(upper));
|
// inputDate = inputDate.addSecs(lower.secsTo(upper));
|
||||||
|
|
||||||
//qCritical() << DBG_HEADER << "NEW INPUT" << inputDate.toString(Qt::ISODate);
|
//qCritical() << DBG_HEADER << "NEW INPUT" << inputDate.toString(Qt::ISODate);
|
||||||
|
|
||||||
inputDate = inputDate.addSecs(durationInSecs);
|
// durationInSecs is a netto-parking-time
|
||||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
inputDate = inputDate.addSecs(durationInSecs + lower.secsTo(upper));
|
||||||
qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate);
|
qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate);
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // for (int days = 1; days < 8; ++days) {
|
} // for (int days = 1; days < 8; ++days) {
|
||||||
@@ -530,36 +667,31 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
lower.setTime(current_working_time_to);
|
lower.setTime(current_working_time_to);
|
||||||
|
|
||||||
inputDate = inputDate.addSecs(lower.secsTo(upper) + durationInSecs);
|
inputDate = inputDate.addSecs(lower.secsTo(upper) + durationInSecs);
|
||||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
//qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate);
|
||||||
qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
inputDate = inputDate.addSecs(duration.pun_duration * 60);
|
|
||||||
|
|
||||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
|
||||||
qCritical() << DBG_HEADER << "INPUT-DATE" << inputDate.toString(Qt::ISODate);
|
|
||||||
#endif
|
#endif
|
||||||
|
} else { // if (inputDate.addSecs(durationInSecs) > current_working_date_time_to) {
|
||||||
|
if (pop_accumulate_durations) {
|
||||||
|
inputDate = inputDate.addSecs(durationInSecs);
|
||||||
|
} else {
|
||||||
|
inputDate = inputDate.addSecs(duration.pun_duration * 60);
|
||||||
|
}
|
||||||
|
// qCritical() << DBG_HEADER << "INPUT-DATE" << inputDate.toString(Qt::ISODate);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString const &s = inputDate.toString(Qt::ISODate);
|
QString const &s = inputDate.toString(Qt::ISODate);
|
||||||
|
// qCritical() << DBG_HEADER << "TICKET-END" << s;
|
||||||
#if DEBUG_GET_DURATION_FROM_COST==1
|
|
||||||
qCritical() << DBG_HEADER << "TICKET-END" << s;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return s.toStdString();
|
return s.toStdString();
|
||||||
} // if ((double)price == cost) {
|
} // if ((double)price == cost) {
|
||||||
else {
|
else {
|
||||||
//qCritical() << DBG_HEADER;
|
// qCritical() << DBG_HEADER;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//qCritical() << __func__ << __LINE__;
|
// qCritical() << DBG_HEADER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// qCritical() << DBG_HEADER;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1027,14 +1159,17 @@ uint32_t Calculator::GetCostFromDuration(Configuration * cfg,
|
|||||||
int paymentOptionIndex) const {
|
int paymentOptionIndex) const {
|
||||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
|
|
||||||
//qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
|
// qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
|
||||||
|
|
||||||
if (paymentMethodId == PaymentMethod::Steps ||
|
if (paymentMethodId == PaymentMethod::Steps ||
|
||||||
paymentMethodId == PaymentMethod::Degressive) {
|
paymentMethodId == PaymentMethod::Degressive) {
|
||||||
int const timeStepInMinutes = start.secsTo(end) / 60;
|
int const timeStepInMinutes = start.secsTo(end) / 60;
|
||||||
QList<int> tlist = Calculator::GetInstance().GetTimeSteps(cfg, paymentOptionIndex, start);
|
QList<int> tlist = Calculator::GetInstance().GetTimeSteps(cfg, paymentOptionIndex, start);
|
||||||
qCritical() << DBG_HEADER << "timeStepList" << timeStepInMinutes << tlist;
|
Q_UNUSED(tlist);
|
||||||
qCritical() << DBG_HEADER << "timeStepInMinutes" << timeStepInMinutes << start.toString(Qt::ISODate);
|
//qCritical() << DBG_HEADER << " start" << start.toString(Qt::ISODate);
|
||||||
|
//qCritical() << DBG_HEADER << " end" << end.toString(Qt::ISODate);
|
||||||
|
//qCritical() << DBG_HEADER << "timeStepList" << timeStepInMinutes << tlist;
|
||||||
|
//qCritical() << DBG_HEADER << "timeStepInMinutes" << timeStepInMinutes << start.toString(Qt::ISODate);
|
||||||
|
|
||||||
return GetPriceForTimeStep(cfg, timeStepInMinutes, paymentOptionIndex);
|
return GetPriceForTimeStep(cfg, timeStepInMinutes, paymentOptionIndex);
|
||||||
}
|
}
|
||||||
@@ -1322,8 +1457,8 @@ CalcState Calculator::isParkingAllowed(Configuration const *cfg,
|
|||||||
int netto_parking_time,
|
int netto_parking_time,
|
||||||
int paymentOptionIndex) {
|
int paymentOptionIndex) {
|
||||||
|
|
||||||
qCritical() << DBG_HEADER << "CHECK IF PARKING IS ALLOWED AT"
|
//qCritical() << DBG_HEADER << "CHECK IF PARKING IS ALLOWED AT"
|
||||||
<< start.toString(Qt::ISODate) << "...";
|
// << start.toString(Qt::ISODate) << "...";
|
||||||
|
|
||||||
CalcState cs;
|
CalcState cs;
|
||||||
|
|
||||||
@@ -2541,16 +2676,18 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // if (carryOverTimeRangeFrom == QTime(0, 0, 0)) {
|
} 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 from:" << carryOverTimeRangeFrom.toString(Qt::ISODate);
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over time range to:" << carryOverTimeRangeTo.toString(Qt::ISODate);
|
||||||
//}
|
}
|
||||||
|
|
||||||
m_timeSteps[paymentOptionIndex].clear();
|
m_timeSteps[paymentOptionIndex].clear();
|
||||||
|
|
||||||
std::optional<QDateTime> prepaidStart = cfg->prepaidStart(start, pop_prepaid_option_id);
|
std::optional<QDateTime> prepaidStart = cfg->prepaidStart(start, pop_prepaid_option_id);
|
||||||
// TODO: zusaetzlicher faktor falls vorkauf-option zieht
|
// TODO: zusaetzlicher faktor falls vorkauf-option zieht
|
||||||
if (prepaidStart) {
|
if (prepaidStart) {
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid start value:" << prepaidStart.value().toString(Qt::ISODate);
|
||||||
start = prepaidStart.value();
|
start = prepaidStart.value();
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid adapted start:" << start.toString(Qt::ISODate);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid adapted start:" << start.toString(Qt::ISODate);
|
||||||
@@ -2571,6 +2708,8 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
|||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
|
||||||
|
|
||||||
// int const start_time = start.time().hour() * 60 + start.time().minute();
|
// int const start_time = start.time().hour() * 60 + start.time().minute();
|
||||||
QDateTime nextTimeStep = start;
|
QDateTime nextTimeStep = start;
|
||||||
int runtimeInMinutes = 0;
|
int runtimeInMinutes = 0;
|
||||||
@@ -2596,7 +2735,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
|||||||
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) {
|
||||||
int const durationId = itr->second.pra_payment_unit_id;
|
int const durationId = itr->second.pra_payment_unit_id;
|
||||||
|
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
|
||||||
// int const price = itr->second.pra_price;
|
// int const price = itr->second.pra_price;
|
||||||
|
|
||||||
auto search = cfg->Duration.find(durationId);
|
auto search = cfg->Duration.find(durationId);
|
||||||
@@ -2613,14 +2752,15 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes:" << runtimeInMinutes;
|
||||||
|
|
||||||
std::optional<ATBInterpolation> ipolCheck = cfg->getInterpolationType(duration.pun_interpolation_id);
|
std::optional<ATBInterpolation> ipolCheck = cfg->getInterpolationType(duration.pun_interpolation_id);
|
||||||
if (ipolCheck) {
|
if (ipolCheck) {
|
||||||
ATBInterpolation interpolation = ipolCheck.value();
|
ATBInterpolation interpolation = ipolCheck.value();
|
||||||
|
|
||||||
if (duration.pun_interpolation_id == (int)ATBInterpolation::DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_PRICE) {
|
if (duration.pun_interpolation_id == (int)ATBInterpolation::DYNAMIC_ABSTRACT_TIMEPOINT_AND_STATIC_PRICE) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") HIER NICHT";
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id;
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_intnerpolation_id:" << duration.pun_interpolation_id;
|
||||||
|
|
||||||
interpolation.dynamic_start = start.time();
|
interpolation.dynamic_start = start.time();
|
||||||
interpolation.dynamic_start.setHMS(start.time().hour(), start.time().minute(), 0);
|
interpolation.dynamic_start.setHMS(start.time().hour(), start.time().minute(), 0);
|
||||||
@@ -2633,11 +2773,12 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
|||||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end time:" << end_time;
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") interpolation dynamic end time:" << end_time;
|
||||||
|
|
||||||
int pop_min_time = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
int pop_min_time = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||||
|
bool pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
|
||||||
|
|
||||||
runtimeInMinutes += duration.pun_duration;
|
runtimeInMinutes += duration.pun_duration;
|
||||||
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
nextTimeStep = start.addSecs(runtimeInMinutes * 60);
|
||||||
|
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (1):" << runtimeInMinutes;
|
||||||
|
|
||||||
if (nextTimeStep.time() > carryOverStart) {
|
if (nextTimeStep.time() > carryOverStart) {
|
||||||
int const backTime = carryOverStart.secsTo(nextTimeStep.time()) / 60;
|
int const backTime = carryOverStart.secsTo(nextTimeStep.time()) / 60;
|
||||||
@@ -2662,19 +2803,22 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
|||||||
//}
|
//}
|
||||||
} else {
|
} else {
|
||||||
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
|
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") :" << m_timeSteps[paymentOptionIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
duration.pun_duration = runtimeInMinutes;
|
if (pop_accumulate_durations == false) {
|
||||||
|
duration.pun_duration = runtimeInMinutes;
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration:" << duration.pun_duration;
|
||||||
|
search->second = duration;
|
||||||
search->second = duration;
|
}
|
||||||
} else
|
} else
|
||||||
if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
|
if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" ;
|
||||||
|
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id:" << duration.pun_id;
|
||||||
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex;
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun duration:" << duration.pun_duration;
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next time step:" << nextTimeStep.toString(Qt::ISODate);
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (2):" << runtimeInMinutes;
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") runtime in minutes (2):" << runtimeInMinutes;
|
||||||
@@ -2687,6 +2831,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
|||||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||||
search->second = duration;
|
search->second = duration;
|
||||||
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes;
|
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_min_time" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2762,8 +2907,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
|||||||
// duration.pun_duration = runtimeInMinutes - carryOverDuration;
|
// duration.pun_duration = runtimeInMinutes - carryOverDuration;
|
||||||
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
m_timeSteps[paymentOptionIndex] << duration.pun_duration;
|
||||||
search->second = duration;
|
search->second = duration;
|
||||||
} else {
|
} else { // if (duration.pun_interpolation_id == (int)ATBInterpolation::NO_INTERPOLATION) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") HIER NICHT";
|
|
||||||
cfg->Duration.erase(search);
|
cfg->Duration.erase(search);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2779,243 +2923,6 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
|||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::RECOMPUTE_SOME) {
|
|
||||||
// some durations / timesteps have to be recomputed
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::RECOMPUTE_SOME";
|
|
||||||
int size = m_timeSteps.size();
|
|
||||||
|
|
||||||
while (size <= paymentOptionIndex) {
|
|
||||||
m_timeSteps.push_back(QList<int>());
|
|
||||||
size = m_timeSteps.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
|
|
||||||
|
|
||||||
m_timeSteps[paymentOptionIndex].clear();
|
|
||||||
|
|
||||||
QDateTime const start(s.date(),
|
|
||||||
QTime(s.time().hour(), s.time().minute(), 0),
|
|
||||||
s.timeZone());
|
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDateTime current(start);
|
|
||||||
|
|
||||||
bool casePrepay = false;
|
|
||||||
int const weekDay = start.date().dayOfWeek();
|
|
||||||
|
|
||||||
int const pop_prepay_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_prepay_option_id;
|
|
||||||
|
|
||||||
// compute prepay settings
|
|
||||||
// assumption: prepay settings the same for all days
|
|
||||||
QDateTime prepayStart(start);
|
|
||||||
QDateTime prepayEnd(start);
|
|
||||||
|
|
||||||
prepayStart.setTime(cfg->TariffPrepayOptions.find(pop_prepay_option_id)->second.prepay[weekDay].start);
|
|
||||||
prepayEnd.setTime(cfg->TariffPrepayOptions.find(pop_prepay_option_id)->second.prepay[weekDay].end);
|
|
||||||
|
|
||||||
if (start <= prepayEnd) {
|
|
||||||
prepayStart = prepayStart.addDays(-1);
|
|
||||||
} else {
|
|
||||||
prepayEnd = prepayEnd.addDays(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay start" << prepayStart.toString(Qt::ISODate);
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay end" << prepayEnd.toString(Qt::ISODate);
|
|
||||||
}
|
|
||||||
|
|
||||||
int const prepayDurationInMinutes = start.secsTo(prepayEnd) / 60;
|
|
||||||
|
|
||||||
// compute carryover settings
|
|
||||||
// assumption: carryover settings the same for all days
|
|
||||||
int const pop_carry_over_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
|
|
||||||
QDateTime carryOverStart(start);
|
|
||||||
QDateTime carryOverEnd(start);
|
|
||||||
|
|
||||||
carryOverStart.setTime(cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start);
|
|
||||||
carryOverEnd.setTime(cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end);
|
|
||||||
|
|
||||||
if (start <= carryOverEnd) {
|
|
||||||
carryOverStart = carryOverStart.addDays(-1);
|
|
||||||
} else {
|
|
||||||
carryOverEnd = carryOverEnd.addDays(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over start" << carryOverStart.toString(Qt::ISODate);
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over end" << carryOverEnd.toString(Qt::ISODate);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int cnt = 0;
|
|
||||||
|
|
||||||
for (Configuration::TariffDurationType::iterator it = cfg->Duration.begin();
|
|
||||||
it != cfg->Duration.end();
|
|
||||||
++it) {
|
|
||||||
it->second.pun_duration = it->second.pun_duration_saved;
|
|
||||||
|
|
||||||
// if (++cnt > 2) continue;
|
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << it->second.pun_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (it->second.pun_mutable) {
|
|
||||||
if (it->second.pun_netto) {
|
|
||||||
if (it->second.pun_round_to_next_24h_boundary == false) {
|
|
||||||
//int weekDay = start.date().dayOfWeek();
|
|
||||||
if (m_timeSteps[paymentOptionIndex].isEmpty()) {
|
|
||||||
// handle possible prepay-condition, which applies only
|
|
||||||
// for the very first step
|
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay start" << prepayStart.toString(Qt::ISODate);
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay end" << prepayEnd.toString(Qt::ISODate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prepayStart <= start && start <= prepayEnd) {
|
|
||||||
it->second.pun_duration = prepayDurationInMinutes;
|
|
||||||
it->second.pun_duration += it->second.pun_duration_saved ;
|
|
||||||
casePrepay = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << it->second.pun_duration;
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay" << casePrepay;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!casePrepay) {
|
|
||||||
// handle possible carryover-condition
|
|
||||||
|
|
||||||
int const durationInSecs = it->second.pun_duration_saved * 60;
|
|
||||||
it->second.pun_duration = it->second.pun_duration_saved;
|
|
||||||
|
|
||||||
if (current >= carryOverStart && current < carryOverEnd) {
|
|
||||||
it->second.pun_duration += current.secsTo(carryOverEnd) / 60;
|
|
||||||
} else {
|
|
||||||
// start < carryOverStart
|
|
||||||
QDateTime const &newCurrent = current.addSecs(durationInSecs);
|
|
||||||
if (newCurrent > carryOverStart && newCurrent <= carryOverEnd) {
|
|
||||||
// cross carry over section
|
|
||||||
it->second.pun_next_step_correction = carryOverStart.secsTo(carryOverEnd) / 60;
|
|
||||||
it->second.pun_duration += it->second.pun_next_step_correction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pop_accumulate_durations) {
|
|
||||||
m_timeSteps[paymentOptionIndex] << it->second.pun_duration;
|
|
||||||
} else {
|
|
||||||
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
|
|
||||||
int d = m_timeSteps[paymentOptionIndex].last();
|
|
||||||
m_timeSteps[paymentOptionIndex] << (d + it->second.pun_duration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
current = current.addSecs(m_timeSteps[paymentOptionIndex].last() * 60);
|
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else { // if (it->pun_round_to_next_24h_boundary == false) {
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") round-to-next-24h-boundary";
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay" << casePrepay;
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (casePrepay) {
|
|
||||||
// the last time step contains the (dynamic) prepay duration
|
|
||||||
// so it is possible to compute the last duration
|
|
||||||
int lastDuration = m_timeSteps[paymentOptionIndex].last() - prepayDurationInMinutes;
|
|
||||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") last duration " << lastDuration;
|
|
||||||
|
|
||||||
int const minutesToAdd = 1440 - lastDuration;
|
|
||||||
current = current.addSecs(minutesToAdd * 60);
|
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") minutes to add " << minutesToAdd;
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pop_accumulate_durations) {
|
|
||||||
m_timeSteps[paymentOptionIndex] << minutesToAdd;
|
|
||||||
} else {
|
|
||||||
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
|
|
||||||
int d = m_timeSteps[paymentOptionIndex].last();
|
|
||||||
m_timeSteps[paymentOptionIndex] << (d + minutesToAdd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
|
|
||||||
|
|
||||||
casePrepay = false;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << it->second.pun_id;
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << it->second.pun_duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
int secs = s.secsTo(current);
|
|
||||||
int const dayInSecs = 1440 * 60;
|
|
||||||
int const rest = secs % dayInSecs;
|
|
||||||
int const minutesToAdd = (dayInSecs - rest) / 60;
|
|
||||||
|
|
||||||
current = current.addSecs(minutesToAdd * 60);
|
|
||||||
it->second.pun_duration = minutesToAdd;
|
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") minutes to add " << minutesToAdd;
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pop_accumulate_durations) {
|
|
||||||
m_timeSteps[paymentOptionIndex] << minutesToAdd;
|
|
||||||
} else {
|
|
||||||
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
|
|
||||||
int d = m_timeSteps[paymentOptionIndex].last();
|
|
||||||
m_timeSteps[paymentOptionIndex] << (d + minutesToAdd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else { // if (it->second.pun_netto) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")\n" << it->second;
|
|
||||||
}
|
|
||||||
} else { // mutable == false
|
|
||||||
if (it->second.pun_brutto) { // no handling for prepay and carry-over
|
|
||||||
if (pop_accumulate_durations) {
|
|
||||||
m_timeSteps[paymentOptionIndex] << it->second.pun_duration;
|
|
||||||
} else {
|
|
||||||
if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
|
|
||||||
int d = m_timeSteps[paymentOptionIndex].last();
|
|
||||||
m_timeSteps[paymentOptionIndex] << (d + it->second.pun_duration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
|
|
||||||
|
|
||||||
} else {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")\n" << it->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::STATIC";
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::STATIC";
|
||||||
|
|
||||||
@@ -3034,12 +2941,13 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
QDateTime nextTime(s);
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps;
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << nextTime.toString(Qt::ISODate);
|
|
||||||
for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
|
for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
|
||||||
|
QDateTime nextTime = s;
|
||||||
// nextTime.setTime(QTime(0, 0, 0));
|
// nextTime.setTime(QTime(0, 0, 0));
|
||||||
int const secs = m_timeSteps[paymentOptionIndex][i] * 60;
|
int const secs = m_timeSteps[paymentOptionIndex][i] * 60;
|
||||||
nextTime = nextTime.addSecs(secs);
|
nextTime = nextTime.addSecs(secs);
|
||||||
@@ -3066,9 +2974,13 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
|
|||||||
uint32_t price = 0;
|
uint32_t price = 0;
|
||||||
int pun_duration = 0;
|
int pun_duration = 0;
|
||||||
|
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex" << paymentOptionIndex;
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex" << paymentOptionIndex;
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_accumulate_prices" << pop_accumulate_prices;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_accumulate_durations" << pop_accumulate_durations;
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -3093,6 +3005,7 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_DEBUG) {
|
if (DBG_LEVEL >= DBG_DEBUG) {
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ")";
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
|
||||||
@@ -3101,7 +3014,7 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (timeStep == pun_duration) {
|
if (timeStep == pun_duration) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
|
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3113,7 +3026,9 @@ uint32_t Calculator::GetDurationForPrice(Configuration *cfg, int price) const {
|
|||||||
int const pop_id = cfg->getPaymentOptions().pop_id;
|
int const pop_id = cfg->getPaymentOptions().pop_id;
|
||||||
int const pop_accumulate_prices = cfg->getPaymentOptions().pop_accumulate_prices;
|
int const pop_accumulate_prices = cfg->getPaymentOptions().pop_accumulate_prices;
|
||||||
|
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") accumulate prices" << pop_accumulate_prices;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") accumulate prices" << pop_accumulate_prices;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
|
||||||
|
|
||||||
int new_price = 0;
|
int new_price = 0;
|
||||||
uint32_t duration = 0;
|
uint32_t duration = 0;
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
#include "tariff_business_hours.h"
|
#include "tariff_business_hours.h"
|
||||||
#include "tariff_global_defines.h"
|
#include "tariff_global_defines.h"
|
||||||
#include "tariff_carryover.h"
|
#include "tariff_carryover.h"
|
||||||
#include "tariff_prepay.h"
|
|
||||||
#include "tariff_global_defines.h"
|
#include "tariff_global_defines.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -36,7 +35,6 @@ MemberType Configuration::IdentifyJsonMember(const char* member_name)
|
|||||||
if (strcmp(member_name, "Interpolation") == 0) return MemberType::InterpolationType;
|
if (strcmp(member_name, "Interpolation") == 0) return MemberType::InterpolationType;
|
||||||
if (strcmp(member_name, "Prepaid") == 0) return MemberType::PrepaidType;
|
if (strcmp(member_name, "Prepaid") == 0) return MemberType::PrepaidType;
|
||||||
if (strcmp(member_name, "CarryOver") == 0) return MemberType::CarryOverType;
|
if (strcmp(member_name, "CarryOver") == 0) return MemberType::CarryOverType;
|
||||||
if (strcmp(member_name, "PrepaidOption") == 0) return MemberType::PrepaidOptionType;
|
|
||||||
else return MemberType::UnknownType;
|
else return MemberType::UnknownType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +108,6 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
ATBInterpolation TariffInterpolation;
|
ATBInterpolation TariffInterpolation;
|
||||||
ATBPrepaid TariffPrepaidOption;
|
ATBPrepaid TariffPrepaidOption;
|
||||||
ATBCarryOver TariffCarryOver;
|
ATBCarryOver TariffCarryOver;
|
||||||
ATBPrepay TariffPrepayOption;
|
|
||||||
|
|
||||||
MemberType mb_type = MemberType::UnknownType;
|
MemberType mb_type = MemberType::UnknownType;
|
||||||
this->currentPaymentOptions.clear();
|
this->currentPaymentOptions.clear();
|
||||||
@@ -144,7 +141,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// qCritical() << " -" << mb_name;
|
qCritical() << " -" << mb_name;
|
||||||
|
|
||||||
// Get array for each JSON object member
|
// Get array for each JSON object member
|
||||||
auto mb_array = document[mb_name].GetArray();
|
auto mb_array = document[mb_name].GetArray();
|
||||||
@@ -174,61 +171,6 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
{
|
{
|
||||||
case MemberType::UnknownType:
|
case MemberType::UnknownType:
|
||||||
break;
|
break;
|
||||||
case MemberType::PrepaidOptionType: {
|
|
||||||
if (QString(inner_obj_name) == QString("prepaid_option_id")) {
|
|
||||||
if (k->value.IsInt()) {
|
|
||||||
int const &x = k->value.GetInt();
|
|
||||||
TariffPrepayOption.id = x;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
if (QString(inner_obj_name) == QString("prepaid_option_week")) {
|
|
||||||
if (k->value.IsArray()) {
|
|
||||||
auto days = k->value.GetArray();
|
|
||||||
for (rapidjson::SizeType j=0; j < days.Size(); ++j) {
|
|
||||||
if (days[j].IsObject()) {
|
|
||||||
auto weekday = days[j].GetObject();
|
|
||||||
for (auto w = weekday.MemberBegin(); w != weekday.MemberEnd(); ++w) {
|
|
||||||
int day = j+1; // 8 entries
|
|
||||||
QString member(QString::fromStdString(w->name.GetString()));
|
|
||||||
if (member == "prepaid_option_day") {
|
|
||||||
if (w->value.IsInt()) {
|
|
||||||
rapidjson::SizeType const d = w->value.GetInt();
|
|
||||||
if (d != (j+1)) {
|
|
||||||
qCritical() << "ERROR: misconfigured jsonfile" << d << "!=" << (j+1);
|
|
||||||
}
|
|
||||||
TariffPrepayOption.prepay[day].day = day;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
if (member == "prepaid_option_duration") {
|
|
||||||
if (w->value.IsInt()) {
|
|
||||||
TariffPrepayOption.prepay[day].duration = w->value.GetInt();
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
if (member == "prepaid_option_prepaid") {
|
|
||||||
if (w->value.IsBool()) {
|
|
||||||
bool b = w->value.GetBool();
|
|
||||||
TariffPrepayOption.prepay[day].prepaid = b;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
if (member == "prepaid_option_start") {
|
|
||||||
if (w->value.IsString()) {
|
|
||||||
QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate);
|
|
||||||
TariffPrepayOption.prepay[day].start = t;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
if (member == "prepaid_option_end") {
|
|
||||||
if (w->value.IsString()) {
|
|
||||||
QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate);
|
|
||||||
TariffPrepayOption.prepay[day].end = t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
case MemberType::CarryOverType: {
|
case MemberType::CarryOverType: {
|
||||||
if (QString(inner_obj_name) == QString("carry_over_id")) {
|
if (QString(inner_obj_name) == QString("carry_over_id")) {
|
||||||
if (k->value.IsInt()) {
|
if (k->value.IsInt()) {
|
||||||
@@ -289,7 +231,6 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
// deprecated
|
|
||||||
case MemberType::PrepaidType: {
|
case MemberType::PrepaidType: {
|
||||||
if (QString(inner_obj_name) == QString("prepaid_id")) {
|
if (QString(inner_obj_name) == QString("prepaid_id")) {
|
||||||
if (k->value.IsInt()) {
|
if (k->value.IsInt()) {
|
||||||
@@ -681,10 +622,8 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
this->currentPaymentOptions.last().pop_max_time = k->value.GetDouble();
|
this->currentPaymentOptions.last().pop_max_time = k->value.GetDouble();
|
||||||
} else if (strcmp(inner_obj_name, "pop_min_price") == 0) {
|
} else if (strcmp(inner_obj_name, "pop_min_price") == 0) {
|
||||||
this->currentPaymentOptions.last().pop_min_price = k->value.GetDouble();
|
this->currentPaymentOptions.last().pop_min_price = k->value.GetDouble();
|
||||||
} else if (strcmp(inner_obj_name, "pop_prepaid_option_id") == 0) { // deprecated
|
} else if (strcmp(inner_obj_name, "pop_prepaid_option_id") == 0) {
|
||||||
this->currentPaymentOptions.last().pop_prepaid_option_id = k->value.GetInt();
|
this->currentPaymentOptions.last().pop_prepaid_option_id = k->value.GetInt();
|
||||||
} else if (strcmp(inner_obj_name, "pop_prepay_option_id") == 0) {
|
|
||||||
this->currentPaymentOptions.last().pop_prepay_option_id = k->value.GetInt();
|
|
||||||
} else if (strcmp(inner_obj_name, "pop_truncate_last_interpolation_step") == 0) {
|
} else if (strcmp(inner_obj_name, "pop_truncate_last_interpolation_step") == 0) {
|
||||||
this->currentPaymentOptions.last().pop_truncate_last_interpolation_step = k->value.GetBool();
|
this->currentPaymentOptions.last().pop_truncate_last_interpolation_step = k->value.GetBool();
|
||||||
} else if (strcmp(inner_obj_name, "pop_accumulate_prices") == 0) {
|
} else if (strcmp(inner_obj_name, "pop_accumulate_prices") == 0) {
|
||||||
@@ -782,42 +721,6 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
} else if (strcmp(inner_obj_name, "pun_duration_min") == 0) Duration.pun_duration_min = k->value.GetInt();
|
} else if (strcmp(inner_obj_name, "pun_duration_min") == 0) Duration.pun_duration_min = k->value.GetInt();
|
||||||
else if (strcmp(inner_obj_name, "pun_duration_max") == 0) Duration.pun_duration_max = k->value.GetInt();
|
else if (strcmp(inner_obj_name, "pun_duration_max") == 0) Duration.pun_duration_max = k->value.GetInt();
|
||||||
else if (strcmp(inner_obj_name, "pun_interpolation_id") == 0) Duration.pun_interpolation_id = k->value.GetInt();
|
else if (strcmp(inner_obj_name, "pun_interpolation_id") == 0) Duration.pun_interpolation_id = k->value.GetInt();
|
||||||
else if (strcmp(inner_obj_name, "pun_netto") == 0) {
|
|
||||||
if (k->value.IsBool()) {
|
|
||||||
Duration.pun_netto = k->value.GetBool();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (strcmp(inner_obj_name, "pun_brutto") == 0) {
|
|
||||||
if (k->value.IsBool()) {
|
|
||||||
Duration.pun_brutto = k->value.GetBool();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (strcmp(inner_obj_name, "pun_fixed") == 0) {
|
|
||||||
if (k->value.IsBool()) {
|
|
||||||
Duration.pun_fixed = k->value.GetBool();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (strcmp(inner_obj_name, "pun_mutable") == 0) {
|
|
||||||
if (k->value.IsBool()) {
|
|
||||||
Duration.pun_mutable = k->value.GetBool();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (strcmp(inner_obj_name, "pun_round_to_next_24h_boundary") == 0) {
|
|
||||||
if (k->value.IsBool()) {
|
|
||||||
Duration.pun_round_to_next_24h_boundary = k->value.GetBool();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (strcmp(inner_obj_name, "pun_round_to_prev_24h_boundary") == 0) {
|
|
||||||
if (k->value.IsBool()) {
|
|
||||||
Duration.pun_round_to_prev_24h_boundary = k->value.GetBool();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (strcmp(inner_obj_name, "pun_align_with_timepoint") == 0) {
|
|
||||||
if (k->value.IsString()) {
|
|
||||||
QDateTime const &dt = QDateTime::fromString(k->value.GetString(), Qt::ISODate);
|
|
||||||
Duration.pun_align_with_timepoint = dt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MemberType::SpecialDaysWorktimeType:
|
case MemberType::SpecialDaysWorktimeType:
|
||||||
if (strcmp(inner_obj_name, "pedwt_id") == 0) SpecialDaysWorktime.pedwt_id = k->value.GetInt();
|
if (strcmp(inner_obj_name, "pedwt_id") == 0) SpecialDaysWorktime.pedwt_id = k->value.GetInt();
|
||||||
@@ -882,7 +785,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
} break;
|
} break;
|
||||||
case MemberType::DurationType:
|
case MemberType::DurationType:
|
||||||
cfg->Duration.insert(pair<int, ATBDuration>(Duration.pun_id, Duration));
|
cfg->Duration.insert(pair<int, ATBDuration>(Duration.pun_id, Duration));
|
||||||
//qCritical() << Duration;
|
// qCritical() << Duration;
|
||||||
break;
|
break;
|
||||||
case MemberType::SpecialDaysWorktimeType:
|
case MemberType::SpecialDaysWorktimeType:
|
||||||
cfg->SpecialDaysWorktime.insert(pair<int, ATBSpecialDaysWorktime>(SpecialDaysWorktime.pedwt_period_exc_day_id, SpecialDaysWorktime));
|
cfg->SpecialDaysWorktime.insert(pair<int, ATBSpecialDaysWorktime>(SpecialDaysWorktime.pedwt_period_exc_day_id, SpecialDaysWorktime));
|
||||||
@@ -936,10 +839,6 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
cfg->TariffCarryOverOptions.insert(pair<int, ATBCarryOver>(TariffCarryOver.id, TariffCarryOver));
|
cfg->TariffCarryOverOptions.insert(pair<int, ATBCarryOver>(TariffCarryOver.id, TariffCarryOver));
|
||||||
// qCritical() << TariffCarryOver;
|
// qCritical() << TariffCarryOver;
|
||||||
break;
|
break;
|
||||||
case MemberType::PrepaidOptionType:
|
|
||||||
cfg->TariffPrepayOptions.insert(pair<int, ATBPrepay>(TariffPrepayOption.id, TariffPrepayOption));
|
|
||||||
//qCritical() << TariffPrepayOption;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1361,7 +1260,7 @@ std::optional<QDateTime> Configuration::prepaidStart(QDateTime const &start, int
|
|||||||
std::optional<QDateTime> value;
|
std::optional<QDateTime> value;
|
||||||
QDateTime s = start;
|
QDateTime s = start;
|
||||||
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid option id:" << prepaid_option_id;
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepaid option id:" << prepaid_option_id;
|
||||||
|
|
||||||
std::optional<ATBPrepaid> prepaid_option = getPrepaidType(prepaid_option_id);
|
std::optional<ATBPrepaid> prepaid_option = getPrepaidType(prepaid_option_id);
|
||||||
if (prepaid_option.has_value()) {
|
if (prepaid_option.has_value()) {
|
||||||
|
258
main/main.cpp
258
main/main.cpp
@@ -51,7 +51,8 @@ extern "C" char* strptime(const char* s,
|
|||||||
#define SEXTEN (0)
|
#define SEXTEN (0)
|
||||||
#define SCHNALS_LEITER_KIRCHL (0)
|
#define SCHNALS_LEITER_KIRCHL (0)
|
||||||
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
|
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
|
||||||
#define VALSER_ALM (1)
|
#define VALSER_ALM (0)
|
||||||
|
#define FUCHS_MUEHLBACH (1)
|
||||||
|
|
||||||
#if NEUHAUSER_KIRCHDORF==1
|
#if NEUHAUSER_KIRCHDORF==1
|
||||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
static bool test_neuhauser_kirchdorf(int step, double cost) {
|
||||||
@@ -575,8 +576,8 @@ int main() {
|
|||||||
int pop_max_price;
|
int pop_max_price;
|
||||||
int pop_daily_card_price;
|
int pop_daily_card_price;
|
||||||
|
|
||||||
//input.open("/home/linux/customer_505/etc/psa_tariff/tariff01.json");
|
input.open("/home/linux/customer_505/etc/psa_tariff/tariff01.json");
|
||||||
input.open("/opt/ptu5/opt/customer_505/etc/psa_tariff/tariff01.json");
|
//input.open("/opt/ptu5/opt/customer_505/etc/psa_tariff/tariff01.json");
|
||||||
|
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
while(input >> sstr.rdbuf());
|
while(input >> sstr.rdbuf());
|
||||||
@@ -588,10 +589,13 @@ int main() {
|
|||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
if (isParsed) {
|
if (isParsed) {
|
||||||
pop_min_time = get_minimal_parkingtime(&cfg);
|
//PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
|
||||||
pop_max_time = get_maximal_parkingtime(&cfg);
|
PermitType permitType(PERMIT_TYPE::DAY_TICKET_PKW);
|
||||||
pop_min_price = get_minimal_parkingprice(&cfg);
|
|
||||||
pop_max_price = get_maximal_parkingprice(&cfg);
|
pop_min_time = get_minimal_parkingtime(&cfg, permitType);
|
||||||
|
pop_max_time = get_maximal_parkingtime(&cfg, permitType);
|
||||||
|
pop_min_price = get_minimal_parkingprice(&cfg, permitType);
|
||||||
|
pop_max_price = get_maximal_parkingprice(&cfg, permitType);
|
||||||
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
||||||
|
|
||||||
qCritical() << " pop_min_time: " << pop_min_time;
|
qCritical() << " pop_min_time: " << pop_min_time;
|
||||||
@@ -649,10 +653,10 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
||||||
for (int minutes = 1020; minutes <= 1020; minutes += 1) {
|
for (int minutes = 480; minutes <= 480; minutes += 1) {
|
||||||
QDateTime start = s.addSecs(minutes * 60);
|
QDateTime start = s.addSecs(minutes * 60);
|
||||||
|
|
||||||
qCritical() << "start" << start.toString(Qt::ISODate);
|
// qCritical() << "start" << start.toString(Qt::ISODate);
|
||||||
|
|
||||||
QDateTime effectiveStart = start;
|
QDateTime effectiveStart = start;
|
||||||
|
|
||||||
@@ -669,8 +673,136 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
|
for (int i = 700; i <= 1400; i += 700) {
|
||||||
for (int i = 200; i <= 200; i += 10) {
|
cost = i;
|
||||||
|
|
||||||
|
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, permitType))) { // return value
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cs) {
|
||||||
|
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
||||||
|
} else {
|
||||||
|
// qCritical() << cs.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
//qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
||||||
|
// << "> end" << end.toString(Qt::ISODate);
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
start = QDateTime::currentDateTime();
|
||||||
|
//start.setTime(QTime(9, 57, 0));
|
||||||
|
|
||||||
|
for (int netto_parking_time = 60; netto_parking_time <= 60; netto_parking_time += 60) {
|
||||||
|
|
||||||
|
QDateTime end;
|
||||||
|
struct price_t price;
|
||||||
|
cs = compute_price_for_parking_ticket(&cfg, start, netto_parking_time, end, &price, permitType, true);
|
||||||
|
|
||||||
|
qCritical() << "start" << start.toString(Qt::ISODate) << "end" << end.toString(Qt::ISODate)
|
||||||
|
<< "price" << price.netto;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if FUCHS_MUEHLBACH==1
|
||||||
|
std::ifstream input;
|
||||||
|
int pop_min_time;
|
||||||
|
int pop_max_time;
|
||||||
|
int pop_min_price;
|
||||||
|
int pop_max_price;
|
||||||
|
int pop_daily_card_price;
|
||||||
|
|
||||||
|
input.open("/home/linux/customer_504/etc/psa_tariff/tariff01.json");
|
||||||
|
//input.open("/opt/ptu5/opt/customer_505/etc/psa_tariff/tariff01.json");
|
||||||
|
|
||||||
|
std::stringstream sstr;
|
||||||
|
while(input >> sstr.rdbuf());
|
||||||
|
std::string json(sstr.str());
|
||||||
|
|
||||||
|
Configuration cfg;
|
||||||
|
|
||||||
|
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
|
if (isParsed) {
|
||||||
|
PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
|
||||||
|
|
||||||
|
//pop_min_time = get_minimal_parkingtime(&cfg, permitType);
|
||||||
|
//pop_max_time = get_maximal_parkingtime(&cfg, permitType);
|
||||||
|
//pop_min_price = get_minimal_parkingprice(&cfg, permitType);
|
||||||
|
//pop_max_price = get_maximal_parkingprice(&cfg, permitType);
|
||||||
|
//pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
|
||||||
|
|
||||||
|
//qCritical() << " pop_min_time: " << pop_min_time;
|
||||||
|
//qCritical() << " pop_max_time: " << pop_max_time;
|
||||||
|
//qCritical() << " pop_min_price: " << pop_min_price;
|
||||||
|
//qCritical() << " pop_max_price: " << pop_max_price;
|
||||||
|
|
||||||
|
CalcState cs;
|
||||||
|
double cost;
|
||||||
|
int durationInMinutes = 0;
|
||||||
|
int offsetInMinutes = 0;
|
||||||
|
|
||||||
|
// for (int day = Qt::Monday; day <= Qt::Sunday; ++day) {
|
||||||
|
for (int day = Qt::Wednesday; day <= Qt::Wednesday; ++day) {
|
||||||
|
QDateTime s(QDate(2024, 8, 11 + day), QTime(0, 0, 0));
|
||||||
|
QDateTime end;
|
||||||
|
|
||||||
|
switch (day) {
|
||||||
|
case (int)Qt::Monday:
|
||||||
|
qCritical() << "Monday";
|
||||||
|
break;
|
||||||
|
case (int)Qt::Tuesday:
|
||||||
|
qCritical() << "Tuesday";
|
||||||
|
break;
|
||||||
|
case (int)Qt::Wednesday:
|
||||||
|
qCritical() << "Wednesday";
|
||||||
|
break;
|
||||||
|
case (int)Qt::Thursday:
|
||||||
|
qCritical() << "Thursday";
|
||||||
|
break;
|
||||||
|
case (int)Qt::Friday:
|
||||||
|
qCritical() << "Friday";
|
||||||
|
break;
|
||||||
|
case (int)Qt::Saturday:
|
||||||
|
qCritical() << "Saturday";
|
||||||
|
break;
|
||||||
|
case (int)Qt::Sunday:
|
||||||
|
qCritical() << "Sunday";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//for (int minutes = 0; minutes < 1440; ++minutes) {
|
||||||
|
for (int minutes = 491; minutes <= 491; minutes += 1) {
|
||||||
|
QDateTime start = s.addSecs(minutes * 60);
|
||||||
|
|
||||||
|
//qCritical() << "start" << start.toString(Qt::ISODate);
|
||||||
|
|
||||||
|
QDateTime effectiveStart = start;
|
||||||
|
|
||||||
|
// hier sollte man auch testen was passiert, falls man ausserhalb
|
||||||
|
// der verkaufsdaten steht
|
||||||
|
if (start.time() < QTime(7, 0, 0)) {
|
||||||
|
effectiveStart.setTime(QTime(7, 0, 0));
|
||||||
|
} else
|
||||||
|
if (start.time() <= QTime(20, 0, 0)) {
|
||||||
|
effectiveStart = start;
|
||||||
|
} else {
|
||||||
|
effectiveStart = start.addDays(1);
|
||||||
|
effectiveStart.setTime(QTime(7, 0, 0)); // next day
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
qCritical() << "";
|
||||||
|
qCritical() << "compute_duration_for_parking_ticket";
|
||||||
|
qCritical() << "===================================";
|
||||||
|
|
||||||
|
for (int i = 0; i <= 600; i += 10) {
|
||||||
cost = i;
|
cost = i;
|
||||||
|
|
||||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, permitType))) { // return value
|
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, permitType))) { // return value
|
||||||
@@ -687,33 +819,14 @@ int main() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
for (int i = 700; i <= 1400; i += 700) {
|
qCritical() << "";
|
||||||
//for (int i = 2100; i <= 2100; i += 10) {
|
qCritical() << "compute_price_for_parking_ticket";
|
||||||
cost = i;
|
qCritical() << "================================";
|
||||||
|
|
||||||
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW)))) { // return value
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cs) {
|
|
||||||
qCritical() << "ERROR CalcState" << cs.toString() << endl;
|
|
||||||
} else {
|
|
||||||
// qCritical() << cs.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
|
|
||||||
<< "> end" << end.toString(Qt::ISODate);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
start = QDateTime::currentDateTime();
|
|
||||||
start.setTime(QTime(9, 57, 0));
|
|
||||||
|
|
||||||
for (int i = 66; i <= 66; i += 6) {
|
|
||||||
|
|
||||||
|
for (int netto_parking_time = 180; netto_parking_time <= (180 + 720*3); netto_parking_time += 720) {
|
||||||
QDateTime end;
|
QDateTime end;
|
||||||
struct price_t price;
|
struct price_t price;
|
||||||
cs = compute_price_for_parking_ticket(&cfg, start, i, end, &price);
|
cs = compute_price_for_parking_ticket(&cfg, start, netto_parking_time, end, &price, permitType, true);
|
||||||
|
|
||||||
qCritical() << "start" << start.toString(Qt::ISODate) << "end" << end.toString(Qt::ISODate)
|
qCritical() << "start" << start.toString(Qt::ISODate) << "end" << end.toString(Qt::ISODate)
|
||||||
<< "price" << price.netto;
|
<< "price" << price.netto;
|
||||||
@@ -741,14 +854,7 @@ int main() {
|
|||||||
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json");
|
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json");
|
||||||
}
|
}
|
||||||
if (zone == 3) {
|
if (zone == 3) {
|
||||||
//input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json");
|
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json");
|
||||||
//input.open("/home/linux/customer_502/etc/psa_tariff/tariff01.json");
|
|
||||||
|
|
||||||
// schnals
|
|
||||||
// input.open("/opt/ptu5/opt/customer_505/etc/psa_tariff/tariff01.json");
|
|
||||||
|
|
||||||
// muehlbach
|
|
||||||
input.open("/opt/ptu5/opt/customer_504/etc/psa_tariff/tariff01.json");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
@@ -907,7 +1013,7 @@ int main() {
|
|||||||
int Down = 0;
|
int Down = 0;
|
||||||
int Up = 1;
|
int Up = 1;
|
||||||
|
|
||||||
QDateTime start = QDateTime::currentDateTime();
|
QDateTime const start = QDateTime::currentDateTime();
|
||||||
int paymentOptionIndex = cfg.getPaymentOptionIndex(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
int paymentOptionIndex = cfg.getPaymentOptionIndex(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
|
||||||
|
|
||||||
if (paymentOptionIndex != 0) {
|
if (paymentOptionIndex != 0) {
|
||||||
@@ -920,61 +1026,17 @@ int main() {
|
|||||||
//QSet<uint32_t> const prices2{500, 1600, 2400, 3200, 4000, 4800, 5600};
|
//QSet<uint32_t> const prices2{500, 1600, 2400, 3200, 4000, 4800, 5600};
|
||||||
|
|
||||||
QDateTime end;
|
QDateTime end;
|
||||||
|
|
||||||
QDateTime s(QDateTime::currentDateTime());
|
|
||||||
s.setTime(QTime(10, 0, 0));
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
pop_min_time = get_minimal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
|
|
||||||
pop_max_time = get_maximal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
|
|
||||||
|
|
||||||
pop_min_price = get_minimal_parkingprice(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex, s);
|
|
||||||
pop_max_price = get_maximal_parkingprice(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
|
|
||||||
|
|
||||||
pop_daily_card_price = cfg.getPaymentOptions(paymentOptionIndex).pop_daily_card_price;
|
|
||||||
|
|
||||||
int h = pop_min_time / 60;
|
|
||||||
int m = pop_min_time % 60;
|
|
||||||
qCritical().noquote() << QString(" pop_min_time %1 (%2h, %3m)").arg(pop_min_time).arg(h).arg(m);
|
|
||||||
|
|
||||||
h = pop_max_time / 60;
|
|
||||||
m = pop_max_time % 60;
|
|
||||||
qCritical().noquote()
|
|
||||||
<< QString(" pop_max_time %1 (%2h, %3m)").arg(pop_max_time).arg(h).arg(m);
|
|
||||||
|
|
||||||
qCritical() << " pop_min_price " << pop_min_price;
|
|
||||||
qCritical() << " pop_max_price " << pop_max_price;
|
|
||||||
qCritical() << "pop_daily_card_price " << pop_daily_card_price;
|
|
||||||
#endif
|
|
||||||
CalcState calcState;
|
CalcState calcState;
|
||||||
|
|
||||||
#if 1
|
QDateTime s(QDateTime::currentDateTime());
|
||||||
qCritical() << "start" << s.toString(Qt::ISODate);
|
s.setTime(QTime(12, 0, 0));
|
||||||
//for (int i = 1; i < 11; ++i) {
|
|
||||||
for (int i = 0; i < 21; ++i) {
|
|
||||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
|
||||||
(double)i*10,
|
|
||||||
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
|
||||||
qCritical() << "RUN" << i << ": start" << s.toString(Qt::ISODate)
|
|
||||||
<< ": price" << i*10 << "->" << end.toString(Qt::ISODate) << calcState.toString();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
struct price_t price;
|
|
||||||
int netto_parking_time = 1440;
|
|
||||||
|
|
||||||
start = s;
|
int minimal_parking_price = get_minimal_parkingprice(&cfg,
|
||||||
qCritical() << "RUN" << 0 << ": start" << s.toString(Qt::ISODate);
|
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
|
||||||
|
paymentOptionIndex, s);
|
||||||
calcState = compute_price_for_parking_ticket(&cfg, start, netto_parking_time,
|
|
||||||
end, &price,
|
|
||||||
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
|
|
||||||
qCritical() << "RUN" << 0 << ": start" << start.toString(Qt::ISODate)
|
|
||||||
<< ": price for netto-time" << netto_parking_time
|
|
||||||
<< "->" << price.netto << "->" << end.toString(Qt::ISODate) << calcState.toString();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
qCritical() << "minimal parking price" << minimal_parking_price;
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||||
@@ -983,11 +1045,11 @@ int main() {
|
|||||||
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
|
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// #else
|
#else
|
||||||
s.setTime(QTime(12, 0, 0));
|
s.setTime(QTime(15, 0, 0));
|
||||||
|
|
||||||
minimal_parking_price = get_minimal_parkingprice(&cfg,
|
minimal_parking_price = get_minimal_parkingprice(&cfg,
|
||||||
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS),
|
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
|
||||||
paymentOptionIndex, s);
|
paymentOptionIndex, s);
|
||||||
|
|
||||||
qCritical() << "minimal parking price" << minimal_parking_price;
|
qCritical() << "minimal parking price" << minimal_parking_price;
|
||||||
@@ -995,7 +1057,7 @@ int main() {
|
|||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
calcState = compute_duration_for_parking_ticket(&cfg, s,
|
||||||
(double)minimal_parking_price + i*800,
|
(double)minimal_parking_price + i*800,
|
||||||
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
|
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
|
||||||
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
|
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user