Compare commits
	
		
			132 Commits
		
	
	
		
			2.1.0
			...
			bad-neuena
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1d8dfcfa22 | |||
| 48fccafe76 | |||
| 9394625d35 | |||
| 7492e37e02 | |||
| f0dca3917c | |||
| 57ccbc150a | |||
| 8fa4335669 | |||
| 49298a1821 | |||
| 6fb4d245cb | |||
| 2dc93271fd | |||
| 5be5798681 | |||
| 1a24bc4572 | |||
| 068575f8e8 | |||
| e121cef17e | |||
| bdaea1106c | |||
| bc17213597 | |||
| 64b2b4bd85 | |||
| 8737508839 | |||
| 02f0500eac | |||
| 2d53224feb | |||
| 38964ad9a8 | |||
| d3f18f3b82 | |||
| 1a4265372e | |||
| eb20410849 | |||
| 2a492475e3 | |||
| 6a5272da7a | |||
| 4d5583df2d | |||
| de6f263817 | |||
| e4ce14da3f | |||
| b71c979a91 | |||
| 33f43fb83d | |||
| 1606a784a4 | |||
| 9f2cf613e1 | |||
| dbd9644047 | |||
| f8fef12b55 | |||
| 1dd81d4a56 | |||
| f93cf11d23 | |||
| 9d0ac4f8ce | |||
| 4ec5589f30 | |||
| c1d5ffcf3c | |||
| 7aded2b7fb | |||
| ed9e60a972 | |||
| 5d35331c83 | |||
| c7623429d9 | |||
| b596086245 | |||
| 24ca857b6f | |||
| ea0bcde413 | |||
| e93b08505a | |||
| 44efd44ede | |||
| 9d72574106 | |||
| d8ec41ebfc | |||
| f17c4f240b | |||
| 76bb1eb56a | |||
| 3b813e5eff | |||
| 436f5a109b | |||
| e17e54b315 | |||
| d07fdd8540 | |||
| 1fab458de3 | |||
| 1ac2ca91c5 | |||
| 1852f552a3 | |||
| e2c02420f0 | |||
| 1240abbbec | |||
| e20eb93abf | |||
| b0e7bd91b4 | |||
| 0cd4424434 | |||
| 1991853b66 | |||
| b31fcc5f4f | |||
| dbe649d0e4 | |||
| dfd74a455a | |||
| 10828e0708 | |||
| 2dbcc7018c | |||
| 18ed85430d | |||
| b70094abb5 | |||
| aa15d1c126 | |||
| cd159f2bbd | |||
| 475487c2ce | |||
| 8ff5b8e2b5 | |||
| b0c4ad0e2e | |||
| 7e3347b043 | |||
| 4e7fa83507 | |||
| ac76f194e1 | |||
| fe485b7b39 | |||
| e210224340 | |||
| afa62183fd | |||
| f241a87dc1 | |||
| 9b1cc49d34 | |||
| 449e618417 | |||
| aba38d2614 | |||
| 57d6b85f52 | |||
| 4f9c0422fc | |||
| a5b95d71b8 | |||
| fcbc8dcdc3 | |||
| ed99bae725 | |||
| 627d14204d | |||
| 
						
						
							
						
						d8a4c4eaa7
	
				 | 
					
					
						|||
| 4f45db4fde | |||
| a744a1ebb3 | |||
| df16bd7f9c | |||
| b751ba339e | |||
| 
						
						
							
						
						588a88455b
	
				 | 
					
					
						|||
| 
						
						
							
						
						92bfdced6a
	
				 | 
					
					
						|||
| 8bbec596c9 | |||
| 87b14ee3f8 | |||
| 3ad2c77467 | |||
| 493d94aaa1 | |||
| 7831329b11 | |||
| abbbd06f93 | |||
| ac6e45a913 | |||
| b741d2e312 | |||
| 6756aa5b88 | |||
| 7845ab8077 | |||
| cc222c298a | |||
| eb645273cc | |||
| bd1bdf8a8c | |||
| 6d18ce4caa | |||
| e980d8c451 | |||
| afb0e20dd2 | |||
| 39ab08a5b7 | |||
| c4c0e2fd77 | |||
| 7a5487aa41 | |||
| a8c1caf611 | |||
| a22145002c | |||
| 7b7dd6d103 | |||
| 1c801f1053 | |||
| 56fc95e33c | |||
| c0f81f174a | |||
| 6ba3963f25 | |||
| 1a350c0aeb | |||
| 15801be88e | |||
| 20e146d3c9 | |||
| 30768c6931 | |||
| 7933c826e6 | 
@@ -18,6 +18,8 @@
 | 
				
			|||||||
#define CALCULATE_LIBRARY_API
 | 
					#define CALCULATE_LIBRARY_API
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "tariff_permit_type.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Configuration;
 | 
					class Configuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef Configuration parking_tariff_t;
 | 
					typedef Configuration parking_tariff_t;
 | 
				
			||||||
@@ -39,30 +41,35 @@ struct CALCULATE_LIBRARY_API price_t {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum class PERMIT_TYPE : quint8 {
 | 
					 | 
				
			||||||
    SHORT_TERM_PARKING,
 | 
					 | 
				
			||||||
    DAY_TICKET,
 | 
					 | 
				
			||||||
    SZEGED_START,
 | 
					 | 
				
			||||||
    SZEGED_STOP,
 | 
					 | 
				
			||||||
    DAY_TICKET_ADULT,
 | 
					 | 
				
			||||||
    DAY_TICKET_TEEN,
 | 
					 | 
				
			||||||
    DAY_TICKET_CHILD,
 | 
					 | 
				
			||||||
    INVALID
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct CALCULATE_LIBRARY_API CalcState {
 | 
					struct CALCULATE_LIBRARY_API CalcState {
 | 
				
			||||||
 | 
					    static QString const SUCCESS;
 | 
				
			||||||
 | 
					    static QString const ERROR_PARSING_ZONE_NR;
 | 
				
			||||||
 | 
					    static QString const ERROR_LOADING_TARIFF;
 | 
				
			||||||
 | 
					    static QString const ERROR_PARSING_TARIFF;
 | 
				
			||||||
 | 
					    static QString const NEGATIVE_PARKING_TIME;
 | 
				
			||||||
 | 
					    static QString const INVALID_START_DATE;
 | 
				
			||||||
 | 
					    static QString const WRONG_PARAM_VALUES;
 | 
				
			||||||
 | 
					    static QString const WRONG_ISO_TIME_FORMAT;
 | 
				
			||||||
 | 
					    static QString const ABOVE_MAX_PARKING_TIME;
 | 
				
			||||||
 | 
					    static QString const BELOW_MIN_PARKING_TIME;
 | 
				
			||||||
 | 
					    static QString const BELOW_MIN_PARKING_PRICE;
 | 
				
			||||||
 | 
					    static QString const ABOVE_MAX_PARKING_PRICE;
 | 
				
			||||||
 | 
					    static QString const OVERPAID;
 | 
				
			||||||
 | 
					    static QString const OUTSIDE_ALLOWED_PARKING_TIME;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    enum class State : uint8_t {
 | 
					    enum class State : uint8_t {
 | 
				
			||||||
        SUCCESS,
 | 
					        SUCCESS,
 | 
				
			||||||
        ERROR_PARSING_ZONE_NR,
 | 
					        ERROR_PARSING_ZONE_NR,
 | 
				
			||||||
        ERROR_LOADING_TARIFF,
 | 
					        ERROR_LOADING_TARIFF,
 | 
				
			||||||
        ERROR_PARSING_TARIFF,
 | 
					        ERROR_PARSING_TARIFF,
 | 
				
			||||||
        NEGATIVE_PARING_TIME,
 | 
					        NEGATIVE_PARKING_TIME,
 | 
				
			||||||
        INVALID_START_DATE,
 | 
					        INVALID_START_DATE,
 | 
				
			||||||
        WRONG_PARAM_VALUES,
 | 
					        WRONG_PARAM_VALUES,
 | 
				
			||||||
        WRONG_ISO_TIME_FORMAT,
 | 
					        WRONG_ISO_TIME_FORMAT,
 | 
				
			||||||
        ABOVE_MAX_PARKING_TIME,
 | 
					        ABOVE_MAX_PARKING_TIME,
 | 
				
			||||||
        BELOW_MIN_PARKING_TIME,
 | 
					        BELOW_MIN_PARKING_TIME,
 | 
				
			||||||
        BELOW_MIN_PARKING_PRICE,
 | 
					        BELOW_MIN_PARKING_PRICE,
 | 
				
			||||||
 | 
					        ABOVE_MAX_PARKING_PRICE,
 | 
				
			||||||
        OVERPAID,
 | 
					        OVERPAID,
 | 
				
			||||||
        OUTSIDE_ALLOWED_PARKING_TIME
 | 
					        OUTSIDE_ALLOWED_PARKING_TIME
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
@@ -93,53 +100,154 @@ struct CALCULATE_LIBRARY_API CalcState {
 | 
				
			|||||||
        return (m_status == State::SUCCESS);
 | 
					        return (m_status == State::SUCCESS);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QString toString() {
 | 
				
			||||||
 | 
					        QString s;
 | 
				
			||||||
 | 
					        switch (m_status) {
 | 
				
			||||||
 | 
					        case State::SUCCESS:
 | 
				
			||||||
 | 
					            s = CalcState::SUCCESS;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::ERROR_PARSING_ZONE_NR:
 | 
				
			||||||
 | 
					            s = CalcState::ERROR_PARSING_ZONE_NR;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::ERROR_LOADING_TARIFF:
 | 
				
			||||||
 | 
					            s = CalcState::ERROR_LOADING_TARIFF;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::ERROR_PARSING_TARIFF:
 | 
				
			||||||
 | 
					            s = CalcState::ERROR_PARSING_TARIFF;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::NEGATIVE_PARKING_TIME:
 | 
				
			||||||
 | 
					            s = CalcState::NEGATIVE_PARKING_TIME;
 | 
				
			||||||
 | 
					           break;
 | 
				
			||||||
 | 
					        case State::ABOVE_MAX_PARKING_TIME:
 | 
				
			||||||
 | 
					            s = CalcState::ABOVE_MAX_PARKING_TIME;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::WRONG_PARAM_VALUES:
 | 
				
			||||||
 | 
					            s = CalcState::WRONG_PARAM_VALUES;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::BELOW_MIN_PARKING_TIME:
 | 
				
			||||||
 | 
					            s = CalcState::BELOW_MIN_PARKING_TIME;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::BELOW_MIN_PARKING_PRICE:
 | 
				
			||||||
 | 
					            s = CalcState::BELOW_MIN_PARKING_PRICE;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::OVERPAID:
 | 
				
			||||||
 | 
					            s = CalcState::OVERPAID;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::INVALID_START_DATE:
 | 
				
			||||||
 | 
					            s = CalcState::INVALID_START_DATE;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::WRONG_ISO_TIME_FORMAT:
 | 
				
			||||||
 | 
					            s = CalcState::WRONG_ISO_TIME_FORMAT;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::OUTSIDE_ALLOWED_PARKING_TIME:
 | 
				
			||||||
 | 
					            s = CalcState::OUTSIDE_ALLOWED_PARKING_TIME;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::ABOVE_MAX_PARKING_PRICE:
 | 
				
			||||||
 | 
					            s = CalcState::ABOVE_MAX_PARKING_TIME;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return s + ":" + m_desc;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    explicit operator QString () const noexcept {
 | 
					    explicit operator QString () const noexcept {
 | 
				
			||||||
        QString s;
 | 
					        QString s;
 | 
				
			||||||
        switch (m_status) {
 | 
					        switch (m_status) {
 | 
				
			||||||
        case State::SUCCESS:
 | 
					        case State::SUCCESS:
 | 
				
			||||||
            s = "SUCCESS";
 | 
					            s = CalcState::SUCCESS;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case State::ERROR_PARSING_ZONE_NR:
 | 
					        case State::ERROR_PARSING_ZONE_NR:
 | 
				
			||||||
            s = "ERROR_PARSING_ZONE_NR";
 | 
					            s = CalcState::ERROR_PARSING_ZONE_NR;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case State::ERROR_LOADING_TARIFF:
 | 
					        case State::ERROR_LOADING_TARIFF:
 | 
				
			||||||
            s = "ERROR_LOADING_TARIFF";
 | 
					            s = CalcState::ERROR_LOADING_TARIFF;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case State::ERROR_PARSING_TARIFF:
 | 
					        case State::ERROR_PARSING_TARIFF:
 | 
				
			||||||
            s = "ERROR_PARSING_TARIFF";
 | 
					            s = CalcState::ERROR_PARSING_TARIFF;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case State::NEGATIVE_PARING_TIME:
 | 
					        case State::NEGATIVE_PARKING_TIME:
 | 
				
			||||||
            s = "NEGATIVE_PARKING_TIME";
 | 
					            s = CalcState::NEGATIVE_PARKING_TIME;
 | 
				
			||||||
           break;
 | 
					           break;
 | 
				
			||||||
        case State::ABOVE_MAX_PARKING_TIME:
 | 
					        case State::ABOVE_MAX_PARKING_TIME:
 | 
				
			||||||
            s = "ABOVE_MAX_PARKING_TIME";
 | 
					            s = CalcState::ABOVE_MAX_PARKING_TIME;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case State::WRONG_PARAM_VALUES:
 | 
					        case State::WRONG_PARAM_VALUES:
 | 
				
			||||||
            s = "WRONG_PARAM_VALUES";
 | 
					            s = CalcState::WRONG_PARAM_VALUES;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case State::BELOW_MIN_PARKING_TIME:
 | 
					        case State::BELOW_MIN_PARKING_TIME:
 | 
				
			||||||
            s = "BELOW_MIN_PARKING_TIME";
 | 
					            s = CalcState::BELOW_MIN_PARKING_TIME;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case State::BELOW_MIN_PARKING_PRICE:
 | 
					        case State::BELOW_MIN_PARKING_PRICE:
 | 
				
			||||||
            s = "BELOW_MIN_PARKING_PRICE";
 | 
					            s = CalcState::BELOW_MIN_PARKING_PRICE;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case State::OVERPAID:
 | 
					        case State::OVERPAID:
 | 
				
			||||||
            s = "OVERPAID";
 | 
					            s = CalcState::OVERPAID;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case State::INVALID_START_DATE:
 | 
					        case State::INVALID_START_DATE:
 | 
				
			||||||
            s = "INVALID_START_DATE";
 | 
					            s = CalcState::INVALID_START_DATE;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case State::WRONG_ISO_TIME_FORMAT:
 | 
					        case State::WRONG_ISO_TIME_FORMAT:
 | 
				
			||||||
            s = "WRONG_ISO_TIME_FORMAT";
 | 
					            s = CalcState::WRONG_ISO_TIME_FORMAT;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case State::OUTSIDE_ALLOWED_PARKING_TIME:
 | 
					        case State::OUTSIDE_ALLOWED_PARKING_TIME:
 | 
				
			||||||
            s = "OUTSIDE_ALLOWED_PARKING_TIME";
 | 
					            s = CalcState::OUTSIDE_ALLOWED_PARKING_TIME;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case State::ABOVE_MAX_PARKING_PRICE:
 | 
				
			||||||
 | 
					            s = CalcState::ABOVE_MAX_PARKING_TIME;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return s + ":" + m_desc;
 | 
					        return s + ":" + m_desc;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    CalcState &set(State s) { m_status = s; return *this; }
 | 
					    CalcState &set(State s) { m_status = s; return *this; }
 | 
				
			||||||
    CalcState &setDesc(QString s) { m_desc = s; return *this; }
 | 
					    CalcState &setStatus(State s) { return set(s); }
 | 
				
			||||||
 | 
					    CalcState &setStatus(QString const &desc) {
 | 
				
			||||||
 | 
					        if (desc == SUCCESS) {
 | 
				
			||||||
 | 
					            m_status = State::SUCCESS;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == ERROR_PARSING_ZONE_NR) {
 | 
				
			||||||
 | 
					            m_status = State::ERROR_PARSING_ZONE_NR;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == ERROR_LOADING_TARIFF) {
 | 
				
			||||||
 | 
					            m_status = State::SUCCESS;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == ERROR_PARSING_TARIFF) {
 | 
				
			||||||
 | 
					            m_status = State::ERROR_LOADING_TARIFF;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == NEGATIVE_PARKING_TIME) {
 | 
				
			||||||
 | 
					            m_status = State::NEGATIVE_PARKING_TIME;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == INVALID_START_DATE) {
 | 
				
			||||||
 | 
					            m_status = State::INVALID_START_DATE;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == WRONG_PARAM_VALUES) {
 | 
				
			||||||
 | 
					            m_status = State::WRONG_PARAM_VALUES;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == WRONG_ISO_TIME_FORMAT) {
 | 
				
			||||||
 | 
					            m_status = State::WRONG_ISO_TIME_FORMAT;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == ABOVE_MAX_PARKING_TIME) {
 | 
				
			||||||
 | 
					            m_status = State::ABOVE_MAX_PARKING_TIME;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == BELOW_MIN_PARKING_TIME) {
 | 
				
			||||||
 | 
					            m_status = State::BELOW_MIN_PARKING_TIME;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == BELOW_MIN_PARKING_PRICE) {
 | 
				
			||||||
 | 
					            m_status = State::BELOW_MIN_PARKING_PRICE;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == OVERPAID) {
 | 
				
			||||||
 | 
					            m_status = State::OVERPAID;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == OUTSIDE_ALLOWED_PARKING_TIME) {
 | 
				
			||||||
 | 
					            m_status = State::OUTSIDE_ALLOWED_PARKING_TIME;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (desc == ABOVE_MAX_PARKING_PRICE) {
 | 
				
			||||||
 | 
					            m_status = State::ABOVE_MAX_PARKING_PRICE;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    State getStatus() const { return m_status; }
 | 
				
			||||||
 | 
					    CalcState &setDesc(QString const &s) { m_desc = s; return *this; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void setAllowedTimeRange(QTime const &from, QTime const &until) {
 | 
					    void setAllowedTimeRange(QTime const &from, QTime const &until) {
 | 
				
			||||||
        m_allowedTimeRange.setTimeRange(from, until);
 | 
					        m_allowedTimeRange.setTimeRange(from, until);
 | 
				
			||||||
@@ -158,10 +266,29 @@ int CALCULATE_LIBRARY_API get_zone_nr(int zone = -1);
 | 
				
			|||||||
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes, int UpDown);
 | 
					int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes, int UpDown);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg);
 | 
					QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg);
 | 
				
			||||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg, PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING);
 | 
					
 | 
				
			||||||
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg, PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING);
 | 
					int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
 | 
				
			||||||
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING);
 | 
					                                                  PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
 | 
				
			||||||
int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING);
 | 
					                                                  int paymentOptionIndex=0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
 | 
				
			||||||
 | 
					                                                  PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
 | 
				
			||||||
 | 
					                                                  int paymentOptionIndex=0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
 | 
				
			||||||
 | 
					                                                   PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
 | 
				
			||||||
 | 
					                                                   int paymentOptionIndex = 0,
 | 
				
			||||||
 | 
					                                                   QDateTime const &start = QDateTime::currentDateTime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
 | 
				
			||||||
 | 
					                                                   PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
 | 
				
			||||||
 | 
					                                                   int paymentOptionIndex=0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
 | 
				
			||||||
 | 
					                                                PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING,
 | 
				
			||||||
 | 
					                                                QDateTime const &start = QDateTime::currentDateTime(),
 | 
				
			||||||
 | 
					                                                QDateTime *productStart = nullptr,
 | 
				
			||||||
 | 
					                                                QDateTime *productEnd = nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(       // deprecated
 | 
					CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(       // deprecated
 | 
				
			||||||
                                            parking_tariff_t *tariff,
 | 
					                                            parking_tariff_t *tariff,
 | 
				
			||||||
@@ -174,7 +301,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
                                            QDateTime &start_parking_time,
 | 
					                                            QDateTime &start_parking_time,
 | 
				
			||||||
                                            int netto_parking_time,
 | 
					                                            int netto_parking_time,
 | 
				
			||||||
                                            QDateTime &end_parking_time,    // return value
 | 
					                                            QDateTime &end_parking_time,    // return value
 | 
				
			||||||
                                            struct price_t *price);         // return value
 | 
					                                            struct price_t *price,          // return value
 | 
				
			||||||
 | 
					                                            bool prepaid = true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(        // deprecated
 | 
					CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(        // deprecated
 | 
				
			||||||
                                            parking_tariff_t *tariff,
 | 
					                                            parking_tariff_t *tariff,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,9 +14,19 @@
 | 
				
			|||||||
using namespace std;
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Calculator {
 | 
					class Calculator {
 | 
				
			||||||
    mutable QList<int> m_timeSteps;
 | 
					    mutable QVector<QList<int>> m_timeSteps;
 | 
				
			||||||
    mutable QList<int> m_priceSteps;
 | 
					    mutable QList<int> m_priceSteps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CalcState isParkingAllowedForWeekDay(Configuration const *cfg,
 | 
				
			||||||
 | 
					                                         QDateTime const &start,
 | 
				
			||||||
 | 
					                                         int netto_parking_time,
 | 
				
			||||||
 | 
					                                         int paymentOptionIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CalcState isParkingAllowedForSpecialDay(Configuration const *cfg,
 | 
				
			||||||
 | 
					                                            QDateTime const &start,
 | 
				
			||||||
 | 
					                                            int netto_parking_time,
 | 
				
			||||||
 | 
					                                            int paymentOptionIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
    explicit Calculator() = default;
 | 
					    explicit Calculator() = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -29,13 +39,28 @@ public:
 | 
				
			|||||||
        return c;
 | 
					        return c;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void ResetTimeSteps() { m_timeSteps.clear(); }
 | 
					    void ResetTimeSteps(int paymentOptionIndex) {
 | 
				
			||||||
    QList<int> timeSteps() const { return m_timeSteps; }
 | 
					        if (m_timeSteps.size() > 0) {
 | 
				
			||||||
 | 
					            m_timeSteps[paymentOptionIndex].clear();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    QList<int> timeSteps(int paymentOptionIndex=0) const {
 | 
				
			||||||
 | 
					        if (m_timeSteps.size() > 0) {
 | 
				
			||||||
 | 
					            return m_timeSteps[paymentOptionIndex];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return QList<int>();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void ResetPriceSteps() { m_priceSteps.clear(); }
 | 
					    void ResetPriceSteps() { m_priceSteps.clear(); }
 | 
				
			||||||
    QList<int> priceSteps() const { return m_priceSteps; }
 | 
					    QList<int> priceSteps() const { return m_priceSteps; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    CalcState isParkingAllowed(Configuration const *cfg, QDateTime const &start);
 | 
					    CalcState isParkingAllowed(Configuration const *cfg,
 | 
				
			||||||
 | 
					                               QDateTime const &start);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CalcState isParkingAllowed(Configuration const *cfg,
 | 
				
			||||||
 | 
					                               QDateTime const &start,
 | 
				
			||||||
 | 
					                               int netto_parking_time,
 | 
				
			||||||
 | 
					                               int paymentOptionIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/// <summary>
 | 
						/// <summary>
 | 
				
			||||||
	/// Gets duration in seconds from cost
 | 
						/// Gets duration in seconds from cost
 | 
				
			||||||
@@ -66,8 +91,8 @@ public:
 | 
				
			|||||||
    // helper function to find time steps for a tariff with PaymentMethod::Steps
 | 
					    // helper function to find time steps for a tariff with PaymentMethod::Steps
 | 
				
			||||||
    // (e.g. Schoenau/Koenigsee)
 | 
					    // (e.g. Schoenau/Koenigsee)
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    QList<int> GetTimeSteps(Configuration *cfg) const;
 | 
					    QList<int> GetTimeSteps(Configuration *cfg, int paymentOptionIndex=0) const;
 | 
				
			||||||
    QList<int> GetSteps(Configuration *cfg) const { return GetTimeSteps(cfg); }
 | 
					    QList<int> GetSteps(Configuration *cfg, int paymentOptionIndex=0) const { return GetTimeSteps(cfg, paymentOptionIndex); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QList<int> GetPriceSteps(Configuration *cfg) const;
 | 
					    QList<int> GetPriceSteps(Configuration *cfg) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -87,8 +112,8 @@ public:
 | 
				
			|||||||
// testing public:
 | 
					// testing public:
 | 
				
			||||||
    // Introduced for PaymentMethod::Steps (e.g. Schoenau)
 | 
					    // Introduced for PaymentMethod::Steps (e.g. Schoenau)
 | 
				
			||||||
    // For tariff of following structure: only steps, no special days, nonstop.
 | 
					    // For tariff of following structure: only steps, no special days, nonstop.
 | 
				
			||||||
    uint32_t GetCostFromDuration(Configuration *cfg, QDateTime const &start, quint64 durationMinutes) const;
 | 
					    uint32_t GetCostFromDuration(Configuration *cfg, QDateTime const &start, quint64 durationMinutes, int paymentOptionIndex=0) const;
 | 
				
			||||||
    uint32_t GetCostFromDuration(Configuration *cfg, QDateTime const &start, QDateTime const &end) const;
 | 
					    uint32_t GetCostFromDuration(Configuration *cfg, QDateTime const &start, QDateTime const &end, int paymentOptionIndex=0) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    Ticket private_GetCostFromDuration(Configuration const* cfg,
 | 
					    Ticket private_GetCostFromDuration(Configuration const* cfg,
 | 
				
			||||||
@@ -104,7 +129,7 @@ private:
 | 
				
			|||||||
                              int durationMinutes);
 | 
					                              int durationMinutes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep) const;
 | 
					    uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep, int paymentOptionIndex=0) 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);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@
 | 
				
			|||||||
#include "tariff_daily_ticket.h"
 | 
					#include "tariff_daily_ticket.h"
 | 
				
			||||||
#include "time_range_header.h"
 | 
					#include "time_range_header.h"
 | 
				
			||||||
#include "tariff_timestep_config.h"
 | 
					#include "tariff_timestep_config.h"
 | 
				
			||||||
 | 
					#include "tariff_product.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QVector>
 | 
					#include <QVector>
 | 
				
			||||||
#include <optional>
 | 
					#include <optional>
 | 
				
			||||||
@@ -35,6 +36,12 @@ class Calculator;
 | 
				
			|||||||
class Configuration
 | 
					class Configuration
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					    using SpecialDaysType = std::multimap<int, ATBSpecialDays>;
 | 
				
			||||||
 | 
					    using SpecialDaysWorktimeType = std::multimap<int, ATBSpecialDaysWorktime>;
 | 
				
			||||||
 | 
					    using TimeRangeType = std::multimap<int, ATBTimeRange>;
 | 
				
			||||||
 | 
					    using TariffProductType = std::multimap<int, ATBTariffProduct>;
 | 
				
			||||||
 | 
					    using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ATBProject project;
 | 
					    ATBProject project;
 | 
				
			||||||
    ATBCurrency Currency;
 | 
					    ATBCurrency Currency;
 | 
				
			||||||
	ATBDuration duration;
 | 
						ATBDuration duration;
 | 
				
			||||||
@@ -42,17 +49,18 @@ public:
 | 
				
			|||||||
	multimap<int, ATBDuration> Duration;
 | 
						multimap<int, ATBDuration> Duration;
 | 
				
			||||||
	multimap<int, ATBPaymentMethod> PaymentMethod;
 | 
						multimap<int, ATBPaymentMethod> PaymentMethod;
 | 
				
			||||||
	multimap<int, ATBPaymentRate> PaymentRate;
 | 
						multimap<int, ATBPaymentRate> PaymentRate;
 | 
				
			||||||
	multimap<int, ATBSpecialDaysWorktime> SpecialDaysWorktime;
 | 
					    SpecialDaysWorktimeType SpecialDaysWorktime;
 | 
				
			||||||
	multimap<int, ATBSpecialDays> SpecialDays;
 | 
					    SpecialDaysType SpecialDays;
 | 
				
			||||||
	multimap<int, ATBWeekDays> WeekDays;
 | 
						multimap<int, ATBWeekDays> WeekDays;
 | 
				
			||||||
	multimap<int, ATBPeriodYear> YearPeriod;
 | 
						multimap<int, ATBPeriodYear> YearPeriod;
 | 
				
			||||||
	multimap<int, ATBWeekDaysWorktime> WeekDaysWorktime;
 | 
						multimap<int, ATBWeekDaysWorktime> WeekDaysWorktime;
 | 
				
			||||||
	multimap<int, ATBPaymentOption> PaymentOption;
 | 
					    ATBPaymentOptionType PaymentOption;
 | 
				
			||||||
    multimap<int, ATBDailyTicket> DailyTicket;
 | 
					    multimap<int, ATBDailyTicket> DailyTicket;
 | 
				
			||||||
    multimap<int, ATBTimeRange> TimeRange;
 | 
					    TimeRangeType TimeRange;
 | 
				
			||||||
    multimap<int, ATBTimeStepConfig> TimeStepConfig;
 | 
					    multimap<int, ATBTimeStepConfig> TimeStepConfig;
 | 
				
			||||||
    multimap<int, ATBTimeBase> TimeBase;
 | 
					    multimap<int, ATBTimeBase> TimeBase;
 | 
				
			||||||
    multimap<int, ATBCustomer> Customer;
 | 
					    multimap<int, ATBCustomer> Customer;
 | 
				
			||||||
 | 
					    TariffProductType TariffProduct;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/// <summary>
 | 
						/// <summary>
 | 
				
			||||||
	/// Parse JSON string
 | 
						/// Parse JSON string
 | 
				
			||||||
@@ -61,14 +69,26 @@ public:
 | 
				
			|||||||
	/// <returns>Returns operation status bool (OK | FAIL) </returns>
 | 
						/// <returns>Returns operation status bool (OK | FAIL) </returns>
 | 
				
			||||||
	bool ParseJson(Configuration* cfg, const char* json);
 | 
						bool ParseJson(Configuration* cfg, const char* json);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ATBPaymentOption &getPaymentOptions();
 | 
					    ATBPaymentOption &getPaymentOptions(int paymentOptionsIndex=0);
 | 
				
			||||||
    ATBPaymentOption const &getPaymentOptions() const;
 | 
					    ATBPaymentOption const &getPaymentOptions(int paymentOptionsIndex=0) const;
 | 
				
			||||||
    QVector<ATBPaymentOption> &getAllPaymentOptions();
 | 
					    QVector<ATBPaymentOption> &getAllPaymentOptions();
 | 
				
			||||||
    QVector<ATBPaymentOption> const &getAllPaymentOptions() const;
 | 
					    QVector<ATBPaymentOption> const &getAllPaymentOptions() const;
 | 
				
			||||||
 | 
					    int getPaymentOptionIndex(QDateTime const &dt) const;
 | 
				
			||||||
 | 
					    int getPaymentOptionIndexIfSpecialDay(QDateTime const &dt) const;
 | 
				
			||||||
 | 
					    bool isSpecialDay(QDateTime const &dt) const;
 | 
				
			||||||
 | 
					    int specialDayId(QDateTime const &dt) const;
 | 
				
			||||||
 | 
					    ATBSpecialDays specialDay(QDateTime const &dt) const;
 | 
				
			||||||
 | 
					    bool isDayIncluded(uint64_t businessHours, QDateTime const &dt) const;
 | 
				
			||||||
 | 
					    bool isDayIncludedAsSpecialDay(uint64_t businessHours, QDateTime const &dt) const;
 | 
				
			||||||
 | 
					    bool isDayIncludedAsSpecialDay(uint64_t businessHours, int specialDayId) const;
 | 
				
			||||||
    std::optional<QVector<ATBPaymentRate>> getPaymentRateForAllKeys() const;
 | 
					    std::optional<QVector<ATBPaymentRate>> getPaymentRateForAllKeys() const;
 | 
				
			||||||
    std::optional<QVector<ATBPaymentRate>> getPaymentRateForKey(int key) const;
 | 
					    std::optional<QVector<ATBPaymentRate>> getPaymentRateForKey(int key) const;
 | 
				
			||||||
    std::optional<QVector<ATBDailyTicket>> getDailyTicketsForAllKeys() const;
 | 
					    std::optional<QVector<ATBDailyTicket>> getDailyTicketsForAllKeys() const;
 | 
				
			||||||
    std::optional<QVector<ATBDailyTicket>> getDailyTicketsForKey(int key) const;
 | 
					    std::optional<QVector<ATBDailyTicket>> getDailyTicketsForKey(int key) const;
 | 
				
			||||||
 | 
					    std::optional<QVector<ATBTariffProduct>> getTariffProductForAllKeys() const;
 | 
				
			||||||
 | 
					    std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(int id) const;
 | 
				
			||||||
 | 
					    std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(PermitType permitType) const;
 | 
				
			||||||
 | 
					    std::optional<QVector<ATBTariffProduct>> getTariffProductForProductTypeName(QString const &permitTypeName) const;
 | 
				
			||||||
    std::optional<ATBCustomer> getCustomerForType(ATBCustomer::CustomerType customerType);
 | 
					    std::optional<ATBCustomer> getCustomerForType(ATBCustomer::CustomerType customerType);
 | 
				
			||||||
    std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek);
 | 
					    std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,8 @@ enum MemberType
 | 
				
			|||||||
    CustomerType = 0x0B,
 | 
					    CustomerType = 0x0B,
 | 
				
			||||||
    TimeBaseType = 0x0C,
 | 
					    TimeBaseType = 0x0C,
 | 
				
			||||||
    TimeRangeType = 0x0D,
 | 
					    TimeRangeType = 0x0D,
 | 
				
			||||||
    TimeStepConfigType = 0x0E
 | 
					    TimeStepConfigType = 0x0E,
 | 
				
			||||||
 | 
					    ProductType = 0x0F
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // MEMBER_TYPE_H_INCLUDED
 | 
					#endif // MEMBER_TYPE_H_INCLUDED
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,11 @@
 | 
				
			|||||||
#pragma once
 | 
					#ifndef PAYMENT_OPT_H_INCLUDED
 | 
				
			||||||
 | 
					#define PAYMENT_OPT_H_INCLUDED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
 | 
					#include <cinttypes>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QDateTime>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ATBPaymentOption
 | 
					class ATBPaymentOption
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -18,7 +24,10 @@ public:
 | 
				
			|||||||
        pop_min_price = 0;
 | 
					        pop_min_price = 0;
 | 
				
			||||||
        pop_max_price = 0;
 | 
					        pop_max_price = 0;
 | 
				
			||||||
        pop_carry_over = -1;
 | 
					        pop_carry_over = -1;
 | 
				
			||||||
 | 
					        pop_carry_over_target = false;
 | 
				
			||||||
        pop_carry_over_time_range_id = -1;
 | 
					        pop_carry_over_time_range_id = -1;
 | 
				
			||||||
 | 
					        pop_carry_over_start_time_range = -1;
 | 
				
			||||||
 | 
					        pop_carry_over_end_time_range = -1;
 | 
				
			||||||
        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;
 | 
				
			||||||
@@ -35,8 +44,21 @@ public:
 | 
				
			|||||||
    double pop_min_price;
 | 
					    double pop_min_price;
 | 
				
			||||||
    double pop_max_price;
 | 
					    double pop_max_price;
 | 
				
			||||||
    int pop_carry_over;
 | 
					    int pop_carry_over;
 | 
				
			||||||
 | 
					    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_end_time_range;
 | 
				
			||||||
    int pop_daily_card_price;
 | 
					    int pop_daily_card_price;
 | 
				
			||||||
    int pop_business_hours;
 | 
					    uint64_t pop_business_hours;
 | 
				
			||||||
    int pop_time_step_config;
 | 
					    int pop_time_step_config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    struct ATBMaxDateTime {
 | 
				
			||||||
 | 
					        int direction;
 | 
				
			||||||
 | 
					        uint8_t week;
 | 
				
			||||||
 | 
					        uint8_t day;
 | 
				
			||||||
 | 
					        QTime time;
 | 
				
			||||||
 | 
					    } pop_min_date_time,
 | 
				
			||||||
 | 
					      pop_max_date_time;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // PAYMENT_OPT_H_INCLUDED
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,10 +4,12 @@
 | 
				
			|||||||
class ATBSpecialDays
 | 
					class ATBSpecialDays
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					    explicit ATBSpecialDays() = default;
 | 
				
			||||||
	int ped_id;
 | 
						int ped_id;
 | 
				
			||||||
	std::string ped_label;
 | 
						std::string ped_label;
 | 
				
			||||||
	std::string ped_date_start;
 | 
						std::string ped_date_start;
 | 
				
			||||||
	std::string ped_date_end;
 | 
						std::string ped_date_end;
 | 
				
			||||||
	int ped_period_special_day_id;
 | 
					    int ped_period_special_day_id;
 | 
				
			||||||
 | 
					    int ped_payment_option_id;
 | 
				
			||||||
	int ped_year;
 | 
						int ped_year;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,19 +4,89 @@
 | 
				
			|||||||
/// <summary>
 | 
					/// <summary>
 | 
				
			||||||
/// Business hours (byte represents payment option id)
 | 
					/// Business hours (byte represents payment option id)
 | 
				
			||||||
/// </summary>
 | 
					/// </summary>
 | 
				
			||||||
enum BusinessHours
 | 
					///
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <Qt>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define _NO_RESTRICTION_24_7_                   (uint64_t)(0ULL)
 | 
				
			||||||
 | 
					#define _MON_                                   (uint64_t)(1ULL << 8)
 | 
				
			||||||
 | 
					#define _TUE_                                   (uint64_t)(1ULL << 9)
 | 
				
			||||||
 | 
					#define _WED_                                   (uint64_t)(1ULL << 10)
 | 
				
			||||||
 | 
					#define _THU_                                   (uint64_t)(1ULL << 11)
 | 
				
			||||||
 | 
					#define _FRI_                                   (uint64_t)(1ULL << 12)
 | 
				
			||||||
 | 
					#define _SAT_                                   (uint64_t)(1ULL << 13)
 | 
				
			||||||
 | 
					#define _SUN_                                   (uint64_t)(1ULL << 14)
 | 
				
			||||||
 | 
					#define _WEEK_DAYS_                             ((_MON_|_TUE_|_WED_|_THU_|_FRI_))
 | 
				
			||||||
 | 
					#define _WORKING_DAYS_                          ((_MON_|_TUE_|_WED_|_THU_|_FRI_|_SAT_))
 | 
				
			||||||
 | 
					#define _ALL_DAYS_                              ((_MON_|_TUE_|_WED_|_THU_|_FRI_|_SAT_|_SUN_))
 | 
				
			||||||
 | 
					#define _OFFICIAL_HOLIDAY_                      (uint64_t)(1ULL << 15)
 | 
				
			||||||
 | 
					#define _ONLY_WEEKEND_                          ((_SAT_|_SUN_))
 | 
				
			||||||
 | 
					#define _ONLY_OPEN_FOR_BUSINESS_DAYS_           (uint64_t)(1ULL << 16)    /* verkaufsoffen */
 | 
				
			||||||
 | 
					#define _WITH_RESTRICTED_HOURS_                 (uint64_t)(1ULL << 17)
 | 
				
			||||||
 | 
					#define _ALL_DAYS_WITH_RESTRICTED_HOURS_        ((_WITH_RESTRICTED_HOURS_|_ALL_DAYS_))
 | 
				
			||||||
 | 
					#define _WEEKEND_WITH_RESTRICTED_HOURS_         ((_WITH_RESTRICTED_HOURS_|_FRI_|_SAT_|_SUN_))
 | 
				
			||||||
 | 
					#define _WORKING_DAYS_WITH_RESTRICTED_HOURS_    ((_WITH_RESTRICTED_HOURS_|_WORKING_DAYS_))
 | 
				
			||||||
 | 
					#define _FRI_WITH_RESTRICTED_HOURS_             ((_WITH_RESTRICTED_HOURS_|_FRI_))
 | 
				
			||||||
 | 
					#define _SAT_WITH_RESTRICTED_HOURS_             ((_WITH_RESTRICTED_HOURS_|_SAT_))
 | 
				
			||||||
 | 
					#define _SUN_WITH_RESTRICTED_HOURS_             ((_WITH_RESTRICTED_HOURS_|_SUN_))
 | 
				
			||||||
 | 
					#define _NOT_DEFINED_                           (uint64_t)(~0ULL)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum BusinessHours : std::uint64_t
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    NoRestriction_24_7          = 0,
 | 
					    NoRestriction_24_7          = 0,
 | 
				
			||||||
    OnlyWorkingDays             = 1,    // [Monday-Friday]
 | 
					    OnlyWorkingDays             = 1,    // [Monday-Friday]
 | 
				
			||||||
    OnlyWeekDays                = 2,    // [Monday-Saturday]
 | 
					    OnlyWeekDays                = 2,    // [Monday-Saturday]
 | 
				
			||||||
    OnlyWeekEnd                 = 4,    // [Saturday+Sunday]
 | 
					    OnlyWeekEnd                 = 4,    // [Saturday+Sunday]
 | 
				
			||||||
    OnlyOfficialHolidays        = 8,
 | 
					    OnlyOfficialHolidays        = 8,
 | 
				
			||||||
 | 
					    OnlySundaysAndHolidays      = 12,   // [Sun+Holiday]
 | 
				
			||||||
    OnlySpecialDays             = 16,
 | 
					    OnlySpecialDays             = 16,
 | 
				
			||||||
    OnlySchoolHolidays          = 32,
 | 
					    OnlySchoolHolidays          = 32,
 | 
				
			||||||
    SpecialAndSchoolHolidays    = 48,
 | 
					    SpecialAndSchoolHolidays    = 48,
 | 
				
			||||||
    OnlyOpenForBusinessDays     = 64,   // verkaufsoffen
 | 
					    OnlyOpenForBusinessDays     = 64,   // verkaufsoffen
 | 
				
			||||||
    AllDaysWithRestrictedHours  = 128,  // every day, restricted to some time range
 | 
					    AllDaysWithRestrictedHours  = 128,  // every day, restricted to some time range
 | 
				
			||||||
    NoBusinessHoursDefined      = 255
 | 
					    NoBusinessHoursDefined      = 255,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // new 12.04.2024
 | 
				
			||||||
 | 
					    NO_RESTRICTION_24_7 = _NO_RESTRICTION_24_7_,
 | 
				
			||||||
 | 
					    MON = _MON_,
 | 
				
			||||||
 | 
					    TUE = _TUE_,
 | 
				
			||||||
 | 
					    WED = _WED_,
 | 
				
			||||||
 | 
					    THU = _THU_,
 | 
				
			||||||
 | 
					    FRI = _FRI_,
 | 
				
			||||||
 | 
					    SAT = _SAT_,
 | 
				
			||||||
 | 
					    SUN = _SUN_,
 | 
				
			||||||
 | 
					    WEEK_DAYS = _WEEK_DAYS_,
 | 
				
			||||||
 | 
					    WORKING_DAYS = _WORKING_DAYS_,
 | 
				
			||||||
 | 
					    ALL_DAYS = _ALL_DAYS_,
 | 
				
			||||||
 | 
					    OFFICIAL_HOLIDAY = _OFFICIAL_HOLIDAY_,
 | 
				
			||||||
 | 
					    ONLY_WEEKEND = _ONLY_WEEKEND_,
 | 
				
			||||||
 | 
					    ONLY_OPEN_FOR_BUSINESS_DAYS = _ONLY_OPEN_FOR_BUSINESS_DAYS_,
 | 
				
			||||||
 | 
					    ALL_DAYS_WITH_RESTRICTED_HOURS = _ALL_DAYS_WITH_RESTRICTED_HOURS_,
 | 
				
			||||||
 | 
					    WEEKEND_WITH_RESTRICTED_HOURS = _WEEKEND_WITH_RESTRICTED_HOURS_,
 | 
				
			||||||
 | 
					    WORKING_DAYS_WITH_RESTRICTED_HOURS = _WORKING_DAYS_WITH_RESTRICTED_HOURS_,
 | 
				
			||||||
 | 
					    FRI_WITH_RESTRICTED_HOURS = _FRI_WITH_RESTRICTED_HOURS_,
 | 
				
			||||||
 | 
					    SAT_WITH_RESTRICTED_HOURS = _SAT_WITH_RESTRICTED_HOURS_,
 | 
				
			||||||
 | 
					    SUN_WITH_RESTRICTED_HOURS = _SUN_WITH_RESTRICTED_HOURS_,
 | 
				
			||||||
 | 
					    NOT_DEFINED = _NOT_DEFINED_
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					static bool business(uint64_t businessHours, QDateTime &const dt) {
 | 
				
			||||||
 | 
					    switch (dayOfWeek) {
 | 
				
			||||||
 | 
					    case Qt::Monday:
 | 
				
			||||||
 | 
					        (businessHours & _MON_) == _MON_;
 | 
				
			||||||
 | 
					    case Qt::Tuesday:
 | 
				
			||||||
 | 
					    case Qt::Wednesday:
 | 
				
			||||||
 | 
					    case Qt::Thursday:
 | 
				
			||||||
 | 
					    case Qt::Saturday:
 | 
				
			||||||
 | 
					    case Qt::Sunday:
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct BusinessHours_struct {
 | 
				
			||||||
 | 
					    BusinessHours bh;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // TARIFF_BUSINESS_HOURS_H_INCLUDED
 | 
					#endif // TARIFF_BUSINESS_HOURS_H_INCLUDED
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								library/include/mobilisis/tariff_global_defines.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								library/include/mobilisis/tariff_global_defines.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					#ifndef TARIFF_GLOBAL_DEFINES_H_INCLUDED
 | 
				
			||||||
 | 
					#define TARIFF_GLOBAL_DEFINES_H_INCLUDED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DBG_HEADER "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // TARIFF_GLOBAL_DEFINES_H_INCLUDED
 | 
				
			||||||
							
								
								
									
										151
									
								
								library/include/mobilisis/tariff_permit_type.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										151
									
								
								library/include/mobilisis/tariff_permit_type.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,151 @@
 | 
				
			|||||||
 | 
					#ifndef TARIFF_PERMIT_TYPE_H_INCLUDED
 | 
				
			||||||
 | 
					#define TARIFF_PERMIT_TYPE_H_INCLUDED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QString>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum class PERMIT_TYPE : quint8 {
 | 
				
			||||||
 | 
					    SHORT_TERM_PARKING=0,
 | 
				
			||||||
 | 
					    DAY_TICKET=1,
 | 
				
			||||||
 | 
					    SZEGED_START=2,
 | 
				
			||||||
 | 
					    SZEGED_STOP=3,
 | 
				
			||||||
 | 
					    DAY_TICKET_ADULT=4,
 | 
				
			||||||
 | 
					    DAY_TICKET_TEEN=5,
 | 
				
			||||||
 | 
					    DAY_TICKET_CHILD=6,
 | 
				
			||||||
 | 
					    INVALID=7,
 | 
				
			||||||
 | 
					    FOOD_STAMP=8,
 | 
				
			||||||
 | 
					    TWENTY_FOUR_HOURS_TICKET=9
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct PermitType {
 | 
				
			||||||
 | 
					    PERMIT_TYPE m_permitType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PermitType() { m_permitType = PERMIT_TYPE::INVALID; }
 | 
				
			||||||
 | 
					    PermitType(int permitType) {
 | 
				
			||||||
 | 
					        switch(permitType) {
 | 
				
			||||||
 | 
					        case 0:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::SHORT_TERM_PARKING;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 1:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::DAY_TICKET;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 2:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::SZEGED_START;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 3:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::SZEGED_STOP;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 4:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::DAY_TICKET_ADULT;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 5:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::DAY_TICKET_TEEN;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 6:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::DAY_TICKET_CHILD;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 7:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::FOOD_STAMP;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 8:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            m_permitType = PERMIT_TYPE::INVALID;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    PermitType(PERMIT_TYPE permitType) : m_permitType(permitType) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void set(PERMIT_TYPE p) { m_permitType = p; }
 | 
				
			||||||
 | 
					    PERMIT_TYPE get() const { return m_permitType; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    operator PERMIT_TYPE() const { return m_permitType; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    operator int () const {
 | 
				
			||||||
 | 
					        switch(m_permitType) {
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::SHORT_TERM_PARKING:
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET:
 | 
				
			||||||
 | 
					            return 1;
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::SZEGED_START:
 | 
				
			||||||
 | 
					            return 2;
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::SZEGED_STOP:
 | 
				
			||||||
 | 
					            return 3;
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET_ADULT:
 | 
				
			||||||
 | 
					            return 4;
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET_CHILD:
 | 
				
			||||||
 | 
					            return 5;
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET_TEEN:
 | 
				
			||||||
 | 
					            return 6;
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::FOOD_STAMP:
 | 
				
			||||||
 | 
					            return 7;
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
 | 
				
			||||||
 | 
					            return 8;
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return 7;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QString toString() {
 | 
				
			||||||
 | 
					        switch(m_permitType) {
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET:
 | 
				
			||||||
 | 
					            return QString("DAY_TICKET");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET_ADULT:
 | 
				
			||||||
 | 
					            return QString("DAY_TICKET_ADULT");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET_CHILD:
 | 
				
			||||||
 | 
					            return QString("DAY_TICKET_CHILD");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET_TEEN:
 | 
				
			||||||
 | 
					            return QString("DAY_TICKET_TEEN");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::SHORT_TERM_PARKING:
 | 
				
			||||||
 | 
					            return QString("SHORT_TERM_PARKING");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::SZEGED_START:
 | 
				
			||||||
 | 
					            return QString("SZEGED_START");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::SZEGED_STOP:
 | 
				
			||||||
 | 
					            return QString("SZEGED_STOP");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::FOOD_STAMP:
 | 
				
			||||||
 | 
					            return QString("FOOD_STAMP");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
 | 
				
			||||||
 | 
					            return QString("TWENTY_FOUR_HOURS_TICKET");
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return QString("INVALID");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QString toString() const {
 | 
				
			||||||
 | 
					        switch(m_permitType) {
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET:
 | 
				
			||||||
 | 
					            return QString("DAY_TICKET");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET_ADULT:
 | 
				
			||||||
 | 
					            return QString("DAY_TICKET_ADULT");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET_CHILD:
 | 
				
			||||||
 | 
					            return QString("DAY_TICKET_CHILD");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::DAY_TICKET_TEEN:
 | 
				
			||||||
 | 
					            return QString("DAY_TICKET_TEEN");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::SHORT_TERM_PARKING:
 | 
				
			||||||
 | 
					            return QString("SHORT_TERM_PARKING");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::SZEGED_START:
 | 
				
			||||||
 | 
					            return QString("SZEGED_START");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::SZEGED_STOP:
 | 
				
			||||||
 | 
					            return QString("SZEGED_STOP");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::FOOD_STAMP:
 | 
				
			||||||
 | 
					            return QString("FOOD_STAMP");
 | 
				
			||||||
 | 
					        case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET:
 | 
				
			||||||
 | 
					            return QString("TWENTY_FOUR_HOURS_TICKET");
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return QString("INVALID");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    operator QString () {
 | 
				
			||||||
 | 
					        return toString();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    operator QString () const {
 | 
				
			||||||
 | 
					        return toString();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // TARIFF_PERMIT_TYPE_H_INCLUDED
 | 
				
			||||||
							
								
								
									
										66
									
								
								library/include/mobilisis/tariff_product.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								library/include/mobilisis/tariff_product.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,66 @@
 | 
				
			|||||||
 | 
					#ifndef TARIFF_PRODUCT_H_INCLUDED
 | 
				
			||||||
 | 
					#define TARIFF_PRODUCT_H_INCLUDED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QString>
 | 
				
			||||||
 | 
					#include <QDateTime>
 | 
				
			||||||
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					#include <QDebugStateSaver>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "tariff_permit_type.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct ATBTariffProduct {
 | 
				
			||||||
 | 
					    PermitType m_tariff_product_id;
 | 
				
			||||||
 | 
					    uint32_t m_tariff_product_price;
 | 
				
			||||||
 | 
					    QString m_tariff_product_name;
 | 
				
			||||||
 | 
					    QTime m_tariff_product_start;
 | 
				
			||||||
 | 
					    QTime m_tariff_product_end;
 | 
				
			||||||
 | 
					    int m_tariff_product_from_in_minutes_from_start;
 | 
				
			||||||
 | 
					    int m_tariff_product_to_in_minutes_from_start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    explicit ATBTariffProduct() = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QTime const &getTimeStart() const { return m_tariff_product_start; }
 | 
				
			||||||
 | 
					    QTime const &getTimeEnd() const { return m_tariff_product_end; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool computeQTimeStart(QTime const &t) {
 | 
				
			||||||
 | 
					        if (m_tariff_product_from_in_minutes_from_start != -1) {
 | 
				
			||||||
 | 
					            m_tariff_product_start = t.addSecs(m_tariff_product_from_in_minutes_from_start * 60);
 | 
				
			||||||
 | 
					            return m_tariff_product_start.isValid();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool computeQTimeEnd(QTime const &t) {
 | 
				
			||||||
 | 
					        if (m_tariff_product_to_in_minutes_from_start != -1) {
 | 
				
			||||||
 | 
					            m_tariff_product_end = t.addSecs(m_tariff_product_from_in_minutes_from_start * 60);
 | 
				
			||||||
 | 
					            return m_tariff_product_end.isValid();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool computeQTimes(QTime const &t) {
 | 
				
			||||||
 | 
					        if (!t.isNull() && t.isValid()) {
 | 
				
			||||||
 | 
					            return computeQTimeStart(t) && computeQTimeEnd(t);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    uint32_t getProductPrice() const { return m_tariff_product_price; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    friend QDebug operator<<(QDebug debug, ATBTariffProduct const &product) {
 | 
				
			||||||
 | 
					        QDebugStateSaver saver(debug);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        debug.nospace()
 | 
				
			||||||
 | 
					            << "                        m_tariff_product_id: " << QString(product.m_tariff_product_id) << "\n"
 | 
				
			||||||
 | 
					            << "                      m_tariff_product_name: " << product.m_tariff_product_name << "\n"
 | 
				
			||||||
 | 
					            << "                     m_tariff_product_price: " << product.m_tariff_product_price << "\n"
 | 
				
			||||||
 | 
					            << "                     m_tariff_product_start: " << product.m_tariff_product_start << "\n"
 | 
				
			||||||
 | 
					            << "                       m_tariff_product_end: " << product.m_tariff_product_end << "\n"
 | 
				
			||||||
 | 
					            << "m_tariff_product_from_in_minutes_from_start: " << product.m_tariff_product_from_in_minutes_from_start << "\n"
 | 
				
			||||||
 | 
					            << "  m_tariff_product_to_in_minutes_from_start: " << product.m_tariff_product_to_in_minutes_from_start << "\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return debug;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // TARIFF_PRODUCT_H_INCLUDED
 | 
				
			||||||
@@ -15,6 +15,9 @@
 | 
				
			|||||||
using namespace std;
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Utilities {
 | 
					namespace Utilities {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool isDayIncluded(uint64_t businessHours, QDateTime const &dt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/// <summary>
 | 
						/// <summary>
 | 
				
			||||||
	/// Get day of week from current date (Zeller's Algorithm), starting day is Sunday
 | 
						/// Get day of week from current date (Zeller's Algorithm), starting day is Sunday
 | 
				
			||||||
	/// </summary>
 | 
						/// </summary>
 | 
				
			||||||
@@ -76,10 +79,12 @@ namespace Utilities {
 | 
				
			|||||||
	double CalculatePricePerUnit(double pra_price, double durationUnit = -1);
 | 
						double CalculatePricePerUnit(double pra_price, double durationUnit = -1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QTime SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDayId);
 | 
					    QTime SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDayId);
 | 
				
			||||||
 | 
					    QTime SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator const &it);
 | 
				
			||||||
    QTime SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialDayId);
 | 
					    QTime SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialDayId);
 | 
				
			||||||
    QTime WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
 | 
					    QTime SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator const &it);
 | 
				
			||||||
    QTime WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
 | 
					    QTime WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
 | 
				
			||||||
    int WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
 | 
					    QTime WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
 | 
				
			||||||
 | 
					    int WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
 | 
				
			||||||
    // PaymentRate GetPaymentRate(Configuration const *cfg, );
 | 
					    // PaymentRate GetPaymentRate(Configuration const *cfg, );
 | 
				
			||||||
    bool isCarryOverSet(Configuration const *cfg, PaymentMethod paymentMethodId);
 | 
					    bool isCarryOverSet(Configuration const *cfg, PaymentMethod paymentMethodId);
 | 
				
			||||||
    bool isCarryOverNotSet(Configuration const *cfg, PaymentMethod paymentMethodId);
 | 
					    bool isCarryOverNotSet(Configuration const *cfg, PaymentMethod paymentMethodId);
 | 
				
			||||||
@@ -94,4 +99,6 @@ namespace Utilities {
 | 
				
			|||||||
    BusinessHours getBusinessHours(Configuration const *cfg, PaymentMethod methodId);
 | 
					    BusinessHours getBusinessHours(Configuration const *cfg, PaymentMethod methodId);
 | 
				
			||||||
    uint32_t computeWeekDaysPrice(Configuration const *cfg, PaymentMethod id);
 | 
					    uint32_t computeWeekDaysPrice(Configuration const *cfg, PaymentMethod id);
 | 
				
			||||||
    double computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id);
 | 
					    double computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id);
 | 
				
			||||||
 | 
					    QStringList dumpBusinessHours(uint64_t businessHours);
 | 
				
			||||||
 | 
					    uint32_t getDailyTicketCardPrice(Configuration const *cfg, PaymentMethod methodId);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,10 @@ INCLUDEPATH += $$_PRO_FILE_PWD_/include/rapidjson
 | 
				
			|||||||
#Version is set in yocto recipe with "EXTRA_QMAKEVARS_PRE"
 | 
					#Version is set in yocto recipe with "EXTRA_QMAKEVARS_PRE"
 | 
				
			||||||
#VERSION=1.0.0
 | 
					#VERSION=1.0.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 04.06.2024: Fix for Szeged: read price for daily ticket directly from entry
 | 
				
			||||||
 | 
					#             PaymentOptions in tariff-file if it is not given as part of a
 | 
				
			||||||
 | 
					#             Json-Product-Array in tariff-file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CONFIG(debug, debug|release) {
 | 
					CONFIG(debug, debug|release) {
 | 
				
			||||||
    win32 {
 | 
					    win32 {
 | 
				
			||||||
        QMAKE_CXXFLAGS += -DCALCULATE_LIBRARY_EXPORTS
 | 
					        QMAKE_CXXFLAGS += -DCALCULATE_LIBRARY_EXPORTS
 | 
				
			||||||
@@ -77,7 +81,10 @@ HEADERS += \
 | 
				
			|||||||
    include/mobilisis/tariff_daily_ticket.h \
 | 
					    include/mobilisis/tariff_daily_ticket.h \
 | 
				
			||||||
    include/mobilisis/tariff_customer.h \
 | 
					    include/mobilisis/tariff_customer.h \
 | 
				
			||||||
    include/mobilisis/tariff_timebase.h \
 | 
					    include/mobilisis/tariff_timebase.h \
 | 
				
			||||||
    include/mobilisis/tariff_timestep_config.h
 | 
					    include/mobilisis/tariff_timestep_config.h \
 | 
				
			||||||
 | 
					    include/mobilisis/tariff_product.h \
 | 
				
			||||||
 | 
					    include/mobilisis/tariff_permit_type.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 \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,16 +10,35 @@
 | 
				
			|||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
#include <QList>
 | 
					#include <QList>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString const CalcState::SUCCESS = "SUCCESS";
 | 
				
			||||||
 | 
					QString const CalcState::ERROR_PARSING_ZONE_NR = "ERROR_PARSING_ZONE_NR";
 | 
				
			||||||
 | 
					QString const CalcState::ERROR_LOADING_TARIFF = "ERROR_LOADING_TARIFF";
 | 
				
			||||||
 | 
					QString const CalcState::ERROR_PARSING_TARIFF = "ERROR_PARSING_TARIFF";
 | 
				
			||||||
 | 
					QString const CalcState::NEGATIVE_PARKING_TIME = "NEGATIVE_PARKING_TIME";
 | 
				
			||||||
 | 
					QString const CalcState::INVALID_START_DATE = "INVALID_START_DATE";
 | 
				
			||||||
 | 
					QString const CalcState::WRONG_PARAM_VALUES = "WRONG_PARAM_VALUES";
 | 
				
			||||||
 | 
					QString const CalcState::WRONG_ISO_TIME_FORMAT = "WRONG_ISO_TIME_FORMAT";
 | 
				
			||||||
 | 
					QString const CalcState::ABOVE_MAX_PARKING_TIME = "ABOVE_MAX_PARKING_TIME";
 | 
				
			||||||
 | 
					QString const CalcState::BELOW_MIN_PARKING_TIME = "BELOW_MIN_PARKING_TIME";
 | 
				
			||||||
 | 
					QString const CalcState::BELOW_MIN_PARKING_PRICE = "BELOW_MIN_PARKING_PRICE";
 | 
				
			||||||
 | 
					QString const CalcState::ABOVE_MAX_PARKING_PRICE = "ABOVE_MAX_PARKING_PRICE";
 | 
				
			||||||
 | 
					QString const CalcState::OVERPAID = "OVERPAID";
 | 
				
			||||||
 | 
					QString const CalcState::OUTSIDE_ALLOWED_PARKING_TIME = "OUTSIDE_ALLOWED_PARKING_TIME";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
 | 
					QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
 | 
				
			||||||
    return Calculator::GetInstance().GetTimeSteps(cfg);
 | 
					    return Calculator::GetInstance().GetTimeSteps(cfg);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg, PERMIT_TYPE permitType) {
 | 
					int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
 | 
				
			||||||
 | 
					                                                  PERMIT_TYPE permitType,
 | 
				
			||||||
 | 
					                                                  int paymentOptionIndex) {
 | 
				
			||||||
    int minTime = 0;
 | 
					    int minTime = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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)
 | 
				
			||||||
        minTime = cfg->getPaymentOptions().pop_min_time;
 | 
					        QList<int> const tsteps = Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex);
 | 
				
			||||||
 | 
					        Q_UNUSED(tsteps);
 | 
				
			||||||
 | 
					        minTime = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
				
			||||||
    } break;
 | 
					    } break;
 | 
				
			||||||
    case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
					    case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
				
			||||||
    } break;
 | 
					    } break;
 | 
				
			||||||
@@ -30,20 +49,22 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg, PERMIT_TYP
 | 
				
			|||||||
    default:
 | 
					    default:
 | 
				
			||||||
        // for each new sell-procedure, recomute the timesteps. implicitly, set
 | 
					        // for each new sell-procedure, recomute the timesteps. implicitly, set
 | 
				
			||||||
        // the minimal parking time.
 | 
					        // the minimal parking time.
 | 
				
			||||||
        Calculator::GetInstance().ResetTimeSteps();
 | 
					        Calculator::GetInstance().ResetTimeSteps(paymentOptionIndex);
 | 
				
			||||||
        Calculator::GetInstance().GetTimeSteps(cfg);
 | 
					        Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex);
 | 
				
			||||||
        minTime = qRound(cfg->getPaymentOptions().pop_min_time);
 | 
					        minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return minTime;
 | 
					    return minTime;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg, PERMIT_TYPE permitType) {
 | 
					int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
 | 
				
			||||||
 | 
					                                                  PERMIT_TYPE permitType,
 | 
				
			||||||
 | 
					                                                  int paymentOptionIndex) {
 | 
				
			||||||
    int maxTime = 0;
 | 
					    int maxTime = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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)
 | 
				
			||||||
        maxTime = cfg->getPaymentOptions().pop_max_time;
 | 
					        maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
				
			||||||
    } break;
 | 
					    } break;
 | 
				
			||||||
    case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
					    case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
				
			||||||
    } break;
 | 
					    } break;
 | 
				
			||||||
@@ -55,14 +76,18 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg, PERMIT_TYP
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return maxTime;
 | 
					    return maxTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType) {
 | 
					int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
 | 
				
			||||||
 | 
					                                                   PERMIT_TYPE permitType,
 | 
				
			||||||
 | 
					                                                   int paymentOptionIndex,
 | 
				
			||||||
 | 
					                                                   QDateTime const &start) {
 | 
				
			||||||
    int minPrice = -1;
 | 
					    int minPrice = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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().pop_min_price;
 | 
					        minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
				
			||||||
    } break;
 | 
					    } break;
 | 
				
			||||||
    case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
					    case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
				
			||||||
    } break;
 | 
					    } break;
 | 
				
			||||||
@@ -70,28 +95,151 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, PERMIT_TY
 | 
				
			|||||||
    } break;
 | 
					    } break;
 | 
				
			||||||
    case PERMIT_TYPE::DAY_TICKET_CHILD: {
 | 
					    case PERMIT_TYPE::DAY_TICKET_CHILD: {
 | 
				
			||||||
    } break;
 | 
					    } break;
 | 
				
			||||||
 | 
					    case PERMIT_TYPE::DAY_TICKET: {
 | 
				
			||||||
 | 
					        minPrice = compute_product_price(cfg, permitType, start);
 | 
				
			||||||
 | 
					    } break;
 | 
				
			||||||
    default: ;
 | 
					    default: ;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return minPrice;
 | 
					    return minPrice;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType) {
 | 
					int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
 | 
				
			||||||
 | 
					                                                PERMIT_TYPE permitType,
 | 
				
			||||||
 | 
					                                                QDateTime const &start,
 | 
				
			||||||
 | 
					                                                QDateTime *productStart,
 | 
				
			||||||
 | 
					                                                QDateTime *productEnd) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    switch(permitType) {
 | 
				
			||||||
 | 
					    case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
 | 
				
			||||||
 | 
					    } break;
 | 
				
			||||||
 | 
					    case PERMIT_TYPE::DAY_TICKET_CHILD:
 | 
				
			||||||
 | 
					        // [[fallthrough]];
 | 
				
			||||||
 | 
					    case PERMIT_TYPE::DAY_TICKET_TEEN:
 | 
				
			||||||
 | 
					        // [[fallthrough]];
 | 
				
			||||||
 | 
					    case PERMIT_TYPE::FOOD_STAMP:
 | 
				
			||||||
 | 
					        // [[fallthrough]];
 | 
				
			||||||
 | 
					    case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
				
			||||||
 | 
					        std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
 | 
				
			||||||
 | 
					        if (products) {
 | 
				
			||||||
 | 
					            QVector<ATBTariffProduct> product = products.value();
 | 
				
			||||||
 | 
					            if (product.size() > 0) {
 | 
				
			||||||
 | 
					                ATBTariffProduct const &p = product[0];
 | 
				
			||||||
 | 
					                return p.m_tariff_product_price;
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
 | 
					                // in case we do not have prepaid-option
 | 
				
			||||||
 | 
					                QTime const ¤tTime = QDateTime::currentDateTime().time();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (p.m_tariff_product_start <= currentTime && currentTime <= p.m_tariff_product_end) {
 | 
				
			||||||
 | 
					                    return p.m_tariff_product_price;
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                                << "ERROR currentTime"
 | 
				
			||||||
 | 
					                                << currentTime.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << "INVALID ("
 | 
				
			||||||
 | 
					                                << p.m_tariff_product_start.toString(Qt::ISODate)
 | 
				
			||||||
 | 
					                                << p.m_tariff_product_end.toString(Qt::ISODate) << ")";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } break;
 | 
				
			||||||
 | 
					    case PERMIT_TYPE::INVALID:
 | 
				
			||||||
 | 
					        // [[fallthrough]];
 | 
				
			||||||
 | 
					    case PERMIT_TYPE::DAY_TICKET: {
 | 
				
			||||||
 | 
					        std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
 | 
				
			||||||
 | 
					        if (products) {
 | 
				
			||||||
 | 
					            QVector<ATBTariffProduct> product = products.value();
 | 
				
			||||||
 | 
					            int product_price = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (productStart && productEnd) {
 | 
				
			||||||
 | 
					                *productStart = start;
 | 
				
			||||||
 | 
					                *productEnd = start;
 | 
				
			||||||
 | 
					                if (product.size() > 0) {
 | 
				
			||||||
 | 
					                    productStart->setTime(product[0].getTimeStart());
 | 
				
			||||||
 | 
					                    productEnd->setTime(product[0].getTimeEnd());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for (QVector<ATBTariffProduct>::size_type i=0; i<product.size(); ++i) {
 | 
				
			||||||
 | 
					                ATBTariffProduct const &p = product[i];
 | 
				
			||||||
 | 
					                QTime const &startTime = p.getTimeStart();
 | 
				
			||||||
 | 
					                QTime const &endTime = p.getTimeEnd();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // qCritical() << __LINE__ << startTime.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                // qCritical() << __LINE__ << endTime.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					                // qCritical() << __LINE__ << start.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (start.time() >= startTime && start.time() < endTime) {
 | 
				
			||||||
 | 
					                    product_price = p.getProductPrice();
 | 
				
			||||||
 | 
					                    if (productStart && productEnd) {
 | 
				
			||||||
 | 
					                        productStart->setTime(startTime);
 | 
				
			||||||
 | 
					                        productEnd->setTime(endTime);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return product_price;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            // SZEGED
 | 
				
			||||||
 | 
					            int const pop_daily_card_price = cfg->getPaymentOptions().pop_daily_card_price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            qDebug() << QString("(%1:%2) no products defined in tariff-file").arg(__func__).arg(__LINE__);
 | 
				
			||||||
 | 
					            qDebug() << QString("(%1:%2) pop_daily_card_price=%3").arg(__func__).arg(__LINE__).arg(pop_daily_card_price);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
				
			||||||
 | 
					            // return Utilities::getDailyTicketCardPrice(cfg, paymentMethodId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return pop_daily_card_price;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } break;
 | 
				
			||||||
 | 
					    case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
 | 
				
			||||||
 | 
					        std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
 | 
				
			||||||
 | 
					        if (products) {
 | 
				
			||||||
 | 
					            int product_price = 0;
 | 
				
			||||||
 | 
					            QVector<ATBTariffProduct> product = products.value();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (product.size() > 0) {
 | 
				
			||||||
 | 
					                if (productStart && productEnd) {
 | 
				
			||||||
 | 
					                    int pop_min_time = get_minimal_parkingtime(cfg); // in minutes
 | 
				
			||||||
 | 
					                    int pop_max_time = get_maximal_parkingtime(cfg); // in minutes
 | 
				
			||||||
 | 
					                    if (pop_max_time >= pop_min_time) {
 | 
				
			||||||
 | 
					                        *productStart = start;
 | 
				
			||||||
 | 
					                        *productEnd = start.addSecs(pop_max_time*60);
 | 
				
			||||||
 | 
					                        product_price = product[0].getProductPrice();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return product_price;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    } break;
 | 
				
			||||||
 | 
					    default:
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
 | 
				
			||||||
 | 
					                                                   PERMIT_TYPE permitType,
 | 
				
			||||||
 | 
					                                                   int paymentOptionIndex) {
 | 
				
			||||||
    int maxPrice = -1;
 | 
					    int maxPrice = -1;
 | 
				
			||||||
    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
					    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch(permitType) {
 | 
					    switch(permitType) {
 | 
				
			||||||
    case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
 | 
					    case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
 | 
				
			||||||
        if (paymentMethodId == PaymentMethod::Progressive) {
 | 
					        if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
 | 
				
			||||||
            maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
 | 
					            maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
 | 
				
			||||||
        } else { // PaymentMethod::Linear -> e.g. szeged
 | 
					        } else { // PaymentMethod::Linear -> e.g. szeged
 | 
				
			||||||
            int const key = cfg->getPaymentOptions().pop_id;
 | 
					            int const key = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
 | 
				
			||||||
            int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes
 | 
					            int const maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time; // maxTime is given in minutes
 | 
				
			||||||
            std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key);
 | 
					            std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key);
 | 
				
			||||||
            if (pv) {
 | 
					            if (pv) {
 | 
				
			||||||
                QVector<ATBPaymentRate> const &paymentRate = pv.value();
 | 
					                QVector<ATBPaymentRate> const &paymentRate = pv.value();
 | 
				
			||||||
                if (paymentRate.size() > 0) {
 | 
					                if (paymentRate.size() > 0) {
 | 
				
			||||||
                    int const price = paymentRate.at(0).pra_price; // price is given per hour
 | 
					                    int const price = paymentRate.last().pra_price; // price is given per hour
 | 
				
			||||||
                    maxPrice = qRound((maxTime * price) / 60.0f);
 | 
					                    maxPrice = qRound((maxTime * price) / 60.0f);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -307,7 +455,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
    if (duration < 0) {
 | 
					    if (duration < 0) {
 | 
				
			||||||
        calcState.setDesc(QString("end=%1, start=%2")
 | 
					        calcState.setDesc(QString("end=%1, start=%2")
 | 
				
			||||||
                          .arg(end_parking_time, start_parking_time));
 | 
					                          .arg(end_parking_time, start_parking_time));
 | 
				
			||||||
        return calcState.set(CalcState::State::NEGATIVE_PARING_TIME);
 | 
					        return calcState.set(CalcState::State::NEGATIVE_PARKING_TIME);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (duration > maxMin) {
 | 
					    if (duration > maxMin) {
 | 
				
			||||||
        calcState.setDesc(QString("duration=%1, maxMin=%2").arg(duration).arg(maxMin));
 | 
					        calcState.setDesc(QString("duration=%1, maxMin=%2").arg(duration).arg(maxMin));
 | 
				
			||||||
@@ -352,14 +500,19 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
        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,
 | 
				
			||||||
 | 
					        bool prepaid)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    CalcState calcState;
 | 
					    CalcState calcState;
 | 
				
			||||||
    double minMin = tariff->getPaymentOptions().pop_min_time;
 | 
					
 | 
				
			||||||
    double maxMin = tariff->getPaymentOptions().pop_max_time;
 | 
					    int paymentOptionIndex = tariff->getPaymentOptionIndex(start_parking_time);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    double minMin = tariff->getPaymentOptions(paymentOptionIndex).pop_min_time;
 | 
				
			||||||
 | 
					    double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // DEBUG
 | 
					    // DEBUG
 | 
				
			||||||
    qCritical() << "compute_price_for_parking_ticket() " << endl
 | 
					    qCritical() << "compute_price_for_parking_ticket() " << endl
 | 
				
			||||||
 | 
					                << "          paymentOptionIndex: " << paymentOptionIndex << endl
 | 
				
			||||||
                << "          start_parking_time: " << start_parking_time << endl
 | 
					                << "          start_parking_time: " << start_parking_time << endl
 | 
				
			||||||
                << "          netto_parking_time: " << netto_parking_time << endl
 | 
					                << "          netto_parking_time: " << netto_parking_time << endl
 | 
				
			||||||
                << "                      minMin: " << minMin << endl
 | 
					                << "                      minMin: " << minMin << endl
 | 
				
			||||||
@@ -370,7 +523,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
        calcState.setDesc(QString("end=%1, start=%2")
 | 
					        calcState.setDesc(QString("end=%1, start=%2")
 | 
				
			||||||
                          .arg(end_parking_time.toString(Qt::ISODate),
 | 
					                          .arg(end_parking_time.toString(Qt::ISODate),
 | 
				
			||||||
                               start_parking_time.toString(Qt::ISODate)));
 | 
					                               start_parking_time.toString(Qt::ISODate)));
 | 
				
			||||||
        return calcState.set(CalcState::State::NEGATIVE_PARING_TIME);
 | 
					        return calcState.set(CalcState::State::NEGATIVE_PARKING_TIME);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (netto_parking_time > maxMin) {
 | 
					    if (netto_parking_time > maxMin) {
 | 
				
			||||||
        calcState.setDesc(QString("duration=%1, maxMin=%2").arg(netto_parking_time).arg(maxMin));
 | 
					        calcState.setDesc(QString("duration=%1, maxMin=%2").arg(netto_parking_time).arg(maxMin));
 | 
				
			||||||
@@ -384,25 +537,46 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
        return calcState.set(CalcState::State::SUCCESS);
 | 
					        return calcState.set(CalcState::State::SUCCESS);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    double cost = -1;
 | 
				
			||||||
    if (start_parking_time.isValid()) {
 | 
					    if (start_parking_time.isValid()) {
 | 
				
			||||||
        double cost = Calculator::GetInstance().GetCostFromDuration(
 | 
					        if (tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id == PaymentMethod::Steps) {
 | 
				
			||||||
 | 
					            // hier muesste man unterscheiden: uebertrag oder nicht?
 | 
				
			||||||
 | 
					            calcState = Calculator::GetInstance().isParkingAllowed(tariff, start_parking_time,
 | 
				
			||||||
 | 
					                                                                   netto_parking_time, paymentOptionIndex);
 | 
				
			||||||
 | 
					            if (calcState.getStatus() == CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME) {
 | 
				
			||||||
 | 
					                // qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
 | 
				
			||||||
 | 
					                //             << calcState.toString();
 | 
				
			||||||
 | 
					                return calcState;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            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__ << ")"
 | 
				
			||||||
 | 
					            //             << "end_parking_time" << end_parking_time.toString(Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            cost = Calculator::GetInstance().GetCostFromDuration(
 | 
				
			||||||
                        tariff,
 | 
					                        tariff,
 | 
				
			||||||
                        tariff->getPaymentOptions().pop_payment_method_id,
 | 
					                        tariff->getPaymentOptions().pop_payment_method_id,
 | 
				
			||||||
                        start_parking_time,         // starting time
 | 
					                        start_parking_time,         // starting time
 | 
				
			||||||
                        end_parking_time,           // return value: end time
 | 
					                        end_parking_time,           // return value: end time
 | 
				
			||||||
                        netto_parking_time,         // minutes, netto
 | 
					                        netto_parking_time,         // minutes, netto
 | 
				
			||||||
                        false, true);
 | 
					                        false, prepaid);
 | 
				
			||||||
        double minCost = tariff->getPaymentOptions().pop_min_price;
 | 
					        }
 | 
				
			||||||
 | 
					        double minCost = tariff->getPaymentOptions(paymentOptionIndex).pop_min_price;
 | 
				
			||||||
        if (cost < minCost) {
 | 
					        if (cost < minCost) {
 | 
				
			||||||
            calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost, cost));
 | 
					            calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost, cost));
 | 
				
			||||||
            return calcState.set(CalcState::State::BELOW_MIN_PARKING_PRICE);
 | 
					            return calcState.set(CalcState::State::BELOW_MIN_PARKING_PRICE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // DEBUG
 | 
					        // DEBUG
 | 
				
			||||||
        qCritical() << "               -> calculated cost (price->netto) =  " << cost;
 | 
					        qCritical() << "            end_parking_time: " << end_parking_time;
 | 
				
			||||||
 | 
					        qCritical() << "  -> calculated cost (netto): " << cost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        price->brutto = price->vat = price->vat_percentage = 0;
 | 
				
			||||||
        price->units = cost;
 | 
					        price->units = cost;
 | 
				
			||||||
        price->netto = cost;
 | 
					        price->netto = cost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        return calcState.set(CalcState::State::INVALID_START_DATE);
 | 
					        return calcState.set(CalcState::State::INVALID_START_DATE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -458,16 +632,76 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
 | 
				
			|||||||
                    tariff->getPaymentOptions().pop_payment_method_id,
 | 
					                    tariff->getPaymentOptions().pop_payment_method_id,
 | 
				
			||||||
                    cs.toLocal8Bit().constData(),
 | 
					                    cs.toLocal8Bit().constData(),
 | 
				
			||||||
                    price, false, true).c_str();
 | 
					                    price, false, true).c_str();
 | 
				
			||||||
        ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // DEBUG
 | 
					        if (endTime == CalcState::SUCCESS) {
 | 
				
			||||||
        qCritical() << "compute_duration_for_parking_ticket(): ";
 | 
					            calcState.setDesc(QString("SUCCESS"));
 | 
				
			||||||
        qCritical() << "                 endTime: " << endTime;
 | 
					            calcState.setStatus(endTime);
 | 
				
			||||||
        qCritical() << "           ticketEndTime: " << ticketEndTime;
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::ERROR_PARSING_ZONE_NR) {
 | 
				
			||||||
 | 
					            calcState.setStatus(endTime);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::ERROR_LOADING_TARIFF) {
 | 
				
			||||||
 | 
					            calcState.setStatus(endTime);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::ERROR_PARSING_TARIFF) {
 | 
				
			||||||
 | 
					            calcState.setStatus(endTime);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::NEGATIVE_PARKING_TIME) {
 | 
				
			||||||
 | 
					            calcState.setStatus(endTime);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::INVALID_START_DATE) {
 | 
				
			||||||
 | 
					            calcState.setStatus(endTime);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::WRONG_PARAM_VALUES) {
 | 
				
			||||||
 | 
					            calcState.setStatus(endTime);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::WRONG_ISO_TIME_FORMAT) {
 | 
				
			||||||
 | 
					            calcState.setStatus(endTime);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::ABOVE_MAX_PARKING_TIME) {
 | 
				
			||||||
 | 
					            calcState.setStatus(endTime);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::BELOW_MIN_PARKING_TIME) {
 | 
				
			||||||
 | 
					            calcState.setStatus(endTime);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::BELOW_MIN_PARKING_PRICE) {
 | 
				
			||||||
 | 
					            calcState.setStatus(endTime);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::ABOVE_MAX_PARKING_PRICE) {
 | 
				
			||||||
 | 
					            calcState.setDesc(CalcState::ABOVE_MAX_PARKING_PRICE);
 | 
				
			||||||
 | 
					            calcState.setStatus(CalcState::ABOVE_MAX_PARKING_PRICE);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::OVERPAID) {
 | 
				
			||||||
 | 
					            calcState.setDesc(CalcState::OVERPAID);
 | 
				
			||||||
 | 
					            calcState.setStatus(CalcState::OVERPAID);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else
 | 
				
			||||||
 | 
					        if (endTime == CalcState::OUTSIDE_ALLOWED_PARKING_TIME) {
 | 
				
			||||||
 | 
					            calcState.setStatus(endTime);
 | 
				
			||||||
 | 
					            return calcState;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!ticketEndTime.isValid()) {
 | 
					            // DEBUG
 | 
				
			||||||
            calcState.setDesc(QString("ticketEndTime=%1").arg(endTime));
 | 
					            //qCritical() << "compute_duration_for_parking_ticket(): ";
 | 
				
			||||||
            return calcState.set(CalcState::State::WRONG_ISO_TIME_FORMAT);
 | 
					            //qCritical() << "                 endTime: " << endTime;
 | 
				
			||||||
 | 
					            //qCritical() << "           ticketEndTime: " << ticketEndTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!ticketEndTime.isValid()) {
 | 
				
			||||||
 | 
					                calcState.setDesc(QString("ticketEndTime=%1").arg(endTime));
 | 
				
			||||||
 | 
					                return calcState.set(CalcState::State::WRONG_ISO_TIME_FORMAT);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } 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
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,5 +1,6 @@
 | 
				
			|||||||
#include "utilities.h"
 | 
					#include "utilities.h"
 | 
				
			||||||
#include "tariff_log.h"
 | 
					#include "tariff_log.h"
 | 
				
			||||||
 | 
					#include "tariff_business_hours.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
#include <algorithm>
 | 
					#include <algorithm>
 | 
				
			||||||
@@ -260,7 +261,7 @@ bool Utilities::CheckSpecialDay(Configuration* cfg, const char* currentDateTimeS
 | 
				
			|||||||
						//cout << "CheckSpecialDay() => Month is in range between start and end" << endl;
 | 
											//cout << "CheckSpecialDay() => Month is in range between start and end" << endl;
 | 
				
			||||||
						if ((current_tm.tm_mday >= start_tm.tm_mday) && (current_tm.tm_mday <= end_tm.tm_mday))
 | 
											if ((current_tm.tm_mday >= start_tm.tm_mday) && (current_tm.tm_mday <= end_tm.tm_mday))
 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
							LOG_DEBUG("CheckSpecialDay() => SPECIAL DAY");
 | 
					                            //LOG_DEBUG("CheckSpecialDay() => SPECIAL DAY");
 | 
				
			||||||
							*specialDayId = spec_days_itr->second.ped_id;
 | 
												*specialDayId = spec_days_itr->second.ped_id;
 | 
				
			||||||
							*specialDayPrice = cfg->SpecialDaysWorktime.find(*specialDayId)->second.pedwt_price;
 | 
												*specialDayPrice = cfg->SpecialDaysWorktime.find(*specialDayId)->second.pedwt_price;
 | 
				
			||||||
							return true;
 | 
												return true;
 | 
				
			||||||
@@ -275,7 +276,7 @@ bool Utilities::CheckSpecialDay(Configuration* cfg, const char* currentDateTimeS
 | 
				
			|||||||
					//cout << "CheckSpecialDay() => Month is in range between start and end" << endl;
 | 
										//cout << "CheckSpecialDay() => Month is in range between start and end" << endl;
 | 
				
			||||||
					if ((current_tm.tm_mday >= start_tm.tm_mday) && (current_tm.tm_mday <= end_tm.tm_mday))
 | 
										if ((current_tm.tm_mday >= start_tm.tm_mday) && (current_tm.tm_mday <= end_tm.tm_mday))
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						LOG_DEBUG("CheckSpecialDay() => SPECIAL DAY");
 | 
					                        //LOG_DEBUG("CheckSpecialDay() => SPECIAL DAY");
 | 
				
			||||||
						*specialDayId = spec_days_itr->second.ped_id;
 | 
											*specialDayId = spec_days_itr->second.ped_id;
 | 
				
			||||||
						*specialDayPrice = cfg->SpecialDaysWorktime.find(*specialDayId)->second.pedwt_price;
 | 
											*specialDayPrice = cfg->SpecialDaysWorktime.find(*specialDayId)->second.pedwt_price;
 | 
				
			||||||
						return true;
 | 
											return true;
 | 
				
			||||||
@@ -317,7 +318,7 @@ bool Utilities::CheckSpecialDay(Configuration const *cfg,
 | 
				
			|||||||
                            continue;
 | 
					                            continue;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    qDebug() << "CheckSpecialDay() => SPECIAL DAY";
 | 
					                    //qDebug() << "CheckSpecialDay() => SPECIAL DAY";
 | 
				
			||||||
                    *specialDayId = spec_days_itr->second.ped_id;
 | 
					                    *specialDayId = spec_days_itr->second.ped_id;
 | 
				
			||||||
                    *specialDayPrice = cfg->SpecialDaysWorktime.find(*specialDayId)->second.pedwt_price;
 | 
					                    *specialDayPrice = cfg->SpecialDaysWorktime.find(*specialDayId)->second.pedwt_price;
 | 
				
			||||||
                    return true;
 | 
					                    return true;
 | 
				
			||||||
@@ -333,19 +334,27 @@ QTime Utilities::SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDa
 | 
				
			|||||||
    return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_from.c_str(), Qt::ISODate);
 | 
					    return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_from.c_str(), Qt::ISODate);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QTime Utilities::SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator const &it) {
 | 
				
			||||||
 | 
					    return QTime::fromString(it->second.pedwt_time_from.c_str(), Qt::ISODate);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QTime Utilities::SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator const &it) {
 | 
				
			||||||
 | 
					    return QTime::fromString(it->second.pedwt_time_to.c_str(), Qt::ISODate);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QTime Utilities::SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialDayId) {
 | 
					QTime Utilities::SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialDayId) {
 | 
				
			||||||
    return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_to.c_str(), Qt::ISODate);
 | 
					    return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_to.c_str(), Qt::ISODate);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QTime Utilities::WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr) {
 | 
					QTime Utilities::WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr) {
 | 
				
			||||||
    return QTime::fromString(itr->second.pwd_time_from.c_str(), Qt::ISODate);
 | 
					    return QTime::fromString(itr->second.pwd_time_from.c_str(), Qt::ISODate);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QTime Utilities::WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr) {
 | 
					QTime Utilities::WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr) {
 | 
				
			||||||
    return QTime::fromString(itr->second.pwd_time_to.c_str(), Qt::ISODate);
 | 
					    return QTime::fromString(itr->second.pwd_time_to.c_str(), Qt::ISODate);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int Utilities::WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr) {
 | 
					int Utilities::WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr) {
 | 
				
			||||||
    return itr->second.pwd_period_day_in_week_id;
 | 
					    return itr->second.pwd_period_day_in_week_id;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -397,9 +406,16 @@ uint32_t Utilities::getMaximalParkingPrice(Configuration const *cfg, PaymentMeth
 | 
				
			|||||||
    return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_max_price, 0);
 | 
					    return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_max_price, 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint32_t Utilities::getDailyTicketCardPrice(Configuration const *cfg, PaymentMethod methodId) {
 | 
				
			||||||
 | 
					    return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_daily_card_price, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint32_t Utilities::getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId) {
 | 
					uint32_t Utilities::getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId) {
 | 
				
			||||||
    if (methodId == PaymentMethod::Progressive) {
 | 
					    if (methodId == PaymentMethod::Progressive) {
 | 
				
			||||||
        return std::max((int)cfg->TimeRange.find(step)->second.time_range_to_in_minutes_from_start, 0);
 | 
					        Configuration::TimeRangeType::const_iterator it = cfg->TimeRange.find(step);
 | 
				
			||||||
 | 
					        if (it != cfg->TimeRange.cend()) {
 | 
				
			||||||
 | 
					            return std::max((int)(it->second.time_range_to_in_minutes_from_start), 0);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
@@ -420,10 +436,10 @@ uint32_t Utilities::getFirstDurationStep(Configuration const *cfg, PaymentMethod
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BusinessHours Utilities::getBusinessHours(Configuration const *cfg, PaymentMethod methodId) {
 | 
					BusinessHours Utilities::getBusinessHours(Configuration const *cfg, PaymentMethod methodId) {
 | 
				
			||||||
    int businessHours = cfg->PaymentOption.find(methodId)->second.pop_business_hours;
 | 
					    uint64_t businessHours = cfg->PaymentOption.find(methodId)->second.pop_business_hours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (businessHours) {
 | 
					    switch (businessHours) {
 | 
				
			||||||
    case NoRestriction_24_7: return BusinessHours::NoRestriction_24_7;
 | 
					    //case NoRestriction_24_7: return BusinessHours::NoRestriction_24_7;
 | 
				
			||||||
    case OnlyWorkingDays: return BusinessHours::OnlyWorkingDays;
 | 
					    case OnlyWorkingDays: return BusinessHours::OnlyWorkingDays;
 | 
				
			||||||
    case OnlyWeekDays: return BusinessHours::OnlyWeekDays;
 | 
					    case OnlyWeekDays: return BusinessHours::OnlyWeekDays;
 | 
				
			||||||
    case OnlyWeekEnd: return BusinessHours::OnlyWeekEnd;
 | 
					    case OnlyWeekEnd: return BusinessHours::OnlyWeekEnd;
 | 
				
			||||||
@@ -433,6 +449,21 @@ BusinessHours Utilities::getBusinessHours(Configuration const *cfg, PaymentMetho
 | 
				
			|||||||
    case SpecialAndSchoolHolidays: return BusinessHours::SpecialAndSchoolHolidays;
 | 
					    case SpecialAndSchoolHolidays: return BusinessHours::SpecialAndSchoolHolidays;
 | 
				
			||||||
    case OnlyOpenForBusinessDays: return BusinessHours::OnlyOpenForBusinessDays;
 | 
					    case OnlyOpenForBusinessDays: return BusinessHours::OnlyOpenForBusinessDays;
 | 
				
			||||||
    case AllDaysWithRestrictedHours: return BusinessHours::AllDaysWithRestrictedHours;
 | 
					    case AllDaysWithRestrictedHours: return BusinessHours::AllDaysWithRestrictedHours;
 | 
				
			||||||
 | 
					    case _NO_RESTRICTION_24_7_: return BusinessHours::NO_RESTRICTION_24_7;
 | 
				
			||||||
 | 
					    case _MON_: return BusinessHours::MON;
 | 
				
			||||||
 | 
					    case _TUE_: return BusinessHours::TUE;
 | 
				
			||||||
 | 
					    case _WED_: return BusinessHours::WED;
 | 
				
			||||||
 | 
					    case _THU_: return BusinessHours::THU;
 | 
				
			||||||
 | 
					    case _FRI_: return BusinessHours::FRI;
 | 
				
			||||||
 | 
					    case _SAT_: return BusinessHours::SAT;
 | 
				
			||||||
 | 
					    case _SUN_: return BusinessHours::SUN;
 | 
				
			||||||
 | 
					    case _WEEK_DAYS_: return BusinessHours::WEEK_DAYS;
 | 
				
			||||||
 | 
					    case _WORKING_DAYS_: return BusinessHours::WORKING_DAYS;
 | 
				
			||||||
 | 
					    case _ALL_DAYS_: return BusinessHours::ALL_DAYS;
 | 
				
			||||||
 | 
					    case _OFFICIAL_HOLIDAY_: return BusinessHours::OFFICIAL_HOLIDAY;
 | 
				
			||||||
 | 
					    case _ONLY_WEEKEND_: return BusinessHours::ONLY_WEEKEND;
 | 
				
			||||||
 | 
					    case _ONLY_OPEN_FOR_BUSINESS_DAYS_: return BusinessHours::ONLY_OPEN_FOR_BUSINESS_DAYS;
 | 
				
			||||||
 | 
					    case _NOT_DEFINED_: return BusinessHours::NOT_DEFINED;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return BusinessHours::NoBusinessHoursDefined;
 | 
					    return BusinessHours::NoBusinessHoursDefined;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -447,3 +478,82 @@ double Utilities::computeWeekDaysDurationUnit(Configuration const *cfg, PaymentM
 | 
				
			|||||||
    int durationId = cfg->PaymentRate.find(pop_id)->second.pra_payment_unit_id;
 | 
					    int durationId = cfg->PaymentRate.find(pop_id)->second.pra_payment_unit_id;
 | 
				
			||||||
    return (double)(cfg->Duration.find(durationId)->second.pun_duration);
 | 
					    return (double)(cfg->Duration.find(durationId)->second.pun_duration);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool Utilities::isDayIncluded(uint64_t businessHours, QDateTime const &dt) {
 | 
				
			||||||
 | 
					    int dayOfWeek = dt.date().dayOfWeek();
 | 
				
			||||||
 | 
					    switch (dayOfWeek) {
 | 
				
			||||||
 | 
					    case Qt::Monday:
 | 
				
			||||||
 | 
					        return ((businessHours & BusinessHours::MON) == BusinessHours::MON);
 | 
				
			||||||
 | 
					    case Qt::Tuesday:
 | 
				
			||||||
 | 
					        return ((businessHours & BusinessHours::TUE) == BusinessHours::TUE);
 | 
				
			||||||
 | 
					    case Qt::Wednesday:
 | 
				
			||||||
 | 
					        return ((businessHours & BusinessHours::WED) == BusinessHours::WED);
 | 
				
			||||||
 | 
					    case Qt::Thursday:
 | 
				
			||||||
 | 
					        return ((businessHours & BusinessHours::THU) == BusinessHours::THU);
 | 
				
			||||||
 | 
					    case Qt::Friday:
 | 
				
			||||||
 | 
					        return ((businessHours & BusinessHours::FRI) == BusinessHours::FRI);
 | 
				
			||||||
 | 
					    case Qt::Saturday:
 | 
				
			||||||
 | 
					        return ((businessHours & BusinessHours::SAT) == BusinessHours::SAT);
 | 
				
			||||||
 | 
					    case Qt::Sunday:
 | 
				
			||||||
 | 
					        return ((businessHours & BusinessHours::SUN) == BusinessHours::SUN);
 | 
				
			||||||
 | 
					    default:;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QStringList Utilities::dumpBusinessHours(uint64_t businessHours) {
 | 
				
			||||||
 | 
					    QStringList s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ((businessHours & BusinessHours::MON) == BusinessHours::MON) {
 | 
				
			||||||
 | 
					        if ((businessHours & BusinessHours::OFFICIAL_HOLIDAY) == BusinessHours::OFFICIAL_HOLIDAY) {
 | 
				
			||||||
 | 
					            s << "MON (Holiday)";
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            s << "MON";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((businessHours & BusinessHours::TUE) == BusinessHours::TUE) {
 | 
				
			||||||
 | 
					        if ((businessHours & BusinessHours::OFFICIAL_HOLIDAY) == BusinessHours::OFFICIAL_HOLIDAY) {
 | 
				
			||||||
 | 
					            s << "TUE (Holiday)";
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            s << "TUE";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((businessHours & BusinessHours::WED) == BusinessHours::WED) {
 | 
				
			||||||
 | 
					        if ((businessHours & BusinessHours::OFFICIAL_HOLIDAY) == BusinessHours::OFFICIAL_HOLIDAY) {
 | 
				
			||||||
 | 
					            s << "WED (Holiday)";
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            s << "WED";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((businessHours & BusinessHours::THU) == BusinessHours::THU) {
 | 
				
			||||||
 | 
					        if ((businessHours & BusinessHours::OFFICIAL_HOLIDAY) == BusinessHours::OFFICIAL_HOLIDAY) {
 | 
				
			||||||
 | 
					            s << "THU (Holiday)";
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            s << "THU";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((businessHours & BusinessHours::FRI) == BusinessHours::FRI) {
 | 
				
			||||||
 | 
					        if ((businessHours & BusinessHours::OFFICIAL_HOLIDAY) == BusinessHours::OFFICIAL_HOLIDAY) {
 | 
				
			||||||
 | 
					            s << "FRI (Holiday)";
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            s << "FRI";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((businessHours & BusinessHours::SAT) == BusinessHours::SAT) {
 | 
				
			||||||
 | 
					        if ((businessHours & BusinessHours::OFFICIAL_HOLIDAY) == BusinessHours::OFFICIAL_HOLIDAY) {
 | 
				
			||||||
 | 
					            s << "SAT (Holiday)";
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            s << "SAT";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((businessHours & BusinessHours::SUN) == BusinessHours::SUN) {
 | 
				
			||||||
 | 
					        if ((businessHours & BusinessHours::OFFICIAL_HOLIDAY) == BusinessHours::OFFICIAL_HOLIDAY) {
 | 
				
			||||||
 | 
					            s << "SUN (Holiday)";
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            s << "SUN";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return s;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2600
									
								
								main/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										2600
									
								
								main/main.cpp
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user