2023-04-24 15:31:46 +02:00
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
|
|
#include <variant>
|
|
|
|
#include <cstddef>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <rapidjson/rapidjson.h>
|
|
|
|
#include <rapidjson/document.h>
|
|
|
|
#include <rapidjson/error/en.h>
|
|
|
|
#include "member_type.h"
|
|
|
|
#include "currency.h"
|
|
|
|
#include "duration.h"
|
|
|
|
#include "payment_mtd.h"
|
|
|
|
#include "payment_opt.h"
|
|
|
|
#include "spec_days.h"
|
|
|
|
#include "payment_opt.h"
|
|
|
|
#include "weekdays.h"
|
|
|
|
#include "weekdays_worktime.h"
|
|
|
|
#include "spec_days_worktime.h"
|
|
|
|
#include "member_type.h"
|
|
|
|
#include "period_year.h"
|
|
|
|
#include "payment_rate.h"
|
2023-10-11 15:42:31 +02:00
|
|
|
#include "atb_project.h"
|
2023-12-15 13:27:02 +01:00
|
|
|
#include "tariff_daily_ticket.h"
|
2024-01-18 14:43:08 +01:00
|
|
|
#include "time_range_header.h"
|
|
|
|
#include "tariff_timestep_config.h"
|
2024-02-22 16:31:51 +01:00
|
|
|
#include "tariff_product.h"
|
2024-07-19 14:01:27 +02:00
|
|
|
#include "tariff_interpolation.h"
|
|
|
|
#include "tariff_prepaid.h"
|
|
|
|
#include "tariff_carryover.h"
|
2023-12-15 13:27:02 +01:00
|
|
|
|
|
|
|
#include <QVector>
|
2024-01-30 10:20:42 +01:00
|
|
|
#include <optional>
|
2023-04-24 15:31:46 +02:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace rapidjson;
|
|
|
|
|
2024-01-22 14:28:22 +01:00
|
|
|
class Calculator;
|
2023-04-24 15:31:46 +02:00
|
|
|
class Configuration
|
|
|
|
{
|
|
|
|
public:
|
2024-04-19 13:09:53 +02:00
|
|
|
using SpecialDaysType = std::multimap<int, ATBSpecialDays>;
|
|
|
|
using SpecialDaysWorktimeType = std::multimap<int, ATBSpecialDaysWorktime>;
|
2024-04-24 13:14:04 +02:00
|
|
|
using TimeRangeType = std::multimap<int, ATBTimeRange>;
|
2024-04-30 13:44:53 +02:00
|
|
|
using TariffProductType = std::multimap<int, ATBTariffProduct>;
|
2024-05-03 13:47:28 +02:00
|
|
|
using ATBPaymentOptionType = std::multimap<int, ATBPaymentOption>;
|
2024-07-19 14:01:27 +02:00
|
|
|
using TariffInterpolationType = std::multimap<int, ATBInterpolation>;
|
|
|
|
using TariffPrepaidType = std::multimap<int, ATBPrepaid>;
|
|
|
|
using TariffCarryOverType = std::multimap<int, ATBCarryOver>;
|
2024-04-19 13:09:53 +02:00
|
|
|
|
2023-10-11 15:42:31 +02:00
|
|
|
ATBProject project;
|
|
|
|
ATBCurrency Currency;
|
2024-07-21 20:58:12 +02:00
|
|
|
ATBDuration duration;
|
2023-04-24 15:31:46 +02:00
|
|
|
|
|
|
|
multimap<int, ATBDuration> Duration;
|
|
|
|
multimap<int, ATBPaymentMethod> PaymentMethod;
|
|
|
|
multimap<int, ATBPaymentRate> PaymentRate;
|
2024-07-21 20:58:12 +02:00
|
|
|
SpecialDaysWorktimeType SpecialDaysWorktime;
|
|
|
|
SpecialDaysType SpecialDays;
|
2023-04-24 15:31:46 +02:00
|
|
|
multimap<int, ATBWeekDays> WeekDays;
|
|
|
|
multimap<int, ATBPeriodYear> YearPeriod;
|
|
|
|
multimap<int, ATBWeekDaysWorktime> WeekDaysWorktime;
|
2024-07-21 20:58:12 +02:00
|
|
|
ATBPaymentOptionType PaymentOption;
|
|
|
|
multimap<int, ATBDailyTicket> DailyTicket;
|
|
|
|
TimeRangeType TimeRange;
|
|
|
|
multimap<int, ATBTimeStepConfig> TimeStepConfig;
|
|
|
|
multimap<int, ATBTimeBase> TimeBase;
|
|
|
|
multimap<int, ATBCustomer> Customer;
|
|
|
|
TariffProductType TariffProduct;
|
|
|
|
TariffInterpolationType TariffInterpolations;
|
|
|
|
TariffPrepaidType TariffPrepaidOptions;
|
|
|
|
TariffCarryOverType TariffCarryOverOptions;
|
2023-04-24 15:31:46 +02:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Parse JSON string
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="json"></param>
|
|
|
|
/// <returns>Returns operation status bool (OK | FAIL) </returns>
|
|
|
|
bool ParseJson(Configuration* cfg, const char* json);
|
|
|
|
|
2024-04-12 14:22:20 +02:00
|
|
|
ATBPaymentOption &getPaymentOptions(int paymentOptionsIndex=0);
|
|
|
|
ATBPaymentOption const &getPaymentOptions(int paymentOptionsIndex=0) const;
|
2024-01-30 10:20:42 +01:00
|
|
|
QVector<ATBPaymentOption> &getAllPaymentOptions();
|
|
|
|
QVector<ATBPaymentOption> const &getAllPaymentOptions() const;
|
2024-04-19 13:09:53 +02:00
|
|
|
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;
|
2024-01-30 10:20:42 +01:00
|
|
|
std::optional<QVector<ATBPaymentRate>> getPaymentRateForAllKeys() const;
|
|
|
|
std::optional<QVector<ATBPaymentRate>> getPaymentRateForKey(int key) const;
|
|
|
|
std::optional<QVector<ATBDailyTicket>> getDailyTicketsForAllKeys() const;
|
|
|
|
std::optional<QVector<ATBDailyTicket>> getDailyTicketsForKey(int key) const;
|
2024-07-19 14:01:27 +02:00
|
|
|
std::optional<ATBInterpolation> getInterpolationType(int type) const;
|
2024-07-21 20:58:12 +02:00
|
|
|
std::optional<QDateTime> getInterpolationEnd(QDateTime const &start, int paymentOptionIndex) const;
|
2024-07-19 14:01:27 +02:00
|
|
|
std::optional<ATBPrepaid> getPrepaidType(int type) const;
|
2024-02-22 16:31:51 +01:00
|
|
|
std::optional<QVector<ATBTariffProduct>> getTariffProductForAllKeys() const;
|
|
|
|
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(int id) const;
|
|
|
|
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductId(PermitType permitType) const;
|
2024-04-30 13:45:22 +02:00
|
|
|
std::optional<QVector<ATBTariffProduct>> getTariffProductForProductTypeName(QString const &permitTypeName) const;
|
2024-01-30 10:20:42 +01:00
|
|
|
std::optional<ATBCustomer> getCustomerForType(ATBCustomer::CustomerType customerType);
|
|
|
|
std::optional<ATBWeekDaysWorktime> getWeekDayWorkTime(QTime const &time, Qt::DayOfWeek dayOfWeek);
|
2023-11-22 16:27:41 +01:00
|
|
|
|
2024-07-21 20:58:12 +02:00
|
|
|
std::optional<QDateTime> prepaidStart(QDateTime const &start, int prepaid_option_id);
|
2024-07-19 14:01:27 +02:00
|
|
|
|
2023-04-24 15:31:46 +02:00
|
|
|
private:
|
|
|
|
/// <summary>
|
|
|
|
/// Identify type of JSON member
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="member_name"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
MemberType IdentifyJsonMember(const char* member_name);
|
2023-11-22 16:27:41 +01:00
|
|
|
|
2024-07-21 20:58:12 +02:00
|
|
|
QVector<ATBPaymentOption> currentPaymentOptions;
|
2023-05-15 14:05:55 +02:00
|
|
|
};
|