Compare commits
	
		
			30 Commits
		
	
	
		
			remotes/or
			...
			praesentat
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| ed6d355517 | |||
| f1f033d1cd | |||
| f547f563bf | |||
| 141d3281b7 | |||
| 
						
						
							
						
						f2156e4650
	
				 | 
					
					
						|||
| 
						
						
							
						
						338a1a4ebc
	
				 | 
					
					
						|||
| b4818a3918 | |||
| 35294e99f0 | |||
| edfa5dc1b1 | |||
| d95741baae | |||
| e172e814e7 | |||
| 37aa10fc85 | |||
| 4b9edb0f47 | |||
| e70e9a8586 | |||
| aec290fe26 | |||
| 78cae24389 | |||
| de0be1d19b | |||
| 54921f0e85 | |||
| 077c2334ca | |||
| d605af5c5a | |||
| c5900f9f2b | |||
| 9b137c2873 | |||
| dd249a87d5 | |||
| 575885c19e | |||
| d82a732a8d | |||
| 99dbd7c194 | |||
| 
						
						
							
						
						ae985d25ce
	
				 | 
					
					
						|||
| 
						
						
							
						
						6a215d4cf9
	
				 | 
					
					
						|||
| 
						
						
							
						
						a3f4a742ce
	
				 | 
					
					
						|||
| e6d8c04076 | 
@@ -277,6 +277,12 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff,
 | 
				
			|||||||
void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff);
 | 
					void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff);
 | 
				
			||||||
int CALCULATE_LIBRARY_API get_zone_nr(int zone = -1);
 | 
					int CALCULATE_LIBRARY_API get_zone_nr(int zone = -1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int CALCULATE_LIBRARY_API isOutOfService(Configuration const *cfg,
 | 
				
			||||||
 | 
					                                         QDateTime const &dt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int CALCULATE_LIBRARY_API isOutOfService(QDateTime const &dt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes,
 | 
					int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes,
 | 
				
			||||||
                                                int UpDown, PermitType const &permitType);
 | 
					                                                int UpDown, PermitType const &permitType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,6 +34,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <QVector>
 | 
					#include <QVector>
 | 
				
			||||||
#include <optional>
 | 
					#include <optional>
 | 
				
			||||||
 | 
					#include <QList>
 | 
				
			||||||
 | 
					#include <QPair>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace std;
 | 
					using namespace std;
 | 
				
			||||||
using namespace rapidjson;
 | 
					using namespace rapidjson;
 | 
				
			||||||
@@ -83,6 +85,11 @@ public:
 | 
				
			|||||||
    TariffOutOfServiceType TariffOutOfServices;
 | 
					    TariffOutOfServiceType TariffOutOfServices;
 | 
				
			||||||
    ATBTariffPrepaidType TariffPrepaids;
 | 
					    ATBTariffPrepaidType TariffPrepaids;
 | 
				
			||||||
    ATBTariffCarryOverType TariffCarryOvers;
 | 
					    ATBTariffCarryOverType TariffCarryOvers;
 | 
				
			||||||
 | 
					    QList<QPair<QString, QString>> TariffIncludes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QTime ValidFrom;
 | 
				
			||||||
 | 
					    int ValidForWeekDay{};
 | 
				
			||||||
 | 
					    QStringList tariffFileName{};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/// <summary>
 | 
						/// <summary>
 | 
				
			||||||
	/// Parse JSON string
 | 
						/// Parse JSON string
 | 
				
			||||||
@@ -123,6 +130,9 @@ public:
 | 
				
			|||||||
    std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek);
 | 
					    std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek);
 | 
				
			||||||
    std::optional<QVector<ATBWeekDaysWorktime>> getAllWeekDayWorkTimes();
 | 
					    std::optional<QVector<ATBWeekDaysWorktime>> getAllWeekDayWorkTimes();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QList<QPair<QString, QString>> const &getTariffIncludes() const { return TariffIncludes; }
 | 
				
			||||||
 | 
					    QList<QPair<QString, QString>> &getTariffIncludes() { return TariffIncludes; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::optional<QDateTime> prepaidStart(QDateTime const &start, int prepaid_option_id);
 | 
					    std::optional<QDateTime> prepaidStart(QDateTime const &start, int prepaid_option_id);
 | 
				
			||||||
    int getPaymentOptionIndex(PERMIT_TYPE permitType);
 | 
					    int getPaymentOptionIndex(PERMIT_TYPE permitType);
 | 
				
			||||||
    int getPaymentOptionIndex(PERMIT_TYPE permitType) const;
 | 
					    int getPaymentOptionIndex(PERMIT_TYPE permitType) const;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,7 +22,8 @@ enum MemberType
 | 
				
			|||||||
    ProductType = 0x0F,
 | 
					    ProductType = 0x0F,
 | 
				
			||||||
    InterpolationType = 0x10,
 | 
					    InterpolationType = 0x10,
 | 
				
			||||||
    PrepaidType = 0x11,
 | 
					    PrepaidType = 0x11,
 | 
				
			||||||
    CarryOverType = 0x12
 | 
					    CarryOverType = 0x12,
 | 
				
			||||||
 | 
					    IncludesType = 0x13
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // MEMBER_TYPE_H_INCLUDED
 | 
					#endif // MEMBER_TYPE_H_INCLUDED
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,7 +37,7 @@ struct ATBTariffCarryOver {
 | 
				
			|||||||
        if (coif == "always") {
 | 
					        if (coif == "always") {
 | 
				
			||||||
            m_carryOverIf = ApplyCarryOver::ALWAYS;
 | 
					            m_carryOverIf = ApplyCarryOver::ALWAYS;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
           qCritical() << "ERROR unknown carry over application" << coif;
 | 
					           qCritical() << __func__ << ":" << __LINE__ << "ERROR unknown carry over application" << coif;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -65,13 +65,22 @@ struct ATBTariffCarryOver {
 | 
				
			|||||||
        int minutes = 0;
 | 
					        int minutes = 0;
 | 
				
			||||||
        QString end = m_range.m_end.toString(Qt::ISODate);
 | 
					        QString end = m_range.m_end.toString(Qt::ISODate);
 | 
				
			||||||
        if (end == "24:00:00") {
 | 
					        if (end == "24:00:00") {
 | 
				
			||||||
            QDateTime t = dt.addDays(1);
 | 
					            // note: this did not work
 | 
				
			||||||
            t.setTime(QTime(0,0,0));
 | 
					            // QDateTime t(dt.addDays(1));
 | 
				
			||||||
            minutes = dt.secsTo(t) / 60;
 | 
					            // t.setTime(QTime(0,0,0));
 | 
				
			||||||
 | 
					            // dt: 2024-10-27T00:00:00 EEST, but t: 2024-10-28T00:00:00 EET (!)
 | 
				
			||||||
 | 
					            // so the difference is 1500 instead of 1440
 | 
				
			||||||
 | 
					            // reason: change from summer to winter time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // compute minutes directly
 | 
				
			||||||
 | 
					            if (dt.time().isValid()) {
 | 
				
			||||||
 | 
					                minutes = 1440 - (dt.time().hour() * 60 + dt.time().minute());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            QDateTime t(dt);
 | 
					            QTime t(QTime::fromString(end, Qt::ISODate));
 | 
				
			||||||
            t.setTime(QTime::fromString(end, Qt::ISODate));
 | 
					            if (t.isValid() && dt.time().isValid()) {
 | 
				
			||||||
            minutes = dt.secsTo(t) / 60;
 | 
					                minutes = (t.hour() * 60 + t.minute()) - (dt.time().hour() * 60 + dt.time().minute());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (minutes < 0 || minutes > m_range.m_duration) {
 | 
					        if (minutes < 0 || minutes > m_range.m_duration) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,7 +19,12 @@ enum class PERMIT_TYPE : quint8 {
 | 
				
			|||||||
    SHORT_TERM_PARKING_CAMPER=12,
 | 
					    SHORT_TERM_PARKING_CAMPER=12,
 | 
				
			||||||
    DAY_TICKET_PKW=13,
 | 
					    DAY_TICKET_PKW=13,
 | 
				
			||||||
    DAY_TICKET_BUS=14,
 | 
					    DAY_TICKET_BUS=14,
 | 
				
			||||||
    DAY_TICKET_CAMPER=15
 | 
					    DAY_TICKET_CAMPER=15,
 | 
				
			||||||
 | 
					    FREE_TICKET=16,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    TEST_PRODUCT_1=17,
 | 
				
			||||||
 | 
					    TEST_PRODUCT_2=18,
 | 
				
			||||||
 | 
					    PRODUCT_MAX
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct PermitType {
 | 
					struct PermitType {
 | 
				
			||||||
@@ -73,6 +78,15 @@ struct PermitType {
 | 
				
			|||||||
        case 15:
 | 
					        case 15:
 | 
				
			||||||
            m_permitType = PERMIT_TYPE::DAY_TICKET_CAMPER;
 | 
					            m_permitType = PERMIT_TYPE::DAY_TICKET_CAMPER;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					        case 16:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::FREE_TICKET;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 17:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::TEST_PRODUCT_1;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 18:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::TEST_PRODUCT_2;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            m_permitType = PERMIT_TYPE::INVALID;
 | 
					            m_permitType = PERMIT_TYPE::INVALID;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -116,6 +130,12 @@ struct PermitType {
 | 
				
			|||||||
            return 14;
 | 
					            return 14;
 | 
				
			||||||
        case PERMIT_TYPE::DAY_TICKET_CAMPER:
 | 
					        case PERMIT_TYPE::DAY_TICKET_CAMPER:
 | 
				
			||||||
            return 15;
 | 
					            return 15;
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::FREE_TICKET:
 | 
				
			||||||
 | 
					            return 16;
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::TEST_PRODUCT_1:
 | 
				
			||||||
 | 
					            return 17;
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::TEST_PRODUCT_2:
 | 
				
			||||||
 | 
					            return 18;
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -132,9 +152,6 @@ struct PermitType {
 | 
				
			|||||||
        if (permitTypeStr == "DAY_TICKET_CHILD") {
 | 
					        if (permitTypeStr == "DAY_TICKET_CHILD") {
 | 
				
			||||||
            return PERMIT_TYPE::DAY_TICKET_CHILD;
 | 
					            return PERMIT_TYPE::DAY_TICKET_CHILD;
 | 
				
			||||||
        } else
 | 
					        } else
 | 
				
			||||||
        if (permitTypeStr == "DAY_TICKET_ADULT") {
 | 
					 | 
				
			||||||
            return PERMIT_TYPE::DAY_TICKET_ADULT;
 | 
					 | 
				
			||||||
        } else
 | 
					 | 
				
			||||||
        if (permitTypeStr == "DAY_TICKET_TEEN") {
 | 
					        if (permitTypeStr == "DAY_TICKET_TEEN") {
 | 
				
			||||||
            return PERMIT_TYPE::DAY_TICKET_TEEN;
 | 
					            return PERMIT_TYPE::DAY_TICKET_TEEN;
 | 
				
			||||||
        } else
 | 
					        } else
 | 
				
			||||||
@@ -170,6 +187,15 @@ struct PermitType {
 | 
				
			|||||||
        } else
 | 
					        } else
 | 
				
			||||||
        if (permitTypeStr == "DAY_TICKET_CAMPER") {
 | 
					        if (permitTypeStr == "DAY_TICKET_CAMPER") {
 | 
				
			||||||
            return PERMIT_TYPE::DAY_TICKET_CAMPER;
 | 
					            return PERMIT_TYPE::DAY_TICKET_CAMPER;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (permitTypeStr == "FREE_TICKET") {
 | 
				
			||||||
 | 
					            return PERMIT_TYPE::FREE_TICKET;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (permitTypeStr == "TEST_PRODUCT_1") {
 | 
				
			||||||
 | 
					            return PERMIT_TYPE::TEST_PRODUCT_1;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (permitTypeStr == "TEST_PRODUCT_2") {
 | 
				
			||||||
 | 
					            return PERMIT_TYPE::TEST_PRODUCT_2;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return PERMIT_TYPE::INVALID;
 | 
					        return PERMIT_TYPE::INVALID;
 | 
				
			||||||
@@ -207,6 +233,12 @@ struct PermitType {
 | 
				
			|||||||
            return QString("DAY_TICKET_BUS");
 | 
					            return QString("DAY_TICKET_BUS");
 | 
				
			||||||
        case PERMIT_TYPE::DAY_TICKET_CAMPER:
 | 
					        case PERMIT_TYPE::DAY_TICKET_CAMPER:
 | 
				
			||||||
            return QString("DAY_TICKET_CAMPER");
 | 
					            return QString("DAY_TICKET_CAMPER");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::FREE_TICKET:
 | 
				
			||||||
 | 
					            return QString("FREE_TICKET");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::TEST_PRODUCT_1:
 | 
				
			||||||
 | 
					            return QString("TEST_PRODUCT_1");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::TEST_PRODUCT_2:
 | 
				
			||||||
 | 
					            return QString("TEST_PRODUCT_2");
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -245,6 +277,12 @@ struct PermitType {
 | 
				
			|||||||
            return QString("DAY_TICKET_BUS");
 | 
					            return QString("DAY_TICKET_BUS");
 | 
				
			||||||
        case PERMIT_TYPE::DAY_TICKET_CAMPER:
 | 
					        case PERMIT_TYPE::DAY_TICKET_CAMPER:
 | 
				
			||||||
            return QString("DAY_TICKET_CAMPER");
 | 
					            return QString("DAY_TICKET_CAMPER");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::FREE_TICKET:
 | 
				
			||||||
 | 
					            return QString("FREE_TICKET");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::TEST_PRODUCT_1:
 | 
				
			||||||
 | 
					            return QString("TEST_PRODUCT_1");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::TEST_PRODUCT_2:
 | 
				
			||||||
 | 
					            return QString("TEST_PRODUCT_2");
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,7 +38,7 @@ struct ATBTariffPrepaid {
 | 
				
			|||||||
        if (ppif == "always") {
 | 
					        if (ppif == "always") {
 | 
				
			||||||
            m_prepaidIf = ApplyPrepaid::ALWAYS;
 | 
					            m_prepaidIf = ApplyPrepaid::ALWAYS;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
           qCritical() << "ERROR unknown carry over application" << ppif;
 | 
					           qCritical() << __func__ << ":" << __LINE__ << "ERROR unknown carry over application" << ppif;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,12 +5,15 @@
 | 
				
			|||||||
#include "utilities.h"
 | 
					#include "utilities.h"
 | 
				
			||||||
#include "tariff_global_defines.h"
 | 
					#include "tariff_global_defines.h"
 | 
				
			||||||
#include "period_year.h"
 | 
					#include "period_year.h"
 | 
				
			||||||
 | 
					#include "tariff_permit_type.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QFile>
 | 
					#include <QFile>
 | 
				
			||||||
#include <QFileInfo>
 | 
					#include <QFileInfo>
 | 
				
			||||||
#include <QDateTime>
 | 
					#include <QDateTime>
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
#include <QList>
 | 
					#include <QList>
 | 
				
			||||||
 | 
					#include <map>
 | 
				
			||||||
 | 
					#include <memory>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString const CalcState::SUCCESS = "SUCCESS";
 | 
					QString const CalcState::SUCCESS = "SUCCESS";
 | 
				
			||||||
QString const CalcState::ERROR_PARSING_ZONE_NR = "ERROR_PARSING_ZONE_NR";
 | 
					QString const CalcState::ERROR_PARSING_ZONE_NR = "ERROR_PARSING_ZONE_NR";
 | 
				
			||||||
@@ -28,6 +31,104 @@ QString const CalcState::OVERPAID = "OVERPAID";
 | 
				
			|||||||
QString const CalcState::OUTSIDE_ALLOWED_PARKING_TIME = "OUTSIDE_ALLOWED_PARKING_TIME";
 | 
					QString const CalcState::OUTSIDE_ALLOWED_PARKING_TIME = "OUTSIDE_ALLOWED_PARKING_TIME";
 | 
				
			||||||
QString const CalcState::SUCCESS_MAXPRICE = "SUCCESS_MAXPRICE";
 | 
					QString const CalcState::SUCCESS_MAXPRICE = "SUCCESS_MAXPRICE";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static std::map<PERMIT_TYPE, std::unique_ptr<parking_tariff_t>> tariffs;
 | 
				
			||||||
 | 
					static QDateTime start_ = QDateTime::currentDateTime();
 | 
				
			||||||
 | 
					static Configuration const *current_tariff{nullptr};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int CALCULATE_LIBRARY_API isOutOfService(QDateTime const &dt) {
 | 
				
			||||||
 | 
					    if (!current_tariff) {
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "NO CURRENT TARIFF";
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // L201
 | 
				
			||||||
 | 
					    if (current_tariff->tariffFileName.contains("tariff01")) {
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "NO";
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    } else
 | 
				
			||||||
 | 
					    // L264
 | 
				
			||||||
 | 
					    if (current_tariff->tariffFileName.contains("tariff02") ||
 | 
				
			||||||
 | 
					        current_tariff->tariffFileName.contains("tariff02_1700_2300") ||
 | 
				
			||||||
 | 
					        current_tariff->tariffFileName.contains("tariff02_1900_2300")) {
 | 
				
			||||||
 | 
					        // feiertage
 | 
				
			||||||
 | 
					        QDate const &d = dt.date();
 | 
				
			||||||
 | 
					        if (d.toString(Qt::ISODate) == "2025-06-09"
 | 
				
			||||||
 | 
					         || d.toString(Qt::ISODate) == "2025-06-19"
 | 
				
			||||||
 | 
					         || d.toString(Qt::ISODate) == "2025-08-15"
 | 
				
			||||||
 | 
					         || d.toString(Qt::ISODate) == "2025-10-03"
 | 
				
			||||||
 | 
					         || d.toString(Qt::ISODate) == "2025-11-01"
 | 
				
			||||||
 | 
					         || d.toString(Qt::ISODate) == "2025-12-25"
 | 
				
			||||||
 | 
					         || d.toString(Qt::ISODate) == "2025-12-26") {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__ << "YES";
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int const day = d.dayOfWeek();
 | 
				
			||||||
 | 
					        if (day == 7) {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__ << "YES";
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dt.time() >= QTime::fromString("23:00:00", Qt::ISODate)) {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__ << "YES";
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    } else
 | 
				
			||||||
 | 
					    // H242
 | 
				
			||||||
 | 
					    if (current_tariff->tariffFileName.contains("tariff03") ||
 | 
				
			||||||
 | 
					        current_tariff->tariffFileName.contains("tariff03_H242_sat")) {
 | 
				
			||||||
 | 
					        // feiertage
 | 
				
			||||||
 | 
					        QDate const &d = dt.date();
 | 
				
			||||||
 | 
					        if (d.toString(Qt::ISODate) == "2025-06-09"
 | 
				
			||||||
 | 
					         || d.toString(Qt::ISODate) == "2025-06-19"
 | 
				
			||||||
 | 
					         || d.toString(Qt::ISODate) == "2025-08-15"
 | 
				
			||||||
 | 
					         || d.toString(Qt::ISODate) == "2025-10-03"
 | 
				
			||||||
 | 
					         || d.toString(Qt::ISODate) == "2025-11-01"
 | 
				
			||||||
 | 
					         || d.toString(Qt::ISODate) == "2025-12-25"
 | 
				
			||||||
 | 
					         || d.toString(Qt::ISODate) == "2025-12-26") {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__ << "YES";
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int const day = d.dayOfWeek();
 | 
				
			||||||
 | 
					        if (day == 7) {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__ << "YES";
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        QTime const &t = dt.time();
 | 
				
			||||||
 | 
					        if (day <= 5) {
 | 
				
			||||||
 | 
					            if (t < QTime::fromString("18:00:00", Qt::ISODate)) {
 | 
				
			||||||
 | 
					                qCritical() << __func__ << ":" << __LINE__ << "YES";
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (day == 6) {
 | 
				
			||||||
 | 
					            if (t < QTime::fromString("14:00:00", Qt::ISODate)) {
 | 
				
			||||||
 | 
					                qCritical() << __func__ << ":" << __LINE__ << "YES";
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (t >= QTime::fromString("23:00:00", Qt::ISODate)) {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__ << "YES";
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "NO";
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int CALCULATE_LIBRARY_API isOutOfService(Configuration const *cfg,
 | 
				
			||||||
 | 
					                                         QDateTime const &dt) {
 | 
				
			||||||
 | 
					    Q_UNUSED(cfg);
 | 
				
			||||||
 | 
					    return isOutOfService(dt);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
 | 
					QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
 | 
				
			||||||
    return Calculator::GetInstance().GetTimeSteps(cfg);
 | 
					    return Calculator::GetInstance().GetTimeSteps(cfg);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -35,15 +136,91 @@ QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
 | 
				
			|||||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
 | 
					int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
 | 
				
			||||||
                                                  PERMIT_TYPE permitType,
 | 
					                                                  PERMIT_TYPE permitType,
 | 
				
			||||||
                                                  int paymentOptionIndex) {
 | 
					                                                  int paymentOptionIndex) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
    int minTime = 0;
 | 
					    int minTime = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // tariffs are only set if there is a Includes-section in the tariff-file,
 | 
				
			||||||
 | 
					    // which means the code below will be executed only in such a case.
 | 
				
			||||||
 | 
					    if (tariffs.count(permitType) > 0) {
 | 
				
			||||||
 | 
					        Configuration *c = tariffs[permitType].get();
 | 
				
			||||||
 | 
					        if (c && c != cfg) {
 | 
				
			||||||
 | 
					            Configuration *const c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					            Configuration *const c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					            if (cfg != c1 && cfg != c2) {
 | 
				
			||||||
 | 
					                cfg = c;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
 | 
				
			||||||
 | 
					        Configuration *c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					        if (c1 && c1->ValidFrom.isValid()) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << start_.time() << c1->ValidFrom;
 | 
				
			||||||
 | 
					            if (start_.time() >= c1->ValidFrom) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					                if (c2 && c2 != cfg) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    if (c1 && c1 != cfg) {
 | 
				
			||||||
 | 
					                        cfg = c1;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (c1 && c1->ValidForWeekDay == start_.date().dayOfWeek()) {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            if (c1 && c1 != cfg) {
 | 
				
			||||||
 | 
					                cfg = c1;
 | 
				
			||||||
 | 
					                qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
 | 
				
			||||||
 | 
					        Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					        if (c2 && c2->ValidFrom.isValid()) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            if (start_.time() >= c2->ValidFrom) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                if (c2 && c2 != cfg) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    cfg = c2;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_tariff = cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int weekDay = start_.date().dayOfWeek();
 | 
				
			||||||
 | 
					    qCritical() << __func__ << __LINE__ << cfg << "CCCCCC week" << (int)permitType << weekDay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (auto[itr, rangeEnd] = cfg->WeekDays.equal_range((Qt::DayOfWeek)weekDay); itr != rangeEnd; ++itr) {
 | 
				
			||||||
 | 
					        ATBWeekDay const &wd = itr->second;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        minTime = wd.getTariffSettings().m_min_time;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << __LINE__ << "CCCCCC min_time" << (int)permitType << minTime;
 | 
				
			||||||
 | 
					        if (minTime < 0) {
 | 
				
			||||||
 | 
					            return minTime;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    paymentOptionIndex = getPaymentOptionIndex(*cfg);
 | 
					    paymentOptionIndex = getPaymentOptionIndex(*cfg);
 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					    if (paymentOptionIndex == -1) {
 | 
				
			||||||
        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();
 | 
					    qCritical() << __func__ << __LINE__ << "permit" << (int)permitType << PermitType(permitType).toString();
 | 
				
			||||||
 | 
					    qCritical() << __func__ << __LINE__ << "min_time" << (int)permitType << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << __LINE__ << "min_price" << (int)permitType << cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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)
 | 
				
			||||||
@@ -65,7 +242,7 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
 | 
				
			|||||||
        minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time);
 | 
					        minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qCritical() << "minTime" << minTime;
 | 
					    qCritical() << __func__ << ":" << __LINE__ << " minTime" << minTime;
 | 
				
			||||||
    return minTime;
 | 
					    return minTime;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -73,6 +250,64 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
 | 
				
			|||||||
                                                  PERMIT_TYPE permitType,
 | 
					                                                  PERMIT_TYPE permitType,
 | 
				
			||||||
                                                  int paymentOptionIndex) {
 | 
					                                                  int paymentOptionIndex) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					    // tariffs are only set if there is a Includes-section in the tariff-file,
 | 
				
			||||||
 | 
					    // which means the code below will be executed only in such a case.
 | 
				
			||||||
 | 
					    if (tariffs.count(permitType) > 0) {
 | 
				
			||||||
 | 
					        Configuration *c = tariffs[permitType].get();
 | 
				
			||||||
 | 
					        if (c && c != cfg) {
 | 
				
			||||||
 | 
					            Configuration *const c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					            Configuration *const c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					            if (cfg != c1 && cfg != c2) {
 | 
				
			||||||
 | 
					                cfg = c;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
 | 
				
			||||||
 | 
					        Configuration *c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					        if (c1 && c1->ValidFrom.isValid()) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << start_.time() << c1->ValidFrom;
 | 
				
			||||||
 | 
					            if (start_.time() >= c1->ValidFrom) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					                if (c2 && c2 != cfg) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    if (c1 && c1 != cfg) {
 | 
				
			||||||
 | 
					                        cfg = c1;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (c1 && c1->ValidForWeekDay == start_.date().dayOfWeek()) {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            if (c1 && c1 != cfg) {
 | 
				
			||||||
 | 
					                cfg = c1;
 | 
				
			||||||
 | 
					                qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
 | 
				
			||||||
 | 
					        Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					        if (c2 && c2->ValidFrom.isValid()) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            if (start_.time() >= c2->ValidFrom) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                if (c2 && c2 != cfg) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    cfg = c2;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_tariff = cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    paymentOptionIndex = getPaymentOptionIndex(*cfg);
 | 
					    paymentOptionIndex = getPaymentOptionIndex(*cfg);
 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					    if (paymentOptionIndex == -1) {
 | 
				
			||||||
        paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
					        paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
				
			||||||
@@ -94,6 +329,8 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
 | 
				
			|||||||
        maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
					        maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << " maxTime" << maxTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return maxTime;
 | 
					    return maxTime;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -101,8 +338,67 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
 | 
				
			|||||||
                                                   PERMIT_TYPE permitType,
 | 
					                                                   PERMIT_TYPE permitType,
 | 
				
			||||||
                                                   int paymentOptionIndex,
 | 
					                                                   int paymentOptionIndex,
 | 
				
			||||||
                                                   QDateTime const &start) {
 | 
					                                                   QDateTime const &start) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					    start_ = start;
 | 
				
			||||||
    int minPrice = -1;
 | 
					    int minPrice = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // tariffs are only set if there is a Includes-section in the tariff-file,
 | 
				
			||||||
 | 
					    // which means the code below will be executed only in such a case.
 | 
				
			||||||
 | 
					    if (tariffs.count(permitType) > 0) {
 | 
				
			||||||
 | 
					        Configuration *c = tariffs[permitType].get();
 | 
				
			||||||
 | 
					        if (c && c != cfg) {
 | 
				
			||||||
 | 
					            Configuration *const c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					            Configuration *const c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					            if (cfg != c1 && cfg != c2) {
 | 
				
			||||||
 | 
					                cfg = c;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
 | 
				
			||||||
 | 
					        Configuration *c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					        if (c1 && c1->ValidFrom.isValid()) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << start_.time() << c1->ValidFrom;
 | 
				
			||||||
 | 
					            if (start_.time() >= c1->ValidFrom) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					                if (c2 && c2 != cfg) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    if (c1 && c1 != cfg) {
 | 
				
			||||||
 | 
					                        cfg = c1;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (c1 && c1->ValidForWeekDay == start_.date().dayOfWeek()) {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            if (c1 && c1 != cfg) {
 | 
				
			||||||
 | 
					                cfg = c1;
 | 
				
			||||||
 | 
					                qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
 | 
				
			||||||
 | 
					        Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					        if (c2 && c2->ValidFrom.isValid()) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            if (start_.time() >= c2->ValidFrom) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                if (c2 && c2 != cfg) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    cfg = c2;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_tariff = cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((paymentOptionIndex = getPaymentOptionIndex(*cfg, start)) == -1) {
 | 
					    if ((paymentOptionIndex = getPaymentOptionIndex(*cfg, start)) == -1) {
 | 
				
			||||||
        paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
					        paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -159,6 +455,7 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << " minPrice" << minPrice;
 | 
				
			||||||
    return minPrice;
 | 
					    return minPrice;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -167,6 +464,22 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
 | 
				
			|||||||
                                                QDateTime const &start,
 | 
					                                                QDateTime const &start,
 | 
				
			||||||
                                                QDateTime *productStart,
 | 
					                                                QDateTime *productStart,
 | 
				
			||||||
                                                QDateTime *productEnd) {
 | 
					                                                QDateTime *productEnd) {
 | 
				
			||||||
 | 
					    start_ = start;
 | 
				
			||||||
 | 
					    // tariffs are only set if there is a Includes-section in the tariff-file,
 | 
				
			||||||
 | 
					    // which means the code below will be executed only in such a case.
 | 
				
			||||||
 | 
					    if (tariffs.count(permitType) > 0) {
 | 
				
			||||||
 | 
					        Configuration *c = tariffs[permitType].get();
 | 
				
			||||||
 | 
					        if (c && c != cfg) {
 | 
				
			||||||
 | 
					            Configuration *const c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					            Configuration *const c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					            if (cfg != c1 && cfg != c2) {
 | 
				
			||||||
 | 
					                cfg = c;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_tariff = 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)
 | 
				
			||||||
@@ -329,7 +642,66 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
 | 
				
			|||||||
int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
 | 
					int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
 | 
				
			||||||
                                                   PERMIT_TYPE permitType,
 | 
					                                                   PERMIT_TYPE permitType,
 | 
				
			||||||
                                                   int paymentOptionIndex) {
 | 
					                                                   int paymentOptionIndex) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
    int maxPrice = -1;
 | 
					    int maxPrice = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // tariffs are only set if there is a Includes-section in the tariff-file,
 | 
				
			||||||
 | 
					    // which means the code below will be executed only in such a case.
 | 
				
			||||||
 | 
					    if (tariffs.count(permitType) > 0) {
 | 
				
			||||||
 | 
					        Configuration *c = tariffs[permitType].get();
 | 
				
			||||||
 | 
					        if (c && c != cfg) {
 | 
				
			||||||
 | 
					            Configuration *const c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					            Configuration *const c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					            if (cfg != c1 && cfg != c2) {
 | 
				
			||||||
 | 
					                cfg = c;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
 | 
				
			||||||
 | 
					        Configuration *c1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					        if (c1 && c1->ValidFrom.isValid()) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << start_.time() << c1->ValidFrom;
 | 
				
			||||||
 | 
					            if (start_.time() >= c1->ValidFrom) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					                if (c2 && c2 != cfg) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    if (c1 && c1 != cfg) {
 | 
				
			||||||
 | 
					                        cfg = c1;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (c1 && c1->ValidForWeekDay == start_.date().dayOfWeek()) {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            if (c1 && c1 != cfg) {
 | 
				
			||||||
 | 
					                cfg = c1;
 | 
				
			||||||
 | 
					                qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
 | 
				
			||||||
 | 
					        Configuration *c2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					        if (c2 && c2->ValidFrom.isValid()) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            if (start_.time() >= c2->ValidFrom) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                if (c2 && c2 != cfg) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    cfg = c2;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_tariff = cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
					    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((paymentOptionIndex = getPaymentOptionIndex(*cfg)) == -1) {
 | 
					    if ((paymentOptionIndex = getPaymentOptionIndex(*cfg)) == -1) {
 | 
				
			||||||
@@ -388,6 +760,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
 | 
				
			|||||||
    default: ;
 | 
					    default: ;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << " maxPrice" << maxPrice;
 | 
				
			||||||
    return maxPrice;
 | 
					    return maxPrice;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -396,16 +769,14 @@ int CALCULATE_LIBRARY_API get_zone_nr(int zone)
 | 
				
			|||||||
    if(zone > -1) return zone;
 | 
					    if(zone > -1) return zone;
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        QFile zone("/etc/zone_nr");
 | 
					        QFile zone("/mnt/system_data/zone_nr");
 | 
				
			||||||
        if (zone.exists()) {
 | 
					        if (zone.exists()) {
 | 
				
			||||||
            QFileInfo finfo(zone);
 | 
					            QFileInfo finfo(zone);
 | 
				
			||||||
            if (finfo.size() <= 4) { // decimal 000\n
 | 
					 | 
				
			||||||
            if (zone.open(QIODevice::ReadOnly | QIODevice::Text)) {
 | 
					            if (zone.open(QIODevice::ReadOnly | QIODevice::Text)) {
 | 
				
			||||||
                QTextStream in(&zone);
 | 
					                QTextStream in(&zone);
 | 
				
			||||||
                return in.readLine(100).toInt();
 | 
					                return in.readLine(100).toInt();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -457,6 +828,9 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff, char cons
 | 
				
			|||||||
            qCritical() << "      ... error parsing tariff";
 | 
					            qCritical() << "      ... error parsing tariff";
 | 
				
			||||||
            return calcState.set(CalcState::State::ERROR_PARSING_TARIFF);
 | 
					            return calcState.set(CalcState::State::ERROR_PARSING_TARIFF);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        QFileInfo fi(confFile);
 | 
				
			||||||
 | 
					        (*tariff)->tariffFileName << fi.baseName();
 | 
				
			||||||
 | 
					        current_tariff = *tariff;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        delete *tariff;
 | 
					        delete *tariff;
 | 
				
			||||||
        *tariff = nullptr;
 | 
					        *tariff = nullptr;
 | 
				
			||||||
@@ -466,6 +840,47 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff, char cons
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    qCritical() << "init_tariff: Parsing tariff config (" << confFile << ")";
 | 
					    qCritical() << "init_tariff: Parsing tariff config (" << confFile << ")";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ((*tariff)->TariffIncludes.size() > 0) {
 | 
				
			||||||
 | 
					        qCritical() << "init_tariff: TariffIncludes" << (*tariff)->TariffIncludes;
 | 
				
			||||||
 | 
					        for (int i = 0 ; i < (*tariff)->TariffIncludes.size(); ++i) {
 | 
				
			||||||
 | 
					            QPair<QString, QString> const &p = (*tariff)->TariffIncludes.at(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QFile f(QString("/etc/psa_tariff/%1").arg((*tariff)->TariffIncludes.at(i).second));
 | 
				
			||||||
 | 
					            if (f.exists() &&
 | 
				
			||||||
 | 
					                f.open(QIODevice::ReadOnly | QIODevice::Text)) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                QString json = f.readAll();
 | 
				
			||||||
 | 
					                std::unique_ptr<parking_tariff_t> t = std::make_unique<parking_tariff_t>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (! t->ParseJson(t.get(), json.toStdString().c_str())) {
 | 
				
			||||||
 | 
					                    qCritical() << "      ... error parsing tariff in" << f.fileName();
 | 
				
			||||||
 | 
					                    qCritical() << "      ... json" << json;
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    QFileInfo fi(p.second.trimmed());
 | 
				
			||||||
 | 
					                    t->tariffFileName << fi.baseName();
 | 
				
			||||||
 | 
					                    QTime validFrom(QTime::fromString(p.first, Qt::ISODate));
 | 
				
			||||||
 | 
					                    if (validFrom.isValid()) {
 | 
				
			||||||
 | 
					                        t->ValidFrom = validFrom;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    QString validForWeekDay(p.first);
 | 
				
			||||||
 | 
					                    qCritical() << "      ... valid for weekday" << validForWeekDay;
 | 
				
			||||||
 | 
					                    if (validForWeekDay.contains("Sat")) {
 | 
				
			||||||
 | 
					                        t->ValidForWeekDay = (int)Qt::Saturday;
 | 
				
			||||||
 | 
					                    qCritical() << "      ... valid for weekday" << validForWeekDay;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    PERMIT_TYPE pt = static_cast<PERMIT_TYPE>(t->getPaymentOptions().pop_product_id);
 | 
				
			||||||
 | 
					                    if (tariffs.count(pt) == 0) {
 | 
				
			||||||
 | 
					                        const auto [it, success] = tariffs.insert(std::make_pair(pt, std::move(t)));
 | 
				
			||||||
 | 
					                        qCritical() << "      ... insertion" << success;
 | 
				
			||||||
 | 
					                        qCritical() << "      ... insertion" << (int)it->first << it->second->getPaymentOptions().pop_product_name;
 | 
				
			||||||
 | 
					                        qCritical() << "      ... insertion" << tariffs[pt]->getPaymentOptions().pop_product_name;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    return calcState;
 | 
					    return calcState;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -480,7 +895,64 @@ void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff) {
 | 
				
			|||||||
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes,
 | 
					int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes,
 | 
				
			||||||
                                                int UpDown, PermitType const &permitType)
 | 
					                                                int UpDown, PermitType const &permitType)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    if (tariffs.count(permitType) > 0) {
 | 
				
			||||||
 | 
					        parking_tariff_t *t = tariffs[permitType].get();
 | 
				
			||||||
 | 
					        if (t && t != tariff) {
 | 
				
			||||||
 | 
					            parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					            parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					            if (tariff != t1 && tariff != t2) {
 | 
				
			||||||
 | 
					                tariff = t;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
 | 
				
			||||||
 | 
					        parking_tariff_t *t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					        if (t1 && t1->ValidFrom.isValid()) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << start_.time() << t1->ValidFrom;
 | 
				
			||||||
 | 
					            if (start_.time() >= t1->ValidFrom) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                parking_tariff_t *t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					                if (t2 && t2 != tariff) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    if (t1 && t1 != tariff) {
 | 
				
			||||||
 | 
					                        tariff = t1;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (t1 && t1->ValidForWeekDay == start_.date().dayOfWeek()) {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            if (t1 && t1 != tariff) {
 | 
				
			||||||
 | 
					                tariff = t1;
 | 
				
			||||||
 | 
					                qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
 | 
				
			||||||
 | 
					        parking_tariff_t *t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					        if (t2 && t2->ValidFrom.isValid()) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            if (start_.time() >= t2->ValidFrom) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                if (t2 && t2 != tariff) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					                    tariff = t2;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_tariff = tariff;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __LINE__ << "compute_next_timestep()                  start: " << start_.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					    qCritical() << __LINE__ << "compute_next_timestep()             valid from: " << tariff->ValidFrom.toString(Qt::ISODate);
 | 
				
			||||||
    qCritical() << __LINE__ << "compute_next_timestep()     currentTimeMinutes: " << currentTimeMinutes;
 | 
					    qCritical() << __LINE__ << "compute_next_timestep()     currentTimeMinutes: " << currentTimeMinutes;
 | 
				
			||||||
    qCritical() << __LINE__ << "compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
 | 
					    qCritical() << __LINE__ << "compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -511,6 +983,7 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
 | 
				
			|||||||
    qCritical() << __LINE__ << "compute_next_timestep()   payment option index: " << paymentOptionIndex;
 | 
					    qCritical() << __LINE__ << "compute_next_timestep()   payment option index: " << paymentOptionIndex;
 | 
				
			||||||
    qCritical() << __LINE__ << "compute_next_timestep()             plus steps: " << pop_plus_steps;
 | 
					    qCritical() << __LINE__ << "compute_next_timestep()             plus steps: " << pop_plus_steps;
 | 
				
			||||||
    qCritical() << __LINE__ << "compute_next_timestep()            minus steps: " << pop_minus_steps;
 | 
					    qCritical() << __LINE__ << "compute_next_timestep()            minus steps: " << pop_minus_steps;
 | 
				
			||||||
 | 
					    qCritical() << __LINE__ << "compute_next_timestep()             valid from: " << tariff->ValidFrom;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Configuration const *cfg = tariff;
 | 
					    Configuration const *cfg = tariff;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -627,6 +1100,23 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
 | 
				
			|||||||
                qCritical() << __LINE__ << "compute_next_timestep()       next step index:" << nextStepIndex;
 | 
					                qCritical() << __LINE__ << "compute_next_timestep()       next step index:" << nextStepIndex;
 | 
				
			||||||
                if (nextStepIndex >= 0 && nextStepIndex < stepList.size()) {
 | 
					                if (nextStepIndex >= 0 && nextStepIndex < stepList.size()) {
 | 
				
			||||||
                    qCritical() << __LINE__ << "compute_next_timestep() return next time step:" << stepList[nextStepIndex];
 | 
					                    qCritical() << __LINE__ << "compute_next_timestep() return next time step:" << stepList[nextStepIndex];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // L264
 | 
				
			||||||
 | 
					                qCritical() << __LINE__ << "compute_next_timestep()  TTTTTT tariff-files:" << tariff->tariffFileName;
 | 
				
			||||||
 | 
					                    if (tariff->tariffFileName.contains("tariff02") ||
 | 
				
			||||||
 | 
					                        tariff->tariffFileName.contains("tariff02_1700_2300") ||
 | 
				
			||||||
 | 
					                        tariff->tariffFileName.contains("tariff02_1900_2300") ||
 | 
				
			||||||
 | 
					                        tariff->tariffFileName.contains("tariff03") ||
 | 
				
			||||||
 | 
					                        tariff->tariffFileName.contains("tariff03_H242_sat")) {
 | 
				
			||||||
 | 
					                        QDateTime dt = start_.addSecs( stepList[nextStepIndex] * 60);
 | 
				
			||||||
 | 
					                        qCritical() << __LINE__ << "compute_next_timestep() dt:" << dt.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (dt.time() > QTime::fromString("23:11:59", Qt::ISODate)) {
 | 
				
			||||||
 | 
					                        qCritical() << __LINE__ << "compute_next_timestep() dt:" << currentTimeMinutes;
 | 
				
			||||||
 | 
					                            return currentTimeMinutes;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    return stepList[nextStepIndex];
 | 
					                    return stepList[nextStepIndex];
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -695,6 +1185,32 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
    start = start.toLocalTime().addSecs(start_parking_time * 60);
 | 
					    start = start.toLocalTime().addSecs(start_parking_time * 60);
 | 
				
			||||||
    QDateTime end(start);
 | 
					    QDateTime end(start);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    start_ = start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // tariffs are only set if there is a Includes-section in the tariff-file,
 | 
				
			||||||
 | 
					    // which means the code below will be executed only in such a case.
 | 
				
			||||||
 | 
					    if (tariffs.count(permitType) > 0) {
 | 
				
			||||||
 | 
					        parking_tariff_t *t = tariffs[permitType].get();
 | 
				
			||||||
 | 
					        if (t && t != tariff) {
 | 
				
			||||||
 | 
					            parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					            parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					            if (tariff != t1 && tariff != t2) {
 | 
				
			||||||
 | 
					                tariff = t;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_tariff = tariff;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    } else
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int paymentOptionIndex = getPaymentOptionIndex(*tariff, start);
 | 
					    int paymentOptionIndex = getPaymentOptionIndex(*tariff, start);
 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					    if (paymentOptionIndex == -1) {
 | 
				
			||||||
        paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
 | 
					        paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
 | 
				
			||||||
@@ -766,10 +1282,61 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
        PermitType permitType,
 | 
					        PermitType permitType,
 | 
				
			||||||
        bool prepaid)
 | 
					        bool prepaid)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    start_ = start_parking_time_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    CalcState calcState;
 | 
					    CalcState calcState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QDateTime start_parking_time(start_parking_time_);
 | 
					    QDateTime start_parking_time(start_parking_time_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // tariffs are only set if there is a Includes-section in the tariff-file,
 | 
				
			||||||
 | 
					    // which means the code below will be executed only in such a case.
 | 
				
			||||||
 | 
					    if (tariffs.count(permitType) > 0) {
 | 
				
			||||||
 | 
					        parking_tariff_t *t = tariffs[permitType].get();
 | 
				
			||||||
 | 
					        if (t && t != tariff) {
 | 
				
			||||||
 | 
					            parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					            parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					            if (tariff != t1 && tariff != t2) {
 | 
				
			||||||
 | 
					                tariff = t;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_1)) > 0) {
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_1";
 | 
				
			||||||
 | 
					        parking_tariff_t *t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					        if (t1 && t1->ValidFrom.isValid()) {
 | 
				
			||||||
 | 
					            if (start_parking_time_.time() >= t1->ValidFrom) {
 | 
				
			||||||
 | 
					                parking_tariff_t *t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					                if (t2 && t2 != tariff) {
 | 
				
			||||||
 | 
					                    if (t1 && t1 != tariff) {
 | 
				
			||||||
 | 
					                        tariff = t1;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (t1 && t1->ValidForWeekDay == start_.date().dayOfWeek()) {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            if (t1 && t1 != tariff) {
 | 
				
			||||||
 | 
					                tariff = t1;
 | 
				
			||||||
 | 
					                qCritical() << __func__ << ":" << __LINE__;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } else
 | 
				
			||||||
 | 
					    if (tariffs.count(PermitType(PERMIT_TYPE::TEST_PRODUCT_2)) > 0) {
 | 
				
			||||||
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "TEST_PRODUCT_2";
 | 
				
			||||||
 | 
					        parking_tariff_t *t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					        if (t2 && t2 != tariff) {
 | 
				
			||||||
 | 
					            tariff = t2;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_tariff = tariff;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
 | 
				
			||||||
 | 
					                << isOutOfService(start_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int paymentOptionIndex = getPaymentOptionIndex(*tariff, start_parking_time);
 | 
					    int paymentOptionIndex = getPaymentOptionIndex(*tariff, start_parking_time);
 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					    if (paymentOptionIndex == -1) {
 | 
				
			||||||
        paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
					        paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
				
			||||||
@@ -782,7 +1349,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
    double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
					    double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // DEBUG
 | 
					    // DEBUG
 | 
				
			||||||
    qCritical() << "compute_price_for_parking_ticket() " << endl
 | 
					    qCritical() << __func__ << ":" << __LINE__ << endl
 | 
				
			||||||
                << "          paymentOptionIndex: " << paymentOptionIndex << endl
 | 
					                << "          paymentOptionIndex: " << paymentOptionIndex << endl
 | 
				
			||||||
                << "          start_parking_time: " << start_parking_time << endl
 | 
					                << "          start_parking_time: " << start_parking_time << endl
 | 
				
			||||||
                << "          netto_parking_time: " << netto_parking_time << endl
 | 
					                << "          netto_parking_time: " << netto_parking_time << endl
 | 
				
			||||||
@@ -792,24 +1359,32 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
                << "                     prepaid: " << prepaid
 | 
					                << "                     prepaid: " << prepaid
 | 
				
			||||||
                << "                  permitType: " << permitType.toString();
 | 
					                << "                  permitType: " << permitType.toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (netto_parking_time < 0) {
 | 
					    if (netto_parking_time < 0) {
 | 
				
			||||||
        calcState.setDesc(QString("end=%1, start=%2")
 | 
					        calcState.setDesc(QString("end=%1, start=%2")
 | 
				
			||||||
                          .arg(end_parking_time.toString(Qt::ISODate),
 | 
					                          .arg(end_parking_time.toString(Qt::ISODate),
 | 
				
			||||||
                               start_parking_time.toString(Qt::ISODate)));
 | 
					                               start_parking_time.toString(Qt::ISODate)));
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
 | 
				
			||||||
        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));
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
 | 
				
			||||||
        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));
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
 | 
				
			||||||
        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);
 | 
					        qCritical() << __func__ << ":" << __LINE__ << "CCCCCC" << netto_parking_time;
 | 
				
			||||||
 | 
					   //     return calcState.set(CalcState::State::SUCCESS);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    double cost = -1;
 | 
					    double cost = -1;
 | 
				
			||||||
    if (start_parking_time.isValid()) {
 | 
					    if (start_parking_time.isValid()) {
 | 
				
			||||||
        if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps ||
 | 
					        if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps ||
 | 
				
			||||||
@@ -852,6 +1427,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QDateTime effectiveStartTime(start_parking_time);
 | 
					            QDateTime effectiveStartTime(start_parking_time);
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
 | 
				
			||||||
 | 
					                        << effectiveStartTime.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // handle special days
 | 
					            // handle special days
 | 
				
			||||||
            int const specialDayId = tariff->specialDayId(start_parking_time);
 | 
					            int const specialDayId = tariff->specialDayId(start_parking_time);
 | 
				
			||||||
@@ -882,6 +1459,9 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
 | 
				
			||||||
 | 
					                        << effectiveStartTime.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // handle prepaid option
 | 
					            // handle prepaid option
 | 
				
			||||||
            int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
					            int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
				
			||||||
            std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
 | 
					            std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
 | 
				
			||||||
@@ -896,17 +1476,36 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                    if (start_parking_time.time() < p.prepaid[weekDay].static_end) {     // static_end: e.g. 08:00:00
 | 
					                    if (start_parking_time.time() < p.prepaid[weekDay].static_end) {     // static_end: e.g. 08:00:00
 | 
				
			||||||
                        effectiveStartTime.setTime(p.prepaid[weekDay].static_end);
 | 
					                        effectiveStartTime.setTime(p.prepaid[weekDay].static_end);
 | 
				
			||||||
 | 
					                        qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
 | 
				
			||||||
 | 
					                                    << effectiveStartTime.toString(Qt::ISODate);
 | 
				
			||||||
                    } else
 | 
					                    } else
 | 
				
			||||||
                    if (start_parking_time.time() > p.prepaid[weekDay].static_start) {   // static_start: e.g. 22:00:00
 | 
					                    if (start_parking_time.time() > p.prepaid[weekDay].static_start) {   // static_start: e.g. 22:00:00
 | 
				
			||||||
                        effectiveStartTime.setTime(p.prepaid[weekDay].static_start);
 | 
					                        QTime const midnight(23, 59, 59);
 | 
				
			||||||
 | 
					                        QTime const midnight24(0, 0, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if ((p.prepaid[weekDay].static_start <= midnight && midnight24 <= p.prepaid[weekDay].static_end)
 | 
				
			||||||
 | 
					                         || (p.prepaid[weekDay].static_start == midnight && midnight == p.prepaid[weekDay].static_end)
 | 
				
			||||||
 | 
					                         || (p.prepaid[weekDay].static_start == midnight24 && midnight24 == p.prepaid[weekDay].static_end)) {
 | 
				
			||||||
 | 
					                            effectiveStartTime = effectiveStartTime.addDays(1);
 | 
				
			||||||
 | 
					                            weekDay = effectiveStartTime.date().dayOfWeek();
 | 
				
			||||||
 | 
					                            qCritical() << __func__ << ":" << __LINE__
 | 
				
			||||||
 | 
					                                        << "effectiveStartTime: new week day [" << weekDay << "] (Mon=1, Tue=2, ..., Sun=7)";
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        effectiveStartTime.setTime(p.prepaid[weekDay].static_end);
 | 
				
			||||||
 | 
					                        qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
 | 
				
			||||||
 | 
					                                    << effectiveStartTime.toString(Qt::ISODate);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                qCritical() << __func__ << ":" << __LINE__ << "no prepaid option set";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // set seconds to 0
 | 
				
			||||||
            effectiveStartTime.setTime(QTime(effectiveStartTime.time().hour(),
 | 
					            effectiveStartTime.setTime(QTime(effectiveStartTime.time().hour(),
 | 
				
			||||||
                                             effectiveStartTime.time().minute(), 0));
 | 
					                                             effectiveStartTime.time().minute(), 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:" << effectiveStartTime.toString(Qt::ISODate);
 | 
					            qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
 | 
				
			||||||
 | 
					                        << effectiveStartTime.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            int const carryOver = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over;
 | 
					            int const carryOver = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -914,10 +1513,12 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (carryOver == 1) {
 | 
					            if (carryOver == 1) {
 | 
				
			||||||
                QTime carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
 | 
					                QTime carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
 | 
				
			||||||
 | 
					                QTime carryOverEnd = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end;
 | 
				
			||||||
                int carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
 | 
					                int 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__ << "     carryOverEnd:" << carryOverEnd.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                qCritical() << __func__ << ":" << __LINE__ << "carryOverDuration:" << carryOverDuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // handle carry over
 | 
					                // handle carry over
 | 
				
			||||||
                int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
 | 
					                int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
 | 
				
			||||||
@@ -927,11 +1528,11 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
                    s = s.addSecs(minutesUntilCarryOver * 60);
 | 
					                    s = s.addSecs(minutesUntilCarryOver * 60);
 | 
				
			||||||
                    s = s.addSecs(carryOverDuration * 60);
 | 
					                    s = s.addSecs(carryOverDuration * 60);
 | 
				
			||||||
                    end_parking_time = s.addSecs(rest * 60);
 | 
					                    end_parking_time = s.addSecs(rest * 60);
 | 
				
			||||||
 | 
					                    qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    end_parking_time = effectiveStartTime.addSecs(netto_parking_time*60);
 | 
					                    end_parking_time = effectiveStartTime.addSecs(netto_parking_time*60);
 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
					                    qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                weekDay = end_parking_time.date().dayOfWeek();
 | 
					                weekDay = end_parking_time.date().dayOfWeek();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -943,12 +1544,21 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
                    end_parking_time = end_parking_time.addSecs(carryOverDuration * 60);
 | 
					                    end_parking_time = end_parking_time.addSecs(carryOverDuration * 60);
 | 
				
			||||||
                } else
 | 
					                } else
 | 
				
			||||||
                if (end_parking_time.time() == carryOverStart) {
 | 
					                if (end_parking_time.time() == carryOverStart) {
 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
					                    qCritical() << __func__ << ":" << __LINE__ << "        end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "   carryOverStart" << carryOverStart.toString(Qt::ISODate);
 | 
					                    qCritical() << __func__ << ":" << __LINE__ << "          carryOverStart:" << carryOverStart.toString(Qt::ISODate);
 | 
				
			||||||
                    ATBPaymentOption const &po = tariff->getPaymentOptions(paymentOptionIndex);
 | 
					                    ATBPaymentOption const &po = tariff->getPaymentOptions(paymentOptionIndex);
 | 
				
			||||||
                    if (po.pop_apply_carry_over_to_ticket_endtime) {
 | 
					                    if (po.pop_apply_carry_over_to_ticket_endtime) {
 | 
				
			||||||
                        end_parking_time = end_parking_time.addSecs(carryOverDuration * 60);
 | 
					                        end_parking_time = end_parking_time.addSecs(carryOverDuration * 60);
 | 
				
			||||||
                        qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
					                        qCritical() << __func__ << ":" << __LINE__ << "adapted end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                } else
 | 
				
			||||||
 | 
					                if (end_parking_time.time() == carryOverEnd) {
 | 
				
			||||||
 | 
					                    qCritical() << __func__ << ":" << __LINE__ << "        end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                    qCritical() << __func__ << ":" << __LINE__ << "            carryOverEnd:" << carryOverEnd.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                    ATBPaymentOption const &po = tariff->getPaymentOptions(paymentOptionIndex);
 | 
				
			||||||
 | 
					                    if (po.pop_apply_carry_over_to_ticket_endtime == false) {
 | 
				
			||||||
 | 
					                        end_parking_time = end_parking_time.addSecs(-carryOverDuration * 60);
 | 
				
			||||||
 | 
					                        qCritical() << __func__ << ":" << __LINE__ << "adapted end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
@@ -980,6 +1590,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        } else
 | 
					        } else
 | 
				
			||||||
        if (tariff->getPaymentOptions(0).pop_payment_method_id == PaymentMethod::Unified) {
 | 
					        if (tariff->getPaymentOptions(0).pop_payment_method_id == PaymentMethod::Unified) {
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "CCCCCC";
 | 
				
			||||||
            std::pair<CalcState, std::optional<int>> p =
 | 
					            std::pair<CalcState, std::optional<int>> p =
 | 
				
			||||||
                Calculator::GetInstance().ComputeCostFromDuration(tariff, start_parking_time, end_parking_time, netto_parking_time);
 | 
					                Calculator::GetInstance().ComputeCostFromDuration(tariff, start_parking_time, end_parking_time, netto_parking_time);
 | 
				
			||||||
            CalcState const cs = p.first;
 | 
					            CalcState const cs = p.first;
 | 
				
			||||||
@@ -1037,6 +1648,23 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
        QString &duration,
 | 
					        QString &duration,
 | 
				
			||||||
        PermitType permitType) {
 | 
					        PermitType permitType) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // tariffs are only set if there is a Includes-section in the tariff-file,
 | 
				
			||||||
 | 
					    // which means the code below will be executed only in such a case.
 | 
				
			||||||
 | 
					    if (tariffs.count(permitType) > 0) {
 | 
				
			||||||
 | 
					        parking_tariff_t *t = tariffs[permitType].get();
 | 
				
			||||||
 | 
					        if (t && t != tariff) {
 | 
				
			||||||
 | 
					            parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					            parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					            if (tariff != t1 && tariff != t2) {
 | 
				
			||||||
 | 
					                tariff = t;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_tariff = tariff;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
 | 
				
			||||||
 | 
					                << isOutOfService(start_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    tariff->getPaymentOptions(0).pop_max_price
 | 
					    tariff->getPaymentOptions(0).pop_max_price
 | 
				
			||||||
        = tariff->getPaymentOptions(0).pop_max_price_save;
 | 
					        = tariff->getPaymentOptions(0).pop_max_price_save;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1045,6 +1673,9 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
    QTime const t(0, 0, 0);
 | 
					    QTime const t(0, 0, 0);
 | 
				
			||||||
    QDateTime start(d, t, Qt::UTC);
 | 
					    QDateTime start(d, t, Qt::UTC);
 | 
				
			||||||
    start = start.toLocalTime().addSecs(start_parking_time * 60);
 | 
					    start = start.toLocalTime().addSecs(start_parking_time * 60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    start_ = start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (start.isValid()) {
 | 
					    if (start.isValid()) {
 | 
				
			||||||
        QString cs = start.toString(Qt::ISODate);
 | 
					        QString cs = start.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1095,6 +1726,25 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
        QDateTime &ticketEndTime,
 | 
					        QDateTime &ticketEndTime,
 | 
				
			||||||
        PermitType permitType)
 | 
					        PermitType permitType)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    start_ = start_parking_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // tariffs are only set if there is a Includes-section in the tariff-file,
 | 
				
			||||||
 | 
					    // which means the code below will be executed only in such a case.
 | 
				
			||||||
 | 
					    if (tariffs.count(permitType) > 0) {
 | 
				
			||||||
 | 
					        parking_tariff_t *t = tariffs[permitType].get();
 | 
				
			||||||
 | 
					        if (t && t != tariff) {
 | 
				
			||||||
 | 
					            parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					            parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					            if (tariff != t1 && tariff != t2) {
 | 
				
			||||||
 | 
					                tariff = t;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_tariff = tariff;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
 | 
				
			||||||
 | 
					                << isOutOfService(start_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    tariff->getPaymentOptions(0).pop_max_price
 | 
					    tariff->getPaymentOptions(0).pop_max_price
 | 
				
			||||||
        = tariff->getPaymentOptions(0).pop_max_price_save;
 | 
					        = tariff->getPaymentOptions(0).pop_max_price_save;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1102,8 +1752,15 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    bool prepaid = true;
 | 
					    bool prepaid = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "   permit type (int): " << static_cast<int>(permitType);
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "permit type (string): " << permitType.toString();
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "     tariff-includes: " << tariff->getTariffIncludes();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int paymentOptionIndex = getPaymentOptionIndex(*tariff, start_parking_time);
 | 
					    int paymentOptionIndex = getPaymentOptionIndex(*tariff, start_parking_time);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qCritical() << __func__ << ":" << __LINE__ << "payment option index: " << paymentOptionIndex;
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "payment option index: " << paymentOptionIndex;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					    if (paymentOptionIndex == -1) {
 | 
				
			||||||
        paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
					        paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -1423,8 +2080,27 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff,
 | 
					CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff,
 | 
				
			||||||
                                                                  QDateTime const &start_parking_time,
 | 
					                                                                  QDateTime const &start_parking_time,
 | 
				
			||||||
                                                                  QDateTime &ticketEndTime,
 | 
					                                                                  QDateTime &ticketEndTime,
 | 
				
			||||||
                                                                  PermitType /* PermitType */)
 | 
					                                                                  PermitType permitType)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    start_ = start_parking_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // tariffs are only set if there is a Includes-section in the tariff-file,
 | 
				
			||||||
 | 
					    // which means the code below will be executed only in such a case.
 | 
				
			||||||
 | 
					    if (tariffs.count(permitType) > 0) {
 | 
				
			||||||
 | 
					        parking_tariff_t *t = tariffs[permitType].get();
 | 
				
			||||||
 | 
					        if (t && t != tariff) {
 | 
				
			||||||
 | 
					            parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					            parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					            if (tariff != t1 && tariff != t2) {
 | 
				
			||||||
 | 
					                tariff = t;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_tariff = tariff;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
 | 
				
			||||||
 | 
					                << isOutOfService(start_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    tariff->getPaymentOptions(0).pop_max_price
 | 
					    tariff->getPaymentOptions(0).pop_max_price
 | 
				
			||||||
        = tariff->getPaymentOptions(0).pop_max_price_save;
 | 
					        = tariff->getPaymentOptions(0).pop_max_price_save;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1460,6 +2136,25 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_daily_ticket(
 | 
				
			|||||||
                                    PERMIT_TYPE permitType,
 | 
					                                    PERMIT_TYPE permitType,
 | 
				
			||||||
                                    struct price_t *price) {// return value
 | 
					                                    struct price_t *price) {// return value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    start_ = startDatetime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // tariffs are only set if there is a Includes-section in the tariff-file,
 | 
				
			||||||
 | 
					    // which means the code below will be executed only in such a case.
 | 
				
			||||||
 | 
					    if (tariffs.count(permitType) > 0) {
 | 
				
			||||||
 | 
					        parking_tariff_t *t = tariffs[permitType].get();
 | 
				
			||||||
 | 
					        if (t && t != tariff) {
 | 
				
			||||||
 | 
					            parking_tariff_t *const t1 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_1)].get();
 | 
				
			||||||
 | 
					            parking_tariff_t *const t2 = tariffs[PermitType(PERMIT_TYPE::TEST_PRODUCT_2)].get();
 | 
				
			||||||
 | 
					            if (tariff != t1 && tariff != t2) {
 | 
				
			||||||
 | 
					                tariff = t;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_tariff = tariff;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "OUT_OF_SERVICE: "
 | 
				
			||||||
 | 
					                << isOutOfService(start_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    tariff->getPaymentOptions(0).pop_max_price
 | 
					    tariff->getPaymentOptions(0).pop_max_price
 | 
				
			||||||
        = tariff->getPaymentOptions(0).pop_max_price_save;
 | 
					        = tariff->getPaymentOptions(0).pop_max_price_save;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -379,7 +379,8 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    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_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
 | 
					    int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price =
 | 
				
			||||||
 | 
					                                cfg->getPaymentOptions(paymentOptionIndex).pop_max_price_save;
 | 
				
			||||||
    int const pop_max_time = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
					    int const pop_max_time = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
				
			||||||
    int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
					    int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
				
			||||||
    int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
 | 
					    int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
 | 
				
			||||||
@@ -452,13 +453,50 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
 | 
				
			|||||||
    netto_parking_time_in_minutes = 0;
 | 
					    netto_parking_time_in_minutes = 0;
 | 
				
			||||||
    brutto_parking_time_in_minutes = 0;
 | 
					    brutto_parking_time_in_minutes = 0;
 | 
				
			||||||
    free_parking_time_in_minutes = 0;
 | 
					    free_parking_time_in_minutes = 0;
 | 
				
			||||||
 | 
					    int nettoParktimeForCost = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int const nettoParktimeForCost = priceNettoParktime[int(cost)];
 | 
					    if (priceNettoParktime.contains(int(cost))) {
 | 
				
			||||||
 | 
					        nettoParktimeForCost = priceNettoParktime[int(cost)];
 | 
				
			||||||
        qCritical() << __func__ << ":" << __LINE__ << QString("cost=%1 nettoParkTimeForCost=%2").
 | 
					        qCritical() << __func__ << ":" << __LINE__ << QString("cost=%1 nettoParkTimeForCost=%2").
 | 
				
			||||||
                                                            arg(cost).arg(nettoParktimeForCost);
 | 
					                                                            arg(cost).arg(nettoParktimeForCost);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // cannot find netto-parking time for cost (=price)
 | 
				
			||||||
 | 
					        // this happens for direct coin input and should not happen otherwise
 | 
				
			||||||
 | 
					        // take the value for the nearest value of cost and mark result as overpaid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        QList <int> keys = priceNettoParktime.keys();   // keys (=prices) are sorted in ascending order
 | 
				
			||||||
 | 
					        QSet<int> s; // make keys unique
 | 
				
			||||||
 | 
					        for (int k = 0; k < keys.size(); ++k) {
 | 
				
			||||||
 | 
					            if (keys[k] < cost) {
 | 
				
			||||||
 | 
					                s << keys[k];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        keys = s.values();
 | 
				
			||||||
 | 
					        // sort in descending order
 | 
				
			||||||
 | 
					        std::sort(std::begin(keys), std::end(keys), std::greater<>());
 | 
				
			||||||
 | 
					        // qCritical() << __func__ << ":" << __LINE__ << "keys=" << keys;
 | 
				
			||||||
 | 
					        if (!keys.isEmpty()) {
 | 
				
			||||||
 | 
					            int const maxCost = keys[0];
 | 
				
			||||||
 | 
					            auto const p = priceNettoParktime.equal_range(maxCost);
 | 
				
			||||||
 | 
					            for (auto it = p.first; it != p.second; ++it) {
 | 
				
			||||||
 | 
					                nettoParktimeForCost = std::max(nettoParktimeForCost, it.value());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            ATBPaymentOption &po = cfg->getPaymentOptions(paymentOptionIndex);
 | 
				
			||||||
 | 
					            po.pop_max_price = maxCost;
 | 
				
			||||||
 | 
					            cfg->getPaymentOptions(paymentOptionIndex).pop_max_price = maxCost;
 | 
				
			||||||
 | 
					            if (pop_allow_overpay) {
 | 
				
			||||||
 | 
					                overPaid = true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__ << QString("cost=%1 -> maxCost=%2 nettoParkTimeForCost=%3").
 | 
				
			||||||
 | 
					                                                            arg(cost).arg(maxCost).arg(nettoParktimeForCost);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            qCritical() << __func__ << ":" << __LINE__ << "ERROR empty keys -> check tariff file";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int cnt = 0;
 | 
					    int cnt = 0;
 | 
				
			||||||
    while (++cnt < 10 && netto_parking_time_in_minutes < nettoParktimeForCost) {
 | 
					    while (++cnt < 20 && netto_parking_time_in_minutes < nettoParktimeForCost) {
 | 
				
			||||||
        // qCritical() << __func__ << ":" << __LINE__ << "cnt [" << cnt;
 | 
					        // qCritical() << __func__ << ":" << __LINE__ << "cnt [" << cnt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        brutto_parking_time_in_minutes = free_parking_time_in_minutes + netto_parking_time_in_minutes;
 | 
					        brutto_parking_time_in_minutes = free_parking_time_in_minutes + netto_parking_time_in_minutes;
 | 
				
			||||||
@@ -711,6 +749,10 @@ Calculator::ComputeCostFromDuration(Configuration *cfg, QDateTime const &startDa
 | 
				
			|||||||
    CalcState returnState;
 | 
					    CalcState returnState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QList<int> keys = nettoParktimePrice.keys();
 | 
					    QList<int> keys = nettoParktimePrice.keys();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "Times Keys" << keys;
 | 
				
			||||||
 | 
					    qCritical() << __func__ << ":" << __LINE__ << "Prices Keys" << priceNettoParktime.keys();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int index = keys.indexOf(nettoParkingTime);
 | 
					    int index = keys.indexOf(nettoParkingTime);
 | 
				
			||||||
    if (index != -1) {
 | 
					    if (index != -1) {
 | 
				
			||||||
        int c = nettoParktimePrice[keys.at(index)];
 | 
					        int c = nettoParktimePrice[keys.at(index)];
 | 
				
			||||||
@@ -912,7 +954,8 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
					                int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
				
			||||||
                int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
 | 
					                int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price
 | 
				
			||||||
 | 
					                                            = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price_save;
 | 
				
			||||||
                //int const pop_max_time = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
					                //int const pop_max_time = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
				
			||||||
                int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
					                int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
				
			||||||
                int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
 | 
					                int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
 | 
				
			||||||
@@ -3584,7 +3627,9 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
 | 
				
			|||||||
            qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (timeStep == pun_duration) {
 | 
					        // allow some tolerance when searching for [timeStep == pun_duration]:
 | 
				
			||||||
 | 
					        // this might happen when crossing minute boundaries
 | 
				
			||||||
 | 
					        if (std::abs(timeStep - pun_duration) < 4) {
 | 
				
			||||||
            qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
 | 
				
			||||||
            return price;
 | 
					            return price;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -3655,6 +3700,9 @@ Calculator::GetDailyTicketPrice(Configuration* cfg,
 | 
				
			|||||||
        if (dailyTickets) {
 | 
					        if (dailyTickets) {
 | 
				
			||||||
            QVector<ATBDailyTicket> const tickets = dailyTickets.value();
 | 
					            QVector<ATBDailyTicket> const tickets = dailyTickets.value();
 | 
				
			||||||
            switch (permitType) {
 | 
					            switch (permitType) {
 | 
				
			||||||
 | 
					                case PERMIT_TYPE::FREE_TICKET: {
 | 
				
			||||||
 | 
					                    // TODO
 | 
				
			||||||
 | 
					                } break;
 | 
				
			||||||
                case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
 | 
					                case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
 | 
				
			||||||
                    // TODO
 | 
					                    // TODO
 | 
				
			||||||
                } break;
 | 
					                } break;
 | 
				
			||||||
@@ -3742,6 +3790,10 @@ Calculator::GetDailyTicketPrice(Configuration* cfg,
 | 
				
			|||||||
                // [[fallthrough]];
 | 
					                // [[fallthrough]];
 | 
				
			||||||
                case PERMIT_TYPE::SHORT_TERM_PARKING: {
 | 
					                case PERMIT_TYPE::SHORT_TERM_PARKING: {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                case PERMIT_TYPE::TEST_PRODUCT_1: {
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                case PERMIT_TYPE::TEST_PRODUCT_2: {
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                // [[fallthrough]];
 | 
					                // [[fallthrough]];
 | 
				
			||||||
                case PERMIT_TYPE::DAY_TICKET: {
 | 
					                case PERMIT_TYPE::DAY_TICKET: {
 | 
				
			||||||
                } break;
 | 
					                } break;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,8 @@
 | 
				
			|||||||
#include <QString>
 | 
					#include <QString>
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
#include <QRegularExpression>
 | 
					#include <QRegularExpression>
 | 
				
			||||||
 | 
					#include <QPair>
 | 
				
			||||||
 | 
					#include <QList>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// <inheritdoc/>
 | 
					/// <inheritdoc/>
 | 
				
			||||||
MemberType Configuration::IdentifyJsonMember(const char* member_name)
 | 
					MemberType Configuration::IdentifyJsonMember(const char* member_name)
 | 
				
			||||||
@@ -46,6 +48,7 @@ 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, "Includes") == 0) return MemberType::IncludesType;
 | 
				
			||||||
    else return MemberType::UnknownType;
 | 
					    else return MemberType::UnknownType;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -70,7 +73,7 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
 | 
				
			|||||||
        // start with new implementation of tariff-calculator
 | 
					        // start with new implementation of tariff-calculator
 | 
				
			||||||
        // see for instance: bad neuenahr (249), Zone5
 | 
					        // see for instance: bad neuenahr (249), Zone5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // qCritical() << __func__ << ":" << __LINE__ << innerObjName;
 | 
					        qCritical() << __func__ << ":" << __LINE__ << innerObjName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (k->value.IsObject()) {
 | 
					        if (k->value.IsObject()) {
 | 
				
			||||||
            auto obj = k->value.GetObject();
 | 
					            auto obj = k->value.GetObject();
 | 
				
			||||||
@@ -171,8 +174,9 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
 | 
				
			|||||||
                                                                if (!d.isNull() && d.isValid()) {
 | 
					                                                                if (!d.isNull() && d.isValid()) {
 | 
				
			||||||
                                                                    TariffPrepaid.m_date = d;
 | 
					                                                                    TariffPrepaid.m_date = d;
 | 
				
			||||||
                                                                }
 | 
					                                                                }
 | 
				
			||||||
 | 
					                                                                if (!prepaidIf.isNull() && !prepaidIf.trimmed().isEmpty()) {
 | 
				
			||||||
                                                                    TariffPrepaid.setPrepaidIf(prepaidIf);
 | 
					                                                                    TariffPrepaid.setPrepaidIf(prepaidIf);
 | 
				
			||||||
 | 
					                                                                }
 | 
				
			||||||
                                                                qCritical() << TariffPrepaid;
 | 
					                                                                qCritical() << TariffPrepaid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                                                cfg.TariffPrepaids.insert(std::pair<int, ATBTariffPrepaid>(weekDay, TariffPrepaid));
 | 
					                                                                cfg.TariffPrepaids.insert(std::pair<int, ATBTariffPrepaid>(weekDay, TariffPrepaid));
 | 
				
			||||||
@@ -258,7 +262,7 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
 | 
				
			|||||||
                                                                if (!d.isNull() && d.isValid()) {
 | 
					                                                                if (!d.isNull() && d.isValid()) {
 | 
				
			||||||
                                                                    TariffCarryOver.m_date = d;
 | 
					                                                                    TariffCarryOver.m_date = d;
 | 
				
			||||||
                                                                }
 | 
					                                                                }
 | 
				
			||||||
                                                                if (!carryOverIf.isEmpty()) {
 | 
					                                                                if (!carryOverIf.isNull() && !carryOverIf.trimmed().isEmpty()) {
 | 
				
			||||||
                                                                    TariffCarryOver.setCarryOverIf(carryOverIf);
 | 
					                                                                    TariffCarryOver.setCarryOverIf(carryOverIf);
 | 
				
			||||||
                                                                }
 | 
					                                                                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -461,6 +465,14 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            ATBTariffSettings ts(max_price, min_price, max_time, min_time);
 | 
				
			||||||
 | 
					            ATBTariffCarryOverSettings cs(duration, start, end, parking_time_limit, about_to_exceed_limit,
 | 
				
			||||||
 | 
					                                          parkTimeLimitChecker);
 | 
				
			||||||
 | 
					            if (!d.isNull() && d.isValid()) { // special day, given in date-format
 | 
				
			||||||
 | 
					                WeekDay = ATBWeekDay(weekDay, weekDayName, ATBWeekDay::HOLIDAY, QDate(), ts, cs);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                WeekDay = ATBWeekDay(weekDay, weekDayName, ATBWeekDay::USUAL_WEEKDAY, QDate(), ts, cs);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else
 | 
					    } else
 | 
				
			||||||
    if (innerObjName == QString("week_day_default")) {
 | 
					    if (innerObjName == QString("week_day_default")) {
 | 
				
			||||||
@@ -810,6 +822,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
            ATBInterpolation TariffInterpolation;
 | 
					            ATBInterpolation TariffInterpolation;
 | 
				
			||||||
            ATBPrepaid TariffPrepaidOption;
 | 
					            ATBPrepaid TariffPrepaidOption;
 | 
				
			||||||
            ATBCarryOver TariffCarryOver;
 | 
					            ATBCarryOver TariffCarryOver;
 | 
				
			||||||
 | 
					            QList<QPair<QString, QString>> TariffIncludes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            MemberType mb_type = MemberType::UnknownType;
 | 
					            MemberType mb_type = MemberType::UnknownType;
 | 
				
			||||||
            this->currentPaymentOptions.clear();
 | 
					            this->currentPaymentOptions.clear();
 | 
				
			||||||
@@ -875,32 +888,32 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
                    case MemberType::WeekDaysType: {
 | 
					                    case MemberType::WeekDaysType: {
 | 
				
			||||||
                        ATBWeekDay WeekDay;
 | 
					                        ATBWeekDay WeekDay;
 | 
				
			||||||
                        if (QString(mb_name) == "Monday") {
 | 
					                        if (QString(mb_name).trimmed() == "Monday") {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Monday, mb_name);
 | 
					                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Monday, QString(mb_name).trimmed());
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (QString(mb_name) == "Tuesday") {
 | 
					                        if (QString(mb_name).trimmed() == "Tuesday") {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Tuesday, mb_name);
 | 
					                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Tuesday, QString(mb_name).trimmed());
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (QString(mb_name) == "Wednesday") {
 | 
					                        if (QString(mb_name).trimmed() == "Wednesday") {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Wednesday, mb_name);
 | 
					                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Wednesday, QString(mb_name).trimmed());
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (QString(mb_name) == "Thursday") {
 | 
					                        if (QString(mb_name).trimmed() == "Thursday") {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Thursday, mb_name);
 | 
					                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Thursday, QString(mb_name).trimmed());
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (QString(mb_name) == "Friday") {
 | 
					                        if (QString(mb_name).trimmed() == "Friday") {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Friday, mb_name);
 | 
					                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Friday, QString(mb_name).trimmed());
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (QString(mb_name) == "Saturday") {
 | 
					                        if (QString(mb_name).trimmed() == "Saturday") {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Saturday, mb_name);
 | 
					                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Saturday, QString(mb_name).trimmed());
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (QString(mb_name) == "Sunday") {
 | 
					                        if (QString(mb_name).trimmed() == "Sunday") {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Sunday, mb_name);
 | 
					                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Sunday, QString(mb_name).trimmed());
 | 
				
			||||||
                        } else {
 | 
					                        } else {
 | 
				
			||||||
                            qCritical() << "ERROR: unknown week day" << mb_name;
 | 
					                            qCritical() << "ERROR: unknown week day" << mb_name;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        cfg->WeekDays.insert(pair<Qt::DayOfWeek, ATBWeekDay>(WeekDay.m_id, WeekDay));
 | 
					                        cfg->WeekDays.insert(pair<Qt::DayOfWeek, ATBWeekDay>(WeekDay.m_id, WeekDay));
 | 
				
			||||||
                        // qCritical() << WeekDay;
 | 
					                        qCritical() << __func__ << ":" << __LINE__ << cfg << "CCCC insert" << (int)WeekDay.m_id << WeekDay.m_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    } break;
 | 
					                    } break;
 | 
				
			||||||
                    case MemberType::CarryOverType: {
 | 
					                    case MemberType::CarryOverType: {
 | 
				
			||||||
@@ -1341,6 +1354,9 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                        else if (strcmp(inner_obj_name, "pcu_minor") == 0) Currency.pcu_minor = k->value.GetString();
 | 
					                        else if (strcmp(inner_obj_name, "pcu_minor") == 0) Currency.pcu_minor = k->value.GetString();
 | 
				
			||||||
                        else if (strcmp(inner_obj_name, "pcu_active") == 0) Currency.pcu_active = k->value.GetBool();
 | 
					                        else if (strcmp(inner_obj_name, "pcu_active") == 0) Currency.pcu_active = k->value.GetBool();
 | 
				
			||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case MemberType::IncludesType:
 | 
				
			||||||
 | 
					                        TariffIncludes << QPair<QString, QString>(QString(inner_obj_name), k->value.GetString());
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
                    case MemberType::PaymentMethodType:
 | 
					                    case MemberType::PaymentMethodType:
 | 
				
			||||||
                        if (strcmp(inner_obj_name, "pme_id") == 0) PaymentMethod.pme_id = k->value.GetInt();
 | 
					                        if (strcmp(inner_obj_name, "pme_id") == 0) PaymentMethod.pme_id = k->value.GetInt();
 | 
				
			||||||
                        else if (strcmp(inner_obj_name, "pme_label") == 0) PaymentMethod.pme_label = k->value.GetString();
 | 
					                        else if (strcmp(inner_obj_name, "pme_label") == 0) PaymentMethod.pme_label = k->value.GetString();
 | 
				
			||||||
@@ -1630,6 +1646,9 @@ 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::IncludesType:
 | 
				
			||||||
 | 
					                    cfg->TariffIncludes = TariffIncludes;
 | 
				
			||||||
 | 
					                    // qCritical() << "TariffIncludes" << cfg->TariffIncludes;
 | 
				
			||||||
                default:
 | 
					                default:
 | 
				
			||||||
                     break;
 | 
					                     break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -211,21 +211,73 @@ static bool test_neuhauser_kirchdorf(int step, double cost) {
 | 
				
			|||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QProcess>
 | 
				
			||||||
 | 
					#include <QCoreApplication>
 | 
				
			||||||
 | 
					QString getCalculatorLibVersion() {
 | 
				
			||||||
 | 
					    static QString v;
 | 
				
			||||||
 | 
					    if (v.isEmpty()) {
 | 
				
			||||||
 | 
					        QProcess shell;
 | 
				
			||||||
 | 
					        QString command = QString("cat /proc/%1/maps | awk '{print $6;}' | grep 'libmobilisis_calc' | uniq").arg(QCoreApplication::applicationPid());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        shell.start("/bin/bash", {"-c", command});
 | 
				
			||||||
 | 
					        if ( shell.waitForFinished( 5000 )) {
 | 
				
			||||||
 | 
					            v = shell.readAllStandardOutput();
 | 
				
			||||||
 | 
					            // /usr/lib/libmobilisis_calc.so.2.3.99-18
 | 
				
			||||||
 | 
					            if (!v.isEmpty()) {
 | 
				
			||||||
 | 
					                QStringList vlst = v.trimmed().split("/", QString::SkipEmptyParts);
 | 
				
			||||||
 | 
					                if (vlst.size() > 0) {
 | 
				
			||||||
 | 
					                    vlst = vlst.last().split(".", QString::SkipEmptyParts);
 | 
				
			||||||
 | 
					                    if (vlst.size() > 4) {
 | 
				
			||||||
 | 
					                        v = QString("%1.%2.%3").arg(vlst[2]).arg(vlst[3]).arg(vlst[4]);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return v;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool isProductSupportedInCalculatorLib(QString const &product) {
 | 
				
			||||||
 | 
					    bool supported{false};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QProcess shell;
 | 
				
			||||||
 | 
					    QString command = QString("cat /proc/%1/maps | awk '{print $6;}' | grep 'libmobilisis_calc' | uniq | xargs strings | grep %2").arg(QCoreApplication::applicationPid()).arg(product);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    shell.start("/bin/bash", {"-c", command});
 | 
				
			||||||
 | 
					    if ( shell.waitForFinished( 5000 )) {
 | 
				
			||||||
 | 
					        QString s = shell.readAllStandardOutput().trimmed();
 | 
				
			||||||
 | 
					        // /usr/lib/libmobilisis_calc.so.2.3.99-18
 | 
				
			||||||
 | 
					        if (!s.isEmpty() && (s == product)) {
 | 
				
			||||||
 | 
					            qCritical() << "product" << s << "supported";
 | 
				
			||||||
 | 
					            supported = true;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            qCritical() << "product" << product << "not supported";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return supported;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main() {
 | 
					int main() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << getCalculatorLibVersion();
 | 
				
			||||||
 | 
					    isProductSupportedInCalculatorLib("FREE_TICKET");
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
    //487     {
 | 
					    //487     {
 | 
				
			||||||
    //  488         "pra_payment_option_id": 1049,
 | 
					    //  488         "pra_payment_option_id": 1049,
 | 
				
			||||||
    //  489         "pra_payment_unit_id": 84,
 | 
					    //  489         "pra_payment_unit_id": 84,
 | 
				
			||||||
    //  490         "pra_price":"840"
 | 
					    //  490         "pra_price":"840"
 | 
				
			||||||
    //>>491     }
 | 
					    //>>491     }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //for (int i = 1; i < 85; ++i) {
 | 
					    //for (int i = 1; i < 346; ++i) {
 | 
				
			||||||
    //printf("{\n    \"\pra_payment_option_id\": 1049,\n    \"\pra_payment_unit_id\": %d,\n    \"pra_price\": %d\n},\n",
 | 
					    //printf("{\n    \"pun_id\": %i,\n    \"pun_duration\": %d\n},\n",
 | 
				
			||||||
    //       i, i*10);
 | 
					    //       i, 60 + i*4);
 | 
				
			||||||
    //}
 | 
					    //}
 | 
				
			||||||
    //return 0;
 | 
					    for (int i = 1; i < 361; ++i) {
 | 
				
			||||||
 | 
					    printf("{\n    \"pra_payment_option_id\": 1049,\n    \"pra_payment_unit_id\": %i,\n    \"pra_price\":%i\n},\n",
 | 
				
			||||||
 | 
					           i, i*10);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
    MessageHelper msgHelp;
 | 
					    MessageHelper msgHelp;
 | 
				
			||||||
    // msgHelp.createLoginMessageChunksToSend(0x02);
 | 
					    // msgHelp.createLoginMessageChunksToSend(0x02);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,5 @@
 | 
				
			|||||||
 | 
					QT += core
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEMPLATE = app
 | 
					TEMPLATE = app
 | 
				
			||||||
TARGET = main
 | 
					TARGET = main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user