Compare commits
	
		
			81 Commits
		
	
	
		
			2.3.99-2
			...
			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 | |||
| 
						
						
							
						
						3a98a14eb0
	
				 | 
					
					
						|||
| 7bf7108668 | |||
| e5629ba4fd | |||
| 
						
						
							
						
						0d0d34cb87
	
				 | 
					
					
						|||
| e4cb992aae | |||
| cdeb625a15 | |||
| 589d89b73a | |||
| 7536f89d75 | |||
| 9a6b2b195d | |||
| 7233bc55c2 | |||
| 
						
						
							
						
						8fff7a76f6
	
				 | 
					
					
						|||
| 52b7c2390a | |||
| 894e23332f | |||
| fbc255a6f2 | |||
| 24ab01695d | |||
| 37652d3b6a | |||
| 14fd7ddd39 | |||
| ca3c3921d4 | |||
| 37620a06c1 | |||
| 9f4affca5a | |||
| 4f2c33cdc2 | |||
| 3cd02296b0 | |||
| f1493f417f | |||
| 356e3be178 | |||
| 31b1dd1690 | |||
| 
						
						
							
						
						84d807930e
	
				 | 
					
					
						|||
| dbf5b1f11d | |||
| 
						
						
							
						
						18f4e74eea
	
				 | 
					
					
						|||
| 29368ea850 | |||
| b84f80887e | |||
| 
						
						
							
						
						bfd9f3b80c
	
				 | 
					
					
						|||
| 
						
						
							
						
						cb69d3ca2f
	
				 | 
					
					
						|||
| 4a2b15d086 | |||
| 
						
						
							
						
						63043931c2
	
				 | 
					
					
						|||
| 8dad8f00e8 | |||
| 
						
						
							
						
						1ea03f522c
	
				 | 
					
					
						|||
| 805a732c52 | 
@@ -40,12 +40,12 @@ public:
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void ResetTimeSteps(int paymentOptionIndex) {
 | 
					    void ResetTimeSteps(int paymentOptionIndex) {
 | 
				
			||||||
        if (m_timeSteps.size() > 0) {
 | 
					        if (m_timeSteps.size() > 0 && paymentOptionIndex < m_timeSteps.size()) {
 | 
				
			||||||
            m_timeSteps[paymentOptionIndex].clear();
 | 
					            m_timeSteps[paymentOptionIndex].clear();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    QList<int> timeSteps(int paymentOptionIndex=0) const {
 | 
					    QList<int> timeSteps(int paymentOptionIndex=0) const {
 | 
				
			||||||
        if (m_timeSteps.size() > 0) {
 | 
					        if (m_timeSteps.size() > 0 && paymentOptionIndex < m_timeSteps.size()) {
 | 
				
			||||||
            return m_timeSteps[paymentOptionIndex];
 | 
					            return m_timeSteps[paymentOptionIndex];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return QList<int>();
 | 
					        return QList<int>();
 | 
				
			||||||
@@ -133,10 +133,10 @@ private:
 | 
				
			|||||||
                              int durationMinutes);
 | 
					                              int durationMinutes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex=0) const;
 | 
					    uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex) const;
 | 
				
			||||||
    uint32_t GetPriceForStep(Configuration *cfg, int step) const {
 | 
					    //uint32_t GetPriceForStep(Configuration *cfg, int step) const {
 | 
				
			||||||
        return GetPriceForTimeStep(cfg, step);
 | 
					    //    return GetPriceForTimeStep(cfg, step, 0);
 | 
				
			||||||
    }
 | 
					    //}
 | 
				
			||||||
    uint32_t GetDurationForPrice(Configuration *cfg, int price) const;
 | 
					    uint32_t GetDurationForPrice(Configuration *cfg, int price) const;
 | 
				
			||||||
    uint32_t GetStepForPrice(Configuration *cfg, int price) const {
 | 
					    uint32_t GetStepForPrice(Configuration *cfg, int price) const {
 | 
				
			||||||
        return GetDurationForPrice(cfg, price);
 | 
					        return GetDurationForPrice(cfg, price);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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,13 +48,15 @@ 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>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ATBProject project;
 | 
					    ATBProject project;
 | 
				
			||||||
    ATBCurrency Currency;
 | 
					    ATBCurrency Currency;
 | 
				
			||||||
    ATBDuration duration;
 | 
					    ATBDuration duration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	multimap<int, ATBDuration> Duration;
 | 
						TariffDurationType Duration;
 | 
				
			||||||
	multimap<int, ATBPaymentMethod> PaymentMethod;
 | 
						multimap<int, ATBPaymentMethod> PaymentMethod;
 | 
				
			||||||
	multimap<int, ATBPaymentRate> PaymentRate;
 | 
						multimap<int, ATBPaymentRate> PaymentRate;
 | 
				
			||||||
	SpecialDaysWorktimeType SpecialDaysWorktime;
 | 
						SpecialDaysWorktimeType SpecialDaysWorktime;
 | 
				
			||||||
@@ -70,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,7 +13,15 @@ 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) {
 | 
				
			||||||
@@ -25,7 +34,14 @@ public:
 | 
				
			|||||||
            << "            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;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -37,4 +53,12 @@ public:
 | 
				
			|||||||
	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;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,8 +21,9 @@ enum MemberType
 | 
				
			|||||||
	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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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>
 | 
				
			||||||
@@ -94,6 +96,40 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
 | 
				
			|||||||
    int minPrice = -1;
 | 
					    int minPrice = -1;
 | 
				
			||||||
    paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
					    paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int payment_method_id = cfg->getPaymentOptions(paymentOptionIndex).pop_payment_method_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (payment_method_id == PaymentMethod::Degressive) {
 | 
				
			||||||
 | 
					        // Degressive: new for Fuchs Technik (500), ValserAlm (Fane):
 | 
				
			||||||
 | 
					        // the minimal price has to be calculated, in cannot be hard coded into
 | 
				
			||||||
 | 
					        // the tariff file.
 | 
				
			||||||
 | 
					        // The working times have a reference into the payment rates. Two special
 | 
				
			||||||
 | 
					        // entries (with the numbers 1000/1001) point to the respective prices.
 | 
				
			||||||
 | 
					        switch(permitType) {
 | 
				
			||||||
 | 
					            default: {
 | 
				
			||||||
 | 
					                // find the correct work time range
 | 
				
			||||||
 | 
					                int weekDay = start.date().dayOfWeek();
 | 
				
			||||||
 | 
					                std::optional<QVector<ATBWeekDaysWorktime>> const &wd = cfg->getAllWeekDayWorkTimes();
 | 
				
			||||||
 | 
					                if (wd.has_value()) {
 | 
				
			||||||
 | 
					                    QVector<ATBWeekDaysWorktime> const &vec = wd.value();
 | 
				
			||||||
 | 
					                    for (int i = 0; i < vec.size(); ++i) {
 | 
				
			||||||
 | 
					                        ATBWeekDaysWorktime const &wt = vec[i];
 | 
				
			||||||
 | 
					                        if (wt.pwd_period_day_in_week_id == weekDay) {
 | 
				
			||||||
 | 
					                            if (start.time() >= QTime::fromString(QString::fromStdString(wt.pwd_time_from), Qt::ISODate)
 | 
				
			||||||
 | 
					                             && start.time() <= QTime::fromString(QString::fromStdString(wt.pwd_time_to), Qt::ISODate)) {
 | 
				
			||||||
 | 
					                                // found worktime range
 | 
				
			||||||
 | 
					                                int pop_id = wt.pwd_pop_id; // 1000 or 1001
 | 
				
			||||||
 | 
					                                for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
 | 
				
			||||||
 | 
					                                    i = vec.size(); // to leave outer loop
 | 
				
			||||||
 | 
					                                    minPrice = itr->second.pra_price; // this is now the minimal price
 | 
				
			||||||
 | 
					                                    break;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
        switch(permitType) {
 | 
					        switch(permitType) {
 | 
				
			||||||
        case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
 | 
					        case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
 | 
				
			||||||
            minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
					            minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
				
			||||||
@@ -110,6 +146,7 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
 | 
				
			|||||||
        default:
 | 
					        default:
 | 
				
			||||||
            minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
					            minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return minPrice;
 | 
					    return minPrice;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -211,8 +248,8 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (product.size() > 0) {
 | 
					            if (product.size() > 0) {
 | 
				
			||||||
                if (productStart && productEnd) {
 | 
					                if (productStart && productEnd) {
 | 
				
			||||||
                    int pop_min_time = get_minimal_parkingtime(cfg); // in minutes
 | 
					                    int pop_min_time = get_minimal_parkingtime(cfg, PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET); // in minutes
 | 
				
			||||||
                    int pop_max_time = get_maximal_parkingtime(cfg); // in minutes
 | 
					                    int pop_max_time = get_maximal_parkingtime(cfg, PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET); // in minutes
 | 
				
			||||||
                    if (pop_max_time >= pop_min_time) {
 | 
					                    if (pop_max_time >= pop_min_time) {
 | 
				
			||||||
                        *productStart = start;
 | 
					                        *productStart = start;
 | 
				
			||||||
                        *productEnd = start.addSecs(pop_max_time*60);
 | 
					                        *productEnd = start.addSecs(pop_max_time*60);
 | 
				
			||||||
@@ -290,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
 | 
				
			||||||
@@ -315,10 +354,20 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
 | 
				
			|||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case PERMIT_TYPE::DAY_TICKET_PKW:
 | 
					    case PERMIT_TYPE::DAY_TICKET_PKW:
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case PERMIT_TYPE::SHORT_TERM_PARKING_BUS:
 | 
					    case PERMIT_TYPE::SHORT_TERM_PARKING_BUS: {
 | 
				
			||||||
        break;
 | 
					        std::optional<ATBPaymentOption> po = cfg->getPaymentOptionForKey(permitType);
 | 
				
			||||||
    case PERMIT_TYPE::SHORT_TERM_PARKING_PKW:
 | 
					        if (po.has_value()) {
 | 
				
			||||||
        break;
 | 
					            ATBPaymentOption option = po.value();
 | 
				
			||||||
 | 
					            return option.pop_max_price;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } break;
 | 
				
			||||||
 | 
					    case PERMIT_TYPE::SHORT_TERM_PARKING_PKW: {
 | 
				
			||||||
 | 
					        std::optional<ATBPaymentOption> po = cfg->getPaymentOptionForKey(permitType);
 | 
				
			||||||
 | 
					        if (po.has_value()) {
 | 
				
			||||||
 | 
					            ATBPaymentOption option = po.value();
 | 
				
			||||||
 | 
					            return option.pop_max_price;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } break;
 | 
				
			||||||
    case PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER:
 | 
					    case PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER:
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    default: ;
 | 
					    default: ;
 | 
				
			||||||
@@ -417,17 +466,23 @@ 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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::optional<ATBPaymentOption> paymentOption = tariff->getPaymentOptionForKey(permitType.get());
 | 
					    // FIXME
 | 
				
			||||||
    if (!paymentOption.has_value()) {
 | 
					    //std::optional<ATBPaymentOption> paymentOption = tariff->getPaymentOptionForKey(permitType.get());
 | 
				
			||||||
        return currentTimeMinutes;
 | 
					    //if (!paymentOption.has_value()) {
 | 
				
			||||||
    }
 | 
					    //    qCritical() << "   compute_next_timestep() ERROR";
 | 
				
			||||||
 | 
					    //    return currentTimeMinutes;
 | 
				
			||||||
 | 
					    //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -455,61 +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 {
 | 
				
			||||||
                return stepList[currentStepIndex + 1];
 | 
					                int const rest = currentStepIndex % pop_plus_steps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                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 {
 | 
				
			||||||
                return stepList[currentStepIndex - 1];
 | 
					                int const nextStepIndex = currentStepIndex - pop_minus_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];
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else
 | 
					    } else
 | 
				
			||||||
@@ -553,6 +653,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
        time_t end_parking_time,    // netto time in minutes
 | 
					        time_t end_parking_time,    // netto time in minutes
 | 
				
			||||||
        struct price_t *price,
 | 
					        struct price_t *price,
 | 
				
			||||||
        PermitType permitType) {    // permitType maps to product
 | 
					        PermitType permitType) {    // permitType maps to product
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    CalcState calcState;
 | 
					    CalcState calcState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
 | 
					    int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
 | 
				
			||||||
@@ -611,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,
 | 
				
			||||||
@@ -620,7 +721,9 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    CalcState calcState;
 | 
					    CalcState calcState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int paymentOptionIndex = tariff->getPaymentOptionIndex(start_parking_time);
 | 
					    QDateTime start_parking_time(start_parking_time_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
					    double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
				
			||||||
    double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
					    double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
				
			||||||
@@ -632,8 +735,9 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
                << "          netto_parking_time: " << netto_parking_time << endl
 | 
					                << "          netto_parking_time: " << netto_parking_time << endl
 | 
				
			||||||
                << "               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();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (netto_parking_time < 0) {
 | 
					    if (netto_parking_time < 0) {
 | 
				
			||||||
        calcState.setDesc(QString("end=%1, start=%2")
 | 
					        calcState.setDesc(QString("end=%1, start=%2")
 | 
				
			||||||
@@ -655,38 +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);
 | 
				
			||||||
            end_parking_time = start_parking_time.addSecs(netto_parking_time*60);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
					            int weekDay = start_parking_time.date().dayOfWeek();
 | 
				
			||||||
            //             << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
 | 
					            int pop_carry_over_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
 | 
				
			||||||
 | 
					            qCritical() << __func__ << __LINE__ << "configured carry-over-id" << pop_carry_over_option_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            std::optional<ATBPeriodYear> yperiod = Utilities::GetYearPeriodActive(tariff, start_parking_time);
 | 
				
			||||||
 | 
					            if (yperiod.has_value()) {
 | 
				
			||||||
 | 
					                ATBPeriodYear const &period = yperiod.value();
 | 
				
			||||||
 | 
					                pop_carry_over_option_id = period.pye_id;
 | 
				
			||||||
 | 
					                qCritical() << __func__ << __LINE__ << "re-computed carry-over-id" << pop_carry_over_option_id;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QTime 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() << __func__ << __LINE__ << "carryOverStart" << carryOverStart.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					            qCritical() << __func__ << __LINE__ << "carryOverDuration" << carryOverDuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 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,
 | 
				
			||||||
@@ -703,8 +840,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // DEBUG
 | 
					        // DEBUG
 | 
				
			||||||
        qCritical() << "            end_parking_time: " << end_parking_time;
 | 
					        //qCritical() << __LINE__ << "            end_parking_time: " << end_parking_time;
 | 
				
			||||||
        qCritical() << "  -> 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;
 | 
				
			||||||
@@ -714,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);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -731,15 +874,25 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
    if (start.isValid()) {
 | 
					    if (start.isValid()) {
 | 
				
			||||||
        QString cs = start.toString(Qt::ISODate);
 | 
					        QString cs = start.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bool prepaid = true;
 | 
				
			||||||
 | 
					        int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
				
			||||||
 | 
					        int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
				
			||||||
 | 
					        if (prepaid_option_id == 2) { // see tariff03.json for 502: 2 means no prepaid-option
 | 
				
			||||||
 | 
					            prepaid = false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        bool const nextDay = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // DEBUG
 | 
					        // DEBUG
 | 
				
			||||||
        qCritical() << "compute_duration_for_parking_ticket(): ";
 | 
					        qCritical() << "compute_duration_for_parking_ticket(1): ";
 | 
				
			||||||
 | 
					        qCritical() << " payment option index: " << paymentOptionIndex;
 | 
				
			||||||
 | 
					        qCritical() << "              prepaid: " << prepaid;
 | 
				
			||||||
        qCritical() << "           start (cs): " << cs;
 | 
					        qCritical() << "           start (cs): " << cs;
 | 
				
			||||||
        qCritical() << "                price: " << price;
 | 
					        qCritical() << "                price: " << price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        duration = Calculator::GetInstance().GetDurationFromCost(tariff,
 | 
					        duration = Calculator::GetInstance().GetDurationFromCost(tariff,
 | 
				
			||||||
                                                  tariff->getPaymentOptions().pop_payment_method_id,
 | 
					                                                  tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id,
 | 
				
			||||||
                                                  cs.toLocal8Bit().constData(),
 | 
					                                                  cs.toLocal8Bit().constData(),
 | 
				
			||||||
                                                  price, false, true).c_str();
 | 
					                                                  price, permitType, nextDay, prepaid).c_str();
 | 
				
			||||||
        QDateTime d = QDateTime::fromString(duration, Qt::ISODate);
 | 
					        QDateTime d = QDateTime::fromString(duration, Qt::ISODate);
 | 
				
			||||||
        if (!d.isValid()) {
 | 
					        if (!d.isValid()) {
 | 
				
			||||||
            calcState.setDesc(QString("ticketEndTime=%1").arg(duration));
 | 
					            calcState.setDesc(QString("ticketEndTime=%1").arg(duration));
 | 
				
			||||||
@@ -760,13 +913,33 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
        PermitType permitType)
 | 
					        PermitType permitType)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    CalcState calcState;
 | 
					    CalcState calcState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool prepaid = true;
 | 
				
			||||||
 | 
					    int paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
 | 
				
			||||||
 | 
					    int prepaid_option_id = tariff->getPaymentOptions(paymentOptionIndex).pop_prepaid_option_id;
 | 
				
			||||||
 | 
					    if (prepaid_option_id == 2) {
 | 
				
			||||||
 | 
					        prepaid = false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    bool const nextDay = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // DEBUG
 | 
				
			||||||
 | 
					    // if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					        qCritical() << "\ncompute_duration_for_parking_ticket(2):";
 | 
				
			||||||
 | 
					        qCritical() << "                              start time:" << start_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					        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);
 | 
				
			||||||
        QString endTime = Calculator::GetInstance().GetDurationFromCost(
 | 
					        QString endTime = Calculator::GetInstance().GetDurationFromCost(
 | 
				
			||||||
                    tariff,
 | 
					                    tariff,
 | 
				
			||||||
                    tariff->getPaymentOptions().pop_payment_method_id,
 | 
					                    tariff->getPaymentOptions().pop_payment_method_id,
 | 
				
			||||||
                    cs.toLocal8Bit().constData(),
 | 
					                    cs.toLocal8Bit().constData(),
 | 
				
			||||||
                    price, false, true).c_str();
 | 
					                    price, permitType, nextDay, prepaid).c_str();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (endTime == CalcState::SUCCESS) {
 | 
					        if (endTime == CalcState::SUCCESS) {
 | 
				
			||||||
            calcState.setDesc(QString("SUCCESS"));
 | 
					            calcState.setDesc(QString("SUCCESS"));
 | 
				
			||||||
@@ -828,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);
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -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();
 | 
				
			||||||
@@ -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;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -882,7 +991,7 @@ std::optional<QDateTime> Configuration::getInterpolationEnd(QDateTime const &sta
 | 
				
			|||||||
                ATBInterpolation interpolation = ipolCheck.value();
 | 
					                ATBInterpolation interpolation = ipolCheck.value();
 | 
				
			||||||
                switch (duration.pun_interpolation_id) {
 | 
					                switch (duration.pun_interpolation_id) {
 | 
				
			||||||
                    case static_cast<int>(ATBInterpolation::NO_INTERPOLATION):
 | 
					                    case static_cast<int>(ATBInterpolation::NO_INTERPOLATION):
 | 
				
			||||||
                        qCritical() << "(" << __func__ << ":" << __LINE__ << ") NO_INTERPOLATION";
 | 
					                        //qCritical() << "(" << __func__ << ":" << __LINE__ << ") NO_INTERPOLATION";
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                    case static_cast<int>(ATBInterpolation::STATIC_WALLCLOCK_TIME_VALUES):
 | 
					                    case static_cast<int>(ATBInterpolation::STATIC_WALLCLOCK_TIME_VALUES):
 | 
				
			||||||
                        //qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
 | 
					                        //qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
 | 
				
			||||||
@@ -987,6 +1096,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_id = getPaymentOptions(opt).pop_id;
 | 
					                uint64_t const pop_id = getPaymentOptions(opt).pop_id;
 | 
				
			||||||
                if (pop_id == (uint64_t)sd.ped_payment_option_id) {
 | 
					                if (pop_id == (uint64_t)sd.ped_payment_option_id) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    qCritical() << __func__ << __LINE__ << opt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    return opt;
 | 
					                    return opt;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -996,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();
 | 
				
			||||||
@@ -1026,6 +1141,9 @@ int Configuration::getPaymentOptionIndex(QDateTime const &dt) const {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ((pop_business_hours & p) == p) {
 | 
					        if ((pop_business_hours & p) == p) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            qCritical() << __func__ << __LINE__ << opt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return opt;
 | 
					            return opt;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -1148,6 +1266,7 @@ int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) {
 | 
				
			|||||||
    if (paymentOptions) {
 | 
					    if (paymentOptions) {
 | 
				
			||||||
        QVector<ATBPaymentOption> const vec = paymentOptions.value();
 | 
					        QVector<ATBPaymentOption> const vec = paymentOptions.value();
 | 
				
			||||||
        PermitType const p(permitType);
 | 
					        PermitType const p(permitType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < vec.size(); ++i) {
 | 
					        for (int i = 0; i < vec.size(); ++i) {
 | 
				
			||||||
            if (vec[i].pop_product_name == p.toString()) {
 | 
					            if (vec[i].pop_product_name == p.toString()) {
 | 
				
			||||||
               return i;
 | 
					               return i;
 | 
				
			||||||
@@ -1161,8 +1280,11 @@ int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) {
 | 
				
			|||||||
int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) const {
 | 
					int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) const {
 | 
				
			||||||
    std::optional<QVector<ATBPaymentOption>> paymentOptions = getPaymentOptionsForAllKeys();
 | 
					    std::optional<QVector<ATBPaymentOption>> paymentOptions = getPaymentOptionsForAllKeys();
 | 
				
			||||||
    if (paymentOptions) {
 | 
					    if (paymentOptions) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QVector<ATBPaymentOption> const vec = paymentOptions.value();
 | 
					        QVector<ATBPaymentOption> const vec = paymentOptions.value();
 | 
				
			||||||
        PermitType const p(permitType);
 | 
					        PermitType const p(permitType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < vec.size(); ++i) {
 | 
					        for (int i = 0; i < vec.size(); ++i) {
 | 
				
			||||||
            if (vec[i].pop_product_name == p.toString()) {
 | 
					            if (vec[i].pop_product_name == p.toString()) {
 | 
				
			||||||
               return i;
 | 
					               return i;
 | 
				
			||||||
@@ -1310,11 +1432,14 @@ Configuration::getPaymentOptionsForAllKeys() const {
 | 
				
			|||||||
    return value;
 | 
					    return value;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TODO: umbenennen: getPaymentOptionForPermitType
 | 
				
			||||||
std::optional<ATBPaymentOption>
 | 
					std::optional<ATBPaymentOption>
 | 
				
			||||||
Configuration::getPaymentOptionForKey(PERMIT_TYPE permitType) const {
 | 
					Configuration::getPaymentOptionForKey(PERMIT_TYPE permitType) const {
 | 
				
			||||||
    return getPaymentOptionForKey(static_cast<int>(permitType));
 | 
					    return getPaymentOptionForKey(static_cast<int>(permitType));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TODO: umbenennen: getPaymentOptionForPermitType
 | 
				
			||||||
std::optional<ATBPaymentOption>
 | 
					std::optional<ATBPaymentOption>
 | 
				
			||||||
Configuration::getPaymentOptionForKey(int permitType) const {
 | 
					Configuration::getPaymentOptionForKey(int permitType) const {
 | 
				
			||||||
    std::optional<ATBPaymentOption> value;
 | 
					    std::optional<ATBPaymentOption> value;
 | 
				
			||||||
@@ -1331,6 +1456,7 @@ Configuration::getPaymentOptionForKey(int permitType) const {
 | 
				
			|||||||
    return value;
 | 
					    return value;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TODO: umbenennen: getPaymentOptionForPermitType
 | 
				
			||||||
std::optional<ATBPaymentOption>
 | 
					std::optional<ATBPaymentOption>
 | 
				
			||||||
Configuration::getPaymentOptionForKey(QString const &permitTypeStr) const {
 | 
					Configuration::getPaymentOptionForKey(QString const &permitTypeStr) const {
 | 
				
			||||||
    PERMIT_TYPE permitType = PermitType::toPermitType(permitTypeStr);
 | 
					    PERMIT_TYPE permitType = PermitType::toPermitType(permitTypeStr);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										390
									
								
								main/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										390
									
								
								main/main.cpp
									
									
									
									
									
								
							@@ -49,9 +49,9 @@ extern "C" char* strptime(const char* s,
 | 
				
			|||||||
#define NEUHAUSER_STOCKERAU                     (0)
 | 
					#define NEUHAUSER_STOCKERAU                     (0)
 | 
				
			||||||
#define KLEIPEDA_LITAUEN                        (0)
 | 
					#define KLEIPEDA_LITAUEN                        (0)
 | 
				
			||||||
#define SEXTEN                                  (0)
 | 
					#define SEXTEN                                  (0)
 | 
				
			||||||
#define SCHNALS_LEITER_KIRCHL                   (1)
 | 
					#define SCHNALS_LEITER_KIRCHL                   (0)
 | 
				
			||||||
#define SCHNALS_STAUMAUER                       (SCHNALS_LEITER_KIRCHL)
 | 
					#define SCHNALS_STAUMAUER                       (SCHNALS_LEITER_KIRCHL)
 | 
				
			||||||
#define VALSER_ALM                              (0)
 | 
					#define VALSER_ALM                              (1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if NEUHAUSER_KIRCHDORF==1
 | 
					#if NEUHAUSER_KIRCHDORF==1
 | 
				
			||||||
static bool test_neuhauser_kirchdorf(int step, double cost) {
 | 
					static bool test_neuhauser_kirchdorf(int step, double cost) {
 | 
				
			||||||
@@ -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) {
 | 
				
			||||||
@@ -801,7 +732,7 @@ int main() {
 | 
				
			|||||||
    int pop_max_price;
 | 
					    int pop_max_price;
 | 
				
			||||||
    int pop_daily_card_price;
 | 
					    int pop_daily_card_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int zone = 2;
 | 
					    int zone = 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (zone == 1) {
 | 
					    if (zone == 1) {
 | 
				
			||||||
        input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json");
 | 
					        input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json");
 | 
				
			||||||
@@ -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;
 | 
				
			||||||
@@ -823,6 +761,33 @@ int main() {
 | 
				
			|||||||
    cout << endl;
 | 
					    cout << endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (isParsed) {
 | 
					    if (isParsed) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (zone == 1 || zone == 3) {
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					            pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
 | 
				
			||||||
 | 
					            pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
 | 
				
			||||||
 | 
					            pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
 | 
				
			||||||
 | 
					            pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
 | 
				
			||||||
 | 
					            pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            qCritical() << "        pop_min_time_pkw: " << pop_min_time;
 | 
				
			||||||
 | 
					            qCritical() << "        pop_max_time_pkw: " << pop_max_time;
 | 
				
			||||||
 | 
					            qCritical() << "       pop_min_price_pkw: " << pop_min_price;
 | 
				
			||||||
 | 
					            qCritical() << "       pop_max_price_pkw: " << pop_max_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
 | 
				
			||||||
 | 
					            pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
 | 
				
			||||||
 | 
					            pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
 | 
				
			||||||
 | 
					            pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
 | 
				
			||||||
 | 
					            pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            qCritical() << "        pop_min_time_bus: " << pop_min_time;
 | 
				
			||||||
 | 
					            qCritical() << "        pop_max_time_bus: " << pop_max_time;
 | 
				
			||||||
 | 
					            qCritical() << "       pop_min_price_bus: " << pop_min_price;
 | 
				
			||||||
 | 
					            qCritical() << "       pop_max_price_bus: " << pop_max_price;
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (zone == 2) {
 | 
				
			||||||
            pop_min_time = get_minimal_parkingtime(&cfg);
 | 
					            pop_min_time = get_minimal_parkingtime(&cfg);
 | 
				
			||||||
            pop_max_time = get_maximal_parkingtime(&cfg);
 | 
					            pop_max_time = get_maximal_parkingtime(&cfg);
 | 
				
			||||||
            pop_min_price = get_minimal_parkingprice(&cfg);
 | 
					            pop_min_price = get_minimal_parkingprice(&cfg);
 | 
				
			||||||
@@ -833,12 +798,48 @@ int main() {
 | 
				
			|||||||
            qCritical() << "        pop_max_time: " << pop_max_time;
 | 
					            qCritical() << "        pop_max_time: " << pop_max_time;
 | 
				
			||||||
            qCritical() << "       pop_min_price: " << pop_min_price;
 | 
					            qCritical() << "       pop_min_price: " << pop_min_price;
 | 
				
			||||||
            qCritical() << "       pop_max_price: " << pop_max_price;
 | 
					            qCritical() << "       pop_max_price: " << pop_max_price;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //QDateTime start = QDateTime::currentDateTime();
 | 
					        //QDateTime start = QDateTime::currentDateTime();
 | 
				
			||||||
        //start.setTime(QTime(12, 0, 0));
 | 
					        //start.setTime(QTime(12, 0, 0));
 | 
				
			||||||
        //QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, start);
 | 
					        //QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, start);
 | 
				
			||||||
        //qCritical() << "TimeSteps" << timeSteps;
 | 
					        //qCritical() << "TimeSteps" << timeSteps;
 | 
				
			||||||
        //return 0;
 | 
					        //return 0;
 | 
				
			||||||
 | 
					        if (zone == 1) {
 | 
				
			||||||
 | 
					            //int minParkingTime = get_minimal_parkingtime(&cfg);
 | 
				
			||||||
 | 
					            QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
 | 
				
			||||||
 | 
					            qCritical() << timeSteps;
 | 
				
			||||||
 | 
					            int Down = 0;
 | 
				
			||||||
 | 
					            int Up = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QDateTime const start = QDateTime::currentDateTime();
 | 
				
			||||||
 | 
					            int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (paymentOptionIndex < 0) {
 | 
				
			||||||
 | 
					                qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex
 | 
				
			||||||
 | 
					                            << "< 0 for start" << start.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                exit(-1);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QSet<uint32_t> const prices_pkw{600, 1200, 1800, 2400, 3000, 3600, 4200};
 | 
				
			||||||
 | 
					            QSet<uint32_t> const prices_bus{3000, 6000, 9000, 12000, 15000, 18000, 21000};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QDateTime end;
 | 
				
			||||||
 | 
					            CalcState calcState;
 | 
				
			||||||
 | 
					            QDateTime s(QDateTime::currentDateTime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            s.setTime(QTime(12, 0, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
				
			||||||
 | 
					            //                                    (double)1200, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
 | 
				
			||||||
 | 
					            //qCritical() << end.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					            //qCritical() << calcState.toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
				
			||||||
 | 
					                                                (double)50, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
 | 
				
			||||||
 | 
					            qCritical() << end.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					            qCritical() << calcState.toString();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (zone == 2) {
 | 
					        if (zone == 2) {
 | 
				
			||||||
            //int minParkingTime = get_minimal_parkingtime(&cfg);
 | 
					            //int minParkingTime = get_minimal_parkingtime(&cfg);
 | 
				
			||||||
@@ -858,6 +859,16 @@ int main() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            QSet<uint32_t> const prices{600, 1200, 1800, 2400, 3000, 3600, 4200};
 | 
					            QSet<uint32_t> const prices{600, 1200, 1800, 2400, 3000, 3600, 4200};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QDateTime end;
 | 
				
			||||||
 | 
					            CalcState calcState;
 | 
				
			||||||
 | 
					            QDateTime s(QDateTime::currentDateTime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            s.setTime(QTime(18, 0, 0));
 | 
				
			||||||
 | 
					            calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
				
			||||||
 | 
					                                                (double)600, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
				
			||||||
 | 
					            qCritical() << end.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					            qCritical() << calcState.toString();
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (int i=0; i<timeSteps.size(); ++i) {
 | 
					            for (int i=0; i<timeSteps.size(); ++i) {
 | 
				
			||||||
                int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
 | 
					                int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
 | 
				
			||||||
@@ -882,89 +893,110 @@ int main() {
 | 
				
			|||||||
                            << "(price so far:" << price << ")";
 | 
					                            << "(price so far:" << price << ")";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (zone == 3) {
 | 
					        if (zone == 3) {
 | 
				
			||||||
            int price;
 | 
					            //QDateTime xx(QDateTime::fromString("2024-07-31T00:00:00", Qt::ISODate));
 | 
				
			||||||
            QDateTime productStart;
 | 
					            //xx = xx.addSecs(-60); // -->  "2024-07-30T23:59:00"
 | 
				
			||||||
            QDateTime productEnd;
 | 
					            //qCritical() << xx.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //QDateTime s(QDateTime::currentDateTime());
 | 
				
			||||||
 | 
					            //s.setTime(QTime(12, 0, 0));
 | 
				
			||||||
 | 
					            //QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, s);
 | 
				
			||||||
 | 
					            //qCritical() << timeSteps;
 | 
				
			||||||
 | 
					            int Down = 0;
 | 
				
			||||||
 | 
					            int Up = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QDateTime start = QDateTime::currentDateTime();
 | 
					            QDateTime start = QDateTime::currentDateTime();
 | 
				
			||||||
 | 
					            int paymentOptionIndex = cfg.getPaymentOptionIndex(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (paymentOptionIndex != 0) {
 | 
				
			||||||
 | 
					                qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex
 | 
				
			||||||
 | 
					                            << "< 0 for start" << start.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                exit(-1);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //QSet<uint32_t> const prices1{800, 1600, 2400, 3200, 4000, 4800, 5600};
 | 
				
			||||||
 | 
					            //QSet<uint32_t> const prices2{500, 1600, 2400, 3200, 4000, 4800, 5600};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QDateTime end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            QDateTime s(QDateTime::currentDateTime());
 | 
				
			||||||
 | 
					            s.setTime(QTime(10, 0, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
            start.setTime(QTime(0, 0, 0));
 | 
					 | 
				
			||||||
            price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start);
 | 
					 | 
				
			||||||
            qCritical() << QString("line=%1 price (%2) :")
 | 
					 | 
				
			||||||
                           .arg(__LINE__)
 | 
					 | 
				
			||||||
                           .arg(start.time().toString(Qt::ISODate)) << price;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
 | 
					            pop_min_time = get_minimal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
 | 
				
			||||||
            qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
 | 
					            pop_max_time = get_maximal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            start.setTime(QTime(14, 0, 0));
 | 
					            pop_min_price = get_minimal_parkingprice(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex, s);
 | 
				
			||||||
            productStart = productEnd = QDateTime();
 | 
					            pop_max_price = get_maximal_parkingprice(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
 | 
				
			||||||
            price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
 | 
					 | 
				
			||||||
            qCritical() << QString("line=%1 price (%2-%3) :")
 | 
					 | 
				
			||||||
                           .arg(__LINE__)
 | 
					 | 
				
			||||||
                           .arg(productStart.time().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                           .arg(productEnd.time().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                        << price;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
 | 
					            pop_daily_card_price = cfg.getPaymentOptions(paymentOptionIndex).pop_daily_card_price;
 | 
				
			||||||
            qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__)
 | 
					 | 
				
			||||||
                        << price;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start);
 | 
					            int h = pop_min_time / 60;
 | 
				
			||||||
            qCritical() << QString("line=%1 price:").arg(__LINE__) << price;
 | 
					            int m = pop_min_time % 60;
 | 
				
			||||||
 | 
					            qCritical().noquote() << QString("         pop_min_time %1 (%2h, %3m)").arg(pop_min_time).arg(h).arg(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            start.setTime(QTime(15, 0, 0));
 | 
					            h = pop_max_time / 60;
 | 
				
			||||||
            productStart = productEnd = QDateTime();
 | 
					            m = pop_max_time % 60;
 | 
				
			||||||
            price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
 | 
					            qCritical().noquote()
 | 
				
			||||||
            qCritical() << QString("line=%1 price (%2-%3) :")
 | 
					               << QString("         pop_max_time %1 (%2h, %3m)").arg(pop_max_time).arg(h).arg(m);
 | 
				
			||||||
                           .arg(__LINE__)
 | 
					 | 
				
			||||||
                           .arg(productStart.time().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                           .arg(productEnd.time().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                        << price;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
 | 
					            qCritical() << "       pop_min_price " << pop_min_price;
 | 
				
			||||||
            qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
 | 
					            qCritical() << "       pop_max_price " << pop_max_price;
 | 
				
			||||||
 | 
					            qCritical() << "pop_daily_card_price " << pop_daily_card_price;
 | 
				
			||||||
            start.setTime(QTime(16, 0, 0));
 | 
					#endif
 | 
				
			||||||
            productStart = productEnd = QDateTime();
 | 
					            CalcState calcState;
 | 
				
			||||||
            price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
 | 
					 | 
				
			||||||
            qCritical() << QString("line=%1 price (%2-%3) :")
 | 
					 | 
				
			||||||
                           .arg(__LINE__)
 | 
					 | 
				
			||||||
                           .arg(productStart.time().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                           .arg(productEnd.time().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                        << price;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
 | 
					 | 
				
			||||||
            qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            start.setTime(QTime(17, 0, 0));
 | 
					 | 
				
			||||||
            productStart = productEnd = QDateTime();
 | 
					 | 
				
			||||||
            price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
 | 
					 | 
				
			||||||
            qCritical() << QString("line=%1 price (%2-%3) :")
 | 
					 | 
				
			||||||
                           .arg(__LINE__)
 | 
					 | 
				
			||||||
                           .arg(productStart.time().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                           .arg(productEnd.time().toString(Qt::ISODate))
 | 
					 | 
				
			||||||
                        << price;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET, 0, start);
 | 
					 | 
				
			||||||
            //qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET);
 | 
					 | 
				
			||||||
            //qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#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
 | 
					#else
 | 
				
			||||||
            for (int h = 0; h < 24; ++h) {
 | 
					            struct price_t price;
 | 
				
			||||||
                start.setTime(QTime(h, 0, 0));
 | 
					            int netto_parking_time = 1440;
 | 
				
			||||||
                productStart = productEnd = QDateTime();
 | 
					
 | 
				
			||||||
                price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
 | 
					            start = s;
 | 
				
			||||||
                qCritical() << QString("line=%1 %2 price (%3-%4) :")
 | 
					            qCritical() << "RUN" << 0 << ": start" << s.toString(Qt::ISODate);
 | 
				
			||||||
                               .arg(__LINE__)
 | 
					
 | 
				
			||||||
                               .arg(start.time().toString(Qt::ISODate))
 | 
					            calcState = compute_price_for_parking_ticket(&cfg, start, netto_parking_time,
 | 
				
			||||||
                               .arg(productStart.time().toString(Qt::ISODate))
 | 
					                                                         end, &price,
 | 
				
			||||||
                               .arg(productEnd.time().toString(Qt::ISODate))
 | 
					                                                         PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
				
			||||||
                            << price;
 | 
					            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) {
 | 
				
			||||||
 | 
					                calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
				
			||||||
 | 
					                                                    (double)minimal_parking_price + i*800,
 | 
				
			||||||
 | 
					                                                    end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
 | 
				
			||||||
 | 
					                qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// #else
 | 
				
			||||||
 | 
					            s.setTime(QTime(12, 0, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            minimal_parking_price = get_minimal_parkingprice(&cfg,
 | 
				
			||||||
 | 
					                                                             PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS),
 | 
				
			||||||
 | 
					                                                             paymentOptionIndex, s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            qCritical() << "minimal parking price" << minimal_parking_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for (int i = 0; i < 8; ++i) {
 | 
				
			||||||
 | 
					                calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
				
			||||||
 | 
					                                                    (double)minimal_parking_price + i*800,
 | 
				
			||||||
 | 
					                                                    end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
 | 
				
			||||||
 | 
					                qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -1485,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);
 | 
				
			||||||
@@ -1508,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,
 | 
				
			||||||
@@ -1592,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 {
 | 
				
			||||||
@@ -1676,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 {
 | 
				
			||||||
@@ -1761,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 {
 | 
				
			||||||
@@ -1819,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 {
 | 
				
			||||||
@@ -1922,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;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1947,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);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,9 @@ SOURCES += main.cpp
 | 
				
			|||||||
# HEADERS +=
 | 
					# HEADERS +=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
OTHER_FILES += \
 | 
					OTHER_FILES += \
 | 
				
			||||||
    /home/linux/customer_505/etc/psa_tariff/tariff01.json
 | 
					    /opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json \
 | 
				
			||||||
 | 
					    /opt/ptu5/opt/customer_502/etc/psa_tariff/tariff02.json \
 | 
				
			||||||
 | 
					    /opt/ptu5/opt/customer_502/etc/psa_tariff/tariff03.json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user