Compare commits
	
		
			23 Commits
		
	
	
		
			kleipeda-e
			...
			fuchs-mueh
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						96aad6b797
	
				 | 
					
					
						|||
| 648799629a | |||
| 84e2530767 | |||
| ceb78772dd | |||
| 675ba60733 | |||
| d86a688836 | |||
| 171b23eebb | |||
| ae9a54bf02 | |||
| 84e61844ab | |||
| 328f7cb712 | |||
| 84dbfc7234 | |||
| 48cc6b1302 | |||
| a6007ee89a | |||
| 192a37d93f | |||
| b17f77b22a | |||
| 007978a0f8 | |||
| 80b21ac231 | |||
| 0a32d60827 | |||
| 26a50fb972 | |||
| 964ee17540 | |||
| 6ef57792ce | |||
| ec9f7d9262 | |||
| a2c40fa32a | 
@@ -3,7 +3,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
#include <optional>
 | 
					#include <optional>
 | 
				
			||||||
#include <utility>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "configuration.h"
 | 
					#include "configuration.h"
 | 
				
			||||||
#include "calculate_price.h"
 | 
					#include "calculate_price.h"
 | 
				
			||||||
@@ -71,8 +70,7 @@ public:
 | 
				
			|||||||
	/// <param name="start_datetime">Date/time of payment to be conducted in ISO8601 format (e.g. 2022-12-25T08:00:00Z)</param>
 | 
						/// <param name="start_datetime">Date/time of payment to be conducted in ISO8601 format (e.g. 2022-12-25T08:00:00Z)</param>
 | 
				
			||||||
	/// <param name="price"></param>
 | 
						/// <param name="price"></param>
 | 
				
			||||||
	/// <returns>Returns duration in seconds (data type: double)</returns>
 | 
						/// <returns>Returns duration in seconds (data type: double)</returns>
 | 
				
			||||||
    std::pair<std::string, QDateTime>
 | 
					    std::string GetDurationFromCost(Configuration* cfg, uint8_t vehicle_type, char const* start_datetime, double price,
 | 
				
			||||||
        GetDurationFromCost(Configuration* cfg, uint8_t vehicle_type, char const* start_datetime, double price,
 | 
					 | 
				
			||||||
                                    PermitType permitType, bool nextDay = false, bool prepaid = false);
 | 
					                                    PermitType permitType, bool nextDay = false, bool prepaid = false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/// <summary>
 | 
						/// <summary>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@
 | 
				
			|||||||
#include "tariff_interpolation.h"
 | 
					#include "tariff_interpolation.h"
 | 
				
			||||||
#include "tariff_prepaid.h"
 | 
					#include "tariff_prepaid.h"
 | 
				
			||||||
#include "tariff_carryover.h"
 | 
					#include "tariff_carryover.h"
 | 
				
			||||||
 | 
					#include "tariff_prepay.h"
 | 
				
			||||||
#include "tariff_permit_type.h"
 | 
					#include "tariff_permit_type.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QVector>
 | 
					#include <QVector>
 | 
				
			||||||
@@ -36,7 +37,6 @@
 | 
				
			|||||||
using namespace std;
 | 
					using namespace std;
 | 
				
			||||||
using namespace rapidjson;
 | 
					using namespace rapidjson;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
class Calculator;
 | 
					class Calculator;
 | 
				
			||||||
class Configuration
 | 
					class Configuration
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -48,6 +48,7 @@ public:
 | 
				
			|||||||
    using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
 | 
					    using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
 | 
				
			||||||
    using TariffInterpolationType = std::multimap<int, ATBInterpolation>;
 | 
					    using TariffInterpolationType = std::multimap<int, ATBInterpolation>;
 | 
				
			||||||
    using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
 | 
					    using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
 | 
				
			||||||
 | 
					    using TariffPrepayOptionType = std::multimap<int, ATBPrepay>;
 | 
				
			||||||
    using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
 | 
					    using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
 | 
				
			||||||
    using TariffDurationType = std::multimap<int, ATBDuration>;
 | 
					    using TariffDurationType = std::multimap<int, ATBDuration>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -55,12 +56,12 @@ public:
 | 
				
			|||||||
    ATBCurrency Currency;
 | 
					    ATBCurrency Currency;
 | 
				
			||||||
    ATBDuration duration;
 | 
					    ATBDuration duration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    TariffDurationType Duration;
 | 
						TariffDurationType Duration;
 | 
				
			||||||
	multimap<int, ATBPaymentMethod> PaymentMethod;
 | 
						multimap<int, ATBPaymentMethod> PaymentMethod;
 | 
				
			||||||
	multimap<int, ATBPaymentRate> PaymentRate;
 | 
						multimap<int, ATBPaymentRate> PaymentRate;
 | 
				
			||||||
	SpecialDaysWorktimeType SpecialDaysWorktime;
 | 
						SpecialDaysWorktimeType SpecialDaysWorktime;
 | 
				
			||||||
	SpecialDaysType SpecialDays;
 | 
						SpecialDaysType SpecialDays;
 | 
				
			||||||
    multimap<Qt::DayOfWeek, ATBWeekDay> WeekDays;
 | 
						multimap<int, ATBWeekDays> WeekDays;
 | 
				
			||||||
	multimap<int, ATBPeriodYear> YearPeriod;
 | 
						multimap<int, ATBPeriodYear> YearPeriod;
 | 
				
			||||||
	multimap<int, ATBWeekDaysWorktime> WeekDaysWorktime;
 | 
						multimap<int, ATBWeekDaysWorktime> WeekDaysWorktime;
 | 
				
			||||||
	ATBPaymentOptionType PaymentOption;
 | 
						ATBPaymentOptionType PaymentOption;
 | 
				
			||||||
@@ -72,6 +73,7 @@ public:
 | 
				
			|||||||
	TariffProductType TariffProduct;
 | 
						TariffProductType TariffProduct;
 | 
				
			||||||
	TariffInterpolationType TariffInterpolations;
 | 
						TariffInterpolationType TariffInterpolations;
 | 
				
			||||||
	TariffPrepaidType TariffPrepaidOptions;
 | 
						TariffPrepaidType TariffPrepaidOptions;
 | 
				
			||||||
 | 
						TariffPrepayOptionType TariffPrepayOptions;
 | 
				
			||||||
	TariffCarryOverType TariffCarryOverOptions;
 | 
						TariffCarryOverType TariffCarryOverOptions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/// <summary>
 | 
						/// <summary>
 | 
				
			||||||
@@ -127,15 +129,3 @@ private:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	QVector<ATBPaymentOption> currentPaymentOptions;
 | 
						QVector<ATBPaymentOption> currentPaymentOptions;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					 | 
				
			||||||
bool previousDayHoliday(Configuration const &cfg, QDateTime const &t);
 | 
					 | 
				
			||||||
bool isHoliday(Configuration const &cfg, QDateTime const &t);
 | 
					 | 
				
			||||||
int getPaymentOptionIndex(Configuration const &cfg, QDateTime const& dt = QDateTime::currentDateTime());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ATBWeekDay parseWeekDay(Configuration &cfg,
 | 
					 | 
				
			||||||
                        rapidjson::GenericMemberIterator<false,
 | 
					 | 
				
			||||||
                                                         rapidjson::UTF8<char>,
 | 
					 | 
				
			||||||
                                                         rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> k,
 | 
					 | 
				
			||||||
                        QString const &innerObjName,
 | 
					 | 
				
			||||||
                        Qt::DayOfWeek weekDay,
 | 
					 | 
				
			||||||
                        QString const &weekDayName);
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					#include <QDateTime>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ATBDuration
 | 
					class ATBDuration
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -12,20 +13,35 @@ public:
 | 
				
			|||||||
      , pun_duration_saved(0)
 | 
					      , pun_duration_saved(0)
 | 
				
			||||||
      , pun_duration_min(0)
 | 
					      , pun_duration_min(0)
 | 
				
			||||||
      , pun_duration_max(0)
 | 
					      , pun_duration_max(0)
 | 
				
			||||||
      , pun_interpolation_id(-1) {
 | 
					      , pun_interpolation_id(-1)
 | 
				
			||||||
 | 
					      , pun_netto(false)
 | 
				
			||||||
 | 
					      , pun_brutto(false)
 | 
				
			||||||
 | 
					      , pun_fixed(false)
 | 
				
			||||||
 | 
					      , pun_mutable(false)
 | 
				
			||||||
 | 
					      , pun_round_to_next_24h_boundary(false)
 | 
				
			||||||
 | 
					      , pun_round_to_prev_24h_boundary(false)
 | 
				
			||||||
 | 
					      , pun_align_with_timepoint(QDateTime())
 | 
				
			||||||
 | 
					      , pun_next_step_correction(0) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    friend QDebug operator<<(QDebug debug, ATBDuration const &td) {
 | 
					    friend QDebug operator<<(QDebug debug, ATBDuration const &td) {
 | 
				
			||||||
        QDebugStateSaver saver(debug);
 | 
					        QDebugStateSaver saver(debug);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        debug.nospace()
 | 
					        debug.nospace()
 | 
				
			||||||
            << "              pun_id: " << td.pun_id << "\n"
 | 
					            << "                        pun_id: " << td.pun_id << "\n"
 | 
				
			||||||
            << "           pun_label: " << QString::fromStdString(td.pun_label) << "\n"
 | 
					            << "                     pun_label: " << QString::fromStdString(td.pun_label) << "\n"
 | 
				
			||||||
            << "        pun_duration: " << td.pun_duration << "\n"
 | 
					            << "                  pun_duration: " << td.pun_duration << "\n"
 | 
				
			||||||
            << "  pun_duration_saved: " << td.pun_duration_saved << "\n"
 | 
					            << "            pun_duration_saved: " << td.pun_duration_saved << "\n"
 | 
				
			||||||
            << "    pun_duration_min: " << td.pun_duration_min << "\n"
 | 
					            << "              pun_duration_min: " << td.pun_duration_min << "\n"
 | 
				
			||||||
            << "    pun_duration_max: " << td.pun_duration_max << "\n"
 | 
					            << "              pun_duration_max: " << td.pun_duration_max << "\n"
 | 
				
			||||||
            << "pun_interpolation_id: " << td.pun_interpolation_id << "\n";
 | 
					            << "          pun_interpolation_id: " << td.pun_interpolation_id << "\n"
 | 
				
			||||||
 | 
					            << "                     pun_netto: " << td.pun_netto << "\n"
 | 
				
			||||||
 | 
					            << "                    pun_brutto: " << td.pun_brutto << "\n"
 | 
				
			||||||
 | 
					            << "                     pun_fixed: " << td.pun_fixed << "\n"
 | 
				
			||||||
 | 
					            << "                   pun_mutable: " << td.pun_mutable << "\n"
 | 
				
			||||||
 | 
					            << "pun_round_to_next_24h_boundary: " << td.pun_round_to_next_24h_boundary << "\n"
 | 
				
			||||||
 | 
					            << "pun_round_to_prev_24h_boundary: " << td.pun_round_to_prev_24h_boundary << "\n"
 | 
				
			||||||
 | 
					            << "      pun_align_with_timepoint: " << td.pun_align_with_timepoint << endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return debug;
 | 
					        return debug;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -33,8 +49,16 @@ public:
 | 
				
			|||||||
	int pun_id;
 | 
						int pun_id;
 | 
				
			||||||
	std::string pun_label;
 | 
						std::string pun_label;
 | 
				
			||||||
	int pun_duration;
 | 
						int pun_duration;
 | 
				
			||||||
    int pun_duration_saved;
 | 
						int pun_duration_saved;
 | 
				
			||||||
    int pun_duration_min;
 | 
						int pun_duration_min;
 | 
				
			||||||
    int pun_duration_max;
 | 
						int pun_duration_max;
 | 
				
			||||||
    int pun_interpolation_id;
 | 
						int pun_interpolation_id;
 | 
				
			||||||
 | 
						bool pun_netto;             // the timestep expressed by this duration is a netto timestep
 | 
				
			||||||
 | 
						bool pun_brutto;            // the timestep expressed by this duration is a brutto timestep
 | 
				
			||||||
 | 
						bool pun_fixed;             // the value given in tariff-file is fixed (constant)
 | 
				
			||||||
 | 
						bool pun_mutable;           // the value could change
 | 
				
			||||||
 | 
						bool pun_round_to_next_24h_boundary;
 | 
				
			||||||
 | 
						bool pun_round_to_prev_24h_boundary;
 | 
				
			||||||
 | 
						QDateTime pun_align_with_timepoint;
 | 
				
			||||||
 | 
						int pun_next_step_correction;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,16 +13,17 @@ enum MemberType
 | 
				
			|||||||
	WeekDaysWorkTimeType = 0x06,
 | 
						WeekDaysWorkTimeType = 0x06,
 | 
				
			||||||
	SpecialDaysWorktimeType = 0x07,
 | 
						SpecialDaysWorktimeType = 0x07,
 | 
				
			||||||
	SpecialDaysType = 0x08,
 | 
						SpecialDaysType = 0x08,
 | 
				
			||||||
    PeriodYearType = 0x09,
 | 
						PeriodYearType = 0x09,
 | 
				
			||||||
    DailyTicketType = 0x0A,
 | 
						DailyTicketType = 0x0A,
 | 
				
			||||||
    CustomerType = 0x0B,
 | 
						CustomerType = 0x0B,
 | 
				
			||||||
    TimeBaseType = 0x0C,
 | 
						TimeBaseType = 0x0C,
 | 
				
			||||||
    TimeRangeType = 0x0D,
 | 
						TimeRangeType = 0x0D,
 | 
				
			||||||
    TimeStepConfigType = 0x0E,
 | 
						TimeStepConfigType = 0x0E,
 | 
				
			||||||
    ProductType = 0x0F,
 | 
						ProductType = 0x0F,
 | 
				
			||||||
    InterpolationType = 0x10,
 | 
						InterpolationType = 0x10,
 | 
				
			||||||
    PrepaidType = 0x11,
 | 
						PrepaidType = 0x11, // deprecated
 | 
				
			||||||
    CarryOverType = 0x12
 | 
						CarryOverType = 0x12,
 | 
				
			||||||
 | 
						PrepaidOptionType = 0x13,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // MEMBER_TYPE_H_INCLUDED
 | 
					#endif // MEMBER_TYPE_H_INCLUDED
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@ public:
 | 
				
			|||||||
        pop_carry_over = -1;
 | 
					        pop_carry_over = -1;
 | 
				
			||||||
        pop_carry_over_option_id = -1;
 | 
					        pop_carry_over_option_id = -1;
 | 
				
			||||||
        pop_prepaid_option_id = -1;
 | 
					        pop_prepaid_option_id = -1;
 | 
				
			||||||
 | 
					        pop_prepay_option_id = -1;
 | 
				
			||||||
        pop_truncate_last_interpolation_step = false;
 | 
					        pop_truncate_last_interpolation_step = false;
 | 
				
			||||||
        pop_accumulate_prices = false;
 | 
					        pop_accumulate_prices = false;
 | 
				
			||||||
        pop_accumulate_durations = false;
 | 
					        pop_accumulate_durations = false;
 | 
				
			||||||
@@ -41,10 +42,7 @@ public:
 | 
				
			|||||||
        pop_use_only_upto_datetime = ""; // deprecated
 | 
					        pop_use_only_upto_datetime = ""; // deprecated
 | 
				
			||||||
        pop_use_only_for_duration = 0;   // deprecated
 | 
					        pop_use_only_for_duration = 0;   // deprecated
 | 
				
			||||||
        pop_plus_steps = 1;  // +: jump <x=1> steps forward
 | 
					        pop_plus_steps = 1;  // +: jump <x=1> steps forward
 | 
				
			||||||
        pop_plus_steps_saved = 1;
 | 
					 | 
				
			||||||
        pop_minus_steps = 1; // -: jump <x=1> steps backward
 | 
					        pop_minus_steps = 1; // -: jump <x=1> steps backward
 | 
				
			||||||
        pop_allow_overpay = false;
 | 
					 | 
				
			||||||
        pop_apply_carry_over_to_ticket_endtime = false;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int pop_id;
 | 
					    int pop_id;
 | 
				
			||||||
@@ -64,7 +62,8 @@ public:
 | 
				
			|||||||
    int pop_carry_over;
 | 
					    int pop_carry_over;
 | 
				
			||||||
    int pop_carry_over_option_id;
 | 
					    int pop_carry_over_option_id;
 | 
				
			||||||
    bool pop_truncate_last_interpolation_step;
 | 
					    bool pop_truncate_last_interpolation_step;
 | 
				
			||||||
    int pop_prepaid_option_id;
 | 
					    int pop_prepaid_option_id; // deprecated
 | 
				
			||||||
 | 
					    int pop_prepay_option_id;
 | 
				
			||||||
    bool pop_carry_over_target;
 | 
					    bool pop_carry_over_target;
 | 
				
			||||||
    int pop_carry_over_time_range_id;
 | 
					    int pop_carry_over_time_range_id;
 | 
				
			||||||
    int pop_carry_over_start_time_range;
 | 
					    int pop_carry_over_start_time_range;
 | 
				
			||||||
@@ -75,10 +74,7 @@ public:
 | 
				
			|||||||
    bool pop_accumulate_prices;
 | 
					    bool pop_accumulate_prices;
 | 
				
			||||||
    bool pop_accumulate_durations;
 | 
					    bool pop_accumulate_durations;
 | 
				
			||||||
    int pop_plus_steps;
 | 
					    int pop_plus_steps;
 | 
				
			||||||
    int pop_plus_steps_saved;
 | 
					 | 
				
			||||||
    int pop_minus_steps;
 | 
					    int pop_minus_steps;
 | 
				
			||||||
    bool pop_allow_overpay;
 | 
					 | 
				
			||||||
    bool pop_apply_carry_over_to_ticket_endtime;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    struct ATBMaxDateTime {
 | 
					    struct ATBMaxDateTime {
 | 
				
			||||||
        int direction;
 | 
					        int direction;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,9 +8,5 @@ public:
 | 
				
			|||||||
	int pedwt_period_exc_day_id;
 | 
						int pedwt_period_exc_day_id;
 | 
				
			||||||
	std::string pedwt_time_from;
 | 
						std::string pedwt_time_from;
 | 
				
			||||||
	std::string pedwt_time_to;
 | 
						std::string pedwt_time_to;
 | 
				
			||||||
    double pedwt_price;
 | 
						double pedwt_price;
 | 
				
			||||||
    int pedwt_paid; // 00: not paid (i.e. free)
 | 
					 | 
				
			||||||
                    // 01: not paid in winter term, piad in summer term
 | 
					 | 
				
			||||||
                    // 10: paid in winter term, not paid in summer term
 | 
					 | 
				
			||||||
                    // 11: paid in winter and in summer term
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@@ -15,19 +15,6 @@ struct ATBCarryOver {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    int id;
 | 
					    int id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    explicit ATBCarryOver()
 | 
					 | 
				
			||||||
      : id(-1) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (int i = 0 ; i < 8; ++i) {
 | 
					 | 
				
			||||||
            carryover[i].day = -1;
 | 
					 | 
				
			||||||
            carryover[i].seemless = false;
 | 
					 | 
				
			||||||
            carryover[i].never = false;
 | 
					 | 
				
			||||||
            carryover[i].static_start = QTime(23, 59, 59);
 | 
					 | 
				
			||||||
            carryover[i].static_end = QTime(0, 0, 0);
 | 
					 | 
				
			||||||
            carryover[i].duration = -1;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    friend QDebug operator<<(QDebug debug, ATBCarryOver const &co) {
 | 
					    friend QDebug operator<<(QDebug debug, ATBCarryOver const &co) {
 | 
				
			||||||
        QDebugStateSaver saver(debug);
 | 
					        QDebugStateSaver saver(debug);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -44,21 +31,21 @@ struct ATBCarryOver {
 | 
				
			|||||||
            << "                day: " << co.carryover[(int)Qt::Tuesday].day << "\n"
 | 
					            << "                day: " << co.carryover[(int)Qt::Tuesday].day << "\n"
 | 
				
			||||||
            << "       static_start: " << co.carryover[(int)Qt::Tuesday].static_start.toString(Qt::ISODate) << "\n"
 | 
					            << "       static_start: " << co.carryover[(int)Qt::Tuesday].static_start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
            << "         static_end: " << co.carryover[(int)Qt::Tuesday].static_end.toString(Qt::ISODate) << "\n"
 | 
					            << "         static_end: " << co.carryover[(int)Qt::Tuesday].static_end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
            << "           duration: " << co.carryover[(int)Qt::Tuesday].duration << "\n"
 | 
					            << "           duration: " << co.carryover[(int)Qt::Monday].duration << "\n"
 | 
				
			||||||
            << "            anytime: " << co.carryover[(int)Qt::Tuesday].seemless << "\n"
 | 
					            << "            anytime: " << co.carryover[(int)Qt::Tuesday].seemless << "\n"
 | 
				
			||||||
            << "              never: " << co.carryover[(int)Qt::Tuesday].never << "\n"
 | 
					            << "              never: " << co.carryover[(int)Qt::Tuesday].never << "\n"
 | 
				
			||||||
            << "        **** Wednesday **** \n"
 | 
					            << "        **** Wednesday **** \n"
 | 
				
			||||||
            << "                day: " << co.carryover[(int)Qt::Wednesday].day << "\n"
 | 
					            << "                day: " << co.carryover[(int)Qt::Wednesday].day << "\n"
 | 
				
			||||||
            << "       static_start: " << co.carryover[(int)Qt::Wednesday].static_start.toString(Qt::ISODate) << "\n"
 | 
					            << "       static_start: " << co.carryover[(int)Qt::Wednesday].static_start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
            << "         static_end: " << co.carryover[(int)Qt::Wednesday].static_end.toString(Qt::ISODate) << "\n"
 | 
					            << "         static_end: " << co.carryover[(int)Qt::Wednesday].static_end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
            << "           duration: " << co.carryover[(int)Qt::Wednesday].duration << "\n"
 | 
					            << "           duration: " << co.carryover[(int)Qt::Monday].duration << "\n"
 | 
				
			||||||
            << "            anytime: " << co.carryover[(int)Qt::Wednesday].seemless << "\n"
 | 
					            << "            anytime: " << co.carryover[(int)Qt::Wednesday].seemless << "\n"
 | 
				
			||||||
            << "              never: " << co.carryover[(int)Qt::Wednesday].never << "\n"
 | 
					            << "              never: " << co.carryover[(int)Qt::Wednesday].never << "\n"
 | 
				
			||||||
            << "        **** Thursday **** \n"
 | 
					            << "        **** Thursday **** \n"
 | 
				
			||||||
            << "                day: " << co.carryover[(int)Qt::Thursday].day << "\n"
 | 
					            << "                day: " << co.carryover[(int)Qt::Thursday].day << "\n"
 | 
				
			||||||
            << "       static_start: " << co.carryover[(int)Qt::Thursday].static_start.toString(Qt::ISODate) << "\n"
 | 
					            << "       static_start: " << co.carryover[(int)Qt::Thursday].static_start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
            << "         static_end: " << co.carryover[(int)Qt::Thursday].static_end.toString(Qt::ISODate) << "\n"
 | 
					            << "         static_end: " << co.carryover[(int)Qt::Thursday].static_end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
            << "           duration: " << co.carryover[(int)Qt::Thursday].duration << "\n"
 | 
					            << "           duration: " << co.carryover[(int)Qt::Monday].duration << "\n"
 | 
				
			||||||
            << "            anytime: " << co.carryover[(int)Qt::Thursday].seemless << "\n"
 | 
					            << "            anytime: " << co.carryover[(int)Qt::Thursday].seemless << "\n"
 | 
				
			||||||
            << "              never: " << co.carryover[(int)Qt::Thursday].never << "\n"
 | 
					            << "              never: " << co.carryover[(int)Qt::Thursday].never << "\n"
 | 
				
			||||||
            << "        **** Friday **** \n"
 | 
					            << "        **** Friday **** \n"
 | 
				
			||||||
@@ -71,14 +58,14 @@ struct ATBCarryOver {
 | 
				
			|||||||
            << "                day: " << co.carryover[(int)Qt::Saturday].day << "\n"
 | 
					            << "                day: " << co.carryover[(int)Qt::Saturday].day << "\n"
 | 
				
			||||||
            << "       static_start: " << co.carryover[(int)Qt::Saturday].static_start.toString(Qt::ISODate) << "\n"
 | 
					            << "       static_start: " << co.carryover[(int)Qt::Saturday].static_start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
            << "         static_end: " << co.carryover[(int)Qt::Saturday].static_end.toString(Qt::ISODate) << "\n"
 | 
					            << "         static_end: " << co.carryover[(int)Qt::Saturday].static_end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
            << "           duration: " << co.carryover[(int)Qt::Saturday].duration << "\n"
 | 
					            << "           duration: " << co.carryover[(int)Qt::Monday].duration << "\n"
 | 
				
			||||||
            << "            anytime: " << co.carryover[(int)Qt::Saturday].seemless << "\n"
 | 
					            << "            anytime: " << co.carryover[(int)Qt::Saturday].seemless << "\n"
 | 
				
			||||||
            << "              never: " << co.carryover[(int)Qt::Saturday].never << "\n"
 | 
					            << "              never: " << co.carryover[(int)Qt::Saturday].never << "\n"
 | 
				
			||||||
            << "        **** Sunday **** \n"
 | 
					            << "        **** Sunday **** \n"
 | 
				
			||||||
            << "                day: " << co.carryover[(int)Qt::Sunday].day << "\n"
 | 
					            << "                day: " << co.carryover[(int)Qt::Sunday].day << "\n"
 | 
				
			||||||
            << "       static_start: " << co.carryover[(int)Qt::Sunday].static_start.toString(Qt::ISODate) << "\n"
 | 
					            << "       static_start: " << co.carryover[(int)Qt::Sunday].static_start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
            << "         static_end: " << co.carryover[(int)Qt::Sunday].static_end.toString(Qt::ISODate) << "\n"
 | 
					            << "         static_end: " << co.carryover[(int)Qt::Sunday].static_end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
            << "           duration: " << co.carryover[(int)Qt::Sunday].duration << "\n"
 | 
					            << "           duration: " << co.carryover[(int)Qt::Monday].duration << "\n"
 | 
				
			||||||
            << "            anytime: " << co.carryover[(int)Qt::Sunday].seemless << "\n"
 | 
					            << "            anytime: " << co.carryover[(int)Qt::Sunday].seemless << "\n"
 | 
				
			||||||
            << "              never: " << co.carryover[(int)Qt::Sunday].never << "\n";
 | 
					            << "              never: " << co.carryover[(int)Qt::Sunday].never << "\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,69 +0,0 @@
 | 
				
			|||||||
#ifndef ATB_TARIFF_CARRYOVER_SETTINGS_H_INCLUDED
 | 
					 | 
				
			||||||
#define ATB_TARIFF_CARRYOVER_SETTINGS_H_INCLUDED
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <QDebug>
 | 
					 | 
				
			||||||
#include <QDateTime>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <functional>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct ATBTariffCarryOverSettings {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // parking time limit not violated: return false, otherwise: return true.
 | 
					 | 
				
			||||||
    using ParkingTimeLimitChecker = std::function<bool(ATBTariffCarryOverSettings const&,
 | 
					 | 
				
			||||||
                                                       QDateTime const &startTime,
 | 
					 | 
				
			||||||
                                                       QDateTime const &endTime,
 | 
					 | 
				
			||||||
                                                       int paymentOptionIndex)>;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    int m_duration;
 | 
					 | 
				
			||||||
    QTime m_start;
 | 
					 | 
				
			||||||
    QTime m_end;
 | 
					 | 
				
			||||||
    ParkingTimeLimitChecker m_parkingTimeLimitChecker;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    QTime m_parking_time_limit;
 | 
					 | 
				
			||||||
    QTime m_about_to_exceed_parking_time_limit;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    explicit ATBTariffCarryOverSettings()
 | 
					 | 
				
			||||||
      : m_duration(0)
 | 
					 | 
				
			||||||
      , m_start(QTime())
 | 
					 | 
				
			||||||
      , m_end(QTime())
 | 
					 | 
				
			||||||
      , m_parkingTimeLimitChecker([](ATBTariffCarryOverSettings const&,
 | 
					 | 
				
			||||||
                                  QDateTime const&, QDateTime const&, int) { return false; })
 | 
					 | 
				
			||||||
      , m_parking_time_limit(QTime())
 | 
					 | 
				
			||||||
      , m_about_to_exceed_parking_time_limit(QTime()) {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    explicit ATBTariffCarryOverSettings(int duration, QTime const &start,
 | 
					 | 
				
			||||||
                                        QTime const &end,
 | 
					 | 
				
			||||||
                                        QTime const &parking_time_limit,
 | 
					 | 
				
			||||||
                                        QTime const &about_to_exceed_parking_time_limit,
 | 
					 | 
				
			||||||
                                        ParkingTimeLimitChecker parkingTimeLimitChecker)
 | 
					 | 
				
			||||||
      : m_duration(duration)
 | 
					 | 
				
			||||||
      , m_start(start)
 | 
					 | 
				
			||||||
      , m_end(end)
 | 
					 | 
				
			||||||
      , m_parkingTimeLimitChecker(std::move(parkingTimeLimitChecker))
 | 
					 | 
				
			||||||
      , m_parking_time_limit(parking_time_limit)
 | 
					 | 
				
			||||||
      , m_about_to_exceed_parking_time_limit(about_to_exceed_parking_time_limit) {
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    bool parkingTimeLimitExceeded(QDateTime const &startTime,
 | 
					 | 
				
			||||||
                                  QDateTime const &endTime,
 | 
					 | 
				
			||||||
                                  int paymentOptionIndex) const {
 | 
					 | 
				
			||||||
        return m_parkingTimeLimitChecker(*this, startTime, endTime, paymentOptionIndex);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    QTime const &parkingTimeLimit() const { return m_parking_time_limit; }
 | 
					 | 
				
			||||||
    QTime &parkingTimeLimit() { return m_parking_time_limit; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    friend QDebug operator<<(QDebug debug, ATBTariffCarryOverSettings const &co) {
 | 
					 | 
				
			||||||
        QDebugStateSaver saver(debug);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        debug.nospace()
 | 
					 | 
				
			||||||
            << "                 duration: " << co.m_duration << "\n"
 | 
					 | 
				
			||||||
            << "                    start: " << co.m_start.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "                      end: " << co.m_end.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "       parking_time_limit: " << co.m_parking_time_limit.toString(Qt::ISODate) << endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return debug;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif // ATB_TARIFF_CARRYOVER_SETTINGS_H_INCLUDED
 | 
					 | 
				
			||||||
@@ -14,8 +14,6 @@
 | 
				
			|||||||
void setDebugLevel(int level);
 | 
					void setDebugLevel(int level);
 | 
				
			||||||
int getDebugLevel();
 | 
					int getDebugLevel();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void print() {
 | 
					static void print() {
 | 
				
			||||||
    std::cerr << "\n";
 | 
					    std::cerr << "\n";
 | 
				
			||||||
    if (getDebugLevel() == DBG_LEVEL_FATAL) {
 | 
					    if (getDebugLevel() == DBG_LEVEL_FATAL) {
 | 
				
			||||||
@@ -77,6 +75,4 @@ static void LOG_FATAL(const Arg1& arg1, const Args&&... args) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif //  TARIFF_LOG_INCLUDED_H
 | 
					#endif //  TARIFF_LOG_INCLUDED_H
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,34 +5,13 @@
 | 
				
			|||||||
#include <QString>
 | 
					#include <QString>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct ATBPrepaid {
 | 
					struct ATBPrepaid {
 | 
				
			||||||
 | 
					    explicit ATBPrepaid() = default;
 | 
				
			||||||
    int id;
 | 
					    int id;
 | 
				
			||||||
    bool anytime;
 | 
					    bool anytime;
 | 
				
			||||||
    bool never;
 | 
					    bool never;
 | 
				
			||||||
    QTime static_start;
 | 
					    QTime static_start;
 | 
				
			||||||
    QTime static_end;
 | 
					    QTime static_end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    struct week {
 | 
					 | 
				
			||||||
        int day;
 | 
					 | 
				
			||||||
        QTime static_start;
 | 
					 | 
				
			||||||
        QTime static_end;
 | 
					 | 
				
			||||||
        int duration;
 | 
					 | 
				
			||||||
    } prepaid[8];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    explicit ATBPrepaid()
 | 
					 | 
				
			||||||
      : id(-1)
 | 
					 | 
				
			||||||
      , anytime(false)
 | 
					 | 
				
			||||||
      , never(false)
 | 
					 | 
				
			||||||
      , static_start(QTime(23, 59, 59))
 | 
					 | 
				
			||||||
      , static_end(QTime(0, 0, 0)) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (int i = 0 ; i < 8; ++i) {
 | 
					 | 
				
			||||||
            prepaid[i].day = -1;
 | 
					 | 
				
			||||||
            prepaid[i].static_start = QTime(23, 59, 59);
 | 
					 | 
				
			||||||
            prepaid[i].static_end = QTime(0, 0, 0);
 | 
					 | 
				
			||||||
            prepaid[i].duration = -1;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    friend QDebug operator<<(QDebug debug, ATBPrepaid const &pp) {
 | 
					    friend QDebug operator<<(QDebug debug, ATBPrepaid const &pp) {
 | 
				
			||||||
        QDebugStateSaver saver(debug);
 | 
					        QDebugStateSaver saver(debug);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -41,41 +20,7 @@ struct ATBPrepaid {
 | 
				
			|||||||
            << "       static_start: " << pp.static_start.toString(Qt::ISODate) << "\n"
 | 
					            << "       static_start: " << pp.static_start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
            << "         static_end: " << pp.static_end.toString(Qt::ISODate) << "\n"
 | 
					            << "         static_end: " << pp.static_end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
            << "            anytime: " << pp.anytime << "\n"
 | 
					            << "            anytime: " << pp.anytime << "\n"
 | 
				
			||||||
            << "              never: " << pp.never << "\n"
 | 
					            << "              never: " << pp.never << "\n";
 | 
				
			||||||
            << "        **** Monday **** \n"
 | 
					 | 
				
			||||||
            << "                day: " << pp.prepaid[(int)Qt::Monday].day << "\n"
 | 
					 | 
				
			||||||
            << "       static_start: " << pp.prepaid[(int)Qt::Monday].static_start.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "         static_end: " << pp.prepaid[(int)Qt::Monday].static_end.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "           duration: " << pp.prepaid[(int)Qt::Monday].duration << "\n"
 | 
					 | 
				
			||||||
            << "        **** Tuesday **** \n"
 | 
					 | 
				
			||||||
            << "                day: " << pp.prepaid[(int)Qt::Tuesday].day << "\n"
 | 
					 | 
				
			||||||
            << "       static_start: " << pp.prepaid[(int)Qt::Tuesday].static_start.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "         static_end: " << pp.prepaid[(int)Qt::Tuesday].static_end.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "           duration: " << pp.prepaid[(int)Qt::Tuesday].duration << "\n"
 | 
					 | 
				
			||||||
            << "        **** Wednesday **** \n"
 | 
					 | 
				
			||||||
            << "                day: " << pp.prepaid[(int)Qt::Wednesday].day << "\n"
 | 
					 | 
				
			||||||
            << "       static_start: " << pp.prepaid[(int)Qt::Wednesday].static_start.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "         static_end: " << pp.prepaid[(int)Qt::Wednesday].static_end.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "           duration: " << pp.prepaid[(int)Qt::Wednesday].duration << "\n"
 | 
					 | 
				
			||||||
            << "        **** Thursday **** \n"
 | 
					 | 
				
			||||||
            << "                day: " << pp.prepaid[(int)Qt::Thursday].day << "\n"
 | 
					 | 
				
			||||||
            << "       static_start: " << pp.prepaid[(int)Qt::Thursday].static_start.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "         static_end: " << pp.prepaid[(int)Qt::Thursday].static_end.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "           duration: " << pp.prepaid[(int)Qt::Thursday].duration << "\n"
 | 
					 | 
				
			||||||
            << "        **** Friday **** \n"
 | 
					 | 
				
			||||||
            << "                day: " << pp.prepaid[(int)Qt::Friday].day << "\n"
 | 
					 | 
				
			||||||
            << "       static_start: " << pp.prepaid[(int)Qt::Friday].static_start.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "         static_end: " << pp.prepaid[(int)Qt::Friday].static_end.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "        **** Saturday **** \n"
 | 
					 | 
				
			||||||
            << "                day: " << pp.prepaid[(int)Qt::Saturday].day << "\n"
 | 
					 | 
				
			||||||
            << "       static_start: " << pp.prepaid[(int)Qt::Saturday].static_start.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "         static_end: " << pp.prepaid[(int)Qt::Saturday].static_end.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "           duration: " << pp.prepaid[(int)Qt::Saturday].duration << "\n"
 | 
					 | 
				
			||||||
            << "        **** Sunday **** \n"
 | 
					 | 
				
			||||||
            << "                day: " << pp.prepaid[(int)Qt::Sunday].day << "\n"
 | 
					 | 
				
			||||||
            << "       static_start: " << pp.prepaid[(int)Qt::Sunday].static_start.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "         static_end: " << pp.prepaid[(int)Qt::Sunday].static_end.toString(Qt::ISODate) << "\n"
 | 
					 | 
				
			||||||
            << "           duration: " << pp.prepaid[(int)Qt::Sunday].duration << "\n";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return debug;
 | 
					        return debug;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										68
									
								
								library/include/mobilisis/tariff_prepay.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								library/include/mobilisis/tariff_prepay.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
				
			|||||||
 | 
					#ifndef TARIFF_PREPAY_H_INCLUDED
 | 
				
			||||||
 | 
					#define TARIFF_PREPAY_H_INCLUDED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QTime>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct ATBPrepay {
 | 
				
			||||||
 | 
					    struct week {
 | 
				
			||||||
 | 
					        int day;
 | 
				
			||||||
 | 
					        bool prepaid;       // yes/no
 | 
				
			||||||
 | 
					        QTime start; // only valid if prepaid == true
 | 
				
			||||||
 | 
					        QTime end;
 | 
				
			||||||
 | 
					        int duration;
 | 
				
			||||||
 | 
					    } prepay[8];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    friend QDebug operator<<(QDebug debug, ATBPrepay const &pp) {
 | 
				
			||||||
 | 
					        QDebugStateSaver saver(debug);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        debug.nospace()
 | 
				
			||||||
 | 
					            << "          id:" << pp.id << "\n"
 | 
				
			||||||
 | 
					            << "        **** Monday **** \n"
 | 
				
			||||||
 | 
					            << "         day: " << pp.prepay[(int)Qt::Monday].day << "\n"
 | 
				
			||||||
 | 
					            << "       start: " << pp.prepay[(int)Qt::Monday].start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "         end: " << pp.prepay[(int)Qt::Monday].end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "    duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
 | 
				
			||||||
 | 
					            << "     prepaid: " << pp.prepay[(int)Qt::Monday].prepaid << "\n"
 | 
				
			||||||
 | 
					            << "        **** Tuesday **** \n"
 | 
				
			||||||
 | 
					            << "         day: " << pp.prepay[(int)Qt::Tuesday].day << "\n"
 | 
				
			||||||
 | 
					            << "       start: " << pp.prepay[(int)Qt::Tuesday].start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "         end: " << pp.prepay[(int)Qt::Tuesday].end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "    duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
 | 
				
			||||||
 | 
					            << "     prepaid: " << pp.prepay[(int)Qt::Tuesday].prepaid << "\n"
 | 
				
			||||||
 | 
					            << "        **** Wednesday **** \n"
 | 
				
			||||||
 | 
					            << "         day: " << pp.prepay[(int)Qt::Wednesday].day << "\n"
 | 
				
			||||||
 | 
					            << "       start: " << pp.prepay[(int)Qt::Wednesday].start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "         end: " << pp.prepay[(int)Qt::Wednesday].end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "    duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
 | 
				
			||||||
 | 
					            << "     prepaid: " << pp.prepay[(int)Qt::Wednesday].prepaid << "\n"
 | 
				
			||||||
 | 
					            << "        **** Thursday **** \n"
 | 
				
			||||||
 | 
					            << "         day: " << pp.prepay[(int)Qt::Thursday].day << "\n"
 | 
				
			||||||
 | 
					            << "       start: " << pp.prepay[(int)Qt::Thursday].start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "         end: " << pp.prepay[(int)Qt::Thursday].end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "    duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
 | 
				
			||||||
 | 
					            << "     prepaid: " << pp.prepay[(int)Qt::Thursday].prepaid << "\n"
 | 
				
			||||||
 | 
					            << "        **** Friday **** \n"
 | 
				
			||||||
 | 
					            << "         day: " << pp.prepay[(int)Qt::Friday].day << "\n"
 | 
				
			||||||
 | 
					            << "       start: " << pp.prepay[(int)Qt::Friday].start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "         end: " << pp.prepay[(int)Qt::Friday].end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "     prepaid: " << pp.prepay[(int)Qt::Friday].prepaid << "\n"
 | 
				
			||||||
 | 
					            << "        **** Saturday **** \n"
 | 
				
			||||||
 | 
					            << "         day: " << pp.prepay[(int)Qt::Saturday].day << "\n"
 | 
				
			||||||
 | 
					            << "       start: " << pp.prepay[(int)Qt::Saturday].start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "         end: " << pp.prepay[(int)Qt::Saturday].end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "    duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
 | 
				
			||||||
 | 
					            << "     prepaid: " << pp.prepay[(int)Qt::Saturday].prepaid << "\n"
 | 
				
			||||||
 | 
					            << "        **** Sunday **** \n"
 | 
				
			||||||
 | 
					            << "         day: " << pp.prepay[(int)Qt::Sunday].day << "\n"
 | 
				
			||||||
 | 
					            << "       start: " << pp.prepay[(int)Qt::Sunday].start.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "         end: " << pp.prepay[(int)Qt::Sunday].end.toString(Qt::ISODate) << "\n"
 | 
				
			||||||
 | 
					            << "    duration: " << pp.prepay[(int)Qt::Monday].duration << "\n"
 | 
				
			||||||
 | 
					            << "     prepaid: " << pp.prepay[(int)Qt::Sunday].prepaid << "\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return debug;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // TARIFF_CARRYOVER_H_INCLUDED
 | 
				
			||||||
@@ -1,40 +0,0 @@
 | 
				
			|||||||
#ifndef ATB_TARIFF_SETTINGS_H_INCLUDED
 | 
					 | 
				
			||||||
#define ATB_TARIFF_SETTINGS_H_INCLUDED
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <QDebug>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct ATBTariffSettings {
 | 
					 | 
				
			||||||
    int m_max_price;
 | 
					 | 
				
			||||||
    int m_min_price;
 | 
					 | 
				
			||||||
    int m_max_time;
 | 
					 | 
				
			||||||
    int m_min_time;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    explicit ATBTariffSettings()
 | 
					 | 
				
			||||||
      : m_max_price(0)
 | 
					 | 
				
			||||||
      , m_min_price(0)
 | 
					 | 
				
			||||||
      , m_max_time(0)
 | 
					 | 
				
			||||||
      , m_min_time(0) {
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    explicit ATBTariffSettings(int max_price, int min_price, int max_time, int min_time)
 | 
					 | 
				
			||||||
      : m_max_price(max_price)
 | 
					 | 
				
			||||||
      , m_min_price(min_price)
 | 
					 | 
				
			||||||
      , m_max_time(max_time)
 | 
					 | 
				
			||||||
      , m_min_time(min_time) {
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    friend QDebug operator<<(QDebug debug, ATBTariffSettings const &ts) {
 | 
					 | 
				
			||||||
        QDebugStateSaver saver(debug);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        debug.nospace()
 | 
					 | 
				
			||||||
            << "                max_price: " << ts.m_max_price << "\n"
 | 
					 | 
				
			||||||
            << "                min_price: " << ts.m_min_price << "\n"
 | 
					 | 
				
			||||||
            << "                 max_time: " << ts.m_max_time << "\n"
 | 
					 | 
				
			||||||
            << "                 min_time: " << ts.m_min_time << endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return debug;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif // ATB_TARIFF_SETTINGS_H_INCLUDED
 | 
					 | 
				
			||||||
@@ -6,7 +6,7 @@
 | 
				
			|||||||
#include <QDebugStateSaver>
 | 
					#include <QDebugStateSaver>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct ATBTimeStepConfig {
 | 
					struct ATBTimeStepConfig {
 | 
				
			||||||
    enum class TimeStepConfig {STATIC=1, DYNAMIC=2};
 | 
					    enum class TimeStepConfig {STATIC=1, DYNAMIC=2, RECOMPUTE_SOME=3};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ATBTimeStepConfig() = default;
 | 
					    ATBTimeStepConfig() = default;
 | 
				
			||||||
    int tsconfig_id;
 | 
					    int tsconfig_id;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,57 +1,10 @@
 | 
				
			|||||||
#include "tariff_settings.h"
 | 
					#pragma once
 | 
				
			||||||
#include "tariff_carryover_settings.h"
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QString>
 | 
					class ATBWeekDays
 | 
				
			||||||
#include <Qt>
 | 
					{
 | 
				
			||||||
#include <QDate>
 | 
					public:
 | 
				
			||||||
 | 
						int pdiw_id;
 | 
				
			||||||
struct ATBWeekDay {
 | 
						std::string pdiw_label;
 | 
				
			||||||
    enum WeekDayType {USUAL_WEEKDAY=0, HOLIDAY=1};
 | 
						int pdiw_index;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    Qt::DayOfWeek m_id;
 | 
					 | 
				
			||||||
    QString m_name;
 | 
					 | 
				
			||||||
    QDate m_date;
 | 
					 | 
				
			||||||
    WeekDayType m_type;
 | 
					 | 
				
			||||||
    ATBTariffSettings m_tariffSettings;
 | 
					 | 
				
			||||||
    ATBTariffCarryOverSettings m_tariffCarryOverSettings;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    explicit ATBWeekDay()
 | 
					 | 
				
			||||||
        : m_id(Qt::Monday)
 | 
					 | 
				
			||||||
        , m_name("")
 | 
					 | 
				
			||||||
        , m_date(QDate())
 | 
					 | 
				
			||||||
        , m_type(USUAL_WEEKDAY)
 | 
					 | 
				
			||||||
        , m_tariffSettings()
 | 
					 | 
				
			||||||
        , m_tariffCarryOverSettings() {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    explicit ATBWeekDay(Qt::DayOfWeek id, QString const &name, WeekDayType type,
 | 
					 | 
				
			||||||
                        QDate const &date,
 | 
					 | 
				
			||||||
                        ATBTariffSettings const &tariffSettings,
 | 
					 | 
				
			||||||
                        ATBTariffCarryOverSettings const &tariffCarryOverSettings)
 | 
					 | 
				
			||||||
        : m_id(id)
 | 
					 | 
				
			||||||
        , m_name(name)
 | 
					 | 
				
			||||||
        , m_date(date)
 | 
					 | 
				
			||||||
        , m_type(type)
 | 
					 | 
				
			||||||
        , m_tariffSettings(tariffSettings)
 | 
					 | 
				
			||||||
        , m_tariffCarryOverSettings(tariffCarryOverSettings) {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ATBTariffCarryOverSettings &getTariffCarryOverSettings() { return m_tariffCarryOverSettings; }
 | 
					 | 
				
			||||||
    ATBTariffCarryOverSettings const &getTariffCarryOverSettings() const { return m_tariffCarryOverSettings; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ATBTariffSettings &getTariffSettings() { return m_tariffSettings; }
 | 
					 | 
				
			||||||
    ATBTariffSettings const &getTariffSettings() const { return m_tariffSettings; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    friend QDebug operator<<(QDebug debug, ATBWeekDay const &wd) {
 | 
					 | 
				
			||||||
        QDebugStateSaver saver(debug);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        debug.nospace()
 | 
					 | 
				
			||||||
            << "                       id: " << (int)wd.m_id << "\n"
 | 
					 | 
				
			||||||
            << "                     name: " << wd.m_name << "\n"
 | 
					 | 
				
			||||||
            << "                     type: " << (int)wd.m_type << "\n\n"
 | 
					 | 
				
			||||||
            << "          tariff settings: " << "\n"
 | 
					 | 
				
			||||||
                                             << wd.m_tariffSettings << "\n"
 | 
					 | 
				
			||||||
            << "tariff carryover settings: " << "\n"
 | 
					 | 
				
			||||||
                                             << wd.m_tariffCarryOverSettings << endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return debug;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@@ -38,24 +38,24 @@ SOURCES += \
 | 
				
			|||||||
    src/tariff_global_defines.cpp
 | 
					    src/tariff_global_defines.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HEADERS += \
 | 
					HEADERS += \
 | 
				
			||||||
	include/mobilisis/calculator_functions.h \
 | 
					    include/mobilisis/calculator_functions.h \
 | 
				
			||||||
	include/mobilisis/duration.h \
 | 
					    include/mobilisis/duration.h \
 | 
				
			||||||
	include/mobilisis/payment_opt.h \
 | 
					    include/mobilisis/payment_opt.h \
 | 
				
			||||||
	include/mobilisis/spec_days.h \
 | 
					    include/mobilisis/spec_days.h \
 | 
				
			||||||
	include/mobilisis/utilities.h \
 | 
					    include/mobilisis/utilities.h \
 | 
				
			||||||
	include/mobilisis/configuration.h \
 | 
					    include/mobilisis/configuration.h \
 | 
				
			||||||
	include/mobilisis/member_type.h \
 | 
					    include/mobilisis/member_type.h \
 | 
				
			||||||
	include/mobilisis/payment_option.h \
 | 
					    include/mobilisis/payment_option.h \
 | 
				
			||||||
	include/mobilisis/spec_days_worktime.h \
 | 
					    include/mobilisis/spec_days_worktime.h \
 | 
				
			||||||
	include/mobilisis/weekdays.h \
 | 
					    include/mobilisis/weekdays.h \
 | 
				
			||||||
	include/mobilisis/currency.h \
 | 
					    include/mobilisis/currency.h \
 | 
				
			||||||
	include/mobilisis/payment_method.h \
 | 
					    include/mobilisis/payment_method.h \
 | 
				
			||||||
	include/mobilisis/payment_rate.h \
 | 
					    include/mobilisis/payment_rate.h \
 | 
				
			||||||
	include/mobilisis/time_range.h \
 | 
					    include/mobilisis/time_range.h \
 | 
				
			||||||
	include/mobilisis/weekdays_worktime.h \
 | 
					    include/mobilisis/weekdays_worktime.h \
 | 
				
			||||||
	include/mobilisis/day_of_week.h \
 | 
					    include/mobilisis/day_of_week.h \
 | 
				
			||||||
	include/mobilisis/payment_mtd.h \
 | 
					    include/mobilisis/payment_mtd.h \
 | 
				
			||||||
	include/mobilisis/period_year.h \
 | 
					    include/mobilisis/period_year.h \
 | 
				
			||||||
    include/mobilisis/time_range_header.h \
 | 
					    include/mobilisis/time_range_header.h \
 | 
				
			||||||
    include/mobilisis/tariff_cfg.h \
 | 
					    include/mobilisis/tariff_cfg.h \
 | 
				
			||||||
    include/mobilisis/tariff_calc.h \
 | 
					    include/mobilisis/tariff_calc.h \
 | 
				
			||||||
@@ -89,12 +89,14 @@ HEADERS += \
 | 
				
			|||||||
    include/mobilisis/tariff_interpolation.h \
 | 
					    include/mobilisis/tariff_interpolation.h \
 | 
				
			||||||
    include/mobilisis/tariff_prepaid.h \
 | 
					    include/mobilisis/tariff_prepaid.h \
 | 
				
			||||||
    include/mobilisis/tariff_carryover.h \
 | 
					    include/mobilisis/tariff_carryover.h \
 | 
				
			||||||
 | 
					    include/mobilisis/tariff_prepay.h \
 | 
				
			||||||
    include/mobilisis/tariff_global_defines.h
 | 
					    include/mobilisis/tariff_global_defines.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
OTHER_FILES += src/main.cpp \
 | 
					# OTHER_FILES += src/main.cpp \
 | 
				
			||||||
    ../tariffs/tariff_korneuburg.json \
 | 
					#    ../tariffs/tariff_korneuburg.json \
 | 
				
			||||||
    ../tariffs/tariff_linsinger_maschinenbau.json \
 | 
					#    ../tariffs/tariff_linsinger_maschinenbau.json \
 | 
				
			||||||
    ../tariffs/tariff_naz.json
 | 
					#    ../tariffs/tariff_naz.json \
 | 
				
			||||||
 | 
					#    /home/linux/customer_502/etc/psa_tariff/tariff03.json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Default rules for deployment.
 | 
					# Default rules for deployment.
 | 
				
			||||||
qnx: target.path = /tmp/$${TARGET}/bin
 | 
					qnx: target.path = /tmp/$${TARGET}/bin
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,10 +36,7 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
 | 
				
			|||||||
                                                  int paymentOptionIndex) {
 | 
					                                                  int paymentOptionIndex) {
 | 
				
			||||||
    int minTime = 0;
 | 
					    int minTime = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    paymentOptionIndex = getPaymentOptionIndex(*cfg);
 | 
					    paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					 | 
				
			||||||
        paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
 | 
					    qCritical() << __func__ << __LINE__ << "paymentOptionIndex" << paymentOptionIndex;
 | 
				
			||||||
    qCritical() << __func__ << __LINE__ << "permit" << PermitType(permitType).toString();
 | 
					    qCritical() << __func__ << __LINE__ << "permit" << PermitType(permitType).toString();
 | 
				
			||||||
@@ -72,10 +69,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
 | 
				
			|||||||
                                                  PERMIT_TYPE permitType,
 | 
					                                                  PERMIT_TYPE permitType,
 | 
				
			||||||
                                                  int paymentOptionIndex) {
 | 
					                                                  int paymentOptionIndex) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    paymentOptionIndex = getPaymentOptionIndex(*cfg);
 | 
					    paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					 | 
				
			||||||
        paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    int maxTime = 0;
 | 
					    int maxTime = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch(permitType) {
 | 
					    switch(permitType) {
 | 
				
			||||||
@@ -100,10 +94,7 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
 | 
				
			|||||||
                                                   int paymentOptionIndex,
 | 
					                                                   int paymentOptionIndex,
 | 
				
			||||||
                                                   QDateTime const &start) {
 | 
					                                                   QDateTime const &start) {
 | 
				
			||||||
    int minPrice = -1;
 | 
					    int minPrice = -1;
 | 
				
			||||||
 | 
					    paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
				
			||||||
    if ((paymentOptionIndex = getPaymentOptionIndex(*cfg, start)) == -1) {
 | 
					 | 
				
			||||||
        paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int payment_method_id = cfg->getPaymentOptions(paymentOptionIndex).pop_payment_method_id;
 | 
					    int payment_method_id = cfg->getPaymentOptions(paymentOptionIndex).pop_payment_method_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -330,16 +321,14 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
 | 
				
			|||||||
    int maxPrice = -1;
 | 
					    int maxPrice = -1;
 | 
				
			||||||
    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
					    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((paymentOptionIndex = getPaymentOptionIndex(*cfg)) == -1) {
 | 
					    paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
				
			||||||
        paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch(permitType) {
 | 
					    switch(permitType) {
 | 
				
			||||||
    case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
 | 
					    case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
 | 
				
			||||||
        if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
 | 
					        if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
 | 
				
			||||||
            //maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
 | 
					            maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
 | 
				
			||||||
            ATBPaymentOption const &po = cfg->getPaymentOptions(paymentOptionIndex);
 | 
					        } else if (paymentMethodId == PaymentMethod::Degressive) {
 | 
				
			||||||
            maxPrice = po.pop_max_price; // maxTime is given in minutes
 | 
					            maxPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
 | 
				
			||||||
        } else { // PaymentMethod::Linear -> e.g. szeged
 | 
					        } else { // PaymentMethod::Linear -> e.g. szeged
 | 
				
			||||||
            int const key = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
					            int const key = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
				
			||||||
            int const maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time; // maxTime is given in minutes
 | 
					            int const maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time; // maxTime is given in minutes
 | 
				
			||||||
@@ -487,11 +476,7 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
 | 
				
			|||||||
    //    return currentTimeMinutes;
 | 
					    //    return currentTimeMinutes;
 | 
				
			||||||
    //}
 | 
					    //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int paymentOptionIndex = getPaymentOptionIndex(*tariff);
 | 
					    int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					 | 
				
			||||||
        paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    int const &pop_plus_steps = tariff->getPaymentOptions(paymentOptionIndex).pop_plus_steps;
 | 
					    int const &pop_plus_steps = tariff->getPaymentOptions(paymentOptionIndex).pop_plus_steps;
 | 
				
			||||||
    int const &pop_minus_steps = tariff->getPaymentOptions(paymentOptionIndex).pop_minus_steps;
 | 
					    int const &pop_minus_steps = tariff->getPaymentOptions(paymentOptionIndex).pop_minus_steps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -556,7 +541,7 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            // max. tolerance set to 3 minutes
 | 
					            // max. tolerance set to 3 minutes
 | 
				
			||||||
            // unsigned const tolerance = std::min(minimalDistance, (unsigned)(3));
 | 
					            unsigned const tolerance = std::min(minimalDistance, (unsigned)(3));
 | 
				
			||||||
            if (j != -1) {
 | 
					            if (j != -1) {
 | 
				
			||||||
                stepList[j] = currentTimeMinutes;
 | 
					                stepList[j] = currentTimeMinutes;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -671,16 +656,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    CalcState calcState;
 | 
					    CalcState calcState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QDate const d(1970, 1, 1);
 | 
					    int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
 | 
				
			||||||
    QTime const t(0, 0, 0);
 | 
					 | 
				
			||||||
    QDateTime start(d, t, Qt::UTC);
 | 
					 | 
				
			||||||
    start = start.toLocalTime().addSecs(start_parking_time * 60);
 | 
					 | 
				
			||||||
    QDateTime end(start);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    int paymentOptionIndex = getPaymentOptionIndex(*tariff, start);
 | 
					 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					 | 
				
			||||||
        paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    double minMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_min_time;
 | 
					    double minMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_min_time;
 | 
				
			||||||
    double maxMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_max_time;
 | 
					    double maxMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_max_time;
 | 
				
			||||||
@@ -708,11 +684,11 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
        return calcState.set(CalcState::State::SUCCESS);
 | 
					        return calcState.set(CalcState::State::SUCCESS);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //QDate const d(1970, 1, 1);
 | 
					    QDate const d(1970, 1, 1);
 | 
				
			||||||
    //QTime const t(0, 0, 0);
 | 
					    QTime const t(0, 0, 0);
 | 
				
			||||||
    //QDateTime start(d, t, Qt::UTC);
 | 
					    QDateTime start(d, t, Qt::UTC);
 | 
				
			||||||
    //start = start.toLocalTime().addSecs(start_parking_time * 60);
 | 
					    start = start.toLocalTime().addSecs(start_parking_time * 60);
 | 
				
			||||||
    //QDateTime end(start);
 | 
					    QDateTime end(start);
 | 
				
			||||||
    if (start.isValid()) {
 | 
					    if (start.isValid()) {
 | 
				
			||||||
        double cost = Calculator::GetInstance().GetCostFromDuration(
 | 
					        double cost = Calculator::GetInstance().GetCostFromDuration(
 | 
				
			||||||
                    tariff,
 | 
					                    tariff,
 | 
				
			||||||
@@ -747,10 +723,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    QDateTime start_parking_time(start_parking_time_);
 | 
					    QDateTime start_parking_time(start_parking_time_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int paymentOptionIndex = getPaymentOptionIndex(*tariff, start_parking_time);
 | 
					    int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					 | 
				
			||||||
        paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
					    double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
				
			||||||
    double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
					    double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
				
			||||||
@@ -797,7 +770,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
                return calcState;
 | 
					                return calcState;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff);
 | 
					            QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex, start_parking_time_);
 | 
				
			||||||
            Q_UNUSED(tlist);
 | 
					            Q_UNUSED(tlist);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // compute cost (price)
 | 
					            // compute cost (price)
 | 
				
			||||||
@@ -805,141 +778,51 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            int weekDay = start_parking_time.date().dayOfWeek();
 | 
					            int weekDay = start_parking_time.date().dayOfWeek();
 | 
				
			||||||
            int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
 | 
					            int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
 | 
				
			||||||
            int pop_prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
					            qCritical() << __func__ << __LINE__ << "configured carry-over-id" << pop_carry_over_option_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
 | 
					            std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
 | 
				
			||||||
            int period_id = -1;
 | 
					 | 
				
			||||||
            if (yperiod.has_value()) {
 | 
					            if (yperiod.has_value()) {
 | 
				
			||||||
                ATBPeriodYear const &period = yperiod.value();
 | 
					                ATBPeriodYear const &period = yperiod.value();
 | 
				
			||||||
                period_id = period.pye_id;
 | 
					 | 
				
			||||||
                pop_carry_over_option_id = period.pye_id;
 | 
					                pop_carry_over_option_id = period.pye_id;
 | 
				
			||||||
                pop_prepaid_option_id = period.pye_id;
 | 
					                qCritical() << __func__ << __LINE__ << "re-computed carry-over-id" << pop_carry_over_option_id;
 | 
				
			||||||
                qCritical() << __func__ << ":" << __LINE__ << "re-computed carry-over-id" << pop_carry_over_option_id;
 | 
					 | 
				
			||||||
                qCritical() << __func__ << ":" << __LINE__ << "   re-computed prepaid-id" << pop_prepaid_option_id;
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QDateTime effectiveStartTime(start_parking_time);
 | 
					            QTime const carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
 | 
				
			||||||
 | 
					            int const carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // handle special days
 | 
					            qCritical() << __func__ << __LINE__ << "carryOverStart" << carryOverStart.toString(Qt::ISODate);
 | 
				
			||||||
            int const specialDayId = tariff->specialDayId(start_parking_time);
 | 
					            qCritical() << __func__ << __LINE__ << "carryOverDuration" << carryOverDuration;
 | 
				
			||||||
            if (specialDayId > 0) { // found special day
 | 
					 | 
				
			||||||
                for (auto[itr, rangeEnd] = tariff->SpecialDaysWorktime.equal_range(specialDayId); itr != rangeEnd; ++itr) {
 | 
					 | 
				
			||||||
                    ATBSpecialDaysWorktime const &wt = itr->second;
 | 
					 | 
				
			||||||
                    switch(period_id) {
 | 
					 | 
				
			||||||
                    case 1: // summer term
 | 
					 | 
				
			||||||
                        if ((wt.pedwt_paid & 1) == 0) {
 | 
					 | 
				
			||||||
                            // does not have to be paid, move to next midnight
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            // better: start of next day (falls kein vorkauf besteht)
 | 
					 | 
				
			||||||
                            effectiveStartTime = effectiveStartTime.addDays(1);
 | 
					 | 
				
			||||||
                            effectiveStartTime.setTime(QTime(0, 0, 0));
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    case 2: // winter term
 | 
					 | 
				
			||||||
                        if ((wt.pedwt_paid & 2) == 0) {
 | 
					 | 
				
			||||||
                            // does not have to be paid, move to next midnight
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            // better: start of next day (falls kein vorkauf besteht)
 | 
					 | 
				
			||||||
                            effectiveStartTime = effectiveStartTime.addDays(1);
 | 
					 | 
				
			||||||
                            effectiveStartTime.setTime(QTime(0, 0, 0));
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    default:;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // handle prepaid option
 | 
					            // handle prepaid option
 | 
				
			||||||
 | 
					            QDateTime effectiveStartTime(start_parking_time);
 | 
				
			||||||
            int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
					            int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
				
			||||||
            std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
 | 
					            std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
 | 
				
			||||||
            if (prepaidOption.has_value()) {
 | 
					            if (prepaidOption.has_value()) {
 | 
				
			||||||
                ATBPrepaid const &p = prepaidOption.value();
 | 
					                ATBPrepaid const &p = prepaidOption.value();
 | 
				
			||||||
                if (p.never) {
 | 
					                if (p.never) {
 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "prepaid: no";
 | 
					                    qCritical() << __func__ << __LINE__ << "prepaid: no";
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "    prepaidStart" << p.prepaid[weekDay].static_start.toString(Qt::ISODate);
 | 
					                    if (start_parking_time.time() < p.static_end) {     // static_end: e.g. 08:00:00
 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "      prepaidEnd" << p.prepaid[weekDay].static_end.toString(Qt::ISODate);
 | 
					                        effectiveStartTime.setTime(p.static_end);
 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "prepaid duration" << p.prepaid[weekDay].duration;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    if (start_parking_time.time() < p.prepaid[weekDay].static_end) {     // static_end: e.g. 08:00:00
 | 
					 | 
				
			||||||
                        effectiveStartTime.setTime(p.prepaid[weekDay].static_end);
 | 
					 | 
				
			||||||
                    } else
 | 
					                    } else
 | 
				
			||||||
                    if (start_parking_time.time() > p.prepaid[weekDay].static_start) {   // static_start: e.g. 22:00:00
 | 
					                    if (start_parking_time.time() > p.static_start) {   // static_start: e.g. 22:00:00
 | 
				
			||||||
                        effectiveStartTime.setTime(p.prepaid[weekDay].static_start);
 | 
					                        effectiveStartTime.setTime(p.static_start);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            qCritical() << __func__ << ":" << __LINE__ << "effectiveStartTime:" << effectiveStartTime.toString(Qt::ISODate);
 | 
					            // handle carry over
 | 
				
			||||||
 | 
					            int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
 | 
				
			||||||
            int const carryOver = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over;
 | 
					            if (netto_parking_time > minutesUntilCarryOver) {
 | 
				
			||||||
 | 
					                int const rest = netto_parking_time - minutesUntilCarryOver;
 | 
				
			||||||
            qCritical() << __func__ << ":" << __LINE__ << "   carryOver flag" << carryOver;
 | 
					                QDateTime s(effectiveStartTime);
 | 
				
			||||||
 | 
					                s = s.addSecs(minutesUntilCarryOver * 60);
 | 
				
			||||||
            if (carryOver == 1) {
 | 
					                s = s.addSecs(carryOverDuration * 60);
 | 
				
			||||||
                QTime carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
 | 
					                end_parking_time = s.addSecs(rest * 60);
 | 
				
			||||||
                int carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                qCritical() << __func__ << ":" << __LINE__ << "   carryOverStart" << carryOverStart.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                qCritical() << __func__ << ":" << __LINE__ << "carryOverDuration" << carryOverDuration;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                // handle carry over
 | 
					 | 
				
			||||||
                int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
 | 
					 | 
				
			||||||
                if (netto_parking_time > minutesUntilCarryOver) {
 | 
					 | 
				
			||||||
                    int const rest = netto_parking_time - minutesUntilCarryOver;
 | 
					 | 
				
			||||||
                    QDateTime s(effectiveStartTime);
 | 
					 | 
				
			||||||
                    s = s.addSecs(minutesUntilCarryOver * 60);
 | 
					 | 
				
			||||||
                    s = s.addSecs(carryOverDuration * 60);
 | 
					 | 
				
			||||||
                    end_parking_time = s.addSecs(rest * 60);
 | 
					 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                    end_parking_time = effectiveStartTime.addSecs(netto_parking_time*60);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                weekDay = end_parking_time.date().dayOfWeek();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                // musste man in einer schleife machen
 | 
					 | 
				
			||||||
                carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
 | 
					 | 
				
			||||||
                carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (end_parking_time.time() > carryOverStart) {
 | 
					 | 
				
			||||||
                    end_parking_time = end_parking_time.addSecs(carryOverDuration * 60);
 | 
					 | 
				
			||||||
                } else
 | 
					 | 
				
			||||||
                if (end_parking_time.time() == carryOverStart) {
 | 
					 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "   carryOverStart" << carryOverStart.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                    ATBPaymentOption const &po = tariff->getPaymentOptions(paymentOptionIndex);
 | 
					 | 
				
			||||||
                    if (po.pop_apply_carry_over_to_ticket_endtime) {
 | 
					 | 
				
			||||||
                        end_parking_time = end_parking_time.addSecs(carryOverDuration * 60);
 | 
					 | 
				
			||||||
                        qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                qCritical() << __func__ << ":" << __LINE__ << "NO carryOver configured";
 | 
					 | 
				
			||||||
                end_parking_time = effectiveStartTime.addSecs(netto_parking_time*60);
 | 
					                end_parking_time = effectiveStartTime.addSecs(netto_parking_time*60);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            end_parking_time.setTime(QTime(end_parking_time.time().hour(),
 | 
					 | 
				
			||||||
                                           end_parking_time.time().minute(), 0));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
            qCritical() << __func__ << ":" << __LINE__ << "        week-day:" << weekDay;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            for (auto[itr, rangeEnd] = tariff->WeekDays.equal_range((Qt::DayOfWeek)weekDay); itr != rangeEnd; ++itr) {
 | 
					 | 
				
			||||||
                ATBWeekDay const &wd = itr->second;
 | 
					 | 
				
			||||||
                bool const parkTimeLimitViolated = wd.getTariffCarryOverSettings().parkingTimeLimitExceeded(effectiveStartTime,
 | 
					 | 
				
			||||||
                                                                                                            end_parking_time,
 | 
					 | 
				
			||||||
                                                                                                            paymentOptionIndex);
 | 
					 | 
				
			||||||
                if (parkTimeLimitViolated) {
 | 
					 | 
				
			||||||
                    //QTime const &tlimit = wd.getTariffCarryOverSettings().parkingTimeLimit();
 | 
					 | 
				
			||||||
                    //end_parking_time.setTime(tlimit);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    calcState.setDesc(QString("line=%1 endTime=%2: park-time-limit violated").arg(__LINE__)
 | 
					 | 
				
			||||||
                                        .arg(end_parking_time.time().toString(Qt::ISODate)));
 | 
					 | 
				
			||||||
                    return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            cost = Calculator::GetInstance().GetCostFromDuration(
 | 
					            cost = Calculator::GetInstance().GetCostFromDuration(
 | 
				
			||||||
                        tariff,
 | 
					                        tariff,
 | 
				
			||||||
@@ -992,12 +875,7 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
        QString cs = start.toString(Qt::ISODate);
 | 
					        QString cs = start.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool prepaid = true;
 | 
					        bool prepaid = true;
 | 
				
			||||||
        int paymentOptionIndex = getPaymentOptionIndex(*tariff, start);
 | 
					        int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
				
			||||||
        qCritical() << " payment option index: " << paymentOptionIndex;
 | 
					 | 
				
			||||||
        if (paymentOptionIndex == -1) {
 | 
					 | 
				
			||||||
            paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
					        int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
				
			||||||
        if (prepaid_option_id == 2) { // see tariff03.json for 502: 2 means no prepaid-option
 | 
					        if (prepaid_option_id == 2) { // see tariff03.json for 502: 2 means no prepaid-option
 | 
				
			||||||
            prepaid = false;
 | 
					            prepaid = false;
 | 
				
			||||||
@@ -1011,14 +889,10 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
        qCritical() << "           start (cs): " << cs;
 | 
					        qCritical() << "           start (cs): " << cs;
 | 
				
			||||||
        qCritical() << "                price: " << price;
 | 
					        qCritical() << "                price: " << price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        std::pair<std::string, QDateTime> p_duration
 | 
					        duration = Calculator::GetInstance().GetDurationFromCost(tariff,
 | 
				
			||||||
                = Calculator::GetInstance().GetDurationFromCost(tariff,
 | 
					                                                  tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id,
 | 
				
			||||||
                    tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id,
 | 
					                                                  cs.toLocal8Bit().constData(),
 | 
				
			||||||
                                              cs.toLocal8Bit().constData(),
 | 
					                                                  price, permitType, nextDay, prepaid).c_str();
 | 
				
			||||||
                                              price, permitType, nextDay, prepaid);
 | 
					 | 
				
			||||||
        duration = p_duration.first.c_str();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        QDateTime d = QDateTime::fromString(duration, Qt::ISODate);
 | 
					        QDateTime d = QDateTime::fromString(duration, Qt::ISODate);
 | 
				
			||||||
        if (!d.isValid()) {
 | 
					        if (!d.isValid()) {
 | 
				
			||||||
            calcState.setDesc(QString("ticketEndTime=%1").arg(duration));
 | 
					            calcState.setDesc(QString("ticketEndTime=%1").arg(duration));
 | 
				
			||||||
@@ -1041,64 +915,31 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
    CalcState calcState;
 | 
					    CalcState calcState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool prepaid = true;
 | 
					    bool prepaid = true;
 | 
				
			||||||
 | 
					    int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
				
			||||||
    int paymentOptionIndex = getPaymentOptionIndex(*tariff, start_parking_time);
 | 
					 | 
				
			||||||
    qCritical() << __func__ << ":" << __LINE__ << "payment option index: " << paymentOptionIndex;
 | 
					 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					 | 
				
			||||||
        paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    qCritical() << __func__ << ":" << __LINE__ << " payment option index: " << paymentOptionIndex;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
					    int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (prepaid_option_id == 2) {
 | 
					    if (prepaid_option_id == 2) {
 | 
				
			||||||
        prepaid = false;
 | 
					        prepaid = false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    bool const nextDay = false;
 | 
					    bool const nextDay = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // DEBUG
 | 
					    // DEBUG
 | 
				
			||||||
    if (DBG_LEVEL >= DBG_DEBUG) {
 | 
					    // if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
        qCritical() << "compute_duration_for_parking_ticket(2): ";
 | 
					        qCritical() << "\ncompute_duration_for_parking_ticket(2):";
 | 
				
			||||||
        qCritical() << " payment option index: " << paymentOptionIndex;
 | 
					        qCritical() << "                              start time:" << start_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
        qCritical() << "              prepaid: " << prepaid;
 | 
					        qCritical() << "                    payment option index:" << paymentOptionIndex;
 | 
				
			||||||
        qCritical() << "                price: " << price;
 | 
					        qCritical() << "                                 prepaid:" << prepaid;
 | 
				
			||||||
    }
 | 
					        qCritical() << "                                   price:" << price;
 | 
				
			||||||
 | 
					        qCritical() << "                             permit type:" << permitType.toString() << endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (start_parking_time.isValid()) {
 | 
					    if (start_parking_time.isValid()) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        int const pop_time_step_config = tariff->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
 | 
					 | 
				
			||||||
        if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::STATIC) {
 | 
					 | 
				
			||||||
            // handle prepaid option
 | 
					 | 
				
			||||||
            QDateTime effectiveStartTime(start_parking_time);
 | 
					 | 
				
			||||||
            int const prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
					 | 
				
			||||||
            std::optional<ATBPrepaid> prepaidOption = tariff->getPrepaidType(prepaid_option_id);
 | 
					 | 
				
			||||||
            if (prepaidOption.has_value()) {
 | 
					 | 
				
			||||||
                ATBPrepaid const &p = prepaidOption.value();
 | 
					 | 
				
			||||||
                if (p.never) {
 | 
					 | 
				
			||||||
                    qCritical() << __func__ << __LINE__ << "prepaid: no";
 | 
					 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                    if (start_parking_time.time() < p.static_end) {     // static_end: e.g. 08:00:00
 | 
					 | 
				
			||||||
                        effectiveStartTime.setTime(p.static_end);
 | 
					 | 
				
			||||||
                    } else
 | 
					 | 
				
			||||||
                    if (start_parking_time.time() > p.static_start) {   // static_start: e.g. 22:00:00
 | 
					 | 
				
			||||||
                        effectiveStartTime.setTime(p.static_start);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        QString cs = start_parking_time.toString(Qt::ISODate);
 | 
					        QString cs = start_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					        QString endTime = Calculator::GetInstance().GetDurationFromCost(
 | 
				
			||||||
        std::pair<std::string, QDateTime> p_endTime
 | 
					 | 
				
			||||||
                = Calculator::GetInstance().GetDurationFromCost(
 | 
					 | 
				
			||||||
                    tariff,
 | 
					                    tariff,
 | 
				
			||||||
                    tariff->getPaymentOptions().pop_payment_method_id,
 | 
					                    tariff->getPaymentOptions().pop_payment_method_id,
 | 
				
			||||||
                    cs.toLocal8Bit().constData(),
 | 
					                    cs.toLocal8Bit().constData(),
 | 
				
			||||||
                    price, permitType, nextDay, prepaid);
 | 
					                    price, permitType, nextDay, prepaid).c_str();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        QString endTime = p_endTime.first.c_str();
 | 
					 | 
				
			||||||
        ticketEndTime = p_endTime.second;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (endTime == CalcState::SUCCESS) {
 | 
					        if (endTime == CalcState::SUCCESS) {
 | 
				
			||||||
            calcState.setDesc(QString("SUCCESS"));
 | 
					            calcState.setDesc(QString("SUCCESS"));
 | 
				
			||||||
@@ -1160,96 +1001,21 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate);
 | 
					            ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
            qCritical() << __func__ << ":" << __LINE__ << "step-config:" << pop_time_step_config;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (!ticketEndTime.isValid()) {
 | 
					            if (!ticketEndTime.isValid()) {
 | 
				
			||||||
                calcState.setDesc(QString("ticketEndTime=%1").arg(endTime));
 | 
					                calcState.setDesc(QString("ticketEndTime=%1").arg(endTime));
 | 
				
			||||||
                return calcState.set(CalcState::State::WRONG_ISO_TIME_FORMAT);
 | 
					                return calcState.set(CalcState::State::WRONG_ISO_TIME_FORMAT);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::STATIC) {
 | 
					 | 
				
			||||||
                // handle carry over for ticket-end-time
 | 
					 | 
				
			||||||
                qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                int weekDay = start_parking_time.date().dayOfWeek();
 | 
					 | 
				
			||||||
                int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
 | 
					 | 
				
			||||||
                qCritical() << __func__ << ":" << __LINE__ << "configured carry-over-id" << pop_carry_over_option_id;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
 | 
					 | 
				
			||||||
                if (yperiod.has_value()) {
 | 
					 | 
				
			||||||
                    ATBPeriodYear const &period = yperiod.value();
 | 
					 | 
				
			||||||
                    pop_carry_over_option_id = period.pye_id;
 | 
					 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "re-computed carry-over-id" << pop_carry_over_option_id;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                QTime carryOverStart;
 | 
					 | 
				
			||||||
                QTime carryOverEnd;
 | 
					 | 
				
			||||||
                int carryOverDuration = -1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                // using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
 | 
					 | 
				
			||||||
                std::multimap<int, ATBCarryOver>::const_iterator it;
 | 
					 | 
				
			||||||
                if ((it = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)) !=
 | 
					 | 
				
			||||||
                    tariff->TariffCarryOverOptions.cend()) {
 | 
					 | 
				
			||||||
                    carryOverStart = it->second.carryover[weekDay].static_start;
 | 
					 | 
				
			||||||
                    carryOverEnd = it->second.carryover[weekDay].static_end;
 | 
					 | 
				
			||||||
                    carryOverDuration = it->second.carryover[weekDay].duration;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (carryOverStart.isValid() && carryOverEnd.isValid()) {
 | 
					 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "carryOverStart" << carryOverStart.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "carryOverEnd" << carryOverEnd.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "carryOverDuration" << carryOverDuration;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (carryOverStart.isValid() && carryOverEnd.isValid() && carryOverDuration != -1) {
 | 
					 | 
				
			||||||
                    // qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                    if (ticketEndTime.time() > carryOverStart) {
 | 
					 | 
				
			||||||
                        // qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                        ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
 | 
					 | 
				
			||||||
                    } else {
 | 
					 | 
				
			||||||
                        // qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                        if (ticketEndTime.time() < carryOverEnd) {
 | 
					 | 
				
			||||||
                            // qCritical() << __func__ << __LINE__ << "ticketEndTime.time():" << ticketEndTime.time().toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                            ticketEndTime = ticketEndTime.addSecs(carryOverDuration * 60);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                    qCritical() << __func__ << ":" << __LINE__ << "WARNING: wrong carry-over-settings";
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ticketEndTime.setTime(QTime(ticketEndTime.time().hour(),
 | 
					 | 
				
			||||||
                                        ticketEndTime.time().minute(), 0));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            for (auto[itr, rangeEnd] = tariff->WeekDays.equal_range((Qt::DayOfWeek)(ticketEndTime.date().dayOfWeek()));
 | 
					 | 
				
			||||||
                 itr != rangeEnd;
 | 
					 | 
				
			||||||
                 ++itr) {
 | 
					 | 
				
			||||||
                ATBWeekDay const &wd = itr->second;
 | 
					 | 
				
			||||||
                bool const parkTimeLimitViolated = wd.getTariffCarryOverSettings().parkingTimeLimitExceeded(start_parking_time,
 | 
					 | 
				
			||||||
                                                                                                            ticketEndTime,
 | 
					 | 
				
			||||||
                                                                                                            paymentOptionIndex);
 | 
					 | 
				
			||||||
                if (parkTimeLimitViolated) {
 | 
					 | 
				
			||||||
                    //QTime const &tlimit = wd.getTariffCarryOverSettings().parkingTimeLimit();
 | 
					 | 
				
			||||||
                    //ticketEndTime.setTime(tlimit);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    calcState.setDesc(QString("line=%1 endTime=%2: park-time-limit violated").arg(__LINE__)
 | 
					 | 
				
			||||||
                                      .arg(ticketEndTime.time().toString(Qt::ISODate)));
 | 
					 | 
				
			||||||
                    return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ticketEndTime.time().hour() == 0 && ticketEndTime.time().minute() == 0) {
 | 
					            if (ticketEndTime.time().hour() == 0 && ticketEndTime.time().minute() == 0) {
 | 
				
			||||||
                ticketEndTime = ticketEndTime.addDays(-1);
 | 
					                ticketEndTime = ticketEndTime.addDays(-1);
 | 
				
			||||||
                ticketEndTime.setTime(QTime(23, 59, 0));
 | 
					                ticketEndTime.setTime(QTime(23, 59, 0));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // DEBUG
 | 
					            // DEBUG
 | 
				
			||||||
            qCritical() << __func__ << ":" << __LINE__ << "      endTime:" << endTime;
 | 
					            qCritical() << "\ncompute_duration_for_parking_ticket():";
 | 
				
			||||||
            qCritical() << __func__ << ":" << __LINE__ << "ticketEndTime:" << ticketEndTime.toString(Qt::ISODate);
 | 
					            qCritical() << "                           start time:" << start_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					            qCritical() << "                              endTime:" << endTime;
 | 
				
			||||||
 | 
					            qCritical() << "                        ticketEndTime:" << ticketEndTime.toString(Qt::ISODate) << endl;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        return calcState.set(CalcState::State::INVALID_START_DATE);
 | 
					        return calcState.set(CalcState::State::INVALID_START_DATE);
 | 
				
			||||||
@@ -1261,7 +1027,7 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff,
 | 
					CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff,
 | 
				
			||||||
                                                                  QDateTime const &start_parking_time,
 | 
					                                                                  QDateTime const &start_parking_time,
 | 
				
			||||||
                                                                  QDateTime &ticketEndTime,
 | 
					                                                                  QDateTime &ticketEndTime,
 | 
				
			||||||
                                                                  PermitType /* PermitType */)
 | 
					                                                                  PermitType PermitType)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    CalcState calcState;
 | 
					    CalcState calcState;
 | 
				
			||||||
    if (start_parking_time.isValid()) {
 | 
					    if (start_parking_time.isValid()) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,9 +10,12 @@
 | 
				
			|||||||
#include <sstream>
 | 
					#include <sstream>
 | 
				
			||||||
#include <algorithm>
 | 
					#include <algorithm>
 | 
				
			||||||
#include <optional>
 | 
					#include <optional>
 | 
				
			||||||
 | 
					#include <iterator>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QDateTime>
 | 
					#include <QDateTime>
 | 
				
			||||||
#include <QScopedArrayPointer>
 | 
					#include <QScopedArrayPointer>
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					#include <QTimeZone>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double total_duration_min = 0.0f;
 | 
					double total_duration_min = 0.0f;
 | 
				
			||||||
double total_cost = 0.0f;
 | 
					double total_cost = 0.0f;
 | 
				
			||||||
@@ -118,14 +121,13 @@ QDateTime Calculator::GetDailyTicketDuration(Configuration* cfg, const QDateTime
 | 
				
			|||||||
    return QDateTime();
 | 
					    return QDateTime();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/// <inheritdoc/>
 | 
					/// <inheritdoc/>
 | 
				
			||||||
std::pair<std::string, QDateTime>
 | 
					std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			||||||
Calculator::GetDurationFromCost(Configuration* cfg,
 | 
					                                            uint8_t payment_option,
 | 
				
			||||||
                                uint8_t payment_option,
 | 
					                                            char const *startDatetimePassed, // given in local time
 | 
				
			||||||
                                char const *startDatetimePassed, // given in local time
 | 
					                                            double cost,
 | 
				
			||||||
                                double cost,
 | 
					                                            PermitType permitType,
 | 
				
			||||||
                                PermitType /*permitType*/,
 | 
					                                            bool nextDay,
 | 
				
			||||||
                                bool nextDay,
 | 
					                                            bool prepaid)
 | 
				
			||||||
                                bool prepaid)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Q_UNUSED(payment_option);
 | 
					    Q_UNUSED(payment_option);
 | 
				
			||||||
    Q_UNUSED(nextDay);
 | 
					    Q_UNUSED(nextDay);
 | 
				
			||||||
@@ -134,15 +136,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
    QDateTime inputDate = QDateTime::fromString(startDatetimePassed, Qt::ISODate);
 | 
					    QDateTime inputDate = QDateTime::fromString(startDatetimePassed, Qt::ISODate);
 | 
				
			||||||
    inputDate.setTime(QTime(inputDate.time().hour(), inputDate.time().minute(), 0));
 | 
					    inputDate.setTime(QTime(inputDate.time().hour(), inputDate.time().minute(), 0));
 | 
				
			||||||
    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
					    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
				
			||||||
 | 
					    int const paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get());
 | 
				
			||||||
    bool overPaid = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    int paymentOptionIndex = getPaymentOptionIndex(*cfg, inputDate);
 | 
					 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					 | 
				
			||||||
        paymentOptionIndex = cfg->getPaymentOptionIndex(QDateTime::fromString(startDatetimePassed, Qt::ISODate));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    qCritical() << DBG_HEADER << "   option index:" << paymentOptionIndex;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (DBG_LEVEL >= DBG_DEBUG) {
 | 
					    if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
        qCritical() << DBG_HEADER << "          start:" << inputDate.toString(Qt::ISODate);
 | 
					        qCritical() << DBG_HEADER << "          start:" << inputDate.toString(Qt::ISODate);
 | 
				
			||||||
@@ -165,10 +159,11 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
            // minimal price is set by GetTimeSteps()
 | 
					            // minimal price is set by GetTimeSteps()
 | 
				
			||||||
            qCritical() << DBG_HEADER << "   provided price (cost):" << cost;
 | 
					            qCritical() << DBG_HEADER << "   provided price (cost):" << cost;
 | 
				
			||||||
            qCritical() << DBG_HEADER << "configured minimal price:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
					            qCritical() << DBG_HEADER << "configured minimal price:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
				
			||||||
            return std::make_pair(CalcState::BELOW_MIN_PARKING_PRICE.toStdString(), QDateTime());
 | 
					            return CalcState::BELOW_MIN_PARKING_PRICE.toStdString();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (prepaid == false) {
 | 
					        int const pop_time_step_config = cfg->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
 | 
				
			||||||
 | 
					        if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::RECOMPUTE_SOME || prepaid == false) {
 | 
				
			||||||
            int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
					            int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
				
			||||||
            int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
 | 
					            int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
 | 
				
			||||||
            int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
 | 
					            int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
 | 
				
			||||||
@@ -183,6 +178,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
 | 
					            for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
 | 
				
			||||||
                int const pra_price = itr->second.pra_price;
 | 
					                int const pra_price = itr->second.pra_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // qCritical() << DBG_HEADER << "pra_price" << pra_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                int const durationId = itr->second.pra_payment_unit_id;
 | 
					                int const durationId = itr->second.pra_payment_unit_id;
 | 
				
			||||||
                if (pop_accumulate_prices) {
 | 
					                if (pop_accumulate_prices) {
 | 
				
			||||||
                    price += pra_price;
 | 
					                    price += pra_price;
 | 
				
			||||||
@@ -200,7 +198,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                    ATBDuration duration = search->second;
 | 
					                    ATBDuration duration = search->second;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (pop_accumulate_prices) {
 | 
					                    if (pop_accumulate_prices) {
 | 
				
			||||||
                        uint32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
 | 
					                        int32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        // qCritical() << DBG_HEADER << "  duration unit" << durationUnit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        new_price += pra_price;
 | 
					                        new_price += pra_price;
 | 
				
			||||||
                        // qCritical() << "(" << __func__ << ":" << __LINE__ << ")  old price" << price << ", new_price:" << new_price;
 | 
					                        // qCritical() << "(" << __func__ << ":" << __LINE__ << ")  old price" << price << ", new_price:" << new_price;
 | 
				
			||||||
@@ -228,9 +228,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                            qCritical() << DBG_HEADER << "           minimal parking time (minutes):" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
					                            qCritical() << DBG_HEADER << "           minimal parking time (minutes):" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if (duration_previous < cfg->getPaymentOptions(paymentOptionIndex).pop_min_time) {
 | 
					                            if (duration_previous < cfg->getPaymentOptions(paymentOptionIndex).pop_min_time) {
 | 
				
			||||||
                                return std::make_pair(CalcState::BELOW_MIN_PARKING_TIME.toStdString(), d); // minimal parking time is set by GetTimeSteps()
 | 
					                                return CalcState::BELOW_MIN_PARKING_TIME.toStdString(); // minimal parking time is set by GetTimeSteps()
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            return std::make_pair(d.toString(Qt::ISODate).toStdString(), d);
 | 
					                            return d.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -243,7 +243,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                        qCritical() << DBG_HEADER << "   provided price (cost):" << cost;
 | 
					                        qCritical() << DBG_HEADER << "   provided price (cost):" << cost;
 | 
				
			||||||
                        qCritical() << DBG_HEADER << "      duration for price:" << durationStr;
 | 
					                        qCritical() << DBG_HEADER << "      duration for price:" << durationStr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        return std::make_pair(durationStr.toStdString(), d);
 | 
					                        return durationStr.toStdString();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -257,35 +257,30 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
            // use tariff with structure as for instance Schoenau, Koenigsee:
 | 
					            // use tariff with structure as for instance Schoenau, Koenigsee:
 | 
				
			||||||
            // without given YearPeriod, SpecialDays and SpecialDaysWorktime
 | 
					            // without given YearPeriod, SpecialDays and SpecialDaysWorktime
 | 
				
			||||||
            inputDate = inputDate.addSecs(GetDurationForPrice(cfg, cost) * 60);
 | 
					            inputDate = inputDate.addSecs(GetDurationForPrice(cfg, cost) * 60);
 | 
				
			||||||
            return std::make_pair(inputDate.toString(Qt::ISODate).toStdString(), inputDate);
 | 
					            return inputDate.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            if (Utilities::IsYearPeriodActive(cfg, inputDate)) {
 | 
					            if (Utilities::IsYearPeriodActive(cfg, inputDate)) {
 | 
				
			||||||
                if (!prepaid) {
 | 
					                if (!prepaid) {
 | 
				
			||||||
                    CalcState cs = isParkingAllowed(cfg, inputDate);
 | 
					                    CalcState cs = isParkingAllowed(cfg, inputDate);
 | 
				
			||||||
                    if (cs) {
 | 
					                    if (cs) {
 | 
				
			||||||
                        inputDate.setTime(cs.getAllowedTimeRange().getTimeUntil());
 | 
					                        inputDate.setTime(cs.getAllowedTimeRange().getTimeUntil());
 | 
				
			||||||
                        return std::make_pair(inputDate.toString(Qt::ISODate).toStdString(), inputDate);
 | 
					                        return inputDate.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
					                int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
				
			||||||
                int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
 | 
					                int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
 | 
				
			||||||
                int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
					                int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
				
			||||||
                int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (cost > pop_max_price) {
 | 
					                if (cost > pop_max_price) {
 | 
				
			||||||
                    qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
 | 
					 | 
				
			||||||
                    if (pop_allow_overpay == false) {
 | 
					 | 
				
			||||||
                        return std::make_pair(CalcState::OVERPAID.toStdString(), QDateTime());
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    cost = pop_max_price;
 | 
					                    cost = pop_max_price;
 | 
				
			||||||
                    overPaid = true;
 | 
					                    qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
 | 
				
			||||||
                    // return CalcState::OVERPAID.toStdString();
 | 
					                    //return CalcState::OVERPAID.toStdString();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (cost < pop_min_price) {
 | 
					                if (cost < pop_min_price) {
 | 
				
			||||||
                    qCritical() << DBG_HEADER << "MIN-PARKING-PRICE" << pop_min_price << ", COST" << cost;
 | 
					                    qCritical() << DBG_HEADER << "MIN-PARKING-PRICE" << pop_min_price << ", COST" << cost;
 | 
				
			||||||
                    return std::make_pair(CalcState::BELOW_MIN_PARKING_PRICE.toStdString(), QDateTime());
 | 
					                    return CalcState::BELOW_MIN_PARKING_PRICE.toStdString();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // int const pop_pre_paid = 1;
 | 
					                // int const pop_pre_paid = 1;
 | 
				
			||||||
@@ -370,7 +365,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                    qCritical() << DBG_HEADER
 | 
					                    qCritical() << DBG_HEADER
 | 
				
			||||||
                                << "ERROR" << inputDate.toString(Qt::ISODate)
 | 
					                                << "ERROR" << inputDate.toString(Qt::ISODate)
 | 
				
			||||||
                                << "NOT IN VALID WORKING TIME-RANGE";
 | 
					                                << "NOT IN VALID WORKING TIME-RANGE";
 | 
				
			||||||
                    return std::make_pair("", QDateTime());
 | 
					                    return "";
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //qCritical() << __func__ << __LINE__;
 | 
					                //qCritical() << __func__ << __LINE__;
 | 
				
			||||||
@@ -395,7 +390,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                    qCritical() << DBG_HEADER
 | 
					                    qCritical() << DBG_HEADER
 | 
				
			||||||
                                << "ERROR" << inputDate.toString(Qt::ISODate)
 | 
					                                << "ERROR" << inputDate.toString(Qt::ISODate)
 | 
				
			||||||
                                << "NOT IN VALID WORKING TIME-RANGE";
 | 
					                                << "NOT IN VALID WORKING TIME-RANGE";
 | 
				
			||||||
                    return std::make_pair("", QDateTime());
 | 
					                    return "";
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if DEBUG_GET_DURATION_FROM_COST==1
 | 
					#if DEBUG_GET_DURATION_FROM_COST==1
 | 
				
			||||||
@@ -409,7 +404,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                int new_price = 0;
 | 
					                int new_price = 0;
 | 
				
			||||||
                int durationInSecs = 0;
 | 
					                int durationInSecs = 0;
 | 
				
			||||||
                uint32_t duration_previous = 0;
 | 
					                uint32_t duration_previous = 0;
 | 
				
			||||||
                // bool found = false;
 | 
					                bool found = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
 | 
					                for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
 | 
				
			||||||
                    int const pra_price = itr->second.pra_price;
 | 
					                    int const pra_price = itr->second.pra_price;
 | 
				
			||||||
@@ -438,16 +433,13 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                               duration_previous = durationUnit;
 | 
					                               duration_previous = durationUnit;
 | 
				
			||||||
                               //qCritical() << "(" << __func__ << ":" << __LINE__ << ") ZZZZZZ duration_previous" << duration_previous;
 | 
					                               //qCritical() << "(" << __func__ << ":" << __LINE__ << ") ZZZZZZ duration_previous" << duration_previous;
 | 
				
			||||||
                            } else {
 | 
					                            } else {
 | 
				
			||||||
                               //found = true;
 | 
					                                found = true;
 | 
				
			||||||
                               //qCritical() << "(" << __func__ << ":" << __LINE__ << ") WWWWWW duration_previous" << duration_previous;
 | 
					                               //qCritical() << "(" << __func__ << ":" << __LINE__ << ") WWWWWW duration_previous" << duration_previous;
 | 
				
			||||||
                                QString s = inputDate.toString(Qt::ISODate);
 | 
					                                QString s = inputDate.toString(Qt::ISODate);
 | 
				
			||||||
                                QDateTime d(QDateTime::fromString(s, Qt::ISODate));
 | 
					                                QDateTime d(QDateTime::fromString(s, Qt::ISODate));
 | 
				
			||||||
                                d = d.addSecs(duration_previous * 60);
 | 
					                                d = d.addSecs(duration_previous * 60);
 | 
				
			||||||
                                //qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << d;
 | 
					                                //qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << d;
 | 
				
			||||||
                                if (overPaid) {
 | 
					                                return d.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                                    return std::make_pair(CalcState::OVERPAID.toStdString(), d);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                return std::make_pair(d.toString(Qt::ISODate).toStdString(), d);
 | 
					 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else {
 | 
					                        } else {
 | 
				
			||||||
                            durationInSecs = cfg->Duration.find(durationId)->second.pun_duration * 60;
 | 
					                            durationInSecs = cfg->Duration.find(durationId)->second.pun_duration * 60;
 | 
				
			||||||
@@ -558,10 +550,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                            qCritical() << DBG_HEADER << "TICKET-END" << s;
 | 
					                            qCritical() << DBG_HEADER << "TICKET-END" << s;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if (overPaid) {
 | 
					                            return s.toStdString();
 | 
				
			||||||
                                return std::make_pair(CalcState::OVERPAID.toStdString(), inputDate);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            return std::make_pair(s.toStdString(), inputDate);
 | 
					 | 
				
			||||||
                        } // if ((double)price == cost) {
 | 
					                        } // if ((double)price == cost) {
 | 
				
			||||||
                        else {
 | 
					                        else {
 | 
				
			||||||
                            //qCritical() << DBG_HEADER;
 | 
					                            //qCritical() << DBG_HEADER;
 | 
				
			||||||
@@ -571,7 +560,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return std::make_pair("", QDateTime());
 | 
					                return "";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else
 | 
					    } else
 | 
				
			||||||
@@ -588,7 +577,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if (cost < minParkingPrice) {
 | 
					        if (cost < minParkingPrice) {
 | 
				
			||||||
            qCritical() << QString("ERROR: COST < MIN_PARKING_PRICE (%1 < %2)").arg(cost).arg(minParkingPrice);
 | 
					            qCritical() << QString("ERROR: COST < MIN_PARKING_PRICE (%1 < %2)").arg(cost).arg(minParkingPrice);
 | 
				
			||||||
            return std::make_pair(QDateTime().toString(Qt::ISODate).toStdString(), QDateTime());
 | 
					            return QDateTime().toString(Qt::ISODate).toStdString();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (cost > maxParkingPrice) {
 | 
					        if (cost > maxParkingPrice) {
 | 
				
			||||||
@@ -627,7 +616,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                weekdayId = current.date().dayOfWeek();
 | 
					                weekdayId = current.date().dayOfWeek();
 | 
				
			||||||
                if (weekdayId == weekdayIdLast) {
 | 
					                if (weekdayId == weekdayIdLast) {
 | 
				
			||||||
                    qCritical() << "ERROR: NO VALID WORKDAY-TIMES DEFINED";
 | 
					                    qCritical() << "ERROR: NO VALID WORKDAY-TIMES DEFINED";
 | 
				
			||||||
                    return std::make_pair(QDateTime().toString(Qt::ISODate).toStdString(), QDateTime());
 | 
					                    return QDateTime().toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -645,10 +634,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (current.time() >= to) {
 | 
					            if (current.time() >= to) {
 | 
				
			||||||
                if (carryOverNotSet) {
 | 
					                if (carryOverNotSet) {
 | 
				
			||||||
                    if (overPaid) {
 | 
					                    return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                        return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
 | 
					 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    QDateTime const dt = start;
 | 
					                    QDateTime const dt = start;
 | 
				
			||||||
                    start = start.addDays(1);
 | 
					                    start = start.addDays(1);
 | 
				
			||||||
@@ -695,10 +681,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                                << "price" << price;
 | 
					                                << "price" << price;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
                    end_datetime = current;
 | 
					                    end_datetime = current;
 | 
				
			||||||
                    if (overPaid) {
 | 
					                    return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                        return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                QTime const &from = QTime::fromString(weekDayWorkTimeRanges[weekDayWorkTimeIndex].pwd_time_from.c_str(), Qt::ISODate);
 | 
					                QTime const &from = QTime::fromString(weekDayWorkTimeRanges[weekDayWorkTimeIndex].pwd_time_from.c_str(), Qt::ISODate);
 | 
				
			||||||
@@ -793,10 +776,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                                    << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
					                                    << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
                                    << "price" << price;
 | 
					                                    << "price" << price;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
                        if (overPaid) {
 | 
					                        return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                            return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -837,10 +817,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                                    << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
					                                    << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
                                    << "price" << price;
 | 
					                                    << "price" << price;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
                                if (overPaid) {
 | 
					                                return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                                    return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
 | 
					 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            // price has been updated; use next time range
 | 
					                            // price has been updated; use next time range
 | 
				
			||||||
@@ -871,10 +848,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                                    << "price" << price;
 | 
					                                    << "price" << price;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if (overPaid) {
 | 
					                        return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                            return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (moveToNextTimeRange) {
 | 
					                    if (moveToNextTimeRange) {
 | 
				
			||||||
@@ -990,10 +964,8 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                                    << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
					                                    << "end_datetime" << end_datetime.toString(Qt::ISODate)
 | 
				
			||||||
                                    << "price" << price;
 | 
					                                    << "price" << price;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
                        if (overPaid) {
 | 
					
 | 
				
			||||||
                            return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
 | 
					                        return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1006,10 +978,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                            << "final price" << std::max(price, minParkingPrice);
 | 
					                            << "final price" << std::max(price, minParkingPrice);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (overPaid) {
 | 
					                return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                    return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
 | 
					 | 
				
			||||||
            } // while (timeRangeIt != cfg->TimeRange.cend()) {
 | 
					            } // while (timeRangeIt != cfg->TimeRange.cend()) {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1018,7 +987,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                            << "INVALID END TIME";
 | 
					                            << "INVALID END TIME";
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
        end_datetime = QDateTime();
 | 
					        end_datetime = QDateTime();
 | 
				
			||||||
        return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
 | 
					        return end_datetime.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ticket t = private_GetDurationFromCost(cfg, inputDate, cost, prepaid);
 | 
					    Ticket t = private_GetDurationFromCost(cfg, inputDate, cost, prepaid);
 | 
				
			||||||
@@ -1026,7 +995,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
    // qCritical().noquote() << t;
 | 
					    // qCritical().noquote() << t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // TODO: im fehlerfall
 | 
					    // TODO: im fehlerfall
 | 
				
			||||||
    return std::make_pair(t.getValidUntil().toString(Qt::ISODate).toStdString(), t.getValidUntil());
 | 
					    return t.getValidUntil().toString(Qt::ISODate).toStdString();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#undef _DEBUG_
 | 
					#undef _DEBUG_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1456,10 +1425,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg,
 | 
				
			|||||||
    Q_UNUSED(payment_option);
 | 
					    Q_UNUSED(payment_option);
 | 
				
			||||||
    Q_UNUSED(nextDay);
 | 
					    Q_UNUSED(nextDay);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int paymentOptionIndex = getPaymentOptionIndex(*cfg, start_datetime);
 | 
					    int const paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get());
 | 
				
			||||||
    if (paymentOptionIndex == -1) {
 | 
					 | 
				
			||||||
        paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
					    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
				
			||||||
    if (paymentMethodId == PaymentMethod::Steps) {
 | 
					    if (paymentMethodId == PaymentMethod::Steps) {
 | 
				
			||||||
        if (tariffIs24_7(cfg)) {
 | 
					        if (tariffIs24_7(cfg)) {
 | 
				
			||||||
@@ -2611,7 +2577,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                        // qCritical() << "(" << __func__ << ":" << __LINE__ << ")            runtime in minutes (1):" << runtimeInMinutes;
 | 
					                        // qCritical() << "(" << __func__ << ":" << __LINE__ << ")            runtime in minutes (1):" << runtimeInMinutes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        // int const pop_truncate_last_interpolation_step = cfg->getPaymentOptions(paymentOptionIndex).pop_truncate_last_interpolation_step;
 | 
					                        int const pop_truncate_last_interpolation_step = cfg->getPaymentOptions(paymentOptionIndex).pop_truncate_last_interpolation_step;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        // TODO: auslagern
 | 
					                        // TODO: auslagern
 | 
				
			||||||
                        for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
 | 
					                        for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
 | 
				
			||||||
@@ -2636,7 +2602,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
 | 
				
			|||||||
                            auto search = cfg->Duration.find(durationId);
 | 
					                            auto search = cfg->Duration.find(durationId);
 | 
				
			||||||
                            if (search != cfg->Duration.end()) {
 | 
					                            if (search != cfg->Duration.end()) {
 | 
				
			||||||
                                ATBDuration duration = search->second;
 | 
					                                ATBDuration duration = search->second;
 | 
				
			||||||
                                // ATBDuration &previous = search->second;
 | 
					                                ATBDuration &previous = search->second;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                if (duration.pun_interpolation_id == -1) {
 | 
					                                if (duration.pun_interpolation_id == -1) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2666,7 +2632,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
 | 
				
			|||||||
                                        // qCritical() << "(" << __func__ << ":" << __LINE__ << ")         interpolation dynamic end:" << interpolationEnd.toString(Qt::ISODate);
 | 
					                                        // qCritical() << "(" << __func__ << ":" << __LINE__ << ")         interpolation dynamic end:" << interpolationEnd.toString(Qt::ISODate);
 | 
				
			||||||
                                        // qCritical() << "(" << __func__ << ":" << __LINE__ << ")    interpolation dynamic end time:" << end_time;
 | 
					                                        // qCritical() << "(" << __func__ << ":" << __LINE__ << ")    interpolation dynamic end time:" << end_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        // int pop_min_time = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
					                                        int pop_min_time = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        runtimeInMinutes += duration.pun_duration;
 | 
					                                        runtimeInMinutes += duration.pun_duration;
 | 
				
			||||||
                                        nextTimeStep = start.addSecs(runtimeInMinutes * 60);
 | 
					                                        nextTimeStep = start.addSecs(runtimeInMinutes * 60);
 | 
				
			||||||
@@ -2743,7 +2709,7 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
 | 
				
			|||||||
                                        //qCritical() << "(" << __func__ << ":" << __LINE__ << ")            runtime in minutes:" << runtimeInMinutes;
 | 
					                                        //qCritical() << "(" << __func__ << ":" << __LINE__ << ")            runtime in minutes:" << runtimeInMinutes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        QDateTime s = start.addSecs(runtimeInMinutes * 60);
 | 
					                                        QDateTime s = start.addSecs(runtimeInMinutes * 60);
 | 
				
			||||||
                                        // int const minutes = s.time().secsTo(carryOverStart) / 60;
 | 
					                                        int const minutes = s.time().secsTo(carryOverStart) / 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
                                        if (minutes > 0) {
 | 
					                                        if (minutes > 0) {
 | 
				
			||||||
@@ -2813,6 +2779,243 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
 | 
				
			|||||||
                 qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
 | 
					                 qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    } else
 | 
				
			||||||
 | 
					    if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::RECOMPUTE_SOME) {
 | 
				
			||||||
 | 
					        // some durations / timesteps have to be recomputed
 | 
				
			||||||
 | 
					        qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::RECOMPUTE_SOME";
 | 
				
			||||||
 | 
					        int size = m_timeSteps.size();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        while (size <= paymentOptionIndex) {
 | 
				
			||||||
 | 
					            m_timeSteps.push_back(QList<int>());
 | 
				
			||||||
 | 
					            size = m_timeSteps.size();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        m_timeSteps[paymentOptionIndex].clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        QDateTime const start(s.date(),
 | 
				
			||||||
 | 
					                              QTime(s.time().hour(), s.time().minute(), 0),
 | 
				
			||||||
 | 
					                              s.timeZone());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        QDateTime current(start);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bool casePrepay = false;
 | 
				
			||||||
 | 
					        int const weekDay = start.date().dayOfWeek();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int const pop_prepay_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_prepay_option_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // compute prepay settings
 | 
				
			||||||
 | 
					        // assumption: prepay settings the same for all days
 | 
				
			||||||
 | 
					        QDateTime prepayStart(start);
 | 
				
			||||||
 | 
					        QDateTime prepayEnd(start);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        prepayStart.setTime(cfg->TariffPrepayOptions.find(pop_prepay_option_id)->second.prepay[weekDay].start);
 | 
				
			||||||
 | 
					        prepayEnd.setTime(cfg->TariffPrepayOptions.find(pop_prepay_option_id)->second.prepay[weekDay].end);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (start <= prepayEnd) {
 | 
				
			||||||
 | 
					            prepayStart = prepayStart.addDays(-1);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            prepayEnd = prepayEnd.addDays(1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay start" << prepayStart.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ")   prepay end" << prepayEnd.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int const prepayDurationInMinutes = start.secsTo(prepayEnd) / 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // compute carryover settings
 | 
				
			||||||
 | 
					        // assumption: carryover settings the same for all days
 | 
				
			||||||
 | 
					        int const pop_carry_over_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
 | 
				
			||||||
 | 
					        QDateTime carryOverStart(start);
 | 
				
			||||||
 | 
					        QDateTime carryOverEnd(start);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        carryOverStart.setTime(cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start);
 | 
				
			||||||
 | 
					        carryOverEnd.setTime(cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (start <= carryOverEnd) {
 | 
				
			||||||
 | 
					            carryOverStart = carryOverStart.addDays(-1);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            carryOverEnd = carryOverEnd.addDays(1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over start" << carryOverStart.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ")   carry over end" << carryOverEnd.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // int cnt = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (Configuration::TariffDurationType::iterator it = cfg->Duration.begin();
 | 
				
			||||||
 | 
					             it != cfg->Duration.end();
 | 
				
			||||||
 | 
					             ++it) {
 | 
				
			||||||
 | 
					            it->second.pun_duration = it->second.pun_duration_saved;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // if (++cnt > 2) continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << it->second.pun_id;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (it->second.pun_mutable) {
 | 
				
			||||||
 | 
					                if (it->second.pun_netto) {
 | 
				
			||||||
 | 
					                    if (it->second.pun_round_to_next_24h_boundary == false) {
 | 
				
			||||||
 | 
					                        //int weekDay = start.date().dayOfWeek();
 | 
				
			||||||
 | 
					                        if (m_timeSteps[paymentOptionIndex].isEmpty()) {
 | 
				
			||||||
 | 
					                            // handle possible prepay-condition, which applies only
 | 
				
			||||||
 | 
					                            // for the very first step
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay start" << prepayStart.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ")   prepay end" << prepayEnd.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (prepayStart <= start && start <= prepayEnd) {
 | 
				
			||||||
 | 
					                                it->second.pun_duration = prepayDurationInMinutes;
 | 
				
			||||||
 | 
					                                it->second.pun_duration += it->second.pun_duration_saved ;
 | 
				
			||||||
 | 
					                                casePrepay = true;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << it->second.pun_duration;
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay" << casePrepay;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (!casePrepay) {
 | 
				
			||||||
 | 
					                            // handle possible carryover-condition
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            int const durationInSecs = it->second.pun_duration_saved * 60;
 | 
				
			||||||
 | 
					                            it->second.pun_duration = it->second.pun_duration_saved;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (current >= carryOverStart && current < carryOverEnd) {
 | 
				
			||||||
 | 
					                                it->second.pun_duration += current.secsTo(carryOverEnd) / 60;
 | 
				
			||||||
 | 
					                            } else {
 | 
				
			||||||
 | 
					                                // start < carryOverStart
 | 
				
			||||||
 | 
					                                QDateTime const &newCurrent = current.addSecs(durationInSecs);
 | 
				
			||||||
 | 
					                                if (newCurrent > carryOverStart && newCurrent <= carryOverEnd) {
 | 
				
			||||||
 | 
					                                    // cross carry over section
 | 
				
			||||||
 | 
					                                    it->second.pun_next_step_correction = carryOverStart.secsTo(carryOverEnd) / 60;
 | 
				
			||||||
 | 
					                                    it->second.pun_duration += it->second.pun_next_step_correction;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            // qCritical() << "(" << __func__ << ":" << __LINE__ << ")";
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (pop_accumulate_durations) {
 | 
				
			||||||
 | 
					                            m_timeSteps[paymentOptionIndex] << it->second.pun_duration;
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
 | 
				
			||||||
 | 
					                                int d = m_timeSteps[paymentOptionIndex].last();
 | 
				
			||||||
 | 
					                                m_timeSteps[paymentOptionIndex] << (d + it->second.pun_duration);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        current = current.addSecs(m_timeSteps[paymentOptionIndex].last() * 60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                            qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
 | 
				
			||||||
 | 
					                            qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    } else { // if (it->pun_round_to_next_24h_boundary == false) {
 | 
				
			||||||
 | 
					                        if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                            qCritical() << "(" << __func__ << ":" << __LINE__ << ") round-to-next-24h-boundary";
 | 
				
			||||||
 | 
					                            qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay" << casePrepay;
 | 
				
			||||||
 | 
					                            qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (casePrepay) {
 | 
				
			||||||
 | 
					                            // the last time step contains the (dynamic) prepay duration
 | 
				
			||||||
 | 
					                            // so it is possible to compute the last duration
 | 
				
			||||||
 | 
					                            int lastDuration =  m_timeSteps[paymentOptionIndex].last() - prepayDurationInMinutes;
 | 
				
			||||||
 | 
					                            // qCritical() << "(" << __func__ << ":" << __LINE__ << ") last duration " << lastDuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            int const minutesToAdd = 1440 - lastDuration;
 | 
				
			||||||
 | 
					                            current = current.addSecs(minutesToAdd * 60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") minutes to add " << minutesToAdd;
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (pop_accumulate_durations) {
 | 
				
			||||||
 | 
					                                m_timeSteps[paymentOptionIndex] << minutesToAdd;
 | 
				
			||||||
 | 
					                            } else {
 | 
				
			||||||
 | 
					                                if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
 | 
				
			||||||
 | 
					                                    int d = m_timeSteps[paymentOptionIndex].last();
 | 
				
			||||||
 | 
					                                    m_timeSteps[paymentOptionIndex] << (d + minutesToAdd);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            // qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            casePrepay = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << it->second.pun_id;
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << it->second.pun_duration;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            int secs = s.secsTo(current);
 | 
				
			||||||
 | 
					                            int const dayInSecs = 1440 * 60;
 | 
				
			||||||
 | 
					                            int const rest = secs % dayInSecs;
 | 
				
			||||||
 | 
					                            int const minutesToAdd = (dayInSecs - rest) / 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            current = current.addSecs(minutesToAdd * 60);
 | 
				
			||||||
 | 
					                            it->second.pun_duration = minutesToAdd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") minutes to add " << minutesToAdd;
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (pop_accumulate_durations) {
 | 
				
			||||||
 | 
					                                m_timeSteps[paymentOptionIndex] << minutesToAdd;
 | 
				
			||||||
 | 
					                            } else {
 | 
				
			||||||
 | 
					                                if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
 | 
				
			||||||
 | 
					                                    int d = m_timeSteps[paymentOptionIndex].last();
 | 
				
			||||||
 | 
					                                    m_timeSteps[paymentOptionIndex] << (d + minutesToAdd);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            // qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                } else { // if (it->second.pun_netto) {
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")\n" << it->second;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else { // mutable == false
 | 
				
			||||||
 | 
					                if (it->second.pun_brutto) {    // no handling for prepay and carry-over
 | 
				
			||||||
 | 
					                    if (pop_accumulate_durations) {
 | 
				
			||||||
 | 
					                        m_timeSteps[paymentOptionIndex] << it->second.pun_duration;
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
 | 
				
			||||||
 | 
					                            int d = m_timeSteps[paymentOptionIndex].last();
 | 
				
			||||||
 | 
					                            m_timeSteps[paymentOptionIndex] << (d + it->second.pun_duration);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")\n" << it->second;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::STATIC";
 | 
					        qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::STATIC";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2831,13 +3034,12 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qCritical() << "(" << __func__ << ":" << __LINE__ << ")                   NEW timeSteps:" << m_timeSteps;
 | 
					    //qCritical() << "(" << __func__ << ":" << __LINE__ << ")                   NEW timeSteps:" << m_timeSteps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (DBG_LEVEL >= DBG_DEBUG) {
 | 
					    if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
        qCritical() << "(" << __func__ << ":" << __LINE__ << ")                   NEW timeSteps:" << m_timeSteps;
 | 
					        QDateTime nextTime(s);
 | 
				
			||||||
 | 
					        qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << nextTime.toString(Qt::ISODate);
 | 
				
			||||||
        for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
 | 
					        for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
 | 
				
			||||||
            QDateTime nextTime = s;
 | 
					 | 
				
			||||||
            // nextTime.setTime(QTime(0, 0, 0));
 | 
					            // nextTime.setTime(QTime(0, 0, 0));
 | 
				
			||||||
            int const secs = m_timeSteps[paymentOptionIndex][i] * 60;
 | 
					            int const secs = m_timeSteps[paymentOptionIndex][i] * 60;
 | 
				
			||||||
            nextTime = nextTime.addSecs(secs);
 | 
					            nextTime = nextTime.addSecs(secs);
 | 
				
			||||||
@@ -2864,7 +3066,7 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
 | 
				
			|||||||
    uint32_t price = 0;
 | 
					    uint32_t price = 0;
 | 
				
			||||||
    int pun_duration = 0;
 | 
					    int pun_duration = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex" << paymentOptionIndex;
 | 
					    //qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex" << paymentOptionIndex;
 | 
				
			||||||
    //qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
 | 
					    //qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
 | 
				
			||||||
    //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
 | 
					    //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,9 +7,8 @@
 | 
				
			|||||||
#include "tariff_business_hours.h"
 | 
					#include "tariff_business_hours.h"
 | 
				
			||||||
#include "tariff_global_defines.h"
 | 
					#include "tariff_global_defines.h"
 | 
				
			||||||
#include "tariff_carryover.h"
 | 
					#include "tariff_carryover.h"
 | 
				
			||||||
 | 
					#include "tariff_prepay.h"
 | 
				
			||||||
#include "tariff_global_defines.h"
 | 
					#include "tariff_global_defines.h"
 | 
				
			||||||
#include "tariff_settings.h"
 | 
					 | 
				
			||||||
#include "tariff_carryover_settings.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QString>
 | 
					#include <QString>
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
@@ -23,13 +22,7 @@ MemberType Configuration::IdentifyJsonMember(const char* member_name)
 | 
				
			|||||||
    if (strcmp(member_name, "PaymentRate") == 0) return MemberType::PaymentRateType;
 | 
					    if (strcmp(member_name, "PaymentRate") == 0) return MemberType::PaymentRateType;
 | 
				
			||||||
    if (strcmp(member_name, "PaymentOption") == 0) return MemberType::PaymentOptionType;
 | 
					    if (strcmp(member_name, "PaymentOption") == 0) return MemberType::PaymentOptionType;
 | 
				
			||||||
    if (strcmp(member_name, "Duration") == 0) return MemberType::DurationType;
 | 
					    if (strcmp(member_name, "Duration") == 0) return MemberType::DurationType;
 | 
				
			||||||
    if (strcmp(member_name, "Monday") == 0) return MemberType::WeekDaysType;
 | 
					    //if (strcmp(member_name, "WeekDays") == 0) return MemberType::WeekDaysType;
 | 
				
			||||||
    if (strcmp(member_name, "Tuesday") == 0) return MemberType::WeekDaysType;
 | 
					 | 
				
			||||||
    if (strcmp(member_name, "Wednesday") == 0) return MemberType::WeekDaysType;
 | 
					 | 
				
			||||||
    if (strcmp(member_name, "Thursday") == 0) return MemberType::WeekDaysType;
 | 
					 | 
				
			||||||
    if (strcmp(member_name, "Friday") == 0) return MemberType::WeekDaysType;
 | 
					 | 
				
			||||||
    if (strcmp(member_name, "Saturday") == 0) return MemberType::WeekDaysType;
 | 
					 | 
				
			||||||
    if (strcmp(member_name, "Sunday") == 0) return MemberType::WeekDaysType;
 | 
					 | 
				
			||||||
    if (strcmp(member_name, "WeekDaysWorktime") == 0) return MemberType::WeekDaysWorkTimeType;
 | 
					    if (strcmp(member_name, "WeekDaysWorktime") == 0) return MemberType::WeekDaysWorkTimeType;
 | 
				
			||||||
    if (strcmp(member_name, "SpecialDaysWorktime") == 0) return MemberType::SpecialDaysWorktimeType;
 | 
					    if (strcmp(member_name, "SpecialDaysWorktime") == 0) return MemberType::SpecialDaysWorktimeType;
 | 
				
			||||||
    if (strcmp(member_name, "SpecialDays") == 0) return MemberType::SpecialDaysType;
 | 
					    if (strcmp(member_name, "SpecialDays") == 0) return MemberType::SpecialDaysType;
 | 
				
			||||||
@@ -43,301 +36,10 @@ MemberType Configuration::IdentifyJsonMember(const char* member_name)
 | 
				
			|||||||
    if (strcmp(member_name, "Interpolation") == 0) return MemberType::InterpolationType;
 | 
					    if (strcmp(member_name, "Interpolation") == 0) return MemberType::InterpolationType;
 | 
				
			||||||
    if (strcmp(member_name, "Prepaid") == 0) return MemberType::PrepaidType;
 | 
					    if (strcmp(member_name, "Prepaid") == 0) return MemberType::PrepaidType;
 | 
				
			||||||
    if (strcmp(member_name, "CarryOver") == 0) return MemberType::CarryOverType;
 | 
					    if (strcmp(member_name, "CarryOver") == 0) return MemberType::CarryOverType;
 | 
				
			||||||
 | 
					    if (strcmp(member_name, "PrepaidOption") == 0) return MemberType::PrepaidOptionType;
 | 
				
			||||||
    else return MemberType::UnknownType;
 | 
					    else return MemberType::UnknownType;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ATBWeekDay parseWeekDay(Configuration &cfg,
 | 
					 | 
				
			||||||
                        rapidjson::GenericMemberIterator<false,
 | 
					 | 
				
			||||||
                                                         rapidjson::UTF8<char>,
 | 
					 | 
				
			||||||
                                                         rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> k,
 | 
					 | 
				
			||||||
                        QString const &innerObjName,
 | 
					 | 
				
			||||||
                        Qt::DayOfWeek weekDay,
 | 
					 | 
				
			||||||
                        QString const &weekDayName) {
 | 
					 | 
				
			||||||
    int max_price = 0;
 | 
					 | 
				
			||||||
    int min_price = 0;
 | 
					 | 
				
			||||||
    int min_time = 0;
 | 
					 | 
				
			||||||
    int max_time = 0;
 | 
					 | 
				
			||||||
    int duration = 0;
 | 
					 | 
				
			||||||
    ATBWeekDay WeekDay;
 | 
					 | 
				
			||||||
    QTime start, end, parking_time_limit, about_to_exceed_limit;
 | 
					 | 
				
			||||||
    ATBTariffCarryOverSettings::ParkingTimeLimitChecker parkTimeLimitChecker;
 | 
					 | 
				
			||||||
    if (innerObjName == QString("week_day_default")) {
 | 
					 | 
				
			||||||
        if (k->value.IsObject()) {
 | 
					 | 
				
			||||||
            auto obj = k->value.GetObject();
 | 
					 | 
				
			||||||
            for (auto m = obj.MemberBegin(); m != obj.MemberEnd(); ++m) {
 | 
					 | 
				
			||||||
                QString const &name = m->name.GetString();
 | 
					 | 
				
			||||||
                if (name == "week_day_type") {
 | 
					 | 
				
			||||||
                    //
 | 
					 | 
				
			||||||
                } else
 | 
					 | 
				
			||||||
                if (name == "tariff_settings") {
 | 
					 | 
				
			||||||
                    if (m->value.IsObject()) {
 | 
					 | 
				
			||||||
                        auto obj = m->value.GetObject();
 | 
					 | 
				
			||||||
                        for (auto n = obj.MemberBegin(); n != obj.MemberEnd(); ++n) {
 | 
					 | 
				
			||||||
                            QString const &name = QString::fromStdString(n->name.GetString());
 | 
					 | 
				
			||||||
                            if (name == "min_time") {
 | 
					 | 
				
			||||||
                                if (n->value.IsInt()) { min_time = n->value.GetInt(); }
 | 
					 | 
				
			||||||
                            } else if (name == "max_time") {
 | 
					 | 
				
			||||||
                                if (n->value.IsInt()) { max_time = n->value.GetInt(); }
 | 
					 | 
				
			||||||
                            } else if (name == "min_price") {
 | 
					 | 
				
			||||||
                                if (n->value.IsInt()) { min_price = n->value.GetInt(); }
 | 
					 | 
				
			||||||
                            } else if (name == "max_price") {
 | 
					 | 
				
			||||||
                                if (n->value.IsInt()) { max_price = n->value.GetInt(); }
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                } else
 | 
					 | 
				
			||||||
                if (name == "carry_over_settings") {
 | 
					 | 
				
			||||||
                    if (m->value.IsObject()) {
 | 
					 | 
				
			||||||
                        auto obj = m->value.GetObject();
 | 
					 | 
				
			||||||
                        for (auto n = obj.MemberBegin(); n != obj.MemberEnd(); ++n) {
 | 
					 | 
				
			||||||
                            QString const &name = QString::fromStdString(n->name.GetString());
 | 
					 | 
				
			||||||
                            if (name == "duration") {
 | 
					 | 
				
			||||||
                                if (n->value.IsInt()) {
 | 
					 | 
				
			||||||
                                    duration = n->value.GetInt();
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                            } else
 | 
					 | 
				
			||||||
                            if (name == "start") {
 | 
					 | 
				
			||||||
                                if (n->value.IsString()) {
 | 
					 | 
				
			||||||
                                    start = QTime::fromString(QString::fromStdString(n->value.GetString()), Qt::ISODate);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                            } else
 | 
					 | 
				
			||||||
                            if (name == "end") {
 | 
					 | 
				
			||||||
                                if (n->value.IsString()) {
 | 
					 | 
				
			||||||
                                    end = QTime::fromString(QString::fromStdString(n->value.GetString()), Qt::ISODate);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                            } else
 | 
					 | 
				
			||||||
                            if (name == "parking_time_limit") {
 | 
					 | 
				
			||||||
                                if (n->value.IsObject()) {
 | 
					 | 
				
			||||||
                                    auto o = n->value.GetObject();
 | 
					 | 
				
			||||||
                                    for (auto l = o.MemberBegin(); l != o.MemberEnd(); ++l) {
 | 
					 | 
				
			||||||
                                        if (l->name.IsString()) {
 | 
					 | 
				
			||||||
                                            QString const &member = QString::fromStdString(l->name.GetString());
 | 
					 | 
				
			||||||
                                            if (member == "prev_day_sunday?") {
 | 
					 | 
				
			||||||
                                                if (l->value.IsArray()) {
 | 
					 | 
				
			||||||
                                                    auto limits = l->value.GetArray();
 | 
					 | 
				
			||||||
                                                    if (limits.Size() >= 2) {
 | 
					 | 
				
			||||||
                                                        about_to_exceed_limit = QTime::fromString(QString::fromStdString(limits[0].GetString()), Qt::ISODate);
 | 
					 | 
				
			||||||
                                                        parking_time_limit = QTime::fromString(QString::fromStdString(limits[1].GetString()), Qt::ISODate);
 | 
					 | 
				
			||||||
                                                    }
 | 
					 | 
				
			||||||
                                                    parkTimeLimitChecker = [&cfg, weekDay, weekDayName](ATBTariffCarryOverSettings const& cs,
 | 
					 | 
				
			||||||
                                                                                                        QDateTime const &startTime,
 | 
					 | 
				
			||||||
                                                                                                        QDateTime const &endTime,
 | 
					 | 
				
			||||||
                                                                                                        int paymentOptionIndex) {
 | 
					 | 
				
			||||||
                                                        if (startTime.date() < endTime.date()) { // start end end on different days
 | 
					 | 
				
			||||||
                                                            if (endTime.date().dayOfWeek() == (int)weekDay) {
 | 
					 | 
				
			||||||
                                                                if (endTime.time() > cs.m_parking_time_limit) {
 | 
					 | 
				
			||||||
                                                                    qCritical() << __func__ << ":" << __LINE__
 | 
					 | 
				
			||||||
                                                                                << QString("ERROR time limit for end-time violated: [%1, %2 end-time=%3], but time-limit=%4")
 | 
					 | 
				
			||||||
                                                                                        .arg(weekDayName)
 | 
					 | 
				
			||||||
                                                                                        .arg(endTime.date().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                                                                                        .arg(endTime.time().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                                                                                        .arg(cs.m_parking_time_limit.toString(Qt::ISODate));
 | 
					 | 
				
			||||||
                                                                    return true;
 | 
					 | 
				
			||||||
                                                                }
 | 
					 | 
				
			||||||
                                                                if (endTime.time() >= cs.m_about_to_exceed_parking_time_limit) {
 | 
					 | 
				
			||||||
                                                                    cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps = 1;
 | 
					 | 
				
			||||||
                                                                } else {
 | 
					 | 
				
			||||||
                                                                    cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps =
 | 
					 | 
				
			||||||
                                                                        cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
 | 
					 | 
				
			||||||
                                                                }
 | 
					 | 
				
			||||||
                                                            }
 | 
					 | 
				
			||||||
                                                        }
 | 
					 | 
				
			||||||
                                                        return false;
 | 
					 | 
				
			||||||
                                                    };
 | 
					 | 
				
			||||||
                                                }
 | 
					 | 
				
			||||||
                                            } else
 | 
					 | 
				
			||||||
                                            if (member == "prev_day_holiday?") {
 | 
					 | 
				
			||||||
                                                if (l->value.IsArray()) {
 | 
					 | 
				
			||||||
                                                    auto limits = l->value.GetArray();
 | 
					 | 
				
			||||||
                                                    if (limits.Size() >= 2) {
 | 
					 | 
				
			||||||
                                                        about_to_exceed_limit = QTime::fromString(QString::fromStdString(limits[0].GetString()), Qt::ISODate);
 | 
					 | 
				
			||||||
                                                        parking_time_limit = QTime::fromString(QString::fromStdString(limits[1].GetString()), Qt::ISODate);
 | 
					 | 
				
			||||||
                                                    }
 | 
					 | 
				
			||||||
                                                    parkTimeLimitChecker = [&cfg, weekDayName](ATBTariffCarryOverSettings const& cs,
 | 
					 | 
				
			||||||
                                                                                               QDateTime const &startTime,
 | 
					 | 
				
			||||||
                                                                                               QDateTime const &endTime,
 | 
					 | 
				
			||||||
                                                                                               int paymentOptionIndex) {
 | 
					 | 
				
			||||||
                                                        if (startTime.date() < endTime.date()) { // start end end on different days
 | 
					 | 
				
			||||||
                                                            if (previousDayHoliday(cfg, endTime)) {
 | 
					 | 
				
			||||||
                                                                if (endTime.time() > cs.m_parking_time_limit) {
 | 
					 | 
				
			||||||
                                                                    qCritical() << __func__ << ":" << __LINE__
 | 
					 | 
				
			||||||
                                                                                << QString("ERROR time limit for end-time violated: [%1, %2, end-time=%3], but time-limit=%4")
 | 
					 | 
				
			||||||
                                                                                        .arg(weekDayName)
 | 
					 | 
				
			||||||
                                                                                        .arg(endTime.date().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                                                                                        .arg(endTime.time().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                                                                                        .arg(cs.m_parking_time_limit.toString(Qt::ISODate));
 | 
					 | 
				
			||||||
                                                                    return true;
 | 
					 | 
				
			||||||
                                                                }
 | 
					 | 
				
			||||||
                                                                if (endTime.time() >= cs.m_about_to_exceed_parking_time_limit) {
 | 
					 | 
				
			||||||
                                                                    cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps = 1;
 | 
					 | 
				
			||||||
                                                                } else {
 | 
					 | 
				
			||||||
                                                                    cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps =
 | 
					 | 
				
			||||||
                                                                        cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
 | 
					 | 
				
			||||||
                                                                }
 | 
					 | 
				
			||||||
                                                            }
 | 
					 | 
				
			||||||
                                                        }
 | 
					 | 
				
			||||||
                                                        return false;
 | 
					 | 
				
			||||||
                                                    };
 | 
					 | 
				
			||||||
                                                }
 | 
					 | 
				
			||||||
                                            }
 | 
					 | 
				
			||||||
                                        }
 | 
					 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            ATBTariffSettings ts(max_price, min_price, max_time, min_time);
 | 
					 | 
				
			||||||
            ATBTariffCarryOverSettings cs(duration, start, end, parking_time_limit, about_to_exceed_limit,
 | 
					 | 
				
			||||||
                                          parkTimeLimitChecker);
 | 
					 | 
				
			||||||
            WeekDay = ATBWeekDay(weekDay, weekDayName, ATBWeekDay::USUAL_WEEKDAY, QDate(), ts, cs);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        } // if (k->value.IsObject()) {
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        QDate date(QDate::fromString(innerObjName, Qt::ISODate));
 | 
					 | 
				
			||||||
        if (date.isValid()) {
 | 
					 | 
				
			||||||
            if (k->value.IsObject()) {
 | 
					 | 
				
			||||||
                auto obj = k->value.GetObject();
 | 
					 | 
				
			||||||
                for (auto m = obj.MemberBegin(); m != obj.MemberEnd(); ++m) {
 | 
					 | 
				
			||||||
                    QString const &name = m->name.GetString();
 | 
					 | 
				
			||||||
                    if (name == "week_day_type") {
 | 
					 | 
				
			||||||
                        // TODO
 | 
					 | 
				
			||||||
                    } else
 | 
					 | 
				
			||||||
                    if (name == "tariff_settings") {
 | 
					 | 
				
			||||||
                        if (m->value.IsObject()) {
 | 
					 | 
				
			||||||
                            auto obj = m->value.GetObject();
 | 
					 | 
				
			||||||
                            for (auto n = obj.MemberBegin(); n != obj.MemberEnd(); ++n) {
 | 
					 | 
				
			||||||
                                QString const &name = QString::fromStdString(n->name.GetString());
 | 
					 | 
				
			||||||
                                if (name == "min_time") {
 | 
					 | 
				
			||||||
                                    if (n->value.IsInt()) { min_time = n->value.GetInt(); }
 | 
					 | 
				
			||||||
                                } else if (name == "max_time") {
 | 
					 | 
				
			||||||
                                    if (n->value.IsInt()) { max_time = n->value.GetInt(); }
 | 
					 | 
				
			||||||
                                } else if (name == "min_price") {
 | 
					 | 
				
			||||||
                                    if (n->value.IsInt()) { min_price = n->value.GetInt(); }
 | 
					 | 
				
			||||||
                                } else if (name == "max_price") {
 | 
					 | 
				
			||||||
                                    if (n->value.IsInt()) { max_price = n->value.GetInt(); }
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    } else
 | 
					 | 
				
			||||||
                    if (name == "carry_over_settings") {
 | 
					 | 
				
			||||||
                        if (m->value.IsObject()) {
 | 
					 | 
				
			||||||
                            auto obj = m->value.GetObject();
 | 
					 | 
				
			||||||
                            for (auto n = obj.MemberBegin(); n != obj.MemberEnd(); ++n) {
 | 
					 | 
				
			||||||
                                QString const &name = QString::fromStdString(n->name.GetString());
 | 
					 | 
				
			||||||
                                if (name == "duration") {
 | 
					 | 
				
			||||||
                                    if (n->value.IsInt()) {
 | 
					 | 
				
			||||||
                                        duration = n->value.GetInt();
 | 
					 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
                                } else
 | 
					 | 
				
			||||||
                                if (name == "start") {
 | 
					 | 
				
			||||||
                                    if (n->value.IsString()) {
 | 
					 | 
				
			||||||
                                        start = QTime::fromString(QString::fromStdString(n->value.GetString()), Qt::ISODate);
 | 
					 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
                                } else
 | 
					 | 
				
			||||||
                                if (name == "end") {
 | 
					 | 
				
			||||||
                                    if (n->value.IsString()) {
 | 
					 | 
				
			||||||
                                        end = QTime::fromString(QString::fromStdString(n->value.GetString()), Qt::ISODate);
 | 
					 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
                                } else
 | 
					 | 
				
			||||||
                                if (name == "parking_time_limit") {
 | 
					 | 
				
			||||||
                                    if (n->value.IsObject()) {
 | 
					 | 
				
			||||||
                                        auto o = n->value.GetObject();
 | 
					 | 
				
			||||||
                                        for (auto l = o.MemberBegin(); l != o.MemberEnd(); ++l) {
 | 
					 | 
				
			||||||
                                            if (l->name.IsString()) {
 | 
					 | 
				
			||||||
                                                QString const &member = QString::fromStdString(l->name.GetString());
 | 
					 | 
				
			||||||
                                                if (member == "default") {
 | 
					 | 
				
			||||||
                                                    if (l->value.IsArray()) {
 | 
					 | 
				
			||||||
                                                        auto limits = l->value.GetArray();
 | 
					 | 
				
			||||||
                                                        if (limits.Size() >= 2) {
 | 
					 | 
				
			||||||
                                                            about_to_exceed_limit = QTime::fromString(QString::fromStdString(limits[0].GetString()), Qt::ISODate);
 | 
					 | 
				
			||||||
                                                            parking_time_limit = QTime::fromString(QString::fromStdString(limits[1].GetString()), Qt::ISODate);
 | 
					 | 
				
			||||||
                                                        }
 | 
					 | 
				
			||||||
                                                    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                                    parkTimeLimitChecker = [&cfg, weekDay](ATBTariffCarryOverSettings const& cs,
 | 
					 | 
				
			||||||
                                                                                           QDateTime const &startTime,
 | 
					 | 
				
			||||||
                                                                                           QDateTime const &endTime,
 | 
					 | 
				
			||||||
                                                                                           int paymentOptionIndex) {
 | 
					 | 
				
			||||||
                                                        if (startTime.date() < endTime.date()) { // start end end on different days
 | 
					 | 
				
			||||||
                                                            if (endTime.date().dayOfWeek() == (int)weekDay) {
 | 
					 | 
				
			||||||
                                                                if (endTime.time() > cs.m_parking_time_limit) {
 | 
					 | 
				
			||||||
                                                                    qCritical() << __func__ << ":" << __LINE__
 | 
					 | 
				
			||||||
                                                                                << QString("ERROR time limit for end-time violated: end-time=%1, but time-limit=%2")
 | 
					 | 
				
			||||||
                                                                                        .arg(endTime.time().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                                                                                        .arg(cs.m_parking_time_limit.toString(Qt::ISODate));
 | 
					 | 
				
			||||||
                                                                    return true;
 | 
					 | 
				
			||||||
                                                                }
 | 
					 | 
				
			||||||
                                                                if (endTime.time() >= cs.m_about_to_exceed_parking_time_limit) {
 | 
					 | 
				
			||||||
                                                                    cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps = 1;
 | 
					 | 
				
			||||||
                                                                } else {
 | 
					 | 
				
			||||||
                                                                    cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps =
 | 
					 | 
				
			||||||
                                                                        cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
 | 
					 | 
				
			||||||
                                                                }
 | 
					 | 
				
			||||||
                                                            }
 | 
					 | 
				
			||||||
                                                        }
 | 
					 | 
				
			||||||
                                                        return false;
 | 
					 | 
				
			||||||
                                                    };
 | 
					 | 
				
			||||||
                                                } else
 | 
					 | 
				
			||||||
                                                if (member == "prev_day_holiday?") {
 | 
					 | 
				
			||||||
                                                    if (l->value.IsArray()) {
 | 
					 | 
				
			||||||
                                                        auto limits = l->value.GetArray();
 | 
					 | 
				
			||||||
                                                        if (limits.Size() >= 2) {
 | 
					 | 
				
			||||||
                                                            about_to_exceed_limit = QTime::fromString(QString::fromStdString(limits[0].GetString()), Qt::ISODate);
 | 
					 | 
				
			||||||
                                                            parking_time_limit = QTime::fromString(QString::fromStdString(limits[1].GetString()), Qt::ISODate);
 | 
					 | 
				
			||||||
                                                        }
 | 
					 | 
				
			||||||
                                                    }
 | 
					 | 
				
			||||||
                                                    parkTimeLimitChecker = [&cfg](ATBTariffCarryOverSettings const& cs,
 | 
					 | 
				
			||||||
                                                                                  QDateTime const &startTime,
 | 
					 | 
				
			||||||
                                                                                  QDateTime const &endTime,
 | 
					 | 
				
			||||||
                                                                                  int paymentOptionIndex) {
 | 
					 | 
				
			||||||
                                                        if (startTime.date() < endTime.date()) { // start end end on different days
 | 
					 | 
				
			||||||
                                                            if (previousDayHoliday(cfg, endTime)) {
 | 
					 | 
				
			||||||
                                                                if (endTime.time() > cs.m_parking_time_limit) {
 | 
					 | 
				
			||||||
                                                                    qCritical() << __func__ << ":" << __LINE__
 | 
					 | 
				
			||||||
                                                                                << QString("ERROR time limit for end-time violated: end-time=%1, but time-limit=%2")
 | 
					 | 
				
			||||||
                                                                                        .arg(endTime.time().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                                                                                        .arg(cs.m_parking_time_limit.toString(Qt::ISODate));
 | 
					 | 
				
			||||||
                                                                    return true;
 | 
					 | 
				
			||||||
                                                                }
 | 
					 | 
				
			||||||
                                                                if (endTime.time() >= cs.m_about_to_exceed_parking_time_limit) {
 | 
					 | 
				
			||||||
                                                                    cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps = 1;
 | 
					 | 
				
			||||||
                                                                } else {
 | 
					 | 
				
			||||||
                                                                    cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps =
 | 
					 | 
				
			||||||
                                                                        cfg.getPaymentOptions(paymentOptionIndex).pop_plus_steps_saved;
 | 
					 | 
				
			||||||
                                                                }
 | 
					 | 
				
			||||||
                                                            }
 | 
					 | 
				
			||||||
                                                        }
 | 
					 | 
				
			||||||
                                                        return false;
 | 
					 | 
				
			||||||
                                                    };
 | 
					 | 
				
			||||||
                                                }
 | 
					 | 
				
			||||||
                                            }
 | 
					 | 
				
			||||||
                                        }
 | 
					 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                ATBTariffSettings ts(max_price, min_price, max_time, min_time);
 | 
					 | 
				
			||||||
                ATBTariffCarryOverSettings cs(duration, start, end, parking_time_limit,
 | 
					 | 
				
			||||||
                                              about_to_exceed_limit, parkTimeLimitChecker);
 | 
					 | 
				
			||||||
                WeekDay = ATBWeekDay(weekDay, weekDayName, ATBWeekDay::HOLIDAY, date, ts, cs);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            } else {// if (k->value.IsObject()) {
 | 
					 | 
				
			||||||
                qCritical() << __func__ << ":" << __LINE__ << "ERROR: no object";
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            qCritical() << __func__ << __LINE__
 | 
					 | 
				
			||||||
                        << "ERROR: invalid date for" << weekDayName << "," << innerObjName;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return WeekDay;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/// <inheritdoc/>
 | 
					/// <inheritdoc/>
 | 
				
			||||||
bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
					bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -396,7 +98,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
            ATBPaymentRate PaymentRate;
 | 
					            ATBPaymentRate PaymentRate;
 | 
				
			||||||
            ATBSpecialDaysWorktime SpecialDaysWorktime;
 | 
					            ATBSpecialDaysWorktime SpecialDaysWorktime;
 | 
				
			||||||
            ATBSpecialDays SpecialDays;
 | 
					            ATBSpecialDays SpecialDays;
 | 
				
			||||||
            //ATBWeekDay WeekDay;
 | 
					            ATBWeekDays  WeekDays;
 | 
				
			||||||
            ATBWeekDaysWorktime  WeekDaysWorktime;
 | 
					            ATBWeekDaysWorktime  WeekDaysWorktime;
 | 
				
			||||||
            ATBPeriodYear YearPeriod;
 | 
					            ATBPeriodYear YearPeriod;
 | 
				
			||||||
            ATBDailyTicket DailyTicket;
 | 
					            ATBDailyTicket DailyTicket;
 | 
				
			||||||
@@ -408,40 +110,41 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
            ATBInterpolation TariffInterpolation;
 | 
					            ATBInterpolation TariffInterpolation;
 | 
				
			||||||
            ATBPrepaid TariffPrepaidOption;
 | 
					            ATBPrepaid TariffPrepaidOption;
 | 
				
			||||||
            ATBCarryOver TariffCarryOver;
 | 
					            ATBCarryOver TariffCarryOver;
 | 
				
			||||||
 | 
					            ATBPrepay TariffPrepayOption;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            MemberType mb_type = MemberType::UnknownType;
 | 
					            MemberType mb_type = MemberType::UnknownType;
 | 
				
			||||||
            this->currentPaymentOptions.clear();
 | 
					            this->currentPaymentOptions.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Get all JSON object members
 | 
					                // Get all JSON object members
 | 
				
			||||||
            // This code should run only once (to load JSON variables into memory)
 | 
					                // This code should run only once (to load JSON variables into memory)
 | 
				
			||||||
            for (auto i = document.MemberBegin(); i != document.MemberEnd(); i++)
 | 
					                for (auto i = document.MemberBegin(); i != document.MemberEnd(); i++)
 | 
				
			||||||
            {
 | 
					                {
 | 
				
			||||||
                // Get name of all general members of JSON, don't print name if NULL
 | 
					                        // Get name of all general members of JSON, don't print name if NULL
 | 
				
			||||||
                const char* mb_name = i->name.GetString();
 | 
					                        const char* mb_name = i->name.GetString();
 | 
				
			||||||
                if (mb_name == NULL) continue;
 | 
					            if (mb_name == NULL) continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (document[mb_name].IsString()) {
 | 
					            if (document[mb_name].IsString()) {
 | 
				
			||||||
                    QString const _mb_name(mb_name);
 | 
					                QString const _mb_name(mb_name);
 | 
				
			||||||
                    if (_mb_name.startsWith("Project", Qt::CaseInsensitive)) {
 | 
					                if (_mb_name.startsWith("Project", Qt::CaseInsensitive)) {
 | 
				
			||||||
                        cfg->project.project = document[mb_name].GetString();
 | 
					                    cfg->project.project = document[mb_name].GetString();
 | 
				
			||||||
                        continue;
 | 
					                    continue;
 | 
				
			||||||
                     }
 | 
					                 }
 | 
				
			||||||
                    if (_mb_name.startsWith("Version", Qt::CaseInsensitive)) {
 | 
					                if (_mb_name.startsWith("Version", Qt::CaseInsensitive)) {
 | 
				
			||||||
                        cfg->project.version = document[mb_name].GetString();
 | 
					                    cfg->project.version = document[mb_name].GetString();
 | 
				
			||||||
                        continue;
 | 
					                    continue;
 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    if (_mb_name.startsWith("Info", Qt::CaseInsensitive)) {
 | 
					 | 
				
			||||||
                        cfg->project.info = document[mb_name].GetString();
 | 
					 | 
				
			||||||
                        continue;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                if (_mb_name.startsWith("Info", Qt::CaseInsensitive)) {
 | 
				
			||||||
 | 
					                    cfg->project.info = document[mb_name].GetString();
 | 
				
			||||||
 | 
					                    continue;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // ... everything else should be an array
 | 
					            // ... everything else should be an array
 | 
				
			||||||
            if (!document[mb_name].IsArray()) {
 | 
					            if (!document[mb_name].IsArray()) {
 | 
				
			||||||
                continue;
 | 
					                continue;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            qCritical() << " -" << mb_name;
 | 
					            // qCritical() << " -" << mb_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Get array for each JSON object member
 | 
					            // Get array for each JSON object member
 | 
				
			||||||
            auto mb_array = document[mb_name].GetArray();
 | 
					            auto mb_array = document[mb_name].GetArray();
 | 
				
			||||||
@@ -471,35 +174,60 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                    {
 | 
					                    {
 | 
				
			||||||
                    case MemberType::UnknownType:
 | 
					                    case MemberType::UnknownType:
 | 
				
			||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
                    case MemberType::WeekDaysType: {
 | 
					                    case MemberType::PrepaidOptionType: {
 | 
				
			||||||
                        ATBWeekDay WeekDay;
 | 
					                        if (QString(inner_obj_name) == QString("prepaid_option_id")) {
 | 
				
			||||||
                        if (QString(mb_name) == "Monday") {
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Monday, mb_name);
 | 
					                                int const &x = k->value.GetInt();
 | 
				
			||||||
 | 
					                                TariffPrepayOption.id = x;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
                        } else
 | 
					                        } else
 | 
				
			||||||
                        if (QString(mb_name) == "Tuesday") {
 | 
					                        if (QString(inner_obj_name) == QString("prepaid_option_week")) {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Tuesday, mb_name);
 | 
					                            if (k->value.IsArray()) {
 | 
				
			||||||
                        } else
 | 
					                                auto days = k->value.GetArray();
 | 
				
			||||||
                        if (QString(mb_name) == "Wednesday") {
 | 
					                                for (rapidjson::SizeType j=0; j < days.Size(); ++j) {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Wednesday, mb_name);
 | 
					                                    if (days[j].IsObject()) {
 | 
				
			||||||
                        } else
 | 
					                                        auto weekday = days[j].GetObject();
 | 
				
			||||||
                        if (QString(mb_name) == "Thursday") {
 | 
					                                        for (auto w = weekday.MemberBegin(); w != weekday.MemberEnd(); ++w) {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Thursday, mb_name);
 | 
					                                            int day = j+1; // 8 entries
 | 
				
			||||||
                        } else
 | 
					                                            QString member(QString::fromStdString(w->name.GetString()));
 | 
				
			||||||
                        if (QString(mb_name) == "Friday") {
 | 
					                                            if (member == "prepaid_option_day") {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Friday, mb_name);
 | 
					                                                if (w->value.IsInt()) {
 | 
				
			||||||
                        } else
 | 
					                                                    rapidjson::SizeType const d = w->value.GetInt();
 | 
				
			||||||
                        if (QString(mb_name) == "Saturday") {
 | 
					                                                    if (d != (j+1)) {
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Saturday, mb_name);
 | 
					                                                        qCritical() << "ERROR: misconfigured jsonfile" << d << "!=" << (j+1);
 | 
				
			||||||
                        } else
 | 
					                                                    }
 | 
				
			||||||
                        if (QString(mb_name) == "Sunday") {
 | 
					                                                    TariffPrepayOption.prepay[day].day = day;
 | 
				
			||||||
                            WeekDay = parseWeekDay(*cfg, k, inner_obj_name, Qt::Sunday, mb_name);
 | 
					                                                }
 | 
				
			||||||
                        } else {
 | 
					                                            } else
 | 
				
			||||||
                            qCritical() << "ERROR: unknown week day" << mb_name;
 | 
					                                            if (member == "prepaid_option_duration") {
 | 
				
			||||||
 | 
					                                                if (w->value.IsInt()) {
 | 
				
			||||||
 | 
					                                                    TariffPrepayOption.prepay[day].duration = w->value.GetInt();
 | 
				
			||||||
 | 
					                                                }
 | 
				
			||||||
 | 
					                                            } else
 | 
				
			||||||
 | 
					                                            if (member == "prepaid_option_prepaid") {
 | 
				
			||||||
 | 
					                                                if (w->value.IsBool()) {
 | 
				
			||||||
 | 
					                                                    bool b = w->value.GetBool();
 | 
				
			||||||
 | 
					                                                    TariffPrepayOption.prepay[day].prepaid = b;
 | 
				
			||||||
 | 
					                                                }
 | 
				
			||||||
 | 
					                                            } else
 | 
				
			||||||
 | 
					                                            if (member == "prepaid_option_start") {
 | 
				
			||||||
 | 
					                                                if (w->value.IsString()) {
 | 
				
			||||||
 | 
					                                                    QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate);
 | 
				
			||||||
 | 
					                                                    TariffPrepayOption.prepay[day].start = t;
 | 
				
			||||||
 | 
					                                                }
 | 
				
			||||||
 | 
					                                            } else
 | 
				
			||||||
 | 
					                                            if (member == "prepaid_option_end") {
 | 
				
			||||||
 | 
					                                                if (w->value.IsString()) {
 | 
				
			||||||
 | 
					                                                    QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate);
 | 
				
			||||||
 | 
					                                                    TariffPrepayOption.prepay[day].end = t;
 | 
				
			||||||
 | 
					                                                }
 | 
				
			||||||
 | 
					                                            }
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
                        cfg->WeekDays.insert(pair<Qt::DayOfWeek, ATBWeekDay>(WeekDay.m_id, WeekDay));
 | 
					 | 
				
			||||||
                        // qCritical() << WeekDay;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    } break;
 | 
					                    } break;
 | 
				
			||||||
                    case MemberType::CarryOverType: {
 | 
					                    case MemberType::CarryOverType: {
 | 
				
			||||||
                        if (QString(inner_obj_name) == QString("carry_over_id")) {
 | 
					                        if (QString(inner_obj_name) == QString("carry_over_id")) {
 | 
				
			||||||
@@ -561,6 +289,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    } break;
 | 
					                    } break;
 | 
				
			||||||
 | 
					                    // deprecated
 | 
				
			||||||
                    case MemberType::PrepaidType: {
 | 
					                    case MemberType::PrepaidType: {
 | 
				
			||||||
                        if (QString(inner_obj_name) == QString("prepaid_id")) {
 | 
					                        if (QString(inner_obj_name) == QString("prepaid_id")) {
 | 
				
			||||||
                            if (k->value.IsInt()) {
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
@@ -591,49 +320,6 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                                QTime const &t = QTime::fromString(k->value.GetString(), Qt::ISODate);
 | 
					                                QTime const &t = QTime::fromString(k->value.GetString(), Qt::ISODate);
 | 
				
			||||||
                                TariffPrepaidOption.static_end = t;
 | 
					                                TariffPrepaidOption.static_end = t;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else
 | 
					 | 
				
			||||||
                        if (QString(inner_obj_name) == QString("prepaid_week")) {
 | 
					 | 
				
			||||||
                            if (k->value.IsArray()) {
 | 
					 | 
				
			||||||
                                auto days = k->value.GetArray();
 | 
					 | 
				
			||||||
                                for (rapidjson::SizeType j=0; j < days.Size(); ++j) {
 | 
					 | 
				
			||||||
                                    if (days[j].IsObject()) {
 | 
					 | 
				
			||||||
                                        auto weekday = days[j].GetObject();
 | 
					 | 
				
			||||||
                                        for (auto w = weekday.MemberBegin(); w != weekday.MemberEnd(); ++w) {
 | 
					 | 
				
			||||||
                                            int day = j+1; // 8 entries
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                            TariffPrepaidOption.prepaid[day].day = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                            QString member(QString::fromStdString(w->name.GetString()));
 | 
					 | 
				
			||||||
                                            if (member == "prepaid_day") {
 | 
					 | 
				
			||||||
                                                if (w->value.IsInt()) {
 | 
					 | 
				
			||||||
                                                    rapidjson::SizeType const d = w->value.GetInt();
 | 
					 | 
				
			||||||
                                                    if (d != (j+1)) {
 | 
					 | 
				
			||||||
                                                        qCritical() << "ERROR: misconfigured jsonfile" << d << "!=" << (j+1);
 | 
					 | 
				
			||||||
                                                    }
 | 
					 | 
				
			||||||
                                                    TariffPrepaidOption.prepaid[day].day = day;
 | 
					 | 
				
			||||||
                                                }
 | 
					 | 
				
			||||||
                                            } else
 | 
					 | 
				
			||||||
                                            if (member == "prepaid_duration") {
 | 
					 | 
				
			||||||
                                                if (w->value.IsInt()) {
 | 
					 | 
				
			||||||
                                                    TariffPrepaidOption.prepaid[day].duration = w->value.GetInt();
 | 
					 | 
				
			||||||
                                                }
 | 
					 | 
				
			||||||
                                            } else
 | 
					 | 
				
			||||||
                                            if (member == "prepaid_static_start") {
 | 
					 | 
				
			||||||
                                                if (w->value.IsString()) {
 | 
					 | 
				
			||||||
                                                    QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate);
 | 
					 | 
				
			||||||
                                                    TariffPrepaidOption.prepaid[day].static_start = t;
 | 
					 | 
				
			||||||
                                                }
 | 
					 | 
				
			||||||
                                            } else
 | 
					 | 
				
			||||||
                                            if (member == "prepaid_static_end") {
 | 
					 | 
				
			||||||
                                                if (w->value.IsString()) {
 | 
					 | 
				
			||||||
                                                    QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate);
 | 
					 | 
				
			||||||
                                                    TariffPrepaidOption.prepaid[day].static_end = t;
 | 
					 | 
				
			||||||
                                                }
 | 
					 | 
				
			||||||
                                            }
 | 
					 | 
				
			||||||
                                        }
 | 
					 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    } break;
 | 
					                    } break;
 | 
				
			||||||
                    case MemberType::InterpolationType: {
 | 
					                    case MemberType::InterpolationType: {
 | 
				
			||||||
@@ -974,20 +660,11 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                        } else if (strcmp(inner_obj_name, "pop_plus_steps") == 0) {
 | 
					                        } else if (strcmp(inner_obj_name, "pop_plus_steps") == 0) {
 | 
				
			||||||
                            if (k->value.IsInt()) {
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
                                this->currentPaymentOptions.last().pop_plus_steps = k->value.GetInt();
 | 
					                                this->currentPaymentOptions.last().pop_plus_steps = k->value.GetInt();
 | 
				
			||||||
                                this->currentPaymentOptions.last().pop_plus_steps_saved = k->value.GetInt();
 | 
					 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else if (strcmp(inner_obj_name, "pop_minus_steps") == 0) {
 | 
					                        } else if (strcmp(inner_obj_name, "pop_minus_steps") == 0) {
 | 
				
			||||||
                            if (k->value.IsInt()) {
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
                                this->currentPaymentOptions.last().pop_minus_steps = k->value.GetInt();
 | 
					                                this->currentPaymentOptions.last().pop_minus_steps = k->value.GetInt();
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else if (strcmp(inner_obj_name, "pop_allow_overpay") == 0) {
 | 
					 | 
				
			||||||
                            if (k->value.IsBool()) {
 | 
					 | 
				
			||||||
                                this->currentPaymentOptions.last().pop_allow_overpay = k->value.GetBool();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        } else if (strcmp(inner_obj_name, "pop_apply_carry_over_to_ticket_endtime") == 0) {
 | 
					 | 
				
			||||||
                            if (k->value.IsBool()) {
 | 
					 | 
				
			||||||
                                this->currentPaymentOptions.last().pop_apply_carry_over_to_ticket_endtime = k->value.GetBool();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        } else if (strcmp(inner_obj_name, "pop_payment_method_id") == 0) {
 | 
					                        } else if (strcmp(inner_obj_name, "pop_payment_method_id") == 0) {
 | 
				
			||||||
                            this->currentPaymentOptions.last().pop_payment_method_id = k->value.GetInt();
 | 
					                            this->currentPaymentOptions.last().pop_payment_method_id = k->value.GetInt();
 | 
				
			||||||
                        } else if (strcmp(inner_obj_name, "pop_day_end_time") == 0) {
 | 
					                        } else if (strcmp(inner_obj_name, "pop_day_end_time") == 0) {
 | 
				
			||||||
@@ -1004,8 +681,10 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                            this->currentPaymentOptions.last().pop_max_time = k->value.GetDouble();
 | 
					                            this->currentPaymentOptions.last().pop_max_time = k->value.GetDouble();
 | 
				
			||||||
                        } else if (strcmp(inner_obj_name, "pop_min_price") == 0) {
 | 
					                        } else if (strcmp(inner_obj_name, "pop_min_price") == 0) {
 | 
				
			||||||
                            this->currentPaymentOptions.last().pop_min_price = k->value.GetDouble();
 | 
					                            this->currentPaymentOptions.last().pop_min_price = k->value.GetDouble();
 | 
				
			||||||
                        } else if (strcmp(inner_obj_name, "pop_prepaid_option_id") == 0) {
 | 
					                        } else if (strcmp(inner_obj_name, "pop_prepaid_option_id") == 0) { // deprecated
 | 
				
			||||||
                            this->currentPaymentOptions.last().pop_prepaid_option_id = k->value.GetInt();
 | 
					                            this->currentPaymentOptions.last().pop_prepaid_option_id = k->value.GetInt();
 | 
				
			||||||
 | 
					                        } else if (strcmp(inner_obj_name, "pop_prepay_option_id") == 0) {
 | 
				
			||||||
 | 
					                            this->currentPaymentOptions.last().pop_prepay_option_id = k->value.GetInt();
 | 
				
			||||||
                        } else if (strcmp(inner_obj_name, "pop_truncate_last_interpolation_step") == 0) {
 | 
					                        } else if (strcmp(inner_obj_name, "pop_truncate_last_interpolation_step") == 0) {
 | 
				
			||||||
                            this->currentPaymentOptions.last().pop_truncate_last_interpolation_step = k->value.GetBool();
 | 
					                            this->currentPaymentOptions.last().pop_truncate_last_interpolation_step = k->value.GetBool();
 | 
				
			||||||
                        } else if (strcmp(inner_obj_name, "pop_accumulate_prices") == 0) {
 | 
					                        } else if (strcmp(inner_obj_name, "pop_accumulate_prices") == 0) {
 | 
				
			||||||
@@ -1103,6 +782,42 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                        } else if (strcmp(inner_obj_name, "pun_duration_min") == 0) Duration.pun_duration_min = k->value.GetInt();
 | 
					                        } else if (strcmp(inner_obj_name, "pun_duration_min") == 0) Duration.pun_duration_min = k->value.GetInt();
 | 
				
			||||||
                        else if (strcmp(inner_obj_name, "pun_duration_max") == 0) Duration.pun_duration_max = k->value.GetInt();
 | 
					                        else if (strcmp(inner_obj_name, "pun_duration_max") == 0) Duration.pun_duration_max = k->value.GetInt();
 | 
				
			||||||
                        else if (strcmp(inner_obj_name, "pun_interpolation_id") == 0) Duration.pun_interpolation_id = k->value.GetInt();
 | 
					                        else if (strcmp(inner_obj_name, "pun_interpolation_id") == 0) Duration.pun_interpolation_id = k->value.GetInt();
 | 
				
			||||||
 | 
					                        else if (strcmp(inner_obj_name, "pun_netto") == 0) {
 | 
				
			||||||
 | 
					                            if (k->value.IsBool()) {
 | 
				
			||||||
 | 
					                                Duration.pun_netto = k->value.GetBool();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else if (strcmp(inner_obj_name, "pun_brutto") == 0) {
 | 
				
			||||||
 | 
					                            if (k->value.IsBool()) {
 | 
				
			||||||
 | 
					                                Duration.pun_brutto = k->value.GetBool();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else if (strcmp(inner_obj_name, "pun_fixed") == 0) {
 | 
				
			||||||
 | 
					                            if (k->value.IsBool()) {
 | 
				
			||||||
 | 
					                                Duration.pun_fixed = k->value.GetBool();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else if (strcmp(inner_obj_name, "pun_mutable") == 0) {
 | 
				
			||||||
 | 
					                            if (k->value.IsBool()) {
 | 
				
			||||||
 | 
					                                Duration.pun_mutable = k->value.GetBool();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else if (strcmp(inner_obj_name, "pun_round_to_next_24h_boundary") == 0) {
 | 
				
			||||||
 | 
					                            if (k->value.IsBool()) {
 | 
				
			||||||
 | 
					                                Duration.pun_round_to_next_24h_boundary = k->value.GetBool();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else if (strcmp(inner_obj_name, "pun_round_to_prev_24h_boundary") == 0) {
 | 
				
			||||||
 | 
					                            if (k->value.IsBool()) {
 | 
				
			||||||
 | 
					                                Duration.pun_round_to_prev_24h_boundary = k->value.GetBool();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else if (strcmp(inner_obj_name, "pun_align_with_timepoint") == 0) {
 | 
				
			||||||
 | 
					                            if (k->value.IsString()) {
 | 
				
			||||||
 | 
					                                QDateTime const &dt = QDateTime::fromString(k->value.GetString(), Qt::ISODate);
 | 
				
			||||||
 | 
					                                Duration.pun_align_with_timepoint = dt;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
                     case MemberType::SpecialDaysWorktimeType:
 | 
					                     case MemberType::SpecialDaysWorktimeType:
 | 
				
			||||||
                        if (strcmp(inner_obj_name, "pedwt_id") == 0) SpecialDaysWorktime.pedwt_id = k->value.GetInt();
 | 
					                        if (strcmp(inner_obj_name, "pedwt_id") == 0) SpecialDaysWorktime.pedwt_id = k->value.GetInt();
 | 
				
			||||||
@@ -1110,7 +825,6 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                        else if (strcmp(inner_obj_name, "pedwt_time_from") == 0) SpecialDaysWorktime.pedwt_time_from = k->value.GetString();
 | 
					                        else if (strcmp(inner_obj_name, "pedwt_time_from") == 0) SpecialDaysWorktime.pedwt_time_from = k->value.GetString();
 | 
				
			||||||
                        else if (strcmp(inner_obj_name, "pedwt_time_to") == 0) SpecialDaysWorktime.pedwt_time_to = k->value.GetString();
 | 
					                        else if (strcmp(inner_obj_name, "pedwt_time_to") == 0) SpecialDaysWorktime.pedwt_time_to = k->value.GetString();
 | 
				
			||||||
                        else if (strcmp(inner_obj_name, "pedwt_price") == 0) SpecialDaysWorktime.pedwt_price = k->value.GetDouble();
 | 
					                        else if (strcmp(inner_obj_name, "pedwt_price") == 0) SpecialDaysWorktime.pedwt_price = k->value.GetDouble();
 | 
				
			||||||
                        else if (strcmp(inner_obj_name, "pedwt_paid") == 0) SpecialDaysWorktime.pedwt_paid = k->value.GetInt();
 | 
					 | 
				
			||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
                /*case MemberType::WeekDaysType:
 | 
					                /*case MemberType::WeekDaysType:
 | 
				
			||||||
                        if (strcmp(inner_obj_name, "pdiw_id") == 0) WeekDays.pdiw_id = k->value.GetInt();
 | 
					                        if (strcmp(inner_obj_name, "pdiw_id") == 0) WeekDays.pdiw_id = k->value.GetInt();
 | 
				
			||||||
@@ -1153,11 +867,6 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                switch (mb_type) {
 | 
					                switch (mb_type) {
 | 
				
			||||||
                case MemberType::UnknownType:
 | 
					                case MemberType::UnknownType:
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case MemberType::WeekDaysType:
 | 
					 | 
				
			||||||
                    // qCritical() << "INSERT" << (int)WeekDay.m_id << WeekDay.m_date.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                    // cfg->WeekDays.insert(pair<Qt::DayOfWeek, ATBWeekDay>(WeekDay.m_id, WeekDay));
 | 
					 | 
				
			||||||
                    // qCritical() << WeekDay;
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case MemberType::PaymentMethodType:
 | 
					                case MemberType::PaymentMethodType:
 | 
				
			||||||
                    cfg->PaymentMethod.insert(pair<int, ATBPaymentMethod>(PaymentMethod.pme_id, PaymentMethod));
 | 
					                    cfg->PaymentMethod.insert(pair<int, ATBPaymentMethod>(PaymentMethod.pme_id, PaymentMethod));
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
@@ -1173,7 +882,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                } break;
 | 
					                } break;
 | 
				
			||||||
                case MemberType::DurationType:
 | 
					                case MemberType::DurationType:
 | 
				
			||||||
                    cfg->Duration.insert(pair<int, ATBDuration>(Duration.pun_id, Duration));
 | 
					                    cfg->Duration.insert(pair<int, ATBDuration>(Duration.pun_id, Duration));
 | 
				
			||||||
                    // qCritical() << Duration;
 | 
					                    //qCritical() << Duration;
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case MemberType::SpecialDaysWorktimeType:
 | 
					                case MemberType::SpecialDaysWorktimeType:
 | 
				
			||||||
                    cfg->SpecialDaysWorktime.insert(pair<int, ATBSpecialDaysWorktime>(SpecialDaysWorktime.pedwt_period_exc_day_id, SpecialDaysWorktime));
 | 
					                    cfg->SpecialDaysWorktime.insert(pair<int, ATBSpecialDaysWorktime>(SpecialDaysWorktime.pedwt_period_exc_day_id, SpecialDaysWorktime));
 | 
				
			||||||
@@ -1227,6 +936,10 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                    cfg->TariffCarryOverOptions.insert(pair<int, ATBCarryOver>(TariffCarryOver.id, TariffCarryOver));
 | 
					                    cfg->TariffCarryOverOptions.insert(pair<int, ATBCarryOver>(TariffCarryOver.id, TariffCarryOver));
 | 
				
			||||||
                    // qCritical() << TariffCarryOver;
 | 
					                    // qCritical() << TariffCarryOver;
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
 | 
					                case MemberType::PrepaidOptionType:
 | 
				
			||||||
 | 
					                    cfg->TariffPrepayOptions.insert(pair<int, ATBPrepay>(TariffPrepayOption.id, TariffPrepayOption));
 | 
				
			||||||
 | 
					                    //qCritical() << TariffPrepayOption;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
                default:
 | 
					                default:
 | 
				
			||||||
                     break;
 | 
					                     break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -1478,6 +1191,7 @@ bool Configuration::isDayIncludedAsSpecialDay(uint64_t businessHours, QDateTime
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (isSpecialDay(dt)) {
 | 
					    if (isSpecialDay(dt)) {
 | 
				
			||||||
        bool const &r = ((businessHours & BusinessHours::OFFICIAL_HOLIDAY) == BusinessHours::OFFICIAL_HOLIDAY);
 | 
					        bool const &r = ((businessHours & BusinessHours::OFFICIAL_HOLIDAY) == BusinessHours::OFFICIAL_HOLIDAY);
 | 
				
			||||||
 | 
					        qCritical() << "XXXXXXXXXXXXXXXXXX r" << r << businessHours;
 | 
				
			||||||
        return r;
 | 
					        return r;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1567,6 +1281,7 @@ int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) const {
 | 
				
			|||||||
    std::optional<QVector<ATBPaymentOption>> paymentOptions = getPaymentOptionsForAllKeys();
 | 
					    std::optional<QVector<ATBPaymentOption>> paymentOptions = getPaymentOptionsForAllKeys();
 | 
				
			||||||
    if (paymentOptions) {
 | 
					    if (paymentOptions) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QVector<ATBPaymentOption> const vec = paymentOptions.value();
 | 
					        QVector<ATBPaymentOption> const vec = paymentOptions.value();
 | 
				
			||||||
        PermitType const p(permitType);
 | 
					        PermitType const p(permitType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1580,73 +1295,6 @@ int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) const {
 | 
				
			|||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int getPaymentOptionIndex(Configuration const &cfg, QDateTime const &dt) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    int const numOptions = cfg.getAllPaymentOptions().size();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // qCritical() << __func__ << ":" << __LINE__ << "numOptions" << numOptions;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (int opt=0; opt < numOptions; ++opt) {
 | 
					 | 
				
			||||||
        uint64_t const pop_business_hours = cfg.getPaymentOptions(opt).pop_business_hours;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (pop_business_hours == 0) { // 0 == 24/7
 | 
					 | 
				
			||||||
            return opt;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // QDateTime const dt = QDateTime::currentDateTime();
 | 
					 | 
				
			||||||
        int const dayOfWeek = dt.date().dayOfWeek();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // qCritical() << __func__ << ":" << __LINE__ << "dayOfWeek" << dayOfWeek;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (isHoliday(cfg, dt)) {
 | 
					 | 
				
			||||||
            if (pop_business_hours & BusinessHours::OFFICIAL_HOLIDAY) {
 | 
					 | 
				
			||||||
                return opt;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            switch (dayOfWeek) {
 | 
					 | 
				
			||||||
            case (int)Qt::Monday: {
 | 
					 | 
				
			||||||
                if (pop_business_hours & BusinessHours::MON) {
 | 
					 | 
				
			||||||
                    return opt;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            } break;
 | 
					 | 
				
			||||||
            case (int)Qt::Tuesday: {
 | 
					 | 
				
			||||||
                if (pop_business_hours & BusinessHours::TUE) {
 | 
					 | 
				
			||||||
                    return opt;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            } break;
 | 
					 | 
				
			||||||
            case (int)Qt::Wednesday: {
 | 
					 | 
				
			||||||
                if (pop_business_hours & BusinessHours::WED) {
 | 
					 | 
				
			||||||
                    return opt;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            } break;
 | 
					 | 
				
			||||||
            case (int)Qt::Thursday: {
 | 
					 | 
				
			||||||
                if (pop_business_hours & BusinessHours::THU) {
 | 
					 | 
				
			||||||
                    return opt;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            } break;
 | 
					 | 
				
			||||||
            case (int)Qt::Friday: {
 | 
					 | 
				
			||||||
                if (pop_business_hours & BusinessHours::FRI) {
 | 
					 | 
				
			||||||
                    return opt;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            } break;
 | 
					 | 
				
			||||||
            case (int)Qt::Saturday: {
 | 
					 | 
				
			||||||
                if (pop_business_hours & BusinessHours::SAT) {
 | 
					 | 
				
			||||||
                    return opt;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            } break;
 | 
					 | 
				
			||||||
            case (int)Qt::Sunday: {
 | 
					 | 
				
			||||||
                if (pop_business_hours & BusinessHours::SUN) {
 | 
					 | 
				
			||||||
        qCritical() << __func__ << ":" << __LINE__ << "opt" << opt;
 | 
					 | 
				
			||||||
                    return opt;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            } break;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return -1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
std::optional<QVector<ATBTariffProduct>>
 | 
					std::optional<QVector<ATBTariffProduct>>
 | 
				
			||||||
Configuration::getTariffProductForProductId(PermitType permitType) const {
 | 
					Configuration::getTariffProductForProductId(PermitType permitType) const {
 | 
				
			||||||
    QString permitTypeName(permitType);
 | 
					    QString permitTypeName(permitType);
 | 
				
			||||||
@@ -1901,43 +1549,3 @@ Configuration::getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    return value;
 | 
					    return value;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
bool isHoliday(Configuration const &cfg, QDateTime const &t) {
 | 
					 | 
				
			||||||
    int const weekDay = t.date().dayOfWeek();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (auto[iter, rEnd] = cfg.WeekDays.equal_range(static_cast<Qt::DayOfWeek>(weekDay));
 | 
					 | 
				
			||||||
         iter != rEnd;
 | 
					 | 
				
			||||||
         ++iter) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (iter->second.m_type == ATBWeekDay::WeekDayType::HOLIDAY) {
 | 
					 | 
				
			||||||
            QDate const &d = iter->second.m_date;
 | 
					 | 
				
			||||||
            if (!d.isNull() && d.isValid()) {
 | 
					 | 
				
			||||||
                if (t.date() == d) {
 | 
					 | 
				
			||||||
                    return true;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return false;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
bool previousDayHoliday(Configuration const &cfg, QDateTime const &t) {
 | 
					 | 
				
			||||||
    int const weekDay = t.date().dayOfWeek();
 | 
					 | 
				
			||||||
    int const previousWeekDay = (weekDay == static_cast<int>(Qt::Monday)) ?
 | 
					 | 
				
			||||||
                static_cast<int>(Qt::Sunday) : (weekDay - 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (auto[iter, rEnd] = cfg.WeekDays.equal_range(static_cast<Qt::DayOfWeek>(previousWeekDay));
 | 
					 | 
				
			||||||
         iter != rEnd;
 | 
					 | 
				
			||||||
         ++iter) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (iter->second.m_type == ATBWeekDay::WeekDayType::HOLIDAY) {
 | 
					 | 
				
			||||||
            QDate const &d = iter->second.m_date;
 | 
					 | 
				
			||||||
            if (!d.isNull() && d.isValid()) {
 | 
					 | 
				
			||||||
                if (t.addDays(-1).date() == d) {
 | 
					 | 
				
			||||||
                    return true;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return false;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -207,13 +207,7 @@ bool Utilities::IsYearPeriodActive(Configuration const *cfg, QDateTime const &dt
 | 
				
			|||||||
                              dt.date().day());
 | 
					                              dt.date().day());
 | 
				
			||||||
                QDate const s(2004, year.second.pye_start_month, year.second.pye_start_day);
 | 
					                QDate const s(2004, year.second.pye_start_month, year.second.pye_start_day);
 | 
				
			||||||
                QDate const e(2004, year.second.pye_end_month, year.second.pye_end_day);
 | 
					                QDate const e(2004, year.second.pye_end_month, year.second.pye_end_day);
 | 
				
			||||||
                //qCritical() << __func__ << __LINE__ << "    d" << d.toString(Qt::ISODate);
 | 
					                return (d >= s && d <= e);
 | 
				
			||||||
                //qCritical() << __func__ << __LINE__ << "start" << s.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                //qCritical() << __func__ << __LINE__ << "  end" << e.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                if (s <= e) {
 | 
					 | 
				
			||||||
                    return (d >= s && d <= e);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                return (d >= s || d <= e);
 | 
					 | 
				
			||||||
            })) {
 | 
					            })) {
 | 
				
			||||||
        qCritical() << "NO VALID YEAR PERIOD";
 | 
					        qCritical() << "NO VALID YEAR PERIOD";
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										207
									
								
								main/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										207
									
								
								main/main.cpp
									
									
									
									
									
								
							@@ -43,7 +43,7 @@ extern "C" char* strptime(const char* s,
 | 
				
			|||||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU        (0)
 | 
					#define NEUHAUSER_LINSINGER_MASCHINENBAU        (0)
 | 
				
			||||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
 | 
					#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
 | 
				
			||||||
#define NEUHAUSER_BILEXA_GALTUER                (0)
 | 
					#define NEUHAUSER_BILEXA_GALTUER                (0)
 | 
				
			||||||
#define BAD_NEUENAHR_AHRWEILER                  (1)
 | 
					#define BAD_NEUENAHR_AHRWEILER                  (0)
 | 
				
			||||||
#define NEUHAUSER_CHRISTOPH_REISEN              (0)
 | 
					#define NEUHAUSER_CHRISTOPH_REISEN              (0)
 | 
				
			||||||
#define NEUHAUSER_PERNEGG_AN_DER_MUR            (0)
 | 
					#define NEUHAUSER_PERNEGG_AN_DER_MUR            (0)
 | 
				
			||||||
#define NEUHAUSER_STOCKERAU                     (0)
 | 
					#define NEUHAUSER_STOCKERAU                     (0)
 | 
				
			||||||
@@ -51,7 +51,7 @@ extern "C" char* strptime(const char* s,
 | 
				
			|||||||
#define SEXTEN                                  (0)
 | 
					#define SEXTEN                                  (0)
 | 
				
			||||||
#define SCHNALS_LEITER_KIRCHL                   (0)
 | 
					#define SCHNALS_LEITER_KIRCHL                   (0)
 | 
				
			||||||
#define SCHNALS_STAUMAUER                       (SCHNALS_LEITER_KIRCHL)
 | 
					#define SCHNALS_STAUMAUER                       (SCHNALS_LEITER_KIRCHL)
 | 
				
			||||||
#define VALSER_ALM                              (0)
 | 
					#define VALSER_ALM                              (1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if NEUHAUSER_KIRCHDORF==1
 | 
					#if NEUHAUSER_KIRCHDORF==1
 | 
				
			||||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
 | 
					static bool test_neuhauser_kirchdorf(int step, double cost) {
 | 
				
			||||||
@@ -339,20 +339,20 @@ int main() {
 | 
				
			|||||||
    cout << endl;
 | 
					    cout << endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (isParsed) {
 | 
					    if (isParsed) {
 | 
				
			||||||
        //pop_min_time = get_minimal_parkingtime(&cfg);
 | 
					        pop_min_time = get_minimal_parkingtime(&cfg);
 | 
				
			||||||
        //pop_max_time = get_maximal_parkingtime(&cfg);
 | 
					        pop_max_time = get_maximal_parkingtime(&cfg);
 | 
				
			||||||
        //pop_min_price = get_minimal_parkingprice(&cfg);
 | 
					        pop_min_price = get_minimal_parkingprice(&cfg);
 | 
				
			||||||
        //pop_max_price = get_maximal_parkingprice(&cfg);
 | 
					        pop_max_price = get_maximal_parkingprice(&cfg);
 | 
				
			||||||
        //pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
 | 
					        pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //qCritical() << "        pop_min_time: " << pop_min_time;
 | 
					        qCritical() << "        pop_min_time: " << pop_min_time;
 | 
				
			||||||
        //qCritical() << "        pop_max_time: " << pop_max_time;
 | 
					        qCritical() << "        pop_max_time: " << pop_max_time;
 | 
				
			||||||
        //qCritical() << "       pop_min_price: " << pop_min_price;
 | 
					        qCritical() << "       pop_min_price: " << pop_min_price;
 | 
				
			||||||
        //qCritical() << "       pop_max_price: " << pop_max_price;
 | 
					        qCritical() << "       pop_max_price: " << pop_max_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
 | 
					        QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
 | 
				
			||||||
        //qCritical() << "TimeSteps" << timeSteps;
 | 
					        qCritical() << "TimeSteps" << timeSteps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // return 0;
 | 
					        // return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -363,7 +363,8 @@ int main() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // for (int day = Qt::Monday; day <= Qt::Sunday; ++day) {
 | 
					        // for (int day = Qt::Monday; day <= Qt::Sunday; ++day) {
 | 
				
			||||||
        for (int day = Qt::Monday; day <= Qt::Monday; ++day) {
 | 
					        for (int day = Qt::Monday; day <= Qt::Monday; ++day) {
 | 
				
			||||||
            QDateTime s(QDate(2024, 8, 19 + day), QTime()); // 20: (whit) monday,..., 26: sunday
 | 
					            QDateTime s(QDate(2024, 7, 29 + day), QTime()); // 20: (whit) monday,..., 26: sunday
 | 
				
			||||||
 | 
					            QDateTime end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            switch (day) {
 | 
					            switch (day) {
 | 
				
			||||||
            case (int)Qt::Monday:
 | 
					            case (int)Qt::Monday:
 | 
				
			||||||
@@ -389,30 +390,6 @@ int main() {
 | 
				
			|||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QDateTime start(s);
 | 
					 | 
				
			||||||
            start.setTime(QTime(21, 30, 0));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            QDateTime end;
 | 
					 | 
				
			||||||
            int netto_parking_time = 14 * 60;
 | 
					 | 
				
			||||||
            struct price_t costs;
 | 
					 | 
				
			||||||
            PermitType pt(PERMIT_TYPE::SHORT_TERM_PARKING);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            double cost = 150;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //cs = compute_price_for_parking_ticket(&cfg, start, netto_parking_time,
 | 
					 | 
				
			||||||
            //                                      end, &costs, pt);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << costs.netto
 | 
					 | 
				
			||||||
            //            << "> end" << end.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
					 | 
				
			||||||
                        qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
 | 
					 | 
				
			||||||
                                    << "> end" << end.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
            //}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            exit(0);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /*
 | 
					            /*
 | 
				
			||||||
            CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
					            CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			||||||
@@ -764,7 +741,14 @@ int main() {
 | 
				
			|||||||
        input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json");
 | 
					        input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (zone == 3) {
 | 
					    if (zone == 3) {
 | 
				
			||||||
        input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json");
 | 
					        //input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json");
 | 
				
			||||||
 | 
					        //input.open("/home/linux/customer_502/etc/psa_tariff/tariff01.json");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // schnals
 | 
				
			||||||
 | 
					        // input.open("/opt/ptu5/opt/customer_505/etc/psa_tariff/tariff01.json");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // muehlbach
 | 
				
			||||||
 | 
					        input.open("/opt/ptu5/opt/customer_504/etc/psa_tariff/tariff01.json");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::stringstream sstr;
 | 
					    std::stringstream sstr;
 | 
				
			||||||
@@ -923,7 +907,7 @@ int main() {
 | 
				
			|||||||
            int Down = 0;
 | 
					            int Down = 0;
 | 
				
			||||||
            int Up = 1;
 | 
					            int Up = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QDateTime const start = QDateTime::currentDateTime();
 | 
					            QDateTime start = QDateTime::currentDateTime();
 | 
				
			||||||
            int paymentOptionIndex = cfg.getPaymentOptionIndex(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
 | 
					            int paymentOptionIndex = cfg.getPaymentOptionIndex(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (paymentOptionIndex != 0) {
 | 
					            if (paymentOptionIndex != 0) {
 | 
				
			||||||
@@ -936,17 +920,61 @@ int main() {
 | 
				
			|||||||
            //QSet<uint32_t> const prices2{500, 1600, 2400, 3200, 4000, 4800, 5600};
 | 
					            //QSet<uint32_t> const prices2{500, 1600, 2400, 3200, 4000, 4800, 5600};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QDateTime end;
 | 
					            QDateTime end;
 | 
				
			||||||
            CalcState calcState;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QDateTime s(QDateTime::currentDateTime());
 | 
					            QDateTime s(QDateTime::currentDateTime());
 | 
				
			||||||
            s.setTime(QTime(12, 0, 0));
 | 
					            s.setTime(QTime(10, 0, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            int minimal_parking_price = get_minimal_parkingprice(&cfg,
 | 
					#if 0
 | 
				
			||||||
                                                                 PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
 | 
					
 | 
				
			||||||
                                                                 paymentOptionIndex, s);
 | 
					            pop_min_time = get_minimal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
 | 
				
			||||||
 | 
					            pop_max_time = get_maximal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            pop_min_price = get_minimal_parkingprice(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex, s);
 | 
				
			||||||
 | 
					            pop_max_price = get_maximal_parkingprice(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            pop_daily_card_price = cfg.getPaymentOptions(paymentOptionIndex).pop_daily_card_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int h = pop_min_time / 60;
 | 
				
			||||||
 | 
					            int m = pop_min_time % 60;
 | 
				
			||||||
 | 
					            qCritical().noquote() << QString("         pop_min_time %1 (%2h, %3m)").arg(pop_min_time).arg(h).arg(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            h = pop_max_time / 60;
 | 
				
			||||||
 | 
					            m = pop_max_time % 60;
 | 
				
			||||||
 | 
					            qCritical().noquote()
 | 
				
			||||||
 | 
					               << QString("         pop_max_time %1 (%2h, %3m)").arg(pop_max_time).arg(h).arg(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            qCritical() << "       pop_min_price " << pop_min_price;
 | 
				
			||||||
 | 
					            qCritical() << "       pop_max_price " << pop_max_price;
 | 
				
			||||||
 | 
					            qCritical() << "pop_daily_card_price " << pop_daily_card_price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					            CalcState calcState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if 1
 | 
				
			||||||
 | 
					            qCritical() << "start" << s.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					            //for (int i = 1; i < 11; ++i) {
 | 
				
			||||||
 | 
					            for (int i = 0; i < 21; ++i) {
 | 
				
			||||||
 | 
					                calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
				
			||||||
 | 
					                                                    (double)i*10,
 | 
				
			||||||
 | 
					                                                    end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
 | 
				
			||||||
 | 
					                qCritical() << "RUN" << i << ": start" << s.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                            << ": price" << i*10 << "->" << end.toString(Qt::ISODate) << calcState.toString();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					            struct price_t price;
 | 
				
			||||||
 | 
					            int netto_parking_time = 1440;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            start = s;
 | 
				
			||||||
 | 
					            qCritical() << "RUN" << 0 << ": start" << s.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            calcState = compute_price_for_parking_ticket(&cfg, start, netto_parking_time,
 | 
				
			||||||
 | 
					                                                         end, &price,
 | 
				
			||||||
 | 
					                                                         PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
				
			||||||
 | 
					            qCritical() << "RUN" << 0 << ": start" << start.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                        << ": price for netto-time" << netto_parking_time
 | 
				
			||||||
 | 
					                        << "->" << price.netto << "->" << end.toString(Qt::ISODate) << calcState.toString();
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
            qCritical() << "minimal parking price" << minimal_parking_price;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (int i = 0; i < 8; ++i) {
 | 
					            for (int i = 0; i < 8; ++i) {
 | 
				
			||||||
                calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
					                calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
				
			||||||
@@ -955,11 +983,11 @@ int main() {
 | 
				
			|||||||
                qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
 | 
					                qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else
 | 
					// #else
 | 
				
			||||||
            s.setTime(QTime(15, 0, 0));
 | 
					            s.setTime(QTime(12, 0, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            minimal_parking_price = get_minimal_parkingprice(&cfg,
 | 
					            minimal_parking_price = get_minimal_parkingprice(&cfg,
 | 
				
			||||||
                                                             PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
 | 
					                                                             PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS),
 | 
				
			||||||
                                                             paymentOptionIndex, s);
 | 
					                                                             paymentOptionIndex, s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            qCritical() << "minimal parking price" << minimal_parking_price;
 | 
					            qCritical() << "minimal parking price" << minimal_parking_price;
 | 
				
			||||||
@@ -967,7 +995,7 @@ int main() {
 | 
				
			|||||||
            for (int i = 0; i < 8; ++i) {
 | 
					            for (int i = 0; i < 8; ++i) {
 | 
				
			||||||
                calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
					                calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
				
			||||||
                                                    (double)minimal_parking_price + i*800,
 | 
					                                                    (double)minimal_parking_price + i*800,
 | 
				
			||||||
                                                    end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
 | 
					                                                    end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
 | 
				
			||||||
                qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
 | 
					                qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -1380,7 +1408,7 @@ int main() {
 | 
				
			|||||||
    int pop_carry_over;
 | 
					    int pop_carry_over;
 | 
				
			||||||
    int pop_carry_over_time_range_id;
 | 
					    int pop_carry_over_time_range_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int zone=2; zone < 3; ++zone) {
 | 
					    for (int zone=1; zone < 2; ++zone) {
 | 
				
			||||||
    //for (int t=6; t < 7; t+=20) {
 | 
					    //for (int t=6; t < 7; t+=20) {
 | 
				
			||||||
        switch (zone) {
 | 
					        switch (zone) {
 | 
				
			||||||
        case 1: {
 | 
					        case 1: {
 | 
				
			||||||
@@ -1389,7 +1417,6 @@ int main() {
 | 
				
			|||||||
            //pop_max_time = 6*60;
 | 
					            //pop_max_time = 6*60;
 | 
				
			||||||
        } break;
 | 
					        } break;
 | 
				
			||||||
        case 2: {
 | 
					        case 2: {
 | 
				
			||||||
            qCritical() << "        ZONE 2: KURZZEIT 1";
 | 
					 | 
				
			||||||
            // kuzzeit-1-tarif
 | 
					            // kuzzeit-1-tarif
 | 
				
			||||||
            input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json");
 | 
					            input.open("/opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json");
 | 
				
			||||||
            //pop_max_time = 5*60;
 | 
					            //pop_max_time = 5*60;
 | 
				
			||||||
@@ -1432,7 +1459,6 @@ int main() {
 | 
				
			|||||||
        cout << endl;
 | 
					        cout << endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (isParsed) {
 | 
					        if (isParsed) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            // test library functions
 | 
					            // test library functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (zone == 1) {
 | 
					            if (zone == 1) {
 | 
				
			||||||
@@ -1459,10 +1485,10 @@ int main() {
 | 
				
			|||||||
                static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
 | 
					                static QList<int> const timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
 | 
				
			||||||
                qCritical() << "TimeSteps" << timeSteps;
 | 
					                qCritical() << "TimeSteps" << timeSteps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //if (stepsConfigured != timeSteps) {
 | 
					                if (stepsConfigured != timeSteps) {
 | 
				
			||||||
                //    qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured;
 | 
					                    qCritical() << "TIME-STEPS SHOULD BE" << stepsConfigured;
 | 
				
			||||||
                //    return -1;
 | 
					                    return -1;
 | 
				
			||||||
                //}
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                QDateTime start = QDateTime::currentDateTime();
 | 
					                QDateTime start = QDateTime::currentDateTime();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1470,8 +1496,7 @@ int main() {
 | 
				
			|||||||
                double price1 = 0;
 | 
					                double price1 = 0;
 | 
				
			||||||
                double price2 = 0;
 | 
					                double price2 = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //for (int m=0; m < 1440; ++m) {
 | 
					                for (int m=0; m < 1440; ++m) {
 | 
				
			||||||
                for (int m=480; m < 481; ++m) {
 | 
					 | 
				
			||||||
                    start.setTime(QTime(0, 0, 0));
 | 
					                    start.setTime(QTime(0, 0, 0));
 | 
				
			||||||
                    start = start.addSecs(m*60);
 | 
					                    start = start.addSecs(m*60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1488,7 +1513,7 @@ int main() {
 | 
				
			|||||||
                    //}
 | 
					                    //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    CalcState cs;
 | 
					                    CalcState cs;
 | 
				
			||||||
#if 1
 | 
					
 | 
				
			||||||
                    for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
 | 
					                    for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
 | 
				
			||||||
                        QDateTime end = start.addSecs(timeSteps.at(i)*60);
 | 
					                        QDateTime end = start.addSecs(timeSteps.at(i)*60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1523,21 +1548,6 @@ int main() {
 | 
				
			|||||||
                        //                                                                     cost[i], false, true);
 | 
					                        //                                                                     cost[i], false, true);
 | 
				
			||||||
                        //qCritical() << "duration" << duration.c_str();
 | 
					                        //qCritical() << "duration" << duration.c_str();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    double cost = 80;
 | 
					 | 
				
			||||||
                    qCritical() << "START" << start.toString(Qt::ISODate) << "cost" << cost;
 | 
					 | 
				
			||||||
                    QDateTime end;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    cs = compute_duration_for_parking_ticket(&cfg, start, cost, end,
 | 
					 | 
				
			||||||
                                                             PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
					 | 
				
			||||||
                        qCritical() << __LINE__ << cs.toString()
 | 
					 | 
				
			||||||
                                    << "START" << start.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                                    << "<duration" << start.secsTo(end) / 60
 | 
					 | 
				
			||||||
                                    << "cost" << cost
 | 
					 | 
				
			||||||
                                    << "> end" << end.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                    //}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } // zone == 1
 | 
					            } // zone == 1
 | 
				
			||||||
            if (zone == 2) {
 | 
					            if (zone == 2) {
 | 
				
			||||||
@@ -1575,19 +1585,18 @@ int main() {
 | 
				
			|||||||
                bool fail;
 | 
					                bool fail;
 | 
				
			||||||
                QDateTime start;
 | 
					                QDateTime start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for (int i=1; i < 2; ++i) {
 | 
					                for (int i=0; i < 4; ++i) {
 | 
				
			||||||
                    switch (i) {
 | 
					                    switch (i) {
 | 
				
			||||||
                    case 0:
 | 
					                    case 0:
 | 
				
			||||||
                        start = QDateTime(QDate(2024, 5, 1), QTime(16, 0, 0)); // holiday
 | 
					                        start = QDateTime(QDate(2024, 5, 1), QTime(16, 0, 0)); // holiday
 | 
				
			||||||
                        fail = false;
 | 
					                        fail = false;
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                    case 1:
 | 
					                    case 1:
 | 
				
			||||||
                        //start = QDateTime(QDate(2024, 10, 3), QTime(17, 0, 0)); // sunday
 | 
					                        start = QDateTime(QDate(2024, 4, 21), QTime(16, 0, 0)); // sunday
 | 
				
			||||||
                        start = QDateTime(QDate(2024, 9, 8), QTime(16, 2, 0)); // sunday
 | 
					 | 
				
			||||||
                        fail = false;
 | 
					                        fail = false;
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                    case 2:
 | 
					                    case 2:
 | 
				
			||||||
                        start = QDateTime(QDate(2024, 4, 22), QTime(17, 30, 0)); // monday
 | 
					                        start = QDateTime(QDate(2024, 4, 22), QTime(8, 0, 0)); // monday
 | 
				
			||||||
                        fail = false;
 | 
					                        fail = false;
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                    case 3:
 | 
					                    case 3:
 | 
				
			||||||
@@ -1611,52 +1620,18 @@ int main() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                        QList<int>::const_iterator step;
 | 
					                        QList<int>::const_iterator step;
 | 
				
			||||||
                        for (step = timeSteps.cbegin(); step != timeSteps.cend(); ++step) {
 | 
					                        for (step = timeSteps.cbegin(); step != timeSteps.cend(); ++step) {
 | 
				
			||||||
                            //qCritical() << __LINE__
 | 
					 | 
				
			||||||
                            //            << "START" << start.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                            //            << "<duration" << *step;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            // if (*step != 180)
 | 
					 | 
				
			||||||
                            // continue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            double cost = 0;
 | 
					                            double cost = 0;
 | 
				
			||||||
                            CalcState cs;
 | 
					                            CalcState cs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            QDateTime s(start);
 | 
					                            if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
                            qCritical() << __LINE__
 | 
					 | 
				
			||||||
                                        << "START" << start.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                                        << "<duration" << *step;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if 1
 | 
					 | 
				
			||||||
                            if ((cs = compute_price_for_parking_ticket(&cfg, s, *step, end, &price,
 | 
					 | 
				
			||||||
                                                                       PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
 | 
					 | 
				
			||||||
                                cost = price.netto;
 | 
					                                cost = price.netto;
 | 
				
			||||||
                                qCritical() << __LINE__
 | 
					                                qCritical() << "step" << *step << ": cost" << cost;
 | 
				
			||||||
                                            << "START" << start.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                                            << "<duration" << *step
 | 
					 | 
				
			||||||
                                            << "cost" << cost
 | 
					 | 
				
			||||||
                                            << "> end" << end.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                            } else {
 | 
					                            } else {
 | 
				
			||||||
                                if (fail == false) {
 | 
					                                if (fail == false) {
 | 
				
			||||||
                                    qCritical() << "<<<ERROR>>> cs =" << QString(cs);
 | 
					                                    qCritical() << "<<<ERROR>>> cs =" << QString(cs);
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
                            cost = 200;
 | 
					 | 
				
			||||||
                            qCritical() << "START" << start.toString(Qt::ISODate) << "cost" << cost;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            cs = compute_duration_for_parking_ticket(&cfg, start, cost, end,
 | 
					 | 
				
			||||||
                                                                         PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
					 | 
				
			||||||
                                qCritical() << __LINE__ << cs.toString()
 | 
					 | 
				
			||||||
                                            << "START" << start.toString(Qt::ISODate)
 | 
					 | 
				
			||||||
                                            << "<duration" << start.secsTo(end) / 60
 | 
					 | 
				
			||||||
                                            << "cost" << cost
 | 
					 | 
				
			||||||
                                            << "> end" << end.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                            break;
 | 
					 | 
				
			||||||
                            //}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        qCritical() << "ERROR paymentOptionIndex =" << paymentOptionIndex;
 | 
					                        qCritical() << "ERROR paymentOptionIndex =" << paymentOptionIndex;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,11 +30,9 @@ SOURCES += main.cpp
 | 
				
			|||||||
# HEADERS +=
 | 
					# HEADERS +=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
OTHER_FILES += \
 | 
					OTHER_FILES += \
 | 
				
			||||||
    /opt/ptu5/opt/customer_335/etc/psa_tariff/tariff01.json \
 | 
					    /opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json \
 | 
				
			||||||
    /opt/ptu5/opt/customer_335/etc/psa_tariff/tariff02.json \
 | 
					    /opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json \
 | 
				
			||||||
    /opt/ptu5/opt/customer_249/etc/psa_tariff/tariff01.json \
 | 
					    /opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json
 | 
				
			||||||
    /opt/ptu5/opt/customer_249/etc/psa_tariff/tariff02.json \
 | 
					 | 
				
			||||||
    /opt/ptu5/opt/customer_249/etc/psa_tariff/tariff03.json
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user