Compare commits
	
		
			36 Commits
		
	
	
		
			Neuhauser-
			...
			fix-kirchd
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 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 | |||
| 9d5ddfc328 | |||
| 102607b71f | |||
| 81d515eb7f | |||
| ce61e5d3b2 | |||
| b6a0f5e8af | |||
| e0223b50f9 | |||
| 690267c388 | |||
| 9c19414e5a | 
@@ -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,17 +41,6 @@ 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 {
 | 
				
			||||||
    enum class State : uint8_t {
 | 
					    enum class State : uint8_t {
 | 
				
			||||||
        SUCCESS,
 | 
					        SUCCESS,
 | 
				
			||||||
@@ -162,6 +153,7 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg, PERMIT_TYP
 | 
				
			|||||||
int CALCULATE_LIBRARY_API get_maximal_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_parkingprice(Configuration *cfg, PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING);
 | 
					int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, 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 CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING);
 | 
				
			||||||
 | 
					int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg, PERMIT_TYPE permitType = PERMIT_TYPE::SHORT_TERM_PARKING);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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 +166,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,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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>
 | 
				
			||||||
@@ -53,6 +54,7 @@ public:
 | 
				
			|||||||
    multimap<int, ATBTimeStepConfig> TimeStepConfig;
 | 
					    multimap<int, ATBTimeStepConfig> TimeStepConfig;
 | 
				
			||||||
    multimap<int, ATBTimeBase> TimeBase;
 | 
					    multimap<int, ATBTimeBase> TimeBase;
 | 
				
			||||||
    multimap<int, ATBCustomer> Customer;
 | 
					    multimap<int, ATBCustomer> Customer;
 | 
				
			||||||
 | 
					    multimap<int, ATBTariffProduct> TariffProduct;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/// <summary>
 | 
						/// <summary>
 | 
				
			||||||
	/// Parse JSON string
 | 
						/// Parse JSON string
 | 
				
			||||||
@@ -69,6 +71,9 @@ public:
 | 
				
			|||||||
    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<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
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										101
									
								
								library/include/mobilisis/tariff_permit_type.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								library/include/mobilisis/tariff_permit_type.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,101 @@
 | 
				
			|||||||
 | 
					#ifndef TARIFF_PERMIT_TYPE_H_INCLUDED
 | 
				
			||||||
 | 
					#define TARIFF_PERMIT_TYPE_H_INCLUDED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QString>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 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;
 | 
				
			||||||
 | 
					        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;
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return 7;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    operator QString() 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");
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return QString("INVALID");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // TARIFF_PERMIT_TYPE_H_INCLUDED
 | 
				
			||||||
							
								
								
									
										64
									
								
								library/include/mobilisis/tariff_product.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								library/include/mobilisis/tariff_product.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,64 @@
 | 
				
			|||||||
 | 
					#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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    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
 | 
				
			||||||
@@ -90,6 +90,7 @@ namespace Utilities {
 | 
				
			|||||||
    uint32_t getMinimalParkingPrice(Configuration const *cfg, PaymentMethod methodId);
 | 
					    uint32_t getMinimalParkingPrice(Configuration const *cfg, PaymentMethod methodId);
 | 
				
			||||||
    uint32_t getMaximalParkingPrice(Configuration const *cfg, PaymentMethod methodId);
 | 
					    uint32_t getMaximalParkingPrice(Configuration const *cfg, PaymentMethod methodId);
 | 
				
			||||||
    uint32_t getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId);
 | 
					    uint32_t getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId);
 | 
				
			||||||
 | 
					    uint32_t getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId);
 | 
				
			||||||
    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);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -77,7 +77,9 @@ 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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
OTHER_FILES += src/main.cpp \
 | 
					OTHER_FILES += src/main.cpp \
 | 
				
			||||||
    ../tariffs/tariff_korneuburg.json \
 | 
					    ../tariffs/tariff_korneuburg.json \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -76,19 +76,50 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, PERMIT_TY
 | 
				
			|||||||
    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) {
 | 
				
			||||||
    int maxPrice = -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)
 | 
				
			||||||
        int const key = cfg->getPaymentOptions().pop_id;
 | 
					    } break;
 | 
				
			||||||
        int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes
 | 
					    case PERMIT_TYPE::DAY_TICKET_CHILD:
 | 
				
			||||||
        std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key);
 | 
					        // [[fallthrough]];
 | 
				
			||||||
        if (pv) {
 | 
					    case PERMIT_TYPE::DAY_TICKET_TEEN:
 | 
				
			||||||
            QVector<ATBPaymentRate> const &paymentRate = pv.value();
 | 
					        // [[fallthrough]];
 | 
				
			||||||
            if (paymentRate.size() > 0) {
 | 
					    case PERMIT_TYPE::DAY_TICKET_ADULT: {
 | 
				
			||||||
                int const price = paymentRate.at(0).pra_price; // price is given per hour
 | 
					        std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
 | 
				
			||||||
                maxPrice = qRound((maxTime * price) / 60.0f);
 | 
					        if (products) {
 | 
				
			||||||
 | 
					            QVector<ATBTariffProduct> product = products.value();
 | 
				
			||||||
 | 
					            if (product.size() > 0) {
 | 
				
			||||||
 | 
					                ATBTariffProduct const &p = product[0];
 | 
				
			||||||
 | 
					                return p.m_tariff_product_price;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } break;
 | 
				
			||||||
 | 
					    default:
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType) {
 | 
				
			||||||
 | 
					    int maxPrice = -1;
 | 
				
			||||||
 | 
					    static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    switch(permitType) {
 | 
				
			||||||
 | 
					    case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
 | 
				
			||||||
 | 
					        if (paymentMethodId == PaymentMethod::Progressive) {
 | 
				
			||||||
 | 
					            maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
 | 
				
			||||||
 | 
					        } else { // PaymentMethod::Linear -> e.g. szeged
 | 
				
			||||||
 | 
					            int const key = cfg->getPaymentOptions().pop_id;
 | 
				
			||||||
 | 
					            int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes
 | 
				
			||||||
 | 
					            std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key);
 | 
				
			||||||
 | 
					            if (pv) {
 | 
				
			||||||
 | 
					                QVector<ATBPaymentRate> const &paymentRate = pv.value();
 | 
				
			||||||
 | 
					                if (paymentRate.size() > 0) {
 | 
				
			||||||
 | 
					                    int const price = paymentRate.at(0).pra_price; // price is given per hour
 | 
				
			||||||
 | 
					                    maxPrice = qRound((maxTime * price) / 60.0f);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } break;
 | 
					    } break;
 | 
				
			||||||
@@ -217,7 +248,9 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // use tariff with structure as for instance Schnau, Koenigsee:
 | 
					    // use tariff with structure as for instance Schnau, Koenigsee:
 | 
				
			||||||
    // without given YearPeriod, SpecialDays and SpecialDaysWorktime
 | 
					    // without given YearPeriod, SpecialDays and SpecialDaysWorktime
 | 
				
			||||||
    if (paymentMethodId == PaymentMethod::Steps)
 | 
					    if ((paymentMethodId == PaymentMethod::Steps) ||
 | 
				
			||||||
 | 
					        // progressive tariff: e.g. Neuhauser, Kirchdorf (743)
 | 
				
			||||||
 | 
					        (paymentMethodId == PaymentMethod::Progressive))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        const QList<int> stepList = Calculator::GetInstance().GetTimeSteps(tariff);
 | 
					        const QList<int> stepList = Calculator::GetInstance().GetTimeSteps(tariff);
 | 
				
			||||||
        qCritical() << "   compute_next_timestep()     timeSteps:" << stepList;
 | 
					        qCritical() << "   compute_next_timestep()     timeSteps:" << stepList;
 | 
				
			||||||
@@ -345,7 +378,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,
 | 
					        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 minMin = tariff->getPaymentOptions().pop_min_time;
 | 
				
			||||||
@@ -384,7 +418,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
 | 
				
			|||||||
                        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().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));
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -2,6 +2,7 @@
 | 
				
			|||||||
#include "tariff_timebase.h"
 | 
					#include "tariff_timebase.h"
 | 
				
			||||||
#include "time_range_header.h"
 | 
					#include "time_range_header.h"
 | 
				
			||||||
#include "tariff_timestep_config.h"
 | 
					#include "tariff_timestep_config.h"
 | 
				
			||||||
 | 
					#include "tariff_permit_type.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QString>
 | 
					#include <QString>
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
@@ -24,6 +25,7 @@ MemberType Configuration::IdentifyJsonMember(const char* member_name)
 | 
				
			|||||||
    if (strcmp(member_name, "Customer") == 0) return MemberType::CustomerType;
 | 
					    if (strcmp(member_name, "Customer") == 0) return MemberType::CustomerType;
 | 
				
			||||||
    if (strcmp(member_name, "TimeRange") == 0) return MemberType::TimeRangeType;
 | 
					    if (strcmp(member_name, "TimeRange") == 0) return MemberType::TimeRangeType;
 | 
				
			||||||
    if (strcmp(member_name, "TimeStepConfig") == 0) return MemberType::TimeStepConfigType;
 | 
					    if (strcmp(member_name, "TimeStepConfig") == 0) return MemberType::TimeStepConfigType;
 | 
				
			||||||
 | 
					    if (strcmp(member_name, "Product") == 0) return MemberType::ProductType;
 | 
				
			||||||
    else return MemberType::UnknownType;
 | 
					    else return MemberType::UnknownType;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -93,6 +95,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
        ATBCustomer Customer;
 | 
					        ATBCustomer Customer;
 | 
				
			||||||
        ATBTimeRange TimeRange;
 | 
					        ATBTimeRange TimeRange;
 | 
				
			||||||
        ATBTimeStepConfig TimeStepConfig;
 | 
					        ATBTimeStepConfig TimeStepConfig;
 | 
				
			||||||
 | 
					        ATBTariffProduct TariffProduct;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        MemberType mb_type = MemberType::UnknownType;
 | 
					        MemberType mb_type = MemberType::UnknownType;
 | 
				
			||||||
        this->currentPaymentOptions.clear();
 | 
					        this->currentPaymentOptions.clear();
 | 
				
			||||||
@@ -157,6 +160,50 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
					{
 | 
										{
 | 
				
			||||||
					case MemberType::UnknownType:
 | 
										case MemberType::UnknownType:
 | 
				
			||||||
						break;
 | 
											break;
 | 
				
			||||||
 | 
					                    case MemberType::ProductType: {
 | 
				
			||||||
 | 
					                        if (QString(inner_obj_name) == QString("tariff_product_id")) {
 | 
				
			||||||
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
 | 
					                                int const x = k->value.GetInt();
 | 
				
			||||||
 | 
					                                TariffProduct.m_tariff_product_id = PermitType(x);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        } else
 | 
				
			||||||
 | 
					                        if (QString(inner_obj_name) == QString("tariff_product_price")) {
 | 
				
			||||||
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
 | 
					                                int const x = k->value.GetInt();
 | 
				
			||||||
 | 
					                                TariffProduct.m_tariff_product_price = x;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        } else
 | 
				
			||||||
 | 
					                        if (QString(inner_obj_name) == QString("tariff_product_name")) {
 | 
				
			||||||
 | 
					                            if (k->value.IsString()) {
 | 
				
			||||||
 | 
					                                std::string const &s = k->value.GetString();
 | 
				
			||||||
 | 
					                                TariffProduct.m_tariff_product_name = QString::fromStdString(s);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        } else
 | 
				
			||||||
 | 
					                        if (QString(inner_obj_name) == QString("tariff_product_start")) {
 | 
				
			||||||
 | 
					                            if (k->value.IsString()) {
 | 
				
			||||||
 | 
					                                std::string const &s = k->value.GetString();
 | 
				
			||||||
 | 
					                                TariffProduct.m_tariff_product_start = QTime::fromString(QString::fromStdString(s), Qt::ISODate);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        } else
 | 
				
			||||||
 | 
					                        if (QString(inner_obj_name) == QString("tariff_product_end")) {
 | 
				
			||||||
 | 
					                            if (k->value.IsString()) {
 | 
				
			||||||
 | 
					                                std::string const &s = k->value.GetString();
 | 
				
			||||||
 | 
					                                TariffProduct.m_tariff_product_end = QTime::fromString(QString::fromStdString(s), Qt::ISODate);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        } else
 | 
				
			||||||
 | 
					                        if (QString(inner_obj_name) == QString("tariff_product_from_in_minutes_from_start")) {
 | 
				
			||||||
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
 | 
					                                int const x = k->value.GetInt();
 | 
				
			||||||
 | 
					                                TariffProduct.m_tariff_product_from_in_minutes_from_start = x;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        } else
 | 
				
			||||||
 | 
					                        if (QString(inner_obj_name) == QString("tariff_product_to_in_minutes_from_start")) {
 | 
				
			||||||
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
 | 
					                                int const x = k->value.GetInt();
 | 
				
			||||||
 | 
					                                TariffProduct.m_tariff_product_to_in_minutes_from_start = x;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    } break;
 | 
				
			||||||
                    case MemberType::TimeRangeType:
 | 
					                    case MemberType::TimeRangeType:
 | 
				
			||||||
                        if (QString(inner_obj_name) == QString("time_range_id")) {
 | 
					                        if (QString(inner_obj_name) == QString("time_range_id")) {
 | 
				
			||||||
                            if (k->value.IsInt()) {
 | 
					                            if (k->value.IsInt()) {
 | 
				
			||||||
@@ -479,6 +526,9 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
                    cfg->TimeStepConfig.insert(pair<int, ATBTimeStepConfig>(TimeStepConfig.tsconfig_id, TimeStepConfig));
 | 
					                    cfg->TimeStepConfig.insert(pair<int, ATBTimeStepConfig>(TimeStepConfig.tsconfig_id, TimeStepConfig));
 | 
				
			||||||
                    // qCritical() << TimeStepConfig;
 | 
					                    // qCritical() << TimeStepConfig;
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
 | 
					                case MemberType::ProductType:
 | 
				
			||||||
 | 
					                    cfg->TariffProduct.insert(pair<int, ATBTariffProduct>(TariffProduct.m_tariff_product_id, TariffProduct));
 | 
				
			||||||
 | 
					                    qCritical() << TariffProduct;
 | 
				
			||||||
                default:
 | 
					                default:
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
@@ -492,6 +542,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ATBPaymentOption const &Configuration::getPaymentOptions() const {
 | 
					ATBPaymentOption const &Configuration::getPaymentOptions() const {
 | 
				
			||||||
    Q_ASSERT(!this->currentPaymentOptions.isEmpty());
 | 
					    Q_ASSERT(!this->currentPaymentOptions.isEmpty());
 | 
				
			||||||
    return this->currentPaymentOptions.at(0);
 | 
					    return this->currentPaymentOptions.at(0);
 | 
				
			||||||
@@ -510,6 +561,48 @@ QVector<ATBPaymentOption> &Configuration::getAllPaymentOptions() {
 | 
				
			|||||||
    return this->currentPaymentOptions;
 | 
					    return this->currentPaymentOptions;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					std::optional<QVector<ATBTariffProduct>>
 | 
				
			||||||
 | 
					Configuration::getTariffProductForAllKeys() const {
 | 
				
			||||||
 | 
					    QVector<ATBTariffProduct> products;
 | 
				
			||||||
 | 
					    std::optional<QVector<ATBTariffProduct>> value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    products.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (std::multimap<int, ATBTariffProduct>::const_iterator it = this->TariffProduct.cbegin();
 | 
				
			||||||
 | 
					        it != this->TariffProduct.cend(); ++it) {
 | 
				
			||||||
 | 
					        products.append(it->second);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (products.size() > 0) {
 | 
				
			||||||
 | 
					        value = value.value_or(products);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return value;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					std::optional<QVector<ATBTariffProduct>>
 | 
				
			||||||
 | 
					Configuration::getTariffProductForProductId(PermitType permitType) const {
 | 
				
			||||||
 | 
					    QVector<ATBTariffProduct> products;
 | 
				
			||||||
 | 
					    std::optional<QVector<ATBTariffProduct>> value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    products.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (auto[it, rangeEnd] = this->TariffProduct.equal_range(permitType); it != rangeEnd; ++it) {
 | 
				
			||||||
 | 
					        products.append(it->second);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (products.size() > 0) {
 | 
				
			||||||
 | 
					        value = value.value_or(products);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return value;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					std::optional<QVector<ATBTariffProduct>>
 | 
				
			||||||
 | 
					Configuration::getTariffProductForProductId(int id) const {
 | 
				
			||||||
 | 
					    return getTariffProductForProductId(PermitType(id));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
std::optional<QVector<ATBDailyTicket>>
 | 
					std::optional<QVector<ATBDailyTicket>>
 | 
				
			||||||
Configuration::getDailyTicketsForAllKeys() const {
 | 
					Configuration::getDailyTicketsForAllKeys() const {
 | 
				
			||||||
    QVector<ATBDailyTicket> tickets;
 | 
					    QVector<ATBDailyTicket> tickets;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -397,6 +397,14 @@ 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::getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId) {
 | 
				
			||||||
 | 
					    if (methodId == PaymentMethod::Progressive) {
 | 
				
			||||||
 | 
					        return std::max((int)cfg->TimeRange.find(step)->second.time_range_to_in_minutes_from_start, 0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint32_t Utilities::getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId) {
 | 
					uint32_t Utilities::getFirstDurationStep(Configuration const *cfg, PaymentMethod methodId) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int const popId = cfg->PaymentOption.find(methodId)->second.pop_id;
 | 
					    int const popId = cfg->PaymentOption.find(methodId)->second.pop_id;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1077
									
								
								main/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										1077
									
								
								main/main.cpp
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user