Compare commits
	
		
			44 Commits
		
	
	
		
			2.3.99-10
			...
			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 | |||
| 
						
						
							
						
						25b3143d88
	
				 | 
					
					
						|||
| 0856f10ca9 | |||
| 
						
						
							
						
						88c703ecc2
	
				 | 
					
					
						|||
| 465b2274a1 | |||
| 
						
						
							
						
						f946cd13e4
	
				 | 
					
					
						|||
| 
						
						
							
						
						8d1cbe7337
	
				 | 
					
					
						|||
| 62c52fd580 | |||
| 1023f6ede1 | |||
| 36b3e85d1b | |||
| b394ed46cc | |||
| 3dda2d8355 | |||
| 1152c3824e | |||
| 4271c0fb31 | |||
| 24d9d4a0ff | |||
| 4bce854d77 | |||
| 138221759b | |||
| 9cb7d4aea6 | |||
| cde490bab2 | |||
| f0677374ec | |||
| 89b05ffadc | |||
| 260973cd09 | 
@@ -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>
 | 
				
			||||||
@@ -47,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>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -54,7 +56,7 @@ 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;
 | 
				
			||||||
@@ -71,6 +73,7 @@ public:
 | 
				
			|||||||
	TariffProductType TariffProduct;
 | 
						TariffProductType TariffProduct;
 | 
				
			||||||
	TariffInterpolationType TariffInterpolations;
 | 
						TariffInterpolationType TariffInterpolations;
 | 
				
			||||||
	TariffPrepaidType TariffPrepaidOptions;
 | 
						TariffPrepaidType TariffPrepaidOptions;
 | 
				
			||||||
 | 
						TariffPrepayOptionType TariffPrepayOptions;
 | 
				
			||||||
	TariffCarryOverType TariffCarryOverOptions;
 | 
						TariffCarryOverType TariffCarryOverOptions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/// <summary>
 | 
						/// <summary>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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;
 | 
				
			||||||
@@ -38,8 +39,10 @@ public:
 | 
				
			|||||||
        pop_daily_card_price = -1;
 | 
					        pop_daily_card_price = -1;
 | 
				
			||||||
        pop_business_hours = -1;
 | 
					        pop_business_hours = -1;
 | 
				
			||||||
        pop_time_step_config = -1;
 | 
					        pop_time_step_config = -1;
 | 
				
			||||||
        pop_use_only_upto_datetime = "";
 | 
					        pop_use_only_upto_datetime = ""; // deprecated
 | 
				
			||||||
        pop_use_only_for_duration = 0;
 | 
					        pop_use_only_for_duration = 0;   // deprecated
 | 
				
			||||||
 | 
					        pop_plus_steps = 1;  // +: jump <x=1> steps forward
 | 
				
			||||||
 | 
					        pop_minus_steps = 1; // -: jump <x=1> steps backward
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int pop_id;
 | 
					    int pop_id;
 | 
				
			||||||
@@ -59,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;
 | 
				
			||||||
@@ -69,6 +73,8 @@ public:
 | 
				
			|||||||
    int pop_time_step_config;
 | 
					    int pop_time_step_config;
 | 
				
			||||||
    bool pop_accumulate_prices;
 | 
					    bool pop_accumulate_prices;
 | 
				
			||||||
    bool pop_accumulate_durations;
 | 
					    bool pop_accumulate_durations;
 | 
				
			||||||
 | 
					    int pop_plus_steps;
 | 
				
			||||||
 | 
					    int pop_minus_steps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    struct ATBMaxDateTime {
 | 
					    struct ATBMaxDateTime {
 | 
				
			||||||
        int direction;
 | 
					        int direction;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										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
 | 
				
			||||||
@@ -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;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@
 | 
				
			|||||||
#include <ctime>
 | 
					#include <ctime>
 | 
				
			||||||
#include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
#include <cmath>
 | 
					#include <cmath>
 | 
				
			||||||
 | 
					#include <optional>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "day_of_week.h"
 | 
					#include "day_of_week.h"
 | 
				
			||||||
#include "configuration.h"
 | 
					#include "configuration.h"
 | 
				
			||||||
@@ -62,6 +63,7 @@ namespace Utilities {
 | 
				
			|||||||
	/// <returns></returns>
 | 
						/// <returns></returns>
 | 
				
			||||||
	bool IsYearPeriodActive(Configuration* cfg, struct tm* currentDateTime);
 | 
						bool IsYearPeriodActive(Configuration* cfg, struct tm* currentDateTime);
 | 
				
			||||||
    bool IsYearPeriodActive(Configuration const *cfg, QDateTime const ¤tDateTime);
 | 
					    bool IsYearPeriodActive(Configuration const *cfg, QDateTime const ¤tDateTime);
 | 
				
			||||||
 | 
					    std::optional<ATBPeriodYear> GetYearPeriodActive(Configuration const *cfg, QDateTime const ¤tDateTime);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/// <summary>
 | 
						/// <summary>
 | 
				
			||||||
	/// Check permissions
 | 
						/// Check permissions
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,8 @@
 | 
				
			|||||||
#include "calculator_functions.h"
 | 
					#include "calculator_functions.h"
 | 
				
			||||||
#include "payment_option.h"
 | 
					#include "payment_option.h"
 | 
				
			||||||
#include "utilities.h"
 | 
					#include "utilities.h"
 | 
				
			||||||
 | 
					#include "tariff_global_defines.h"
 | 
				
			||||||
 | 
					#include "period_year.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QFile>
 | 
					#include <QFile>
 | 
				
			||||||
#include <QFileInfo>
 | 
					#include <QFileInfo>
 | 
				
			||||||
@@ -325,6 +327,8 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
 | 
				
			|||||||
    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);
 | 
				
			||||||
 | 
					        } else if (paymentMethodId == PaymentMethod::Degressive) {
 | 
				
			||||||
 | 
					            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
 | 
				
			||||||
@@ -462,8 +466,8 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
 | 
				
			|||||||
                                                int UpDown, PermitType const &permitType)
 | 
					                                                int UpDown, PermitType const &permitType)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qCritical() << "   compute_next_timestep()     currentTimeMinutes: " << currentTimeMinutes;
 | 
					    qCritical() << __LINE__ << "compute_next_timestep()     currentTimeMinutes: " << currentTimeMinutes;
 | 
				
			||||||
    qCritical() << "   compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
 | 
					    qCritical() << __LINE__ << "compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // FIXME
 | 
					    // FIXME
 | 
				
			||||||
    //std::optional<ATBPaymentOption> paymentOption = tariff->getPaymentOptionForKey(permitType.get());
 | 
					    //std::optional<ATBPaymentOption> paymentOption = tariff->getPaymentOptionForKey(permitType.get());
 | 
				
			||||||
@@ -473,7 +477,12 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
 | 
				
			|||||||
    //}
 | 
					    //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
					    int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
				
			||||||
    qCritical() << "   compute_next_timestep()   payment option index: " << paymentOptionIndex;
 | 
					    int const &pop_plus_steps = tariff->getPaymentOptions(paymentOptionIndex).pop_plus_steps;
 | 
				
			||||||
 | 
					    int const &pop_minus_steps = tariff->getPaymentOptions(paymentOptionIndex).pop_minus_steps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qCritical() << __LINE__ << "compute_next_timestep()   payment option index: " << paymentOptionIndex;
 | 
				
			||||||
 | 
					    qCritical() << __LINE__ << "compute_next_timestep()             plus steps: " << pop_plus_steps;
 | 
				
			||||||
 | 
					    qCritical() << __LINE__ << "compute_next_timestep()            minus steps: " << pop_minus_steps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Configuration const *cfg = tariff;
 | 
					    Configuration const *cfg = tariff;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -481,19 +490,19 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
 | 
				
			|||||||
    PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
					    PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
				
			||||||
    switch (paymentMethodId) {
 | 
					    switch (paymentMethodId) {
 | 
				
			||||||
    case PaymentMethod::Progressive:
 | 
					    case PaymentMethod::Progressive:
 | 
				
			||||||
        qCritical() << __LINE__ << "   compute_next_timestep()     paymentMethodId: Progressive";
 | 
					        qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Progressive";
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case PaymentMethod::Degressive:
 | 
					    case PaymentMethod::Degressive:
 | 
				
			||||||
        qCritical() << __LINE__ << "   compute_next_timestep()     paymentMethodId: Degressive";
 | 
					        qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Degressive";
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case PaymentMethod::Linear:
 | 
					    case PaymentMethod::Linear:
 | 
				
			||||||
        qCritical() << __LINE__ << "   compute_next_timestep()     paymentMethodId: Linear";
 | 
					        qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Linear";
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case PaymentMethod::Steps:
 | 
					    case PaymentMethod::Steps:
 | 
				
			||||||
        qCritical() << __LINE__ << "   compute_next_timestep()     paymentMethodId: Steps";
 | 
					        qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Steps";
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case PaymentMethod::Undefined:
 | 
					    case PaymentMethod::Undefined:
 | 
				
			||||||
        qCritical() << __LINE__ << "   compute_next_timestep()     paymentMethodId: Undefined";
 | 
					        qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Undefined";
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -501,63 +510,106 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
 | 
				
			|||||||
    // without given YearPeriod, SpecialDays and SpecialDaysWorktime
 | 
					    // without given YearPeriod, SpecialDays and SpecialDaysWorktime
 | 
				
			||||||
    if ((paymentMethodId == PaymentMethod::Steps) ||
 | 
					    if ((paymentMethodId == PaymentMethod::Steps) ||
 | 
				
			||||||
        // progressive tariff: e.g. Neuhauser, Kirchdorf (743)
 | 
					        // progressive tariff: e.g. Neuhauser, Kirchdorf (743)
 | 
				
			||||||
        (paymentMethodId == PaymentMethod::Progressive))
 | 
					        (paymentMethodId == PaymentMethod::Progressive) ||
 | 
				
			||||||
 | 
					        // degressive tariff: e.g. Fuchs Technik (500)
 | 
				
			||||||
 | 
					        (paymentMethodId == PaymentMethod::Degressive))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // int paymentOptionIndex = 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        QList<int> &stepList = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex);
 | 
					        QList<int> &stepList = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        int const size = stepList.size();
 | 
					        int const size = stepList.size();
 | 
				
			||||||
        if (size == 0) {
 | 
					        if (size == 0) {
 | 
				
			||||||
            qCritical() << "compute_next_timestep() *ERROR empty step-list*";
 | 
					            qCritical() << "compute_next_timestep() *ERROR empty step-list*";
 | 
				
			||||||
            return  currentTimeMinutes;
 | 
					            return  currentTimeMinutes;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        qCritical() << "   compute_next_timestep()      first time step:" << stepList[0];
 | 
					        qCritical() << __LINE__ << "compute_next_timestep()      first time step:" << stepList[0];
 | 
				
			||||||
        qCritical() << "   compute_next_timestep()            timeSteps:" << stepList;
 | 
					        qCritical() << __LINE__ << "compute_next_timestep()            timeSteps:" << stepList;
 | 
				
			||||||
        qCritical() << "   compute_next_timestep() currentTimeInMinutes:" << currentTimeMinutes;
 | 
					        qCritical() << __LINE__ << "compute_next_timestep() currentTimeInMinutes:" << currentTimeMinutes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // consider time shift: the step-list might have been computed at a
 | 
					        // consider time shift: the step-list might have been computed at a
 | 
				
			||||||
        // slightly different time point
 | 
					        // slightly different time point
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int currentStepIndex = stepList.indexOf(currentTimeMinutes);
 | 
				
			||||||
 | 
					        if (currentStepIndex == -1) {
 | 
				
			||||||
 | 
					            unsigned minimalDistance = ~0;
 | 
				
			||||||
 | 
					            int j = -1;
 | 
				
			||||||
 | 
					            for (int i = 0; i < stepList.size(); ++i) {
 | 
				
			||||||
 | 
					                unsigned distance = std::abs(stepList[i] - currentTimeMinutes);
 | 
				
			||||||
 | 
					                if (distance < minimalDistance) {
 | 
				
			||||||
 | 
					                    minimalDistance = distance;
 | 
				
			||||||
 | 
					                    j = i;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            // max. tolerance set to 3 minutes
 | 
				
			||||||
 | 
					            unsigned const tolerance = std::min(minimalDistance, (unsigned)(3));
 | 
				
			||||||
 | 
					            if (j != -1) {
 | 
				
			||||||
 | 
					                stepList[j] = currentTimeMinutes;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
        int maxStep = -1;
 | 
					        int maxStep = -1;
 | 
				
			||||||
        if (size >= 2) {
 | 
					        if (size >= 2) {
 | 
				
			||||||
            maxStep = stepList[1] - stepList[0];
 | 
					            maxStep = stepList[1] - stepList[0];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        int tolerance = (maxStep == -1) ? 5 : std::min(maxStep, 5);
 | 
					        // max. tolerance set to 5 minutes
 | 
				
			||||||
 | 
					        int const tolerance = (maxStep == -1) ? 5 : std::min(maxStep, 5);
 | 
				
			||||||
        for (int i=0; i < stepList.size(); ++i) {
 | 
					        for (int i=0; i < stepList.size(); ++i) {
 | 
				
			||||||
            if (std::abs(stepList[i] - currentTimeMinutes) <= tolerance) {
 | 
					            if (std::abs(stepList[i] - currentTimeMinutes) <= tolerance) {
 | 
				
			||||||
                qCritical().noquote()
 | 
					                qCritical().noquote()
 | 
				
			||||||
                    << QString("   compute_next_timestep() correction stepList[%1]=%2 -> %3:")
 | 
					                    << __LINE__ << QString("compute_next_timestep() correction stepList[%1]=%2 -> %3:")
 | 
				
			||||||
                                    .arg(i).arg(stepList[0]).arg(currentTimeMinutes);
 | 
					                                    .arg(i).arg(stepList[0]).arg(currentTimeMinutes);
 | 
				
			||||||
                stepList[i] = currentTimeMinutes;
 | 
					                stepList[i] = currentTimeMinutes;
 | 
				
			||||||
                qCritical() << "   compute_next_timestep()        NEW timeSteps:" << stepList;
 | 
					                qCritical() << __LINE__ << "compute_next_timestep()        NEW timeSteps:" << stepList;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        int currentStepIndex = stepList.indexOf(currentTimeMinutes);
 | 
					        int currentStepIndex = stepList.indexOf(currentTimeMinutes);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        currentStepIndex = stepList.indexOf(currentTimeMinutes);
 | 
				
			||||||
 | 
					        qCritical() << __LINE__ << "compute_next_timestep() currentStepIndex (" << currentStepIndex << ")";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (currentStepIndex == -1) {
 | 
					        if (currentStepIndex == -1) {
 | 
				
			||||||
            qCritical() << "compute_next_timestep() *NO STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
 | 
					            qCritical() << __LINE__ << "compute_next_timestep() *NO STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
 | 
				
			||||||
            return  currentTimeMinutes;
 | 
					            return  currentTimeMinutes;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (UpDown == 1) { // UP
 | 
					        if (UpDown == 1) { // UP
 | 
				
			||||||
            if (stepList[currentStepIndex] == stepList.last()) {
 | 
					            if (stepList[currentStepIndex] == stepList.last()) {
 | 
				
			||||||
                qCritical() << "compute_next_timestep() *NO NEXT STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
 | 
					                qCritical() << __LINE__ << "compute_next_timestep() *NO NEXT STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
 | 
				
			||||||
                return  currentTimeMinutes;
 | 
					                return  currentTimeMinutes;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else {
 | 
					            else {
 | 
				
			||||||
                qCritical() << "   compute_next_timestep() return next time step:" << stepList[currentStepIndex + 1];
 | 
					                int const rest = currentStepIndex % pop_plus_steps;
 | 
				
			||||||
                return stepList[currentStepIndex + 1];
 | 
					
 | 
				
			||||||
 | 
					                if (rest) {
 | 
				
			||||||
 | 
					                    currentStepIndex -= rest;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                qCritical() << __LINE__ << "compute_next_timestep() currentStepIndex (" << currentStepIndex << ")";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                int const nextStepIndex = currentStepIndex + pop_plus_steps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                qCritical() << __LINE__ << "compute_next_timestep()       next step index:" << nextStepIndex;
 | 
				
			||||||
 | 
					                if (nextStepIndex >= 0 && nextStepIndex < stepList.size()) {
 | 
				
			||||||
 | 
					                    qCritical() << __LINE__ << "compute_next_timestep() return next time step:" << stepList[nextStepIndex];
 | 
				
			||||||
 | 
					                    return stepList[nextStepIndex];
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (UpDown == 0) { // DOWN
 | 
					        if (UpDown == 0) { // DOWN
 | 
				
			||||||
            if (stepList[currentStepIndex] == stepList.first()) {
 | 
					            if (stepList[currentStepIndex] == stepList.first()) {
 | 
				
			||||||
                qCritical() << "compute_next_timestep() *NO PREVIOUS STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
 | 
					                qCritical() << __LINE__ << "compute_next_timestep() *NO PREVIOUS STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
 | 
				
			||||||
                return  currentTimeMinutes;
 | 
					                return  currentTimeMinutes;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else {
 | 
					            else {
 | 
				
			||||||
                qCritical() << "   compute_next_timestep() return next time step:" << stepList[currentStepIndex - 1];
 | 
					                int const nextStepIndex = currentStepIndex - pop_minus_steps;
 | 
				
			||||||
                return stepList[currentStepIndex - 1];
 | 
					                qCritical() << __LINE__ << "compute_next_timestep()       next step index:" << nextStepIndex;
 | 
				
			||||||
 | 
					                if (nextStepIndex >= 0 && nextStepIndex < stepList.size()) {
 | 
				
			||||||
 | 
					                    qCritical() << __LINE__ << "compute_next_timestep() return next time step:" << stepList[nextStepIndex];
 | 
				
			||||||
 | 
					                    return stepList[nextStepIndex];
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else
 | 
					    } else
 | 
				
			||||||
@@ -660,7 +712,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
					CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			||||||
        parking_tariff_t *tariff,
 | 
					        parking_tariff_t *tariff,
 | 
				
			||||||
        QDateTime &start_parking_time,
 | 
					        QDateTime &start_parking_time_,
 | 
				
			||||||
        int netto_parking_time,
 | 
					        int netto_parking_time,
 | 
				
			||||||
        QDateTime &end_parking_time,
 | 
					        QDateTime &end_parking_time,
 | 
				
			||||||
        struct price_t *price,
 | 
					        struct price_t *price,
 | 
				
			||||||
@@ -669,6 +721,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    CalcState calcState;
 | 
					    CalcState calcState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QDateTime start_parking_time(start_parking_time_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
					    int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
					    double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
				
			||||||
@@ -682,9 +736,9 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
                << "               start + netto: " << start_parking_time.addSecs(netto_parking_time * 60) << endl
 | 
					                << "               start + netto: " << start_parking_time.addSecs(netto_parking_time * 60) << endl
 | 
				
			||||||
                << "                      minMin: " << minMin << endl
 | 
					                << "                      minMin: " << minMin << endl
 | 
				
			||||||
                << "                      maxMin: " << maxMin
 | 
					                << "                      maxMin: " << maxMin
 | 
				
			||||||
 | 
					                << "                     prepaid: " << prepaid
 | 
				
			||||||
                << "                  permitType: " << permitType.toString();
 | 
					                << "                  permitType: " << permitType.toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (netto_parking_time < 0) {
 | 
					    if (netto_parking_time < 0) {
 | 
				
			||||||
        calcState.setDesc(QString("end=%1, start=%2")
 | 
					        calcState.setDesc(QString("end=%1, start=%2")
 | 
				
			||||||
                          .arg(end_parking_time.toString(Qt::ISODate),
 | 
					                          .arg(end_parking_time.toString(Qt::ISODate),
 | 
				
			||||||
@@ -705,59 +759,71 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    double cost = -1;
 | 
					    double cost = -1;
 | 
				
			||||||
    if (start_parking_time.isValid()) {
 | 
					    if (start_parking_time.isValid()) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        // qCritical() << __func__ << __LINE__;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps ||
 | 
					        if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps ||
 | 
				
			||||||
            tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Degressive) {
 | 
					            tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Degressive) {
 | 
				
			||||||
        // qCritical() << __func__ << __LINE__;
 | 
					 | 
				
			||||||
            // hier muesste man unterscheiden: uebertrag oder nicht?
 | 
					            // hier muesste man unterscheiden: uebertrag oder nicht?
 | 
				
			||||||
            calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time,
 | 
					            calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time,
 | 
				
			||||||
                                                                   netto_parking_time, paymentOptionIndex);
 | 
					                                                                   netto_parking_time, paymentOptionIndex);
 | 
				
			||||||
            if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
 | 
					            if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
 | 
				
			||||||
                 qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
					                qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
                             << calcState.toString();
 | 
					                            << calcState.toString();
 | 
				
			||||||
        // qCritical() << __func__ << __LINE__;
 | 
					 | 
				
			||||||
                return calcState;
 | 
					                return calcState;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        // qCritical() << __func__ << __LINE__;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QList<int> lll = Calculator::GetInstance().GetTimeSteps(tariff);
 | 
					            QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex, start_parking_time_);
 | 
				
			||||||
 | 
					            Q_UNUSED(tlist);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // netto_parking_time = compute_next_timestep(tariff, netto_parking_time, 1, permitType);
 | 
					            // compute cost (price)
 | 
				
			||||||
 | 
					 | 
				
			||||||
            qCritical() << "LINE" << __LINE__ << "netto" << netto_parking_time << lll;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // qCritical() << __func__ << __LINE__;
 | 
					 | 
				
			||||||
            cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex);
 | 
					            cost = Calculator::GetInstance().GetCostFromDuration(tariff, start_parking_time, netto_parking_time, paymentOptionIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            int weekDay = start_parking_time.date().dayOfWeek();
 | 
					            int weekDay = start_parking_time.date().dayOfWeek();
 | 
				
			||||||
            int const 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;
 | 
				
			||||||
            QTime const carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
 | 
					            qCritical() << __func__ << __LINE__ << "configured carry-over-id" << pop_carry_over_option_id;
 | 
				
			||||||
            //QTime const carryOverEnd = cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end;
 | 
					 | 
				
			||||||
            int const carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            qCritical() << "LINE" << __LINE__ << "carryStart" << carryOverStart.toString(Qt::ISODate);
 | 
					            std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
 | 
				
			||||||
            qCritical() << "LINE" << __LINE__ << "carryDur" << carryOverDuration;
 | 
					            if (yperiod.has_value()) {
 | 
				
			||||||
            qCritical() << "LINE" << __LINE__ << "start" << start_parking_time.toString(Qt::ISODate);
 | 
					                ATBPeriodYear const &period = yperiod.value();
 | 
				
			||||||
 | 
					                pop_carry_over_option_id = period.pye_id;
 | 
				
			||||||
            if (start_parking_time.time() > carryOverStart) {
 | 
					                qCritical() << __func__ << __LINE__ << "re-computed carry-over-id" << pop_carry_over_option_id;
 | 
				
			||||||
                //int const backTime = carryOverStart.secsTo(start_parking_time.time()) / 60;
 | 
					 | 
				
			||||||
            //qCritical() << "LINE" << __LINE__ << "backTime" << backTime;
 | 
					 | 
				
			||||||
            //qCritical() << "LINE" << __LINE__ << "backTime + dur" << backTime + carryOverDuration;
 | 
					 | 
				
			||||||
                start_parking_time.setTime(carryOverStart);
 | 
					 | 
				
			||||||
                start_parking_time = start_parking_time.addSecs(carryOverDuration * 60);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            end_parking_time = start_parking_time.addSecs(netto_parking_time*60);
 | 
					            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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            qCritical() << "LINE" << __LINE__ << "netto" << netto_parking_time;
 | 
					            qCritical() << __func__ << __LINE__ << "carryOverStart" << carryOverStart.toString(Qt::ISODate);
 | 
				
			||||||
            qCritical() << "LINE" << __LINE__ << "start" << start_parking_time.toString(Qt::ISODate);
 | 
					            qCritical() << __func__ << __LINE__ << "carryOverDuration" << carryOverDuration;
 | 
				
			||||||
            qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
					
 | 
				
			||||||
                         << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
 | 
					            // 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);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 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);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
        // qCritical() << __func__ << __LINE__;
 | 
					 | 
				
			||||||
            cost = Calculator::GetInstance().GetCostFromDuration(
 | 
					            cost = Calculator::GetInstance().GetCostFromDuration(
 | 
				
			||||||
                        tariff,
 | 
					                        tariff,
 | 
				
			||||||
                        tariff->getPaymentOptions().pop_payment_method_id,
 | 
					                        tariff->getPaymentOptions().pop_payment_method_id,
 | 
				
			||||||
@@ -774,8 +840,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // DEBUG
 | 
					        // DEBUG
 | 
				
			||||||
        qCritical() << __LINE__ << "            end_parking_time: " << end_parking_time;
 | 
					        //qCritical() << __LINE__ << "            end_parking_time: " << end_parking_time;
 | 
				
			||||||
        qCritical() << __LINE__ << "  -> calculated cost (netto): " << cost;
 | 
					        //qCritical() << __LINE__ << "  -> calculated cost (netto): " << cost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        price->brutto = price->vat = price->vat_percentage = 0;
 | 
					        price->brutto = price->vat = price->vat_percentage = 0;
 | 
				
			||||||
        price->units = cost;
 | 
					        price->units = cost;
 | 
				
			||||||
@@ -785,6 +851,12 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
        return calcState.set(CalcState::State::INVALID_START_DATE);
 | 
					        return calcState.set(CalcState::State::INVALID_START_DATE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (end_parking_time.time().hour() == 0 && end_parking_time.time().minute() == 0) {
 | 
				
			||||||
 | 
					        end_parking_time = end_parking_time.addDays(-1);
 | 
				
			||||||
 | 
					        end_parking_time.setTime(QTime(23, 59, 0));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    qCritical() << __func__ << __LINE__ << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return calcState.set(CalcState::State::SUCCESS);
 | 
					    return calcState.set(CalcState::State::SUCCESS);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -851,10 +923,15 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
    bool const nextDay = false;
 | 
					    bool const nextDay = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // DEBUG
 | 
					    // DEBUG
 | 
				
			||||||
    qCritical() << "compute_duration_for_parking_ticket(2): ";
 | 
					    // if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
    qCritical() << " payment option index: " << paymentOptionIndex;
 | 
					        qCritical() << "\ncompute_duration_for_parking_ticket(2):";
 | 
				
			||||||
    qCritical() << "              prepaid: " << prepaid;
 | 
					        qCritical() << "                              start time:" << start_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
    qCritical() << "                price: " << price;
 | 
					        qCritical() << "                    payment option index:" << paymentOptionIndex;
 | 
				
			||||||
 | 
					        qCritical() << "                                 prepaid:" << prepaid;
 | 
				
			||||||
 | 
					        qCritical() << "                                   price:" << price;
 | 
				
			||||||
 | 
					        qCritical() << "                             permit type:" << permitType.toString() << endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (start_parking_time.isValid()) {
 | 
					    if (start_parking_time.isValid()) {
 | 
				
			||||||
        QString cs = start_parking_time.toString(Qt::ISODate);
 | 
					        QString cs = start_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
@@ -924,15 +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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // DEBUG
 | 
					 | 
				
			||||||
            //qCritical() << "compute_duration_for_parking_ticket(): ";
 | 
					 | 
				
			||||||
            //qCritical() << "                 endTime: " << endTime;
 | 
					 | 
				
			||||||
            //qCritical() << "           ticketEndTime: " << ticketEndTime;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            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 (ticketEndTime.time().hour() == 0 && ticketEndTime.time().minute() == 0) {
 | 
				
			||||||
 | 
					                ticketEndTime = ticketEndTime.addDays(-1);
 | 
				
			||||||
 | 
					                ticketEndTime.setTime(QTime(23, 59, 0));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // DEBUG
 | 
				
			||||||
 | 
					            qCritical() << "\ncompute_duration_for_parking_ticket():";
 | 
				
			||||||
 | 
					            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);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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;
 | 
				
			||||||
@@ -135,14 +138,20 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
					    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
				
			||||||
    int const paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get());
 | 
					    int const paymentOptionIndex = cfg->getPaymentOptionIndex(permitType.get());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qCritical() << DBG_HEADER << "          start:" << inputDate.toString(Qt::ISODate);
 | 
					    if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
    qCritical() << DBG_HEADER << "   option index:" << paymentOptionIndex;
 | 
					        qCritical() << DBG_HEADER << "          start:" << inputDate.toString(Qt::ISODate);
 | 
				
			||||||
    qCritical() << DBG_HEADER << "paymentMethodId:" << static_cast<int>(paymentMethodId);
 | 
					        qCritical() << DBG_HEADER << "   option index:" << paymentOptionIndex;
 | 
				
			||||||
    qCritical() << DBG_HEADER << "        prepaid:" << prepaid;
 | 
					        qCritical() << DBG_HEADER << "paymentMethodId:" << static_cast<int>(paymentMethodId);
 | 
				
			||||||
    qCritical() << DBG_HEADER << "   cost (price):" << cost;
 | 
					        qCritical() << DBG_HEADER << "        prepaid:" << prepaid;
 | 
				
			||||||
 | 
					        qCritical() << DBG_HEADER << "   cost (price):" << cost;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QList<int> tsteps = Calculator::GetInstance().GetTimeSteps(cfg, paymentOptionIndex, inputDate);
 | 
					    QList<int> tsteps = Calculator::GetInstance().GetTimeSteps(cfg, paymentOptionIndex, inputDate);
 | 
				
			||||||
    qCritical() << DBG_HEADER << "     time steps:" << tsteps;
 | 
					    if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					        qCritical() << DBG_HEADER << "     time steps:" << tsteps;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        Q_UNUSED(tsteps);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (paymentMethodId == PaymentMethod::Degressive) {
 | 
					    if (paymentMethodId == PaymentMethod::Degressive) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -153,7 +162,8 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
            return CalcState::BELOW_MIN_PARKING_PRICE.toStdString();
 | 
					            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;
 | 
				
			||||||
@@ -168,6 +178,9 @@ std::string 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;
 | 
				
			||||||
@@ -175,8 +188,8 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                    price = pra_price;
 | 
					                    price = pra_price;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //qCritical() << DBG_HEADER << "  PRICE" << price << "COST" << cost;
 | 
					                // qCritical() << DBG_HEADER << "  PRICE" << price << "COST" << cost;
 | 
				
			||||||
                //qCritical() << DBG_HEADER << "  duration id" << durationId;
 | 
					                // qCritical() << DBG_HEADER << "  duration id" << durationId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                auto search = cfg->Duration.find(durationId);
 | 
					                auto search = cfg->Duration.find(durationId);
 | 
				
			||||||
                if (search != cfg->Duration.end()) {
 | 
					                if (search != cfg->Duration.end()) {
 | 
				
			||||||
@@ -185,7 +198,9 @@ std::string 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;
 | 
				
			||||||
@@ -201,11 +216,16 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                            //found = true;
 | 
					                            //found = true;
 | 
				
			||||||
                            //qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
 | 
					                            //qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration_previous" << duration_previous;
 | 
				
			||||||
                            //qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration in minutes" << durationInMinutes;
 | 
					                            //qCritical() << "(" << __func__ << ":" << __LINE__ << ") duration in minutes" << durationInMinutes;
 | 
				
			||||||
                            QDateTime d(inputDate.addSecs(duration_previous * 60));
 | 
					                            QDateTime d;
 | 
				
			||||||
 | 
					                            if (pop_accumulate_durations) {
 | 
				
			||||||
 | 
					                                d = inputDate.addSecs(durationInMinutes * 60);
 | 
				
			||||||
 | 
					                            } else {
 | 
				
			||||||
 | 
					                                d = inputDate.addSecs(duration_previous * 60);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            qCritical() << DBG_HEADER << "                    provided price (cost):" << cost;
 | 
					                            qCritical() << DBG_HEADER << "                    provided price (cost):" << cost;
 | 
				
			||||||
                            qCritical() << DBG_HEADER << "        computed time for price (minutes):" << duration_previous;
 | 
					                            qCritical() << DBG_HEADER << "        computed time for price (minutes):" << duration_previous;
 | 
				
			||||||
                            qCritical() << DBG_HEADER << "configured 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 CalcState::BELOW_MIN_PARKING_TIME.toStdString(); // minimal parking time is set by GetTimeSteps()
 | 
					                                return CalcState::BELOW_MIN_PARKING_TIME.toStdString(); // minimal parking time is set by GetTimeSteps()
 | 
				
			||||||
@@ -287,6 +307,9 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                        QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
 | 
					                        QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
 | 
				
			||||||
                        QTime pwd_time_to = QTime::fromString(QString::fromStdString(iter->second.pwd_time_to), Qt::ISODate);
 | 
					                        QTime pwd_time_to = QTime::fromString(QString::fromStdString(iter->second.pwd_time_to), Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        //qCritical() << DBG_HEADER << "from" << pwd_time_from.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                        //qCritical() << DBG_HEADER << "  to" << pwd_time_to.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if (inputDate.time() < pwd_time_from) {
 | 
					                        if (inputDate.time() < pwd_time_from) {
 | 
				
			||||||
                            inputDate.setTime(pwd_time_from);
 | 
					                            inputDate.setTime(pwd_time_from);
 | 
				
			||||||
                            useWeekDaysWorkTimeOfOtherDay = false;
 | 
					                            useWeekDaysWorkTimeOfOtherDay = false;
 | 
				
			||||||
@@ -418,6 +441,10 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                                //qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << d;
 | 
					                                //qCritical() << DBG_HEADER << "XXXXXXXXXXXXXXXXXXXXX" << d;
 | 
				
			||||||
                                return d.toString(Qt::ISODate).toStdString();
 | 
					                                return d.toString(Qt::ISODate).toStdString();
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            durationInSecs = cfg->Duration.find(durationId)->second.pun_duration * 60;
 | 
				
			||||||
 | 
					                            //qCritical() << DBG_HEADER << "DURATION-SECS" << durationInSecs;
 | 
				
			||||||
 | 
					                            //qCritical() << DBG_HEADER << "DURATION-MINS" << durationInSecs / 60;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if ((double)price == cost) {
 | 
					                        if ((double)price == cost) {
 | 
				
			||||||
@@ -465,6 +492,7 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                                                    QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
 | 
					                                                    QTime pwd_time_from = QTime::fromString(QString::fromStdString(iter->second.pwd_time_from), Qt::ISODate);
 | 
				
			||||||
                                                    if (next_working_time_from < pwd_time_from) {
 | 
					                                                    if (next_working_time_from < pwd_time_from) {
 | 
				
			||||||
                                                        next_working_time_from = pwd_time_from;
 | 
					                                                        next_working_time_from = pwd_time_from;
 | 
				
			||||||
 | 
					                                                        qCritical() << DBG_HEADER << "next working time from" << next_working_time_from.toString(Qt::ISODate);
 | 
				
			||||||
                                                        break;
 | 
					                                                        break;
 | 
				
			||||||
                                                    }
 | 
					                                                    }
 | 
				
			||||||
                                                }
 | 
					                                                }
 | 
				
			||||||
@@ -1004,7 +1032,8 @@ uint32_t Calculator::GetCostFromDuration(Configuration * cfg,
 | 
				
			|||||||
    if (paymentMethodId == PaymentMethod::Steps ||
 | 
					    if (paymentMethodId == PaymentMethod::Steps ||
 | 
				
			||||||
        paymentMethodId == PaymentMethod::Degressive) {
 | 
					        paymentMethodId == PaymentMethod::Degressive) {
 | 
				
			||||||
        int const timeStepInMinutes = start.secsTo(end) / 60;
 | 
					        int const timeStepInMinutes = start.secsTo(end) / 60;
 | 
				
			||||||
 | 
					        QList<int> tlist = Calculator::GetInstance().GetTimeSteps(cfg, paymentOptionIndex, start);
 | 
				
			||||||
 | 
					        qCritical() << DBG_HEADER << "timeStepList" << timeStepInMinutes << tlist;
 | 
				
			||||||
        qCritical() << DBG_HEADER << "timeStepInMinutes" << timeStepInMinutes << start.toString(Qt::ISODate);
 | 
					        qCritical() << DBG_HEADER << "timeStepInMinutes" << timeStepInMinutes << start.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return GetPriceForTimeStep(cfg, timeStepInMinutes, paymentOptionIndex);
 | 
					        return GetPriceForTimeStep(cfg, timeStepInMinutes, paymentOptionIndex);
 | 
				
			||||||
@@ -2750,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";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2768,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);
 | 
				
			||||||
@@ -2795,9 +3060,11 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
 | 
				
			|||||||
    // paymentOptionIndex = 1;
 | 
					    // paymentOptionIndex = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
					    int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
				
			||||||
 | 
					    int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
 | 
				
			||||||
    int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
 | 
					    int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    uint32_t price = 0;
 | 
					    uint32_t price = 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;
 | 
				
			||||||
@@ -2813,19 +3080,25 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
 | 
				
			|||||||
        //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
 | 
					        //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
 | 
				
			||||||
        //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
 | 
					        //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        int const pun_duration = cfg->Duration.find(payment_unit_id)->second.pun_duration;
 | 
					        if (pop_accumulate_durations) {
 | 
				
			||||||
        //int const pun_duration = cfg->Duration.find(2)->second.pun_duration;
 | 
					            pun_duration += cfg->Duration.find(payment_unit_id)->second.pun_duration;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            pun_duration = cfg->Duration.find(payment_unit_id)->second.pun_duration;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (pop_accumulate_prices) {
 | 
					        if (pop_accumulate_prices) {
 | 
				
			||||||
            price += itr->second.pra_price;
 | 
					            price += itr->second.pra_price;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            price = (uint32_t)(itr->second.pra_price);
 | 
					            price = (uint32_t)(itr->second.pra_price);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
 | 
					        if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
        //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
 | 
				
			||||||
        //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << pun_id;
 | 
				
			||||||
        //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << pun_duration;
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_unit_id" << payment_unit_id;
 | 
				
			||||||
        //qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << pun_duration;
 | 
				
			||||||
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (timeStep == pun_duration) {
 | 
					        if (timeStep == pun_duration) {
 | 
				
			||||||
            qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,7 @@
 | 
				
			|||||||
#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 <QString>
 | 
					#include <QString>
 | 
				
			||||||
@@ -35,6 +36,7 @@ MemberType Configuration::IdentifyJsonMember(const char* member_name)
 | 
				
			|||||||
    if (strcmp(member_name, "Interpolation") == 0) return MemberType::InterpolationType;
 | 
					    if (strcmp(member_name, "Interpolation") == 0) return MemberType::InterpolationType;
 | 
				
			||||||
    if (strcmp(member_name, "Prepaid") == 0) return MemberType::PrepaidType;
 | 
					    if (strcmp(member_name, "Prepaid") == 0) return MemberType::PrepaidType;
 | 
				
			||||||
    if (strcmp(member_name, "CarryOver") == 0) return MemberType::CarryOverType;
 | 
					    if (strcmp(member_name, "CarryOver") == 0) return MemberType::CarryOverType;
 | 
				
			||||||
 | 
					    if (strcmp(member_name, "PrepaidOption") == 0) return MemberType::PrepaidOptionType;
 | 
				
			||||||
    else return MemberType::UnknownType;
 | 
					    else return MemberType::UnknownType;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -108,6 +110,7 @@ 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();
 | 
				
			||||||
@@ -141,7 +144,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                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();
 | 
				
			||||||
@@ -171,6 +174,61 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                    {
 | 
					                    {
 | 
				
			||||||
                    case MemberType::UnknownType:
 | 
					                    case MemberType::UnknownType:
 | 
				
			||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case MemberType::PrepaidOptionType: {
 | 
				
			||||||
 | 
					                        if (QString(inner_obj_name) == QString("prepaid_option_id")) {
 | 
				
			||||||
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
 | 
					                                int const &x = k->value.GetInt();
 | 
				
			||||||
 | 
					                                TariffPrepayOption.id = x;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        } else
 | 
				
			||||||
 | 
					                        if (QString(inner_obj_name) == QString("prepaid_option_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
 | 
				
			||||||
 | 
					                                            QString member(QString::fromStdString(w->name.GetString()));
 | 
				
			||||||
 | 
					                                            if (member == "prepaid_option_day") {
 | 
				
			||||||
 | 
					                                                if (w->value.IsInt()) {
 | 
				
			||||||
 | 
					                                                    rapidjson::SizeType const d = w->value.GetInt();
 | 
				
			||||||
 | 
					                                                    if (d != (j+1)) {
 | 
				
			||||||
 | 
					                                                        qCritical() << "ERROR: misconfigured jsonfile" << d << "!=" << (j+1);
 | 
				
			||||||
 | 
					                                                    }
 | 
				
			||||||
 | 
					                                                    TariffPrepayOption.prepay[day].day = day;
 | 
				
			||||||
 | 
					                                                }
 | 
				
			||||||
 | 
					                                            } else
 | 
				
			||||||
 | 
					                                            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;
 | 
				
			||||||
 | 
					                                                }
 | 
				
			||||||
 | 
					                                            }
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    } 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")) {
 | 
				
			||||||
                            if (k->value.IsInt()) {
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
@@ -231,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()) {
 | 
				
			||||||
@@ -598,6 +657,14 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                            if (k->value.IsInt()) {
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
                                this->currentPaymentOptions.last().pop_use_only_for_duration = k->value.GetInt();
 | 
					                                this->currentPaymentOptions.last().pop_use_only_for_duration = k->value.GetInt();
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
 | 
					                        } else if (strcmp(inner_obj_name, "pop_plus_steps") == 0) {
 | 
				
			||||||
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
 | 
					                                this->currentPaymentOptions.last().pop_plus_steps = k->value.GetInt();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        } else if (strcmp(inner_obj_name, "pop_minus_steps") == 0) {
 | 
				
			||||||
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
 | 
					                                this->currentPaymentOptions.last().pop_minus_steps = k->value.GetInt();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
                        } 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) {
 | 
				
			||||||
@@ -614,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) {
 | 
				
			||||||
@@ -713,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();
 | 
				
			||||||
@@ -777,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));
 | 
				
			||||||
@@ -831,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;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -999,6 +1108,9 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
 | 
				
			|||||||
    for (int opt=0; opt < numOptions; ++opt) {
 | 
					    for (int opt=0; opt < numOptions; ++opt) {
 | 
				
			||||||
        uint64_t const pop_business_hours = getPaymentOptions(opt).pop_business_hours;
 | 
					        uint64_t const pop_business_hours = getPaymentOptions(opt).pop_business_hours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (pop_business_hours == 0) { // 0 == 24/7
 | 
				
			||||||
 | 
					            return opt;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        uint64_t p = 0;
 | 
					        uint64_t p = 0;
 | 
				
			||||||
        int const dayOfWeek = dt.date().dayOfWeek();
 | 
					        int const dayOfWeek = dt.date().dayOfWeek();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -215,6 +215,43 @@ bool Utilities::IsYearPeriodActive(Configuration const *cfg, QDateTime const &dt
 | 
				
			|||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					std::optional<ATBPeriodYear>
 | 
				
			||||||
 | 
					Utilities::GetYearPeriodActive(Configuration const *cfg, QDateTime const ¤tDateTime) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ATBPeriodYear period;
 | 
				
			||||||
 | 
					    std::optional<ATBPeriodYear> value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (multimap<int, ATBPeriodYear>::const_iterator it = cfg->YearPeriod.cbegin();
 | 
				
			||||||
 | 
					         it != cfg->YearPeriod.cend();
 | 
				
			||||||
 | 
					         ++it) {
 | 
				
			||||||
 | 
					        QDate const s(currentDateTime.date().year(), it->second.pye_start_month, it->second.pye_start_day);
 | 
				
			||||||
 | 
					        QDate const e(currentDateTime.date().year(), it->second.pye_end_month, it->second.pye_end_day);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        QDateTime start(currentDateTime);
 | 
				
			||||||
 | 
					        QDateTime end(currentDateTime);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        start.setDate(s);
 | 
				
			||||||
 | 
					        end.setDate(e);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (start.date().dayOfYear() < end.date().dayOfYear()) {
 | 
				
			||||||
 | 
					            // start and end in the same year
 | 
				
			||||||
 | 
					            if (currentDateTime.date().dayOfYear() >= start.date().dayOfYear() &&
 | 
				
			||||||
 | 
					                currentDateTime.date().dayOfYear() <= end.date().dayOfYear()) {
 | 
				
			||||||
 | 
					                value = value.value_or(it->second);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            if (currentDateTime.date().dayOfYear() >= start.date().dayOfYear() ||
 | 
				
			||||||
 | 
					                currentDateTime.date().dayOfYear() <= end.date().dayOfYear()) {
 | 
				
			||||||
 | 
					                value = value.value_or(it->second);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return value;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// <inheritdoc/>
 | 
					/// <inheritdoc/>
 | 
				
			||||||
bool Utilities::CheckSpecialDay(Configuration* cfg, const char* currentDateTimeStr, int* specialDayId, double* specialDayPrice)
 | 
					bool Utilities::CheckSpecialDay(Configuration* cfg, const char* currentDateTimeStr, int* specialDayId, double* specialDayPrice)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										219
									
								
								main/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										219
									
								
								main/main.cpp
									
									
									
									
									
								
							@@ -354,7 +354,7 @@ int main() {
 | 
				
			|||||||
        QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
 | 
					        QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
 | 
				
			||||||
        qCritical() << "TimeSteps" << timeSteps;
 | 
					        qCritical() << "TimeSteps" << timeSteps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return 0;
 | 
					        // return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CalcState cs;
 | 
					        CalcState cs;
 | 
				
			||||||
        double cost;
 | 
					        double cost;
 | 
				
			||||||
@@ -363,7 +363,7 @@ 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, 5, 19 + day), QTime()); // 20: (whit) monday,..., 26: sunday
 | 
					            QDateTime s(QDate(2024, 7, 29 + day), QTime()); // 20: (whit) monday,..., 26: sunday
 | 
				
			||||||
            QDateTime end;
 | 
					            QDateTime end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            switch (day) {
 | 
					            switch (day) {
 | 
				
			||||||
@@ -401,9 +401,11 @@ int main() {
 | 
				
			|||||||
                                                        bool prepaid = true);
 | 
					                                                        bool prepaid = true);
 | 
				
			||||||
            */
 | 
					            */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (int minutes = 0; minutes < 1440; ++minutes) {
 | 
					            //for (int minutes = 0; minutes < 1440; ++minutes) {
 | 
				
			||||||
                QDateTime start = s.addSecs(minutes * 60);
 | 
					            for (int minutes = 540; minutes <= 540; ++minutes) {
 | 
				
			||||||
                QDateTime effectiveStart = start;
 | 
					                // QDateTime start = s.addSecs(minutes * 60);
 | 
				
			||||||
 | 
					                QDateTime start(QDateTime::currentDateTime());
 | 
				
			||||||
 | 
					                QDateTime effectiveStart(QDateTime::currentDateTime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (start.time() < QTime(8, 0, 0)) {
 | 
					                if (start.time() < QTime(8, 0, 0)) {
 | 
				
			||||||
                    effectiveStart.setTime(QTime(8, 0, 0));
 | 
					                    effectiveStart.setTime(QTime(8, 0, 0));
 | 
				
			||||||
@@ -415,55 +417,18 @@ int main() {
 | 
				
			|||||||
                    effectiveStart.setTime(QTime(8, 0, 0)); // next day
 | 
					                    effectiveStart.setTime(QTime(8, 0, 0)); // next day
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for (int i = 0; i <= 2100; i += 10) {
 | 
					                for (int i = 30; i <= 30; i += 10) {
 | 
				
			||||||
                //for (int i = 2100; i <= 2100; i += 10) {
 | 
					                //for (int i = 2100; i <= 2100; i += 10) {
 | 
				
			||||||
                    cost = i;
 | 
					                    cost = i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) {      // return value
 | 
					                    if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {      // return value
 | 
				
			||||||
                        durationInMinutes = pop_min_time;
 | 
					                        qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
 | 
				
			||||||
                        if (i > 0) {
 | 
					                                    << "> end" << end.toString(Qt::ISODate);
 | 
				
			||||||
                            durationInMinutes += (i/10) * 4;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        offsetInMinutes = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(22, 0, 0)) {
 | 
					 | 
				
			||||||
                            if (effectiveStart.time().secsTo(QTime(22, 0, 0)) < (durationInMinutes * 60)) {
 | 
					 | 
				
			||||||
                                offsetInMinutes = 600; // 22:00 -> 8:00
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (i == 0) {
 | 
					 | 
				
			||||||
                            i += 20;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if ((durationInMinutes + offsetInMinutes) == (effectiveStart.secsTo(end) / 60)) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            if (day == Qt::Monday && minutes >= 480 && minutes <= 1320) {
 | 
					 | 
				
			||||||
                                qCritical() << "| start ............................" << start.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                                qCritical() << "| cost ............................." << cost;
 | 
					 | 
				
			||||||
                                qCritical() << "| durationInMinutes ................" << durationInMinutes
 | 
					 | 
				
			||||||
                                            << "(" << (durationInMinutes - 60) << "+ 60 )";
 | 
					 | 
				
			||||||
                                qCritical() << "| offsetInMinutes .................." << offsetInMinutes;
 | 
					 | 
				
			||||||
                                qCritical() << "| end .............................." << end.toString(Qt::ISODate) << endl;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            continue;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (!cs) {
 | 
					                    if (!cs) {
 | 
				
			||||||
                        qCritical() << "ERROR CalcState" << cs.toString() << endl;
 | 
					                        qCritical() << "ERROR CalcState" << cs.toString() << endl;
 | 
				
			||||||
                    } else {
 | 
					 | 
				
			||||||
                        qCritical() << cs.toString();
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    qCritical() << __LINE__ << "start ............................" << start.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                    qCritical() << __LINE__ << "effectiveStart ..................." << effectiveStart.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                    qCritical() << __LINE__ << "cost ............................." << cost;
 | 
					 | 
				
			||||||
                    qCritical() << __LINE__ << "durationInMinutes ................" << durationInMinutes;
 | 
					 | 
				
			||||||
                    qCritical() << __LINE__ << "offsetInMinutes .................." << offsetInMinutes;
 | 
					 | 
				
			||||||
                    qCritical() << __LINE__ << "effectiveStart.secsTo(end) / 60 .." << effectiveStart.secsTo(end) / 60;
 | 
					 | 
				
			||||||
                    qCritical() << __LINE__ << "end .............................." << end.toString(Qt::ISODate) << endl;
 | 
					 | 
				
			||||||
                    exit(-1);
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -552,7 +517,7 @@ int main() {
 | 
				
			|||||||
            */
 | 
					            */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //for (int minutes = 0; minutes < 1440; ++minutes) {
 | 
					            //for (int minutes = 0; minutes < 1440; ++minutes) {
 | 
				
			||||||
            for (int minutes = 0; minutes < 1440; minutes += 1) {
 | 
					            for (int minutes = 480; minutes <= 480; minutes += 1) {
 | 
				
			||||||
                QDateTime start = s.addSecs(minutes * 60);
 | 
					                QDateTime start = s.addSecs(minutes * 60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // qCritical() << "start" << start.toString(Qt::ISODate);
 | 
					                // qCritical() << "start" << start.toString(Qt::ISODate);
 | 
				
			||||||
@@ -569,66 +534,32 @@ int main() {
 | 
				
			|||||||
                    effectiveStart.setTime(QTime(8, 0, 0)); // next day
 | 
					                    effectiveStart.setTime(QTime(8, 0, 0)); // next day
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
                for (int i = 10; i <= 400; i += 10) {
 | 
					                for (int i = 10; i <= 400; i += 10) {
 | 
				
			||||||
                //for (int i = 2100; i <= 2100; i += 10) {
 | 
					 | 
				
			||||||
                    cost = i;
 | 
					                    cost = i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) {      // return value
 | 
					                    if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {      // return value
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
 | 
					                        qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
 | 
				
			||||||
                                    << "> end" << end.toString(Qt::ISODate);
 | 
					                                    << "> end" << end.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					 | 
				
			||||||
                        durationInMinutes = pop_min_time;
 | 
					 | 
				
			||||||
                        if (i > 0) {
 | 
					 | 
				
			||||||
                            durationInMinutes += (i/10) * 4;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        offsetInMinutes = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(19, 0, 0)) {
 | 
					 | 
				
			||||||
                            if (effectiveStart.time().secsTo(QTime(19, 0, 0)) < (durationInMinutes * 60)) {
 | 
					 | 
				
			||||||
                                offsetInMinutes = 780; // 19:00 -> 8:00
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (i == 0) {
 | 
					 | 
				
			||||||
                            i += 20;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
                        if ((durationInMinutes + offsetInMinutes) == (effectiveStart.secsTo(end) / 60)) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            if (day == Qt::Monday && minutes >= 480 && minutes <= 1140) {
 | 
					 | 
				
			||||||
                                qCritical() << "| start ............................" << start.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                                qCritical() << "| cost ............................." << cost;
 | 
					 | 
				
			||||||
                                qCritical() << "| durationInMinutes ................" << durationInMinutes
 | 
					 | 
				
			||||||
                                            << "(" << (durationInMinutes - 60) << "+ 60 )";
 | 
					 | 
				
			||||||
                                qCritical() << "| offsetInMinutes .................." << offsetInMinutes;
 | 
					 | 
				
			||||||
                                qCritical() << "| end .............................." << end.toString(Qt::ISODate) << endl;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            continue;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (!cs) {
 | 
					                    if (!cs) {
 | 
				
			||||||
                        qCritical() << "ERROR CalcState" << cs.toString() << endl;
 | 
					                        qCritical() << "ERROR CalcState" << cs.toString() << endl;
 | 
				
			||||||
                    } else {
 | 
					 | 
				
			||||||
//                        qCritical() << cs.toString();
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					                int netto_parking_time = 60;
 | 
				
			||||||
 | 
					                struct price_t price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					                qCritical() << "start" << start.toString(Qt::ISODate);
 | 
				
			||||||
                    qCritical() << __LINE__ << "start ............................" << start.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                    qCritical() << __LINE__ << "effectiveStart ..................." << effectiveStart.toString(Qt::ISODate);
 | 
					 | 
				
			||||||
                    qCritical() << __LINE__ << "cost ............................." << cost;
 | 
					 | 
				
			||||||
                    qCritical() << __LINE__ << "durationInMinutes ................" << durationInMinutes;
 | 
					 | 
				
			||||||
                    qCritical() << __LINE__ << "offsetInMinutes .................." << offsetInMinutes;
 | 
					 | 
				
			||||||
                    qCritical() << __LINE__ << "effectiveStart.secsTo(end) / 60 .." << effectiveStart.secsTo(end) / 60;
 | 
					 | 
				
			||||||
                    qCritical() << __LINE__ << "end .............................." << end.toString(Qt::ISODate) << endl;
 | 
					 | 
				
			||||||
                    exit(-1);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                QDateTime const s = start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if ((cs = compute_price_for_parking_ticket(&cfg, start, netto_parking_time, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
 | 
				
			||||||
 | 
					                        qCritical() << "start" << s.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                    << "netto_parking_time" << netto_parking_time
 | 
				
			||||||
 | 
					                                    << "< price" << price.netto
 | 
				
			||||||
 | 
					                                    << "> end" << end.toString(Qt::ISODate);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -737,7 +668,7 @@ int main() {
 | 
				
			|||||||
                    effectiveStart.setTime(QTime(7, 0, 0)); // next day
 | 
					                    effectiveStart.setTime(QTime(7, 0, 0)); // next day
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 1
 | 
					#if 0
 | 
				
			||||||
                PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
 | 
					                PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
 | 
				
			||||||
                for (int i = 200; i <= 200; i += 10) {
 | 
					                for (int i = 200; i <= 200; i += 10) {
 | 
				
			||||||
                    cost = i;
 | 
					                    cost = i;
 | 
				
			||||||
@@ -760,7 +691,7 @@ int main() {
 | 
				
			|||||||
                //for (int i = 2100; i <= 2100; i += 10) {
 | 
					                //for (int i = 2100; i <= 2100; i += 10) {
 | 
				
			||||||
                    cost = i;
 | 
					                    cost = i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) {      // return value
 | 
					                    if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW)))) {      // return value
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (!cs) {
 | 
					                    if (!cs) {
 | 
				
			||||||
@@ -810,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;
 | 
				
			||||||
@@ -898,7 +836,7 @@ int main() {
 | 
				
			|||||||
            //qCritical() << calcState.toString();
 | 
					            //qCritical() << calcState.toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
					            calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
				
			||||||
                                                (double)9000, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
 | 
					                                                (double)50, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
 | 
				
			||||||
            qCritical() << end.toString(Qt::ISODate);
 | 
					            qCritical() << end.toString(Qt::ISODate);
 | 
				
			||||||
            qCritical() << calcState.toString();
 | 
					            qCritical() << calcState.toString();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -969,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) {
 | 
				
			||||||
@@ -982,16 +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);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            qCritical() << "minimal parking price" << minimal_parking_price;
 | 
					            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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            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,
 | 
				
			||||||
@@ -1000,10 +983,11 @@ int main() {
 | 
				
			|||||||
                qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
 | 
					                qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            s.setTime(QTime(15, 0, 0));
 | 
					// #else
 | 
				
			||||||
 | 
					            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;
 | 
				
			||||||
@@ -1011,9 +995,10 @@ 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
 | 
					#endif
 | 
				
			||||||
@@ -1532,7 +1517,7 @@ int main() {
 | 
				
			|||||||
                    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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs);
 | 
					                        cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
				
			||||||
                        if (cs.getStatus() != CalcState::State::SUCCESS) {
 | 
					                        if (cs.getStatus() != CalcState::State::SUCCESS) {
 | 
				
			||||||
                            if (start.time().hour() >= 8 && start.time().hour() < 18) {
 | 
					                            if (start.time().hour() >= 8 && start.time().hour() < 18) {
 | 
				
			||||||
                                qCritical() << "ERROR CALC-STATE-1=" << QString(cs);
 | 
					                                qCritical() << "ERROR CALC-STATE-1=" << QString(cs);
 | 
				
			||||||
@@ -1555,7 +1540,7 @@ int main() {
 | 
				
			|||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        qCritical() << "compute_price_for_parking_ticket()/GetCostFromDuration() TIME: "
 | 
					                        qCritical() << "compute_price_for_parking_ticket()/GetCostFromDuration() TIME: "
 | 
				
			||||||
                                    << timeSteps.at(i) << "PRICE=" << price1;
 | 
					                                    << timeSteps.at(i) << "PRICE=" << price1 << "end=" << end.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        //std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 4,
 | 
					                        //std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 4,
 | 
				
			||||||
@@ -1639,7 +1624,7 @@ int main() {
 | 
				
			|||||||
                            double cost = 0;
 | 
					                            double cost = 0;
 | 
				
			||||||
                            CalcState cs;
 | 
					                            CalcState cs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
 | 
					                            if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
 | 
				
			||||||
                                cost = price.netto;
 | 
					                                cost = price.netto;
 | 
				
			||||||
                                qCritical() << "step" << *step << ": cost" << cost;
 | 
					                                qCritical() << "step" << *step << ": cost" << cost;
 | 
				
			||||||
                            } else {
 | 
					                            } else {
 | 
				
			||||||
@@ -1723,7 +1708,7 @@ int main() {
 | 
				
			|||||||
                            double cost = 0;
 | 
					                            double cost = 0;
 | 
				
			||||||
                            CalcState cs;
 | 
					                            CalcState cs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
 | 
					                            if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
 | 
				
			||||||
                                cost = price.netto;
 | 
					                                cost = price.netto;
 | 
				
			||||||
                                qCritical() << "step" << *step << ": cost" << cost;
 | 
					                                qCritical() << "step" << *step << ": cost" << cost;
 | 
				
			||||||
                            } else {
 | 
					                            } else {
 | 
				
			||||||
@@ -1808,7 +1793,7 @@ int main() {
 | 
				
			|||||||
                            double cost = 0;
 | 
					                            double cost = 0;
 | 
				
			||||||
                            CalcState cs;
 | 
					                            CalcState cs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
 | 
					                            if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
 | 
				
			||||||
                                cost = price.netto;
 | 
					                                cost = price.netto;
 | 
				
			||||||
                                qCritical() << "step" << *step << ": cost" << cost;
 | 
					                                qCritical() << "step" << *step << ": cost" << cost;
 | 
				
			||||||
                            } else {
 | 
					                            } else {
 | 
				
			||||||
@@ -1866,7 +1851,7 @@ int main() {
 | 
				
			|||||||
                        double cost = 0;
 | 
					                        double cost = 0;
 | 
				
			||||||
                        CalcState cs;
 | 
					                        CalcState cs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
 | 
					                        if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
 | 
				
			||||||
                            cost = price.netto;
 | 
					                            cost = price.netto;
 | 
				
			||||||
                            qCritical() << "step" << *step << ": cost" << cost;
 | 
					                            qCritical() << "step" << *step << ": cost" << cost;
 | 
				
			||||||
                        } else {
 | 
					                        } else {
 | 
				
			||||||
@@ -1969,7 +1954,7 @@ int main() {
 | 
				
			|||||||
                CalcState cs;
 | 
					                CalcState cs;
 | 
				
			||||||
                for (int i = 13, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
 | 
					                for (int i = 13, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
 | 
				
			||||||
                    QDateTime end = start.addSecs(timeSteps.at(i)*60);
 | 
					                    QDateTime end = start.addSecs(timeSteps.at(i)*60);
 | 
				
			||||||
                    cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs);
 | 
					                    cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
				
			||||||
                    qCritical() << endl;
 | 
					                    qCritical() << endl;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1994,7 +1979,7 @@ int main() {
 | 
				
			|||||||
                    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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs);
 | 
					                        cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
				
			||||||
                        if (cs.getStatus() != CalcState::State::SUCCESS) {
 | 
					                        if (cs.getStatus() != CalcState::State::SUCCESS) {
 | 
				
			||||||
                            if (start.time().hour() >= 8 && start.time().hour() < 18) {
 | 
					                            if (start.time().hour() >= 8 && start.time().hour() < 18) {
 | 
				
			||||||
                                qCritical() << "ERROR CALC-STATE-1=" << QString(cs);
 | 
					                                qCritical() << "ERROR CALC-STATE-1=" << QString(cs);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user