Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
e050a8a82a | |||
68ba6808fa | |||
9bfea0f46d | |||
7ee90a9e8a | |||
8f2609c4ae | |||
453ca266a5 | |||
0217bb8918 | |||
4b35b1ffb7 | |||
80e228b498 | |||
574161ff76 | |||
b80cd5e6ef | |||
ccbf07a654 | |||
3a2e521345 | |||
cd77e380ef | |||
aaa4348a9a | |||
17c4aac452 | |||
68c438bfe0 | |||
509bc29d7e | |||
f7e462188f |
13
library/include/mobilisis/atb_project.h
Normal file
13
library/include/mobilisis/atb_project.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef ATB_PROJECT_H_INCLUDED
|
||||
#define ATB_PROJECT_H_INCLUDED
|
||||
|
||||
#include <QString>
|
||||
|
||||
class ATBProject {
|
||||
public:
|
||||
QString project;
|
||||
QString version;
|
||||
QString info;
|
||||
};
|
||||
|
||||
#endif // ATB_PROJECT_H_INCLUDED
|
|
@ -109,6 +109,8 @@ CalcState CALCULATE_LIBRARY_API init_tariff(parking_tariff_t **tariff,
|
|||
void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff);
|
||||
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);
|
||||
|
||||
CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket( // deprecated
|
||||
parking_tariff_t *tariff,
|
||||
time_t start_parking_time,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include <iostream>
|
||||
#include "configuration.h"
|
||||
#include "payment_method.h"
|
||||
#include <QDateTime>
|
||||
using namespace std;
|
||||
|
||||
|
@ -30,4 +31,18 @@ public:
|
|||
|
||||
// Daily ticket
|
||||
QDateTime GetDailyTicketDuration(Configuration* cfg, const QDateTime start_datetime, uint8_t payment_option, bool carry_over);
|
||||
|
||||
//
|
||||
// helper function to find time steps for a tariff with PaymentMethod::Steps
|
||||
// (e.g. Schoenau/Koenigsee)
|
||||
//
|
||||
QList<int> GetTimeSteps(Configuration *cfg) const;
|
||||
|
||||
private:
|
||||
// Introduced for PaymentMethod::Steps (e.g. Schoenau)
|
||||
// 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, QDateTime const &end) const;
|
||||
uint32_t GetPriceForTimeStep(Configuration *cfg, int timeStep) const;
|
||||
uint32_t GetDurationForPrice(Configuration *cfg, int price) const;
|
||||
};
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "member_type.h"
|
||||
#include "period_year.h"
|
||||
#include "payment_rate.h"
|
||||
#include "atb_project.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace rapidjson;
|
||||
|
@ -27,8 +28,8 @@ using namespace rapidjson;
|
|||
class Configuration
|
||||
{
|
||||
public:
|
||||
|
||||
ATBCurrency Currency;
|
||||
ATBProject project;
|
||||
ATBCurrency Currency;
|
||||
ATBDuration duration;
|
||||
|
||||
multimap<int, ATBDuration> Duration;
|
||||
|
@ -48,6 +49,8 @@ public:
|
|||
/// <returns>Returns operation status bool (OK | FAIL) </returns>
|
||||
bool ParseJson(Configuration* cfg, const char* json);
|
||||
|
||||
ATBPaymentOption const & getPaymentOptions();
|
||||
|
||||
private:
|
||||
/// <summary>
|
||||
/// Identify type of JSON member
|
||||
|
@ -55,4 +58,6 @@ private:
|
|||
/// <param name="member_name"></param>
|
||||
/// <returns></returns>
|
||||
MemberType IdentifyJsonMember(const char* member_name);
|
||||
|
||||
ATBPaymentOption currentPaymentOptions;
|
||||
};
|
||||
|
|
|
@ -65,7 +65,8 @@ HEADERS += \
|
|||
include/mobilisis/tariff_period_year.h \
|
||||
include/mobilisis/tariff_payment_rate.h \
|
||||
include/mobilisis/tariff_log.h \
|
||||
include/mobilisis/calculate_price.h
|
||||
include/mobilisis/calculate_price.h \
|
||||
include/mobilisis/atb_project.h
|
||||
|
||||
OTHER_FILES += src/main.cpp
|
||||
|
||||
|
|
|
@ -93,6 +93,44 @@ void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff) {
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// UpDown 1 -> up; 0 -> down
|
||||
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes, int UpDown)
|
||||
{
|
||||
static const QList<int> stepList = calculator.GetTimeSteps(tariff);
|
||||
|
||||
int currentStepIndex = stepList.indexOf(currentTimeMinutes);
|
||||
|
||||
if (currentStepIndex == -1) {
|
||||
qCritical() << "compute_next_timestep() *NO STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
|
||||
return currentTimeMinutes;
|
||||
}
|
||||
|
||||
if (UpDown == 1) { // UP
|
||||
if (stepList[currentStepIndex] == stepList.last()) {
|
||||
qCritical() << "compute_next_timestep() *NO NEXT STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
|
||||
return currentTimeMinutes;
|
||||
}
|
||||
else {
|
||||
return stepList[currentStepIndex + 1];
|
||||
}
|
||||
}
|
||||
if (UpDown == 0) { // DOWN
|
||||
if (stepList[currentStepIndex] == stepList.first()) {
|
||||
qCritical() << "compute_next_timestep() *NO PREVIOUS STEP* for currentTimeMinutes (" << currentTimeMinutes << ")";
|
||||
return currentTimeMinutes;
|
||||
}
|
||||
else {
|
||||
return stepList[currentStepIndex - 1];
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "compute_next_timestep() *CAN NOT COMPUTE* for currentTimeMinutes (" << currentTimeMinutes << ")";
|
||||
return currentTimeMinutes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// this is currently not used
|
||||
CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
parking_tariff_t *tariff,
|
||||
|
@ -100,8 +138,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||
time_t end_parking_time, // netto time in minutes
|
||||
struct price_t *price) {
|
||||
CalcState calcState;
|
||||
double minMin = tariff->PaymentOption.find(PaymentOption::Option1)->second.pop_min_time;
|
||||
double maxMin = tariff->PaymentOption.find(PaymentOption::Option1)->second.pop_max_time;
|
||||
double minMin = tariff->PaymentOption.find(tariff->getPaymentOptions().pop_payment_method_id)->second.pop_min_time;
|
||||
double maxMin = tariff->PaymentOption.find(tariff->getPaymentOptions().pop_payment_method_id)->second.pop_max_time;
|
||||
|
||||
if (minMin < 0 || maxMin < 0 || maxMin < minMin) {
|
||||
calcState.setDesc(QString("minMin=%1, maxMin=%2").arg(minMin).arg(maxMin));
|
||||
|
@ -134,11 +172,12 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||
QDateTime end(start);
|
||||
if (start.isValid()) {
|
||||
double cost = calculator.GetCostFromDuration(
|
||||
tariff, PaymentOption::Option1,
|
||||
tariff,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
start,
|
||||
end,
|
||||
duration, false, true);
|
||||
double minCost = tariff->PaymentOption.find(PaymentOption::Option1)->second.pop_min_price;
|
||||
double minCost = tariff->PaymentOption.find(tariff->getPaymentOptions().pop_payment_method_id)->second.pop_min_price;
|
||||
if (cost < minCost) {
|
||||
calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost).arg(cost));
|
||||
return calcState.set(CalcState::State::BELOW_MIN_PARKING_PRICE);
|
||||
|
@ -160,8 +199,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||
struct price_t *price)
|
||||
{
|
||||
CalcState calcState;
|
||||
double minMin = tariff->PaymentOption.find(PaymentOption::Option1)->second.pop_min_time;
|
||||
double maxMin = tariff->PaymentOption.find(PaymentOption::Option1)->second.pop_max_time;
|
||||
double minMin = tariff->getPaymentOptions().pop_min_time;
|
||||
double maxMin = tariff->getPaymentOptions().pop_max_time;
|
||||
|
||||
// DEBUG
|
||||
qCritical() << "compute_price_for_parking_ticket() " << endl
|
||||
|
@ -192,12 +231,13 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||
|
||||
if (start_parking_time.isValid()) {
|
||||
double cost = calculator.GetCostFromDuration(
|
||||
tariff, PaymentOption::Option1,
|
||||
tariff,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
start_parking_time, // starting time
|
||||
end_parking_time, // return value: end time
|
||||
netto_parking_time, // minutes, netto
|
||||
false, true);
|
||||
double minCost = tariff->PaymentOption.find(PaymentOption::Option1)->second.pop_min_price;
|
||||
double minCost = tariff->getPaymentOptions().pop_min_price;
|
||||
if (cost < minCost) {
|
||||
calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost, cost));
|
||||
return calcState.set(CalcState::State::BELOW_MIN_PARKING_PRICE);
|
||||
|
@ -233,7 +273,8 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||
qCritical() << " start (cs): " << cs;
|
||||
qCritical() << " price: " << price;
|
||||
|
||||
duration = calculator.GetDurationFromCost(tariff, PaymentOption::Option1,
|
||||
duration = calculator.GetDurationFromCost(tariff,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
cs.toLocal8Bit().constData(),
|
||||
price, false, true).c_str();
|
||||
QDateTime d = QDateTime::fromString(duration, Qt::ISODate);
|
||||
|
@ -258,7 +299,8 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||
if (start_parking_time.isValid()) {
|
||||
QString cs = start_parking_time.toString(Qt::ISODate);
|
||||
QString endTime = calculator.GetDurationFromCost(
|
||||
tariff, PaymentOption::Option1,
|
||||
tariff,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
cs.toLocal8Bit().constData(),
|
||||
price, false, true).c_str();
|
||||
ticketEndTime = QDateTime::fromString(endTime,Qt::ISODate);
|
||||
|
@ -286,7 +328,7 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff
|
|||
|
||||
ticketEndTime = calculator.GetDailyTicketDuration(tariff,
|
||||
start_parking_time,
|
||||
PaymentOption::Option1,
|
||||
tariff->getPaymentOptions().pop_payment_method_id,
|
||||
false); // carry over
|
||||
|
||||
// DEBUG
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "calculator_functions.h"
|
||||
#include "payment_method.h"
|
||||
#include "payment_option.h"
|
||||
#include "utilities.h"
|
||||
#include "tariff_log.h"
|
||||
|
||||
|
@ -118,22 +118,35 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||
bool nextDay,
|
||||
bool prepaid)
|
||||
{
|
||||
|
||||
// Get input date
|
||||
QDateTime inputDate = QDateTime::fromString(start_datetime,Qt::ISODate);
|
||||
|
||||
// use tariff with structure as for instance Schnau, Koenigsee:
|
||||
// without given YearPeriod, SpecialDays and SpecialDaysWorktime
|
||||
if (cfg->YearPeriod.size() == 0
|
||||
&& cfg->SpecialDays.size() == 0
|
||||
&& cfg->SpecialDaysWorktime.size() == 0)
|
||||
{
|
||||
inputDate = inputDate.addSecs(GetDurationForPrice(cfg, price) * 60);
|
||||
|
||||
return inputDate.toString(Qt::ISODate).toStdString();
|
||||
}
|
||||
|
||||
|
||||
// Get day of week
|
||||
int weekdayId = 0;
|
||||
weekdayId = Utilities::ZellersAlgorithm(inputDate.date().day(),inputDate.date().month(),inputDate.date().year());
|
||||
|
||||
//Get min and max time defined in JSON
|
||||
double minMin = 0;
|
||||
minMin = cfg->PaymentOption.find(payment_option)->second.pop_min_time;
|
||||
minMin = cfg->getPaymentOptions().pop_min_time;
|
||||
|
||||
double maxMin = 0;
|
||||
maxMin = cfg->PaymentOption.find(payment_option)->second.pop_max_time;
|
||||
maxMin = cfg->getPaymentOptions().pop_max_time;
|
||||
|
||||
double min_price = 0;
|
||||
min_price = cfg->PaymentOption.find(payment_option)->second.pop_min_price;
|
||||
min_price = cfg->getPaymentOptions().pop_min_price;
|
||||
|
||||
if(price < min_price)
|
||||
{
|
||||
|
@ -336,11 +349,53 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||
return inputDate.toString(Qt::ISODate).toStdString();
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
/// <inheritdoc/>
|
||||
///
|
||||
|
||||
uint32_t Calculator::GetCostFromDuration(Configuration *cfg,
|
||||
QDateTime const &start,
|
||||
quint64 timeStepInMinutes) const {
|
||||
// for instance, a tariff as used in Schoenau, Koenigssee: only steps, no
|
||||
// special days, nonstop.
|
||||
if (cfg->YearPeriod.size() == 0
|
||||
&& cfg->SpecialDays.size() == 0
|
||||
&& cfg->SpecialDaysWorktime.size() == 0) {
|
||||
QDateTime const end = start.addSecs(timeStepInMinutes*60);
|
||||
return GetCostFromDuration(cfg, start, end);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t Calculator::GetCostFromDuration(Configuration * cfg,
|
||||
QDateTime const &start,
|
||||
QDateTime const &end) const {
|
||||
if (cfg->YearPeriod.size() == 0
|
||||
&& cfg->SpecialDays.size() == 0
|
||||
&& cfg->SpecialDaysWorktime.size() == 0) {
|
||||
int const timeStepInMinutes = start.secsTo(end) / 60;
|
||||
return GetPriceForTimeStep(cfg, timeStepInMinutes);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
/// <inheritdoc/>
|
||||
double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_option, const QDateTime start_datetime, QDateTime & end_datetime, double durationMin, bool nextDay, bool prepaid)
|
||||
{
|
||||
if (cfg->YearPeriod.size() == 0
|
||||
&& cfg->SpecialDays.size() == 0
|
||||
&& cfg->SpecialDaysWorktime.size() == 0)
|
||||
{
|
||||
end_datetime = start_datetime.addSecs(durationMin*60);
|
||||
return GetCostFromDuration(cfg, start_datetime, end_datetime);
|
||||
}
|
||||
|
||||
// Get input date
|
||||
QDateTime inputDate = start_datetime;
|
||||
|
||||
|
@ -401,11 +456,13 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
|
|||
double price_per_unit = 0.0f;
|
||||
QTime worktime_from;
|
||||
QTime worktime_to;
|
||||
double durationUnit = 60.0;
|
||||
|
||||
if(is_special_day)
|
||||
{
|
||||
// Set special day price
|
||||
price_per_unit = Utilities::CalculatePricePerUnit(day_price);
|
||||
// Set price_per_unit to special day price: at the end of the calculation
|
||||
// divide by durationUnit to get correct price.
|
||||
price_per_unit = day_price;
|
||||
worktime_from = QTime::fromString(cfg->SpecialDaysWorktime.find(current_special_day_id)->second.pedwt_time_from.c_str());
|
||||
worktime_to = QTime::fromString(cfg->SpecialDaysWorktime.find(current_special_day_id)->second.pedwt_time_to.c_str());
|
||||
}
|
||||
|
@ -417,8 +474,13 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
|
|||
day_price = cfg->PaymentRate.find(pop_id)->second.pra_price;
|
||||
|
||||
int durationId = cfg->PaymentRate.find(pop_id)->second.pra_payment_unit_id;
|
||||
double durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||
price_per_unit = Utilities::CalculatePricePerUnit(day_price,durationUnit);
|
||||
durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||
if (durationUnit == 0) {
|
||||
durationUnit = 60.0;
|
||||
}
|
||||
// Set price_per_unit to day price: at the end of the calculation
|
||||
// divide by durationUnit to get correct price.
|
||||
price_per_unit = day_price;
|
||||
|
||||
// If no working day found, skip it (recursively call method again)
|
||||
size_t found = 0;
|
||||
|
@ -429,7 +491,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
|
|||
{
|
||||
LOG_DEBUG("- No workday found, trying to find next available day");
|
||||
inputDate = inputDate.addDays(1);
|
||||
return floor(GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, durationMin, true, prepaid));
|
||||
return GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, durationMin, true, prepaid);
|
||||
}
|
||||
worktime_from = QTime::fromString(cfg->WeekDaysWorktime.find(weekdayId)->second.pwd_time_from.c_str());
|
||||
worktime_to = QTime::fromString(cfg->WeekDaysWorktime.find(weekdayId)->second.pwd_time_to.c_str());
|
||||
|
@ -539,5 +601,69 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
|
|||
|
||||
double ret_val = total_cost;
|
||||
total_cost = 0.0f;
|
||||
return ceil(ret_val);
|
||||
return round(ret_val / durationUnit);
|
||||
}
|
||||
|
||||
|
||||
|
||||
QList<int> Calculator::GetTimeSteps(Configuration *cfg) const {
|
||||
QList<int> timeSteps;
|
||||
|
||||
int const pop_id = cfg->getPaymentOptions().pop_id;
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
|
||||
{
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
int const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||
timeSteps << durationUnit;
|
||||
}
|
||||
|
||||
return timeSteps;
|
||||
}
|
||||
|
||||
uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep) const {
|
||||
|
||||
int const pop_id = cfg->getPaymentOptions().pop_id;
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
|
||||
{
|
||||
int const payment_unit_id = itr->second.pra_payment_unit_id;
|
||||
int const pun_id = cfg->Duration.find(payment_unit_id)->second.pun_id;
|
||||
|
||||
Q_ASSERT(pun_id == payment_unit_id);
|
||||
|
||||
int const pun_duration = cfg->Duration.find(payment_unit_id)->second.pun_duration;
|
||||
if (timeStep == pun_duration) {
|
||||
return (uint32_t)(itr->second.pra_price);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* private: read price directly from config file (used with PaymentMethod::Steps)
|
||||
*
|
||||
* return duration in minutes for greatest pra_price < price
|
||||
*/
|
||||
|
||||
uint32_t Calculator::GetDurationForPrice(Configuration *cfg, int price) const {
|
||||
int const pop_id = cfg->getPaymentOptions().pop_id;
|
||||
uint32_t duration = 0;
|
||||
|
||||
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr)
|
||||
{
|
||||
int const durationId = itr->second.pra_payment_unit_id;
|
||||
int const pra_price = itr->second.pra_price;
|
||||
uint32_t const durationUnit = cfg->Duration.find(durationId)->second.pun_duration;
|
||||
|
||||
if (price == pra_price) {
|
||||
return durationUnit;
|
||||
}
|
||||
if (pra_price < price) {
|
||||
duration = durationUnit;
|
||||
}
|
||||
}
|
||||
|
||||
return duration;
|
||||
}
|
||||
|
|
|
@ -59,8 +59,9 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||
|| !document.HasMember("PaymentRate")
|
||||
|| !document.HasMember("Duration")
|
||||
//|| !document.HasMember("WeekDays")
|
||||
|| !document.HasMember("SpecialDaysWorktime")
|
||||
|| !document.HasMember("SpecialDays"))
|
||||
//|| !document.HasMember("SpecialDaysWorktime")
|
||||
//|| !document.HasMember("SpecialDays")
|
||||
)
|
||||
{
|
||||
printf("%s", "Error: not a valid configuration JSON\n");
|
||||
return false;
|
||||
|
@ -87,13 +88,26 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||
const char* mb_name = i->name.GetString();
|
||||
if (mb_name == NULL) continue;
|
||||
|
||||
// if (!document[mb_name].IsArray()) {
|
||||
std::string const _mb_name(mb_name);
|
||||
if (_mb_name == "version" || _mb_name == "project" ||
|
||||
_mb_name == "zone" || _mb_name == "info") {
|
||||
if (document[mb_name].IsString()) {
|
||||
QString const _mb_name(mb_name);
|
||||
if (_mb_name.startsWith("Project", Qt::CaseInsensitive)) {
|
||||
cfg->project.project = document[mb_name].GetString();
|
||||
continue;
|
||||
}
|
||||
if (_mb_name.startsWith("Version", Qt::CaseInsensitive)) {
|
||||
cfg->project.version = document[mb_name].GetString();
|
||||
continue;
|
||||
}
|
||||
// }
|
||||
if (_mb_name.startsWith("Info", Qt::CaseInsensitive)) {
|
||||
cfg->project.info = document[mb_name].GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// ... everything else should be an array
|
||||
if (!document[mb_name].IsArray()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//printf(" -%s\n", mb_name);
|
||||
|
||||
|
@ -155,7 +169,8 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||
else if (strcmp(inner_obj_name, "pop_min_price") == 0) PaymentOption.pop_min_price = k->value.GetDouble();
|
||||
else if (strcmp(inner_obj_name, "pop_carry_over") == 0) PaymentOption.pop_carry_over = k->value.GetInt();
|
||||
else if (strcmp(inner_obj_name, "pop_daily_card_price") == 0) PaymentOption.pop_daily_card_price = k->value.GetInt();
|
||||
break;
|
||||
this->currentPaymentOptions = PaymentOption;
|
||||
break;
|
||||
case MemberType::DurationType:
|
||||
if (strcmp(inner_obj_name, "pun_id") == 0) Duration.pun_id = k->value.GetInt();
|
||||
else if (strcmp(inner_obj_name, "pun_label") == 0) Duration.pun_label = k->value.GetString();
|
||||
|
@ -245,3 +260,10 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const ATBPaymentOption & Configuration::getPaymentOptions()
|
||||
{
|
||||
return this->currentPaymentOptions;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user