Compare commits
	
		
			23 Commits
		
	
	
		
			include-ta
			...
			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 | 
@@ -28,6 +28,7 @@
 | 
				
			|||||||
#include "tariff_interpolation.h"
 | 
					#include "tariff_interpolation.h"
 | 
				
			||||||
#include "tariff_prepaid.h"
 | 
					#include "tariff_prepaid.h"
 | 
				
			||||||
#include "tariff_carryover.h"
 | 
					#include "tariff_carryover.h"
 | 
				
			||||||
 | 
					#include "tariff_prepay.h"
 | 
				
			||||||
#include "tariff_permit_type.h"
 | 
					#include "tariff_permit_type.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QVector>
 | 
					#include <QVector>
 | 
				
			||||||
@@ -47,6 +48,7 @@ public:
 | 
				
			|||||||
    using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
 | 
					    using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
 | 
				
			||||||
    using TariffInterpolationType = std::multimap<int, ATBInterpolation>;
 | 
					    using TariffInterpolationType = std::multimap<int, ATBInterpolation>;
 | 
				
			||||||
    using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
 | 
					    using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
 | 
				
			||||||
 | 
					    using TariffPrepayOptionType = std::multimap<int, ATBPrepay>;
 | 
				
			||||||
    using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
 | 
					    using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
 | 
				
			||||||
    using TariffDurationType = std::multimap<int, ATBDuration>;
 | 
					    using TariffDurationType = std::multimap<int, ATBDuration>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -71,6 +73,7 @@ public:
 | 
				
			|||||||
	TariffProductType TariffProduct;
 | 
						TariffProductType TariffProduct;
 | 
				
			||||||
	TariffInterpolationType TariffInterpolations;
 | 
						TariffInterpolationType TariffInterpolations;
 | 
				
			||||||
	TariffPrepaidType TariffPrepaidOptions;
 | 
						TariffPrepaidType TariffPrepaidOptions;
 | 
				
			||||||
 | 
						TariffPrepayOptionType TariffPrepayOptions;
 | 
				
			||||||
	TariffCarryOverType TariffCarryOverOptions;
 | 
						TariffCarryOverType TariffCarryOverOptions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/// <summary>
 | 
						/// <summary>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					#include <QDateTime>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ATBDuration
 | 
					class ATBDuration
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -12,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;
 | 
				
			||||||
@@ -61,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;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										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;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -327,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
 | 
				
			||||||
@@ -768,7 +770,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
                return calcState;
 | 
					                return calcState;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff);
 | 
					            QList<int> tlist = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex, start_parking_time_);
 | 
				
			||||||
            Q_UNUSED(tlist);
 | 
					            Q_UNUSED(tlist);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // compute cost (price)
 | 
					            // compute cost (price)
 | 
				
			||||||
@@ -921,12 +923,15 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
    bool const nextDay = false;
 | 
					    bool const nextDay = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // DEBUG
 | 
					    // DEBUG
 | 
				
			||||||
    if (DBG_LEVEL >= DBG_DEBUG) {
 | 
					    // if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
        qCritical() << "compute_duration_for_parking_ticket(2): ";
 | 
					        qCritical() << "\ncompute_duration_for_parking_ticket(2):";
 | 
				
			||||||
 | 
					        qCritical() << "                              start time:" << start_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
        qCritical() << "                    payment option index:" << paymentOptionIndex;
 | 
					        qCritical() << "                    payment option index:" << paymentOptionIndex;
 | 
				
			||||||
        qCritical() << "                                 prepaid:" << prepaid;
 | 
					        qCritical() << "                                 prepaid:" << prepaid;
 | 
				
			||||||
        qCritical() << "                                   price:" << price;
 | 
					        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);
 | 
				
			||||||
@@ -1007,9 +1012,10 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // DEBUG
 | 
					            // DEBUG
 | 
				
			||||||
            qCritical() << "compute_duration_for_parking_ticket(): ";
 | 
					            qCritical() << "\ncompute_duration_for_parking_ticket():";
 | 
				
			||||||
 | 
					            qCritical() << "                           start time:" << start_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
            qCritical() << "                              endTime:" << endTime;
 | 
					            qCritical() << "                              endTime:" << endTime;
 | 
				
			||||||
            qCritical() << "           ticketEndTime: " << ticketEndTime;
 | 
					            qCritical() << "                        ticketEndTime:" << ticketEndTime.toString(Qt::ISODate) << endl;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        return calcState.set(CalcState::State::INVALID_START_DATE);
 | 
					        return calcState.set(CalcState::State::INVALID_START_DATE);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,9 +10,12 @@
 | 
				
			|||||||
#include <sstream>
 | 
					#include <sstream>
 | 
				
			||||||
#include <algorithm>
 | 
					#include <algorithm>
 | 
				
			||||||
#include <optional>
 | 
					#include <optional>
 | 
				
			||||||
 | 
					#include <iterator>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QDateTime>
 | 
					#include <QDateTime>
 | 
				
			||||||
#include <QScopedArrayPointer>
 | 
					#include <QScopedArrayPointer>
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					#include <QTimeZone>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double total_duration_min = 0.0f;
 | 
					double total_duration_min = 0.0f;
 | 
				
			||||||
double total_cost = 0.0f;
 | 
					double total_cost = 0.0f;
 | 
				
			||||||
@@ -159,7 +162,8 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
            return CalcState::BELOW_MIN_PARKING_PRICE.toStdString();
 | 
					            return CalcState::BELOW_MIN_PARKING_PRICE.toStdString();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (prepaid == false) {
 | 
					        int const pop_time_step_config = cfg->getPaymentOptions(paymentOptionIndex).pop_time_step_config;
 | 
				
			||||||
 | 
					        if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::RECOMPUTE_SOME || prepaid == false) {
 | 
				
			||||||
            int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
					            int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
				
			||||||
            int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
 | 
					            int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
 | 
				
			||||||
            int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
 | 
					            int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
 | 
				
			||||||
@@ -174,6 +178,9 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
 | 
					            for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
 | 
				
			||||||
                int const pra_price = itr->second.pra_price;
 | 
					                int const pra_price = itr->second.pra_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // qCritical() << DBG_HEADER << "pra_price" << pra_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                int const durationId = itr->second.pra_payment_unit_id;
 | 
					                int const durationId = itr->second.pra_payment_unit_id;
 | 
				
			||||||
                if (pop_accumulate_prices) {
 | 
					                if (pop_accumulate_prices) {
 | 
				
			||||||
                    price += pra_price;
 | 
					                    price += pra_price;
 | 
				
			||||||
@@ -191,7 +198,9 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
				
			|||||||
                    ATBDuration duration = search->second;
 | 
					                    ATBDuration duration = search->second;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (pop_accumulate_prices) {
 | 
					                    if (pop_accumulate_prices) {
 | 
				
			||||||
                        uint32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
 | 
					                        int32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        // qCritical() << DBG_HEADER << "  duration unit" << durationUnit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        new_price += pra_price;
 | 
					                        new_price += pra_price;
 | 
				
			||||||
                        // qCritical() << "(" << __func__ << ":" << __LINE__ << ")  old price" << price << ", new_price:" << new_price;
 | 
					                        // qCritical() << "(" << __func__ << ":" << __LINE__ << ")  old price" << price << ", new_price:" << new_price;
 | 
				
			||||||
@@ -2770,6 +2779,243 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
 | 
				
			|||||||
                 qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
 | 
					                 qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    } else
 | 
				
			||||||
 | 
					    if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::RECOMPUTE_SOME) {
 | 
				
			||||||
 | 
					        // some durations / timesteps have to be recomputed
 | 
				
			||||||
 | 
					        qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::RECOMPUTE_SOME";
 | 
				
			||||||
 | 
					        int size = m_timeSteps.size();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        while (size <= paymentOptionIndex) {
 | 
				
			||||||
 | 
					            m_timeSteps.push_back(QList<int>());
 | 
				
			||||||
 | 
					            size = m_timeSteps.size();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int const pop_accumulate_durations = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_durations;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        m_timeSteps[paymentOptionIndex].clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        QDateTime const start(s.date(),
 | 
				
			||||||
 | 
					                              QTime(s.time().hour(), s.time().minute(), 0),
 | 
				
			||||||
 | 
					                              s.timeZone());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") start:" << start.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        QDateTime current(start);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bool casePrepay = false;
 | 
				
			||||||
 | 
					        int const weekDay = start.date().dayOfWeek();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int const pop_prepay_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_prepay_option_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // compute prepay settings
 | 
				
			||||||
 | 
					        // assumption: prepay settings the same for all days
 | 
				
			||||||
 | 
					        QDateTime prepayStart(start);
 | 
				
			||||||
 | 
					        QDateTime prepayEnd(start);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        prepayStart.setTime(cfg->TariffPrepayOptions.find(pop_prepay_option_id)->second.prepay[weekDay].start);
 | 
				
			||||||
 | 
					        prepayEnd.setTime(cfg->TariffPrepayOptions.find(pop_prepay_option_id)->second.prepay[weekDay].end);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (start <= prepayEnd) {
 | 
				
			||||||
 | 
					            prepayStart = prepayStart.addDays(-1);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            prepayEnd = prepayEnd.addDays(1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay start" << prepayStart.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ")   prepay end" << prepayEnd.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int const prepayDurationInMinutes = start.secsTo(prepayEnd) / 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // compute carryover settings
 | 
				
			||||||
 | 
					        // assumption: carryover settings the same for all days
 | 
				
			||||||
 | 
					        int const pop_carry_over_option_id = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_option_id;
 | 
				
			||||||
 | 
					        QDateTime carryOverStart(start);
 | 
				
			||||||
 | 
					        QDateTime carryOverEnd(start);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        carryOverStart.setTime(cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start);
 | 
				
			||||||
 | 
					        carryOverEnd.setTime(cfg->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (start <= carryOverEnd) {
 | 
				
			||||||
 | 
					            carryOverStart = carryOverStart.addDays(-1);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            carryOverEnd = carryOverEnd.addDays(1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ") carry over start" << carryOverStart.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					            qCritical() << "(" << __func__ << ":" << __LINE__ << ")   carry over end" << carryOverEnd.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // int cnt = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (Configuration::TariffDurationType::iterator it = cfg->Duration.begin();
 | 
				
			||||||
 | 
					             it != cfg->Duration.end();
 | 
				
			||||||
 | 
					             ++it) {
 | 
				
			||||||
 | 
					            it->second.pun_duration = it->second.pun_duration_saved;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // if (++cnt > 2) continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << it->second.pun_id;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (it->second.pun_mutable) {
 | 
				
			||||||
 | 
					                if (it->second.pun_netto) {
 | 
				
			||||||
 | 
					                    if (it->second.pun_round_to_next_24h_boundary == false) {
 | 
				
			||||||
 | 
					                        //int weekDay = start.date().dayOfWeek();
 | 
				
			||||||
 | 
					                        if (m_timeSteps[paymentOptionIndex].isEmpty()) {
 | 
				
			||||||
 | 
					                            // handle possible prepay-condition, which applies only
 | 
				
			||||||
 | 
					                            // for the very first step
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay start" << prepayStart.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ")   prepay end" << prepayEnd.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (prepayStart <= start && start <= prepayEnd) {
 | 
				
			||||||
 | 
					                                it->second.pun_duration = prepayDurationInMinutes;
 | 
				
			||||||
 | 
					                                it->second.pun_duration += it->second.pun_duration_saved ;
 | 
				
			||||||
 | 
					                                casePrepay = true;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << it->second.pun_duration;
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay" << casePrepay;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (!casePrepay) {
 | 
				
			||||||
 | 
					                            // handle possible carryover-condition
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            int const durationInSecs = it->second.pun_duration_saved * 60;
 | 
				
			||||||
 | 
					                            it->second.pun_duration = it->second.pun_duration_saved;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (current >= carryOverStart && current < carryOverEnd) {
 | 
				
			||||||
 | 
					                                it->second.pun_duration += current.secsTo(carryOverEnd) / 60;
 | 
				
			||||||
 | 
					                            } else {
 | 
				
			||||||
 | 
					                                // start < carryOverStart
 | 
				
			||||||
 | 
					                                QDateTime const &newCurrent = current.addSecs(durationInSecs);
 | 
				
			||||||
 | 
					                                if (newCurrent > carryOverStart && newCurrent <= carryOverEnd) {
 | 
				
			||||||
 | 
					                                    // cross carry over section
 | 
				
			||||||
 | 
					                                    it->second.pun_next_step_correction = carryOverStart.secsTo(carryOverEnd) / 60;
 | 
				
			||||||
 | 
					                                    it->second.pun_duration += it->second.pun_next_step_correction;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            // qCritical() << "(" << __func__ << ":" << __LINE__ << ")";
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (pop_accumulate_durations) {
 | 
				
			||||||
 | 
					                            m_timeSteps[paymentOptionIndex] << it->second.pun_duration;
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
 | 
				
			||||||
 | 
					                                int d = m_timeSteps[paymentOptionIndex].last();
 | 
				
			||||||
 | 
					                                m_timeSteps[paymentOptionIndex] << (d + it->second.pun_duration);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        current = current.addSecs(m_timeSteps[paymentOptionIndex].last() * 60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                            qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
 | 
				
			||||||
 | 
					                            qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    } else { // if (it->pun_round_to_next_24h_boundary == false) {
 | 
				
			||||||
 | 
					                        if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                            qCritical() << "(" << __func__ << ":" << __LINE__ << ") round-to-next-24h-boundary";
 | 
				
			||||||
 | 
					                            qCritical() << "(" << __func__ << ":" << __LINE__ << ") prepay" << casePrepay;
 | 
				
			||||||
 | 
					                            qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (casePrepay) {
 | 
				
			||||||
 | 
					                            // the last time step contains the (dynamic) prepay duration
 | 
				
			||||||
 | 
					                            // so it is possible to compute the last duration
 | 
				
			||||||
 | 
					                            int lastDuration =  m_timeSteps[paymentOptionIndex].last() - prepayDurationInMinutes;
 | 
				
			||||||
 | 
					                            // qCritical() << "(" << __func__ << ":" << __LINE__ << ") last duration " << lastDuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            int const minutesToAdd = 1440 - lastDuration;
 | 
				
			||||||
 | 
					                            current = current.addSecs(minutesToAdd * 60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") minutes to add " << minutesToAdd;
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (pop_accumulate_durations) {
 | 
				
			||||||
 | 
					                                m_timeSteps[paymentOptionIndex] << minutesToAdd;
 | 
				
			||||||
 | 
					                            } else {
 | 
				
			||||||
 | 
					                                if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
 | 
				
			||||||
 | 
					                                    int d = m_timeSteps[paymentOptionIndex].last();
 | 
				
			||||||
 | 
					                                    m_timeSteps[paymentOptionIndex] << (d + minutesToAdd);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            // qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            casePrepay = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_id" << it->second.pun_id;
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") pun_duration" << it->second.pun_duration;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            int secs = s.secsTo(current);
 | 
				
			||||||
 | 
					                            int const dayInSecs = 1440 * 60;
 | 
				
			||||||
 | 
					                            int const rest = secs % dayInSecs;
 | 
				
			||||||
 | 
					                            int const minutesToAdd = (dayInSecs - rest) / 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            current = current.addSecs(minutesToAdd * 60);
 | 
				
			||||||
 | 
					                            it->second.pun_duration = minutesToAdd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") minutes to add " << minutesToAdd;
 | 
				
			||||||
 | 
					                                qCritical() << "(" << __func__ << ":" << __LINE__ << ") current" << current.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (pop_accumulate_durations) {
 | 
				
			||||||
 | 
					                                m_timeSteps[paymentOptionIndex] << minutesToAdd;
 | 
				
			||||||
 | 
					                            } else {
 | 
				
			||||||
 | 
					                                if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
 | 
				
			||||||
 | 
					                                    int d = m_timeSteps[paymentOptionIndex].last();
 | 
				
			||||||
 | 
					                                    m_timeSteps[paymentOptionIndex] << (d + minutesToAdd);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            // qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                } else { // if (it->second.pun_netto) {
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")\n" << it->second;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else { // mutable == false
 | 
				
			||||||
 | 
					                if (it->second.pun_brutto) {    // no handling for prepay and carry-over
 | 
				
			||||||
 | 
					                    if (pop_accumulate_durations) {
 | 
				
			||||||
 | 
					                        m_timeSteps[paymentOptionIndex] << it->second.pun_duration;
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        if (!m_timeSteps[paymentOptionIndex].isEmpty()) {
 | 
				
			||||||
 | 
					                            int d = m_timeSteps[paymentOptionIndex].last();
 | 
				
			||||||
 | 
					                            m_timeSteps[paymentOptionIndex] << (d + it->second.pun_duration);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << m_timeSteps[paymentOptionIndex];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ") TODO";
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")\n" << it->second;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::STATIC";
 | 
					        qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option time step config:" << "TimeStepConfig::STATIC";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2788,13 +3034,12 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qCritical() << "(" << __func__ << ":" << __LINE__ << ")                   NEW timeSteps:" << m_timeSteps;
 | 
					    //qCritical() << "(" << __func__ << ":" << __LINE__ << ")                   NEW timeSteps:" << m_timeSteps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (DBG_LEVEL >= DBG_DEBUG) {
 | 
					    if (DBG_LEVEL >= DBG_DEBUG) {
 | 
				
			||||||
        qCritical() << "(" << __func__ << ":" << __LINE__ << ")                   NEW timeSteps:" << m_timeSteps;
 | 
					        QDateTime nextTime(s);
 | 
				
			||||||
 | 
					        qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << nextTime.toString(Qt::ISODate);
 | 
				
			||||||
        for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
 | 
					        for (int i = 0; i < m_timeSteps[paymentOptionIndex].size(); ++i) {
 | 
				
			||||||
            QDateTime nextTime = s;
 | 
					 | 
				
			||||||
            // nextTime.setTime(QTime(0, 0, 0));
 | 
					            // nextTime.setTime(QTime(0, 0, 0));
 | 
				
			||||||
            int const secs = m_timeSteps[paymentOptionIndex][i] * 60;
 | 
					            int const secs = m_timeSteps[paymentOptionIndex][i] * 60;
 | 
				
			||||||
            nextTime = nextTime.addSecs(secs);
 | 
					            nextTime = nextTime.addSecs(secs);
 | 
				
			||||||
@@ -2821,7 +3066,7 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
 | 
				
			|||||||
    uint32_t price = 0;
 | 
					    uint32_t price = 0;
 | 
				
			||||||
    int pun_duration = 0;
 | 
					    int pun_duration = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex" << paymentOptionIndex;
 | 
					    //qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex" << paymentOptionIndex;
 | 
				
			||||||
    //qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
 | 
					    //qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
 | 
				
			||||||
    //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
 | 
					    //qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,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()) {
 | 
				
			||||||
@@ -622,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) {
 | 
				
			||||||
@@ -721,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();
 | 
				
			||||||
@@ -839,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;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -741,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;
 | 
				
			||||||
@@ -900,7 +907,7 @@ int main() {
 | 
				
			|||||||
            int Down = 0;
 | 
					            int Down = 0;
 | 
				
			||||||
            int Up = 1;
 | 
					            int Up = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QDateTime const start = QDateTime::currentDateTime();
 | 
					            QDateTime start = QDateTime::currentDateTime();
 | 
				
			||||||
            int paymentOptionIndex = cfg.getPaymentOptionIndex(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
 | 
					            int paymentOptionIndex = cfg.getPaymentOptionIndex(PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (paymentOptionIndex != 0) {
 | 
					            if (paymentOptionIndex != 0) {
 | 
				
			||||||
@@ -913,17 +920,61 @@ int main() {
 | 
				
			|||||||
            //QSet<uint32_t> const prices2{500, 1600, 2400, 3200, 4000, 4800, 5600};
 | 
					            //QSet<uint32_t> const prices2{500, 1600, 2400, 3200, 4000, 4800, 5600};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QDateTime end;
 | 
					            QDateTime end;
 | 
				
			||||||
            CalcState calcState;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            QDateTime s(QDateTime::currentDateTime());
 | 
					            QDateTime s(QDateTime::currentDateTime());
 | 
				
			||||||
            s.setTime(QTime(12, 0, 0));
 | 
					            s.setTime(QTime(10, 0, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            int minimal_parking_price = get_minimal_parkingprice(&cfg,
 | 
					#if 0
 | 
				
			||||||
                                                                 PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
 | 
					
 | 
				
			||||||
                                                                 paymentOptionIndex, s);
 | 
					            pop_min_time = get_minimal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
 | 
				
			||||||
 | 
					            pop_max_time = get_maximal_parkingtime(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            pop_min_price = get_minimal_parkingprice(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex, s);
 | 
				
			||||||
 | 
					            pop_max_price = get_maximal_parkingprice(&cfg, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING), paymentOptionIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            pop_daily_card_price = cfg.getPaymentOptions(paymentOptionIndex).pop_daily_card_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int h = pop_min_time / 60;
 | 
				
			||||||
 | 
					            int m = pop_min_time % 60;
 | 
				
			||||||
 | 
					            qCritical().noquote() << QString("         pop_min_time %1 (%2h, %3m)").arg(pop_min_time).arg(h).arg(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            h = pop_max_time / 60;
 | 
				
			||||||
 | 
					            m = pop_max_time % 60;
 | 
				
			||||||
 | 
					            qCritical().noquote()
 | 
				
			||||||
 | 
					               << QString("         pop_max_time %1 (%2h, %3m)").arg(pop_max_time).arg(h).arg(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            qCritical() << "       pop_min_price " << pop_min_price;
 | 
				
			||||||
 | 
					            qCritical() << "       pop_max_price " << pop_max_price;
 | 
				
			||||||
 | 
					            qCritical() << "pop_daily_card_price " << pop_daily_card_price;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					            CalcState calcState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if 1
 | 
				
			||||||
 | 
					            qCritical() << "start" << s.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					            //for (int i = 1; i < 11; ++i) {
 | 
				
			||||||
 | 
					            for (int i = 0; i < 21; ++i) {
 | 
				
			||||||
 | 
					                calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
				
			||||||
 | 
					                                                    (double)i*10,
 | 
				
			||||||
 | 
					                                                    end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
 | 
				
			||||||
 | 
					                qCritical() << "RUN" << i << ": start" << s.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                            << ": price" << i*10 << "->" << end.toString(Qt::ISODate) << calcState.toString();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					            struct price_t price;
 | 
				
			||||||
 | 
					            int netto_parking_time = 1440;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            start = s;
 | 
				
			||||||
 | 
					            qCritical() << "RUN" << 0 << ": start" << s.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            calcState = compute_price_for_parking_ticket(&cfg, start, netto_parking_time,
 | 
				
			||||||
 | 
					                                                         end, &price,
 | 
				
			||||||
 | 
					                                                         PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
 | 
				
			||||||
 | 
					            qCritical() << "RUN" << 0 << ": start" << start.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                        << ": price for netto-time" << netto_parking_time
 | 
				
			||||||
 | 
					                        << "->" << price.netto << "->" << end.toString(Qt::ISODate) << calcState.toString();
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
            qCritical() << "minimal parking price" << minimal_parking_price;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (int i = 0; i < 8; ++i) {
 | 
					            for (int i = 0; i < 8; ++i) {
 | 
				
			||||||
                calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
					                calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
				
			||||||
@@ -932,11 +983,11 @@ int main() {
 | 
				
			|||||||
                qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
 | 
					                qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else
 | 
					// #else
 | 
				
			||||||
            s.setTime(QTime(15, 0, 0));
 | 
					            s.setTime(QTime(12, 0, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            minimal_parking_price = get_minimal_parkingprice(&cfg,
 | 
					            minimal_parking_price = get_minimal_parkingprice(&cfg,
 | 
				
			||||||
                                                             PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
 | 
					                                                             PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS),
 | 
				
			||||||
                                                             paymentOptionIndex, s);
 | 
					                                                             paymentOptionIndex, s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            qCritical() << "minimal parking price" << minimal_parking_price;
 | 
					            qCritical() << "minimal parking price" << minimal_parking_price;
 | 
				
			||||||
@@ -944,7 +995,7 @@ int main() {
 | 
				
			|||||||
            for (int i = 0; i < 8; ++i) {
 | 
					            for (int i = 0; i < 8; ++i) {
 | 
				
			||||||
                calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
					                calcState = compute_duration_for_parking_ticket(&cfg, s,
 | 
				
			||||||
                                                    (double)minimal_parking_price + i*800,
 | 
					                                                    (double)minimal_parking_price + i*800,
 | 
				
			||||||
                                                    end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
 | 
					                                                    end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
 | 
				
			||||||
                qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
 | 
					                qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user