Compare commits
	
		
			18 Commits
		
	
	
		
			fix-kirchd
			...
			neuhauser-
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						16ccb706da
	
				 | 
					
					
						|||
| fcbc8dcdc3 | |||
| ed99bae725 | |||
| 627d14204d | |||
| 
						
						
							
						
						d8a4c4eaa7
	
				 | 
					
					
						|||
| 4f45db4fde | |||
| a744a1ebb3 | |||
| df16bd7f9c | |||
| b751ba339e | |||
| 
						
						
							
						
						588a88455b
	
				 | 
					
					
						|||
| 
						
						
							
						
						92bfdced6a
	
				 | 
					
					
						|||
| 8bbec596c9 | |||
| 87b14ee3f8 | |||
| 3ad2c77467 | |||
| 493d94aaa1 | |||
| 7831329b11 | |||
| abbbd06f93 | |||
| ac6e45a913 | 
@@ -84,6 +84,51 @@ struct CALCULATE_LIBRARY_API CalcState {
 | 
				
			|||||||
        return (m_status == State::SUCCESS);
 | 
					        return (m_status == State::SUCCESS);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QString toString() {
 | 
				
			||||||
 | 
					        QString s;
 | 
				
			||||||
 | 
					        switch (m_status) {
 | 
				
			||||||
 | 
					        case State::SUCCESS:
 | 
				
			||||||
 | 
					            s = "SUCCESS";
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::ERROR_PARSING_ZONE_NR:
 | 
				
			||||||
 | 
					            s = "ERROR_PARSING_ZONE_NR";
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::ERROR_LOADING_TARIFF:
 | 
				
			||||||
 | 
					            s = "ERROR_LOADING_TARIFF";
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::ERROR_PARSING_TARIFF:
 | 
				
			||||||
 | 
					            s = "ERROR_PARSING_TARIFF";
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::NEGATIVE_PARING_TIME:
 | 
				
			||||||
 | 
					            s = "NEGATIVE_PARKING_TIME";
 | 
				
			||||||
 | 
					           break;
 | 
				
			||||||
 | 
					        case State::ABOVE_MAX_PARKING_TIME:
 | 
				
			||||||
 | 
					            s = "ABOVE_MAX_PARKING_TIME";
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::WRONG_PARAM_VALUES:
 | 
				
			||||||
 | 
					            s = "WRONG_PARAM_VALUES";
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::BELOW_MIN_PARKING_TIME:
 | 
				
			||||||
 | 
					            s = "BELOW_MIN_PARKING_TIME";
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::BELOW_MIN_PARKING_PRICE:
 | 
				
			||||||
 | 
					            s = "BELOW_MIN_PARKING_PRICE";
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::OVERPAID:
 | 
				
			||||||
 | 
					            s = "OVERPAID";
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::INVALID_START_DATE:
 | 
				
			||||||
 | 
					            s = "INVALID_START_DATE";
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::WRONG_ISO_TIME_FORMAT:
 | 
				
			||||||
 | 
					            s = "WRONG_ISO_TIME_FORMAT";
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::OUTSIDE_ALLOWED_PARKING_TIME:
 | 
				
			||||||
 | 
					            s = "OUTSIDE_ALLOWED_PARKING_TIME";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return s + ":" + m_desc;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    explicit operator QString () const noexcept {
 | 
					    explicit operator QString () const noexcept {
 | 
				
			||||||
        QString s;
 | 
					        QString s;
 | 
				
			||||||
        switch (m_status) {
 | 
					        switch (m_status) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,7 @@ enum class PERMIT_TYPE : quint8 {
 | 
				
			|||||||
    DAY_TICKET_ADULT,
 | 
					    DAY_TICKET_ADULT,
 | 
				
			||||||
    DAY_TICKET_TEEN,
 | 
					    DAY_TICKET_TEEN,
 | 
				
			||||||
    DAY_TICKET_CHILD,
 | 
					    DAY_TICKET_CHILD,
 | 
				
			||||||
 | 
					    FOOD_STAMP,
 | 
				
			||||||
    INVALID
 | 
					    INVALID
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -41,6 +42,9 @@ struct PermitType {
 | 
				
			|||||||
        case 6:
 | 
					        case 6:
 | 
				
			||||||
            m_permitType = PERMIT_TYPE::DAY_TICKET_CHILD;
 | 
					            m_permitType = PERMIT_TYPE::DAY_TICKET_CHILD;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					        case 7:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::FOOD_STAMP;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            m_permitType = PERMIT_TYPE::INVALID;
 | 
					            m_permitType = PERMIT_TYPE::INVALID;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -68,6 +72,8 @@ struct PermitType {
 | 
				
			|||||||
            return 5;
 | 
					            return 5;
 | 
				
			||||||
        case PERMIT_TYPE::DAY_TICKET_TEEN:
 | 
					        case PERMIT_TYPE::DAY_TICKET_TEEN:
 | 
				
			||||||
            return 6;
 | 
					            return 6;
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::FOOD_STAMP:
 | 
				
			||||||
 | 
					            return 7;
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -75,6 +81,30 @@ struct PermitType {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    operator QString () {
 | 
				
			||||||
 | 
					        switch(m_permitType) {
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET:
 | 
				
			||||||
 | 
					            return QString("DAY_TICKET");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET_ADULT:
 | 
				
			||||||
 | 
					            return QString("DAY_TICKET_ADULT");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET_CHILD:
 | 
				
			||||||
 | 
					            return QString("DAY_TICKET_CHILD");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET_TEEN:
 | 
				
			||||||
 | 
					            return QString("DAY_TICKET_TEEN");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::SHORT_TERM_PARKING:
 | 
				
			||||||
 | 
					            return QString("SHORT_TERM_PARKING");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::SZEGED_START:
 | 
				
			||||||
 | 
					            return QString("SZEGED_START");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::SZEGED_STOP:
 | 
				
			||||||
 | 
					            return QString("SZEGED_STOP");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::FOOD_STAMP:
 | 
				
			||||||
 | 
					            return QString("FOOD_STAMP");
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return QString("INVALID");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    operator QString () const {
 | 
					    operator QString () const {
 | 
				
			||||||
        switch(m_permitType) {
 | 
					        switch(m_permitType) {
 | 
				
			||||||
        case PERMIT_TYPE::DAY_TICKET:
 | 
					        case PERMIT_TYPE::DAY_TICKET:
 | 
				
			||||||
@@ -91,6 +121,8 @@ struct PermitType {
 | 
				
			|||||||
            return QString("SZEGED_START");
 | 
					            return QString("SZEGED_START");
 | 
				
			||||||
        case PERMIT_TYPE::SZEGED_STOP:
 | 
					        case PERMIT_TYPE::SZEGED_STOP:
 | 
				
			||||||
            return QString("SZEGED_STOP");
 | 
					            return QString("SZEGED_STOP");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::FOOD_STAMP:
 | 
				
			||||||
 | 
					            return QString("FOOD_STAMP");
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,6 +85,8 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg, PERMIT
 | 
				
			|||||||
        // [[fallthrough]];
 | 
					        // [[fallthrough]];
 | 
				
			||||||
    case PERMIT_TYPE::DAY_TICKET_TEEN:
 | 
					    case PERMIT_TYPE::DAY_TICKET_TEEN:
 | 
				
			||||||
        // [[fallthrough]];
 | 
					        // [[fallthrough]];
 | 
				
			||||||
 | 
					    case PERMIT_TYPE::FOOD_STAMP:
 | 
				
			||||||
 | 
					        // [[fallthrough]];
 | 
				
			||||||
    case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
					    case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
				
			||||||
        std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
 | 
					        std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
 | 
				
			||||||
        if (products) {
 | 
					        if (products) {
 | 
				
			||||||
@@ -92,6 +94,21 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg, PERMIT
 | 
				
			|||||||
            if (product.size() > 0) {
 | 
					            if (product.size() > 0) {
 | 
				
			||||||
                ATBTariffProduct const &p = product[0];
 | 
					                ATBTariffProduct const &p = product[0];
 | 
				
			||||||
                return p.m_tariff_product_price;
 | 
					                return p.m_tariff_product_price;
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					                // in case we do not have prepaid-option
 | 
				
			||||||
 | 
					                QTime const ¤tTime = QDateTime::currentDateTime().time();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (p.m_tariff_product_start <= currentTime && currentTime <= p.m_tariff_product_end) {
 | 
				
			||||||
 | 
					                    return p.m_tariff_product_price;
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "ERROR currentTime"
 | 
				
			||||||
 | 
					                                << currentTime.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "INVALID ("
 | 
				
			||||||
 | 
					                                << p.m_tariff_product_start.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << p.m_tariff_product_end.toString(Qt::ISODate) << ")";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } break;
 | 
					    } break;
 | 
				
			||||||
@@ -117,7 +134,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TY
 | 
				
			|||||||
            if (pv) {
 | 
					            if (pv) {
 | 
				
			||||||
                QVector<ATBPaymentRate> const &paymentRate = pv.value();
 | 
					                QVector<ATBPaymentRate> const &paymentRate = pv.value();
 | 
				
			||||||
                if (paymentRate.size() > 0) {
 | 
					                if (paymentRate.size() > 0) {
 | 
				
			||||||
                    int const price = paymentRate.at(0).pra_price; // price is given per hour
 | 
					                    int const price = paymentRate.last().pra_price; // price is given per hour
 | 
				
			||||||
                    maxPrice = qRound((maxTime * price) / 60.0f);
 | 
					                    maxPrice = qRound((maxTime * price) / 60.0f);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -181,6 +181,13 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
        int durationMinutes = Utilities::getMaximalParkingTime(cfg, paymentMethodId);
 | 
					        int durationMinutes = Utilities::getMaximalParkingTime(cfg, paymentMethodId);
 | 
				
			||||||
        int durationMinutesBrutto = 0;
 | 
					        int durationMinutesBrutto = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef _DEBUG_
 | 
				
			||||||
 | 
					#undef _DEBUG_
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//#define _DEBUG_ 1
 | 
				
			||||||
 | 
					#define _DEBUG_ 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QDateTime current = start;
 | 
					        QDateTime current = start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        int days = 7;
 | 
					        int days = 7;
 | 
				
			||||||
@@ -229,26 +236,61 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
        uint price = 0;
 | 
					        uint price = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (carryOverNotSet) {
 | 
					        if (carryOverNotSet) {
 | 
				
			||||||
            int range = 0;
 | 
					 | 
				
			||||||
            int minsToCarryOver = 0; // from one work-time to the other on the same day
 | 
					            int minsToCarryOver = 0; // from one work-time to the other on the same day
 | 
				
			||||||
            int minsUsed = 0;
 | 
					            int minsUsed = 0;
 | 
				
			||||||
            QDateTime lastCurrent = QDateTime();
 | 
					            QDateTime lastCurrent = QDateTime();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            auto timeRangeIt = cfg->TimeRange.cbegin();
 | 
					            QVector<ATBWeekDaysWorktime> weekDayWorkTimeRanges;
 | 
				
			||||||
            for (; timeRangeIt != cfg->TimeRange.cend(); ++timeRangeIt) {
 | 
					
 | 
				
			||||||
            using WTIterator = std::multimap<int, ATBWeekDaysWorktime>::const_iterator;
 | 
					            using WTIterator = std::multimap<int, ATBWeekDaysWorktime>::const_iterator;
 | 
				
			||||||
            std::pair<WTIterator, WTIterator> p = cfg->WeekDaysWorktime.equal_range(weekdayId);
 | 
					            std::pair<WTIterator, WTIterator> p = cfg->WeekDaysWorktime.equal_range(weekdayId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (WTIterator itr = p.first; itr != p.second; ++itr) {
 | 
					            for (WTIterator itr = p.first; itr != p.second; ++itr) {
 | 
				
			||||||
                    ++range;
 | 
					                weekDayWorkTimeRanges.append(itr->second); // working with vector is easier
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    QTime const &from = Utilities::WeekDaysWorkTimeFrom(itr);
 | 
					            int weekDayWorkTimeIndex = 0;
 | 
				
			||||||
                    QTime const &to = Utilities::WeekDaysWorkTimeUntil(itr);
 | 
					            bool moveToNextTimeRange = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // time ranges for Neuhauser-Kirchdorf (743): 30, 5, 5, ... 5
 | 
				
			||||||
 | 
					            auto timeRangeIt = cfg->TimeRange.cbegin();
 | 
				
			||||||
 | 
					            while (timeRangeIt != cfg->TimeRange.cend()) { // ; ++timeRangeIt) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (weekDayWorkTimeIndex >= weekDayWorkTimeRanges.size()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeRanges.size()" << weekDayWorkTimeRanges.size()
 | 
				
			||||||
 | 
					                                << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					                    end_datetime = current;
 | 
				
			||||||
 | 
					                    return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                QTime const &from = QTime::fromString(weekDayWorkTimeRanges[weekDayWorkTimeIndex].pwd_time_from.c_str(), Qt::ISODate);
 | 
				
			||||||
 | 
					                QTime const &to = QTime::fromString(weekDayWorkTimeRanges[weekDayWorkTimeIndex].pwd_time_to.c_str(), Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                            << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                            << "from" << from.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                            << "to" << to.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                Q_ASSERT_X(from < to, __func__, "MISCONFIGURED WORK-TIMES");
 | 
					                Q_ASSERT_X(from < to, __func__, "MISCONFIGURED WORK-TIMES");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (current.time() >= to) {
 | 
					                if (current.time() >= to) {
 | 
				
			||||||
                        continue; // try to use next available work-time
 | 
					                    ++weekDayWorkTimeIndex;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "try to use next available work-time with"
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                                << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					                    // time range is not affected
 | 
				
			||||||
 | 
					                    continue;
 | 
				
			||||||
                } else
 | 
					                } else
 | 
				
			||||||
                if (current.time() <= from) {
 | 
					                if (current.time() <= from) {
 | 
				
			||||||
                    if (prepaid) {
 | 
					                    if (prepaid) {
 | 
				
			||||||
@@ -258,13 +300,20 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                        uint const minutesMoved = lastCurrent.secsTo(current) / 60;
 | 
					                        uint const minutesMoved = lastCurrent.secsTo(current) / 60;
 | 
				
			||||||
                        durationMinutesBrutto += minutesMoved;
 | 
					                        durationMinutesBrutto += minutesMoved;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if (range == 1) {
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                        qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                    << "lastCurrent" << lastCurrent.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                    << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                    << "minutesMoved" << minutesMoved
 | 
				
			||||||
 | 
					                                    << "durationMinutesBrutto" << durationMinutesBrutto;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (weekDayWorkTimeIndex == 0) {
 | 
				
			||||||
                            start_datetime = current;
 | 
					                            start_datetime = current;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    while (timeRangeIt != cfg->TimeRange.cend()) {
 | 
					 | 
				
			||||||
                ATBTimeRange timeRange = timeRangeIt->second;
 | 
					                ATBTimeRange timeRange = timeRangeIt->second;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                timeRange.computeQTimes(current.time());
 | 
					                timeRange.computeQTimes(current.time());
 | 
				
			||||||
@@ -272,20 +321,64 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                int duration = timeRange.time_range_to_in_minutes_from_start -
 | 
					                int duration = timeRange.time_range_to_in_minutes_from_start -
 | 
				
			||||||
                               timeRange.time_range_from_in_minutes_from_start;
 | 
					                               timeRange.time_range_from_in_minutes_from_start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if (minsUsed > 0) {
 | 
					#if _DEBUG_==1
 | 
				
			||||||
                            duration -= minsUsed;
 | 
					                qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
                            minsUsed = 0;
 | 
					                            << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                            << "duration" << duration
 | 
				
			||||||
 | 
					                            << "minsUsed" << minsUsed
 | 
				
			||||||
 | 
					                            << "minsToCarryOver" << minsToCarryOver
 | 
				
			||||||
 | 
					                            << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                            << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (minsToCarryOver > 0) {  // the price for this time range
 | 
				
			||||||
 | 
					                                            // has been is paid already
 | 
				
			||||||
 | 
					                    Q_ASSERT_X(weekDayWorkTimeIndex > 0, __func__, "WRONG-WORK-TIME");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    current = current.addSecs(minsToCarryOver*60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    durationMinutes -= minsToCarryOver;
 | 
				
			||||||
 | 
					                    durationMinutesNetto += minsToCarryOver;
 | 
				
			||||||
 | 
					                    durationMinutesBrutto += minsToCarryOver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    minsToCarryOver = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "durationMinutes" << durationMinutes
 | 
				
			||||||
 | 
					                                << "durationMinutesNetto" << durationMinutesNetto
 | 
				
			||||||
 | 
					                                << "durationMinutesBrutto" << durationMinutesBrutto
 | 
				
			||||||
 | 
					                                << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					                    if (price >= cost) {
 | 
				
			||||||
 | 
					                        end_datetime = current;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                        qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                    << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                    << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					                        return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (current.addSecs(duration * 60).time() <= to) {
 | 
					                if (current.addSecs(duration * 60).time() <= to) {
 | 
				
			||||||
                            if (minsToCarryOver > 0) {  // the price for this time range
 | 
					
 | 
				
			||||||
                                                        // has been is paid already
 | 
					#if _DEBUG_==1
 | 
				
			||||||
                                durationMinutes -= duration;
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
                                durationMinutesNetto += duration;
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
                                durationMinutesBrutto += duration;
 | 
					                                << "current.addSecs(" << duration * 60 << ")" << current.addSecs(duration*60).time().toString(Qt::ISODate)
 | 
				
			||||||
                                current = current.addSecs(duration*60);
 | 
					                                << "duration" << duration
 | 
				
			||||||
                                minsToCarryOver = 0;
 | 
					                                << "to" << to.toString(Qt::ISODate)
 | 
				
			||||||
                            } else {
 | 
					                                << "minsUsed" << minsUsed
 | 
				
			||||||
 | 
					                                << "minsToCarryOver" << minsToCarryOver
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                                << "durationMinutes" << durationMinutes;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    moveToNextTimeRange = false;
 | 
				
			||||||
                    for(const auto &x: cfg->PaymentRate) {
 | 
					                    for(const auto &x: cfg->PaymentRate) {
 | 
				
			||||||
                        ATBPaymentRate const rate = x.second;
 | 
					                        ATBPaymentRate const rate = x.second;
 | 
				
			||||||
                        if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
 | 
					                        if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
 | 
				
			||||||
@@ -303,37 +396,106 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                            if (price >= cost) {
 | 
					                            if (price >= cost) {
 | 
				
			||||||
                                end_datetime = current;
 | 
					                                end_datetime = current;
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                        qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                    << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                    << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
                                return end_datetime.toString(Qt::ISODate).toStdString();
 | 
					                                return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            // price has been updated; use next time range
 | 
				
			||||||
 | 
					                            moveToNextTimeRange = true;
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if (durationMinutes <= 0) {
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "to" << to.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "price" << price
 | 
				
			||||||
 | 
					                                << "minsToCarryOver" << minsToCarryOver
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                                << "durationMinutes" << durationMinutes
 | 
				
			||||||
 | 
					                                << "durationMinutesNetto" << durationMinutesNetto
 | 
				
			||||||
 | 
					                                << "durationMinutesBrutto" << durationMinutesBrutto;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (price >= cost) {
 | 
				
			||||||
                        end_datetime = current;
 | 
					                        end_datetime = current;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                        qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                    << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                    << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        return end_datetime.toString(Qt::ISODate).toStdString();
 | 
					                        return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            ++timeRangeIt;
 | 
					                    if (moveToNextTimeRange) {
 | 
				
			||||||
 | 
					                        if (++timeRangeIt != cfg->TimeRange.cend()) {
 | 
				
			||||||
 | 
					                            continue;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        } else {
 | 
					                    // havin a new time range means that we always have a new
 | 
				
			||||||
 | 
					                    // work-time-range
 | 
				
			||||||
 | 
					                    // ++timeRangeIt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                } else { // current.addSecs(duration * 60).time() > to
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "current.addSecs(" << duration * 60 << ")" << current.addSecs(duration*60).time().toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << ", to:" << to.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    lastCurrent = current;
 | 
					                    lastCurrent = current;
 | 
				
			||||||
                    current.setTime(to);
 | 
					                    current.setTime(to);
 | 
				
			||||||
                    minsUsed = lastCurrent.secsTo(current) / 60;
 | 
					                    minsUsed = lastCurrent.secsTo(current) / 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "lastCurrent" << lastCurrent.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "to" << to.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "minsUsed" << minsUsed
 | 
				
			||||||
 | 
					                                << "minsToCarryOver" << minsToCarryOver
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                                << "durationMinutes" << durationMinutes;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // mod duration: possibly discard some minutes in
 | 
					                    // mod duration: possibly discard some minutes in
 | 
				
			||||||
                    // the next time-range
 | 
					                    // the next time-range
 | 
				
			||||||
                            if (durationMinutes >= minsUsed) {
 | 
					                    if (duration >= minsUsed) {
 | 
				
			||||||
                                minsToCarryOver = durationMinutes - minsUsed;
 | 
					                        minsToCarryOver = duration - minsUsed;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    durationMinutes -= minsUsed;
 | 
					                    durationMinutes -= minsUsed;
 | 
				
			||||||
                    durationMinutesNetto += minsUsed;
 | 
					                    durationMinutesNetto += minsUsed;
 | 
				
			||||||
                    durationMinutesBrutto += minsUsed;
 | 
					                    durationMinutesBrutto += minsUsed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "lastCurrent" << lastCurrent.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "to" << to.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "minsUsed" << minsUsed
 | 
				
			||||||
 | 
					                                << "minsToCarryOver" << minsToCarryOver
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                                << "durationMinutes" << durationMinutes
 | 
				
			||||||
 | 
					                                << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    moveToNextTimeRange = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (minsUsed > 0) {
 | 
					                    if (minsUsed > 0) {
 | 
				
			||||||
                        for(const auto &x: cfg->PaymentRate) {
 | 
					                        for(const auto &x: cfg->PaymentRate) {
 | 
				
			||||||
                            ATBPaymentRate const rate = x.second;
 | 
					                            ATBPaymentRate const rate = x.second;
 | 
				
			||||||
@@ -346,22 +508,68 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                                if (price >= cost) {
 | 
					                                if (price >= cost) {
 | 
				
			||||||
                                    end_datetime = current;
 | 
					                                    end_datetime = current;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                                << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                                << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                    // return end_datetime.toString(Qt::ISODate).toStdString();
 | 
					                                    // return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                                        break;
 | 
					
 | 
				
			||||||
                                    }
 | 
					                                // price has been updated; use next time range
 | 
				
			||||||
                                }
 | 
					                                moveToNextTimeRange = true;
 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                                break;
 | 
					                                break;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                end_datetime = start.addSecs(durationMinutesBrutto * 60);
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "minsUsed" << minsUsed
 | 
				
			||||||
 | 
					                                << "durationMinutes" << durationMinutes
 | 
				
			||||||
 | 
					                                << "moveToNextTimeRange" << moveToNextTimeRange
 | 
				
			||||||
 | 
					                                << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (moveToNextTimeRange) {
 | 
				
			||||||
 | 
					                        if (++timeRangeIt != cfg->TimeRange.cend()) {
 | 
				
			||||||
 | 
					                            continue;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        // no valid time range left
 | 
				
			||||||
 | 
					                        end_datetime = current;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                        qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                    << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                    << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        return end_datetime.toString(Qt::ISODate).toStdString();
 | 
					                        return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                end_datetime = start.addSecs(durationMinutesBrutto * 60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                            << "start" << start.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                            << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                            << "final price" << std::max(price, minParkingPrice);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
 | 
					            } // while (timeRangeIt != cfg->TimeRange.cend()) {
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                            << "INVALID END TIME";
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
        end_datetime = QDateTime();
 | 
					        end_datetime = QDateTime();
 | 
				
			||||||
        return end_datetime.toString(Qt::ISODate).toStdString();
 | 
					        return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -373,6 +581,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
    // TODO: im fehlerfall
 | 
					    // TODO: im fehlerfall
 | 
				
			||||||
    return t.getValidUntil().toString(Qt::ISODate).toStdString();
 | 
					    return t.getValidUntil().toString(Qt::ISODate).toStdString();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					#undef _DEBUG_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
///////////////////////////////////////
 | 
					///////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -522,6 +731,13 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
 | 
				
			|||||||
        int weekdayIdLast = -1;
 | 
					        int weekdayIdLast = -1;
 | 
				
			||||||
        int durationMinutesBrutto = 0;
 | 
					        int durationMinutesBrutto = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef _DEBUG_
 | 
				
			||||||
 | 
					#undef _DEBUG_
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//#define _DEBUG_ 1
 | 
				
			||||||
 | 
					#define _DEBUG_ 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QDateTime current = start;
 | 
					        QDateTime current = start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        int days = 7;
 | 
					        int days = 7;
 | 
				
			||||||
@@ -571,26 +787,60 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
 | 
				
			|||||||
        uint price = 0;
 | 
					        uint price = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (carryOverNotSet) {
 | 
					        if (carryOverNotSet) {
 | 
				
			||||||
            int range = 0;
 | 
					 | 
				
			||||||
            int minsToCarryOver = 0; // from one work-time to the other on the same day
 | 
					            int minsToCarryOver = 0; // from one work-time to the other on the same day
 | 
				
			||||||
            int minsUsed = 0;
 | 
					            int minsUsed = 0;
 | 
				
			||||||
            QDateTime lastCurrent = QDateTime();
 | 
					            QDateTime lastCurrent = QDateTime();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            auto timeRangeIt = cfg->TimeRange.cbegin();
 | 
					            QVector<ATBWeekDaysWorktime> weekDayWorkTimeRanges;
 | 
				
			||||||
            for (; timeRangeIt != cfg->TimeRange.cend(); ++timeRangeIt) {
 | 
					
 | 
				
			||||||
            using WTIterator = std::multimap<int, ATBWeekDaysWorktime>::const_iterator;
 | 
					            using WTIterator = std::multimap<int, ATBWeekDaysWorktime>::const_iterator;
 | 
				
			||||||
            std::pair<WTIterator, WTIterator> p = cfg->WeekDaysWorktime.equal_range(weekdayId);
 | 
					            std::pair<WTIterator, WTIterator> p = cfg->WeekDaysWorktime.equal_range(weekdayId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (WTIterator itr = p.first; itr != p.second; ++itr) {
 | 
					            for (WTIterator itr = p.first; itr != p.second; ++itr) {
 | 
				
			||||||
                    ++range;
 | 
					                weekDayWorkTimeRanges.append(itr->second); // working with vector is easier
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    QTime const &from = Utilities::WeekDaysWorkTimeFrom(itr);
 | 
					            int weekDayWorkTimeIndex = 0;
 | 
				
			||||||
                    QTime const &to = Utilities::WeekDaysWorkTimeUntil(itr);
 | 
					            bool moveToNextTimeRange = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // time ranges for Neuhauser-Kirchdorf (743): 30, 5, 5, ... 5
 | 
				
			||||||
 | 
					            auto timeRangeIt = cfg->TimeRange.cbegin();
 | 
				
			||||||
 | 
					            while (timeRangeIt != cfg->TimeRange.cend()) { // ; ++timeRangeIt) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (weekDayWorkTimeIndex >= weekDayWorkTimeRanges.size()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeRanges.size()" << weekDayWorkTimeRanges.size();
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					                    end_datetime = current;
 | 
				
			||||||
 | 
					                    return price;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                QTime const &from = QTime::fromString(weekDayWorkTimeRanges[weekDayWorkTimeIndex].pwd_time_from.c_str(), Qt::ISODate);
 | 
				
			||||||
 | 
					                QTime const &to = QTime::fromString(weekDayWorkTimeRanges[weekDayWorkTimeIndex].pwd_time_to.c_str(), Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                            << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                            << "from" << from.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                            << "to" << to.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                Q_ASSERT_X(from < to, __func__, "MISCONFIGURED WORK-TIMES");
 | 
					                Q_ASSERT_X(from < to, __func__, "MISCONFIGURED WORK-TIMES");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (current.time() >= to) {
 | 
					                if (current.time() >= to) {
 | 
				
			||||||
                        continue; // try to use next available work-time
 | 
					                    ++weekDayWorkTimeIndex;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "try to use next available work-time with"
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                                << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					                    // time range is not affected
 | 
				
			||||||
 | 
					                    continue;
 | 
				
			||||||
                } else
 | 
					                } else
 | 
				
			||||||
                if (current.time() <= from) {
 | 
					                if (current.time() <= from) {
 | 
				
			||||||
                    if (prepaid) {
 | 
					                    if (prepaid) {
 | 
				
			||||||
@@ -600,13 +850,20 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
 | 
				
			|||||||
                        uint const minutesMoved = lastCurrent.secsTo(current) / 60;
 | 
					                        uint const minutesMoved = lastCurrent.secsTo(current) / 60;
 | 
				
			||||||
                        durationMinutesBrutto += minutesMoved;
 | 
					                        durationMinutesBrutto += minutesMoved;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if (range == 1) {
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                        qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                    << "lastCurrent" << lastCurrent.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                    << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                    << "minutesMoved" << minutesMoved
 | 
				
			||||||
 | 
					                                    << "durationMinutesBrutto" << durationMinutesBrutto;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (weekDayWorkTimeIndex == 0) {
 | 
				
			||||||
                            start_datetime = current;
 | 
					                            start_datetime = current;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    while (timeRangeIt != cfg->TimeRange.cend()) {
 | 
					 | 
				
			||||||
                ATBTimeRange timeRange = timeRangeIt->second;
 | 
					                ATBTimeRange timeRange = timeRangeIt->second;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                timeRange.computeQTimes(current.time());
 | 
					                timeRange.computeQTimes(current.time());
 | 
				
			||||||
@@ -614,49 +871,64 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
 | 
				
			|||||||
                int duration = timeRange.time_range_to_in_minutes_from_start -
 | 
					                int duration = timeRange.time_range_to_in_minutes_from_start -
 | 
				
			||||||
                               timeRange.time_range_from_in_minutes_from_start;
 | 
					                               timeRange.time_range_from_in_minutes_from_start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        qCritical() << __func__ << ":" << __LINE__
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
                            << "current" << current.toString(Qt::ISODate)
 | 
					                            << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
                            << "duration" << duration
 | 
					                            << "duration" << duration
 | 
				
			||||||
                            << "minsUsed" << minsUsed
 | 
					                            << "minsUsed" << minsUsed
 | 
				
			||||||
                                    << "minsToCarryOver" << minsToCarryOver;
 | 
					                            << "minsToCarryOver" << minsToCarryOver
 | 
				
			||||||
 | 
					                            << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                            << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
                        //if (minsUsed > 0) {
 | 
					 | 
				
			||||||
                        //    duration -= minsUsed;
 | 
					 | 
				
			||||||
                        //    minsUsed = 0;
 | 
					 | 
				
			||||||
                        //}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (current.addSecs(duration * 60).time() <= to) {
 | 
					 | 
				
			||||||
                if (minsToCarryOver > 0) {  // the price for this time range
 | 
					                if (minsToCarryOver > 0) {  // the price for this time range
 | 
				
			||||||
                                            // has been is paid already
 | 
					                                            // has been is paid already
 | 
				
			||||||
                                if (minsUsed == 0) {
 | 
					                    Q_ASSERT_X(weekDayWorkTimeIndex > 0, __func__, "WRONG-WORK-TIME");
 | 
				
			||||||
                                    for(const auto &x: cfg->PaymentRate) {
 | 
					 | 
				
			||||||
                                        ATBPaymentRate const rate = x.second;
 | 
					 | 
				
			||||||
                                        if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
 | 
					 | 
				
			||||||
                                            price += (uint)rate.pra_price;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                            durationMinutes -= duration;
 | 
					                    current = current.addSecs(minsToCarryOver*60);
 | 
				
			||||||
                                            durationMinutesNetto += duration;
 | 
					 | 
				
			||||||
                                            durationMinutesBrutto += duration;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                            current = current.addSecs(duration * 60);
 | 
					                    durationMinutes -= minsToCarryOver;
 | 
				
			||||||
 | 
					                    durationMinutesNetto += minsToCarryOver;
 | 
				
			||||||
 | 
					                    durationMinutesBrutto += minsToCarryOver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                            if (durationMinutes <= 0) {
 | 
					 | 
				
			||||||
                                                end_datetime = current;
 | 
					 | 
				
			||||||
                                                return price;
 | 
					 | 
				
			||||||
                                            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                            break;
 | 
					 | 
				
			||||||
                                        }
 | 
					 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
                                } else {
 | 
					 | 
				
			||||||
                                    durationMinutes -= duration;
 | 
					 | 
				
			||||||
                                    durationMinutesNetto += duration;
 | 
					 | 
				
			||||||
                                    durationMinutesBrutto += duration;
 | 
					 | 
				
			||||||
                                    current = current.addSecs(duration*60);
 | 
					 | 
				
			||||||
                    minsToCarryOver = 0;
 | 
					                    minsToCarryOver = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "durationMinutes" << durationMinutes
 | 
				
			||||||
 | 
					                                << "durationMinutesNetto" << durationMinutesNetto
 | 
				
			||||||
 | 
					                                << "durationMinutesBrutto" << durationMinutesBrutto;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					                    if (durationMinutes <= 0) {
 | 
				
			||||||
 | 
					                        end_datetime = current;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                        qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                    << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                    << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        return price;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                            } else {
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (current.addSecs(duration * 60).time() <= to) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "current.addSecs(" << duration * 60 << ")" << current.addSecs(duration*60).time().toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "to" << to.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "minsUsed" << minsUsed
 | 
				
			||||||
 | 
					                                << "minsToCarryOver" << minsToCarryOver
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                                << "durationMinutes" << durationMinutes;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    moveToNextTimeRange = false;
 | 
				
			||||||
                    for(const auto &x: cfg->PaymentRate) {
 | 
					                    for(const auto &x: cfg->PaymentRate) {
 | 
				
			||||||
                        ATBPaymentRate const rate = x.second;
 | 
					                        ATBPaymentRate const rate = x.second;
 | 
				
			||||||
                        if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
 | 
					                        if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
 | 
				
			||||||
@@ -667,53 +939,157 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
 | 
				
			|||||||
                            durationMinutesBrutto += duration;
 | 
					                            durationMinutesBrutto += duration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            current = current.addSecs(duration * 60);
 | 
					                            current = current.addSecs(duration * 60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            // price has been updated; use next time range
 | 
				
			||||||
 | 
					                            moveToNextTimeRange = true;
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                            }
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "to" << to.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "price" << price
 | 
				
			||||||
 | 
					                                << "minsToCarryOver" << minsToCarryOver
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                                << "durationMinutes" << durationMinutes
 | 
				
			||||||
 | 
					                                << "durationMinutesNetto" << durationMinutesNetto
 | 
				
			||||||
 | 
					                                << "durationMinutesBrutto" << durationMinutesBrutto;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (durationMinutes <= 0) {
 | 
					                    if (durationMinutes <= 0) {
 | 
				
			||||||
                        end_datetime = current;
 | 
					                        end_datetime = current;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        return price;
 | 
					                        return price;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            ++timeRangeIt;
 | 
					                    if (moveToNextTimeRange) {
 | 
				
			||||||
 | 
					                        if (++timeRangeIt != cfg->TimeRange.cend()) {
 | 
				
			||||||
 | 
					                            continue;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        } else {
 | 
					                    // havin a new time range means that we always have a new
 | 
				
			||||||
 | 
					                    // work-time-range
 | 
				
			||||||
 | 
					                    // ++timeRangeIt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                } else { // current.addSecs(duration * 60).time() > to
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "current.addSecs(" << duration * 60 << ")" << current.addSecs(duration*60).time().toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << ", to:" << to.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    lastCurrent = current;
 | 
					                    lastCurrent = current;
 | 
				
			||||||
                    current.setTime(to);
 | 
					                    current.setTime(to);
 | 
				
			||||||
                    minsUsed = lastCurrent.secsTo(current) / 60;
 | 
					                    minsUsed = lastCurrent.secsTo(current) / 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "lastCurrent" << lastCurrent.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "to" << to.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "minsUsed" << minsUsed
 | 
				
			||||||
 | 
					                                << "minsToCarryOver" << minsToCarryOver
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                                << "durationMinutes" << durationMinutes;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // mod duration: possibly discard some minutes in
 | 
					                    // mod duration: possibly discard some minutes in
 | 
				
			||||||
                    // the next time-range
 | 
					                    // the next time-range
 | 
				
			||||||
                            if (durationMinutes >= minsUsed) {
 | 
					                    if (duration >= minsUsed) {
 | 
				
			||||||
                                minsToCarryOver = durationMinutes - minsUsed;
 | 
					                        minsToCarryOver = duration - minsUsed;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    durationMinutes -= minsUsed;
 | 
					                    durationMinutes -= minsUsed;
 | 
				
			||||||
                    durationMinutesNetto += minsUsed;
 | 
					                    durationMinutesNetto += minsUsed;
 | 
				
			||||||
                    durationMinutesBrutto += minsUsed;
 | 
					                    durationMinutesBrutto += minsUsed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "lastCurrent" << lastCurrent.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "to" << to.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "minsUsed" << minsUsed
 | 
				
			||||||
 | 
					                                << "minsToCarryOver" << minsToCarryOver
 | 
				
			||||||
 | 
					                                << "weekDayWorkTimeIndex" << weekDayWorkTimeIndex
 | 
				
			||||||
 | 
					                                << "durationMinutes" << durationMinutes
 | 
				
			||||||
 | 
					                                << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    moveToNextTimeRange = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (minsUsed > 0) {
 | 
					                    if (minsUsed > 0) {
 | 
				
			||||||
                        for(const auto &x: cfg->PaymentRate) {
 | 
					                        for(const auto &x: cfg->PaymentRate) {
 | 
				
			||||||
                            ATBPaymentRate const rate = x.second;
 | 
					                            ATBPaymentRate const rate = x.second;
 | 
				
			||||||
                            if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
 | 
					                            if (rate.pra_payment_unit_id == timeRange.time_range_payment_type_id) {
 | 
				
			||||||
                                price += (uint)rate.pra_price;
 | 
					                                price += (uint)rate.pra_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                // price has been updated; use next time range
 | 
				
			||||||
 | 
					                                moveToNextTimeRange = true;
 | 
				
			||||||
                                break;
 | 
					                                break;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                            break;
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "current" << current.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "minsUsed" << minsUsed
 | 
				
			||||||
 | 
					                                << "durationMinutes" << durationMinutes
 | 
				
			||||||
 | 
					                                << "moveToNextTimeRange" << moveToNextTimeRange
 | 
				
			||||||
 | 
					                                << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (moveToNextTimeRange) {
 | 
				
			||||||
 | 
					                        if (++timeRangeIt != cfg->TimeRange.cend()) {
 | 
				
			||||||
 | 
					                            continue;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        // no valid time range left
 | 
				
			||||||
 | 
					                        end_datetime = current;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                        qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                    << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                    << "price" << price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        return price;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                end_datetime = start.addSecs(durationMinutesBrutto * 60);
 | 
					                end_datetime = start.addSecs(durationMinutesBrutto * 60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                            << "start" << start.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                            << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                            << "final price" << std::max(price, minParkingPrice);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return std::max(price, minParkingPrice);
 | 
					                return std::max(price, minParkingPrice);
 | 
				
			||||||
            }
 | 
					            } // while (timeRangeIt != cfg->TimeRange.cend()) {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if _DEBUG_==1
 | 
				
			||||||
 | 
					                qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                            << "INVALID END TIME";
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
        end_datetime = QDateTime();
 | 
					        end_datetime = QDateTime();
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -1360,6 +1736,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::FOOD_STAMP: {
 | 
				
			||||||
 | 
					                    // TODO
 | 
				
			||||||
 | 
					                } break;
 | 
				
			||||||
                case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
					                case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
				
			||||||
                    std::optional<ATBCustomer> c = cfg->getCustomerForType(ATBCustomer::CustomerType::ADULT);
 | 
					                    std::optional<ATBCustomer> c = cfg->getCustomerForType(ATBCustomer::CustomerType::ADULT);
 | 
				
			||||||
                    if (c) {
 | 
					                    if (c) {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										243
									
								
								main/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										243
									
								
								main/main.cpp
									
									
									
									
									
								
							@@ -34,13 +34,13 @@ extern "C" char* strptime(const char* s,
 | 
				
			|||||||
#include "calculator_functions.h"
 | 
					#include "calculator_functions.h"
 | 
				
			||||||
#include "calculate_price.h"
 | 
					#include "calculate_price.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SZEGED                                  (1)
 | 
					#define SZEGED                                  (0)
 | 
				
			||||||
#define SCHOENAU_KOENIGSEE                      (0)
 | 
					#define SCHOENAU_KOENIGSEE                      (0)
 | 
				
			||||||
#define NEUHAUSER_KORNEUBURG                    (0)
 | 
					#define NEUHAUSER_KORNEUBURG                    (0)
 | 
				
			||||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU        (0)
 | 
					#define NEUHAUSER_LINSINGER_MASCHINENBAU        (0)
 | 
				
			||||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
 | 
					#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (1)
 | 
				
			||||||
#define NEUHAUSER_BILEXA_GALTUER                (0)
 | 
					#define NEUHAUSER_BILEXA_GALTUER                (0)
 | 
				
			||||||
#define NEUHAUSER_KIRCHDORF                     (1)
 | 
					#define NEUHAUSER_KIRCHDORF                     (0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if NEUHAUSER_KIRCHDORF==1
 | 
					#if NEUHAUSER_KIRCHDORF==1
 | 
				
			||||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
 | 
					static bool test_neuhauser_kirchdorf(int step, double cost) {
 | 
				
			||||||
@@ -269,13 +269,20 @@ int main() {
 | 
				
			|||||||
            QList<int>::const_iterator step;
 | 
					            QList<int>::const_iterator step;
 | 
				
			||||||
            for (step = steps.cbegin(); step != steps.cend(); ++step) {
 | 
					            for (step = steps.cbegin(); step != steps.cend(); ++step) {
 | 
				
			||||||
                qCritical() << QString("*** NEXT STEP: %1 ***").arg(*step);
 | 
					                qCritical() << QString("*** NEXT STEP: %1 ***").arg(*step);
 | 
				
			||||||
                //for (int offset = 7*60; offset < 18*60; ++offset) {
 | 
					                //for (int offset = 691; offset < 692; ++offset) {
 | 
				
			||||||
                for (int offset = 690; offset < 691; ++offset) {
 | 
					                for (int offset = 480; offset < 1080; ++offset) {
 | 
				
			||||||
 | 
					                //for (int offset = 7*60; offset < (18*60)-90; ++offset) {
 | 
				
			||||||
 | 
					                //for (int offset = (18*60)-90; offset < 18*60; ++offset) {
 | 
				
			||||||
 | 
					                //for (int offset = 1046; offset < 1047; ++offset) {
 | 
				
			||||||
                    QDateTime start = s.addSecs(offset * 60);
 | 
					                    QDateTime start = s.addSecs(offset * 60);
 | 
				
			||||||
                    QDateTime const firstStart = start;
 | 
					                    QDateTime const firstStart = start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //if (*step != 30) continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    double cost = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (compute_price_for_parking_ticket(&cfg, start, *step, end, &price)) {
 | 
					                    if (compute_price_for_parking_ticket(&cfg, start, *step, end, &price)) {
 | 
				
			||||||
                        double cost = price.netto;
 | 
					                        cost = price.netto;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        qCritical() << "****" << offset << *step << "****";
 | 
					                        qCritical() << "****" << offset << *step << "****";
 | 
				
			||||||
                        qCritical() << "    firstStart :" << firstStart.toString(Qt::ISODate);
 | 
					                        qCritical() << "    firstStart :" << firstStart.toString(Qt::ISODate);
 | 
				
			||||||
@@ -284,66 +291,132 @@ int main() {
 | 
				
			|||||||
                        qCritical() << "    cost       :" << cost;
 | 
					                        qCritical() << "    cost       :" << cost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if (offset < 8*60) {    // [7:00 - 8:00[
 | 
					                        if (offset < 8*60) {    // [7:00 - 8:00[
 | 
				
			||||||
                            if (!test_neuhauser_kirchdorf(*step, cost)) {
 | 
					                            double new_cost = cost;
 | 
				
			||||||
 | 
					                            if (offset > (18*60)-(*step)) {
 | 
				
			||||||
 | 
					                                new_cost += ((*step-30)/5)*10;
 | 
				
			||||||
 | 
					                                qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (!test_neuhauser_kirchdorf(*step, new_cost)) {
 | 
				
			||||||
                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
					                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
				
			||||||
                                return -1;
 | 
					                                //return -1;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (offset < 9*60) {    // [8:00 - 9:00[
 | 
					                        if (offset < 9*60) {    // [8:00 - 9:00[
 | 
				
			||||||
                            if (!test_neuhauser_kirchdorf(*step, cost)) {
 | 
					                            double new_cost = cost;
 | 
				
			||||||
 | 
					                            if (offset > (18*60)-(*step)) {
 | 
				
			||||||
 | 
					                                new_cost += ((*step-30)/5)*10;
 | 
				
			||||||
 | 
					                                qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (!test_neuhauser_kirchdorf(*step, new_cost)) {
 | 
				
			||||||
                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
					                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
				
			||||||
                                return -1;
 | 
					                                //return -1;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (offset < 10*60) {
 | 
					                        if (offset < 10*60) {
 | 
				
			||||||
                            if (!test_neuhauser_kirchdorf(*step, cost)) {
 | 
					                            double new_cost = cost;
 | 
				
			||||||
 | 
					                            if (offset > (18*60)-(*step)) {
 | 
				
			||||||
 | 
					                                new_cost += ((*step-30)/5)*10;
 | 
				
			||||||
 | 
					                                qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (!test_neuhauser_kirchdorf(*step, new_cost)) {
 | 
				
			||||||
                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
					                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
				
			||||||
                                return -1;
 | 
					                                //return -1;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (offset < 11*60) {
 | 
					                        if (offset < 11*60) {
 | 
				
			||||||
                            if (!test_neuhauser_kirchdorf(*step, cost)) {
 | 
					                            double new_cost = cost;
 | 
				
			||||||
 | 
					                            if (offset > (18*60)-(*step)) {
 | 
				
			||||||
 | 
					                                new_cost += ((*step-30)/5)*10;
 | 
				
			||||||
 | 
					                                qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (!test_neuhauser_kirchdorf(*step, new_cost)) {
 | 
				
			||||||
                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
					                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
				
			||||||
                                return -1;
 | 
					                                //return -1;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (offset < 12*60) {
 | 
					                        if (offset < 12*60) {
 | 
				
			||||||
                            if (!test_neuhauser_kirchdorf(*step, cost)) {
 | 
					                            double new_cost = cost;
 | 
				
			||||||
 | 
					                            if (offset > (18*60)-(*step)) {
 | 
				
			||||||
 | 
					                                new_cost += ((*step-30)/5)*10;
 | 
				
			||||||
 | 
					                                qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (!test_neuhauser_kirchdorf(*step, new_cost)) {
 | 
				
			||||||
                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
					                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
				
			||||||
                                return -1;
 | 
					                                //return -1;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (offset < 13*60) {
 | 
					                        if (offset < 13*60) {
 | 
				
			||||||
                            if (!test_neuhauser_kirchdorf(*step, cost)) {
 | 
					                            double new_cost = cost;
 | 
				
			||||||
 | 
					                            if (offset > (18*60)-(*step)) {
 | 
				
			||||||
 | 
					                                new_cost += ((*step-30)/5)*10;
 | 
				
			||||||
 | 
					                                qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (!test_neuhauser_kirchdorf(*step, new_cost)) {
 | 
				
			||||||
                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
					                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
				
			||||||
                                return -1;
 | 
					                                //return -1;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (offset < 14*60) {
 | 
					                        if (offset < 14*60) {
 | 
				
			||||||
                            if (!test_neuhauser_kirchdorf(*step, cost)) {
 | 
					                            double new_cost = cost;
 | 
				
			||||||
 | 
					                            if (offset > (18*60)-(*step)) {
 | 
				
			||||||
 | 
					                                new_cost += ((*step-30)/5)*10;
 | 
				
			||||||
 | 
					                                qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (!test_neuhauser_kirchdorf(*step, new_cost)) {
 | 
				
			||||||
                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
					                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
				
			||||||
                                return -1;
 | 
					                                //return -1;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (offset < 15*60) {
 | 
					                        if (offset < 15*60) {
 | 
				
			||||||
                            if (!test_neuhauser_kirchdorf(*step, cost)) {
 | 
					                            double new_cost = cost;
 | 
				
			||||||
 | 
					                            if (offset > (18*60)-(*step)) {
 | 
				
			||||||
 | 
					                                new_cost += ((*step-30)/5)*10;
 | 
				
			||||||
 | 
					                                qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (!test_neuhauser_kirchdorf(*step, new_cost)) {
 | 
				
			||||||
                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
					                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
				
			||||||
                                return -1;
 | 
					                                //return -1;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (offset < 16*60) {
 | 
					                        if (offset < 16*60) {
 | 
				
			||||||
                            if (!test_neuhauser_kirchdorf(*step, cost)) {
 | 
					                            double new_cost = cost;
 | 
				
			||||||
 | 
					                            if (offset > (18*60)-(*step)) {
 | 
				
			||||||
 | 
					                                new_cost += ((*step-30)/5)*10;
 | 
				
			||||||
 | 
					                                qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (!test_neuhauser_kirchdorf(*step, new_cost)) {
 | 
				
			||||||
                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
					                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
				
			||||||
                                return -1;
 | 
					                                //return -1;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (offset < 17*60) {
 | 
					                        if (offset < 17*60) {
 | 
				
			||||||
                            if (!test_neuhauser_kirchdorf(*step, cost)) {
 | 
					                            double new_cost = cost;
 | 
				
			||||||
 | 
					                            if (offset > (18*60)-(*step)) {
 | 
				
			||||||
 | 
					                                double const f = ((*step-30)/5)*10;
 | 
				
			||||||
 | 
					                                new_cost += f;
 | 
				
			||||||
 | 
					                                new_cost = std::min(new_cost, f+30);
 | 
				
			||||||
 | 
					                                qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (!test_neuhauser_kirchdorf(*step, new_cost)) {
 | 
				
			||||||
                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
					                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
				
			||||||
                                return -1;
 | 
					                                //return -1;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        } else
 | 
				
			||||||
 | 
					                        if (offset < 18*60) {
 | 
				
			||||||
 | 
					                            double new_cost = cost;
 | 
				
			||||||
 | 
					                            if (offset > (18*60)-(*step)) {
 | 
				
			||||||
 | 
					                                double const f = ((*step-30)/5)*10;
 | 
				
			||||||
 | 
					                                new_cost += f;
 | 
				
			||||||
 | 
					                                new_cost = std::min(new_cost, f+30);
 | 
				
			||||||
 | 
					                                qCritical() << __LINE__ << "new_cost" << new_cost << "(cost" << cost << ")";
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (!test_neuhauser_kirchdorf(*step, new_cost)) {
 | 
				
			||||||
 | 
					                                qCritical() << "ERROR AT OFFSET" << offset;
 | 
				
			||||||
 | 
					                            //    return -1;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else {
 | 
					                        } else {
 | 
				
			||||||
                            qCritical() << "WARN OFFSET TOO HIGH" << offset;
 | 
					                            qCritical() << "ERROR OFFSET TOO HIGH" << offset;
 | 
				
			||||||
 | 
					                            return -1;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
@@ -354,6 +427,17 @@ int main() {
 | 
				
			|||||||
                        return -1;
 | 
					                        return -1;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    QDateTime end2 = QDateTime();
 | 
				
			||||||
 | 
					                    if (compute_duration_for_parking_ticket(&cfg, start, cost, end2)) {      // return value
 | 
				
			||||||
 | 
					                        qCritical() << "start" << start.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                    << "offset" << offset
 | 
				
			||||||
 | 
					                                    << "cost" << cost
 | 
				
			||||||
 | 
					                                    << "end" << end2.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                        if (end != end2) {
 | 
				
			||||||
 | 
					                            qCritical() << end.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                        << end2.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -485,15 +569,16 @@ int main() {
 | 
				
			|||||||
        int Up = 1;
 | 
					        int Up = 1;
 | 
				
			||||||
        //compute_next_timestep(&cfg, )
 | 
					        //compute_next_timestep(&cfg, )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        QDateTime const start = QDateTime::currentDateTime();
 | 
				
			||||||
        for (int i=0; i<timeSteps.size(); ++i) {
 | 
					        for (int i=0; i<timeSteps.size(); ++i) {
 | 
				
			||||||
            int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
 | 
					            int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
 | 
				
			||||||
            qCritical() << "nextTimeStep" << nextTimeStep;
 | 
					            qCritical() << "nextTimeStep" << nextTimeStep;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//            uint32_t price = calculator.GetPriceForTimeStep(&cfg, timeSteps.at(i));
 | 
					            uint32_t price = Calculator::GetInstance().GetPriceForTimeStep(&cfg, timeSteps.at(i));
 | 
				
			||||||
//            uint32_t duration = calculator.GetDurationForPrice(&cfg, price);
 | 
					            uint32_t duration = Calculator::GetInstance().GetDurationForPrice(&cfg, price);
 | 
				
			||||||
//            qCritical() << "nextTimeStep relative to start:"
 | 
					            qCritical() << "nextTimeStep relative to start:"
 | 
				
			||||||
//                        << duration << start.addSecs(duration * 60)
 | 
					                        << duration << start.addSecs(duration * 60).toString(Qt::ISODate)
 | 
				
			||||||
//                        << "(price so far:" << price << ")";
 | 
					                        << "(price so far:" << price << ")";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -518,39 +603,28 @@ int main() {
 | 
				
			|||||||
        int w = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET_TEEN);
 | 
					        int w = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET_TEEN);
 | 
				
			||||||
        qCritical() << "price teen" << w;
 | 
					        qCritical() << "price teen" << w;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QDateTime s(QDate(2023, 11, 30), QTime());
 | 
					        QDateTime s(QDate(2023, 11, 30), QTime());
 | 
				
			||||||
        QDateTime end;
 | 
					        QDateTime end;
 | 
				
			||||||
        struct price_t price;
 | 
					        struct price_t price;
 | 
				
			||||||
#define ADULT 0
 | 
					#define ADULT 1
 | 
				
			||||||
#define TEEN 1
 | 
					//#define TEEN 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int offset = 480; offset < 1200; ++offset) {
 | 
				
			||||||
 | 
					            QDateTime start = s.addSecs(offset * 60);
 | 
				
			||||||
 | 
					            CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
 | 
				
			||||||
#if ADULT==1
 | 
					#if ADULT==1
 | 
				
			||||||
        for (int offset = 480; offset < 1080; ++offset) {
 | 
					                                                          PERMIT_TYPE::DAY_TICKET_ADULT,
 | 
				
			||||||
            QDateTime start = s.addSecs(offset * 60);
 | 
					#elif TEEN==1
 | 
				
			||||||
 | 
					                                                          PERMIT_TYPE::DAY_TICKET_TEEN,
 | 
				
			||||||
            // qCritical() << QString(Calculator::GetInstance().isParkingAllowed(&cfg, start));
 | 
					#endif
 | 
				
			||||||
 | 
					                                                          &price);
 | 
				
			||||||
            CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
 | 
					 | 
				
			||||||
                                                          PERMIT_TYPE::DAY_TICKET_ADULT, &price);
 | 
					 | 
				
			||||||
            qCritical() << "start=" << start.toString(Qt::ISODate)
 | 
					            qCritical() << "start=" << start.toString(Qt::ISODate)
 | 
				
			||||||
                        << "end" << end.toString(Qt::ISODate) << "price" << price.netto;
 | 
					                        << "end" << end.toString(Qt::ISODate) << "price" << price.netto;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if TEEN==1
 | 
					 | 
				
			||||||
        for (int offset = 480; offset < 1080; ++offset) {
 | 
					 | 
				
			||||||
            QDateTime start = s.addSecs(offset * 60);
 | 
					 | 
				
			||||||
            CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
 | 
					 | 
				
			||||||
                                                          PERMIT_TYPE::DAY_TICKET_TEEN, &price);
 | 
					 | 
				
			||||||
            qCritical() << "start=" << start.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                        << "end" << end.toString(Qt::ISODate) << "price" << price.netto;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#undef ADULT
 | 
				
			||||||
    }
 | 
					#undef TEEN
 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if NEUHAUSER_LINSINGER_MASCHINENBAU==1
 | 
					#if NEUHAUSER_LINSINGER_MASCHINENBAU==1
 | 
				
			||||||
@@ -566,50 +640,19 @@ int main() {
 | 
				
			|||||||
    cout << endl;
 | 
					    cout << endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (isParsed) {
 | 
					    if (isParsed) {
 | 
				
			||||||
        bool nextDay = false;
 | 
					        int const price = compute_product_price(&cfg, PERMIT_TYPE::FOOD_STAMP);
 | 
				
			||||||
        bool prePaid = false;
 | 
					        qCritical() << "price food stamp" << price;
 | 
				
			||||||
 | 
					 | 
				
			||||||
        // zone 1 (lila)
 | 
					 | 
				
			||||||
        QDateTime s(QDate(2023, 11, 30), QTime());
 | 
					 | 
				
			||||||
        QDateTime end;
 | 
					 | 
				
			||||||
        int marken[] = { 3*60, 5*60, 10*60};
 | 
					 | 
				
			||||||
        for (int duration = 0; duration < 3; ++duration) {
 | 
					 | 
				
			||||||
            for (int offset = 360; offset <= 360; ++offset) {
 | 
					 | 
				
			||||||
            // for (int offset = 360; offset < 1080; ++offset) {
 | 
					 | 
				
			||||||
                QDateTime start = s.addSecs(offset * 60);
 | 
					 | 
				
			||||||
                //qCritical() << "start" << start.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                // note: prepaid == false (!)
 | 
					 | 
				
			||||||
                // double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 4, start, end, marken[duration], nextDay, prePaid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                struct price_t price;
 | 
					 | 
				
			||||||
                if (compute_price_for_parking_ticket(&cfg, start, marken[duration], end, &price, prePaid)) {
 | 
					 | 
				
			||||||
                    double cost = price.netto;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    qCritical() << "start" << start.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                                << "end" << end.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                                << "duration" << marken[duration]
 | 
					 | 
				
			||||||
                                << "cost" << cost;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //std::string d = Calculator::GetInstance().GetDurationFromCost(&cfg, 4, start.toString(Qt::ISODate).toStdString().c_str(), cost);
 | 
					 | 
				
			||||||
                //qCritical() << "start" << start.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                //            << "cost" << cost
 | 
					 | 
				
			||||||
                //            << "until" << d.c_str() << start.secsTo(QDateTime::fromString(d.c_str(), Qt::ISODate)) / 60;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if NEUHAUSER_KORNEUBURG==1
 | 
					#if NEUHAUSER_KORNEUBURG==1
 | 
				
			||||||
    std::ifstream input("/tmp/tariff_korneuburg.json");
 | 
					    std::ifstream input("/opt/ptu5/opt/customer_714/etc/psa_tariff/tariff01.json");
 | 
				
			||||||
    int pop_max_time;
 | 
					    int pop_max_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::stringstream sstr;
 | 
					    std::stringstream sstr;
 | 
				
			||||||
    while(input >> sstr.rdbuf());
 | 
					    while(input >> sstr.rdbuf());
 | 
				
			||||||
    std::string json(sstr.str());
 | 
					    std::string json(sstr.str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Calculator calculator;
 | 
					 | 
				
			||||||
    Configuration cfg;
 | 
					    Configuration cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool isParsed = cfg.ParseJson(&cfg, json.c_str());
 | 
					    bool isParsed = cfg.ParseJson(&cfg, json.c_str());
 | 
				
			||||||
@@ -631,19 +674,19 @@ int main() {
 | 
				
			|||||||
                    QDateTime start = s.addSecs(offset * 60);
 | 
					                    QDateTime start = s.addSecs(offset * 60);
 | 
				
			||||||
                    //qCritical() << "start" << start.toString(Qt::ISODate);
 | 
					                    //qCritical() << "start" << start.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    double cost = calculator.GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
 | 
					                    double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
 | 
				
			||||||
                    //Q_ASSERT(cost == duration*2.5);
 | 
					                    //Q_ASSERT(cost == duration*2.5);
 | 
				
			||||||
                    //qCritical() << "";
 | 
					                    //qCritical() << "";
 | 
				
			||||||
                    //qCritical() << "start" << start.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                    //            << "end" << end.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                    //            << "duration" << duration
 | 
					 | 
				
			||||||
                    //            << "cost" << cost;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    std::string duration = calculator.GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
 | 
					 | 
				
			||||||
                    //Q_ASSERT(cost == duration*2.5);
 | 
					 | 
				
			||||||
                    qCritical() << "start" << start.toString(Qt::ISODate)
 | 
					                    qCritical() << "start" << start.toString(Qt::ISODate)
 | 
				
			||||||
                                << "cost" << cost
 | 
					                                << "end" << end.toString(Qt::ISODate)
 | 
				
			||||||
                                << "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
 | 
					                                << "duration" << duration
 | 
				
			||||||
 | 
					                                << "cost" << cost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
 | 
				
			||||||
 | 
					                    //Q_ASSERT(cost == duration*2.5);
 | 
				
			||||||
 | 
					                    //qCritical() << "start" << start.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                    //            << "cost" << cost
 | 
				
			||||||
 | 
					                    //            << "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user