Compare commits
	
		
			6 Commits
		
	
	
		
			2.4.99
			...
			vorkauf-fi
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 78cae24389 | |||
| de0be1d19b | |||
| 54921f0e85 | |||
| 077c2334ca | |||
| d605af5c5a | |||
| c5900f9f2b | 
@@ -37,7 +37,7 @@ struct ATBTariffCarryOver {
 | 
			
		||||
        if (coif == "always") {
 | 
			
		||||
            m_carryOverIf = ApplyCarryOver::ALWAYS;
 | 
			
		||||
        } else {
 | 
			
		||||
           qCritical() << "ERROR unknown carry over application" << coif;
 | 
			
		||||
           qCritical() << __func__ << ":" << __LINE__ << "ERROR unknown carry over application" << coif;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ struct ATBTariffPrepaid {
 | 
			
		||||
        if (ppif == "always") {
 | 
			
		||||
            m_prepaidIf = ApplyPrepaid::ALWAYS;
 | 
			
		||||
        } else {
 | 
			
		||||
           qCritical() << "ERROR unknown carry over application" << ppif;
 | 
			
		||||
           qCritical() << __func__ << ":" << __LINE__ << "ERROR unknown carry over application" << ppif;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -850,6 +850,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            QDateTime effectiveStartTime(start_parking_time);
 | 
			
		||||
            qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
 | 
			
		||||
                        << effectiveStartTime.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
            // handle special days
 | 
			
		||||
            int const specialDayId = tariff->specialDayId(start_parking_time);
 | 
			
		||||
@@ -880,6 +882,9 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
 | 
			
		||||
                        << effectiveStartTime.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
            // handle prepaid option
 | 
			
		||||
            int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
			
		||||
            std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
 | 
			
		||||
@@ -894,17 +899,36 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
			
		||||
 | 
			
		||||
                    if (start_parking_time.time() < p.prepaid[weekDay].static_end) {     // static_end: e.g. 08:00:00
 | 
			
		||||
                        effectiveStartTime.setTime(p.prepaid[weekDay].static_end);
 | 
			
		||||
                        qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
 | 
			
		||||
                                    << effectiveStartTime.toString(Qt::ISODate);
 | 
			
		||||
                    } else
 | 
			
		||||
                    if (start_parking_time.time() > p.prepaid[weekDay].static_start) {   // static_start: e.g. 22:00:00
 | 
			
		||||
                        effectiveStartTime.setTime(p.prepaid[weekDay].static_start);
 | 
			
		||||
                        QTime const midnight(23, 59, 59);
 | 
			
		||||
                        QTime const midnight24(0, 0, 0);
 | 
			
		||||
 | 
			
		||||
                        if ((p.prepaid[weekDay].static_start <= midnight && midnight24 <= p.prepaid[weekDay].static_end)
 | 
			
		||||
                         || (p.prepaid[weekDay].static_start == midnight && midnight == p.prepaid[weekDay].static_end)
 | 
			
		||||
                         || (p.prepaid[weekDay].static_start == midnight24 && midnight24 == p.prepaid[weekDay].static_end)) {
 | 
			
		||||
                            effectiveStartTime = effectiveStartTime.addDays(1);
 | 
			
		||||
                            weekDay = effectiveStartTime.date().dayOfWeek();
 | 
			
		||||
                            qCritical() << __func__ << ":" << __LINE__
 | 
			
		||||
                                        << "effectiveStartTime: new week day [" << weekDay << "] (Mon=1, Tue=2, ..., Sun=7)";
 | 
			
		||||
                        }
 | 
			
		||||
                        effectiveStartTime.setTime(p.prepaid[weekDay].static_end);
 | 
			
		||||
                        qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
 | 
			
		||||
                                    << effectiveStartTime.toString(Qt::ISODate);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                qCritical() << __func__ << ":" << __LINE__ << "no prepaid option set";
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // set seconds to 0
 | 
			
		||||
            effectiveStartTime.setTime(QTime(effectiveStartTime.time().hour(),
 | 
			
		||||
                                             effectiveStartTime.time().minute(), 0));
 | 
			
		||||
 | 
			
		||||
            qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:" << effectiveStartTime.toString(Qt::ISODate);
 | 
			
		||||
            qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:"
 | 
			
		||||
                        << effectiveStartTime.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
            int const carryOver = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over;
 | 
			
		||||
 | 
			
		||||
@@ -927,12 +951,12 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
			
		||||
                    s = s.addSecs(minutesUntilCarryOver * 60);
 | 
			
		||||
                    s = s.addSecs(carryOverDuration * 60);
 | 
			
		||||
                    end_parking_time = s.addSecs(rest * 60);
 | 
			
		||||
                    qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
			
		||||
                } else {
 | 
			
		||||
                    end_parking_time = effectiveStartTime.addSecs(netto_parking_time*60);
 | 
			
		||||
                    qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
                weekDay = end_parking_time.date().dayOfWeek();
 | 
			
		||||
 | 
			
		||||
                // musste man in einer schleife machen
 | 
			
		||||
 
 | 
			
		||||
@@ -379,7 +379,8 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
 | 
			
		||||
 | 
			
		||||
    int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
			
		||||
    int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
 | 
			
		||||
    int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
 | 
			
		||||
    int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price =
 | 
			
		||||
                                cfg->getPaymentOptions(paymentOptionIndex).pop_max_price_save;
 | 
			
		||||
    int const pop_max_time = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
			
		||||
    int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
			
		||||
    int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
 | 
			
		||||
@@ -452,10 +453,47 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
 | 
			
		||||
    netto_parking_time_in_minutes = 0;
 | 
			
		||||
    brutto_parking_time_in_minutes = 0;
 | 
			
		||||
    free_parking_time_in_minutes = 0;
 | 
			
		||||
    int nettoParktimeForCost = 0;
 | 
			
		||||
 | 
			
		||||
    int const nettoParktimeForCost = priceNettoParktime[int(cost)];
 | 
			
		||||
    qCritical() << __func__ << ":" << __LINE__ << QString("cost=%1 nettoParkTimeForCost=%2").
 | 
			
		||||
                                                        arg(cost).arg(nettoParktimeForCost);
 | 
			
		||||
    if (priceNettoParktime.contains(int(cost))) {
 | 
			
		||||
        nettoParktimeForCost = priceNettoParktime[int(cost)];
 | 
			
		||||
        qCritical() << __func__ << ":" << __LINE__ << QString("cost=%1 nettoParkTimeForCost=%2").
 | 
			
		||||
                                                            arg(cost).arg(nettoParktimeForCost);
 | 
			
		||||
    } else {
 | 
			
		||||
 | 
			
		||||
        // cannot find netto-parking time for cost (=price)
 | 
			
		||||
        // this happens for direct coin input and should not happen otherwise
 | 
			
		||||
        // take the value for the nearest value of cost and mark result as overpaid
 | 
			
		||||
 | 
			
		||||
        QList <int> keys = priceNettoParktime.keys();   // keys (=prices) are sorted in ascending order
 | 
			
		||||
        QSet<int> s; // make keys unique
 | 
			
		||||
        for (int k = 0; k < keys.size(); ++k) {
 | 
			
		||||
            if (keys[k] < cost) {
 | 
			
		||||
                s << keys[k];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        keys = s.values();
 | 
			
		||||
        // sort in descending order
 | 
			
		||||
        std::sort(std::begin(keys), std::end(keys), std::greater<>());
 | 
			
		||||
        // qCritical() << __func__ << ":" << __LINE__ << "keys=" << keys;
 | 
			
		||||
        if (!keys.isEmpty()) {
 | 
			
		||||
            int const maxCost = keys[0];
 | 
			
		||||
            auto const p = priceNettoParktime.equal_range(maxCost);
 | 
			
		||||
            for (auto it = p.first; it != p.second; ++it) {
 | 
			
		||||
                nettoParktimeForCost = std::max(nettoParktimeForCost, it.value());
 | 
			
		||||
            }
 | 
			
		||||
            ATBPaymentOption &po = cfg->getPaymentOptions(paymentOptionIndex);
 | 
			
		||||
            po.pop_max_price = maxCost;
 | 
			
		||||
            cfg->getPaymentOptions(paymentOptionIndex).pop_max_price = maxCost;
 | 
			
		||||
            if (pop_allow_overpay) {
 | 
			
		||||
                overPaid = true;
 | 
			
		||||
            }
 | 
			
		||||
            qCritical() << __func__ << ":" << __LINE__ << QString("cost=%1 -> maxCost=%2 nettoParkTimeForCost=%3").
 | 
			
		||||
                                                            arg(cost).arg(maxCost).arg(nettoParktimeForCost);
 | 
			
		||||
        } else {
 | 
			
		||||
            qCritical() << __func__ << ":" << __LINE__ << "ERROR empty keys -> check tariff file";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int cnt = 0;
 | 
			
		||||
    while (++cnt < 20 && netto_parking_time_in_minutes < nettoParktimeForCost) {
 | 
			
		||||
@@ -912,7 +950,8 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
			
		||||
                int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
 | 
			
		||||
                int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price
 | 
			
		||||
                                            = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price_save;
 | 
			
		||||
                //int const pop_max_time = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
			
		||||
                int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
			
		||||
                int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
 | 
			
		||||
 
 | 
			
		||||
@@ -171,8 +171,9 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
 | 
			
		||||
                                                                if (!d.isNull() && d.isValid()) {
 | 
			
		||||
                                                                    TariffPrepaid.m_date = d;
 | 
			
		||||
                                                                }
 | 
			
		||||
                                                                TariffPrepaid.setPrepaidIf(prepaidIf);
 | 
			
		||||
 | 
			
		||||
                                                                if (!prepaidIf.isNull() && !prepaidIf.trimmed().isEmpty()) {
 | 
			
		||||
                                                                    TariffPrepaid.setPrepaidIf(prepaidIf);
 | 
			
		||||
                                                                }
 | 
			
		||||
                                                                qCritical() << TariffPrepaid;
 | 
			
		||||
 | 
			
		||||
                                                                cfg.TariffPrepaids.insert(std::pair<int, ATBTariffPrepaid>(weekDay, TariffPrepaid));
 | 
			
		||||
@@ -258,7 +259,7 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
 | 
			
		||||
                                                                if (!d.isNull() && d.isValid()) {
 | 
			
		||||
                                                                    TariffCarryOver.m_date = d;
 | 
			
		||||
                                                                }
 | 
			
		||||
                                                                if (!carryOverIf.isEmpty()) {
 | 
			
		||||
                                                                if (!carryOverIf.isNull() && !carryOverIf.trimmed().isEmpty()) {
 | 
			
		||||
                                                                    TariffCarryOver.setCarryOverIf(carryOverIf);
 | 
			
		||||
                                                                }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user