Compare commits
	
		
			56 Commits
		
	
	
		
			v2
			...
			bad-neuena
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1d8dfcfa22 | |||
| 48fccafe76 | |||
| 9394625d35 | |||
| 7492e37e02 | |||
| f0dca3917c | |||
| 57ccbc150a | |||
| 8fa4335669 | |||
| 49298a1821 | |||
| 6fb4d245cb | |||
| 2dc93271fd | |||
| 5be5798681 | |||
| 1a24bc4572 | |||
| 068575f8e8 | |||
| e121cef17e | |||
| bdaea1106c | |||
| bc17213597 | |||
| 64b2b4bd85 | |||
| 8737508839 | |||
| 02f0500eac | |||
| 2d53224feb | |||
| 38964ad9a8 | |||
| d3f18f3b82 | |||
| 1a4265372e | |||
| eb20410849 | |||
| 2a492475e3 | |||
| 6a5272da7a | |||
| 4d5583df2d | |||
| de6f263817 | |||
| e4ce14da3f | |||
| b71c979a91 | |||
| 33f43fb83d | |||
| 1606a784a4 | |||
| 9f2cf613e1 | |||
| dbd9644047 | |||
| f8fef12b55 | |||
| 1dd81d4a56 | |||
| f93cf11d23 | |||
| 9d0ac4f8ce | |||
| 4ec5589f30 | |||
| c1d5ffcf3c | |||
| 7aded2b7fb | |||
| ed9e60a972 | |||
| 5d35331c83 | |||
| c7623429d9 | |||
| b596086245 | |||
| 24ca857b6f | |||
| ea0bcde413 | |||
| e93b08505a | |||
| 44efd44ede | |||
| 9d72574106 | |||
| d8ec41ebfc | |||
| f17c4f240b | |||
| 76bb1eb56a | |||
| 3b813e5eff | |||
| 436f5a109b | |||
| e17e54b315 | 
@@ -42,18 +42,34 @@ struct CALCULATE_LIBRARY_API price_t {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct CALCULATE_LIBRARY_API CalcState {
 | 
			
		||||
    static QString const SUCCESS;
 | 
			
		||||
    static QString const ERROR_PARSING_ZONE_NR;
 | 
			
		||||
    static QString const ERROR_LOADING_TARIFF;
 | 
			
		||||
    static QString const ERROR_PARSING_TARIFF;
 | 
			
		||||
    static QString const NEGATIVE_PARKING_TIME;
 | 
			
		||||
    static QString const INVALID_START_DATE;
 | 
			
		||||
    static QString const WRONG_PARAM_VALUES;
 | 
			
		||||
    static QString const WRONG_ISO_TIME_FORMAT;
 | 
			
		||||
    static QString const ABOVE_MAX_PARKING_TIME;
 | 
			
		||||
    static QString const BELOW_MIN_PARKING_TIME;
 | 
			
		||||
    static QString const BELOW_MIN_PARKING_PRICE;
 | 
			
		||||
    static QString const ABOVE_MAX_PARKING_PRICE;
 | 
			
		||||
    static QString const OVERPAID;
 | 
			
		||||
    static QString const OUTSIDE_ALLOWED_PARKING_TIME;
 | 
			
		||||
 | 
			
		||||
    enum class State : uint8_t {
 | 
			
		||||
        SUCCESS,
 | 
			
		||||
        ERROR_PARSING_ZONE_NR,
 | 
			
		||||
        ERROR_LOADING_TARIFF,
 | 
			
		||||
        ERROR_PARSING_TARIFF,
 | 
			
		||||
        NEGATIVE_PARING_TIME,
 | 
			
		||||
        NEGATIVE_PARKING_TIME,
 | 
			
		||||
        INVALID_START_DATE,
 | 
			
		||||
        WRONG_PARAM_VALUES,
 | 
			
		||||
        WRONG_ISO_TIME_FORMAT,
 | 
			
		||||
        ABOVE_MAX_PARKING_TIME,
 | 
			
		||||
        BELOW_MIN_PARKING_TIME,
 | 
			
		||||
        BELOW_MIN_PARKING_PRICE,
 | 
			
		||||
        ABOVE_MAX_PARKING_PRICE,
 | 
			
		||||
        OVERPAID,
 | 
			
		||||
        OUTSIDE_ALLOWED_PARKING_TIME
 | 
			
		||||
    };
 | 
			
		||||
@@ -88,43 +104,47 @@ struct CALCULATE_LIBRARY_API CalcState {
 | 
			
		||||
        QString s;
 | 
			
		||||
        switch (m_status) {
 | 
			
		||||
        case State::SUCCESS:
 | 
			
		||||
            s = "SUCCESS";
 | 
			
		||||
            s = CalcState::SUCCESS;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::ERROR_PARSING_ZONE_NR:
 | 
			
		||||
            s = "ERROR_PARSING_ZONE_NR";
 | 
			
		||||
            s = CalcState::ERROR_PARSING_ZONE_NR;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::ERROR_LOADING_TARIFF:
 | 
			
		||||
            s = "ERROR_LOADING_TARIFF";
 | 
			
		||||
            s = CalcState::ERROR_LOADING_TARIFF;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::ERROR_PARSING_TARIFF:
 | 
			
		||||
            s = "ERROR_PARSING_TARIFF";
 | 
			
		||||
            s = CalcState::ERROR_PARSING_TARIFF;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::NEGATIVE_PARING_TIME:
 | 
			
		||||
            s = "NEGATIVE_PARKING_TIME";
 | 
			
		||||
        case State::NEGATIVE_PARKING_TIME:
 | 
			
		||||
            s = CalcState::NEGATIVE_PARKING_TIME;
 | 
			
		||||
           break;
 | 
			
		||||
        case State::ABOVE_MAX_PARKING_TIME:
 | 
			
		||||
            s = "ABOVE_MAX_PARKING_TIME";
 | 
			
		||||
            s = CalcState::ABOVE_MAX_PARKING_TIME;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::WRONG_PARAM_VALUES:
 | 
			
		||||
            s = "WRONG_PARAM_VALUES";
 | 
			
		||||
            s = CalcState::WRONG_PARAM_VALUES;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::BELOW_MIN_PARKING_TIME:
 | 
			
		||||
            s = "BELOW_MIN_PARKING_TIME";
 | 
			
		||||
            s = CalcState::BELOW_MIN_PARKING_TIME;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::BELOW_MIN_PARKING_PRICE:
 | 
			
		||||
            s = "BELOW_MIN_PARKING_PRICE";
 | 
			
		||||
            s = CalcState::BELOW_MIN_PARKING_PRICE;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::OVERPAID:
 | 
			
		||||
            s = "OVERPAID";
 | 
			
		||||
            s = CalcState::OVERPAID;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::INVALID_START_DATE:
 | 
			
		||||
            s = "INVALID_START_DATE";
 | 
			
		||||
            s = CalcState::INVALID_START_DATE;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::WRONG_ISO_TIME_FORMAT:
 | 
			
		||||
            s = "WRONG_ISO_TIME_FORMAT";
 | 
			
		||||
            s = CalcState::WRONG_ISO_TIME_FORMAT;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::OUTSIDE_ALLOWED_PARKING_TIME:
 | 
			
		||||
            s = "OUTSIDE_ALLOWED_PARKING_TIME";
 | 
			
		||||
            s = CalcState::OUTSIDE_ALLOWED_PARKING_TIME;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::ABOVE_MAX_PARKING_PRICE:
 | 
			
		||||
            s = CalcState::ABOVE_MAX_PARKING_TIME;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        return s + ":" + m_desc;
 | 
			
		||||
    }
 | 
			
		||||
@@ -133,51 +153,101 @@ struct CALCULATE_LIBRARY_API CalcState {
 | 
			
		||||
        QString s;
 | 
			
		||||
        switch (m_status) {
 | 
			
		||||
        case State::SUCCESS:
 | 
			
		||||
            s = "SUCCESS";
 | 
			
		||||
            s = CalcState::SUCCESS;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::ERROR_PARSING_ZONE_NR:
 | 
			
		||||
            s = "ERROR_PARSING_ZONE_NR";
 | 
			
		||||
            s = CalcState::ERROR_PARSING_ZONE_NR;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::ERROR_LOADING_TARIFF:
 | 
			
		||||
            s = "ERROR_LOADING_TARIFF";
 | 
			
		||||
            s = CalcState::ERROR_LOADING_TARIFF;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::ERROR_PARSING_TARIFF:
 | 
			
		||||
            s = "ERROR_PARSING_TARIFF";
 | 
			
		||||
            s = CalcState::ERROR_PARSING_TARIFF;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::NEGATIVE_PARING_TIME:
 | 
			
		||||
            s = "NEGATIVE_PARKING_TIME";
 | 
			
		||||
        case State::NEGATIVE_PARKING_TIME:
 | 
			
		||||
            s = CalcState::NEGATIVE_PARKING_TIME;
 | 
			
		||||
           break;
 | 
			
		||||
        case State::ABOVE_MAX_PARKING_TIME:
 | 
			
		||||
            s = "ABOVE_MAX_PARKING_TIME";
 | 
			
		||||
            s = CalcState::ABOVE_MAX_PARKING_TIME;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::WRONG_PARAM_VALUES:
 | 
			
		||||
            s = "WRONG_PARAM_VALUES";
 | 
			
		||||
            s = CalcState::WRONG_PARAM_VALUES;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::BELOW_MIN_PARKING_TIME:
 | 
			
		||||
            s = "BELOW_MIN_PARKING_TIME";
 | 
			
		||||
            s = CalcState::BELOW_MIN_PARKING_TIME;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::BELOW_MIN_PARKING_PRICE:
 | 
			
		||||
            s = "BELOW_MIN_PARKING_PRICE";
 | 
			
		||||
            s = CalcState::BELOW_MIN_PARKING_PRICE;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::OVERPAID:
 | 
			
		||||
            s = "OVERPAID";
 | 
			
		||||
            s = CalcState::OVERPAID;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::INVALID_START_DATE:
 | 
			
		||||
            s = "INVALID_START_DATE";
 | 
			
		||||
            s = CalcState::INVALID_START_DATE;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::WRONG_ISO_TIME_FORMAT:
 | 
			
		||||
            s = "WRONG_ISO_TIME_FORMAT";
 | 
			
		||||
            s = CalcState::WRONG_ISO_TIME_FORMAT;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::OUTSIDE_ALLOWED_PARKING_TIME:
 | 
			
		||||
            s = "OUTSIDE_ALLOWED_PARKING_TIME";
 | 
			
		||||
            s = CalcState::OUTSIDE_ALLOWED_PARKING_TIME;
 | 
			
		||||
            break;
 | 
			
		||||
        case State::ABOVE_MAX_PARKING_PRICE:
 | 
			
		||||
            s = CalcState::ABOVE_MAX_PARKING_TIME;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        return s + ":" + m_desc;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    CalcState &set(State s) { m_status = s; return *this; }
 | 
			
		||||
    CalcState &setStatus(State s) { return set(s); }
 | 
			
		||||
    CalcState &setStatus(QString const &desc) {
 | 
			
		||||
        if (desc == SUCCESS) {
 | 
			
		||||
            m_status = State::SUCCESS;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == ERROR_PARSING_ZONE_NR) {
 | 
			
		||||
            m_status = State::ERROR_PARSING_ZONE_NR;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == ERROR_LOADING_TARIFF) {
 | 
			
		||||
            m_status = State::SUCCESS;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == ERROR_PARSING_TARIFF) {
 | 
			
		||||
            m_status = State::ERROR_LOADING_TARIFF;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == NEGATIVE_PARKING_TIME) {
 | 
			
		||||
            m_status = State::NEGATIVE_PARKING_TIME;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == INVALID_START_DATE) {
 | 
			
		||||
            m_status = State::INVALID_START_DATE;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == WRONG_PARAM_VALUES) {
 | 
			
		||||
            m_status = State::WRONG_PARAM_VALUES;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == WRONG_ISO_TIME_FORMAT) {
 | 
			
		||||
            m_status = State::WRONG_ISO_TIME_FORMAT;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == ABOVE_MAX_PARKING_TIME) {
 | 
			
		||||
            m_status = State::ABOVE_MAX_PARKING_TIME;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == BELOW_MIN_PARKING_TIME) {
 | 
			
		||||
            m_status = State::BELOW_MIN_PARKING_TIME;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == BELOW_MIN_PARKING_PRICE) {
 | 
			
		||||
            m_status = State::BELOW_MIN_PARKING_PRICE;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == OVERPAID) {
 | 
			
		||||
            m_status = State::OVERPAID;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == OUTSIDE_ALLOWED_PARKING_TIME) {
 | 
			
		||||
            m_status = State::OUTSIDE_ALLOWED_PARKING_TIME;
 | 
			
		||||
        } else
 | 
			
		||||
        if (desc == ABOVE_MAX_PARKING_PRICE) {
 | 
			
		||||
            m_status = State::ABOVE_MAX_PARKING_PRICE;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return *this;
 | 
			
		||||
    }
 | 
			
		||||
    State getStatus() const { return m_status; }
 | 
			
		||||
    CalcState &setDesc(QString s) { m_desc = s; return *this; }
 | 
			
		||||
    CalcState &setDesc(QString const &s) { m_desc = s; return *this; }
 | 
			
		||||
 | 
			
		||||
    void setAllowedTimeRange(QTime const &from, QTime const &until) {
 | 
			
		||||
        m_allowedTimeRange.setTimeRange(from, until);
 | 
			
		||||
@@ -197,17 +267,18 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
 | 
			
		||||
 | 
			
		||||
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg);
 | 
			
		||||
 | 
			
		||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg,
 | 
			
		||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
 | 
			
		||||
                                                  PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
 | 
			
		||||
                                                  int paymentOptionIndex=0);
 | 
			
		||||
 | 
			
		||||
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg,
 | 
			
		||||
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
 | 
			
		||||
                                                  PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
 | 
			
		||||
                                                  int paymentOptionIndex=0);
 | 
			
		||||
 | 
			
		||||
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
 | 
			
		||||
                                                   PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
 | 
			
		||||
                                                   int paymentOptionIndex=0);
 | 
			
		||||
                                                   int paymentOptionIndex = 0,
 | 
			
		||||
                                                   QDateTime const &start = QDateTime::currentDateTime());
 | 
			
		||||
 | 
			
		||||
int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
 | 
			
		||||
                                                   PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,9 @@ class Configuration
 | 
			
		||||
public:
 | 
			
		||||
    using SpecialDaysType = std::multimap<int, ATBSpecialDays>;
 | 
			
		||||
    using SpecialDaysWorktimeType = std::multimap<int, ATBSpecialDaysWorktime>;
 | 
			
		||||
    using TimeRangeType = std::multimap<int, ATBTimeRange>;
 | 
			
		||||
    using TariffProductType = std::multimap<int, ATBTariffProduct>;
 | 
			
		||||
    using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
 | 
			
		||||
 | 
			
		||||
    ATBProject project;
 | 
			
		||||
    ATBCurrency Currency;
 | 
			
		||||
@@ -51,13 +54,13 @@ public:
 | 
			
		||||
	multimap<int, ATBWeekDays> WeekDays;
 | 
			
		||||
	multimap<int, ATBPeriodYear> YearPeriod;
 | 
			
		||||
	multimap<int, ATBWeekDaysWorktime> WeekDaysWorktime;
 | 
			
		||||
	multimap<int, ATBPaymentOption> PaymentOption;
 | 
			
		||||
    ATBPaymentOptionType PaymentOption;
 | 
			
		||||
    multimap<int, ATBDailyTicket> DailyTicket;
 | 
			
		||||
    multimap<int, ATBTimeRange> TimeRange;
 | 
			
		||||
    TimeRangeType TimeRange;
 | 
			
		||||
    multimap<int, ATBTimeStepConfig> TimeStepConfig;
 | 
			
		||||
    multimap<int, ATBTimeBase> TimeBase;
 | 
			
		||||
    multimap<int, ATBCustomer> Customer;
 | 
			
		||||
    multimap<int, ATBTariffProduct> TariffProduct;
 | 
			
		||||
    TariffProductType TariffProduct;
 | 
			
		||||
 | 
			
		||||
	/// <summary>
 | 
			
		||||
	/// Parse JSON string
 | 
			
		||||
@@ -85,6 +88,7 @@ public:
 | 
			
		||||
    std::optional<QVector<ATBTariffProduct>> getTariffProductForAllKeys() const;
 | 
			
		||||
    std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(int id) const;
 | 
			
		||||
    std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(PermitType permitType) const;
 | 
			
		||||
    std::optional<QVector<ATBTariffProduct>> getTariffProductForProductTypeName(QString const &permitTypeName) const;
 | 
			
		||||
    std::optional<ATBCustomer> getCustomerForType(ATBCustomer::CustomerType customerType);
 | 
			
		||||
    std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,8 @@
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
 | 
			
		||||
#include <QDateTime>
 | 
			
		||||
 | 
			
		||||
class ATBPaymentOption
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
@@ -22,6 +24,7 @@ public:
 | 
			
		||||
        pop_min_price = 0;
 | 
			
		||||
        pop_max_price = 0;
 | 
			
		||||
        pop_carry_over = -1;
 | 
			
		||||
        pop_carry_over_target = false;
 | 
			
		||||
        pop_carry_over_time_range_id = -1;
 | 
			
		||||
        pop_carry_over_start_time_range = -1;
 | 
			
		||||
        pop_carry_over_end_time_range = -1;
 | 
			
		||||
@@ -41,12 +44,21 @@ public:
 | 
			
		||||
    double pop_min_price;
 | 
			
		||||
    double pop_max_price;
 | 
			
		||||
    int pop_carry_over;
 | 
			
		||||
    bool pop_carry_over_target;
 | 
			
		||||
    int pop_carry_over_time_range_id;
 | 
			
		||||
    int pop_carry_over_start_time_range;
 | 
			
		||||
    int pop_carry_over_end_time_range;
 | 
			
		||||
    int pop_daily_card_price;
 | 
			
		||||
    uint64_t pop_business_hours;
 | 
			
		||||
    int pop_time_step_config;
 | 
			
		||||
 | 
			
		||||
    struct ATBMaxDateTime {
 | 
			
		||||
        int direction;
 | 
			
		||||
        uint8_t week;
 | 
			
		||||
        uint8_t day;
 | 
			
		||||
        QTime time;
 | 
			
		||||
    } pop_min_date_time,
 | 
			
		||||
      pop_max_date_time;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // PAYMENT_OPT_H_INCLUDED
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,13 @@
 | 
			
		||||
#define _OFFICIAL_HOLIDAY_                      (uint64_t)(1ULL << 15)
 | 
			
		||||
#define _ONLY_WEEKEND_                          ((_SAT_|_SUN_))
 | 
			
		||||
#define _ONLY_OPEN_FOR_BUSINESS_DAYS_           (uint64_t)(1ULL << 16)    /* verkaufsoffen */
 | 
			
		||||
#define _WITH_RESTRICTED_HOURS_                 (uint64_t)(1ULL << 17)
 | 
			
		||||
#define _ALL_DAYS_WITH_RESTRICTED_HOURS_        ((_WITH_RESTRICTED_HOURS_|_ALL_DAYS_))
 | 
			
		||||
#define _WEEKEND_WITH_RESTRICTED_HOURS_         ((_WITH_RESTRICTED_HOURS_|_FRI_|_SAT_|_SUN_))
 | 
			
		||||
#define _WORKING_DAYS_WITH_RESTRICTED_HOURS_    ((_WITH_RESTRICTED_HOURS_|_WORKING_DAYS_))
 | 
			
		||||
#define _FRI_WITH_RESTRICTED_HOURS_             ((_WITH_RESTRICTED_HOURS_|_FRI_))
 | 
			
		||||
#define _SAT_WITH_RESTRICTED_HOURS_             ((_WITH_RESTRICTED_HOURS_|_SAT_))
 | 
			
		||||
#define _SUN_WITH_RESTRICTED_HOURS_             ((_WITH_RESTRICTED_HOURS_|_SUN_))
 | 
			
		||||
#define _NOT_DEFINED_                           (uint64_t)(~0ULL)
 | 
			
		||||
 | 
			
		||||
enum BusinessHours : std::uint64_t
 | 
			
		||||
@@ -54,6 +61,12 @@ enum BusinessHours : std::uint64_t
 | 
			
		||||
    OFFICIAL_HOLIDAY = _OFFICIAL_HOLIDAY_,
 | 
			
		||||
    ONLY_WEEKEND = _ONLY_WEEKEND_,
 | 
			
		||||
    ONLY_OPEN_FOR_BUSINESS_DAYS = _ONLY_OPEN_FOR_BUSINESS_DAYS_,
 | 
			
		||||
    ALL_DAYS_WITH_RESTRICTED_HOURS = _ALL_DAYS_WITH_RESTRICTED_HOURS_,
 | 
			
		||||
    WEEKEND_WITH_RESTRICTED_HOURS = _WEEKEND_WITH_RESTRICTED_HOURS_,
 | 
			
		||||
    WORKING_DAYS_WITH_RESTRICTED_HOURS = _WORKING_DAYS_WITH_RESTRICTED_HOURS_,
 | 
			
		||||
    FRI_WITH_RESTRICTED_HOURS = _FRI_WITH_RESTRICTED_HOURS_,
 | 
			
		||||
    SAT_WITH_RESTRICTED_HOURS = _SAT_WITH_RESTRICTED_HOURS_,
 | 
			
		||||
    SUN_WITH_RESTRICTED_HOURS = _SUN_WITH_RESTRICTED_HOURS_,
 | 
			
		||||
    NOT_DEFINED = _NOT_DEFINED_
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,15 +4,16 @@
 | 
			
		||||
#include <QString>
 | 
			
		||||
 | 
			
		||||
enum class PERMIT_TYPE : quint8 {
 | 
			
		||||
    SHORT_TERM_PARKING,
 | 
			
		||||
    DAY_TICKET,
 | 
			
		||||
    SZEGED_START,
 | 
			
		||||
    SZEGED_STOP,
 | 
			
		||||
    DAY_TICKET_ADULT,
 | 
			
		||||
    DAY_TICKET_TEEN,
 | 
			
		||||
    DAY_TICKET_CHILD,
 | 
			
		||||
    FOOD_STAMP,
 | 
			
		||||
    INVALID
 | 
			
		||||
    SHORT_TERM_PARKING=0,
 | 
			
		||||
    DAY_TICKET=1,
 | 
			
		||||
    SZEGED_START=2,
 | 
			
		||||
    SZEGED_STOP=3,
 | 
			
		||||
    DAY_TICKET_ADULT=4,
 | 
			
		||||
    DAY_TICKET_TEEN=5,
 | 
			
		||||
    DAY_TICKET_CHILD=6,
 | 
			
		||||
    INVALID=7,
 | 
			
		||||
    FOOD_STAMP=8,
 | 
			
		||||
    TWENTY_FOUR_HOURS_TICKET=9
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct PermitType {
 | 
			
		||||
@@ -45,6 +46,9 @@ struct PermitType {
 | 
			
		||||
        case 7:
 | 
			
		||||
            m_permitType = PERMIT_TYPE::FOOD_STAMP;
 | 
			
		||||
            break;
 | 
			
		||||
        case 8:
 | 
			
		||||
            m_permitType = PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET;
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            m_permitType = PERMIT_TYPE::INVALID;
 | 
			
		||||
        }
 | 
			
		||||
@@ -74,6 +78,8 @@ struct PermitType {
 | 
			
		||||
            return 6;
 | 
			
		||||
        case PERMIT_TYPE::FOOD_STAMP:
 | 
			
		||||
            return 7;
 | 
			
		||||
        case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
 | 
			
		||||
            return 8;
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
@@ -81,7 +87,7 @@ struct PermitType {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    operator QString () {
 | 
			
		||||
    QString toString() {
 | 
			
		||||
        switch(m_permitType) {
 | 
			
		||||
        case PERMIT_TYPE::DAY_TICKET:
 | 
			
		||||
            return QString("DAY_TICKET");
 | 
			
		||||
@@ -99,13 +105,15 @@ struct PermitType {
 | 
			
		||||
            return QString("SZEGED_STOP");
 | 
			
		||||
        case PERMIT_TYPE::FOOD_STAMP:
 | 
			
		||||
            return QString("FOOD_STAMP");
 | 
			
		||||
        case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
 | 
			
		||||
            return QString("TWENTY_FOUR_HOURS_TICKET");
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        return QString("INVALID");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    operator QString () const {
 | 
			
		||||
    QString toString() const {
 | 
			
		||||
        switch(m_permitType) {
 | 
			
		||||
        case PERMIT_TYPE::DAY_TICKET:
 | 
			
		||||
            return QString("DAY_TICKET");
 | 
			
		||||
@@ -123,11 +131,21 @@ struct PermitType {
 | 
			
		||||
            return QString("SZEGED_STOP");
 | 
			
		||||
        case PERMIT_TYPE::FOOD_STAMP:
 | 
			
		||||
            return QString("FOOD_STAMP");
 | 
			
		||||
        case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
 | 
			
		||||
            return QString("TWENTY_FOUR_HOURS_TICKET");
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        return QString("INVALID");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    operator QString () {
 | 
			
		||||
        return toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    operator QString () const {
 | 
			
		||||
        return toString();
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // TARIFF_PERMIT_TYPE_H_INCLUDED
 | 
			
		||||
 
 | 
			
		||||
@@ -79,12 +79,12 @@ namespace Utilities {
 | 
			
		||||
	double CalculatePricePerUnit(double pra_price, double durationUnit = -1);
 | 
			
		||||
 | 
			
		||||
    QTime SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDayId);
 | 
			
		||||
    QTime SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator it);
 | 
			
		||||
    QTime SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator const &it);
 | 
			
		||||
    QTime SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialDayId);
 | 
			
		||||
    QTime SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator it);
 | 
			
		||||
    QTime WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
 | 
			
		||||
    QTime WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
 | 
			
		||||
    int WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
 | 
			
		||||
    QTime SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator const &it);
 | 
			
		||||
    QTime WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
 | 
			
		||||
    QTime WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
 | 
			
		||||
    int WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
 | 
			
		||||
    // PaymentRate GetPaymentRate(Configuration const *cfg, );
 | 
			
		||||
    bool isCarryOverSet(Configuration const *cfg, PaymentMethod paymentMethodId);
 | 
			
		||||
    bool isCarryOverNotSet(Configuration const *cfg, PaymentMethod paymentMethodId);
 | 
			
		||||
@@ -100,4 +100,5 @@ namespace Utilities {
 | 
			
		||||
    uint32_t computeWeekDaysPrice(Configuration const *cfg, PaymentMethod id);
 | 
			
		||||
    double computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id);
 | 
			
		||||
    QStringList dumpBusinessHours(uint64_t businessHours);
 | 
			
		||||
    uint32_t getDailyTicketCardPrice(Configuration const *cfg, PaymentMethod methodId);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,10 @@ INCLUDEPATH += $$_PRO_FILE_PWD_/include/rapidjson
 | 
			
		||||
#Version is set in yocto recipe with "EXTRA_QMAKEVARS_PRE"
 | 
			
		||||
#VERSION=1.0.0
 | 
			
		||||
 | 
			
		||||
# 04.06.2024: Fix for Szeged: read price for daily ticket directly from entry
 | 
			
		||||
#             PaymentOptions in tariff-file if it is not given as part of a
 | 
			
		||||
#             Json-Product-Array in tariff-file.
 | 
			
		||||
 | 
			
		||||
CONFIG(debug, debug|release) {
 | 
			
		||||
    win32 {
 | 
			
		||||
        QMAKE_CXXFLAGS += -DCALCULATE_LIBRARY_EXPORTS
 | 
			
		||||
 
 | 
			
		||||
@@ -10,17 +10,34 @@
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QList>
 | 
			
		||||
 | 
			
		||||
QString const CalcState::SUCCESS = "SUCCESS";
 | 
			
		||||
QString const CalcState::ERROR_PARSING_ZONE_NR = "ERROR_PARSING_ZONE_NR";
 | 
			
		||||
QString const CalcState::ERROR_LOADING_TARIFF = "ERROR_LOADING_TARIFF";
 | 
			
		||||
QString const CalcState::ERROR_PARSING_TARIFF = "ERROR_PARSING_TARIFF";
 | 
			
		||||
QString const CalcState::NEGATIVE_PARKING_TIME = "NEGATIVE_PARKING_TIME";
 | 
			
		||||
QString const CalcState::INVALID_START_DATE = "INVALID_START_DATE";
 | 
			
		||||
QString const CalcState::WRONG_PARAM_VALUES = "WRONG_PARAM_VALUES";
 | 
			
		||||
QString const CalcState::WRONG_ISO_TIME_FORMAT = "WRONG_ISO_TIME_FORMAT";
 | 
			
		||||
QString const CalcState::ABOVE_MAX_PARKING_TIME = "ABOVE_MAX_PARKING_TIME";
 | 
			
		||||
QString const CalcState::BELOW_MIN_PARKING_TIME = "BELOW_MIN_PARKING_TIME";
 | 
			
		||||
QString const CalcState::BELOW_MIN_PARKING_PRICE = "BELOW_MIN_PARKING_PRICE";
 | 
			
		||||
QString const CalcState::ABOVE_MAX_PARKING_PRICE = "ABOVE_MAX_PARKING_PRICE";
 | 
			
		||||
QString const CalcState::OVERPAID = "OVERPAID";
 | 
			
		||||
QString const CalcState::OUTSIDE_ALLOWED_PARKING_TIME = "OUTSIDE_ALLOWED_PARKING_TIME";
 | 
			
		||||
 | 
			
		||||
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
 | 
			
		||||
    return Calculator::GetInstance().GetTimeSteps(cfg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg,
 | 
			
		||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
 | 
			
		||||
                                                  PERMIT_TYPE permitType,
 | 
			
		||||
                                                  int paymentOptionIndex) {
 | 
			
		||||
    int minTime = 0;
 | 
			
		||||
 | 
			
		||||
    switch(permitType) {
 | 
			
		||||
    case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
 | 
			
		||||
        QList<int> const tsteps = Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex);
 | 
			
		||||
        Q_UNUSED(tsteps);
 | 
			
		||||
        minTime = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
			
		||||
    } break;
 | 
			
		||||
    case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
			
		||||
@@ -33,14 +50,14 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg,
 | 
			
		||||
        // for each new sell-procedure, recomute the timesteps. implicitly, set
 | 
			
		||||
        // the minimal parking time.
 | 
			
		||||
        Calculator::GetInstance().ResetTimeSteps(paymentOptionIndex);
 | 
			
		||||
        Calculator::GetInstance().GetTimeSteps(cfg, paymentOptionIndex);
 | 
			
		||||
        Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex);
 | 
			
		||||
        minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return minTime;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg,
 | 
			
		||||
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
 | 
			
		||||
                                                  PERMIT_TYPE permitType,
 | 
			
		||||
                                                  int paymentOptionIndex) {
 | 
			
		||||
    int maxTime = 0;
 | 
			
		||||
@@ -59,11 +76,13 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return maxTime;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
 | 
			
		||||
                                                   PERMIT_TYPE permitType,
 | 
			
		||||
                                                   int paymentOptionIndex) {
 | 
			
		||||
                                                   int paymentOptionIndex,
 | 
			
		||||
                                                   QDateTime const &start) {
 | 
			
		||||
    int minPrice = -1;
 | 
			
		||||
 | 
			
		||||
    switch(permitType) {
 | 
			
		||||
@@ -76,6 +95,9 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
 | 
			
		||||
    } break;
 | 
			
		||||
    case PERMIT_TYPE::DAY_TICKET_CHILD: {
 | 
			
		||||
    } break;
 | 
			
		||||
    case PERMIT_TYPE::DAY_TICKET: {
 | 
			
		||||
        minPrice = compute_product_price(cfg, permitType, start);
 | 
			
		||||
    } break;
 | 
			
		||||
    default: ;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -144,6 +166,10 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
 | 
			
		||||
                QTime const &startTime = p.getTimeStart();
 | 
			
		||||
                QTime const &endTime = p.getTimeEnd();
 | 
			
		||||
 | 
			
		||||
                // qCritical() << __LINE__ << startTime.toString(Qt::ISODate);
 | 
			
		||||
                // qCritical() << __LINE__ << endTime.toString(Qt::ISODate);
 | 
			
		||||
                // qCritical() << __LINE__ << start.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
                if (start.time() >= startTime && start.time() < endTime) {
 | 
			
		||||
                    product_price = p.getProductPrice();
 | 
			
		||||
                    if (productStart && productEnd) {
 | 
			
		||||
@@ -154,8 +180,41 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return product_price;
 | 
			
		||||
        } else {
 | 
			
		||||
            // SZEGED
 | 
			
		||||
            int const pop_daily_card_price = cfg->getPaymentOptions().pop_daily_card_price;
 | 
			
		||||
 | 
			
		||||
            qDebug() << QString("(%1:%2) no products defined in tariff-file").arg(__func__).arg(__LINE__);
 | 
			
		||||
            qDebug() << QString("(%1:%2) pop_daily_card_price=%3").arg(__func__).arg(__LINE__).arg(pop_daily_card_price);
 | 
			
		||||
 | 
			
		||||
            // static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
			
		||||
            // return Utilities::getDailyTicketCardPrice(cfg, paymentMethodId);
 | 
			
		||||
 | 
			
		||||
            return pop_daily_card_price;
 | 
			
		||||
        }
 | 
			
		||||
    } break;
 | 
			
		||||
    case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
 | 
			
		||||
        std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
 | 
			
		||||
        if (products) {
 | 
			
		||||
            int product_price = 0;
 | 
			
		||||
            QVector<ATBTariffProduct> product = products.value();
 | 
			
		||||
 | 
			
		||||
            if (product.size() > 0) {
 | 
			
		||||
                if (productStart && productEnd) {
 | 
			
		||||
                    int pop_min_time = get_minimal_parkingtime(cfg); // in minutes
 | 
			
		||||
                    int pop_max_time = get_maximal_parkingtime(cfg); // in minutes
 | 
			
		||||
                    if (pop_max_time >= pop_min_time) {
 | 
			
		||||
                        *productStart = start;
 | 
			
		||||
                        *productEnd = start.addSecs(pop_max_time*60);
 | 
			
		||||
                        product_price = product[0].getProductPrice();
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return product_price;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    } break;
 | 
			
		||||
    default:
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
@@ -396,7 +455,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
			
		||||
    if (duration < 0) {
 | 
			
		||||
        calcState.setDesc(QString("end=%1, start=%2")
 | 
			
		||||
                          .arg(end_parking_time, start_parking_time));
 | 
			
		||||
        return calcState.set(CalcState::State::NEGATIVE_PARING_TIME);
 | 
			
		||||
        return calcState.set(CalcState::State::NEGATIVE_PARKING_TIME);
 | 
			
		||||
    }
 | 
			
		||||
    if (duration > maxMin) {
 | 
			
		||||
        calcState.setDesc(QString("duration=%1, maxMin=%2").arg(duration).arg(maxMin));
 | 
			
		||||
@@ -453,6 +512,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
			
		||||
 | 
			
		||||
    // DEBUG
 | 
			
		||||
    qCritical() << "compute_price_for_parking_ticket() " << endl
 | 
			
		||||
                << "          paymentOptionIndex: " << paymentOptionIndex << endl
 | 
			
		||||
                << "          start_parking_time: " << start_parking_time << endl
 | 
			
		||||
                << "          netto_parking_time: " << netto_parking_time << endl
 | 
			
		||||
                << "                      minMin: " << minMin << endl
 | 
			
		||||
@@ -463,7 +523,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
			
		||||
        calcState.setDesc(QString("end=%1, start=%2")
 | 
			
		||||
                          .arg(end_parking_time.toString(Qt::ISODate),
 | 
			
		||||
                               start_parking_time.toString(Qt::ISODate)));
 | 
			
		||||
        return calcState.set(CalcState::State::NEGATIVE_PARING_TIME);
 | 
			
		||||
        return calcState.set(CalcState::State::NEGATIVE_PARKING_TIME);
 | 
			
		||||
    }
 | 
			
		||||
    if (netto_parking_time > maxMin) {
 | 
			
		||||
        calcState.setDesc(QString("duration=%1, maxMin=%2").arg(netto_parking_time).arg(maxMin));
 | 
			
		||||
@@ -479,14 +539,21 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
			
		||||
 | 
			
		||||
    double cost = -1;
 | 
			
		||||
    if (start_parking_time.isValid()) {
 | 
			
		||||
        if (tariff->getPaymentOptions().pop_payment_method_id == PaymentMethod::Steps) {
 | 
			
		||||
        if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps) {
 | 
			
		||||
            // hier muesste man unterscheiden: uebertrag oder nicht?
 | 
			
		||||
            calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time,
 | 
			
		||||
                                                                   netto_parking_time, paymentOptionIndex);
 | 
			
		||||
            if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
 | 
			
		||||
                // qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
			
		||||
                //             << calcState.toString();
 | 
			
		||||
                return calcState;
 | 
			
		||||
            }
 | 
			
		||||
            cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex);
 | 
			
		||||
            end_parking_time = start_parking_time.addSecs(netto_parking_time*60);
 | 
			
		||||
 | 
			
		||||
            // qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
			
		||||
            //             << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
        } else {
 | 
			
		||||
            cost = Calculator::GetInstance().GetCostFromDuration(
 | 
			
		||||
                        tariff,
 | 
			
		||||
@@ -503,7 +570,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // DEBUG
 | 
			
		||||
        qCritical() << "               -> calculated cost (price->netto) =  " << cost;
 | 
			
		||||
        qCritical() << "            end_parking_time: " << end_parking_time;
 | 
			
		||||
        qCritical() << "  -> calculated cost (netto): " << cost;
 | 
			
		||||
 | 
			
		||||
        price->brutto = price->vat = price->vat_percentage = 0;
 | 
			
		||||
        price->units = cost;
 | 
			
		||||
@@ -564,17 +632,77 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
			
		||||
                    tariff->getPaymentOptions().pop_payment_method_id,
 | 
			
		||||
                    cs.toLocal8Bit().constData(),
 | 
			
		||||
                    price, false, true).c_str();
 | 
			
		||||
 | 
			
		||||
        if (endTime == CalcState::SUCCESS) {
 | 
			
		||||
            calcState.setDesc(QString("SUCCESS"));
 | 
			
		||||
            calcState.setStatus(endTime);
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::ERROR_PARSING_ZONE_NR) {
 | 
			
		||||
            calcState.setStatus(endTime);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::ERROR_LOADING_TARIFF) {
 | 
			
		||||
            calcState.setStatus(endTime);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::ERROR_PARSING_TARIFF) {
 | 
			
		||||
            calcState.setStatus(endTime);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::NEGATIVE_PARKING_TIME) {
 | 
			
		||||
            calcState.setStatus(endTime);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::INVALID_START_DATE) {
 | 
			
		||||
            calcState.setStatus(endTime);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::WRONG_PARAM_VALUES) {
 | 
			
		||||
            calcState.setStatus(endTime);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::WRONG_ISO_TIME_FORMAT) {
 | 
			
		||||
            calcState.setStatus(endTime);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::ABOVE_MAX_PARKING_TIME) {
 | 
			
		||||
            calcState.setStatus(endTime);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::BELOW_MIN_PARKING_TIME) {
 | 
			
		||||
            calcState.setStatus(endTime);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::BELOW_MIN_PARKING_PRICE) {
 | 
			
		||||
            calcState.setStatus(endTime);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::ABOVE_MAX_PARKING_PRICE) {
 | 
			
		||||
            calcState.setDesc(CalcState::ABOVE_MAX_PARKING_PRICE);
 | 
			
		||||
            calcState.setStatus(CalcState::ABOVE_MAX_PARKING_PRICE);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::OVERPAID) {
 | 
			
		||||
            calcState.setDesc(CalcState::OVERPAID);
 | 
			
		||||
            calcState.setStatus(CalcState::OVERPAID);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else
 | 
			
		||||
        if (endTime == CalcState::OUTSIDE_ALLOWED_PARKING_TIME) {
 | 
			
		||||
            calcState.setStatus(endTime);
 | 
			
		||||
            return calcState;
 | 
			
		||||
        } else {
 | 
			
		||||
            ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
            // DEBUG
 | 
			
		||||
        qCritical() << "compute_duration_for_parking_ticket(): ";
 | 
			
		||||
        qCritical() << "                 endTime: " << endTime;
 | 
			
		||||
        qCritical() << "           ticketEndTime: " << ticketEndTime;
 | 
			
		||||
            //qCritical() << "compute_duration_for_parking_ticket(): ";
 | 
			
		||||
            //qCritical() << "                 endTime: " << endTime;
 | 
			
		||||
            //qCritical() << "           ticketEndTime: " << ticketEndTime;
 | 
			
		||||
 | 
			
		||||
            if (!ticketEndTime.isValid()) {
 | 
			
		||||
                calcState.setDesc(QString("ticketEndTime=%1").arg(endTime));
 | 
			
		||||
                return calcState.set(CalcState::State::WRONG_ISO_TIME_FORMAT);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        return calcState.set(CalcState::State::INVALID_START_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -144,7 +144,228 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                qCritical() << __func__ << ":" << __LINE__ << "NOT YET IMPLEMENTED";
 | 
			
		||||
                // TODO: man braucht den richtigen Index
 | 
			
		||||
                int paymentOptionIndex = 0;
 | 
			
		||||
                int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
			
		||||
                int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
 | 
			
		||||
                int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
			
		||||
 | 
			
		||||
                if (cost > pop_max_price) {
 | 
			
		||||
                    qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
 | 
			
		||||
                    return CalcState::OVERPAID.toStdString();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (cost < pop_min_price) {
 | 
			
		||||
                    qCritical() << DBG_HEADER << "MIN-PARKING-PRICE" << pop_min_price << ", COST" << cost;
 | 
			
		||||
                    return CalcState::BELOW_MIN_PARKING_PRICE.toStdString();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                // int const pop_pre_paid = 1;
 | 
			
		||||
 | 
			
		||||
                if (prepaid) {
 | 
			
		||||
                    // no limits on pre-pay-option, i.e. pre-pay-ranges are exactly
 | 
			
		||||
                    // the complements of operational-ranges
 | 
			
		||||
 | 
			
		||||
                    // find out if we are in a pre-pay-range.
 | 
			
		||||
                    // in this case, adapt inputDate accordingly.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// #define DEBUG_GET_DURATION_FROM_COST 1
 | 
			
		||||
#if DEBUG_GET_DURATION_FROM_COST==1
 | 
			
		||||
                    qCritical() << DBG_HEADER << "PRE-PAID-OPTION: ADAPT-INPUT-DATE" << inputDate.toString(Qt::ISODate);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
                    QTime currentTime = inputDate.time();
 | 
			
		||||
                    int pwd_period_day_in_week_id = inputDate.date().dayOfWeek();
 | 
			
		||||
 | 
			
		||||
                    bool useWeekDaysWorkTimeOfOtherDay = true;
 | 
			
		||||
 | 
			
		||||
                    for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(pwd_period_day_in_week_id); iter != rEnd; ++iter) {
 | 
			
		||||
                        QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
 | 
			
		||||
                        QTime pwd_time_to = QTime::fromString(QString::fromStdString(iter->second.pwd_time_to), Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
                        if (inputDate.time() < pwd_time_from) {
 | 
			
		||||
                            inputDate.setTime(pwd_time_from);
 | 
			
		||||
                            useWeekDaysWorkTimeOfOtherDay = false;
 | 
			
		||||
                            break;
 | 
			
		||||
                        }
 | 
			
		||||
                        if (currentTime <= pwd_time_to) {
 | 
			
		||||
                            useWeekDaysWorkTimeOfOtherDay = false;
 | 
			
		||||
                            break;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    if (useWeekDaysWorkTimeOfOtherDay) {// for the current day, we are above
 | 
			
		||||
                                                        // the latest worktime-range -> find the next valid range
 | 
			
		||||
 | 
			
		||||
                        QTime pwd_time_from_next_valid_range(0, 0, 0);
 | 
			
		||||
                        int pwd_period_next_day_in_week_id = pwd_period_day_in_week_id;
 | 
			
		||||
                        for (int days = 1; days < 8; ++days) {
 | 
			
		||||
                            pwd_period_next_day_in_week_id += 1;
 | 
			
		||||
                            if (pwd_period_next_day_in_week_id > (int)Qt::Sunday) {
 | 
			
		||||
                                pwd_period_next_day_in_week_id = Qt::Monday;
 | 
			
		||||
                            }
 | 
			
		||||
 | 
			
		||||
                            if (cfg->WeekDaysWorktime.count(pwd_period_next_day_in_week_id) > 0) {
 | 
			
		||||
                                for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(pwd_period_next_day_in_week_id); iter != rEnd; ++iter) {
 | 
			
		||||
                                    QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
 | 
			
		||||
                                    if (pwd_time_from_next_valid_range < pwd_time_from) {
 | 
			
		||||
                                        pwd_time_from_next_valid_range = pwd_time_from;
 | 
			
		||||
                                        break;
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                                inputDate = inputDate.addDays(days);
 | 
			
		||||
                                inputDate.setTime(pwd_time_from_next_valid_range);
 | 
			
		||||
                                break;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
#if DEBUG_GET_DURATION_FROM_COST==1
 | 
			
		||||
                qCritical() << DBG_HEADER << "(ADAPTED) INPUT-DATE" << inputDate.toString(Qt::ISODate);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
                // inputDate is now located in a valid operational-working-range
 | 
			
		||||
                // find this working-time-range
 | 
			
		||||
                int pwd_period_day_in_week_id = inputDate.date().dayOfWeek();
 | 
			
		||||
                if (cfg->WeekDaysWorktime.count(pwd_period_day_in_week_id) == 0) {
 | 
			
		||||
                    qCritical() << DBG_HEADER
 | 
			
		||||
                                << "ERROR" << inputDate.toString(Qt::ISODate)
 | 
			
		||||
                                << "NOT IN VALID WORKING TIME-RANGE";
 | 
			
		||||
                    return "";
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                QTime current_working_time_from;
 | 
			
		||||
                QTime current_working_time_to;
 | 
			
		||||
 | 
			
		||||
                for (auto[iter, rEnd] = cfg->WeekDaysWorktime.equal_range(pwd_period_day_in_week_id); iter != rEnd; ++iter) {
 | 
			
		||||
                    QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
 | 
			
		||||
                    QTime pwd_time_to = QTime::fromString(QString::fromStdString(iter->second.pwd_time_to), Qt::ISODate);
 | 
			
		||||
                    if (pwd_time_from <= inputDate.time() && inputDate.time() <= pwd_time_to) {
 | 
			
		||||
                        current_working_time_from = pwd_time_from;
 | 
			
		||||
                        current_working_time_to = pwd_time_to;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (current_working_time_from.isNull() || current_working_time_to.isNull()) {
 | 
			
		||||
                    // can never happen
 | 
			
		||||
                    qCritical() << DBG_HEADER
 | 
			
		||||
                                << "ERROR" << inputDate.toString(Qt::ISODate)
 | 
			
		||||
                                << "NOT IN VALID WORKING TIME-RANGE";
 | 
			
		||||
                    return "";
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
#if DEBUG_GET_DURATION_FROM_COST==1
 | 
			
		||||
                qCritical() << DBG_HEADER << "CURRENT WORKING-TIME-FROM" << current_working_time_from.toString(Qt::ISODate);
 | 
			
		||||
                qCritical() << DBG_HEADER << "  CURRENT WORKING-TIME-TO" << current_working_time_to.toString(Qt::ISODate);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
                for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
 | 
			
		||||
                    int const pra_price = itr->second.pra_price;
 | 
			
		||||
                    if ((double)pra_price == cost) {
 | 
			
		||||
                        int const durationId = itr->second.pra_payment_unit_id;
 | 
			
		||||
                        auto search = cfg->Duration.find(durationId);
 | 
			
		||||
                        if (search != cfg->Duration.end()) {
 | 
			
		||||
                            // found now the duration in minutes
 | 
			
		||||
                            // check if we are still inside the working-time-range
 | 
			
		||||
                            ATBDuration duration = search->second;
 | 
			
		||||
 | 
			
		||||
                            int durationInSecs = duration.pun_duration * 60;
 | 
			
		||||
 | 
			
		||||
                            QDateTime current_working_date_time_to = inputDate;
 | 
			
		||||
                            current_working_date_time_to.setTime(current_working_time_to);
 | 
			
		||||
 | 
			
		||||
#if DEBUG_GET_DURATION_FROM_COST==1
 | 
			
		||||
                            qCritical() << DBG_HEADER << "DURATION IN MINUTES" << duration.pun_duration;
 | 
			
		||||
                            qCritical() << DBG_HEADER << "DURATION IN SECONDS" << duration.pun_duration * 60;
 | 
			
		||||
                            qCritical() << DBG_HEADER << "CURRENT-WORKING-DATE-TIME-TO"
 | 
			
		||||
                                                      << current_working_date_time_to.toString(Qt::ISODate);
 | 
			
		||||
                            qCritical() << DBG_HEADER << "NEW INPUT DATE" << inputDate.addSecs(durationInSecs).toString(Qt::ISODate);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
                            if (inputDate.addSecs(durationInSecs) > current_working_date_time_to) {
 | 
			
		||||
                                QTime next_working_time_from;
 | 
			
		||||
                                if (cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over != 0) {
 | 
			
		||||
#if DEBUG_GET_DURATION_FROM_COST==1
 | 
			
		||||
                                    qCritical() << DBG_HEADER << "CARRY-OVER SET";
 | 
			
		||||
#endif
 | 
			
		||||
                                    // check for next working-time-range on same day
 | 
			
		||||
                                    int day_in_week_id = inputDate.date().dayOfWeek();
 | 
			
		||||
                                    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);
 | 
			
		||||
                                        if (pwd_time_from > current_working_time_to) {
 | 
			
		||||
                                            next_working_time_from = pwd_time_from;
 | 
			
		||||
#if DEBUG_GET_DURATION_FROM_COST==1
 | 
			
		||||
                                            qCritical() << DBG_HEADER << "NEXT-WORKING-TIME-FROM"
 | 
			
		||||
                                                        << next_working_time_from.toString(Qt::ISODate);
 | 
			
		||||
#endif
 | 
			
		||||
                                            break;
 | 
			
		||||
                                        }
 | 
			
		||||
                                    }
 | 
			
		||||
                                    // check for next working-time-range on following day(s)
 | 
			
		||||
                                    if (next_working_time_from.isNull()) {
 | 
			
		||||
                                        next_working_time_from = QTime(0, 0, 0);
 | 
			
		||||
                                        for (int days = 1; days < 8; ++days) {
 | 
			
		||||
                                            day_in_week_id += 1;
 | 
			
		||||
                                            if (day_in_week_id > (int)Qt::Sunday) {
 | 
			
		||||
                                                day_in_week_id = Qt::Monday;
 | 
			
		||||
                                            }
 | 
			
		||||
                                            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);
 | 
			
		||||
                                                    if (next_working_time_from < pwd_time_from) {
 | 
			
		||||
                                                        next_working_time_from = pwd_time_from;
 | 
			
		||||
                                                        break;
 | 
			
		||||
                                                    }
 | 
			
		||||
                                                }
 | 
			
		||||
 | 
			
		||||
                                                QDateTime upper = inputDate.addDays(days);
 | 
			
		||||
                                                upper.setTime(next_working_time_from);
 | 
			
		||||
 | 
			
		||||
                                                QDateTime lower = inputDate;
 | 
			
		||||
                                                lower.setTime(current_working_time_to);
 | 
			
		||||
 | 
			
		||||
                                                inputDate = inputDate.addSecs(lower.secsTo(upper) + durationInSecs);
 | 
			
		||||
#if DEBUG_GET_DURATION_FROM_COST==1
 | 
			
		||||
                                                qCritical() << DBG_HEADER << "TICKET-END" << inputDate.toString(Qt::ISODate);
 | 
			
		||||
#endif
 | 
			
		||||
                                                break;
 | 
			
		||||
                                            }
 | 
			
		||||
                                        } // for (int days = 1; days < 8; ++days) {
 | 
			
		||||
                                    } else { // next working-time is on same day
 | 
			
		||||
                                        QDateTime upper = inputDate;
 | 
			
		||||
                                        upper.setTime(next_working_time_from);
 | 
			
		||||
 | 
			
		||||
                                        QDateTime lower = inputDate;
 | 
			
		||||
                                        lower.setTime(current_working_time_to);
 | 
			
		||||
 | 
			
		||||
                                        inputDate = inputDate.addSecs(lower.secsTo(upper) + durationInSecs);
 | 
			
		||||
#if DEBUG_GET_DURATION_FROM_COST==1
 | 
			
		||||
                                        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
 | 
			
		||||
 | 
			
		||||
                            }
 | 
			
		||||
 | 
			
		||||
                            QString const &s = inputDate.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
#if DEBUG_GET_DURATION_FROM_COST==1
 | 
			
		||||
                            qCritical() << DBG_HEADER << "TICKET-END" << s;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
                            return s.toStdString();
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return "";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -628,12 +849,19 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
 | 
			
		||||
    PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
			
		||||
    if (paymentMethodId == PaymentMethod::Steps) {
 | 
			
		||||
        uint64_t const businessHours = cfg->getPaymentOptions(paymentOptionIndex).pop_business_hours;
 | 
			
		||||
 | 
			
		||||
        if (cfg->isDayIncluded(businessHours, start)) {
 | 
			
		||||
            if (businessHours == BusinessHours::NO_RESTRICTION_24_7) {
 | 
			
		||||
                return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED",
 | 
			
		||||
                         QTime(0, 0, 0), QTime(23, 59, 59));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            int const weekdayId = start.date().dayOfWeek();
 | 
			
		||||
 | 
			
		||||
            // qCritical() << DBG_HEADER
 | 
			
		||||
            //             << "weekdayId" << weekdayId
 | 
			
		||||
            //             << "count" << cfg->WeekDaysWorktime.count(weekdayId);
 | 
			
		||||
 | 
			
		||||
            if (cfg->WeekDaysWorktime.count(weekdayId) > 0) {
 | 
			
		||||
                using WTIterator = std::multimap<int, ATBWeekDaysWorktime>::const_iterator;
 | 
			
		||||
                std::pair<WTIterator, WTIterator> p = cfg->WeekDaysWorktime.equal_range(weekdayId);
 | 
			
		||||
@@ -649,8 +877,10 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
 | 
			
		||||
                    QTime const &startTime = start.time();
 | 
			
		||||
 | 
			
		||||
                    if (startTime >= from && startTime <= until) {
 | 
			
		||||
                        QTime const endTime = start.addSecs(netto_parking_time*60).time();
 | 
			
		||||
                        if (endTime <= until) {
 | 
			
		||||
                        QDateTime const end = start.addSecs(netto_parking_time*60);
 | 
			
		||||
                        QTime const endTime = end.time();
 | 
			
		||||
                        if (endTime <= until && start.date().dayOfWeek() == end.date().dayOfWeek()) {
 | 
			
		||||
                            qCritical() << DBG_HEADER;
 | 
			
		||||
                            return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED", from, until);
 | 
			
		||||
                        } else {
 | 
			
		||||
                            errorStr = QString("%1 startTime not in range (%2 not in [%3, %4))")
 | 
			
		||||
@@ -668,28 +898,59 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
 | 
			
		||||
 | 
			
		||||
                    // qCritical() << DBG_HEADER
 | 
			
		||||
                    //             << "paymentOptionIndex" << paymentOptionIndex
 | 
			
		||||
                    //             << "pop_carry_over" << pop_carry_over;
 | 
			
		||||
 | 
			
		||||
                    if (pop_carry_over == 1) {
 | 
			
		||||
                        qCritical() << DBG_HEADER
 | 
			
		||||
                                    << "NO. CHECK IF PARKING IS ALLOWED WITH CARRY-OVER ...";
 | 
			
		||||
                        // qCritical() << DBG_HEADER
 | 
			
		||||
                        //             << "NO. CHECK IF PARKING IS ALLOWED WITH CARRY-OVER ...";
 | 
			
		||||
 | 
			
		||||
                        int const pop_carry_over_start_time_range = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_start_time_range;
 | 
			
		||||
                        int const pop_carry_over_end_time_range = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_end_time_range;
 | 
			
		||||
 | 
			
		||||
                        // qCritical() << DBG_HEADER
 | 
			
		||||
                        //             << "pop_carry_over_start_time_range" << pop_carry_over_start_time_range
 | 
			
		||||
                        //             << "pop_carry_over_end_time_range" << pop_carry_over_end_time_range;
 | 
			
		||||
 | 
			
		||||
                        if ((int)cfg->TimeRange.count(pop_carry_over_start_time_range) <= 0 &&
 | 
			
		||||
                            (int)cfg->TimeRange.count(pop_carry_over_end_time_range) <= 0) {
 | 
			
		||||
 | 
			
		||||
                            qCritical() << DBG_HEADER << "PARKING_ALLOWED. startTime" << startTime.toString(Qt::ISODate);
 | 
			
		||||
                            return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED", startTime);
 | 
			
		||||
 | 
			
		||||
                        } else
 | 
			
		||||
                        // search entry in time-range-field of tariff-file
 | 
			
		||||
                        if (cfg->TimeRange.count(pop_carry_over_start_time_range) == 1 &&
 | 
			
		||||
                            cfg->TimeRange.count(pop_carry_over_end_time_range) == 1) {
 | 
			
		||||
 | 
			
		||||
                            ATBTimeRange s = cfg->TimeRange.find(pop_carry_over_start_time_range)->second;
 | 
			
		||||
                            ATBTimeRange e = cfg->TimeRange.find(pop_carry_over_end_time_range)->second;
 | 
			
		||||
 | 
			
		||||
                            // qCritical() << DBG_HEADER
 | 
			
		||||
                            //             << "startTime" << startTime.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
                            if (startTime >= s.getTimeFrom() && startTime <= s.getTimeUntil()) {
 | 
			
		||||
 | 
			
		||||
                                QDateTime sd = start;
 | 
			
		||||
                                sd.setTime(s.getTimeUntil());
 | 
			
		||||
 | 
			
		||||
                                // qCritical() << DBG_HEADER << "jumpFrom" << sd.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
                                QDateTime ed = start.addDays(1);
 | 
			
		||||
                                ed.setTime(e.getTimeFrom());
 | 
			
		||||
 | 
			
		||||
                                // qCritical() << DBG_HEADER << "to" << ed.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
                                int const jumpSecs = sd.secsTo(ed);
 | 
			
		||||
 | 
			
		||||
                                // qCritical() << DBG_HEADER << "jumpSecs" << jumpSecs;
 | 
			
		||||
 | 
			
		||||
                                QDateTime const end = start.addSecs(netto_parking_time*60 + jumpSecs);
 | 
			
		||||
 | 
			
		||||
                                // qCritical() << DBG_HEADER << "new end" << end.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
                                if (end.time() <= e.getTimeUntil()) {
 | 
			
		||||
 | 
			
		||||
                                    qCritical() << DBG_HEADER
 | 
			
		||||
@@ -699,13 +960,13 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
 | 
			
		||||
                                    return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED",
 | 
			
		||||
                                                     startTime, end.time());
 | 
			
		||||
                                } else {
 | 
			
		||||
                                    errorStr = QString("endTime %1 exceeds [%2, %3))")
 | 
			
		||||
                                    errorStr = QString("endTime %1 outside [%2, %3))")
 | 
			
		||||
                                                  .arg(end.toString(Qt::ISODate))
 | 
			
		||||
                                                  .arg(sd.toString(Qt::ISODate))
 | 
			
		||||
                                                  .arg(ed.toString(Qt::ISODate));
 | 
			
		||||
                                }
 | 
			
		||||
                            } else {
 | 
			
		||||
                                errorStr = QString("startTime %1 exceeds [%2, %3))")
 | 
			
		||||
                                errorStr = QString("startTime %1 outside [%2, %3))")
 | 
			
		||||
                                              .arg(startTime.toString(Qt::ISODate))
 | 
			
		||||
                                              .arg(s.getTimeFrom().toString(Qt::ISODate))
 | 
			
		||||
                                              .arg(s.getTimeUntil().toString(Qt::ISODate));
 | 
			
		||||
@@ -728,6 +989,8 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    qCritical() << DBG_HEADER << "errorStr" << errorStr;
 | 
			
		||||
 | 
			
		||||
    return CalcState(CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME, errorStr,
 | 
			
		||||
                     QTime(), QTime());
 | 
			
		||||
}
 | 
			
		||||
@@ -1833,6 +2096,8 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
 | 
			
		||||
    if (m_timeSteps.size() > paymentOptionIndex) {
 | 
			
		||||
        //qCritical() << __PRETTY_FUNCTION__ << "timeSteps:" << m_timeSteps;
 | 
			
		||||
        return m_timeSteps[paymentOptionIndex];
 | 
			
		||||
    } else {
 | 
			
		||||
        m_timeSteps.push_back(QList<int>());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QDateTime start = QDateTime::currentDateTime();
 | 
			
		||||
@@ -1888,7 +2153,7 @@ QList<int> Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex)
 | 
			
		||||
                                    qCritical() << "(" << __func__ << ":" << __LINE__ << ") configured minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
			
		||||
 | 
			
		||||
                                    // set dynamic minimal parking time
 | 
			
		||||
                                    cfg->getPaymentOptions().pop_min_time = timeStep;
 | 
			
		||||
                                    cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = timeStep;
 | 
			
		||||
 | 
			
		||||
                                    qCritical() << "(" << __func__ << ":" << __LINE__ << ") computed minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
			
		||||
 | 
			
		||||
@@ -2003,6 +2268,9 @@ Calculator::GetDailyTicketPrice(Configuration* cfg,
 | 
			
		||||
        if (dailyTickets) {
 | 
			
		||||
            QVector<ATBDailyTicket> const tickets = dailyTickets.value();
 | 
			
		||||
            switch (permitType) {
 | 
			
		||||
                case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
 | 
			
		||||
                    // TODO
 | 
			
		||||
                } break;
 | 
			
		||||
                case PERMIT_TYPE::FOOD_STAMP: {
 | 
			
		||||
                    // TODO
 | 
			
		||||
                } break;
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@
 | 
			
		||||
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QRegularExpression>
 | 
			
		||||
 | 
			
		||||
/// <inheritdoc/>
 | 
			
		||||
MemberType Configuration::IdentifyJsonMember(const char* member_name)
 | 
			
		||||
@@ -436,6 +437,60 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
			
		||||
                            }
 | 
			
		||||
                        } else if (strcmp(inner_obj_name, "pop_time_step_config") == 0) {
 | 
			
		||||
                            this->currentPaymentOptions.last().pop_time_step_config = k->value.GetInt();
 | 
			
		||||
                        } else if ((strcmp(inner_obj_name, "pop_min_date_time") == 0)
 | 
			
		||||
                                || (strcmp(inner_obj_name, "pop_max_date_time") == 0)) {
 | 
			
		||||
                            if (k->value.IsString()) { // -w0dFriT16:20:00 or +w0dMonT00:00:00
 | 
			
		||||
                                static const QRegularExpression re(R"(([+-])w([0-9]+)d([A-Za-z]{3})T([0-9]{2}:[0-9]{2}:[0-9]{2}))");
 | 
			
		||||
                                QString const &s = QString::fromStdString(k->value.GetString());
 | 
			
		||||
                                QRegularExpressionMatch match = re.match(s);
 | 
			
		||||
                                if (match.hasMatch()) {
 | 
			
		||||
                                    ATBPaymentOption::ATBMaxDateTime dt;
 | 
			
		||||
                                    int lastCaptured = match.lastCapturedIndex();
 | 
			
		||||
                                    if (lastCaptured == 4) {
 | 
			
		||||
                                        dt.direction = (match.captured(1) == "-") ? -1 : +1;
 | 
			
		||||
 | 
			
		||||
                                        bool ok;
 | 
			
		||||
                                        uint8_t week = match.captured(2).toUInt(&ok);
 | 
			
		||||
                                        if (ok) {
 | 
			
		||||
                                            dt.week = week;
 | 
			
		||||
                                        }
 | 
			
		||||
 | 
			
		||||
                                        QString const &day = match.captured(3);
 | 
			
		||||
                                        if (day.compare("Mon", Qt::CaseInsensitive) == 0) {
 | 
			
		||||
                                            dt.day = (int)Qt::Monday;
 | 
			
		||||
                                        } else if (day.compare("Tue", Qt::CaseInsensitive) == 0) {
 | 
			
		||||
                                            dt.day = (int)Qt::Tuesday;
 | 
			
		||||
                                        } else if (day.compare("Wed", Qt::CaseInsensitive) == 0) {
 | 
			
		||||
                                            dt.day = (int)Qt::Wednesday;
 | 
			
		||||
                                        } else if (day.compare("Thu", Qt::CaseInsensitive) == 0) {
 | 
			
		||||
                                            dt.day = (int)Qt::Thursday;
 | 
			
		||||
                                        } else if (day.compare("Fri", Qt::CaseInsensitive) == 0) {
 | 
			
		||||
                                            dt.day = (int)Qt::Friday;
 | 
			
		||||
                                        } else if (day.compare("Sat", Qt::CaseInsensitive) == 0) {
 | 
			
		||||
                                            dt.day = (int)Qt::Saturday;
 | 
			
		||||
                                        } else if (day.compare("Sun", Qt::CaseInsensitive) == 0) {
 | 
			
		||||
                                            dt.day = (int)Qt::Sunday;
 | 
			
		||||
                                        }
 | 
			
		||||
 | 
			
		||||
                                        QTime t = QTime::fromString(match.captured(4), Qt::ISODate);
 | 
			
		||||
                                        if (t.isValid()) {
 | 
			
		||||
                                            dt.time = t;
 | 
			
		||||
                                        }
 | 
			
		||||
                                    }
 | 
			
		||||
 | 
			
		||||
                                    if (strcmp(inner_obj_name, "pop_min_date_time") == 0) {
 | 
			
		||||
                                        this->currentPaymentOptions.last().pop_min_date_time = dt;
 | 
			
		||||
                                    } else
 | 
			
		||||
                                    if (strcmp(inner_obj_name, "pop_max_date_time") == 0) {
 | 
			
		||||
                                        this->currentPaymentOptions.last().pop_max_date_time = dt;
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        } else if (strcmp(inner_obj_name, "pop_carry_over_target") == 0) {
 | 
			
		||||
                            if (k->value.IsBool()) {
 | 
			
		||||
                                bool const v = k->value.GetBool();
 | 
			
		||||
                                this->currentPaymentOptions.last().pop_carry_over_target = v;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
					case MemberType::DurationType:
 | 
			
		||||
@@ -583,7 +638,7 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
 | 
			
		||||
        if (sd.ped_id != 0) {
 | 
			
		||||
            for (int opt=0; opt < numOptions; ++opt) {
 | 
			
		||||
                uint64_t const pop_id = getPaymentOptions(opt).pop_id;
 | 
			
		||||
                if (pop_id == sd.ped_payment_option_id) {
 | 
			
		||||
                if (pop_id == (uint64_t)sd.ped_payment_option_id) {
 | 
			
		||||
                    return opt;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@@ -627,7 +682,8 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return -1;
 | 
			
		||||
    qCritical() << DBG_HEADER << "ERROR: DEFAULT VALUE OF '0' RETURNED AS STATIC VALUE";
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ATBSpecialDays Configuration::specialDay(QDateTime const &dt) const {
 | 
			
		||||
@@ -718,12 +774,38 @@ Configuration::getTariffProductForAllKeys() const {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::optional<QVector<ATBTariffProduct>>
 | 
			
		||||
Configuration::getTariffProductForProductId(PermitType permitType) const {
 | 
			
		||||
Configuration::getTariffProductForProductTypeName(QString const &permitTypeName) const {
 | 
			
		||||
    QVector<ATBTariffProduct> products;
 | 
			
		||||
    std::optional<QVector<ATBTariffProduct>> value;
 | 
			
		||||
 | 
			
		||||
    products.clear();
 | 
			
		||||
 | 
			
		||||
    for(const auto &product: this->TariffProduct) {
 | 
			
		||||
        ATBTariffProduct const &v = product.second;
 | 
			
		||||
        if (v.m_tariff_product_name == permitTypeName) {
 | 
			
		||||
            products.append(v);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (products.size() > 0) {
 | 
			
		||||
        value = value.value_or(products);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::optional<QVector<ATBTariffProduct>>
 | 
			
		||||
Configuration::getTariffProductForProductId(PermitType permitType) const {
 | 
			
		||||
    QString permitTypeName(permitType);
 | 
			
		||||
    return getTariffProductForProductTypeName(permitTypeName);
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
    QVector<ATBTariffProduct> products;
 | 
			
		||||
    std::optional<QVector<ATBTariffProduct>> value;
 | 
			
		||||
 | 
			
		||||
    products.clear();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    for (auto[it, rangeEnd] = this->TariffProduct.equal_range(permitType); it != rangeEnd; ++it) {
 | 
			
		||||
        products.append(it->second);
 | 
			
		||||
    }
 | 
			
		||||
@@ -733,6 +815,7 @@ Configuration::getTariffProductForProductId(PermitType permitType) const {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return value;
 | 
			
		||||
    */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::optional<QVector<ATBTariffProduct>>
 | 
			
		||||
 
 | 
			
		||||
@@ -334,11 +334,11 @@ QTime Utilities::SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDa
 | 
			
		||||
    return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_from.c_str(), Qt::ISODate);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QTime Utilities::SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator it) {
 | 
			
		||||
QTime Utilities::SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator const &it) {
 | 
			
		||||
    return QTime::fromString(it->second.pedwt_time_from.c_str(), Qt::ISODate);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QTime Utilities::SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator it) {
 | 
			
		||||
QTime Utilities::SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator const &it) {
 | 
			
		||||
    return QTime::fromString(it->second.pedwt_time_to.c_str(), Qt::ISODate);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -346,15 +346,15 @@ QTime Utilities::SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialD
 | 
			
		||||
    return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_to.c_str(), Qt::ISODate);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QTime Utilities::WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr) {
 | 
			
		||||
QTime Utilities::WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr) {
 | 
			
		||||
    return QTime::fromString(itr->second.pwd_time_from.c_str(), Qt::ISODate);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QTime Utilities::WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr) {
 | 
			
		||||
QTime Utilities::WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr) {
 | 
			
		||||
    return QTime::fromString(itr->second.pwd_time_to.c_str(), Qt::ISODate);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int Utilities::WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr) {
 | 
			
		||||
int Utilities::WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr) {
 | 
			
		||||
    return itr->second.pwd_period_day_in_week_id;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -406,9 +406,16 @@ uint32_t Utilities::getMaximalParkingPrice(Configuration const *cfg, PaymentMeth
 | 
			
		||||
    return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_max_price, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint32_t Utilities::getDailyTicketCardPrice(Configuration const *cfg, PaymentMethod methodId) {
 | 
			
		||||
    return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_daily_card_price, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint32_t Utilities::getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId) {
 | 
			
		||||
    if (methodId == PaymentMethod::Progressive) {
 | 
			
		||||
        return std::max((int)cfg->TimeRange.find(step)->second.time_range_to_in_minutes_from_start, 0);
 | 
			
		||||
        Configuration::TimeRangeType::const_iterator it = cfg->TimeRange.find(step);
 | 
			
		||||
        if (it != cfg->TimeRange.cend()) {
 | 
			
		||||
            return std::max((int)(it->second.time_range_to_in_minutes_from_start), 0);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1189
									
								
								main/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										1189
									
								
								main/main.cpp
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user